jplana / python-etcd

A python client for etcd
Other
520 stars 210 forks source link

auth tests are failed #251

Closed stanislavlevin closed 6 years ago

stanislavlevin commented 6 years ago

Using command: python -m pytest --verbose --pdb

There are several auth test fails: 1) EtcdUserTest::test_names FAILED

running pytest
running egg_info
writing requirements to src/python_etcd.egg-info/requires.txt
writing src/python_etcd.egg-info/PKG-INFO
writing top-level names to src/python_etcd.egg-info/top_level.txt
writing dependency_links to src/python_etcd.egg-info/dependency_links.txt
reading manifest file 'src/python_etcd.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'src/python_etcd.egg-info/SOURCES.txt'
running build_ext
========================================== test session starts ==========================================
platform linux2 -- Python 2.7.11, pytest-3.2.1, py-1.4.34, pluggy-0.4.0 -- /usr/bin/python
cachedir: .cache
rootdir: /usr/src/RPM/BUILD/python-module-etcd-0.4.5, inifile:
collected 149 items                                                                                      

src/etcd/tests/test_auth.py::EtcdUserTest::test_names FAILED
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> traceback >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

self = <etcd.tests.test_auth.EtcdUserTest testMethod=test_names>

    def test_names(self):
        u = auth.EtcdUser(self.client, 'test_user')
>       self.assertEquals(u.names, ['root'])
E       AssertionError: Lists differ: [{u'user': u'root', u'roles': ... != ['root']
E       
E       First differing element 0:
E       {u'user': u'root', u'roles': [{u'role': u'root', u'permissions': {u'kv': {u'read': [u'/*'], u'write': [u'/*']}}}]}
E       root
E       
E       + ['root']
E       - [{u'roles': [{u'permissions': {u'kv': {u'read': [u'/*'],
E       -                                        u'write': [u'/*']}},
E       -               u'role': u'root'}],
E       -   u'user': u'root'}]

src/etcd/tests/test_auth.py:38: AssertionError
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> entering PDB >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> /usr/lib64/python2.7/unittest/case.py(410)fail()
-> raise self.failureException(msg)

2) EtcdUserTest::test_read FAILED

src/etcd/tests/test_auth.py::EtcdUserTest::test_read FAILED
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> traceback >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

self = <etcd.tests.test_auth.EtcdUserTest testMethod=test_read>

    def setUp(self):
        # Sets up the root user, toggles auth
        u = auth.EtcdUser(self.client, 'root')
        u.password = 'testpass'
>       u.write()

src/etcd/tests/test_auth.py:13: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
src/etcd/auth.py:46: in write
    r.read()
src/etcd/auth.py:27: in read
    response = self.client.api_execute(self.uri, self.client._MGET)
src/etcd/client.py:907: in wrapper
    return self._handle_server_response(response)
src/etcd/client.py:987: in _handle_server_response
    etcd.EtcdError.handle(r)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

cls = <class 'etcd.EtcdError'>, payload = {'message': 'Insufficient credentials', 'status': 401}

    @classmethod
    def handle(cls, payload):
        """
            Decodes the error and throws the appropriate error message

            :param payload: The decoded JSON error payload as a dict.
            """
        error_code = payload.get("errorCode")
        message = payload.get("message")
        cause = payload.get("cause")
        msg = '{} : {}'.format(message, cause)
        status = payload.get("status")
        # Some general status handling, as
        # not all endpoints return coherent error messages
        if status == 404:
            error_code = 100
        elif status == 401:
            error_code = 110
        exc = cls.error_exceptions.get(error_code, EtcdException)
        if issubclass(exc, EtcdException):
>           raise exc(msg, payload)
E           EtcdInsufficientPermissions: Insufficient credentials : None

src/etcd/__init__.py:306: EtcdInsufficientPermissions
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> entering PDB >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> /usr/src/RPM/BUILD/python-module-etcd-0.4.5/src/etcd/__init__.py(306)handle()
-> raise exc(msg, payload)

3) EtcdUserTest::test_write_and_delete FAILED

src/etcd/tests/test_auth.py::EtcdUserTest::test_write_and_delete FAILED
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> traceback >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

self = <etcd.tests.test_auth.EtcdUserTest testMethod=test_write_and_delete>

    def setUp(self):
        # Sets up the root user, toggles auth
        u = auth.EtcdUser(self.client, 'root')
        u.password = 'testpass'
>       u.write()

src/etcd/tests/test_auth.py:13: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
src/etcd/auth.py:46: in write
    r.read()
src/etcd/auth.py:27: in read
    response = self.client.api_execute(self.uri, self.client._MGET)
src/etcd/client.py:907: in wrapper
    return self._handle_server_response(response)
src/etcd/client.py:987: in _handle_server_response
    etcd.EtcdError.handle(r)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

cls = <class 'etcd.EtcdError'>, payload = {'message': 'Insufficient credentials', 'status': 401}

    @classmethod
    def handle(cls, payload):
        """
            Decodes the error and throws the appropriate error message

            :param payload: The decoded JSON error payload as a dict.
            """
        error_code = payload.get("errorCode")
        message = payload.get("message")
        cause = payload.get("cause")
        msg = '{} : {}'.format(message, cause)
        status = payload.get("status")
        # Some general status handling, as
        # not all endpoints return coherent error messages
        if status == 404:
            error_code = 100
        elif status == 401:
            error_code = 110
        exc = cls.error_exceptions.get(error_code, EtcdException)
        if issubclass(exc, EtcdException):
