How to use show_domain_group_option_config method in tempest

Best Python code snippet using tempest_python

test_domain_config.py

Source:test_domain_config.py Github

copy

Full Screen

1# Copyright 2020 SUSE LLC2#3# Licensed under the Apache License, Version 2.0 (the "License"); you may4# not use this file except in compliance with the License. You may obtain5# a copy of the License at6#7# http://www.apache.org/licenses/LICENSE-2.08#9# Unless required by applicable law or agreed to in writing, software10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the12# License for the specific language governing permissions and limitations13# under the License.14import abc15from tempest.api.identity import base16from tempest.lib.common.utils import data_utils17from tempest.lib import exceptions18from keystone_tempest_plugin.tests.rbac.v3 import base as rbac_base19class IdentityV3RbacDomainConfigTest(rbac_base.IdentityV3RbacBaseTests,20 metaclass=abc.ABCMeta):21 @classmethod22 def setup_clients(cls):23 super(IdentityV3RbacDomainConfigTest, cls).setup_clients()24 cls.persona = getattr(cls, 'os_%s' % cls.credentials[0])25 cls.client = cls.persona.domain_config_client26 cls.admin_client = cls.os_system_admin27 cls.admin_domain_config_client = cls.admin_client.domain_config_client28 @classmethod29 def resource_setup(cls):30 super(IdentityV3RbacDomainConfigTest, cls).resource_setup()31 cls.domain_id = cls.admin_client.domains_client.create_domain(32 name=data_utils.rand_name('domain'))['domain']['id']33 cls.addClassResourceCleanup(34 cls.admin_client.domains_client.delete_domain,35 cls.domain_id)36 cls.addClassResourceCleanup(37 cls.admin_client.domains_client.update_domain,38 cls.domain_id,39 enabled=False)40 def domain_config(self, **kwargs):41 ref = {42 "identity": {43 "driver": "ldap"44 },45 "ldap": {46 "url": "ldap://myldap.com:389/",47 "user_tree_dn": "ou=Users,dc=my_new_root,dc=org"48 }49 }50 ref.update(kwargs)51 return ref52 @abc.abstractmethod53 def test_identity_create_domain_config(self):54 """Test identity:create_domain_config policy.55 This test must check:56 * whether the persona can create a domain config for a valid domain57 """58 pass59 @abc.abstractmethod60 def test_identity_get_domain_config(self):61 """Test identity:get_domain_config policy.62 This test must check:63 * whether the persona can get a domain config64 * whether the persona can get an option group for a domain config65 * whether the persona can get an option from a group in a domain66 config67 * whether the persona can get a config for an invalid domain68 * whether the persona can get a config that does not exist69 """70 pass71 @abc.abstractmethod72 def test_identity_get_domain_config_default(self):73 """Test identity:get_domain_config_default policy.74 * whether the persona can get the default config75 * whether the persona can get the default config for an option group76 * whether the persona can get the default value for an option77 """78 pass79 @abc.abstractmethod80 def test_identity_get_security_compliance_domain_config(self):81 """Test identity:get_security_compliance_domain_config policy.82 This test must check:83 * whether the persona can get the security compliance configuration84 for the default domain85 * whether the persona can get an option from the security compliance86 configuration for the default domain87 """88 pass89 @abc.abstractmethod90 def test_identity_update_domain_config(self):91 """Test identity:update_domain_config policy.92 This test must check:93 * whether the persona can update the config for a domain94 * whether the persona can update an option group config for a domain95 * whether the persona can update an option in a domain config96 """97 pass98 @abc.abstractmethod99 def test_identity_delete_domain_config(self):100 """Test identity:delete_domain_config policy.101 This test must check102 * whether the persona can delete a domain config103 * whether the persona can delete an option group within a domain104 config105 * whether the persona can delete an option within a domain config106 """107 pass108class SystemAdminTests(IdentityV3RbacDomainConfigTest, base.BaseIdentityTest):109 credentials = ['system_admin']110 def test_identity_create_domain_config(self):111 self.do_request(112 'create_domain_config',113 expected_status=201,114 domain_id=self.domain_id,115 **self.domain_config())116 self.addCleanup(117 self.admin_domain_config_client.delete_domain_config,118 self.domain_id)119 def test_identity_get_domain_config(self):120 # should be able to get domain config, group and individual options121 self.admin_domain_config_client.create_domain_config(122 self.domain_id, **self.domain_config())123 self.addCleanup(124 self.admin_domain_config_client.delete_domain_config,125 self.domain_id)126 self.do_request(127 'show_domain_config',128 domain_id=self.domain_id)129 self.do_request(130 'show_domain_group_config',131 domain_id=self.domain_id,132 group='ldap')133 self.do_request(134 'show_domain_group_option_config',135 domain_id=self.domain_id,136 group='ldap',137 option='url')138 # should get Not Found for invalid domain139 self.do_request(140 'show_domain_config',141 expected_status=exceptions.NotFound,142 domain_id=data_utils.rand_uuid_hex())143 # should get Not Found for nonexistent config for valid domain144 domain = self.admin_client.domains_client.create_domain(145 name=data_utils.rand_name('domain'))['domain']['id']146 self.addCleanup(self.admin_client.domains_client.delete_domain, domain)147 self.addCleanup(148 self.admin_client.domains_client.update_domain,149 domain, enabled=False)150 self.do_request(151 'show_domain_config',152 expected_status=exceptions.NotFound,153 domain_id=domain)154 def test_identity_get_domain_config_default(self):155 self.do_request('show_default_config_settings')156 self.do_request('show_default_group_config', group='ldap')157 self.do_request(158 'show_default_group_option', group='ldap', option='url')159 def test_identity_get_security_compliance_domain_config(self):160 self.do_request(161 'show_domain_group_config',162 domain_id='default',163 group='security_compliance')164 self.do_request(165 'show_domain_group_option_config',166 domain_id='default',167 group='security_compliance',168 option='password_regex_description')169 def test_identity_update_domain_config(self):170 self.admin_domain_config_client.create_domain_config(171 self.domain_id, **self.domain_config())172 self.addCleanup(173 self.admin_domain_config_client.delete_domain_config,174 self.domain_id)175 self.do_request(176 'update_domain_group_config',177 domain_id=self.domain_id,178 group='ldap',179 ldap={'url': 'ldaps://myldap.com:636/',180 'user_tree_dn': 'ou=People,dc=my_new_root,dc=org'})181 self.do_request(182 'update_domain_group_option_config',183 domain_id=self.domain_id,184 group='ldap',185 option='user_tree_dn',186 user_tree_dn='ou=Aliens,dc=my_new_root,dc=org')187 # test changing the entire config last188 self.do_request(189 'update_domain_config',190 domain_id=self.domain_id,191 identity={"driver": "sql"})192 def test_identity_delete_domain_config(self):193 self.admin_domain_config_client.create_domain_config(194 self.domain_id, **self.domain_config())195 self.do_request(196 'delete_domain_group_option_config',197 expected_status=204,198 domain_id=self.domain_id,199 group='ldap',200 option='user_tree_dn')201 self.do_request(202 'delete_domain_group_config',203 expected_status=204,204 domain_id=self.domain_id,205 group='ldap')206 self.do_request(207 'delete_domain_config',208 expected_status=204,209 domain_id=self.domain_id)210class SystemMemberTests(SystemAdminTests):211 credentials = ['system_member', 'system_admin']212 def test_identity_create_domain_config(self):213 self.do_request(214 'create_domain_config',215 expected_status=exceptions.Forbidden,216 domain_id=self.domain_id,217 **self.domain_config())218 def test_identity_update_domain_config(self):219 self.admin_domain_config_client.create_domain_config(220 self.domain_id, **self.domain_config())221 self.addCleanup(222 self.admin_domain_config_client.delete_domain_config,223 self.domain_id)224 self.do_request(225 'update_domain_group_config',226 expected_status=exceptions.Forbidden,227 domain_id=self.domain_id,228 group='ldap',229 ldap={'url': 'ldaps://myldap.com:636/',230 'user_tree_dn': 'ou=People,dc=my_new_root,dc=org'})231 self.do_request(232 'update_domain_group_option_config',233 expected_status=exceptions.Forbidden,234 domain_id=self.domain_id,235 group='ldap',236 option='user_tree_dn',237 user_tree_dn='ou=Aliens,dc=my_new_root,dc=org')238 # test changing the entire config last239 self.do_request(240 'update_domain_config',241 expected_status=exceptions.Forbidden,242 domain_id=self.domain_id,243 identity={"driver": "sql"})244 def test_identity_delete_domain_config(self):245 self.admin_domain_config_client.create_domain_config(246 self.domain_id, **self.domain_config())247 self.do_request(248 'delete_domain_group_option_config',249 expected_status=exceptions.Forbidden,250 domain_id=self.domain_id,251 group='ldap',252 option='user_tree_dn')253 self.do_request(254 'delete_domain_group_config',255 expected_status=exceptions.Forbidden,256 domain_id=self.domain_id,257 group='ldap')258 self.do_request(259 'delete_domain_config',260 expected_status=exceptions.Forbidden,261 domain_id=self.domain_id)262class SystemReaderTests(SystemMemberTests):263 credentials = ['system_reader', 'system_admin']264class DomainAdminTests(SystemReaderTests):265 credentials = ['domain_admin', 'system_admin']266 def test_identity_get_domain_config(self):267 # should not be able to get domain config, group and individual options268 self.admin_domain_config_client.create_domain_config(269 self.domain_id, **self.domain_config())270 self.addCleanup(271 self.admin_domain_config_client.delete_domain_config,272 self.domain_id)273 self.do_request(274 'show_domain_config',275 expected_status=exceptions.Forbidden,276 domain_id=self.domain_id)277 self.do_request(278 'show_domain_group_config',279 expected_status=exceptions.Forbidden,280 domain_id=self.domain_id,281 group='ldap')282 self.do_request(283 'show_domain_group_option_config',284 expected_status=exceptions.Forbidden,285 domain_id=self.domain_id,286 group='ldap',287 option='url')288 # should get Forbidden for invalid domain289 self.do_request(290 'show_domain_config',291 expected_status=exceptions.Forbidden,292 domain_id=data_utils.rand_uuid_hex())293 # should get Forbidden for nonexistent config for valid domain294 domain = self.admin_client.domains_client.create_domain(295 name=data_utils.rand_name('domain'))['domain']['id']296 self.addCleanup(self.admin_client.domains_client.delete_domain, domain)297 self.addCleanup(298 self.admin_client.domains_client.update_domain,299 domain, enabled=False)300 self.do_request(301 'show_domain_config',302 expected_status=exceptions.Forbidden,303 domain_id=domain)304 def test_identity_get_domain_config_default(self):305 self.do_request(306 'show_default_config_settings',307 expected_status=exceptions.Forbidden)308 self.do_request(309 'show_default_group_config',310 expected_status=exceptions.Forbidden, group='ldap')311 self.do_request(312 'show_default_group_option',313 expected_status=exceptions.Forbidden, group='ldap', option='url')314class DomainMemberTests(DomainAdminTests):315 credentials = ['domain_member', 'system_admin']316class DomainReaderTests(DomainAdminTests):317 credentials = ['domain_reader', 'system_admin']318class ProjectAdminTests(DomainReaderTests):319 credentials = ['project_admin', 'system_admin']320class ProjectMemberTests(ProjectAdminTests):321 credentials = ['project_member', 'system_admin']322class ProjectReaderTests(ProjectAdminTests):...

Full Screen

Full Screen

test_domain_configuration.py

Source:test_domain_configuration.py Github

copy

Full Screen

...89 self.assertEqual(self.custom_config[group_name],90 group_cfg[group_name])91 # Check that each configuration option is correct.92 for opt_name in self.custom_config[group_name].keys():93 group_opt = self.client.show_domain_group_option_config(94 domain['id'], group_name, opt_name)['config']95 self.assertIn(opt_name, group_opt)96 self.assertEqual(self.custom_config[group_name][opt_name],97 group_opt[opt_name])98 @decorators.idempotent_id('7161023e-5dd0-4612-9da0-1bac6ac30b63')99 def test_create_update_and_delete_domain_config(self):100 domain, created_config = self._create_domain_and_config(101 self.custom_config)102 new_config = created_config103 new_config['ldap']['url'] = data_utils.rand_url()104 # Check that the altered configuration is reflected in updated_config.105 updated_config = self.client.update_domain_config(106 domain['id'], **new_config)['config']107 self.assertEqual(new_config, updated_config)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful