2 Documentation AAA System Tests
3 Suite Setup Credential Authentication Suite Setup
4 Suite Teardown Credential Authentication Suite Teardown
6 Library OperatingSystem
8 Library HttpLibrary.HTTP
9 Library RequestsLibrary
10 Library ../../../libraries/Common.py
11 Resource ../../../libraries/Utils.robot
12 Variables ../../../variables/Variables.py
13 Resource ../../../libraries/AAAKeywords.robot
18 Get Token With Valid Username And Password
19 [Documentation] Sanity test to ensure default user/password can get a token
20 ${auth_token}= Get Auth Token
21 Should Be String ${auth_token}
22 Log Token: ${auth_token}
23 Validate Token Format ${auth_token}
25 Fail To Get Token With Invalid Username And Password
26 [Documentation] Negative test to verify invalid user/password is denied a token
27 ${bad_user}= Set Variable notTheAdmin
28 ${auth_data}= Create Auth Data ${bad_user} notTheAdminPassword
29 ${resp}= AAA Login ${CONTROLLER} ${auth_data}
30 Should Be Equal As Strings ${resp.status_code} 401
32 ${error_msg}= Extract Value From Content ${resp.content} /error strip
33 Should Be Equal As Strings ${error_msg} User :${bad_user} does not exist
35 Create Token with Client Authorization
36 [Documentation] Get a token using client domain
37 ${auth_token}= Get Auth Token ${USER} ${PWD} ${SCOPE} dlux secrete
38 Should Be String ${auth_token}
39 Log Token: ${auth_token}
40 Validate Token Format ${auth_token}
42 Token Authentication In REST Request
43 [Documentation] Use a token to make a successful REST transaction
44 ${auth_token}= Get Auth Token
45 Make REST Transaction 200 ${auth_token}
47 Revoke Token And Verify Transaction Fails
48 [Documentation] negative test to revoke valid token and check that REST transaction fails
49 ${auth_token}= Get Auth Token
50 Make REST Transaction 200 ${auth_token}
51 Revoke Auth Token ${auth_token}
52 Make REST Transaction 401 ${auth_token}
54 Disable Authentication And Re-Enable Authentication
55 [Documentation] Toggles authentication off and verifies that no login credentials are needed for REST transactions
56 Disable Authentication On Controller ${CONTROLLER}
57 Wait Until Keyword Succeeds 10s 1s Make REST Transaction 200
58 Enable Authentication On Controller ${CONTROLLER}
59 Wait Until Keyword Succeeds 10s 1s Validate That Authentication Fails With Wrong Token
60 ${auth_token}= Get Auth Token
61 Make REST Transaction 200 ${auth_token}
64 Validate That Authentication Fails With Wrong Token
65 ${bad_token}= Set Variable notARealToken
66 Make REST Transaction 401 ${bad_token}
69 [Arguments] ${expected_status_code} ${auth_data}=${EMPTY}
70 Create Session ODL_SESSION http://${CONTROLLER}:8181
71 ${headers}= Create Dictionary Content-Type=application/x-www-form-urlencoded
72 Run Keyword If "${auth_data}" != "${EMPTY}" Set To Dictionary ${headers} Authorization Bearer ${auth_data}
73 ${resp}= RequestsLibrary.GET ODL_SESSION ${OPERATIONAL_NODES_API} headers=${headers}
74 Log STATUS_CODE: ${resp.status_code} CONTENT: ${resp.content}
75 Should Be Equal As Strings ${resp.status_code} ${expected_status_code}
76 Should Contain ${resp.content} nodes
78 Credential Authentication Suite Setup
81 Credential Authentication Suite Teardown