feat: associate name to username in saml config

This commit is contained in:
Kira
2022-01-11 09:19:37 -05:00
parent 0e9499de7d
commit 4d1275a521
2 changed files with 5 additions and 1 deletions

View File

@@ -22,7 +22,8 @@ class SAMLProviderConfigSerializer(serializers.ModelSerializer): # lint-amnesty
saml_configuration = SAMLConfiguration.objects.current_set().get(id=validated_data['saml_config_id'])
del validated_data['saml_config_id']
validated_data['saml_configuration'] = saml_configuration
if validated_data.get('attr_first_name'):
validated_data['attr_username'] = validated_data['attr_first_name']
return SAMLProviderConfig.objects.create(**validated_data)
def update(self, instance, validated_data):

View File

@@ -25,6 +25,8 @@ SINGLE_PROVIDER_CONFIG = {
'enabled': 'true',
'slug': 'test-slug',
'country': 'https://example.customer.com/countrycode',
'attr_first_name': 'jon',
'attr_last_name': 'snow',
}
SINGLE_PROVIDER_CONFIG_2 = copy.copy(SINGLE_PROVIDER_CONFIG)
@@ -144,6 +146,7 @@ class SAMLProviderConfigTests(APITestCase):
provider_config = SAMLProviderConfig.objects.get(slug=SINGLE_PROVIDER_CONFIG_2['slug'])
assert provider_config.name == 'name-of-config-2'
assert provider_config.country == SINGLE_PROVIDER_CONFIG_2['country']
assert provider_config.attr_username == SINGLE_PROVIDER_CONFIG['attr_first_name']
# check association has also been created
assert EnterpriseCustomerIdentityProvider.objects.filter(