2020-04-01 12:42:05 +08:00
|
|
|
|
*** Settings ***
|
|
|
|
|
|
Resource ../../03-Variable/BifangApiVariable.txt
|
2020-06-16 16:42:04 +08:00
|
|
|
|
Library REST http://${host}:${port}
|
2020-04-01 12:42:05 +08:00
|
|
|
|
Library Collections
|
|
|
|
|
|
Library RequestsLibrary
|
|
|
|
|
|
|
|
|
|
|
|
*** Keywords ***
|
2020-06-16 15:10:02 +08:00
|
|
|
|
ManageApistr
|
|
|
|
|
|
[Documentation]
|
|
|
|
|
|
... 描述:入口,apistr 为调用api地址
|
|
|
|
|
|
... 本关键字的作用是判断地址前有没有加版本号,如果没有加上
|
|
|
|
|
|
... policy/compile -> /v1/policy/compile
|
|
|
|
|
|
... /policy/compile -> /v1/policy/compile
|
|
|
|
|
|
... v1/policy/compile -> /v1/policy/compile
|
|
|
|
|
|
... /v1/policy/compile -> /v1/policy/compile
|
|
|
|
|
|
[Arguments] ${apistr}
|
|
|
|
|
|
${apiStart} Evaluate '${apistr}'[0:1]
|
|
|
|
|
|
${apiStart1} Evaluate '${apistr}'[0:2]
|
|
|
|
|
|
${apistr} Run Keyword If "${apiStart}"!="/" and "${apiStart}"!="v"
|
|
|
|
|
|
... Set Variable /${version}/${apistr}
|
|
|
|
|
|
... ELSE IF "${apiStart}"=="/" and "${apiStart1}"!="/v"
|
|
|
|
|
|
... Set Variable /${version}${apistr}
|
|
|
|
|
|
... ELSE IF "${apiStart}"=="v" Set Variable /${apistr}
|
|
|
|
|
|
... ELSE IF "${apiStart1}"=="/v" Set Variable ${apistr}
|
|
|
|
|
|
... ELSE Set Variable ${apistr}
|
|
|
|
|
|
log ${apistr}
|
|
|
|
|
|
[Return] ${apistr}
|
2020-04-01 12:42:05 +08:00
|
|
|
|
BasePostRequest
|
2020-06-16 15:10:02 +08:00
|
|
|
|
[Arguments] ${apistr} ${body}
|
2020-04-01 12:42:05 +08:00
|
|
|
|
Set Headers {"Authorization":"${token}","Content-Type":"application/json"}
|
2020-04-29 19:39:52 +08:00
|
|
|
|
log 111111111111111111111111${apistr}
|
2020-04-07 12:51:52 +08:00
|
|
|
|
&{httpResponse} Post ${apistr} ${body}
|
|
|
|
|
|
#Output response body
|
2020-04-01 12:42:05 +08:00
|
|
|
|
Object response body
|
|
|
|
|
|
#Integer $.code 200
|
|
|
|
|
|
#Array $.data.policyList
|
|
|
|
|
|
${response} Set Variable ${httpResponse.body}
|
2020-04-29 20:04:46 +08:00
|
|
|
|
[Return] ${response}
|
2020-06-16 15:10:02 +08:00
|
|
|
|
BasePostRequestForV2
|
|
|
|
|
|
[Arguments] ${requestUri} ${data} ${apiVersion}
|
|
|
|
|
|
${headers} set variable {"Authorization":"${token}","Content-Type":"application/json"}
|
|
|
|
|
|
create session api http://${host}:${port}/${apiVersion} ${headers}
|
|
|
|
|
|
${response}= Post 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}
|
2020-04-29 20:04:46 +08:00
|
|
|
|
BaseGetRequest
|
|
|
|
|
|
[Arguments] ${apistr} ${body}
|
|
|
|
|
|
Set Headers {"Authorization":"${token}","Content-Type":"application/json"}
|
2020-06-16 16:42:04 +08:00
|
|
|
|
&{httpResponse} Get /${apistr}?${body}
|
2020-04-29 20:04:46 +08:00
|
|
|
|
#Output response body
|
|
|
|
|
|
Object response body
|
|
|
|
|
|
#Integer $.code 200
|
|
|
|
|
|
#Array $.data.policyList
|
|
|
|
|
|
${response} Set Variable ${httpResponse.body}
|
2020-04-01 12:42:05 +08:00
|
|
|
|
[Return] ${response}
|
2020-06-16 15:10:02 +08:00
|
|
|
|
BaseGetRequestForV2
|
|
|
|
|
|
[Arguments] ${requestUri} ${data} ${apiVersion}
|
|
|
|
|
|
${headers} set variable {"Authorization":"${token}","Content-Type":"application/json"}
|
|
|
|
|
|
create session api http://${host}:${port}/${apiVersion} ${headers}
|
|
|
|
|
|
${response}= Get Request api ${requestUri}?${data}
|
|
|
|
|
|
log return data =${response}
|
|
|
|
|
|
Should Be Equal As Strings ${response.status_code} 200
|
|
|
|
|
|
${response} to json ${response.content}
|
|
|
|
|
|
[Return] ${response}
|
2020-04-01 12:42:05 +08:00
|
|
|
|
BaseDeleteRequest
|
|
|
|
|
|
[Arguments] ${requestUri} ${data}
|
|
|
|
|
|
${headers} set variable {"Authorization":"${token}","Content-Type":"application/json"}
|
2020-06-16 16:42:04 +08:00
|
|
|
|
create session api http://${host}:${port} ${headers}
|
2020-04-01 12:42:05 +08:00
|
|
|
|
${response}= Delete 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}
|
|
|
|
|
|
|
|
|
|
|
|
BaseEditRequest
|
|
|
|
|
|
[Arguments] ${requestUri} ${data}
|
|
|
|
|
|
${headers} set variable {"Authorization":"${token}","Content-Type":"application/json"}
|
2020-06-16 16:42:04 +08:00
|
|
|
|
create session api http://${host}:${port} ${headers}
|
2020-04-01 12:42:05 +08:00
|
|
|
|
${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}
|