Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ env:
- DJANGO="django>=1.4,<1.5"
- DJANGO="django>=1.5,<1.6"
- DJANGO="django>=1.6,<1.7"
- DJANGO="django>=1.7,<1.8"
python:
- "2.6"
- "2.7"
Expand Down
62 changes: 62 additions & 0 deletions provider/oauth2/fixtures/test_oauth2_17.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
[
{
"fields": {
"redirect_uri": "http://example.com/application/1/",
"client_id": "90a4a24ffefe7ebbae2c",
"client_secret": "35c25066023f32c4f098d1e40de94f07f98c1acf",
"client_type": 0,
"url": "http://example.com/",
"user": 1
},
"model": "provider.client",
"pk": 1
},
{
"fields": {
"redirect_uri": "http://example.com/application/2/",
"client_id": "71fbc29950ac1b386a12",
"client_secret": "1944b695ca0cbf4f419a7d5c7e4fed13a660bc04",
"client_type": 0,
"url": "http://example.com/",
"user": 2
},
"model": "provider.client",
"pk": 2
},
{
"fields": {
"date_joined": "2012-01-23 05:44:17",
"email": "[email protected]",
"first_name": "",
"groups": [],
"is_active": true,
"is_staff": true,
"is_superuser": true,
"last_login": "2012-01-23 05:52:32",
"last_name": "",
"password": "sha1$da29e$498b9faab2d002183bc1d874689634b0e15ad6d7",
"user_permissions": [],
"username": "test-user-1"
},
"model": "auth.user",
"pk": 1
},
{
"fields": {
"date_joined": "2012-01-23 05:53:31",
"email": "",
"first_name": "",
"groups": [],
"is_active": true,
"is_staff": false,
"is_superuser": false,
"last_login": "2012-01-23 05:53:31",
"last_name": "",
"password": "sha1$0cf1b$d66589690edd96b410170fcae5cc2bdfb68821e7",
"user_permissions": [],
"username": "test-user-2"
},
"model": "auth.user",
"pk": 2
}
]
16 changes: 11 additions & 5 deletions provider/oauth2/tests.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import urlparse
import datetime
from django import VERSION as DJANGO_VERSION
from django.http import QueryDict
from django.conf import settings
from django.core.urlresolvers import reverse
Expand All @@ -16,6 +17,11 @@
from .backends import BasicClientBackend, RequestParamsClientBackend
from .backends import AccessTokenBackend

FIXTURES = ['test_oauth2']

if DJANGO_VERSION[0] == 1 and DJANGO_VERSION[1] >= 7:
FIXTURES = ['test_oauth2_17']


@skipIfCustomUser
class BaseOAuth2TestCase(TestCase):
Expand Down Expand Up @@ -59,7 +65,7 @@ def _login_and_authorize(self, url_func=None):


class AuthorizationTest(BaseOAuth2TestCase):
fixtures = ['test_oauth2']
fixtures = FIXTURES

def setUp(self):
self._old_login = settings.LOGIN_URL
Expand Down Expand Up @@ -202,7 +208,7 @@ def test_redirect_requires_valid_data(self):


class AccessTokenTest(BaseOAuth2TestCase):
fixtures = ['test_oauth2.json']
fixtures = FIXTURES

def test_access_token_get_expire_delta_value(self):
user = self.get_user()
Expand Down Expand Up @@ -450,7 +456,7 @@ def test_access_token_response_valid_token_type(self):


class AuthBackendTest(BaseOAuth2TestCase):
fixtures = ['test_oauth2']
fixtures = FIXTURES

def test_basic_client_backend(self):
request = type('Request', (object,), {'META': {}})()
Expand Down Expand Up @@ -482,7 +488,7 @@ def test_access_token_backend(self):


class EnforceSecureTest(BaseOAuth2TestCase):
fixtures = ['test_oauth2']
fixtures = FIXTURES

def setUp(self):
constants.ENFORCE_SECURE = True
Expand Down Expand Up @@ -556,7 +562,7 @@ def test_template_filter(self):


class DeleteExpiredTest(BaseOAuth2TestCase):
fixtures = ['test_oauth2']
fixtures = FIXTURES

def setUp(self):
self._delete_expired = constants.DELETE_EXPIRED
Expand Down
2 changes: 1 addition & 1 deletion test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ DJ_VERSION=$(django-admin.py --version)
# exit if fail
[[ "$?" -ne "0" ]] && exit;

IS_16=$(echo $DJ_VERSION | grep "1.6")
IS_16_OR_17=$(echo $DJ_VERSION | grep -e "1.[67]")

# if django version is not 1.6 (non-0 exit) we have to pass different
# app names to test runner
Expand Down
14 changes: 14 additions & 0 deletions tests/settings.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Django settings for example project.
import os

from django import VERSION as DJANGO_VERSION

DEBUG = True
TEMPLATE_DEBUG = DEBUG

Expand Down Expand Up @@ -60,3 +62,15 @@
'provider.oauth2',
)

MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

# Use DiscoverRunner on Django 1.7 and above
if DJANGO_VERSION[0] == 1 and DJANGO_VERSION[1] >= 7:
TEST_RUNNER = 'django.test.runner.DiscoverRunner'