Skip to content

Commit

Permalink
Merge pull request #4 from Affirm/Affirm/make_set_nonce_py3_compatible
Browse files Browse the repository at this point in the history
Make set_nonce py3 compatible
  • Loading branch information
alimpon authored Nov 4, 2020
2 parents c49a8d2 + 4c0525c commit 14f50b3
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 7 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ optimize = 1
[sdist]
formats = bztar,zip

[pytest]
[tool:pytest]
norecursedirs = .git .hg .svn build dist

[egg_info]
Expand Down
2 changes: 1 addition & 1 deletion suds/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@
"""

__version__ = "0.6.3+affirm"
__version__ = "0.6.4+affirm"
__build__ = ""
4 changes: 2 additions & 2 deletions suds/wsse.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions tests/indirect_parametrize.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
49 changes: 49 additions & 0 deletions tests/test_wsse.py
Original file line number Diff line number Diff line change
@@ -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ć ( [email protected] )

"""
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"

0 comments on commit 14f50b3

Please sign in to comment.