blob: c6eed6f550d096b5f8caa697c454b0283b303ece [file] [log] [blame]
Kiall Mac Innes25fb29e2016-04-07 08:07:04 +01001# Copyright 2016 Hewlett Packard Enterprise Development Company, L.P.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14from tempest import clients
15from tempest import config
Cao Xuan Hoanga585e942016-08-29 14:52:30 +070016from tempest.lib import auth
Kiall Mac Innes25fb29e2016-04-07 08:07:04 +010017
Paul Glass8abae332016-04-21 15:34:09 +000018from designate_tempest_plugin.services.dns.v2.json.blacklists_client import \
19 BlacklistsClient
sonu.kumar4beb93c2016-05-05 01:12:43 +090020from designate_tempest_plugin.services.dns.v2.json.pool_client import \
21 PoolClient
Michael Johnsondf9fda12021-07-09 16:39:08 +000022from designate_tempest_plugin.services.dns.v2.json.recordset_client import \
23 RecordsetClient
sonu.kumar2de01be2016-05-05 10:07:28 +090024from designate_tempest_plugin.services.dns.v2.json.tld_client import \
25 TldClient
Michael Johnsondf9fda12021-07-09 16:39:08 +000026from designate_tempest_plugin.services.dns.v2.json.zones_client import \
27 ZonesClient
Michael Johnsonac961e52021-07-09 18:26:04 +000028
Kiall Mac Innes25fb29e2016-04-07 08:07:04 +010029
30CONF = config.CONF
31
32
Michael Johnsondf9fda12021-07-09 16:39:08 +000033class ManagerV2Unauthed(clients.Manager):
Paul Glassd56330a2016-06-13 21:03:33 +000034
Graham Hayesc1978262017-01-11 17:17:32 +000035 def __init__(self, credentials=None):
36 super(ManagerV2Unauthed, self).__init__(credentials)
Paul Glass4b07b382016-07-13 19:14:02 +000037 self.auth_provider = self._auth_provider_class()(
Paul Glassd56330a2016-06-13 21:03:33 +000038 credentials=self.auth_provider.credentials,
39 auth_url=self.auth_provider.auth_client.auth_url,
40 disable_ssl_certificate_validation=self.auth_provider.dscv,
41 ca_certs=self.auth_provider.ca_certs,
42 trace_requests=self.auth_provider.trace_requests,
43 )
44 self._init_clients(self._get_params())
45
Michael Johnsondf9fda12021-07-09 16:39:08 +000046 def _init_clients(self, params):
47 self.zones_client = ZonesClient(**params)
48 self.blacklists_client = BlacklistsClient(**params)
49 self.recordset_client = RecordsetClient(**params)
50 self.pool_client = PoolClient(**params)
51 self.tld_client = TldClient(**params)
52
Paul Glass4b07b382016-07-13 19:14:02 +000053 def _auth_provider_class(self):
54 if CONF.identity.auth_version == 'v3':
55 return KeystoneV3UnauthedProvider
56 else:
57 return KeystoneV2UnauthedProvider
Paul Glassd56330a2016-06-13 21:03:33 +000058
Michael Johnsondf9fda12021-07-09 16:39:08 +000059 def _get_params(self):
60 params = dict(self.default_params)
61 params.update({
62 'auth_provider': self.auth_provider,
63 'service': CONF.dns.catalog_type,
64 'region': CONF.identity.region,
65 'endpoint_type': CONF.dns.endpoint_type,
66 'build_interval': CONF.dns.build_interval,
67 'build_timeout': CONF.dns.build_timeout
68 })
69 return params
70
Paul Glass4b07b382016-07-13 19:14:02 +000071
Cao Xuan Hoanga585e942016-08-29 14:52:30 +070072class BaseUnauthedProvider(auth.KeystoneAuthProvider):
Paul Glassd56330a2016-06-13 21:03:33 +000073
74 def _decorate_request(self, filters, method, url, headers=None, body=None,
75 auth_data=None):
Paul Glass4b07b382016-07-13 19:14:02 +000076 result = super(BaseUnauthedProvider, self)._decorate_request(
Paul Glassd56330a2016-06-13 21:03:33 +000077 filters, method, url, headers=headers, body=body,
78 auth_data=auth_data)
79 url, headers, body = result
80 try:
81 del headers['X-Auth-Token']
82 except KeyError:
83 pass
84 return url, headers, body
Paul Glass4b07b382016-07-13 19:14:02 +000085
86
Cao Xuan Hoanga585e942016-08-29 14:52:30 +070087class KeystoneV2UnauthedProvider(auth.KeystoneV2AuthProvider,
88 BaseUnauthedProvider):
Paul Glass4b07b382016-07-13 19:14:02 +000089
90 def _decorate_request(self, *args, **kwargs):
91 return BaseUnauthedProvider._decorate_request(self, *args, **kwargs)
92
93
Cao Xuan Hoanga585e942016-08-29 14:52:30 +070094class KeystoneV3UnauthedProvider(auth.KeystoneV3AuthProvider,
95 BaseUnauthedProvider):
Paul Glass4b07b382016-07-13 19:14:02 +000096
97 def _decorate_request(self, *args, **kwargs):
98 return BaseUnauthedProvider._decorate_request(self, *args, **kwargs)