ENH adding country to SAML mapping config
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 2.2.14 on 2020-07-21 19:08
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('third_party_auth', '0001_squashed_0026_auto_20200401_1932'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='samlproviderconfig',
|
||||
name='country',
|
||||
field=models.CharField(blank=True, help_text=('String representation of the mapping between user`s IDP and edx`s country field.',), max_length=255),
|
||||
),
|
||||
]
|
||||
@@ -618,6 +618,13 @@ class SAMLProviderConfig(ProviderConfig):
|
||||
"This is helpful for testing/setup but should always be disabled before users start using this provider."
|
||||
),
|
||||
)
|
||||
country = models.CharField(
|
||||
max_length=255,
|
||||
help_text=(
|
||||
u'String representation of the mapping between user`s IDP and edx`s country field.',
|
||||
),
|
||||
blank=True,
|
||||
)
|
||||
other_settings = models.TextField(
|
||||
verbose_name=u"Advanced settings", blank=True,
|
||||
help_text=(
|
||||
|
||||
@@ -23,7 +23,8 @@ SINGLE_PROVIDER_CONFIG = {
|
||||
'metadata_source': 'http://test.url',
|
||||
'name': 'name-of-config',
|
||||
'enabled': 'true',
|
||||
'slug': 'test-slug'
|
||||
'slug': 'test-slug',
|
||||
'country': 'https:://example.customer.com/countrycode'
|
||||
}
|
||||
|
||||
SINGLE_PROVIDER_CONFIG_2 = copy.copy(SINGLE_PROVIDER_CONFIG)
|
||||
@@ -54,7 +55,8 @@ class SAMLProviderConfigTests(APITestCase):
|
||||
cls.samlproviderconfig, _ = SAMLProviderConfig.objects.get_or_create(
|
||||
entity_id=SINGLE_PROVIDER_CONFIG['entity_id'],
|
||||
metadata_source=SINGLE_PROVIDER_CONFIG['metadata_source'],
|
||||
slug=SINGLE_PROVIDER_CONFIG['slug']
|
||||
slug=SINGLE_PROVIDER_CONFIG['slug'],
|
||||
country=SINGLE_PROVIDER_CONFIG['country'],
|
||||
)
|
||||
|
||||
def setUp(self):
|
||||
@@ -82,6 +84,7 @@ class SAMLProviderConfigTests(APITestCase):
|
||||
self.assertEqual(len(results), 1)
|
||||
self.assertEqual(results[0]['entity_id'], SINGLE_PROVIDER_CONFIG['entity_id'])
|
||||
self.assertEqual(results[0]['metadata_source'], SINGLE_PROVIDER_CONFIG['metadata_source'])
|
||||
self.assertEqual(response.data['results'][0]['country'], SINGLE_PROVIDER_CONFIG['country'])
|
||||
self.assertEqual(SAMLProviderConfig.objects.count(), 1)
|
||||
|
||||
def test_get_one_config_by_enterprise_uuid_invalid_uuid(self):
|
||||
@@ -131,6 +134,7 @@ class SAMLProviderConfigTests(APITestCase):
|
||||
self.assertEqual(SAMLProviderConfig.objects.count(), orig_count + 1)
|
||||
provider_config = SAMLProviderConfig.objects.get(slug=SINGLE_PROVIDER_CONFIG_2['slug'])
|
||||
self.assertEqual(provider_config.name, 'name-of-config-2')
|
||||
self.assertEqual(provider_config.country, SINGLE_PROVIDER_CONFIG_2['country'])
|
||||
|
||||
# check association has also been created
|
||||
self.assertTrue(
|
||||
|
||||
Reference in New Issue
Block a user