How to use get_domain_url method in SeleniumBase

Best Python code snippet using SeleniumBase

fireREST.py

Source:fireREST.py Github

copy

Full Screen

...129 # HELPER FUNCTIONS130 ######################################################################131132 def get_object_id_by_name(self, object_type, name, domain='Global'):133 domain_url = self.get_domain_url(self.get_domain_id(domain))134 obj_type = object_type.lower() + 's'135 data = self._get(self.api_config_request_url + domain_url + 'object/%s' % obj_type).json()136 for item in data['items']:137 if item['name'] == name:138 return item['id']139 return None140141 def get_device_id_by_name(self, name, domain='Global'):142 domain_url = self.get_domain_url(self.get_domain_id(domain))143 data = self._get(self.api_config_request_url + domain_url + 'devices/devicerecords').json()144 for item in data['items']:145 if item['name'] == name:146 return item['id']147 return None148149 def get_acp_id_by_name(self, name, domain='Global'):150 domain_url = self.get_domain_url(self.get_domain_id(domain))151 responses = self._get(self.api_config_request_url + domain_url + 'policy/accesspolicies')152 for response in responses:153 for item in response.json()['items']:154 if item['name'] == name:155 return item['id']156 return None157158 def get_rule_id_by_name(self, policy_name, rule_name, domain='Global'):159 domain_url = self.get_domain_url(self.get_domain_id(domain))160 policy_id = self.get_acp_id_by_name(policy_name)161 data = self._get(162 self.api_config_request_url + domain_url + 'policy/accesspolicies/' + policy_id + '/accessrules').json()163 for item in data['items']:164 if item['name'] == rule_name:165 return item['id']166 return None167168 def get_domain_id(self, name):169 for domain in self.domains:170 if domain['name'] == name:171 return domain['uuid']172 logging.warn('Could not find domain with name %s. Make sure full path is provided' % domain['name'])173 logging.debug('Available Domains: %s' % self.domains)174175 def get_domain_url(self, domain_id):176 return 'domain/%s/' % domain_id177178 ######################################################################179 # <SYSTEM>180 ######################################################################181182 def get_system_version(self):183 request = self.api_platform_request_url + 'info/serverversion'184 return self._get(request)185186 def get_audit_records(self, domain='Global'):187 domain_url = self.get_domain_url(self.get_domain_id(domain))188 request = self.api_platform_request_url + domain_url + 'audit/auditrecords'189 return self._get(request)190191 ######################################################################192 # <OBJECTS>193 ######################################################################194195 def create_object(self, object_type, data, domain='Global'):196 domain_url = self.get_domain_url(self.get_domain_id(domain))197 obj_type = object_type.lower() + 's'198 request = self.api_config_request_url + domain_url + 'object/' + obj_type199 response = self._post(request, data)200 if response.status_code == 201:201 self.logger.info('Object %s of type %s successfully created' % (data['name'], object_type))202 else:203 if response.status_code == 400 and 'error' in response.json():204 if 'The object name already exists' in response.json()['error']['messages'][0]['description']:205 self.logger.info('Import of Object %s skipped, Object already exists.' % data['name'])206 else:207 self.logger.error('Import of Object %s failed with Reason: %s' % (208 data['name'], response.json()))209 self.logger.debug('Object Dump: %s' % data)210 return response211212 def delete_object(self, object_type, object_id, domain='Global'):213 domain_url = self.get_domain_url(self.get_domain_id(domain))214 request = self.api_config_request_url + domain_url + 'object/' + object_type + '/' + object_id215 return self._delete(request)216217 def update_object(self, object_type, object_id, data, domain='Global'):218 domain_url = self.get_domain_url(self.get_domain_id(domain))219 request = self.api_config_request_url + domain_url + 'object/' + object_type + '/' + object_id220 return self._put(request, data)221222 def get_objects(self, object_type, expanded=False, domain='Global'):223 domain_url = self.get_domain_url(self.get_domain_id(domain))224 obj_type = object_type.lower() + 's'225 request = self.api_config_request_url + domain_url + 'object/' + obj_type226 if expanded:227 request += '?expanded=True'228 return self._get(request)229230 def get_object(self, object_type, object_id, domain='Global'):231 domain_url = self.get_domain_url(self.get_domain_id(domain))232 obj_type = object_type.lower() + 's'233 request = self._get(self.api_config_request_url + domain_url + 'object/' + obj_type + '/' + object_id)234 return request235236 ######################################################################237 # </OBJECTS>238 ######################################################################239240241 ######################################################################242 # <DEVICES>243 ######################################################################244245 def get_devices(self, domain='Global'):246 domain_url = self.get_domain_url(self.get_domain_id(domain))247 request = self._get(self.api_config_request_url + domain_url + 'devices/devicerecords')248 return request249250 def get_device(self, device_id, domain='Global'):251 domain_url = self.get_domain_url(self.get_domain_id(domain))252 request = self._get(self.api_config_request_url + domain_url + 'devices/devicerecords/' + device_id)253 return request254255 ######################################################################256 # </DEVICES>257 ######################################################################258259 ######################################################################260 # <DEPLOYMENT>261 ######################################################################262263 def get_deploy_devices(self, domain='Global'):264 domain_url = self.get_domain_url(self.get_domain_id(domain))265 request = self._get(self.api_config_request_url + domain_url + 'deployment/deployabledevices')266 return request267268 def deploy_configuration(self, data, domain='Global'):269 domain_url = self.get_domain_url(self.get_domain_id(domain))270 request = self._post(self.api_config_request_url + domain_url + 'deployment/deploymentrequests')271 return request272273 ######################################################################274 # </DEPLOYMENT>275 ######################################################################276277 ######################################################################278 # <POLICIES>279 ######################################################################280281 def create_policy(self, policy_type, data, domain='Global'):282 domain_url = self.get_domain_url(self.get_domain_id(domain))283 policy_type = self.url_policy['policy_type']284 request = self.api_config_request_url + domain_url + 'policy/' + policy_type + '/'285 return self._post(request, data)286287 def delete_policy(self, policy_id, policy_type, domain='Global'):288 domain_url = self.get_domain_url(self.get_domain_id(domain))289 policy_type = self.url_policy['policy_type']290 request = self.api_config_request_url + domain_url + 'policy/' + policy_type + '/' + policy_id291 return self._delete(request)292293 def update_policy(self, policy_id, policy_type, domain='Global'):294 domain_url = self.get_domain_url(self.get_domain_id(domain))295 policy_type = self.url_policy['policy_type']296 request = self.api_config_request_url + domain_url + 'policy/' + policy_type + '/' + policy_id297 return self._put(request)298299 def get_policies(self, policy_type, domain='Global'):300 domain_url = self.get_domain_url(self.get_domain_id(domain))301 policy_type = self.url_policy['policy_type']302 request = self._get(self.api_config_request_url + domain_url + 'policy/' + policy_type)303 return request304305 def get_policy(self, policy_id, policy_type, expanded=False, domain='Global'):306 domain_url = self.get_domain_url(self.get_domain_id(domain))307 policy_type = self.url_policy[policy_type]308 request = self._get(self.api_config_request_url + domain_url + 'policy/' + policy_type + '/' + policy_id)309 if expanded:310 request += '?expanded=True'311 return request312313 def get_acp_rules(self, policy_id, expanded=False, domain='Global'):314 domain_url = self.get_domain_url(self.get_domain_id(domain))315 request = self.api_config_request_url + domain_url + 'policy/accesspolicies/' + policy_id + '/accessrules'316 if expanded:317 request += '?expanded=True'318 return self._get(request)319320 def get_acp_rule(self, policy_id, rule_id, domain='Global'):321 domain_url = self.get_domain_url(self.get_domain_id(domain))322 request = self._get(323 self.api_config_request_url + domain_url + 'policy/accesspolicies/' + policy_id + '/accessrules/' + rule_id,324 limit=None)325 return request326327 def update_acp_rule(self, policy_id, rule_id, data, domain='Global'):328 domain_url = self.get_domain_url(self.get_domain_id(domain))329 request = self._put(330 self.api_config_request_url + domain_url + 'policy/accesspolicies/' + policy_id + '/accessrules/' + rule_id,331 data) ...

