From 12966b8851a24f1a685aa2172470b873857d2220 Mon Sep 17 00:00:00 2001 From: Lance Bragstad Date: Mon, 18 Jul 2016 19:57:49 +0000 Subject: [PATCH] Refactor TestAuthExternalDomain to not inherit tests Previously, TestAuthExternalDomain was inheriting from test_v3.RestfulTestCase, which allowed it to run as part of the keystone test suite. This commit breaks it into a class that only inherits from `object` and introduces 3 other classes the inherit the old TestAuthExternalDomain and run the tests according to the setup needed. Since the Fernet provider doesn't support bind authentication, there is no test class to setup Fernet and run the TestAuthExternalDomain behaviors. This change will make defaulting to Fernet easier. This fix was originally a part of https://review.openstack.org/#/c/258650 but this is an attempt to break 258650 into smaller, more reviewable, pieces. Co-Authored-By: Raildo Mascena Co-Authored-By: Adam Young Change-Id: I28e575ddada8492bd4fc17b78cb00651d9d4af07 Partial-Bug: 1561054 --- keystone/tests/unit/test_v3_auth.py | 40 ++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/keystone/tests/unit/test_v3_auth.py b/keystone/tests/unit/test_v3_auth.py index da66dd77b0..f53112fe25 100644 --- a/keystone/tests/unit/test_v3_auth.py +++ b/keystone/tests/unit/test_v3_auth.py @@ -3592,14 +3592,9 @@ class TestAuthExternalDisabled(test_v3.RestfulTestCase): auth_context) -class TestAuthExternalDomain(test_v3.RestfulTestCase): +class AuthExternalDomainBehavior(object): content_type = 'json' - def config_overrides(self): - super(TestAuthExternalDomain, self).config_overrides() - self.kerberos = False - self.auth_plugin_config_override(external='Domain') - def test_remote_user_with_realm(self): api = auth.controllers.Auth() remote_user = self.user['name'] @@ -3648,6 +3643,37 @@ class TestAuthExternalDomain(test_v3.RestfulTestCase): self.assertEqual(self.user['name'], token['bind']['kerberos']) +class TestAuthExternalDomainBehaviorWithUUID(AuthExternalDomainBehavior, + test_v3.RestfulTestCase): + def config_overrides(self): + super(TestAuthExternalDomainBehaviorWithUUID, self).config_overrides() + self.kerberos = False + self.auth_plugin_config_override(external='Domain') + self.config_fixture.config(group='token', provider='uuid') + + +class TestAuthExternalDomainBehaviorWithPKI(AuthExternalDomainBehavior, + test_v3.RestfulTestCase): + def config_overrides(self): + super(TestAuthExternalDomainBehaviorWithPKI, self).config_overrides() + self.kerberos = False + self.auth_plugin_config_override(external='Domain') + self.config_fixture.config(group='token', provider='pki') + + +class TestAuthExternalDomainBehaviorWithPKIZ(AuthExternalDomainBehavior, + test_v3.RestfulTestCase): + def config_overrides(self): + super(TestAuthExternalDomainBehaviorWithPKIZ, self).config_overrides() + self.kerberos = False + self.auth_plugin_config_override(external='Domain') + self.config_fixture.config(group='token', provider='pkiz') + + +# NOTE(lbragstad): The Fernet token provider doesn't support bind +# authentication so we don't inhereit TestAuthExternalDomain here to test it. + + class TestAuthExternalDefaultDomain(test_v3.RestfulTestCase): content_type = 'json' @@ -3704,7 +3730,7 @@ class TestAuthExternalDefaultDomain(test_v3.RestfulTestCase): token['bind']['kerberos']) -class TestAuthKerberos(TestAuthExternalDomain): +class TestAuthKerberos(AuthExternalDomainBehavior, test_v3.RestfulTestCase): def config_overrides(self): super(TestAuthKerberos, self).config_overrides()