Merge branch 'fix-import-all' of https://github.com/grahamu/django-oidc-provider into grahamu-fix-import-all

This commit is contained in:
Ignacio Fiorentino 2016-08-12 12:02:48 -03:00
commit d35f16eeae
11 changed files with 103 additions and 35 deletions

View file

@ -1,3 +1,4 @@
from datetime import timedelta
import logging
try:
from urllib import urlencode
@ -8,10 +9,22 @@ except ImportError:
from django.utils import timezone
from oidc_provider.lib.claims import StandardScopeClaims
from oidc_provider.lib.errors import *
from oidc_provider.lib.utils.params import *
from oidc_provider.lib.utils.token import *
from oidc_provider.models import *
from oidc_provider.lib.errors import (
AuthorizeError,
ClientIdError,
RedirectUriError,
)
from oidc_provider.lib.utils.params import Params
from oidc_provider.lib.utils.token import (
create_code,
create_id_token,
create_token,
encode_id_token,
)
from oidc_provider.models import (
Client,
UserConsent,
)
from oidc_provider import settings

View file

@ -9,10 +9,20 @@ except ImportError:
from django.http import JsonResponse
from oidc_provider.lib.errors import *
from oidc_provider.lib.utils.params import *
from oidc_provider.lib.utils.token import *
from oidc_provider.models import *
from oidc_provider.lib.errors import (
TokenError,
)
from oidc_provider.lib.utils.params import Params
from oidc_provider.lib.utils.token import (
create_id_token,
create_token,
encode_id_token,
)
from oidc_provider.models import (
Client,
Code,
Token,
)
from oidc_provider import settings

View file

@ -9,7 +9,11 @@ from jwkest.jwk import SYMKey
from jwkest.jws import JWS
from oidc_provider.lib.utils.common import get_issuer
from oidc_provider.models import *
from oidc_provider.models import (
Code,
RSAKey,
Token,
)
from oidc_provider import settings

View file

@ -1,4 +1,3 @@
import os
import random
import string
try:
@ -8,7 +7,10 @@ except ImportError:
from django.contrib.auth.models import User
from oidc_provider.models import *
from oidc_provider.models import (
Client,
Code,
)
FAKE_NONCE = 'cb584e44c43ed6bd0bc2d9c7e242837d'

View file

@ -16,9 +16,13 @@ from django.test import TestCase
from jwkest.jwt import JWT
from oidc_provider import settings
from oidc_provider.models import *
from oidc_provider.tests.app.utils import *
from oidc_provider.views import *
from oidc_provider.tests.app.utils import (
create_fake_user,
create_fake_client,
FAKE_CODE_CHALLENGE,
is_code_valid,
)
from oidc_provider.views import AuthorizeView
class AuthorizationCodeFlowTestCase(TestCase):

View file

@ -1,8 +1,7 @@
from django.core.urlresolvers import reverse
from django.test import TestCase
from oidc_provider.views import *
from oidc_provider.tests.app.utils import *
from oidc_provider.tests.app.utils import create_fake_user
class UserInfoTestCase(TestCase):

View file

@ -2,7 +2,7 @@ from django.core.urlresolvers import reverse
from django.test import RequestFactory
from django.test import TestCase
from oidc_provider.views import *
from oidc_provider.views import ProviderInfoView
class ProviderInfoTestCase(TestCase):
@ -23,4 +23,4 @@ class ProviderInfoTestCase(TestCase):
self.assertEqual(response.status_code, 200)
self.assertEqual(response['Content-Type'] == 'application/json', True)
self.assertEqual(bool(response.content), True)
self.assertEqual(bool(response.content), True)

View file

