Rename TsdrUtils.txt to TsdrUtils.robot
[integration.git] / test / csit / libraries / AAAKeywords.txt
index acae6b129b260c7e1bc5d55abec0604e8639cd4b..29ea1f5b3c351648d6e15c9bb40a5249ef288f92 100644 (file)
@@ -33,7 +33,7 @@ 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
+    Login With Public Key    ${CONTROLLER_USER}    ${USER_HOME}/.ssh/${SSH_KEY}    any
     ${cmd}=    Set Variable    sed -i 's/^authEnabled=.*$/authEnabled=false/g' ${AUTHN_CFG_FILE}
     SSHLibrary.Execute Command    ${cmd}
     SSHLibrary.Close Connection
@@ -42,7 +42,7 @@ 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
+    Login With Public Key    ${CONTROLLER_USER}    ${USER_HOME}/.ssh/${SSH_KEY}    any
     ${cmd}=    Set Variable    sed -i 's/^authEnabled=.*$/authEnabled=true/g' ${AUTHN_CFG_FILE}
     SSHLibrary.Execute Command    ${cmd}
     SSHLibrary.Close Connection
@@ -67,3 +67,23 @@ 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}