Add Naming policy test for xacml CSIT
[integration/csit.git] / tests / policy / xacml-pdp / xacml-pdp-test.robot
index 86463c3..5144f96 100644 (file)
@@ -7,7 +7,7 @@ Library     json
 *** Test Cases ***
 Healthcheck
      [Documentation]    Runs Policy Xacml PDP Health check
-     ${auth}=    Create List    healthcheck    zb!XztG34 
+     ${auth}=    Create List    healthcheck    zb!XztG34
      Log    Creating session https://${POLICY_PDPX_IP}:6969
      ${session}=    Create Session      policy  https://${POLICY_PDPX_IP}:6969   auth=${auth}
      ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
@@ -18,7 +18,7 @@ Healthcheck
 
 Statistics
      [Documentation]    Runs Policy Xacml PDP Statistics
-     ${auth}=    Create List    healthcheck    zb!XztG34 
+     ${auth}=    Create List    healthcheck    zb!XztG34
      Log    Creating session https://${POLICY_PDPX_IP}:6969
      ${session}=    Create Session      policy  https://${POLICY_PDPX_IP}:6969   auth=${auth}
      ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
@@ -26,28 +26,15 @@ Statistics
      Log    Received response from policy ${resp.text}
      Should Be Equal As Strings    ${resp.status_code}     200
      Should Be Equal As Strings    ${resp.json()['code']}  200
-     
+
 ExecuteXacmlPolicy
-     Wait Until Keyword Succeeds    2 min    5 sec    CreateMonitorPolicyType
-     Wait Until Keyword Succeeds    2 min    5 sec    CreateNewMonitorPolicy
-     Wait Until Keyword Succeeds    2 min    5 sec    DeployMonitorPolicy
-     Wait Until Keyword Succeeds    2 min    10 sec   GetDecision
-     
-*** Keywords ***
+     Wait Until Keyword Succeeds    0 min   15 sec  CreateNewMonitorPolicy
+     Wait Until Keyword Succeeds    0 min   15 sec  DeployMonitorPolicy
+     Wait Until Keyword Succeeds    0 min   15 sec  GetAbbreviatedDecisionResult
+     Wait Until Keyword Succeeds    0 min   15 sec  GetMonitoringDecision
+     Wait Until Keyword Succeeds    0 min   15 sec  GetNamingDecision
 
-CreateMonitorPolicyType
-     [Documentation]    Create Monitoring Policy Type
-     ${auth}=    Create List    healthcheck    zb!XztG34
-     ${postjson}=  Get file  ${CURDIR}/data/onap.policies.monitoring.cdap.tca.hi.lo.app.json
-     Log    Creating session https://${POLICY_API_IP}:6969
-     ${session}=    Create Session      policy  https://${POLICY_API_IP}:6969   auth=${auth}
-     ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
-     ${resp}=   Post Request   policy  /policy/api/v1/policytypes  data=${postjson}   headers=${headers}
-     Log    Received response from policy2 ${resp.text}
-     Should Be Equal As Strings    ${resp.status_code}     200
-     ${postjsonobject}   To Json    ${postjson}
-     Dictionary Should Contain Key    ${resp.json()}    tosca_definitions_version
-     Dictionary Should Contain Key    ${postjsonobject}    tosca_definitions_version
+*** Keywords ***
 
 CreateNewMonitorPolicy
      [Documentation]    Create a new Monitoring policy
@@ -77,7 +64,7 @@ DeployMonitorPolicy
 
 GetStatisticsAfterDeployed
      [Documentation]    Runs Policy Xacml PDP Statistics after policy is deployed
-     ${auth}=    Create List    healthcheck    zb!XztG34 
+     ${auth}=    Create List    healthcheck    zb!XztG34
      Log    Creating session https://${POLICY_PDPX_IP}:6969
      ${session}=    Create Session      policy  https://${POLICY_PDPX_IP}:6969   auth=${auth}
      ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
@@ -86,21 +73,63 @@ GetStatisticsAfterDeployed
      Should Be Equal As Strings    ${resp.status_code}     200
      Should Be Equal As Strings    ${resp.json()['code']}  200
      Should Be Equal As Strings    ${resp.json()['totalPoliciesCount']     1
-     
-GetDecision
-    [Documentation]    Get Decision from Policy Xacml PDP
+
+GetAbbreviatedDecisionResult
+    [Documentation]    Get Decision with abbreviated results from Policy Xacml PDP
      ${auth}=    Create List    healthcheck    zb!XztG34
      ${postjson}=  Get file  ${CURDIR}/data/onap.policy.monitoring.decision.request.json
      Log    Creating session https://${POLICY_PDPX_IP}:6969
      ${session}=    Create Session      policy  https://${POLICY_PDPX_IP}:6969   auth=${auth}
      ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
+     ${params}=  Create Dictionary      abbrev=true
+     ${resp}=   Post Request     policy  /policy/pdpx/v1/decision     params=${params}  data=${postjson}   headers=${headers}
+     Log    Received response from policy ${resp.text}
+     ${policy}=    Get From Dictionary    ${resp.json()['policies']}   onap.restart.tca
+     Should Be Equal As Strings    ${resp.status_code}     200
+     Dictionary Should Contain Key    ${policy}    type
+     Dictionary Should Contain Key    ${policy}    metadata
+     Dictionary Should Not Contain Key    ${policy}    type_version
+     Dictionary Should Not Contain Key    ${policy}    properties
+     Dictionary Should Not Contain Key    ${policy}    name
+     Dictionary Should Not Contain Key    ${policy}    version
+
+GetMonitoringDecision
+    [Documentation]    Get Decision from Monitoring Policy Xacml PDP
+     ${auth}=    Create List    healthcheck    zb!XztG34
+     ${postjson}=  Get file  ${CURDIR}/data/onap.policy.monitoring.decision.request.json
+     Log    Creating session https://${POLICY_PDPX_IP}:6969
+     ${session}=    Create Session      policy  https://${POLICY_PDPX_IP}:6969   auth=${auth}
+     ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
+     ${resp}=   Post Request     policy  /policy/pdpx/v1/decision  data=${postjson}   headers=${headers}
+     Log    Received response from policy ${resp.text}
+     ${policy}=    Get From Dictionary    ${resp.json()['policies']}   onap.restart.tca
+     Should Be Equal As Strings    ${resp.status_code}     200
+     Dictionary Should Contain Key    ${policy}    type
+     Dictionary Should Contain Key    ${policy}    metadata
+     Dictionary Should Contain Key    ${policy}    type_version
+     Dictionary Should Contain Key    ${policy}    properties
+     Dictionary Should Contain Key    ${policy}    name
+     Dictionary Should Contain Key    ${policy}    version
+
+GetNamingDecision
+    [Documentation]    Get Decision from Naming Policy Xacml PDP
+     ${auth}=    Create List    healthcheck    zb!XztG34
+     ${postjson}=  Get file  ${CURDIR}/data/onap.policy.naming.decision.request.json
+     Log    Creating session https://${POLICY_PDPX_IP}:6969
+     ${session}=    Create Session      policy  https://${POLICY_PDPX_IP}:6969   auth=${auth}
+     ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
      ${resp}=   Post Request     policy  /policy/pdpx/v1/decision  data=${postjson}   headers=${headers}
      Log    Received response from policy ${resp.text}
+     ${policy}=    Get From Dictionary    ${resp.json()['policies']}   SDNC_Policy.ONAP_VNF_NAMING_TIMESTAMP
      Should Be Equal As Strings    ${resp.status_code}     200
-     
+     Dictionary Should Contain Key    ${policy}    type
+     Dictionary Should Contain Key    ${policy}    type_version
+     Dictionary Should Contain Key    ${policy}    properties
+     Dictionary Should Contain Key    ${policy}    name
+
 GetStatisticsAfterDecision
      [Documentation]    Runs Policy Xacml PDP Statistics after Decision request
-     ${auth}=    Create List    healthcheck    zb!XztG34 
+     ${auth}=    Create List    healthcheck    zb!XztG34
      Log    Creating session https://${POLICY_PDPX_IP}:6969
      ${session}=    Create Session      policy  https://${POLICY_PDPX_IP}:6969   auth=${auth}
      ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
@@ -109,7 +138,7 @@ GetStatisticsAfterDecision
      Should Be Equal As Strings    ${resp.status_code}     200
      Should Be Equal As Strings    ${resp.json()['code']}  200
      Should Be Equal As Strings    ${resp.json()['totalDecisionsCount']     1
-     
+
 UndeployMonitorPolicy
      [Documentation]    Runs Policy PAP to undeploy a policy
      ${auth}=    Create List    healthcheck    zb!XztG34
@@ -119,10 +148,10 @@ UndeployMonitorPolicy
      ${resp}=   Delete Request     policy  /policy/pap/v1/pdps/policies/onap.restart.tca     headers=${headers}
      Log    Received response from policy ${resp.text}
      Should Be Equal As Strings    ${resp.status_code}     200
-     
+
 GetStatisticsAfterUndeploy
      [Documentation]    Runs Policy Xacml PDP Statistics after policy is undeployed
-     ${auth}=    Create List    healthcheck    zb!XztG34 
+     ${auth}=    Create List    healthcheck    zb!XztG34
      Log    Creating session https://${POLICY_PDPX_IP}:6969
      ${session}=    Create Session      policy  https://${POLICY_PDPX_IP}:6969   auth=${auth}
      ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
@@ -131,5 +160,3 @@ GetStatisticsAfterUndeploy
      Should Be Equal As Strings    ${resp.status_code}     200
      Should Be Equal As Strings    ${resp.json()['code']}  200
      Should Be Equal As Strings    ${resp.json()['totalPoliciesCount']     0
-
-