*** Settings *** Library Collections Library RequestsLibrary Library REST http://${host}:${port} Resource ../../03-Variable/BifangApiVariable.txt *** Keywords *** GetRequestBase [Arguments] ${header} ${apistr} ${body} Set Headers ${header} &{httpResponse} Get ${apistr}?${body} #Output response body Object response body #Integer $.code 200 #Array $.data.policyList ${response} Set Variable ${httpResponse.body} [Return] ${response} GetRequestBase [Arguments] ${api} ${header} [Documentation] [Get方法封装:第一层,] ${response} BaseGetRequest ${apistr} ${body} ${remoteResponse} Get Request api ${api} ${response} to json ${remoteResponse.content} [Return] ${response} GetRequest [Arguments] ${url} [Documentation] [Get方法封装:第一层,] ${header} Create Dictionary Content-Type=application/json Authorization=${token} Create Session api http://${host}:${port} headers=${header} ${remoteResponse} Get Request api ${url} headers=${header} ${response} to json ${remoteResponse.content} Should Be Equal As Strings ${remoteResponse.status_code} 200 [Return] ${response} PostRequest [Arguments] ${url} ${data} ${header} Create Dictionary Content-Type=application/json Authorization=${token} Create Session api http://${host}:${port} headers=${header} ${remoteResponse} Post Request api ${url} data=${data} headers=${header} ${response} to json ${remoteResponse.content} Should Be Equal As Strings ${remoteResponse.status_code} 200 [Return] ${response} PutRequest [Arguments] ${requestUri} ${data} ${headers} set variable {"Authorization":"${token}","Content-Type":"application/json"} create session api http://${host}:${port} ${headers} ${response}= Put Request api ${requestUri} data=${data} log return data =${response} Should Be Equal As Strings ${response.status_code} 200 ${response} to json ${response.content} [Return] ${response} DeleteRequest [Arguments] ${url} ${data} ${header} Create Dictionary Content-Type=application/json Authorization=${token} Create Session api http://${host}:${port} headers=${header} ${remoteResponse} Delete Request api ${url} data=${data} headers=${header} ${response} to json ${remoteResponse.content} Should Be Equal As Strings ${remoteResponse.status_code} 200 [Return] ${response} UpFileRequest [Arguments] ${url} ${data} ${files} ${fileDesc} ${header} Set To Dictionary ${fileDesc} Authorization=${token} Create Session api http://${host}:${port} headers=${header} ${remoteResponse} Post Request api ${url} data=${data} files=${files} headers=${header} ${response} to json ${remoteResponse.content} Should Be Equal As Strings ${remoteResponse.status_code} 200 [Return] ${response} PutFileRequest [Arguments] ${url} ${data} ${files} ${fileDesc} ${header} Set To Dictionary ${fileDesc} Authorization=${token} Create Session api http://${host}:${port} headers=${header} ${remoteResponse} Put Request api ${url} params=${data} files=${files} headers=${header} ${response} to json ${remoteResponse.content} Should Be Equal As Strings ${remoteResponse.status_code} 200 [Return] ${response} *** Test Cases *** Test-GetRequestBase ${api} Set Variable /v2/policy/compile?pageSize=20&pageNo=1&policyType=tsg_security ${header} Create Dictionary Content-Type=application/json Authorization=${token} ${response} GetRequestBase ${api} ${header} log ${response}