@ -1,3 +1,7 @@
from datetime import timedelta
import json
import uuid
from base64 import b64encode
try:
from urllib.parse import urlencode
@ -5,15 +9,30 @@ except ImportError:
from urllib import urlencode
from django.core.management import call_command
from django.core.urlresolvers import reverse
from django.test import RequestFactory, override_settings
from django.test import TestCase
from django.utils import timezone
from jwkest.jwk import KEYS
from jwkest.jws import JWS
from jwkest.jwt import JWT
from mock import patch
from oidc_provider.lib.utils.token import *
from oidc_provider.tests.app.utils import *
from oidc_provider.views import *
from oidc_provider.lib.utils.token import create_code
from oidc_provider.models import Token
from oidc_provider.tests.app.utils import (
create_fake_user,
create_fake_client,
FAKE_CODE_CHALLENGE,
FAKE_CODE_VERIFIER,
FAKE_NONCE,
FAKE_RANDOM_STRING,
)
from oidc_provider.views import (
JwksView,
TokenView,
userinfo,
)
class TokenTestCase(TestCase):
@ -208,14 +227,14 @@ class TokenTestCase(TestCase):
response = TokenView.as_view()(request)
self.assertEqual(response.status_code == 405, True,
msg=request.method+' request does not return a 405 status.')
msg=request.method + ' request does not return a 405 status.')
request = self.factory.post(url)
response = TokenView.as_view()(request)
self.assertEqual(response.status_code == 400, True,
msg=request.method+' request does not return a 400 status.')
msg=request.method + ' request does not return a 400 status.')
def test_client_authentication(self):
"""
@ -238,7 +257,7 @@ class TokenTestCase(TestCase):
# Now, test with an invalid client_id.
invalid_data = post_data.copy()
invalid_data['client_id'] = self.client.client_id * 2 # Fake id.
invalid_data['client_id'] = self.client.client_id * 2 # Fake id.
# Create another grant code.
code = self._create_code()
@ -264,8 +283,8 @@ class TokenTestCase(TestCase):
user_pass = self.client.client_id + ':' + self.client.client_secret
auth_header = b'Basic ' + b64encode(user_pass.encode('utf-8'))
response = self._post_request(basicauth_data, {
'HTTP_AUTHORIZATION': auth_header.decode('utf-8'),
})
'HTTP_AUTHORIZATION': auth_header.decode('utf-8'),
})
response.content.decode('utf-8')
self.assertEqual('invalid_client' in response.content.decode('utf-8'),
@ -326,7 +345,7 @@ class TokenTestCase(TestCase):
the JOSE Header.
"""
SIGKEYS = self._get_keys()
RSAKEYS = [ k for k in SIGKEYS if k.kty == 'RSA' ]
RSAKEYS = [k for k in SIGKEYS if k.kty == 'RSA']
code = self._create_code()

View file

@ -1,3 +1,5 @@
import json
from datetime import timedelta
try:
from urllib.parse import urlencode
@ -9,9 +11,15 @@ from django.test import RequestFactory
from django.test import TestCase
from django.utils import timezone
from oidc_provider.lib.utils.token import *
from oidc_provider.models import *
from oidc_provider.tests.app.utils import *
from oidc_provider.lib.utils.token import (
create_id_token,
create_token,
)
from oidc_provider.tests.app.utils import (
create_fake_user,
create_fake_client,
FAKE_NONCE,
)
from oidc_provider.views import userinfo

View file

@ -1,3 +1,5 @@
import logging
from Crypto.PublicKey import RSA
from django.contrib.auth.views import redirect_to_login, logout
from django.core.urlresolvers import reverse
@ -9,9 +11,14 @@ from django.views.generic import View
from jwkest import long_to_base64
from oidc_provider.lib.claims import StandardScopeClaims
from oidc_provider.lib.endpoints.authorize import *
from oidc_provider.lib.endpoints.token import *
from oidc_provider.lib.errors import *
from oidc_provider.lib.endpoints.authorize import AuthorizeEndpoint
from oidc_provider.lib.endpoints.token import TokenEndpoint
from oidc_provider.lib.errors import (
AuthorizeError,
ClientIdError,
RedirectUriError,
TokenError,
)
from oidc_provider.lib.utils.common import redirect, get_site_url, get_issuer
from oidc_provider.lib.utils.oauth2 import protected_resource_view
from oidc_provider.models import RESPONSE_TYPE_CHOICES, RSAKey

View file

@ -98,11 +98,13 @@ def runtests(*test_args):
try:
from django.test.runner import DiscoverRunner
runner_class = DiscoverRunner
test_args = ["oidc_provider.tests"]
if not test_args:
test_args = ["oidc_provider.tests"]
except ImportError:
from django.test.simple import DjangoTestSuiteRunner
runner_class = DjangoTestSuiteRunner
test_args = ["tests"]
if not test_args:
test_args = ["tests"]
failures = runner_class(verbosity=1, interactive=True, failfast=False).run_tests(test_args)
sys.exit(failures)