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