Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- *** Keywords ***
- GET AUTH_TOKEN
- [Arguments] ${CREDENTIALS}
- Create Session AUTH ${ROOT_URL} verify=${True}
- ${resp}= POST Request AUTH /token
- ... headers=${HEADERS}
- ... data=${CREDENTIALS}
- ... timeout=${timeout}
- Should Be Equal As Strings ${resp.status_code} 200
- ${response}= Set Variable ${resp.json()}
- ${access_token}= Set Variable Bearer ${response['access_token']}
- Set Suite Variable ${auth_token} ${access_token}
- # Log To Console ${auth_token}
- [Return] ${auth_token}
- Create Admin Session
- [Documentation] Admin session for API foo bar
- ${admin_token}= GET AUTH_TOKEN ${ADMIN}
- ${admin_headers}= Create Dictionary Authorization=${admin_token}
- ... Content-Type=application/json # or what ever you need
- Create Session ADMIN ${YOUR_API_ROOT_URL} verify=True
- ... headers=${admin_headers}
- ... max_retries=5
- ... backoff_factor=0.5
- ... timeout=${timeout}
- Create ${ROLE_BASED} Session
- [Documentation] Create session for specific user role.
- ... Valid roles: ADMIN, USER_1, USER_2, ...
- ${bearer_token}= GET AUTH_TOKEN ${${ROLE_BASED}}
- ${session_headers}= Create Dictionary Authorization=${bearer_token}
- ... Content-Type=application/json
- Create Session ${ROLE_BASED} ${ROOT_URL} verify=True
- ... headers=${session_headers}
- ... max_retries=5
- ... backoff_factor=0.5
- ... timeout=${timeout}
- # Calling above keyword
- Create ADMIN Session
- Create USER_1 Session
- Create USER_2 Session
- *** Test Cases ***
- 000 Get Email Information of Foo Bar
- As ADMIN Call GET /my_api/vers001/endpoint/email
- # VERIFICATION
- Response Should Return Status Code 200
- Response Should Contain Value foo bar
- Response Should Contain Key foo_bar=bar_foo
- ...
- *** Keywords ***
- As ${ROLE} Call ${METHOD} ${ENDPOINT}
- ${response}= Run Keyword ${METHOD} Request ${ROLE} ${ENDPOINT}
- Set Test Variable ${response}
- Log ${response.content}
Add Comment
Please, Sign In to add comment