fix saml_admin_attr

This commit is contained in:
chris meyers
2018-07-20 16:31:33 -04:00
parent 32c2e36ac4
commit 3fcd1575c1
3 changed files with 12 additions and 1 deletions

View File

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

View File

@@ -757,6 +757,8 @@ class SAMLOrgAttrField(BaseDictWithChildField):
child_fields = { child_fields = {
'remove': fields.BooleanField(required=False), 'remove': fields.BooleanField(required=False),
'saml_attr': fields.CharField(required=False, allow_null=True), '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'}), ({'remove': True, 'saml_attr': 3.14}, {'remove': True, 'saml_attr': '3.14'}),
({'saml_attr': 'foobar'}, {'saml_attr': 'foobar'}), ({'saml_attr': 'foobar'}, {'saml_attr': 'foobar'}),
({'remove': True}, {'remove': True}), ({'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): def test_internal_value_valid(self, data, expected):
field = SAMLOrgAttrField() field = SAMLOrgAttrField()
@@ -33,6 +38,10 @@ class TestSAMLOrgAttrField():
ValidationError('Not a valid string.')), ValidationError('Not a valid string.')),
({'remove': True, 'saml_attr': False, 'foo': 'bar', 'gig': 'ity'}, ({'remove': True, 'saml_attr': False, 'foo': 'bar', 'gig': 'ity'},
ValidationError('Invalid key(s): "gig", "foo".')), 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): def test_internal_value_invalid(self, data, expected):
field = SAMLOrgAttrField() field = SAMLOrgAttrField()