From 5e600a646c6165cd9a5666792e82891a5fe85059 Mon Sep 17 00:00:00 2001 From: Marek Denis Date: Mon, 11 Jan 2016 13:52:21 +0100 Subject: [PATCH] Add asserts for service providers Add two methods useful while testing service providers: - assertValidServiceProvider() - assertValidServiceProvidersListResponse() Change-Id: I62ec9619d8b187cda80100e383d40b158550b71f --- keystone/tests/unit/test_v3.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/keystone/tests/unit/test_v3.py b/keystone/tests/unit/test_v3.py index 526aec221d..15d8896196 100644 --- a/keystone/tests/unit/test_v3.py +++ b/keystone/tests/unit/test_v3.py @@ -1094,6 +1094,27 @@ class RestfulTestCase(unit.SQLDriverOverrides, rest.RestfulTestCase, return entity + # Service providers (federation) + + def assertValidServiceProvider(self, entity, ref=None, *args, **kwargs): + + attributes = frozenset(['auth_url', 'id', 'enabled', 'description', + 'links', 'relay_state_prefix', 'sp_url']) + for attribute in attributes: + self.assertIsNotNone(entity.get(attribute)) + + def assertValidServiceProviderListResponse(self, resp, *args, **kwargs): + if kwargs.get('keys_to_check') is None: + kwargs['keys_to_check'] = ['auth_url', 'id', 'enabled', + 'description', 'relay_state_prefix', + 'sp_url'] + return self.assertValidListResponse( + resp, + 'service_providers', + self.assertValidServiceProvider, + *args, + **kwargs) + def build_external_auth_request(self, remote_user, remote_domain=None, auth_data=None, kerberos=False):