1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-31 15:21:13 +03:00

Merge pull request #2632 from chrismeyersfsu/fix-saml_admin_attr

fix saml_admin_attr
This commit is contained in:
Chris Meyers 2018-07-23 12:06:02 -04:00 committed by GitHub
commit 90fba9381d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 1 deletions

View File

@ -1213,7 +1213,7 @@ register(
category=_('SAML'),
category_slug='saml',
placeholder=collections.OrderedDict([
('saml_attr', 'organization'),
('saml_attr', 'team'),
('remove', True),
('team_org_map', [
collections.OrderedDict([

View File

@ -757,6 +757,8 @@ class SAMLOrgAttrField(BaseDictWithChildField):
child_fields = {
'remove': fields.BooleanField(required=False),
'saml_attr': fields.CharField(required=False, allow_null=True),
'remove_admins': fields.BooleanField(required=False),
'saml_admin_attr': fields.CharField(required=False, allow_null=True),
}

View File

@ -20,6 +20,11 @@ class TestSAMLOrgAttrField():
({'remove': True, 'saml_attr': 3.14}, {'remove': True, 'saml_attr': '3.14'}),
({'saml_attr': 'foobar'}, {'saml_attr': 'foobar'}),
({'remove': True}, {'remove': True}),
({'remove': True, 'saml_admin_attr': 'foobar'}, {'remove': True, 'saml_admin_attr': 'foobar'}),
({'saml_admin_attr': 'foobar'}, {'saml_admin_attr': 'foobar'}),
({'remove_admins': True, 'saml_admin_attr': 'foobar'}, {'remove_admins': True, 'saml_admin_attr': 'foobar'}),
({'remove': True, 'saml_attr': 'foo', 'remove_admins': True, 'saml_admin_attr': 'bar'},
{'remove': True, 'saml_attr': 'foo', 'remove_admins': True, 'saml_admin_attr': 'bar'}),
])
def test_internal_value_valid(self, data, expected):
field = SAMLOrgAttrField()
@ -33,6 +38,10 @@ class TestSAMLOrgAttrField():
ValidationError('Not a valid string.')),
({'remove': True, 'saml_attr': False, 'foo': 'bar', 'gig': 'ity'},
ValidationError('Invalid key(s): "gig", "foo".')),
({'remove_admins': True, 'saml_admin_attr': False},
ValidationError('Not a valid string.')),
({'remove_admins': 'blah', 'saml_admin_attr': 'foobar'},
ValidationError('"blah" is not a valid boolean.')),
])
def test_internal_value_invalid(self, data, expected):
field = SAMLOrgAttrField()