*** Settings ***
Documentation Test suite: Authentication Support for Keystone
...
-... This feature implements the user management for ODL NBI REST APIs integrated with OpenStack, so that the authentication functionality provided by Keystone can be used. This allows consuming ODL NBI REST APIs using the same authentication procedures as any OpenStack project, such as Nova, Neutron, etc. bringing the benefits of a centralized / unified user management framework.
+... This feature implements the user management for ODL NBI REST APIs integrated with OpenStack, so that
+... the authentication functionality provided by Keystone can be used. This allows consuming ODL NBI REST
+... APIs using the same authentication procedures as any OpenStack project, such as Nova, Neutron, etc.
+... bringing the benefits of a centralized / unified user management framework.
...
-... As a first step, It shall be possible to authenticate users against Keystone by using passwords provided by the users.
+... As a first step, It shall be possible to authenticate users against Keystone by using passwords
+... provided by the users.
Suite Setup Init Suite
Suite Teardown Cleanup Suite
-Test Timeout
Library SSHLibrary
Library Collections
Library OperatingSystem
Resource ../../../libraries/AAA/DockerKeystone.robot
*** Variables ***
+${URI_CERTIFICATE} /restconf/operations/aaa-cert-rpc:getODLCertificate
+${URI_RESTCONF} /restconf/operational/ietf-restconf-monitoring:restconf-state
*** Test Cases ***
Successful Authentication Including Domain
... Steps:
...
... - Create an HTTP session with ODL as "sdnadmin" user in "sdn" domain
- ... - Check that the access to URLs of ODL NBI is allowed \ because "sdnadmin" user is associated to domain "sdn" in Keystone and the provided password is the right one
- [Tags]
+ ... - Check that the access to URLs of ODL NBI is allowed \ because "sdnadmin" user is associated to domain "sdn" in Keystone and the provided password is the right one.
+ ...
+ ... Note:
+ ...
+ ... - URL "/restconf/operations/aaa-cert-rpc:getODLCertificate" ia authorized just for "admin" roles according to shiro.ini configuration. As "sdnadmin" has "admin" role in keystone the access is authorized too
+ ...
+ ... - URL "/restconf/operational/ietf-restconf-monitoring:restconf-state" is not specified neither in shiro.ini nor in MDSAL Dynamic Authorization so no specific role is required
Create Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH_SDN_DOMAIN} headers=${HEADERS}
- ${resp}= RequestsLibrary.Post Request session /restconf/operations/aaa-cert-rpc:getODLCertificate headers=${HEADERS}
- Log ${resp}\n${resp.headers}\n${resp.content}
+ ${resp}= RequestsLibrary.Post Request session ${URI_CERTIFICATE} headers=${HEADERS}
+ Should Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
+ ${resp}= RequestsLibrary.Get Request session ${URI_RESTCONF} headers=${HEADERS}
Should Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
Successful Authentication Without Domain
...
... - Create an HTTP session with ODL as "CSC_user" user without specifying any domain then domain "Default" is considered
... - Check that the access to URLs of ODL NBI is allowed because "CSC_user" user is associated to domain "Default" in Keystone and the provided password is the right one
- [Tags] include
+ ...
+ ... Note:
+ ...
+ ... - URL "/restconf/operations/aaa-cert-rpc:getODLCertificate" ia authorized just for "admin" roles according to shiro.ini configuration. As "CSC_user" has "admin" role in keystone the access is authorized too
+ ...
+ ... - URL "/restconf/operational/ietf-restconf-monitoring:restconf-state" is not specified neither in shiro.ini nor in MDSAL Dynamic Authorization so no specific role is required
Create Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH_CSC_SDN} headers=${HEADERS}
- ${resp}= RequestsLibrary.Post Request session /restconf/operations/aaa-cert-rpc:getODLCertificate headers=${HEADERS}
- Log ${resp}\n${resp.headers}\n${resp.content}
+ ${resp}= RequestsLibrary.Post Request session ${URI_CERTIFICATE} headers=${HEADERS}
+ Should Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
+ ${resp}= RequestsLibrary.Get Request session ${URI_RESTCONF} headers=${HEADERS}
Should Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
Unsuccessful Authentication Wrong User
...
... - Create an HTTP session with ODL as an invalid user
... - Check that the access to URLs of ODL NBI is NOT allowed \ because "invaliduser" user does not exist in Keystone
- [Tags]
+ ...
+ ... Note:
+ ...
+ ... Due to authentication fails, authorization is not evaluated
Create Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH_INVALID} headers=${HEADERS}
- ${resp}= RequestsLibrary.Post Request session /restconf/operations/aaa-cert-rpc:getODLCertificate headers=${HEADERS}
- Log ${resp}
- Log ${resp.headers}
- Log ${resp.content}
+ ${resp}= RequestsLibrary.Post Request session ${URI_CERTIFICATE} headers=${HEADERS}
+ Should Contain ${UNAUTHORIZED_STATUS_CODES} ${resp.status_code}
+ ${resp}= RequestsLibrary.Get Request session ${URI_RESTCONF} headers=${HEADERS}
Should Contain ${UNAUTHORIZED_STATUS_CODES} ${resp.status_code}
UnSuccessful Authentication Without Domain
...
... - Create an HTTP session with ODL as "sdnadmin" user without specifying any domain then domain "Default" is considered
... - Check that the access to URLs of ODL NBI is NOT allowed because "sdnadmin" user is not associated to domain "Default" in Keystone but to "sdn" which is not included in the credentials
- [Tags]
+ ...
+ ... Note:
+ ...
+ ... Due to authentication fails, authorization is not evaluated
Create Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH_SDN} headers=${HEADERS}
- ${resp}= RequestsLibrary.Post Request session /restconf/operations/aaa-cert-rpc:getODLCertificate headers=${HEADERS}
- Log ${resp}
- Log ${resp.headers}
- Log ${resp.content}
+ ${resp}= RequestsLibrary.Post Request session ${URI_CERTIFICATE} headers=${HEADERS}
+ Should Contain ${UNAUTHORIZED_STATUS_CODES} ${resp.status_code}
+ ${resp}= RequestsLibrary.Get Request session ${URI_RESTCONF} headers=${HEADERS}
Should Contain ${UNAUTHORIZED_STATUS_CODES} ${resp.status_code}
Unsuccessful Authentication Wrong Domain
... - Create an HTTP session with ODL as "sdnadmin" user with "wrong" as domain
... - Check that the access to URLs of ODL NBI is NOT allowed because "sdnadmin" user is not associated to domain "wrong" in Keystone but to "sdn"
...
- ... Note: Also for troubleshooting purposes keystone debug files are dumped
- [Tags]
+ ... Note:
+ ...
+ ... Due to authentication fails, authorization is not evaluated
Create Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH_SDN_WRONG_DOM} headers=${HEADERS}
- ${resp}= RequestsLibrary.Post Request session /restconf/operations/aaa-cert-rpc:getODLCertificate headers=${HEADERS}
- Log ${resp}
- Log ${resp.headers}
- Log ${resp.content}
- ${output} SSHLibrary.Execute Command docker exec -t keystone bash -c "cat /var/log/nginx-access.log"
- Log ${output}
- ${output} SSHLibrary.Execute Command docker exec -t keystone bash -c "cat /var/log/uwsgi-keystone-admin.log"
- Log ${output}
- ${output} SSHLibrary.Execute Command docker exec -t keystone bash -c "cat /var/log/nginx-error.log"
- Log ${output}
- ${output} SSHLibrary.Execute Command docker exec -t keystone bash -c "cat /var/log/uwsgi-keystone-public.log"
- Log ${output}
+ ${resp}= RequestsLibrary.Post Request session ${URI_CERTIFICATE} headers=${HEADERS}
+ Should Contain ${UNAUTHORIZED_STATUS_CODES} ${resp.status_code}
+ ${resp}= RequestsLibrary.Get Request session ${URI_RESTCONF} headers=${HEADERS}
+ Should Contain ${UNAUTHORIZED_STATUS_CODES} ${resp.status_code}
+
+Unsuccessful Basic Authorization
+ [Documentation] *Test Case: UnSuccessful Basic Authorization*
+ ...
+ ... Steps:
+ ...
+ ... - Provision MDSAL so that users with role "admin" or "user" are authorized to access all URIs
+ ... - Create an HTTP session with ODL as "CSC_user_no_admin" user
+ ... - Check that the access to URL "/restconf/operations/aaa-cert-rpc:getODLCertificate" is NOT authorized because in shiro.ini configuration the access is allowed just to "admin" roles and "CSC_user_no_admin" does not have \ "admin" role in keystone but "user" role even though the MDSAL Dynamic Authorization would allow the access, that is, authorization process is an "AND" operation between shiro.ini and MDSAL Dynamic Authorization
+ ... - Check that the access to URL "/restconf/operational/ietf-restconf-monitoring:restconf-state" is authorized becaiuse that URL is not specified in shiro.ini and in MDSAL Dynamic Authorization access to all URLs is allowed to all user with "user" role
+ Set Suite Variable ${PUT_DYNAMIC_AUTH_FILE} ${CURDIR}/../../../variables/aaa/put-dynamic-auth.json
+ Provision MDSAL ${PUT_DYNAMIC_AUTH_FILE}
+ Create Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH_CSC_NO_ADMIN} headers=${HEADERS}
+ ${resp_ok}= RequestsLibrary.Get Request session ${URI_RESTCONF} headers=${HEADERS}
+ Should Contain ${ALLOWED_STATUS_CODES} ${resp_ok.status_code}
+ ${resp_nook}= RequestsLibrary.Post Request session ${URI_CERTIFICATE} headers=${HEADERS}
+ Should Contain ${UNAUTHORIZED_STATUS_CODES} ${resp_nook.status_code}
+
+Unsuccessful Dynamic Authorization
+ [Documentation] *Test Case: UnSuccessful Dynamic Authorization*
+ ...
+ ... Steps:
+ ...
+ ... - Provision MDSAL so that just users with role "admin" are authorized to access all URIs
+ ... - Create an HTTP session with ODL as "CSC_user_no_admin" user
+ ... - Check that the access to URL "/restconf/operations/aaa-cert-rpc:getODLCertificate" is NOT authorized because in shiro.ini configuration the access is allowed just to "admin" roles and "CSC_user_no_admin" does not have \ "admin" role in keystone but "user" role even though the MDSAL Dynamic Authorization would allow the access, that is, authorization process is an "AND" operation between shiro.ini and MDSAL Dynamic Authorization
+ ... - Check that the access to URL "/restconf/operational/ietf-restconf-monitoring:restconf-state" is NOT authorized because although the URL is not specified in shiro.ini, in MDSAL Dynamic Authorization access to all URLs is allowed just for users with "admin" role and "CSC_user_no_admin" does not have \ "admin" role in keystone but "user" role
+ Set Suite Variable ${PUT_DYNAMIC_AUTH_FILE} ${CURDIR}/../../../variables/aaa/put-dynamic-auth-2.json
+ Provision MDSAL ${PUT_DYNAMIC_AUTH_FILE}
+ Create Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH_CSC_NO_ADMIN} headers=${HEADERS}
+ ${resp_nook}= RequestsLibrary.Get Request session ${URI_RESTCONF} headers=${HEADERS}
+ Should Contain ${UNAUTHORIZED_STATUS_CODES} ${resp_nook.status_code}
+ ${resp_nook}= RequestsLibrary.Post Request session ${URI_CERTIFICATE} headers=${HEADERS}
+ Should Contain ${UNAUTHORIZED_STATUS_CODES} ${resp_nook.status_code}
+
+Unsuccessful Dynamic Authorization 2
+ [Documentation] *Test Case: UnSuccessful Dynamic Authorization 2*
+ ...
+ ... Steps:
+ ...
+ ... - Provision MDSAL so that:
+ ... \ \ - URI "/restconf/operations/aaa-cert-rpc:getODLCertificate" is authorized just for users with "user" role
+ ... \ - URI "/restconf/operational/**" is authorized just for users with "user" role
+ ...
+ ... - Create an HTTP session with ODL as "sdnadmin" user
+ ... - Check that the access to URL "/restconf/operations/aaa-cert-rpc:getODLCertificate" is NOT authorized because although in shiro.ini configuration the access is allowed to "admin" roles and "cscadmin" does have \ "admin" role, \ in MDSAL Dynamic Authorization access to that URL is allowed just for users with "user" role and "cscadmin" does not have \ "user" role in keystone but "admin" role
+ ... - Check that the access to URL "/restconf/operational/ietf-restconf-monitoring:restconf-state" is NOT authorized because although in shiro.ini configuration that URL is not considered, \ in MDSAL Dynamic Authorization access to that URL is allowed just for users with "user" role and "cscadmin" does not have \ "user" role in keystone but "admin" role
+ ...
+ ...
+ ... - Create an HTTP session with ODL as "CSC_user_no_admin" user
+ ... - Check that the access to URL "/restconf/operations/aaa-cert-rpc:getODLCertificate" is NOT authorized because in shiro.ini configuration the access is allowed just to "admin" roles and "CSC_user_no_admin" does not have \ "admin" role in keystone but "user" role even though the MDSAL Dynamic Authorization would allow the access, that is, authorization process is an "AND" operation between shiro.ini and MDSAL Dynamic Authorization
+ ... - Check that the access to URL "/restconf/operational/ietf-restconf-monitoring:restconf-state" is authorized because the URL is not specified in shiro.ini and in MDSAL Dynamic Authorization access to that URL is allowed just for users with "user" role and "CSC_user_no_admin" does \ have \ "user" role in keystone
+ Set Suite Variable ${PUT_DYNAMIC_AUTH_FILE} ${CURDIR}/../../../variables/aaa/put-dynamic-auth-3.json
+ Provision MDSAL ${PUT_DYNAMIC_AUTH_FILE}
+ Create Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH_SDN_DOMAIN} headers=${HEADERS}
+ ${resp}= RequestsLibrary.Post Request session ${URI_CERTIFICATE} headers=${HEADERS}
+ Should Contain ${UNAUTHORIZED_STATUS_CODES} ${resp.status_code}
+ ${resp}= RequestsLibrary.Get Request session ${URI_RESTCONF} headers=${HEADERS}
+ Should Contain ${UNAUTHORIZED_STATUS_CODES} ${resp.status_code}
+ Create Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH_CSC_NO_ADMIN} headers=${HEADERS}
+ ${resp}= RequestsLibrary.Get Request session ${URI_RESTCONF} headers=${HEADERS}
+ Should Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
+ ${resp}= RequestsLibrary.Post Request session ${URI_CERTIFICATE} headers=${HEADERS}
+ Should Contain ${UNAUTHORIZED_STATUS_CODES} ${resp.status_code}
+
+Unsuccessful No Keystone Connection
+ [Documentation] *Test Case: Unsuccessful No Keystone Connection*
+ ...
+ ... Steps:
+ ...
+ ... - Put down Keystone
+ ... - All accesses are forbidden
+ Cleanup Suite
+ Create Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH_SDN_DOMAIN} headers=${HEADERS}
+ ${resp}= RequestsLibrary.Post Request session ${URI_CERTIFICATE} headers=${HEADERS}
+ Should Contain ${UNAUTHORIZED_STATUS_CODES} ${resp.status_code}
+ ${resp}= RequestsLibrary.Get Request session ${URI_RESTCONF} headers=${HEADERS}
+ Should Contain ${UNAUTHORIZED_STATUS_CODES} ${resp.status_code}
+ Create Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH_CSC_NO_ADMIN} headers=${HEADERS}
+ ${resp}= RequestsLibrary.Get Request session ${URI_RESTCONF} headers=${HEADERS}
+ Should Contain ${UNAUTHORIZED_STATUS_CODES} ${resp.status_code}
+ ${resp}= RequestsLibrary.Post Request session ${URI_CERTIFICATE} headers=${HEADERS}
Should Contain ${UNAUTHORIZED_STATUS_CODES} ${resp.status_code}
*** Keywords ***
${TOOLS_SYSTEM_NAME} Run Command On Remote System ${TOOLS_SYSTEM_IP} hostname -f user=${TOOLS_SYSTEM_USER} password=${TOOLS_SYSTEM_PASSWORD}
Run Docker Keystone
Configure AAA In Controller ${TOOLS_SYSTEM_NAME}
- Restart Controller
- Provision Keystone
Set Suite Variable ${PUT_KEYSTONE_CERT_FILE} ${CURDIR}/../../../variables/aaa/put-keystone-cert.json
Set Keystone Certificate into ODL ${PUT_KEYSTONE_CERT_FILE} ${TOOLS_SYSTEM_NAME}
+ Restart Controller
+ Provision Keystone
+ Set Suite Variable ${PUT_DYNAMIC_AUTH_FILE} ${CURDIR}/../../../variables/aaa/put-dynamic-auth.json
+ Provision MDSAL ${PUT_DYNAMIC_AUTH_FILE}
Cleanup Suite
[Documentation] Destoy keystone container
- Set Domain To False ${domain} ${HEADERS_TOKEN}
- Delete Keystone Domain ${domain} ${HEADERS_TOKEN}
- Destroy Docker Keystone
+ ${result} Run Keyword And Return Status Set Domain To False ${domain} ${HEADERS_TOKEN}
+ Run Keyword If ${result} == True Delete Keystone Domain ${domain} ${HEADERS_TOKEN}
+ Run Keyword If ${result} == True Destroy Docker Keystone
+ SSHLibrary.Close All Connections
Configure AAA In Controller
[Arguments] ${TOOLS_SYSTEM_NAME}
${result} Run Command On Controller cmd=sed -ie 's/#keystoneAuthRealm.url =.*/keystoneAuthRealm.url = https:\\/\\/${TOOLS_SYSTEM_NAME}:35357/g' ${shiro_path}
${result} Run Command On Controller cmd=sed -ie 's/securityManager.realms =.*/securityManager.realms = $tokenAuthRealm, $keystoneAuthRealm/g' ${shiro_path}
${result} Run Command On Controller cmd=sed -ie 's/#keystoneAuthRealm.sslVerification =.*/keystoneAuthRealm.sslVerification = true/g' ${shiro_path}
- ${result} Run Command On Controller cmd=sed -ie '/^\\/operations\\/aaa-cert-rpc/d' ${shiro_path}
+ ${result} Run Command On Controller cmd=sed -ie 's/\\/operations\\/aaa-cert-rpc.*/\\/operations\\/aaa-cert-rpc** = authcBasic, roles[admin], dynamicAuthorization/g' ${shiro_path}
${result} Run Command On Controller cmd=sed -ie 's/<use-config>.*/<use-config>true<\\/use-config>/g' ${cert_path}
${result} Run Command On Controller cmd=sed -ie 's/<tls-protocols.*/<tls-protocols>TLSv1.2<\\/tls-protocols>/g' ${cert_path}
${result} Run Command On Controller cmd=cat ${shiro_path}
${user} Create Keystone User in a Domain ${HEADERS_TOKEN} ${CREATE_USERS_FILE}
Grant Admin Role ${domain} ${user} ${admin_role_id} ${HEADERS_TOKEN}
+Provision MDSAL
+ [Arguments] ${PUT_DYNAMIC_AUTH_FILE}
+ Create Session session_admin http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH} headers=${HEADERS}
+ Set Suite Variable ${PUT_DYNAMIC_AUTH_URI} /restconf/config/aaa:http-authorization
+ ${body_dyn} OperatingSystem.Get File ${PUT_DYNAMIC_AUTH_FILE}
+ ${resp} RequestsLibrary.Put Request session_admin ${PUT_DYNAMIC_AUTH_URI} data=${body_dyn} headers=${HEADERS}
+ Should Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
+ Delete Request session_admin http://${ODL_SYSTEM_IP}:${RESTCONFPORT}
+
Restart Controller
[Documentation] Controller restart is needed in order the new shiro.ini config takes effect
ClusterManagement.ClusterManagement_Setup
Wait Until Keyword Succeeds 5x 20 Stop_Single_Member 1
Start_Single_Member 1 wait_for_sync=False timeout=120
+ # TODO: the below Get Controller Modules keyword ends up giving a lot of WARN messages in the robot
+ # log as the controller is coming up and the initial requests are failing. This is just cosmetic at this point, but
+ # would be nice to clean up somehow.
Wait Until Keyword Succeeds 30x 5s Get Controller Modules
Get Controller Modules