fix: correct bug in sapsf country to code mapping (#32675)

This commit is contained in:
John Nagro
2023-07-06 16:28:38 -04:00
committed by GitHub
parent 7d27a66a60
commit 74e3bb9fd4
2 changed files with 13 additions and 11 deletions

View File

@@ -283,16 +283,18 @@ class SapSuccessFactorsIdentityProvider(EdXSAMLIdentityProvider):
# Define a simple mapping to relate SAPSF values to Open edX-compatible values for
# any given field. By default, this only contains the Country field, as SAPSF supplies
# a country name, which has to be translated to a country code.
default_value_mapping = {
'country': {name: code for code, name in countries}
}
country_mapping = {name: code for code, name in countries}
# Unfortunately, not everything has a 1:1 name mapping between Open edX and SAPSF, so
# we need some overrides. TODO: Fill in necessary mappings
default_value_mapping.update({
country_mapping.update({
'United States': 'US',
})
default_value_mapping = {
'country': country_mapping
}
def get_registration_fields(self, response):
"""
Get a dictionary mapping registration field names to default values.

View File

@@ -534,7 +534,7 @@ class SuccessFactorsIntegrationTest(SamlIntegrationTestUtilities, IntegrationTes
'lastName': 'Smith',
'defaultFullName': 'John Smith',
'email': 'john@smith.com',
'country': 'Australia',
'country': 'United States',
}
})
)
@@ -589,7 +589,7 @@ class SuccessFactorsIntegrationTest(SamlIntegrationTestUtilities, IntegrationTes
what we're looking for, and when an empty override is provided (expected behavior is that
existing value maps will be left alone).
"""
expected_country = 'AU'
expected_country = 'US'
provider_settings = {
'sapsf_oauth_root_url': 'http://successfactors.com/oauth/',
'sapsf_private_key': 'fake_private_key_here',
@@ -632,7 +632,7 @@ class SuccessFactorsIntegrationTest(SamlIntegrationTestUtilities, IntegrationTes
'firstName': 'John',
'lastName': 'Smith',
'defaultFullName': 'John Smith',
'country': 'Australia'
'country': 'United States'
}
})
)
@@ -666,7 +666,7 @@ class SuccessFactorsIntegrationTest(SamlIntegrationTestUtilities, IntegrationTes
what we're looking for, and when an empty override is provided (expected behavior is that
existing value maps will be left alone).
"""
value_map = {'country': {'Australia': 'NZ'}}
value_map = {'country': {'United States': 'NZ'}}
expected_country = 'NZ'
provider_settings = {
'sapsf_oauth_root_url': 'http://successfactors.com/oauth/',
@@ -695,8 +695,8 @@ class SuccessFactorsIntegrationTest(SamlIntegrationTestUtilities, IntegrationTes
what we're looking for, and when an empty override is provided (expected behavior is that
existing value maps will be left alone).
"""
value_map = {'country': {'United States': 'blahfake'}}
expected_country = 'AU'
value_map = {'country': {'Australia': 'blahfake'}}
expected_country = 'US'
provider_settings = {
'sapsf_oauth_root_url': 'http://successfactors.com/oauth/',
'sapsf_private_key': 'fake_private_key_here',
@@ -726,7 +726,7 @@ class SuccessFactorsIntegrationTest(SamlIntegrationTestUtilities, IntegrationTes
"""
value_map = {'country': {}}
expected_country = 'AU'
expected_country = 'US'
provider_settings = {
'sapsf_oauth_root_url': 'http://successfactors.com/oauth/',
'sapsf_private_key': 'fake_private_key_here',