Skip to content

Commit

Permalink
Added a way to run tests and two dummy tests
Browse files Browse the repository at this point in the history
Added login-logic to sso_server
  • Loading branch information
Jonas Obrist committed Aug 10, 2011
1 parent ffcf72f commit a318015
Show file tree
Hide file tree
Showing 9 changed files with 124 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .gitignore
@@ -1,2 +1,6 @@
*.pyc
.*
/build/
/dist/
*.egg-info
/*env*/
24 changes: 24 additions & 0 deletions LICENSE
@@ -0,0 +1,24 @@
Copyright (c) 2011, Jonas Obrist
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Jonas Obrist nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL JONAS OBRIST BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1 change: 1 addition & 0 deletions MANIFEST.in
@@ -0,0 +1 @@
include README.rst LICENSE
50 changes: 50 additions & 0 deletions runtests.py
@@ -0,0 +1,50 @@
# -*- coding: utf-8 -*-
#!/usr/bin/env python
import os
import sys

INSTALLED_APPS = [
'django.contrib.contenttypes',
'django.contrib.auth',
'django.contrib.sessions',
'django.contrib.admin',
'simple_sso.sso_server',
'simple_sso',
]

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':memory:',
}
}

def teardown(state):
from django.conf import settings
# Restore the old settings.
for key, value in state.items():
setattr(settings, key, value)

def run_tests():
from django.conf import settings
settings.configure(
INSTALLED_APPS = INSTALLED_APPS,
ROOT_URLCONF = 'runtests',
DATABASES = DATABASES,
TEST_RUNNER = 'django.test.simple.DjangoTestSuiteRunner',
)

# Run the test suite, including the extra validation tests.
from django.test.utils import get_runner
TestRunner = get_runner(settings)

test_runner = TestRunner(verbosity=1, interactive=False, failfast=False)
failures = test_runner.run_tests(['simple_sso'])
return failures


if __name__ == "__main__":
failures = run_tests()
if failures:
sys.exit(bool(failures))

31 changes: 31 additions & 0 deletions setup.py
@@ -0,0 +1,31 @@
import os
from setuptools import setup
from simple_sso import __version__ as version

README = os.path.join(os.path.dirname(__file__), 'README.rst')

with open(README) as fobj:
long_description = fobj.read()

setup(name="django-simple-sso",
version=version,
description="Simple SSO for Django",
long_description=long_description,
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Topic :: Software Development',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
],
keywords='django sso',
author='Jonas Obrist',
author_email='jonas.obrist@divio.ch',
url='http://github.com/ojii/django-simple-sso',
license='BSD',
packages=['simple_sso', 'simple_sso.sso_client', 'simple_sso.sso_server'],
install_requires=['Django>=1.3', 'django-load'],
include_package_data=True,
zip_safe=False
)
1 change: 1 addition & 0 deletions simple_sso/__init__.py
@@ -0,0 +1 @@
__version__ = '0.1'
1 change: 1 addition & 0 deletions simple_sso/models.py
@@ -0,0 +1 @@
# -*- coding: utf-8 -*-
5 changes: 3 additions & 2 deletions simple_sso/sso_server/views.py
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from django.core.urlresolvers import reverse
from django.http import (HttpResponse, HttpResponseForbidden,
HttpResponseBadRequest, HttpResponseRedirect)
from simple_sso.signatures import build_signature
Expand Down Expand Up @@ -37,8 +38,8 @@ def authorize(request):
token.save()
return HttpResponseRedirect('%s?%s' % (url, urllib.urlencode(params)))
else:
# TODO: Promt login
pass
params = urllib.urlencode([('next', '%s?%s' % (request.path, urllib.urlencode(request.GET)))])
return HttpResponseRedirect('%s?%s' % (reverse('django.contrib.auth.views.login'), params))
else:
if form.invalid_signature:
return HttpResponseForbidden()
Expand Down
9 changes: 9 additions & 0 deletions simple_sso/tests.py
@@ -1 +1,10 @@
# -*- coding: utf-8 -*-
from django.test.testcases import TestCase


class SimpleSSOTests(TestCase):
def test_ok(self):
self.assertTrue(True)

def test_fail(self):
self.assertTrue(False)

0 comments on commit a318015

Please sign in to comment.