2 # Copyright (c) Lumina Networks 2020 and others.
5 # This program and the accompanying materials are made available under the
6 # terms of the Eclipse Public License v1.0 which accompanies this distribution,
7 # and is available at http://www.eclipse.org/legal/epl-v10.html
11 Documentation Test Basic Authentication support in RESTCONF
12 Suite Teardown Delete All Sessions
13 Library RequestsLibrary
15 Resource ../../../variables/Variables.robot
18 ${ADMIN_USER} ${ODL_RESTCONF_USER}
19 ${ADMIN_PW} ${ODL_RESTCONF_PASSWORD}
20 ${RESTCONF_TEST_URL} ${MODULES_API}
21 ${JOLOKIA_TEST_URL} jolokia
22 ${JOLOKIA_USER} ${ODL_RESTCONF_USER}
23 ${JOLOKIA_PW} ${ODL_RESTCONF_PASSWORD}
26 ${JOLOKIA_BAD_USER} ${BAD_USER}
27 ${USERS_REST_URL} auth/v1/users
32 No RESTCONF Credentials
33 [Documentation] Given no credentials GET RESTCONF fails
34 Auth Should Fail ${RESTCONF_TEST_URL} ${EMPTY} ${EMPTY}
36 Incorrect RESTCONF Password
37 [Documentation] Given incorrect password GET RESTCONF fails
38 Auth Should Fail ${RESTCONF_TEST_URL} ${ADMIN_USER} ${BAD_PW}
40 Incorrect RESTCONF Username
41 [Documentation] Given incorrect username GET RESTCONF fails
42 Auth Should Fail ${RESTCONF_TEST_URL} ${BAD_USER} ${ADMIN_PW}
44 Correct RESTCONF Credentials
45 [Documentation] Given correct credentials GET RESTCONF succeeds
46 Auth Should Pass ${RESTCONF_TEST_URL} ${ADMIN_USER} ${ADMIN_PW}
48 No Jolokia REST Credentials
49 [Documentation] Given no credentials, HTTP GET on a Jolokia endpoint fails
50 Auth Should Fail ${JOLOKIA_TEST_URL} ${EMPTY} ${EMPTY}
52 Incorrect Jolokia REST Password
53 [Documentation] Given incorrect password, GET on a Jolokia endpoint fails
54 Auth Should Fail ${JOLOKIA_TEST_URL} ${JOLOKIA_USER} ${BAD_PW}
56 Incorrect Jolokia REST Username
57 [Documentation] Given incorrect username, GET on a Jolokia endpoint fails
58 Auth Should Fail ${JOLOKIA_TEST_URL} ${JOLOKIA_BAD_USER} ${JOLOKIA_PW}
60 Correct Jolokia REST Credentials
61 [Documentation] Given correct credentials, GET on a Jolokia endpoint succeeds
62 Auth Should Pass ${JOLOKIA_TEST_URL} ${JOLOKIA_USER} ${JOLOKIA_PW}
64 IDM Endpoints Only Available To admin Role
65 [Documentation] A user with a non-"admin" role should not have access to AAA endpoints
66 ${auth} Create List ${USER_USER} ${USER_PW}
67 Create Session httpbin http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${auth} headers=${HEADERS}
68 ${resp} = RequestsLibrary.Get Request httpbin ${USERS_REST_URL}
69 Should Be Equal As Numbers ${resp.status_code} 401
73 [Arguments] ${url} ${user} ${password}
74 [Documentation] Checks the given HTTP RESTCONF response for authentication failure
75 @{auth} = Create List ${user} ${password}
76 Create Session httpbin http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${auth} headers=${HEADERS}
77 ${resp} = RequestsLibrary.Get Request httpbin ${url}
78 Should Be Equal As Strings ${resp.status_code} 401
79 ${header_value} = Convert To Uppercase ${resp.headers}[www-authenticate]
80 Should Contain ${header_value} BASIC
84 [Arguments] ${url} ${user} ${password}
85 [Documentation] Checks the given HTTP RESTCONF response for authentication failure
86 @{auth} = Create List ${user} ${password}
87 Create Session httpbin http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${auth} headers=${HEADERS}
88 ${resp} = RequestsLibrary.Get Request httpbin ${url}
89 Should Be Equal As Strings ${resp.status_code} 200