2 Documentation Basic REST AAA Tests for IdMLight
4 ... Copyright (c) 2015 Hewlett-Packard Development Company, L.P. and others. All rights reserved.
6 ... This program and the accompanying materials are made available under the
7 ... terms of the Eclipse Public License v1.0 which accompanies this distribution,
8 ... and is available at http://www.eclipse.org/legal/ep1-v10.html
9 Suite Setup IdMLight Suite Setup
10 Suite Teardown IdMLight Suite Teardown
12 Library RequestsLibrary
13 Library OperatingSystem
15 Library HttpLibrary.HTTP
17 Library ../../../libraries/Common.py
18 Library ../../../libraries/AAAJsonUtils.py
19 Resource ../../../libraries/Utils.robot
20 Variables ../../../variables/Variables.py
21 Resource ../../../libraries/AAAKeywords.robot
24 # port is fixed in Jetty configuration, as well
25 ${URI} http://${CONTROLLER}:8282
26 # create lists for Domains, Roles and Users - that can be cleaned up upon Teardown
27 @{cleanup_domain_list}
31 # will modify value in Setup and use throughout the code
36 [Documentation] Create a domain using REST POST command.
37 # create a temp name, set it to domainName
38 ${domainName}= Create Random Name domain-Other
39 # Create the new domain, initialize some values to test against
40 ${domaindesc}= Set Variable "testdomain other"
41 ${domainstatus}= Set Variable "true"
42 # Have to escape the quotes, need quotes to make the POST work properly
43 ${data}= Set Variable {"description":${domaindesc},"domainid":"7","name":\"${domainName}\","enabled":${domainstatus}}
46 ${domain}= Post New Domain ${domainName} ${data}
48 ${domainid}= Parse Item From Blob By Offset ${domain} 0
50 # get the domain to verify
51 ${fetched_domain}= Get Specific Domain ${domainid}
52 # add new domain json string to the cleanup list for later cleanup
53 Append To List ${cleanup_domain_list} ${fetched_domain}
54 # count the number of domainid's that appear in this block of JSON
55 ${depth}= Fieldcount ${fetched_domain} "domainid"
56 ${fetchedDomStatus}= Get Domain State By Domainid ${domain} ${domainid} ${depth}
57 ${fetchedDomDesc}= Get Domain Description By Domainid ${domain} ${domainid} ${depth}
58 # Set Test Disposition based on comparison of what was posted and what was fetched
59 ${testdisposition}= Set Variable If '${fetched_domain}' == '${domain}' '${fetchedDomStatus}' == '${domainstatus}' '${fetchedDomDesc}' == '${domaindesc}'
60 Log ${testdisposition}
63 [Documentation] Exercise REST GET command to get all domains.
64 # rely on the creation of a test role in the Setup routine
65 # pop item off of end of the cleanup list, for use (does not alter list)
66 Log ${cleanup_domain_list}
67 ${domain_item}= Get From List ${cleanup_domain_list} -1
69 # parse out the domainid from the domain info we just grabbed
70 ${domainid}= Parse Item From Blob By Offset ${domain_item} 0
72 # parse out the name from the same info
73 ${domainname}= Parse Item From Blob By Offset ${domain_item} 1
75 # get the entire dump of created domains
76 ${content}= Get Domains
77 # parse through that massive blob and get the individual name created in Setup
78 ${node_count}= Nodecount ${content} domains domainid
79 ${domainid}= Convert To Integer ${domainid}
80 # Get the domain name from the database, looking it up by its domainid
81 ${domainentry}= Get Domain Name By Domainid ${content} ${domainid} ${node_count}
83 # compare to see if the parsed user id matches the one we grabbed from list
84 Should Be Equal ${domainentry} ${domainname}
86 Test Get Specific Domain
87 [Documentation] Get a specific domain using REST GET command.
88 # from the pre-created (see Setup routine) list, grab a domain id for testing
89 ${listlength}= Get Length ${cleanup_domain_list}
90 # pop item off of end of the list, for use (does not alter list)
91 Log ${cleanup_domain_list}
92 ${domain_item}= Get From List ${cleanup_domain_list} -1
93 ${item}= Pop Name Off Json ${domain_item}
94 # convert this crap to unicode
95 # ${item}= Convert To String ${item}
97 # make a GET call to find the material we want to delete
98 ${domains}= Get Domains
99 # convert name on the list to an ID, by which we delete this stuff
100 ${node_count}= Nodecount ${domains} domains domainid
101 ${node_count}= Convert To Integer ${node_count}
102 ${domainid}= Get Domain Id By Domainname ${domains} ${item} ${node_count}
103 # now, get the specific domain by it's domainid
104 ${domaininfo}= Get Specific Domain ${domainid}
105 Should Contain ${domaininfo} ${item}
108 Test Update Specific Domain
109 [Documentation] Update a specific domain using REST PUT command.
110 # rely on the creation of a test domain in the Setup routine
111 # pop item off of end of the list, for use (does not alter list)
112 Log ${cleanup_domain_list}
113 ${domain_item}= Get From List ${cleanup_domain_list} -1
115 # parse out the domain id from the domain info we just grabbed
116 ${domid}= Parse Item From Blob By Offset ${domain_item} 0
118 # parse out the name from the same info
119 ${domname}= Parse Item From Blob By Offset ${domain_item} 1
121 ${data}= Set Variable {"name":"MasterTest Domain"}
122 Update Specific Domain ${data} ${domid}
123 ${domname}= Get Specific Domain Name ${domid}
125 ${z}= Split String ${data} :
126 ${dname}= Get From List ${z} 1
127 ${dname}= Replace String ${dname} " ${EMPTY}
128 ${dname}= Replace String ${dname} } ${EMPTY}
130 ${modified_name}= Pop Name Off Json ${domname}
132 Should Be Equal ${dname} ${modified_name}
135 [Documentation] Delete a specific domain using REST DELETE command.
136 # create a temporary test domain
137 ${tempdomain}= Create Random Name temp-domain-name
138 ${domaindata}= Set Variable {"description":"temporary test domain","domainid":"1","name":"${tempdomain}","enabled":"true"}
139 # Post that temp domain
140 ${newdomain}= Post New Domain ${tempdomain} ${domaindata}
142 # parse out the domain-id from the domain info we just created
143 ${domainid}= Parse Item From Blob By Offset ${newdomain} 0
145 # now wipe if off the map
146 Delete Domain ${domainid}
147 # we should not be able to fetch this domain from the database of domains...should fail...
148 ${content}= Check Specific Id Does Not Exist domain ${domainid}
152 [Documentation] Exercise REST GET command for obtaining all users.
153 # rely on the creation of a test user in the Setup routine
154 # pop item off of end of the list, for use (does not alter list)
155 Log ${cleanup_user_list}
156 ${user_item}= Get From List ${cleanup_user_list} -1
158 # parse out the userid from the user info we just grabbed
159 ${userid}= Parse Item From Blob By Offset ${user_item} 0
161 # parse out the name from the same info
162 ${username}= Parse Item From Blob By Offset ${user_item} 1
164 # get the entire blob of users
165 ${content}= Get Users
166 # parse through that massive blob and get the individual name
167 ${node_count}= Nodecount ${content} users userid
168 ${userid}= Convert To Integer ${userid}
169 ${userentry}= Get User Name By Userid ${content} ${userid} ${node_count}
171 # compare to see if the parsed user id matches the one we grabbed from list
172 Should Be Equal ${userentry} ${username}
174 Test Get Specific User
175 [Documentation] Exercise REST GET command to obtain a specific user.
176 # from the pre-created (see Setup routine) list, grab a user id for testing
177 ${listlength}= Get Length ${cleanup_user_list}
178 # pop item off of end of the list, for use (does not alter list)
179 Log ${cleanup_user_list}
180 ${user_item}= Get From List ${cleanup_user_list} -1
181 ${item}= Pop Name Off Json ${user_item}
182 # convert this to unicode
183 # ${item}= Convert To String ${item}
185 # parse out the userid from the user info we just grabbed
186 ${userid}= Parse Item From Blob By Offset ${user_item} 0
188 # parse out the name from the same info
189 ${username}= Parse Item From Blob By Offset ${user_item} 1
191 # make a GET call to find the material we want
192 ${content}= Get Specific User ${userid}
193 # parse out the user name from the content we just fetched
194 ${fetched_username}= Parse Item From Blob By Offset ${content} 1
195 Log ${fetched_username}
196 # compare to see if the parsed user name matches the one we grabbed from list
197 Should Contain ${fetched_username} ${username}
200 [Documentation] Exercise PUT command against an existing User ID.
201 # pop item off of end of the list, for use (does not alter list)
202 Log ${cleanup_user_list}
203 ${user_item}= Get From List ${cleanup_user_list} -1
205 # parse out the user-id from the user info we just created
206 ${userid}= Parse Item From Blob By Offset ${user_item} 0
208 # update the information for the userid
209 ${testusername}= Create Random Name force-accomplish
210 ${data}= Set Variable {"description":"sample test description", "name":"${testusername}"}
211 ${content}= Update Specific User ${data} ${userid}
213 # now, make a GET call to find the material we modified
214 ${existing_useritem}= Get Specific User ${userid}
215 # parse out the name from the existing userinfo
216 ${expected_username}= Parse Item From Blob By Offset ${existing_useritem} 1
217 Log ${expected_username}
218 # compare to see if the GOTTEN user id matches the one we grabbed from list
219 Should Be Equal ${expected_username} ${testusername}
222 [Documentation] Test the POST command to create a new user.
223 # create information for a new role (for the test)
224 ${testusername}= Create Random Name Darth-Maul
225 ${data}= Set Variable {"description":"sample user description", "name":"${testusername}", "userid":1}
228 ${content}= Post New User ${testusername} ${data}
229 # parse out the userid from the content we just created
230 ${userid}= Parse Item From Blob By Offset ${content} 0
232 # now go GET the userid info and compare to the name we fabricated
233 ${existing_useritem}= Get Specific User ${userid}
234 ${expected_username}= Parse Item From Blob By Offset ${existing_useritem} 1
235 Log ${expected_username}
236 # compare to see if the GOTTEN role id matches the one we grabbed from list
237 Should Be Equal ${expected_username} ${testusername}
240 [Documentation] Exercise REST command for DELETE user command.
241 # create a user and then delete it. Use Get to verify it's gone
242 # create information for a new user (for the test)
243 ${testusername}= Create Random Name force-user
244 ${data}= Set Variable {"description":"sample test description", "name":"${testusername}", "userid":1}
246 # Post this disposable user
247 ${content}= Post New User ${testusername} ${data}
248 # parse out the user-id from the content we just created
249 ${userid}= Parse Item From Blob By Offset ${content} 0
252 ${content2}= Delete User ${userid}
254 ${content}= Check Specific Id Does Not Exist user ${userid}
257 Test Get Specific Role
258 [Documentation] Exercise REST command for roles GET command.
259 # from the pre-created (see Setup routine) list, grab a role id for testing
260 ${listlength}= Get Length ${cleanup_role_list}
261 # pop item off of end of the list, for use (does not alter list)
262 Log ${cleanup_role_list}
263 ${role_item}= Get From List ${cleanup_role_list} -1
265 # parse out the role-id from the role info we just created
266 ${roleid}= Parse Item From Blob By Offset ${roleitem} 0
268 # make a GET call to find the material we want
269 ${existing_roleitem}= Get Specific Role ${roleid}
270 # parse out the expected role-id from the content we just created
271 ${eroleid}= Parse Item From Blob By Offset ${existing_roleitem} 0
273 # compare to see if the GOTTEN role id matches the one we grabbed from list
274 Should Be Equal ${eroleid} ${roleid}
277 [Documentation] Exercise REST command for roles GET command.
278 # rely on the creation of a test role in the Setup routine
279 # pop item off of end of the list, for use (does not alter list)
280 Log ${cleanup_role_list}
281 ${role_item}= Get From List ${cleanup_role_list} -1
283 # parse out the role-id from the info we just grabbed
284 ${roleid}= Parse Item From Blob By Offset ${role_item} 0
286 # parse out the name from the same info
287 ${rolename}= Parse Item From Blob By Offset ${role_item} 1
289 # get the entire blob of roles
290 ${content}= Get Roles
291 # parse through that massive blob and get the individual name
292 ${node_count}= Nodecount ${content} roles roleid
293 ${roleid}= Convert To Integer ${roleid}
294 ${roleentry}= Get Role Name By Roleid ${content} ${roleid} ${node_count}
296 # compare to see if the parsed user id matches the one we grabbed from list
297 Should Be Equal ${roleentry} ${rolename}
300 [Documentation] Exercise PUT command against an existing Role ID.
301 # pop item off of end of the list, for use (does not alter list)
302 Log ${cleanup_role_list}
303 ${role_item}= Get From List ${cleanup_role_list} -1
305 # parse out the role-id from the role info we just created
306 ${roleid}= Parse Item From Blob By Offset ${role_item} 0
308 # update the information for the roleid
309 ${testrolename}= Create Random Name force-accomplish
310 ${data}= Set Variable {"description":"sample test description", "name":"${testrolename}"}
311 ${content}= Update Specific Role ${data} ${roleid}
313 # now, make a GET call to find the material we modified
314 ${existing_roleitem}= Get Specific Role ${roleid}
315 # parse out the name from the same info
316 ${expected_rolename}= Parse Item From Blob By Offset ${existing_roleitem} 1
317 Log ${expected_rolename}
318 # compare to see if the GOTTEN role id matches the one we grabbed from list
319 Should Be Equal ${expected_rolename} ${testrolename}
322 [Documentation] Exercise POST command to create a new Role.
323 # create information for a new role (for the test)
324 ${testrolename}= Create Random Name force-brother-cousin
325 ${data}= Set Variable {"description":"sample test description", "name":"${testrolename}", "roleid":1}
328 ${content}= Post New Role ${data}
329 # parse out the role-id from the content we just created
330 ${roleid}= Parse Item From Blob By Offset ${content} 0
332 # now got GET the roleid info and compare to the name we fabricated
333 # and parse out role name
334 ${existing_roleitem}= Get Specific Role ${roleid}
335 ${expected_rolename}= Parse Item From Blob By Offset ${content} 1
336 Log ${expected_rolename}
337 # compare to see if the GOTTEN role id matches the one we grabbed from list
338 Should Be Equal ${expected_rolename} ${testrolename}
341 [Documentation] Exercise REST command for DELETE role command.
342 # create a role and then delete it. Use Get to verify it's gone
343 # create information for a new role (for the test)
344 ${testrolename}= Create Random Name force-usurper
345 ${data}= Set Variable {"description":"sample test description", "name":"${testrolename}", "roleid":1}
347 # Post this disposable role
348 ${content}= Post New Role ${data}
349 # parse out the role-id from the content we just created
350 ${roleid}= Parse Item From Blob By Offset ${content} 0
353 ${content2}= Delete Role ${roleid}
355 ${content}= Check Specific Id Does Not Exist role ${roleid}
358 Test Grant Role To Domain And User
359 [Documentation] Test the POST of a Role to Domain and User
360 # rely on the creation of a test role, user and domain in the Setup routine
361 # pop item off of end of the list, for use (does not alter list)
362 ${role_item}= Get From List ${cleanup_role_list} -1
364 ${user_item}= Get From List ${cleanup_user_list} -1
366 ${domain_item}= Get From List ${cleanup_domain_list} -1
368 # parse out the roleid from the role info we just grabbed
369 ${roleid}= Parse Item From Blob By Offset ${role_item} 0
371 # parse out the name from the same info
372 ${rolename}= Parse Item From Blob By Offset ${role_item} 1
374 # parse out the userid from the user info we just grabbed
375 ${userid}= Parse Item From Blob By Offset ${user_item} 0
377 # parse out the name from the same info
378 ${username}= Parse Item From Blob By Offset ${user_item} 1
380 # parse out the domain-id from the domain info we just grabbed
381 ${domainid}= Parse Item From Blob By Offset ${domain_item} 0
383 # parse out the name from the same info
384 ${domainname}= Parse Item From Blob By Offset ${domain_item} 1
386 # generate the data payload that we wish to post
387 ${data}= Set Variable {"roleid":"${roleid}", "description":"fabricated test roleid"}
389 ${content}= Post Role To Domain And User ${data} ${domainid} ${userid}
390 # add new json string to the cleanup list for later cleanup
391 Append To List ${cleanup_grant_list} ${content}
392 Should Contain ${content} ${domainid}
393 Should Contain ${content} ${roleid}
394 Should Contain ${content} ${userid}
399 # create a domain, role and user for testing.
400 ${HEADERS}= Create Dictionary Content-Type=application/json
402 Set Global Variable ${HEADERS}
403 # create a name to use in each case
404 ${testdomain}= Create Random Name Alderaan
406 ${testuser}= Create Random Name Leia
408 ${testrole}= Create Random Name Force-User
410 # now create the domain, role and userid
411 # create the test domain
412 Create Session httpbin ${URI}
413 ${domaindata}= Set Variable {"description":"planetary domain","domainid":"7","name":"${testdomain}","enabled":"true"}
414 ${newdomain}= Post New Domain ${testdomain} ${domaindata}
416 # add new domain name to the cleanup list for later cleanup
417 Append To List ${cleanup_domain_list} ${newdomain}
418 # now create the test user
419 ${userdata}= Set Variable {"description":"User-of-the-Force","name":"${testuser}","enabled":"true"}
420 ${newuser}= Post New User ${testuser} ${userdata}
422 # add new user name to the cleanup list for later cleanup
423 Append To List ${cleanup_user_list} ${newuser}
424 # now create the test role
425 ${roledata}= Set Variable {"name":"${testrole}","description":"Force User"}
426 ${newrole}= Post New Role ${roledata}
427 # add new role name to the cleanup list for later cleanup
428 Append To List ${cleanup_role_list} ${newrole}
430 # return the three item names to the caller of setup
431 [Return] ${newdomain} ${newuser} ${newrole}
433 IdMLight Suite Teardown
435 ${ELEMENT}= Create Session httpbin ${URI}
436 # if the test domain, role or user exists, wipe it out.
437 : FOR ${ELEMENT} IN @{cleanup_domain_list}
438 \ ${ELEMENT} Replace String ${ELEMENT} ${SPACE} ${EMPTY}
440 \ # split it up to get the domainid
441 \ ${x}= Split String ${ELEMENT} ,
442 \ ${y}= Get From List ${x} 0
443 \ ${z}= Split String ${y} :
444 \ ${domainid}= Get From List ${z} 1
446 \ # convert name on the list to an ID, by which we delete this stuff
447 \ Delete Domain ${domainid}
448 Log ${cleanup_domain_list}
449 # Cleanup roles that were created during testing
450 : FOR ${ELEMENT} IN @{cleanup_role_list}
452 \ ${ELEMENT} Replace String ${ELEMENT} ${SPACE} ${EMPTY}
454 \ # split it up to get the roleid
455 \ ${x}= Split String ${ELEMENT} ,
456 \ ${y}= Get From List ${x} 0
457 \ ${z}= Split String ${y} :
458 \ ${roleid}= Get From List ${z} 1
460 \ # convert name on the list to an ID, by which we delete this stuff
461 \ Delete Role ${roleid}
462 Log ${cleanup_role_list}
463 # Cleanup users that were created during testing
464 : FOR ${ELEMENT} IN @{cleanup_user_list}
466 \ ${ELEMENT} Replace String ${ELEMENT} ${SPACE} ${EMPTY}
468 \ # split it up to get the roleid
469 \ ${x}= Split String ${ELEMENT} ,
470 \ ${y}= Get From List ${x} 0
471 \ ${z}= Split String ${y} :
472 \ ${userid}= Get From List ${z} 1
474 \ Delete User ${userid}
475 Log ${cleanup_user_list}
478 Check Specific Id Does Not Exist
479 [Arguments] ${area_to_look} ${id}
480 [Documentation] Execute GET command on specified single id
481 # the ITEM is the area to look under... users, domains, roles, etc
482 ${n1}= Set Variable auth/v1/${area_to_look}/${id}
484 ${resp} RequestsLibrary.Get Request httpbin ${n1} headers=${HEADERS}
485 Should Be Equal As Strings ${resp.status_code} 404
486 ${id_string}= Convert To String ${id}
487 Should Contain ${resp.content} ${id_string}
488 [Return] ${resp.content}
491 [Arguments] ${domainid}
492 [Documentation] Execute GET command on specified single domain
493 ${n1}= Set Variable auth/v1/domains/${domainid}
494 ${resp} RequestsLibrary.Get Request httpbin ${n1} headers=${HEADERS}
495 Should Be Equal As Strings ${resp.status_code} 200
496 ${domainid_string}= Convert To String ${domainid}
497 Should Contain ${resp.content} ${domainid_string}
498 [Return] ${resp.content}
500 Get Specific Domain Name
501 [Arguments] ${domainid}
502 [Documentation] Execute GET command on specified single domain
503 ${n1}= Set Variable auth/v1/domains/${domainid}
504 ${resp} RequestsLibrary.Get Request httpbin ${n1} headers=${HEADERS}
505 Should Contain ${resp.content} ${domainid}
507 [Return] ${resp.content}
510 [Arguments] ${roleid}
511 [Documentation] Exercise REST command to GET a specific role, based on role-id
512 ${n1}= Set Variable auth/v1/roles/${roleid}
513 ${resp} RequestsLibrary.Get Request httpbin ${n1} headers=${HEADERS}
514 Should Be Equal As Strings ${resp.status_code} 200
515 Should Contain ${resp.content} ${roleid}
516 [Return] ${resp.content}
519 [Documentation] Execute getdomains GET command.
520 ${n1}= Set Variable auth/v1/domains
521 ${resp} RequestsLibrary.Get Request httpbin ${n1} headers=${HEADERS}
522 Should Be Equal As Strings ${resp.status_code} 200
523 Should Contain ${resp.content} "domains"
524 [Return] ${resp.content}
527 [Documentation] Execute GET command to obtain list of roles.
528 ${n1}= Set Variable auth/v1/roles
529 ${resp} RequestsLibrary.Get Request httpbin ${n1} headers=${HEADERS}
530 Should Be Equal As Strings ${resp.status_code} 200
531 Should Contain ${resp.content} "roles"
532 [Return] ${resp.content}
536 [Documentation] Exercise REST command for users GET command.
537 ${n1}= Set Variable auth/v1/users/${user}
538 ${resp} RequestsLibrary.Get Request httpbin ${n1} headers=${HEADERS}
539 Should Be Equal As Strings ${resp.status_code} 200
540 Should Contain ${resp.content} ${user}
541 [Return] ${resp.content}
544 [Documentation] GET the complete set of users.
545 ${n1}= Set Variable auth/v1/users
546 ${resp} RequestsLibrary.Get Request httpbin ${n1} headers=${HEADERS}
547 Should Be Equal As Strings ${resp.status_code} 200
548 Should Contain ${resp.content} ${user}
549 [Return] ${resp.content}
552 [Arguments] ${domain} ${data}
553 [Documentation] Exercise REST command for domains POST command.
554 ${n1}= Set Variable auth/v1/domains
555 ${resp} RequestsLibrary.Post Request httpbin ${n1} headers=${HEADERS} data=${data}
556 Should Be Equal As Strings ${resp.status_code} 201
557 Should Contain ${resp.content} ${domain}
558 [Return] ${resp.content}
562 [Documentation] Use POST REST command to create specified Role.
563 ${n1}= Set Variable auth/v1/roles
564 ${resp} RequestsLibrary.Post Request httpbin ${n1} headers=${HEADERS} data=${data}
565 # HTTP/1.1 201 Created
566 Should Be Equal As Strings ${resp.status_code} 201
567 [Return] ${resp.content}
570 [Arguments] ${username} ${data}
571 [Documentation] Exercise REST command for users POST command.
572 ${n1}= Set Variable auth/v1/users
573 ${resp} RequestsLibrary.Post Request httpbin ${n1} headers=${HEADERS} data=${data}
574 # grab the list of users, count the list, and then search the list for the specific user id
576 ${depth}= Nodecount ${users} users userid
577 ${abc}= Get User Id By Username ${users} ${username} ${depth}
578 Should Be Equal As Strings ${resp.status_code} 201
579 Should Contain ${resp.content} ${username}
580 [Return] ${resp.content}
583 [Arguments] ${jsonblock} ${property}
584 [Documentation] hand this function a block of Json, and it will find your
585 ... user by name and return userid
586 ${foundit}= Get From Dictionary ${jsonblock} ${property}
588 Update Specific Domain
589 [Arguments] ${data} ${domainid}
590 [Documentation] Update the specified domainid with a new name specified in domain-name
591 ${n1}= Set Variable auth/v1/domains/${domainid}
592 ${resp} RequestsLibrary.Put Request httpbin ${n1} headers=${HEADERS} data=${data}
593 # Should Be Equal As Strings ${resp.status_code} 201
597 [Arguments] ${data} ${roleid}
598 [Documentation] Update the specified roleid with a new information name specified
599 ${n1}= Set Variable auth/v1/roles/${roleid}
600 ${resp} RequestsLibrary.Put Request httpbin ${n1} headers=${HEADERS} data=${data}
601 # Should Be Equal As Strings ${resp.status_code} 201
605 [Arguments] ${data} ${userid}
606 [Documentation] Update the specified userid with a new information name specified
607 ${n1}= Set Variable auth/v1/users/${userid}
608 ${resp} RequestsLibrary.Put Request httpbin ${n1} headers=${HEADERS} data=${data}
609 # Should Be Equal As Strings ${resp.status_code} 201
613 [Arguments] ${domainid}
614 [Documentation] Delete the specified domain, by id
615 ${n1}= Set Variable auth/v1/domains/${domainid}
617 ${resp} RequestsLibrary.Delete Request httpbin ${n1} headers=${HEADERS}
618 Should Be Equal As Strings ${resp.status_code} 204
622 [Arguments] ${userid}
623 [Documentation] Delete the specified user, by id
624 ${n1}= Set Variable auth/v1/users/${userid}
625 ${resp} RequestsLibrary.Delete Request httpbin ${n1} headers=${HEADERS}
626 Should Be Equal As Strings ${resp.status_code} 204
630 [Arguments] ${roleid}
631 [Documentation] Use DELETE REST command to wipe out a Role created for testing.
632 ${n1}= Set Variable auth/v1/roles/${roleid}
633 ${resp} RequestsLibrary.Delete Request httpbin ${n1} headers=${HEADERS}
634 Should Be Equal As Strings ${resp.status_code} 204
635 #Should NOT Contain ${resp.content} ${roleid}
636 [Return] ${resp.content}
638 Post Role To Domain And User
639 [Arguments] ${data} ${domainid} ${userid}
640 [Documentation] Exercise REST POST command for posting a role to particular domain and user
641 ${n1}= Set Variable auth/v1/domains/${domainid}/users/${userid}/roles
643 ${resp} RequestsLibrary.Post Request httpbin ${n1} headers=${HEADERS} data=${data}
644 Should Be Equal As Strings ${resp.status_code} 201
645 [Return] ${resp.content}
647 Get Roles For Specific Domain And User
648 [Arguments] ${domainid} ${userid}
649 [Documentation] Exercise REST GET command for roles in a specific domain and user
650 ${n1}= Set Variable auth/v1/domains/${domainid}/users/${userid}/roles
652 ${resp} RequestsLibrary.Get Request httpbin ${n1} headers=${HEADERS}
653 Should Be Equal As Strings ${resp.status_code} 200
654 [Return] ${resp.content}
656 Delete Specific Grant
657 [Arguments] ${domainid} ${userid} ${roleid}
658 [Documentation] Exercise REST DELETE command for a grant by roleid
659 ${n1}= Set Variable auth/v1/domains/${domainid}/users/${userid}/roles/${roleid}
661 ${resp} RequestsLibrary.Delete Request httpbin ${n1} headers=${HEADERS}
662 Should Be Equal As Strings ${resp.status_code} 204
663 [Return] ${resp.content}
665 Parse Item From Blob By Offset
666 [Arguments] ${item} ${offset}
667 [Documentation] Parse out a field from JSON structure
668 ${x}= Split String ${item} ,
669 ${y}= Get From List ${x} ${offset}
670 ${z}= Split String ${y} :
671 # offset is one in next line because you are looking at a key:value pair
672 ${return_item_}= Get From List ${z} 1
673 ${return_item}= Replace String ${return_item_} " ${EMPTY}
674 [Return] ${return_item}
677 [Arguments] ${basename}
678 [Documentation] Take the basename given and return a new name with date-time-stamp appended.
679 ${datetime}= Get Current Date result_format=%Y-%m-%d-%H-%M
681 ${newname}= Catenate SEPARATOR=- ${basename} ${datetime}
685 [Arguments] ${jsonstring}
686 [Documentation] Pop the name item out of the Json string
687 # split it up to get the id
688 ${x}= Split String ${jsonstring} ,
689 ${y}= Get From List ${x} 1
690 ${z}= Split String ${y} :
691 ${name}= Get From List ${z} 1
692 ${name}= Replace String ${name} " ${EMPTY}
697 [Arguments] ${content_block} ${keyvar}
698 [Documentation] Verify that the content block passed in, contains the variable identified in second argument
699 Should Contain ${content_block} ${keyvar}
702 [Documentation] Clean up domains, users, roles in db, keep original 4 of each
703 ${domains}= Get Domains
706 ${domcount}= Nodecount ${domains} domains "domainid"
707 ${rolecount}= Nodecount ${roles} roles "roleid"
708 ${usercount}= Nodecount ${users} users "userid"
709 : FOR ${index} IN RANGE 5 ${domains}
710 \ Delete Domain ${index}
711 : FOR ${index} IN RANGE 5 ${roles}
712 \ Delete Role ${index}
713 : FOR ${index} IN RANGE 5 ${users}
714 \ Delete User ${index}