From 3fcd1575c1abfef8b5433cdb28fcdc41b2957ef7 Mon Sep 17 00:00:00 2001 From: chris meyers Date: Fri, 20 Jul 2018 16:31:33 -0400 Subject: [PATCH] fix saml_admin_attr --- awx/sso/conf.py | 2 +- awx/sso/fields.py | 2 ++ awx/sso/tests/unit/test_fields.py | 9 +++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/awx/sso/conf.py b/awx/sso/conf.py index c9393160b2..3dbe8d267c 100644 --- a/awx/sso/conf.py +++ b/awx/sso/conf.py @@ -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([ diff --git a/awx/sso/fields.py b/awx/sso/fields.py index c31591beb7..a240e368aa 100644 --- a/awx/sso/fields.py +++ b/awx/sso/fields.py @@ -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), } diff --git a/awx/sso/tests/unit/test_fields.py b/awx/sso/tests/unit/test_fields.py index 1113665241..f6afabc5ba 100644 --- a/awx/sso/tests/unit/test_fields.py +++ b/awx/sso/tests/unit/test_fields.py @@ -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()