Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
f1bfa568
Commit
f1bfa568
authored
Oct 21, 2015
by
Braden MacDonald
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up integration tests, test logging in without activation
parent
90cdb913
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
228 additions
and
6 deletions
+228
-6
common/djangoapps/third_party_auth/tests/specs/base.py
+175
-0
common/djangoapps/third_party_auth/tests/specs/test_generic.py
+33
-0
common/djangoapps/third_party_auth/tests/specs/test_testshib.py
+0
-0
common/djangoapps/third_party_auth/tests/testutil.py
+20
-6
No files found.
common/djangoapps/third_party_auth/tests/specs/base.py
View file @
f1bfa568
This diff is collapsed.
Click to expand it.
common/djangoapps/third_party_auth/tests/specs/test_generic.py
0 → 100644
View file @
f1bfa568
"""
Use the 'Dummy' auth provider for generic integration tests of third_party_auth.
"""
import
unittest
from
third_party_auth.tests
import
testutil
from
.base
import
IntegrationTestMixin
@unittest.skipUnless
(
testutil
.
AUTH_FEATURE_ENABLED
,
'third_party_auth not enabled'
)
class
GenericIntegrationTest
(
IntegrationTestMixin
,
testutil
.
TestCase
):
"""
Basic integration tests of third_party_auth using Dummy provider
"""
PROVIDER_ID
=
"oa2-dummy"
PROVIDER_NAME
=
"Dummy"
PROVIDER_BACKEND
=
"dummy"
USER_EMAIL
=
"adama@fleet.colonies.gov"
USER_NAME
=
"William Adama"
USER_USERNAME
=
"Galactica1"
def
setUp
(
self
):
super
(
GenericIntegrationTest
,
self
)
.
setUp
()
self
.
configure_dummy_provider
(
enabled
=
True
)
def
do_provider_login
(
self
,
provider_redirect_url
):
"""
Mock logging in to the Dummy provider
"""
# For the Dummy provider, the provider redirect URL is self.complete_url
self
.
assertEqual
(
provider_redirect_url
,
self
.
url_prefix
+
self
.
complete_url
)
return
self
.
client
.
get
(
provider_redirect_url
)
common/djangoapps/third_party_auth/tests/specs/test_testshib.py
View file @
f1bfa568
This diff is collapsed.
Click to expand it.
common/djangoapps/third_party_auth/tests/testutil.py
View file @
f1bfa568
...
...
@@ -10,6 +10,7 @@ from django.contrib.auth.models import User
from
provider.oauth2.models
import
Client
as
OAuth2Client
from
provider
import
constants
import
django.test
from
mako.template
import
Template
import
mock
import
os.path
...
...
@@ -27,6 +28,18 @@ AUTH_FEATURES_KEY = 'ENABLE_THIRD_PARTY_AUTH'
AUTH_FEATURE_ENABLED
=
AUTH_FEATURES_KEY
in
settings
.
FEATURES
def
patch_mako_templates
():
""" Patch mako so the django test client can access template context """
orig_render
=
Template
.
render_unicode
def
wrapped_render
(
*
args
,
**
kwargs
):
""" Render the template and send the context info to any listeners that want it """
django
.
test
.
signals
.
template_rendered
.
send
(
sender
=
None
,
template
=
None
,
context
=
kwargs
)
return
orig_render
(
*
args
,
**
kwargs
)
return
mock
.
patch
.
multiple
(
Template
,
render_unicode
=
wrapped_render
,
render
=
wrapped_render
)
class
FakeDjangoSettings
(
object
):
"""A fake for Django settings."""
...
...
@@ -110,6 +123,13 @@ class ThirdPartyAuthTestMixin(object):
return
cls
.
configure_oauth_provider
(
**
kwargs
)
@classmethod
def
configure_dummy_provider
(
cls
,
**
kwargs
):
""" Update the settings for the Twitter third party auth provider/backend """
kwargs
.
setdefault
(
"name"
,
"Dummy"
)
kwargs
.
setdefault
(
"backend_name"
,
"dummy"
)
return
cls
.
configure_oauth_provider
(
**
kwargs
)
@classmethod
def
verify_user_email
(
cls
,
email
):
""" Mark the user with the given email as verified """
user
=
User
.
objects
.
get
(
email
=
email
)
...
...
@@ -142,12 +162,6 @@ class SAMLTestCase(TestCase):
"""
Base class for SAML-related third_party_auth tests
"""
def
setUp
(
self
):
super
(
SAMLTestCase
,
self
)
.
setUp
()
self
.
client
.
defaults
[
'SERVER_NAME'
]
=
'example.none'
# The SAML lib we use doesn't like testserver' as a domain
self
.
url_prefix
=
'http://example.none'
@classmethod
def
_get_public_key
(
cls
,
key_name
=
'saml_key'
):
""" Get a public key for use in the test. """
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment