aboutsummaryrefslogtreecommitdiffstats
path: root/csit/resources/tests/opa-pdp-test.robot
blob: 908314f8068cb84629e8cf124ca390fdd990fd1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
*** Settings ***
Library    RequestsLibrary
Library    Collections
Library    OperatingSystem
Library    Process
Library     json
Resource   common-library.robot

*** Variables ***
${OPA_PDP_HOST}    /policy/pdpx/v1/healthcheck
${url}    /policy/pdpx/v1/decision

*** Test Cases ***
Healthcheck
    [Documentation]    Verify OPA PDP health check
    PdpxGetReq  ${OPA_PDP_HOST}  <Response [200]>

RetrieveSuccessfulRequest
    [Documentation]  Get Decision Request Successful for Opa Pdp
    DecisionRequest  onap.policy.opa.pdp.decision.request.json  PERMIT  200

RetrieveDenyRequest
    [Documentation]  Get Decision Request DENY for Opa Pdp
    DecisionRequest  onap.policy.opa.pdp.decision.requestfailure.json  DENY  200

*** comments ***
| RetrieveFailureRequest
| |[Documentation] | Get Decision Request INDETERMINATE for Opa Pdp ***
| | |DecisionRequest  onap.policy.opa.pdp.decision.requestIndeterminate.json  INDETERMINATE  200 ***

RetrieveFailureBadRequest
    [Documentation]  Get Decision Request Failure Bad Request for Opa Pdp
    DecisionRequest  onap.policy.opa.pdp.decision.badRequest.json  BAD_REQUEST  400
*** Keywords ***
PdpxGetReq
    [Documentation]     Verify the response of Health Check is Successful
    [Arguments]   ${url}  ${status}
    ${hcauth}=  PolicyAdminAuth
    ${resp}=    PerformGetRequest  ${POLICY_OPA_IP}  ${url}  200  null  ${hcauth}
    Should Be Equal As Strings    ${resp}   ${status}

DecisionRequest
    [Arguments]  ${jsonfile}  ${keyword}  ${status}
    ${postjson}=  Get file  ${CURDIR}/data/${jsonfile}
    ${resp}=  DecisionPostReq  ${postjson}  ${status}  abbrev=true
    Should Contain  ${resp.text}  ${keyword}

DecisionPostReq
    [Arguments]  ${postjson}  ${status}  ${abbr}
    ${expectedStatus}=    Set Variable    ${status}
    ${hcauth}=  PolicyAdminAuth
    ${resp}=    PerformPostRequest   ${POLICY_OPA_IP}  ${url}  ${expectedStatus}  ${postjson}  ${abbr}  ${hcauth}
    RETURN  ${resp}