X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=test%2Fcsit%2Flibraries%2FAAAKeywords.txt;h=7419d33247802ee17d7066b82f1bb927f85e7c4a;hb=de7f319a62a249669d7239ce93149124c0da0570;hp=fca8ccfffd7dd7fb9473087729506de47e1205dc;hpb=e0d94c59a708d4499ac0751915c368ee76f91c3d;p=integration%2Ftest.git diff --git a/test/csit/libraries/AAAKeywords.txt b/test/csit/libraries/AAAKeywords.txt index fca8ccfffd..7419d33247 100644 --- a/test/csit/libraries/AAAKeywords.txt +++ b/test/csit/libraries/AAAKeywords.txt @@ -3,7 +3,10 @@ Library ./RequestsLibrary.py Variables ../variables/Variables.py *** Variables *** - +${WORKSPACE} /tmp +${BUNDLEFOLDER} distribution-karaf-0.3.0-SNAPSHOT +${AUTHN_CFG_FILE} ${WORKSPACE}/${BUNDLEFOLDER}/etc/org.opendaylight.aaa.authn.cfg +${CONTROLLER_USER} ${MININET_USER} *** Keywords *** AAA Login @@ -26,7 +29,61 @@ Create Auth Data ... ${data} [Return] ${data} +Disable Authentication On Controller + [Arguments] ${controller_ip} + [Documentation] Will disable token based authentication. Currently, that is done with a config file change + SSHLibrary.Open Connection ${controller_ip} + Login With Public Key ${CONTROLLER_USER} ${USER_HOME}/.ssh/id_rsa any + ${cmd}= Set Variable sed -i 's/^authEnabled=.*$/authEnabled=false/g' ${AUTHN_CFG_FILE} + SSHLibrary.Execute Command ${cmd} + SSHLibrary.Close Connection + +Enable Authentication On Controller + [Arguments] ${controller_ip} + [Documentation] Will enable token based authentication. Currently, that is done with a config file change + SSHLibrary.Open Connection ${controller_ip} + Login With Public Key ${CONTROLLER_USER} ${USER_HOME}/.ssh/id_rsa any + ${cmd}= Set Variable sed -i 's/^authEnabled=.*$/authEnabled=true/g' ${AUTHN_CFG_FILE} + SSHLibrary.Execute Command ${cmd} + SSHLibrary.Close Connection + +Get Auth Token + [Arguments] ${user}=${USER} ${password}=${PWD} ${scope}=${SCOPE} ${client_id}=${EMPTY} ${client_secret}=${EMPTY} + [Documentation] Wrapper used to login to controller and retrieve an auth token. Optional argumented available for client based credentials. + ${auth_data}= Create Auth Data ${USER} ${PWD} ${scope} ${client_id} ${client_secret} + ${resp}= AAA Login ${CONTROLLER} ${auth_data} + Should Be Equal As Strings ${resp.status_code} 201 + ${auth_token}= Extract Value From Content ${resp.content} /access_token strip + [Return] ${auth_token} + +Revoke Auth Token + [Arguments] ${token} + [Documentation] Requests the given token be revoked via POST to ${REVOKE_TOKEN_API} + ${headers}= Create Dictionary Content-Type application/x-www-form-urlencoded + ${resp}= RequestsLibrary.POST ODL_SESSION ${REVOKE_TOKEN_API} data=${token} headers=${headers} + Should Be Equal As Strings ${resp.status_code} 204 + Validate Token Format [Arguments] ${token} [Documentation] Validates the given string is in the proper "token" format Should Match Regexp ${token} [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12} + +Get User From IDM DB + [Documentation] Will return user information. If no user id is passed, it will retrieve all users in DB + [Arguments] ${user_id}=${EMPTY} + Create Session httpbin http://${CONTROLLER}:${RESTPORT} + ${headers}= Create Dictionary Content-Type application/x-www-form-urlencoded + ${resp}= RequestsLibrary.GET httpbin ${idmurl}/users/${user_id} headers=${headers} + Should Be Equal As Strings ${resp.status_code} 200 + Log ${resp.content} + [Return] ${resp} + +Create User + [Documentation] Will return user information. If no user id is passed, it will retrieve all users in DB + [Arguments] ${user_data} + Create Session httpbin http://${CONTROLLER}:${RESTPORT} + ${headers}= Create Dictionary Content-Type application/json + ${resp}= RequestsLibrary.POST httpbin ${idmurl}/users headers=${headers} data=${user_data} + Should Be Equal As Strings ${resp.status_code} 201 + Log ${resp.content} + [Return] ${resp}