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
efcc154a
Commit
efcc154a
authored
Aug 21, 2017
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make SiteConfigurationFactory more useable
parent
f79e9da0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
17 deletions
+33
-17
common/djangoapps/third_party_auth/management/commands/tests/test_saml.py
+20
-4
openedx/core/djangoapps/site_configuration/tests/factories.py
+13
-13
No files found.
common/djangoapps/third_party_auth/management/commands/tests/test_saml.py
View file @
efcc154a
...
...
@@ -62,15 +62,25 @@ class TestSAMLCommand(TestCase):
# We are creating SAMLConfiguration instance here so that there is always at-least one
# disabled saml configuration instance, this is done to verify that disabled configurations are
# not processed.
SAMLConfigurationFactory
.
create
(
enabled
=
False
)
SAMLProviderConfigFactory
.
create
()
SAMLConfigurationFactory
.
create
(
enabled
=
False
,
site__domain
=
'testserver.fake'
,
site__name
=
'testserver.fake'
)
SAMLProviderConfigFactory
.
create
(
site__domain
=
'testserver.fake'
,
site__name
=
'testserver.fake'
)
def
__create_saml_configurations__
(
self
,
saml_config
=
None
,
saml_provider_config
=
None
):
"""
Helper method to create SAMLConfiguration and AMLProviderConfig.
"""
SAMLConfigurationFactory
.
create
(
enabled
=
True
,
**
(
saml_config
or
{}))
SAMLProviderConfigFactory
.
create
(
enabled
=
True
,
**
(
saml_provider_config
or
{}))
SAMLConfigurationFactory
.
create
(
enabled
=
True
,
**
(
saml_config
or
{
'site__domain'
:
'testserver.fake'
,
'site__name'
:
'testserver.fake'
}
))
SAMLProviderConfigFactory
.
create
(
enabled
=
True
,
**
(
saml_provider_config
or
{
'site__domain'
:
'testserver.fake'
,
'site__name'
:
'testserver.fake'
}
))
def
test_raises_command_error_for_invalid_arguments
(
self
):
"""
...
...
@@ -137,9 +147,11 @@ class TestSAMLCommand(TestCase):
self
.
__create_saml_configurations__
(
saml_config
=
{
"site__domain"
:
"second.testserver.fake"
,
"site__name"
:
"testserver.fake"
,
},
saml_provider_config
=
{
"site__domain"
:
"second.testserver.fake"
,
"site__name"
:
"testserver.fake"
,
"idp_slug"
:
"second-test-shib"
,
"entity_id"
:
"https://idp.testshib.org/idp/another-shibboleth"
,
"metadata_source"
:
"https://www.testshib.org/metadata/another-testshib-providers.xml"
,
...
...
@@ -150,9 +162,11 @@ class TestSAMLCommand(TestCase):
self
.
__create_saml_configurations__
(
saml_config
=
{
"site__domain"
:
"third.testserver.fake"
,
"site__name"
:
"testserver.fake"
,
},
saml_provider_config
=
{
"site__domain"
:
"third.testserver.fake"
,
"site__name"
:
"testserver.fake"
,
"idp_slug"
:
"third-test-shib"
,
# Note: This entity id will not be present in returned response and will cause failed update.
"entity_id"
:
"https://idp.testshib.org/idp/non-existent-shibboleth"
,
...
...
@@ -169,9 +183,11 @@ class TestSAMLCommand(TestCase):
self
.
__create_saml_configurations__
(
saml_config
=
{
"site__domain"
:
"fourth.testserver.fake"
,
"site__name"
:
"testserver.fake"
,
},
saml_provider_config
=
{
"site__domain"
:
"fourth.testserver.fake"
,
"site__name"
:
"testserver.fake"
,
"idp_slug"
:
"fourth-test-shib"
,
"automatic_refresh_enabled"
:
False
,
# Note: This invalid entity id will not be present in the refresh set
...
...
openedx/core/djangoapps/site_configuration/tests/factories.py
View file @
efcc154a
...
...
@@ -3,30 +3,30 @@ Model factories for unit testing views or models.
"""
from
django.contrib.sites.models
import
Site
from
factory.django
import
DjangoModelFactory
from
factory
import
SubFactory
,
Sequence
,
SelfAttribute
from
openedx.core.djangoapps.site_configuration.models
import
SiteConfiguration
class
Site
Configuration
Factory
(
DjangoModelFactory
):
class
SiteFactory
(
DjangoModelFactory
):
"""
Factory class for Site
Configuration
model
Factory class for Site model
"""
class
Meta
(
object
):
model
=
SiteConfiguration
model
=
Site
django_get_or_create
=
(
'domain'
,)
values
=
{}
enabled
=
True
domain
=
Sequence
(
'testserver.fake.{}'
.
format
)
name
=
SelfAttribute
(
'domain'
)
class
SiteFactory
(
DjangoModelFactory
):
class
Site
Configuration
Factory
(
DjangoModelFactory
):
"""
Factory class for Site model
Factory class for Site
Configuration
model
"""
class
Meta
(
object
):
model
=
Site
django_get_or_create
=
(
'domain'
,)
model
=
SiteConfiguration
# TODO These should be generated. Otherwise, code that creates multiple Site
# objects will only end up with a single Site since domain has a unique constraint.
domain
=
'testserver.fake'
name
=
'testserver.fake'
values
=
{}
enabled
=
True
site
=
SubFactory
(
SiteFactory
)
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