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"
43 # Have to escape the quotes, need quotes to make the POST work properly
44 ${data}= Set Variable {"description":${domaindesc},"domainid":"7","name":\"${domainName}\","enabled":${domainstatus}}
47 ${domain}= Post New Domain ${domainName} ${data}
50 ${domainid}= Parse Item From Blob By Offset ${domain} 0
53 # get the domain to verify
54 ${fetched_domain}= Get Specific Domain ${domainid}
55 # add new domain json string to the cleanup list for later cleanup
56 Append To List ${cleanup_domain_list} ${fetched_domain}
57 # count the number of domainid's that appear in this block of JSON
58 ${depth}= Fieldcount ${fetched_domain} "domainid"
59 ${fetchedDomStatus}= Get Domain State By Domainid ${domain} ${domainid} ${depth}
60 ${fetchedDomDesc}= Get Domain Description By Domainid ${domain} ${domainid} ${depth}
61 # Set Test Disposition based on comparison of what was posted and what was fetched
62 ${testdisposition}= Set Variable If '${fetched_domain}' == '${domain}' '${fetchedDomStatus}' == '${domainstatus}' '${fetchedDomDesc}' == '${domaindesc}'
63 Log ${testdisposition}
66 [Documentation] Exercise REST GET command to get all domains.
67 # rely on the creation of a test role in the Setup routine
68 # pop item off of end of the cleanup list, for use (does not alter list)
69 Log ${cleanup_domain_list}
70 ${domain_item}= Get From List ${cleanup_domain_list} -1
73 # parse out the domainid from the domain info we just grabbed
74 ${domainid}= Parse Item From Blob By Offset ${domain_item} 0
77 # parse out the name from the same info
78 ${domainname}= Parse Item From Blob By Offset ${domain_item} 1
81 # get the entire dump of created domains
82 ${content}= Get Domains
84 # parse through that massive blob and get the individual name created in Setup
85 ${node_count}= Nodecount ${content} domains domainid
86 ${domainid}= Convert To Integer ${domainid}
88 # Get the domain name from the database, looking it up by its domainid
89 ${domainentry}= Get Domain Name By Domainid ${content} ${domainid} ${node_count}
92 # compare to see if the parsed user id matches the one we grabbed from list
93 Should Be Equal ${domainentry} ${domainname}
95 Test Get Specific Domain
96 [Documentation] Get a specific domain using REST GET command.
97 # from the pre-created (see Setup routine) list, grab a domain id for testing
98 ${listlength}= Get Length ${cleanup_domain_list}
99 # pop item off of end of the list, for use (does not alter list)
100 Log ${cleanup_domain_list}
101 ${domain_item}= Get From List ${cleanup_domain_list} -1
102 ${item}= Pop Name Off Json ${domain_item}
103 # convert this crap to unicode
104 # ${item}= Convert To String ${item}
106 # make a GET call to find the material we want to delete
107 ${domains}= Get Domains
108 # convert name on the list to an ID, by which we delete this stuff
109 ${node_count}= Nodecount ${domains} domains domainid
110 ${node_count}= Convert To Integer ${node_count}
111 ${domainid}= Get Domain Id By Domainname ${domains} ${item} ${node_count}
112 # now, get the specific domain by it's domainid
113 ${domaininfo}= Get Specific Domain ${domainid}
114 Should Contain ${domaininfo} ${item}
117 Test Update Specific Domain
118 [Documentation] Update a specific domain using REST PUT command.
119 # rely on the creation of a test domain in the Setup routine
120 # pop item off of end of the list, for use (does not alter list)
121 Log ${cleanup_domain_list}
122 ${domain_item}= Get From List ${cleanup_domain_list} -1
125 # parse out the domain id from the domain info we just grabbed
126 ${domid}= Parse Item From Blob By Offset ${domain_item} 0
129 # parse out the name from the same info
130 ${domname}= Parse Item From Blob By Offset ${domain_item} 1
133 ${data}= Set Variable {"name":"MasterTest Domain"}
134 Update Specific Domain ${data} ${domid}
135 ${domname}= Get Specific Domain Name ${domid}
137 ${z}= Split String ${data} :
138 ${dname}= Get From List ${z} 1
139 ${dname}= Replace String ${dname} " ${EMPTY}
140 ${dname}= Replace String ${dname} } ${EMPTY}
142 ${modified_name}= Pop Name Off Json ${domname}
144 Should Be Equal ${dname} ${modified_name}
147 [Documentation] Delete a specific domain using REST DELETE command.
148 # create a temporary test domain
149 ${tempdomain}= Create Random Name temp-domain-name
150 ${domaindata}= Set Variable {"description":"temporary test domain","domainid":"1","name":"${tempdomain}","enabled":"true"}
151 # Post that temp domain
152 ${newdomain}= Post New Domain ${tempdomain} ${domaindata}
154 # parse out the domain-id from the domain info we just created
155 ${domainid}= Parse Item From Blob By Offset ${newdomain} 0
158 # now wipe if off the map
159 Delete Domain ${domainid}
160 # we should not be able to fetch this domain from the database of domains...should fail...
161 ${content}= Check Specific Id Does Not Exist domain ${domainid}
165 [Documentation] Exercise REST GET command for obtaining all users.
166 # rely on the creation of a test user in the Setup routine
167 # pop item off of end of the list, for use (does not alter list)
168 Log ${cleanup_user_list}
169 ${user_item}= Get From List ${cleanup_user_list} -1
172 # parse out the userid from the user info we just grabbed
173 ${userid}= Parse Item From Blob By Offset ${user_item} 0
176 # parse out the name from the same info
177 ${username}= Parse Item From Blob By Offset ${user_item} 1
180 # get the entire blob of users
181 ${content}= Get Users
182 # parse through that massive blob and get the individual name
183 ${node_count}= Nodecount ${content} users userid
184 ${userid}= Convert To Integer ${userid}
185 ${userentry}= Get User Name By Userid ${content} ${userid} ${node_count}
187 # compare to see if the parsed user id matches the one we grabbed from list
188 Should Be Equal ${userentry} ${username}
190 Test Get Specific User
191 [Documentation] Exercise REST GET command to obtain a specific user.
192 # from the pre-created (see Setup routine) list, grab a user id for testing
193 ${listlength}= Get Length ${cleanup_user_list}
194 # pop item off of end of the list, for use (does not alter list)
195 Log ${cleanup_user_list}
196 ${user_item}= Get From List ${cleanup_user_list} -1
197 ${item}= Pop Name Off Json ${user_item}
198 # convert this to unicode
199 # ${item}= Convert To String ${item}
202 # parse out the userid from the user info we just grabbed
203 ${userid}= Parse Item From Blob By Offset ${user_item} 0
206 # parse out the name from the same info
207 ${username}= Parse Item From Blob By Offset ${user_item} 1
210 # make a GET call to find the material we want
211 ${content}= Get Specific User ${userid}
213 # parse out the user name from the content we just fetched
214 ${fetched_username}= Parse Item From Blob By Offset ${content} 1
215 Log ${fetched_username}
217 # compare to see if the parsed user name matches the one we grabbed from list
218 Should Contain ${fetched_username} ${username}
221 [Documentation] Exercise PUT command against an existing User ID.
222 # pop item off of end of the list, for use (does not alter list)
223 Log ${cleanup_user_list}
224 ${user_item}= Get From List ${cleanup_user_list} -1
227 # parse out the user-id from the user info we just created
228 ${userid}= Parse Item From Blob By Offset ${user_item} 0
231 # update the information for the userid
232 ${testusername}= Create Random Name force-accomplish
233 ${data}= Set Variable {"description":"sample test description", "name":"${testusername}"}
234 ${content}= Update Specific User ${data} ${userid}
236 # now, make a GET call to find the material we modified
237 ${existing_useritem}= Get Specific User ${userid}
239 # parse out the name from the existing userinfo
240 ${expected_username}= Parse Item From Blob By Offset ${existing_useritem} 1
241 Log ${expected_username}
243 # compare to see if the GOTTEN user id matches the one we grabbed from list
244 Should Be Equal ${expected_username} ${testusername}
247 [Documentation] Test the POST command to create a new user.
248 # create information for a new role (for the test)
249 ${testusername}= Create Random Name Darth-Maul
250 ${data}= Set Variable {"description":"sample user description", "name":"${testusername}", "userid":1}
254 ${content}= Post New User ${testusername} ${data}
255 # parse out the userid from the content we just created
256 ${userid}= Parse Item From Blob By Offset ${content} 0
259 # now go GET the userid info and compare to the name we fabricated
260 ${existing_useritem}= Get Specific User ${userid}
262 ${expected_username}= Parse Item From Blob By Offset ${existing_useritem} 1
263 Log ${expected_username}
265 # compare to see if the GOTTEN role id matches the one we grabbed from list
266 Should Be Equal ${expected_username} ${testusername}
269 [Documentation] Exercise REST command for DELETE user command.
270 # create a user and then delete it. Use Get to verify it's gone
271 # create information for a new user (for the test)
272 ${testusername}= Create Random Name force-user
273 ${data}= Set Variable {"description":"sample test description", "name":"${testusername}", "userid":1}
275 # Post this disposable user
276 ${content}= Post New User ${testusername} ${data}
277 # parse out the user-id from the content we just created
278 ${userid}= Parse Item From Blob By Offset ${content} 0
282 ${content2}= Delete User ${userid}
284 ${content}= Check Specific Id Does Not Exist user ${userid}
287 Test Get Specific Role
288 [Documentation] Exercise REST command for roles GET command.
289 # from the pre-created (see Setup routine) list, grab a role id for testing
290 ${listlength}= Get Length ${cleanup_role_list}
291 # pop item off of end of the list, for use (does not alter list)
292 Log ${cleanup_role_list}
293 ${role_item}= Get From List ${cleanup_role_list} -1
295 # parse out the role-id from the role info we just created
296 ${roleid}= Parse Item From Blob By Offset ${roleitem} 0
299 # make a GET call to find the material we want
300 ${existing_roleitem}= Get Specific Role ${roleid}
302 # parse out the expected role-id from the content we just created
303 ${eroleid}= Parse Item From Blob By Offset ${existing_roleitem} 0
305 # compare to see if the GOTTEN role id matches the one we grabbed from list
306 Should Be Equal ${eroleid} ${roleid}
309 [Documentation] Exercise REST command for roles GET command.
310 # rely on the creation of a test role in the Setup routine
311 # pop item off of end of the list, for use (does not alter list)
312 Log ${cleanup_role_list}
313 ${role_item}= Get From List ${cleanup_role_list} -1
316 # parse out the role-id from the info we just grabbed
317 ${roleid}= Parse Item From Blob By Offset ${role_item} 0
319 # parse out the name from the same info
320 ${rolename}= Parse Item From Blob By Offset ${role_item} 1
323 # get the entire blob of roles
324 ${content}= Get Roles
325 # parse through that massive blob and get the individual name
326 ${node_count}= Nodecount ${content} roles roleid
327 ${roleid}= Convert To Integer ${roleid}
328 ${roleentry}= Get Role Name By Roleid ${content} ${roleid} ${node_count}
330 # compare to see if the parsed user id matches the one we grabbed from list
331 Should Be Equal ${roleentry} ${rolename}
334 [Documentation] Exercise PUT command against an existing Role ID.
335 # pop item off of end of the list, for use (does not alter list)
336 Log ${cleanup_role_list}
337 ${role_item}= Get From List ${cleanup_role_list} -1
339 # parse out the role-id from the role info we just created
340 ${roleid}= Parse Item From Blob By Offset ${role_item} 0
343 # update the information for the roleid
344 ${testrolename}= Create Random Name force-accomplish
345 ${data}= Set Variable {"description":"sample test description", "name":"${testrolename}"}
346 ${content}= Update Specific Role ${data} ${roleid}
348 # now, make a GET call to find the material we modified
349 ${existing_roleitem}= Get Specific Role ${roleid}
351 # parse out the name from the same info
352 ${expected_rolename}= Parse Item From Blob By Offset ${existing_roleitem} 1
353 Log ${expected_rolename}
355 # compare to see if the GOTTEN role id matches the one we grabbed from list
356 Should Be Equal ${expected_rolename} ${testrolename}
359 [Documentation] Exercise POST command to create a new Role.
360 # create information for a new role (for the test)
361 ${testrolename}= Create Random Name force-brother-cousin
362 ${data}= Set Variable {"description":"sample test description", "name":"${testrolename}", "roleid":1}
365 ${content}= Post New Role ${data}
366 # parse out the role-id from the content we just created
367 ${roleid}= Parse Item From Blob By Offset ${content} 0
370 # now got GET the roleid info and compare to the name we fabricated
371 # and parse out role name
372 ${existing_roleitem}= Get Specific Role ${roleid}
373 ${expected_rolename}= Parse Item From Blob By Offset ${content} 1
374 Log ${expected_rolename}
376 # compare to see if the GOTTEN role id matches the one we grabbed from list
377 Should Be Equal ${expected_rolename} ${testrolename}
380 [Documentation] Exercise REST command for DELETE role command.
381 # create a role and then delete it. Use Get to verify it's gone
382 # create information for a new role (for the test)
383 ${testrolename}= Create Random Name force-usurper
384 ${data}= Set Variable {"description":"sample test description", "name":"${testrolename}", "roleid":1}
386 # Post this disposable role
387 ${content}= Post New Role ${data}
388 # parse out the role-id from the content we just created
389 ${roleid}= Parse Item From Blob By Offset ${content} 0
393 ${content2}= Delete Role ${roleid}
395 ${content}= Check Specific Id Does Not Exist role ${roleid}
398 Test Grant Role To Domain And User
399 [Documentation] Test the POST of a Role to Domain and User
401 # rely on the creation of a test role, user and domain in the Setup routine
402 # pop item off of end of the list, for use (does not alter list)
403 ${role_item}= Get From List ${cleanup_role_list} -1
405 ${user_item}= Get From List ${cleanup_user_list} -1
407 ${domain_item}= Get From List ${cleanup_domain_list} -1
410 # parse out the roleid from the role info we just grabbed
411 ${roleid}= Parse Item From Blob By Offset ${role_item} 0
414 # parse out the name from the same info
415 ${rolename}= Parse Item From Blob By Offset ${role_item} 1
418 # parse out the userid from the user info we just grabbed
419 ${userid}= Parse Item From Blob By Offset ${user_item} 0
422 # parse out the name from the same info
423 ${username}= Parse Item From Blob By Offset ${user_item} 1
426 # parse out the domain-id from the domain info we just grabbed
427 ${domainid}= Parse Item From Blob By Offset ${domain_item} 0
430 # parse out the name from the same info
431 ${domainname}= Parse Item From Blob By Offset ${domain_item} 1
434 # generate the data payload that we wish to post
435 ${data}= Set Variable {"roleid":"${roleid}", "description":"fabricated test roleid"}
437 ${content}= Post Role To Domain And User ${data} ${domainid} ${userid}
438 # add new json string to the cleanup list for later cleanup
439 Append To List ${cleanup_grant_list} ${content}
440 Should Contain ${content} ${domainid}
441 Should Contain ${content} ${roleid}
442 Should Contain ${content} ${userid}
448 # create a domain, role and user for testing.
449 ${HEADERS}= Create Dictionary Content-Type=application/json
451 Set Global Variable ${HEADERS}
452 # create a name to use in each case
453 ${testdomain}= Create Random Name Alderaan
455 ${testuser}= Create Random Name Leia
457 ${testrole}= Create Random Name Force-User
459 # now create the domain, role and userid
461 # create the test domain
462 Create Session httpbin ${URI}
463 ${domaindata}= Set Variable {"description":"planetary domain","domainid":"7","name":"${testdomain}","enabled":"true"}
464 ${newdomain}= Post New Domain ${testdomain} ${domaindata}
466 # add new domain name to the cleanup list for later cleanup
467 Append To List ${cleanup_domain_list} ${newdomain}
468 # now create the test user
469 ${userdata}= Set Variable {"description":"User-of-the-Force","name":"${testuser}","enabled":"true"}
470 ${newuser}= Post New User ${testuser} ${userdata}
472 # add new user name to the cleanup list for later cleanup
473 Append To List ${cleanup_user_list} ${newuser}
474 # now create the test role
475 ${roledata}= Set Variable {"name":"${testrole}","description":"Force User"}
476 ${newrole}= Post New Role ${roledata}
477 # add new role name to the cleanup list for later cleanup
478 Append To List ${cleanup_role_list} ${newrole}
480 # return the three item names to the caller of setup
481 [Return] ${newdomain} ${newuser} ${newrole}
483 IdMLight Suite Teardown
485 ${ELEMENT}= Create Session httpbin ${URI}
486 # if the test domain, role or user exists, wipe it out.
487 : FOR ${ELEMENT} IN @{cleanup_domain_list}
488 \ ${ELEMENT} Replace String ${ELEMENT} ${SPACE} ${EMPTY}
490 \ # split it up to get the domainid
491 \ ${x}= Split String ${ELEMENT} ,
492 \ ${y}= Get From List ${x} 0
493 \ ${z}= Split String ${y} :
494 \ ${domainid}= Get From List ${z} 1
496 \ # convert name on the list to an ID, by which we delete this stuff
497 \ Delete Domain ${domainid}
498 Log ${cleanup_domain_list}
499 # Cleanup roles that were created during testing
500 : FOR ${ELEMENT} IN @{cleanup_role_list}
502 \ ${ELEMENT} Replace String ${ELEMENT} ${SPACE} ${EMPTY}
504 \ # split it up to get the roleid
505 \ ${x}= Split String ${ELEMENT} ,
506 \ ${y}= Get From List ${x} 0
507 \ ${z}= Split String ${y} :
508 \ ${roleid}= Get From List ${z} 1
510 \ # convert name on the list to an ID, by which we delete this stuff
511 \ Delete Role ${roleid}
512 Log ${cleanup_role_list}
513 # Cleanup users that were created during testing
514 : FOR ${ELEMENT} IN @{cleanup_user_list}
516 \ ${ELEMENT} Replace String ${ELEMENT} ${SPACE} ${EMPTY}
518 \ # split it up to get the roleid
519 \ ${x}= Split String ${ELEMENT} ,
520 \ ${y}= Get From List ${x} 0
521 \ ${z}= Split String ${y} :
522 \ ${userid}= Get From List ${z} 1
524 \ Delete User ${userid}
525 Log ${cleanup_user_list}
529 Check Specific Id Does Not Exist
530 [Arguments] ${area_to_look} ${id}
531 [Documentation] Execute GET command on specified single id
532 # the ITEM is the area to look under... users, domains, roles, etc
533 ${n1}= Set Variable auth/v1/${area_to_look}/${id}
535 ${resp} RequestsLibrary.Get httpbin ${n1} headers=${HEADERS}
536 Should Be Equal As Strings ${resp.status_code} 404
537 ${id_string}= Convert To String ${id}
538 Should Contain ${resp.content} ${id_string}
539 [Return] ${resp.content}
542 [Arguments] ${domainid}
543 [Documentation] Execute GET command on specified single domain
544 ${n1}= Set Variable auth/v1/domains/${domainid}
545 ${resp} RequestsLibrary.Get httpbin ${n1} headers=${HEADERS}
546 Should Be Equal As Strings ${resp.status_code} 200
547 ${domainid_string}= Convert To String ${domainid}
548 Should Contain ${resp.content} ${domainid_string}
549 [Return] ${resp.content}
551 Get Specific Domain Name
552 [Arguments] ${domainid}
553 [Documentation] Execute GET command on specified single domain
554 ${n1}= Set Variable auth/v1/domains/${domainid}
555 ${resp} RequestsLibrary.Get httpbin ${n1} headers=${HEADERS}
556 Should Contain ${resp.content} ${domainid}
558 [Return] ${resp.content}
561 [Arguments] ${roleid}
562 [Documentation] Exercise REST command to GET a specific role, based on role-id
563 ${n1}= Set Variable auth/v1/roles/${roleid}
564 ${resp} RequestsLibrary.Get httpbin ${n1} headers=${HEADERS}
565 Should Be Equal As Strings ${resp.status_code} 200
566 Should Contain ${resp.content} ${roleid}
567 [Return] ${resp.content}
570 [Documentation] Execute getdomains GET command.
571 ${n1}= Set Variable auth/v1/domains
572 ${resp} RequestsLibrary.Get httpbin ${n1} headers=${HEADERS}
573 Should Be Equal As Strings ${resp.status_code} 200
574 Should Contain ${resp.content} "domains"
575 [Return] ${resp.content}
578 [Documentation] Execute GET command to obtain list of roles.
579 ${n1}= Set Variable auth/v1/roles
580 ${resp} RequestsLibrary.Get httpbin ${n1} headers=${HEADERS}
581 Should Be Equal As Strings ${resp.status_code} 200
582 Should Contain ${resp.content} "roles"
583 [Return] ${resp.content}
587 [Documentation] Exercise REST command for users GET command.
588 ${n1}= Set Variable auth/v1/users/${user}
589 ${resp} RequestsLibrary.Get httpbin ${n1} headers=${HEADERS}
590 Should Be Equal As Strings ${resp.status_code} 200
591 Should Contain ${resp.content} ${user}
592 [Return] ${resp.content}
595 [Documentation] GET the complete set of users.
596 ${n1}= Set Variable auth/v1/users
597 ${resp} RequestsLibrary.Get httpbin ${n1} headers=${HEADERS}
598 Should Be Equal As Strings ${resp.status_code} 200
599 Should Contain ${resp.content} ${user}
600 [Return] ${resp.content}
603 [Arguments] ${domain} ${data}
604 [Documentation] Exercise REST command for domains POST command.
605 ${n1}= Set Variable auth/v1/domains
606 ${resp} RequestsLibrary.Post httpbin ${n1} headers=${HEADERS} data=${data}
607 Should Be Equal As Strings ${resp.status_code} 201
608 Should Contain ${resp.content} ${domain}
609 [Return] ${resp.content}
613 [Documentation] Use POST REST command to create specified Role.
614 ${n1}= Set Variable auth/v1/roles
615 ${resp} RequestsLibrary.Post httpbin ${n1} headers=${HEADERS} data=${data}
616 # HTTP/1.1 201 Created
617 Should Be Equal As Strings ${resp.status_code} 201
618 [Return] ${resp.content}
621 [Arguments] ${username} ${data}
622 [Documentation] Exercise REST command for users POST command.
623 ${n1}= Set Variable auth/v1/users
624 ${resp} RequestsLibrary.Post httpbin ${n1} headers=${HEADERS} data=${data}
625 # grab the list of users, count the list, and then search the list for the specific user id
627 ${depth}= Nodecount ${users} users userid
628 ${abc}= Get User Id By Username ${users} ${username} ${depth}
629 Should Be Equal As Strings ${resp.status_code} 201
630 Should Contain ${resp.content} ${username}
631 [Return] ${resp.content}
634 [Arguments] ${jsonblock} ${property}
635 [Documentation] hand this function a block of Json, and it will find your
636 ... user by name and return userid
637 ${foundit}= Get From Dictionary ${jsonblock} ${property}
639 Update Specific Domain
640 [Arguments] ${data} ${domainid}
641 [Documentation] Update the specified domainid with a new name specified in domain-name
642 ${n1}= Set Variable auth/v1/domains/${domainid}
643 ${resp} RequestsLibrary.Put httpbin ${n1} headers=${HEADERS} data=${data}
644 # Should Be Equal As Strings ${resp.status_code} 201
648 [Arguments] ${data} ${roleid}
649 [Documentation] Update the specified roleid with a new information name specified
650 ${n1}= Set Variable auth/v1/roles/${roleid}
651 ${resp} RequestsLibrary.Put httpbin ${n1} headers=${HEADERS} data=${data}
652 # Should Be Equal As Strings ${resp.status_code} 201
656 [Arguments] ${data} ${userid}
657 [Documentation] Update the specified userid with a new information name specified
658 ${n1}= Set Variable auth/v1/users/${userid}
659 ${resp} RequestsLibrary.Put httpbin ${n1} headers=${HEADERS} data=${data}
660 # Should Be Equal As Strings ${resp.status_code} 201
664 [Arguments] ${domainid}
665 [Documentation] Delete the specified domain, by id
666 ${n1}= Set Variable auth/v1/domains/${domainid}
668 ${resp} RequestsLibrary.Delete httpbin ${n1} headers=${HEADERS}
669 Should Be Equal As Strings ${resp.status_code} 204
673 [Arguments] ${userid}
674 [Documentation] Delete the specified user, by id
675 ${n1}= Set Variable auth/v1/users/${userid}
676 ${resp} RequestsLibrary.Delete httpbin ${n1} headers=${HEADERS}
677 Should Be Equal As Strings ${resp.status_code} 204
681 [Arguments] ${roleid}
682 [Documentation] Use DELETE REST command to wipe out a Role created for testing.
683 ${n1}= Set Variable auth/v1/roles/${roleid}
684 ${resp} RequestsLibrary.Delete httpbin ${n1} headers=${HEADERS}
685 Should Be Equal As Strings ${resp.status_code} 204
686 #Should NOT Contain ${resp.content} ${roleid}
687 [Return] ${resp.content}
689 Post Role To Domain And User
690 [Arguments] ${data} ${domainid} ${userid}
691 [Documentation] Exercise REST POST command for posting a role to particular domain and user
692 ${n1}= Set Variable auth/v1/domains/${domainid}/users/${userid}/roles
694 ${resp} RequestsLibrary.Post httpbin ${n1} headers=${HEADERS} data=${data}
695 Should Be Equal As Strings ${resp.status_code} 201
696 [Return] ${resp.content}
698 Get Roles For Specific Domain And User
699 [Arguments] ${domainid} ${userid}
700 [Documentation] Exercise REST GET command for roles in a specific domain and user
701 ${n1}= Set Variable auth/v1/domains/${domainid}/users/${userid}/roles
703 ${resp} RequestsLibrary.Get httpbin ${n1} headers=${HEADERS}
704 Should Be Equal As Strings ${resp.status_code} 200
705 [Return] ${resp.content}
707 Delete Specific Grant
708 [Arguments] ${domainid} ${userid} ${roleid}
709 [Documentation] Exercise REST DELETE command for a grant by roleid
710 ${n1}= Set Variable auth/v1/domains/${domainid}/users/${userid}/roles/${roleid}
712 ${resp} RequestsLibrary.Delete httpbin ${n1} headers=${HEADERS}
713 Should Be Equal As Strings ${resp.status_code} 204
714 [Return] ${resp.content}
716 Parse Item From Blob By Offset
717 [Documentation] Parse out a field from JSON structure
718 [Arguments] ${item} ${offset}
719 ${x}= Split String ${item} ,
720 ${y}= Get From List ${x} ${offset}
721 ${z}= Split String ${y} :
723 # offset is one in next line because you are looking at a key:value pair
724 ${return_item_}= Get From List ${z} 1
725 ${return_item}= Replace String ${return_item_} " ${EMPTY}
726 [Return] ${return_item}
729 [Arguments] ${basename}
730 [Documentation] Take the basename given and return a new name with date-time-stamp appended.
731 ${datetime}= Get Current Date result_format=%Y-%m-%d-%H-%M
733 ${newname}= Catenate SEPARATOR=- ${basename} ${datetime}
737 [Arguments] ${jsonstring}
738 [Documentation] Pop the name item out of the Json string
739 # split it up to get the id
740 ${x}= Split String ${jsonstring} ,
741 ${y}= Get From List ${x} 1
742 ${z}= Split String ${y} :
743 ${name}= Get From List ${z} 1
744 ${name}= Replace String ${name} " ${EMPTY}
749 [Arguments] ${content_block} ${keyvar}
750 [Documentation] Verify that the content block passed in, contains the variable identified in second argument
751 Should Contain ${content_block} ${keyvar}
754 [Documentation] Clean up domains, users, roles in db, keep original 4 of each
755 ${domains}= Get Domains
758 ${domcount}= Nodecount ${domains} domains "domainid"
759 ${rolecount}= Nodecount ${roles} roles "roleid"
760 ${usercount}= Nodecount ${users} users "userid"
761 : FOR ${index} IN RANGE 5 ${domains}
762 \ Delete Domain ${index}
763 : FOR ${index} IN RANGE 5 ${roles}
764 \ Delete Role ${index}
765 : FOR ${index} IN RANGE 5 ${users}
766 \ Delete User ${index}