diff --git a/tests/test_keyio.py b/tests/test_keyio.py index cf9d917..08224b7 100644 --- a/tests/test_keyio.py +++ b/tests/test_keyio.py @@ -12,8 +12,6 @@ from oic.utils.keyio import RSAKey from jwkest.jws import JWS, NoSuitableSigningKeys, WrongTypeOfKey -from utils_for_tests import _eq - BASE_PATH = os.path.dirname(__file__) RSAKEY = "%s/cert.key" % BASE_PATH diff --git a/tests/test_oauth2.py b/tests/test_oauth2.py index ba6cb31..a8c4fa3 100644 --- a/tests/test_oauth2.py +++ b/tests/test_oauth2.py @@ -7,8 +7,6 @@ import base64 import random import hmac import hashlib -import json -import urllib from oic.oauth2 import Grant from oic.utils import time_util diff --git a/tests/test_oauth2_message.py b/tests/test_oauth2_message.py index 5e09258..80f83b5 100644 --- a/tests/test_oauth2_message.py +++ b/tests/test_oauth2_message.py @@ -147,7 +147,7 @@ def test_authz_req_json_2(): assert ue_obj == expected_ue_obj -def test_authz_req_urlencoded_3(): +def test_authz_req_urlencoded_3b(): ar = AuthorizationRequest(response_type=["token"], client_id="s6BhdRkqt3", redirect_uri="https://client.example.com/cb", @@ -163,7 +163,7 @@ def test_authz_req_urlencoded_3(): assert ue_obj == expected_ue_obj -def test_authz_req_urlencoded_4(): +def test_authz_req_urlencoded_4b(): ar = AuthorizationRequest(response_type=["code"], client_id="foobar") @@ -210,7 +210,7 @@ def test_authz_err_resp_2(): # TokenErrorResponse -def test_authz_err_resp_1(): +def test_authz_err_resp_1b(): ter = TokenErrorResponse(error="access_denied", state="xyz") assert ter @@ -219,7 +219,7 @@ def test_authz_err_resp_1(): assert _eq(ter.keys(), ['state', 'error']) -def test_authz_err_resp_2(): +def test_authz_err_resp_2b(): ter = TokenErrorResponse(error="access_denied", error_description="brewers has a four game series", foo="bar") diff --git a/tests/test_x_dynreg.py b/tests/test_x_dynreg.py index 626158f..61d3824 100644 --- a/tests/test_x_dynreg.py +++ b/tests/test_x_dynreg.py @@ -14,8 +14,6 @@ from oic.oauth2.dynreg import RegistrationRequest from oic.oauth2.dynreg import ClientInfoResponse from oic.oauth2.dynreg import ClientRegistrationError -from utils_for_tests import _eq - CLIENT_CONFIG = { "client_id": "client1", "ca_certs": "/usr/local/etc/oic/ca_certs.txt", diff --git a/tests/utils_for_tests.py b/tests/utils_for_tests.py index de9a0d5..948b6f8 100644 --- a/tests/utils_for_tests.py +++ b/tests/utils_for_tests.py @@ -1,56 +1,59 @@ __author__ = "@maennelpaennel" + def _eq(l1, l2): return set(l1) == set(l2) - + class URLObject(object): - host = '' - resource = '' - arguments = set() + host = '' + resource = '' + arguments = set() - @classmethod - def create(klass, address): - url_obj = klass() - url_obj.set_by_string(address) - return url_obj + @classmethod + def create(klass, address): + url_obj = klass() + url_obj.set_by_string(address) + return url_obj - def __init__(self, host='', resource='', arguments=None): - self.host = host - self.resource = resource - self.arguments = arguments or set() + def __init__(self, host='', resource='', arguments=None): + self.host = host + self.resource = resource + self.arguments = arguments or set() - def __eq__(self, other): - return self.host==other.host and self.resource==other.resource and self.arguments==other.arguments + def __eq__(self, other): + return self.host == other.host and self.resource == other.resource \ + and self.arguments == other.arguments - def set_by_string(self, address): - """ - address has the following format ":///?=&..." - """ - address_splits = address.split('?', 1) - if len(address_splits) == 1: - host_resource = address_splits[0] - arguments_str = '' - else: - host_resource = address_splits[0] - arguments_str = address_splits[1] - self.arguments = set(arguments_str.split('&')) - host_res_splits = host_resource.split('://', 1) - if len(host_res_splits) == 1: - host_resource = host_res_splits[0] - prefix = None - else: - host_resource = host_res_splits[0] - prefix = host_res_splits[1] - host_res_splits = host_resource.split('/', 1) - if len(host_res_splits) == 1: - host = None - resource = host_res_splits[0] - else: - host = host_res_splits[0] - resource = host_res_splits[1] - if host: - self.host = host - if prefix: - self.host = "%s://%s" % (prefix, host) - self.resource = resource + def set_by_string(self, address): + """ + address has the following format + ":///?=&..." + """ + address_splits = address.split('?', 1) + if len(address_splits) == 1: + host_resource = address_splits[0] + arguments_str = '' + else: + host_resource = address_splits[0] + arguments_str = address_splits[1] + self.arguments = set(arguments_str.split('&')) + host_res_splits = host_resource.split('://', 1) + if len(host_res_splits) == 1: + host_resource = host_res_splits[0] + prefix = None + else: + host_resource = host_res_splits[0] + prefix = host_res_splits[1] + host_res_splits = host_resource.split('/', 1) + if len(host_res_splits) == 1: + host = None + resource = host_res_splits[0] + else: + host = host_res_splits[0] + resource = host_res_splits[1] + if host: + self.host = host + if prefix: + self.host = "%s://%s" % (prefix, host) + self.resource = resource