>           raise exc(msg, payload)
E           EtcdInsufficientPermissions: Insufficient credentials : None

src/etcd/__init__.py:306: EtcdInsufficientPermissions
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> entering PDB >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> /usr/src/RPM/BUILD/python-module-etcd-0.4.5/src/etcd/__init__.py(306)handle()
-> raise exc(msg, payload)

4) EtcdRoleTest::test_names FAILED

src/etcd/tests/test_auth.py::EtcdRoleTest::test_names FAILED
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> traceback >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

self = <etcd.tests.test_auth.EtcdRoleTest testMethod=test_names>

    def test_names(self):
        r = auth.EtcdRole(self.client, 'guest')
>       self.assertListEqual(r.names, [u'guest', u'root'])
E       AssertionError: Lists differ: [{u'role': u'guest', u'permiss... != [u'guest', u'root']
E       
E       First differing element 0:
E       {u'role': u'guest', u'permissions': {u'kv': {u'read': [u'/*'], u'write': [u'/*']}}}
E       guest
E       
E       + [u'guest', u'root']
E       - [{u'permissions': {u'kv': {u'read': [u'/*'], u'write': [u'/*']}},
E       -   u'role': u'guest'},
E       -  {u'permissions': {u'kv': {u'read': [u'/*'], u'write': [u'/*']}},
E       -   u'role': u'root'}]

src/etcd/tests/test_auth.py:121: AssertionError
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> entering PDB >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> /usr/lib64/python2.7/unittest/case.py(410)fail()
-> raise self.failureException(msg)

5) EtcdRoleTest::test_read FAILED

src/etcd/tests/test_auth.py::EtcdRoleTest::test_read FAILED
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> traceback >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

self = <etcd.tests.test_auth.EtcdRoleTest testMethod=test_read>

    def setUp(self):
        # Sets up the root user, toggles auth
        u = auth.EtcdUser(self.client, 'root')
        u.password = 'testpass'
>       u.write()

src/etcd/tests/test_auth.py:13: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
src/etcd/auth.py:46: in write
    r.read()
src/etcd/auth.py:27: in read
    response = self.client.api_execute(self.uri, self.client._MGET)
src/etcd/client.py:907: in wrapper
    return self._handle_server_response(response)
src/etcd/client.py:987: in _handle_server_response
    etcd.EtcdError.handle(r)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

cls = <class 'etcd.EtcdError'>, payload = {'message': 'Insufficient credentials', 'status': 401}

    @classmethod
    def handle(cls, payload):
        """
            Decodes the error and throws the appropriate error message

            :param payload: The decoded JSON error payload as a dict.
            """
        error_code = payload.get("errorCode")
        message = payload.get("message")
        cause = payload.get("cause")
        msg = '{} : {}'.format(message, cause)
        status = payload.get("status")
        # Some general status handling, as
        # not all endpoints return coherent error messages
        if status == 404:
            error_code = 100
        elif status == 401:
            error_code = 110
        exc = cls.error_exceptions.get(error_code, EtcdException)
        if issubclass(exc, EtcdException):
>           raise exc(msg, payload)
E           EtcdInsufficientPermissions: Insufficient credentials : None

src/etcd/__init__.py:306: EtcdInsufficientPermissions
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> entering PDB >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> /usr/src/RPM/BUILD/python-module-etcd-0.4.5/src/etcd/__init__.py(306)handle()
-> raise exc(msg, payload)

6) EtcdRoleTest::test_write_and_delete FAILED

src/etcd/tests/test_auth.py::EtcdRoleTest::test_write_and_delete FAILED
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> traceback >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

self = <etcd.tests.test_auth.EtcdRoleTest testMethod=test_write_and_delete>

    def setUp(self):
        # Sets up the root user, toggles auth
        u = auth.EtcdUser(self.client, 'root')
        u.password = 'testpass'
>       u.write()

src/etcd/tests/test_auth.py:13: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
src/etcd/auth.py:46: in write
    r.read()
src/etcd/auth.py:27: in read
    response = self.client.api_execute(self.uri, self.client._MGET)
src/etcd/client.py:907: in wrapper
    return self._handle_server_response(response)
src/etcd/client.py:987: in _handle_server_response
    etcd.EtcdError.handle(r)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

cls = <class 'etcd.EtcdError'>, payload = {'message': 'Insufficient credentials', 'status': 401}

    @classmethod
    def handle(cls, payload):
        """
            Decodes the error and throws the appropriate error message

            :param payload: The decoded JSON error payload as a dict.
            """
        error_code = payload.get("errorCode")
        message = payload.get("message")
        cause = payload.get("cause")
        msg = '{} : {}'.format(message, cause)
        status = payload.get("status")
        # Some general status handling, as
        # not all endpoints return coherent error messages
        if status == 404:
            error_code = 100
        elif status == 401:
            error_code = 110
        exc = cls.error_exceptions.get(error_code, EtcdException)
        if issubclass(exc, EtcdException):
>           raise exc(msg, payload)
E           EtcdInsufficientPermissions: Insufficient credentials : None

src/etcd/__init__.py:306: EtcdInsufficientPermissions
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> entering PDB >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> /usr/src/RPM/BUILD/python-module-etcd-0.4.5/src/etcd/__init__.py(306)handle()
-> raise exc(msg, payload)

All the others have been PASSED.

6 failed, 143 passed, 1 warnings

etcd version is 3.2.5. python-etcd version is 0.4.5.

stanislavlevin commented 6 years ago

With fixes from master branch 7f3dd65e5dc79cc456ef58a052501ec256d5070b all tests are OK.