Permalink
Browse files

Added a way to run tests and two dummy tests

Added login-logic to sso_server
  • Loading branch information...
1 parent ffcf72f commit a3180155fd55b04c84365d1e04b4e50a5335acf8 Jonas Obrist committed Aug 10, 2011
Showing with 124 additions and 2 deletions.
  1. +4 −0 .gitignore
  2. +24 −0 LICENSE
  3. +1 −0 MANIFEST.in
  4. +50 −0 runtests.py
  5. +31 −0 setup.py
  6. +1 −0 simple_sso/__init__.py
  7. +1 −0 simple_sso/models.py
  8. +3 −2 simple_sso/sso_server/views.py
  9. +9 −0 simple_sso/tests.py
View
@@ -1,2 +1,6 @@
*.pyc
.*
+/build/
+/dist/
+*.egg-info
+/*env*/
View
@@ -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.
View
@@ -0,0 +1 @@
+include README.rst LICENSE
View
@@ -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))
+
View
@@ -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
+)
@@ -0,0 +1 @@
+__version__ = '0.1'
@@ -0,0 +1 @@
+# -*- coding: utf-8 -*-
@@ -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
@@ -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()
View
@@ -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.