From e9fc58144012a23d228e589ea9de140dc3efee95 Mon Sep 17 00:00:00 2001 From: Lance Bragstad Date: Wed, 20 Jul 2016 22:14:49 +0000 Subject: [PATCH] refactor: inherit AuthWithRemoteUser for other providers This commit makes it so that the AuthWithRemoteUser class no longer inherits from other tests cases. Instead it inherits from `object` and I've added several other classes that setup each token provider to test the cases in AuthWithRemoteUser. This helps us move towards making Fernet the default token provider. Co-Authored-By: Raildo Mascena Co-Authored-By: Adam Young Change-Id: I3ae63c8ff50a897ef0ae6e8129abc02e5b93747c Partial-Bug: 1561054 --- keystone/tests/unit/test_auth.py | 41 +++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/keystone/tests/unit/test_auth.py b/keystone/tests/unit/test_auth.py index e7d5d19ab1..5138db30d2 100644 --- a/keystone/tests/unit/test_auth.py +++ b/keystone/tests/unit/test_auth.py @@ -742,7 +742,7 @@ class AuthWithPasswordCredentials(AuthTest): self.controller.authenticate(self.make_request(), body_dict) -class AuthWithRemoteUser(AuthTest): +class AuthWithRemoteUser(object): def test_unscoped_remote_authn(self): """Verify getting an unscoped token with external authn.""" body_dict = _build_user_auth( @@ -823,6 +823,45 @@ class AuthWithRemoteUser(AuthTest): self.assertNotIn('bind', token['access']['token']) +class FernetAuthWithRemoteUser(AuthWithRemoteUser, AuthTest): + + def config_overrides(self): + super(FernetAuthWithRemoteUser, self).config_overrides() + self.config_fixture.config(group='token', provider='fernet') + self.useFixture(ksfixtures.KeyRepository(self.config_fixture)) + + def test_bind_with_kerberos(self): + self.config_fixture.config(group='token', bind=['kerberos']) + body_dict = _build_user_auth(tenant_name="BAR") + # NOTE(lbragstad): Bind authentication is not supported by the Fernet + # provider. + self.assertRaises(exception.NotImplemented, + self.controller.authenticate, + self.request_with_remote_user, + body_dict) + + +class UUIDAuthWithRemoteUser(AuthWithRemoteUser, AuthTest): + + def config_overrides(self): + super(UUIDAuthWithRemoteUser, self).config_overrides() + self.config_fixture.config(group='token', provider='uuid') + + +class PKIAuthWithRemoteUser(AuthWithRemoteUser, AuthTest): + + def config_overrides(self): + super(PKIAuthWithRemoteUser, self).config_overrides() + self.config_fixture.config(group='token', provider='pki') + + +class PKIZAuthWithRemoteUser(AuthWithRemoteUser, AuthTest): + + def config_overrides(self): + super(PKIZAuthWithRemoteUser, self).config_overrides() + self.config_fixture.config(group='token', provider='pkiz') + + class AuthWithTrust(AuthTest): def setUp(self): super(AuthWithTrust, self).setUp()