2 Documentation AAA System Tests
3 Suite Teardown Delete All Sessions
4 Test Setup Log Testcase Start To Controller Karaf
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 ${ODL_SYSTEM_IP} ${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 Contain ${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 ... Test has been disabled due to the fact that this interface has changed. Authentication is now disabled
57 ... through modification of shiro.ini, which requires controller restart and is not suit for this test.
59 Disable Authentication On Controller ${ODL_SYSTEM_IP}
60 Wait Until Keyword Succeeds 10s 1s Make REST Transaction 200
61 Enable Authentication On Controller ${ODL_SYSTEM_IP}
62 Wait Until Keyword Succeeds 10s 1s Validate That Authentication Fails With Wrong Token
63 ${auth_token}= Get Auth Token
64 Make REST Transaction 200 ${auth_token}
65 [Teardown] Report_Failure_Due_To_Bug 4922
68 Validate That Authentication Fails With Wrong Token
69 ${bad_token}= Set Variable notARealToken
70 Make REST Transaction 401 ${bad_token}
73 [Arguments] ${expected_status_code} ${auth_data}=${EMPTY}
74 Create Session ODL_SESSION http://${ODL_SYSTEM_IP}:8181
75 ${headers}= Create Dictionary Content-Type=application/x-www-form-urlencoded
76 Run Keyword If "${auth_data}" != "${EMPTY}" Set To Dictionary ${headers} Authorization Bearer ${auth_data}
77 ${resp}= RequestsLibrary.GET Request ODL_SESSION ${MODULES_API} headers=${headers}
78 Log STATUS_CODE: ${resp.status_code} CONTENT: ${resp.content}
79 Should Be Equal As Strings ${resp.status_code} ${expected_status_code}