diff --git a/setup.cfg b/setup.cfg index 36ee378..8aa0ef4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -4,7 +4,7 @@ optimize = 1 [sdist] formats = bztar,zip -[pytest] +[tool:pytest] norecursedirs = .git .hg .svn build dist [egg_info] diff --git a/suds/version.py b/suds/version.py index 2516680..84f3e50 100644 --- a/suds/version.py +++ b/suds/version.py @@ -22,5 +22,5 @@ """ -__version__ = "0.6.3+affirm" +__version__ = "0.6.4+affirm" __build__ = "" diff --git a/suds/wsse.py b/suds/wsse.py index 2a091d0..bca0cc2 100644 --- a/suds/wsse.py +++ b/suds/wsse.py @@ -139,9 +139,9 @@ def setnonce(self, text=None): s = [] s.append(self.username) s.append(self.password) - s.append(Token.sysdate()) + s.append(Token.sysdate().encode('utf-8')) m = md5() - m.update(':'.join(s)) + m.update(b':'.join(s)) self.nonce = m.hexdigest() else: self.nonce = text diff --git a/tests/indirect_parametrize.py b/tests/indirect_parametrize.py index 4c909c0..7e89fd8 100644 --- a/tests/indirect_parametrize.py +++ b/tests/indirect_parametrize.py @@ -112,6 +112,7 @@ def pytest_configure(config): "argument list and keyword argument dictionary) based on the received " "input data. For more detailed information see the " "indirect_parametrize pytest plugin implementation module.") + pytest.indirect_parametrize = indirect_parametrize_plugin() def pytest_generate_tests(metafunc): @@ -125,6 +126,5 @@ def pytest_generate_tests(metafunc): metafunc.parametrize(*args, **kwargs) -def pytest_namespace(): - """pytest hook publishing references in the toplevel pytest namespace.""" - return {'indirect_parametrize': indirect_parametrize} +def indirect_parametrize_plugin(): + return indirect_parametrize diff --git a/tests/test_wsse.py b/tests/test_wsse.py new file mode 100644 index 0000000..7f3059b --- /dev/null +++ b/tests/test_wsse.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the (LGPL) GNU Lesser General Public License as +# published by the Free Software Foundation; either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Library Lesser General Public License for more details at +# ( http://www.gnu.org/licenses/lgpl.html ). +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# written by: Jurko Gospodnetić ( jurko.gospodnetic@pke.hr ) + +""" +Implemented using the 'pytest' testing framework. +""" + +if __name__ == "__main__": + import __init__ + __init__.runUsingPyTest(globals()) + + +from suds.wsse import UsernameToken + + +class TestUsernameToken: + + username_token = None + + def setup(self): + self.username_token = UsernameToken( + username=b"foouser", + password=b"barpasswd", + ) + + def test_setnonce_null(self): + self.setup() + self.username_token.setnonce() + assert self.username_token.nonce != None + + def test_setnonce_text(self): + self.setup() + self.username_token.setnonce(b"affirm") + assert self.username_token.nonce == b"affirm"