3 # Copyright (c) Lumina Networks 2020 and others.
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/epl-v10.html
13 Documentation Test Basic Authentication support in RESTCONF
15 Library RequestsLibrary
17 Resource ../../../variables/Variables.robot
19 Suite Teardown Delete All Sessions
23 ${ADMIN_USER} ${ODL_RESTCONF_USER}
24 ${ADMIN_PW} ${ODL_RESTCONF_PASSWORD}
25 ${RESTCONF_TEST_URL} ${MODULES_API}
26 ${JOLOKIA_TEST_URL} jolokia
27 ${JOLOKIA_USER} ${ODL_RESTCONF_USER}
28 ${JOLOKIA_PW} ${ODL_RESTCONF_PASSWORD}
31 ${JOLOKIA_BAD_USER} ${BAD_USER}
32 ${USERS_REST_URL} auth/v1/users
38 No RESTCONF Credentials
39 [Documentation] Given no credentials GET RESTCONF fails
40 Auth Should Fail ${RESTCONF_TEST_URL} ${EMPTY} ${EMPTY}
42 Incorrect RESTCONF Password
43 [Documentation] Given incorrect password GET RESTCONF fails
44 Auth Should Fail ${RESTCONF_TEST_URL} ${ADMIN_USER} ${BAD_PW}
46 Incorrect RESTCONF Username
47 [Documentation] Given incorrect username GET RESTCONF fails
48 Auth Should Fail ${RESTCONF_TEST_URL} ${BAD_USER} ${ADMIN_PW}
50 Correct RESTCONF Credentials
51 [Documentation] Given correct credentials GET RESTCONF succeeds
52 Auth Should Pass ${RESTCONF_TEST_URL} ${ADMIN_USER} ${ADMIN_PW}
54 No Jolokia REST Credentials
55 [Documentation] Given no credentials, HTTP GET on a Jolokia endpoint fails
56 Auth Should Fail ${JOLOKIA_TEST_URL} ${EMPTY} ${EMPTY}
58 Incorrect Jolokia REST Password
59 [Documentation] Given incorrect password, GET on a Jolokia endpoint fails
60 Auth Should Fail ${JOLOKIA_TEST_URL} ${JOLOKIA_USER} ${BAD_PW}
62 Incorrect Jolokia REST Username
63 [Documentation] Given incorrect username, GET on a Jolokia endpoint fails
64 Auth Should Fail ${JOLOKIA_TEST_URL} ${JOLOKIA_BAD_USER} ${JOLOKIA_PW}
66 Correct Jolokia REST Credentials
67 [Documentation] Given correct credentials, GET on a Jolokia endpoint succeeds
68 Auth Should Pass ${JOLOKIA_TEST_URL} ${JOLOKIA_USER} ${JOLOKIA_PW}
70 IDM Endpoints Only Available To admin Role
71 [Documentation] A user with a non-"admin" role should not have access to AAA endpoints
72 ${auth} = Create List ${USER_USER} ${USER_PW}
73 Create Session httpbin http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${auth} headers=${HEADERS}
74 ${resp} = RequestsLibrary.GET On Session httpbin url=${USERS_REST_URL} expected_status=401
79 [Documentation] Checks the given HTTP RESTCONF response for authentication failure
80 [Arguments] ${url} ${user} ${password}
81 @{auth} = Create List ${user} ${password}
82 Create Session httpbin http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${auth} headers=${HEADERS}
83 ${resp} = RequestsLibrary.GET On Session httpbin url=${url} expected_status=401
84 ${header_value} = Convert To Uppercase ${resp.headers}[www-authenticate]
85 Should Contain ${header_value} BASIC
89 [Documentation] Checks the given HTTP RESTCONF response for authentication failure
90 [Arguments] ${url} ${user} ${password}
91 @{auth} = Create List ${user} ${password}
92 Create Session httpbin http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${auth} headers=${HEADERS}
93 ${resp} = RequestsLibrary.GET On Session httpbin url=${url} expected_status=200