Full Screen

Full Screen

test_permissions.py

Source:test_permissions.py Github

copy

Full Screen

...60 self.u_client = user_client(self.user)61 def test_su_can_edit_all_domains(self):62 """Superuser can edit domain not owned by herself."""63 request = self.su_client.patch(64 get_domain_url(self.u_domain),65 {'type': 'NATIVE'},66 )67 self.assertEqual(request.status_code, 200)68 def test_user_cant_edit_other_domains(self):69 """Normal user can't edit domains she doesn't own."""70 request = self.u_client.patch(71 get_domain_url(self.su_domain),72 {'type': 'NATIVE'},73 )74 self.assertEqual(request.status_code, 403)75 def test_user_cant_edit_her_domains(self):76 """Normal user cant edit even owned domains."""77 request = self.u_client.patch(78 get_domain_url(self.u_domain),79 {'type': 'NATIVE'},80 )81 self.assertEqual(request.status_code, 403)82 def test_user_cant_create_domain(self):83 """Normal user can't create domain that is not a child of other domain.84 """85 request = self.u_client.post(86 reverse('api:v2:domain-list'),87 {'name': 'example2.com'}88 )89 self.assertEqual(request.status_code, 403)90 def test_user_cant_subdomain_her_own(self):91 """Normal user can't create domain that is a child of domain she owns.92 """...

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 SeleniumBase 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