Removed unnecessary imports.

This commit is contained in:
Roland Hedberg 2014-12-16 11:12:49 +01:00
parent 68908be4f5
commit 9d0e48b74a
5 changed files with 53 additions and 56 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -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 "<protocol>://<host>/<resource>?<argname>=<argval>&..."
"""
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
"<protocol>://<host>/<resource>?<argname>=<argval>&..."
"""
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