From e090db2d6c0c6e350bac44d717c2938685731d23 Mon Sep 17 00:00:00 2001 From: kaveh Date: Tue, 11 Apr 2017 15:20:37 -0700 Subject: [PATCH] Adds test for OIDC_TEMPLATES settings --- docs/sections/settings.rst | 16 ++++++++++++++++ oidc_provider/tests/test_settings.py | 15 +++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 oidc_provider/tests/test_settings.py diff --git a/docs/sections/settings.rst b/docs/sections/settings.rst index 7893bb2..e60730e 100644 --- a/docs/sections/settings.rst +++ b/docs/sections/settings.rst @@ -186,5 +186,21 @@ Default is:: 'error': 'oidc_provider/error.html' } +The following contexts will be passed to the ``authorize`` and ``error`` templates respectively:: + + # For authorize template + { + 'client': 'an instance of Client for the auth request', + 'hidden_inputs': 'a rendered html with all the hidden inputs needed for AuthorizeEndpoint', + 'params': 'a dict containing the params in the auth request', + 'scopes': 'a list of scopes' + } + + # For error template + { + 'error': 'string stating the error', + 'description': 'string stating description of the error' + } + .. note:: The templates that are not specified here will use the default ones. diff --git a/oidc_provider/tests/test_settings.py b/oidc_provider/tests/test_settings.py new file mode 100644 index 0000000..db6f812 --- /dev/null +++ b/oidc_provider/tests/test_settings.py @@ -0,0 +1,15 @@ +from django.test import TestCase, override_settings + +from oidc_provider import settings + +CUSTOM_TEMPLATES = { + 'authorize': 'custom/authorize.html', + 'error': 'custom/error.html' +} + + +class TokenTest(TestCase): + + @override_settings(OIDC_TEMPLATES=CUSTOM_TEMPLATES) + def test_override_templates(self): + self.assertEqual(settings.get('OIDC_TEMPLATES'), CUSTOM_TEMPLATES)