diff options
Diffstat (limited to 'csit/resources/tests')
40 files changed, 895 insertions, 958 deletions
diff --git a/csit/resources/tests/apex-pdp-common.robot b/csit/resources/tests/apex-pdp-common.robot index 81924604..d88d16f8 100644 --- a/csit/resources/tests/apex-pdp-common.robot +++ b/csit/resources/tests/apex-pdp-common.robot @@ -1,26 +1,26 @@ *** Settings *** -Library Collections -Library RequestsLibrary -Library OperatingSystem -Library json -Library Process +Library Collections +Library RequestsLibrary +Library OperatingSystem +Library json +Library Process Resource common-library.robot *** Keywords *** DeployPolicy - [Documentation] Deploy the policy in apex-pdp engine - ${postjson}= Get File ${CURDIR}/data/policy_deploy.json - ${postjson}= evaluate json.loads('''${postjson}''') json - set to dictionary ${postjson['groups'][0]['deploymentSubgroups'][0]['policies'][0]} name=${policyName} - ${postjson}= evaluate json.dumps(${postjson}) json - ${policyadmin}= PolicyAdminAuth - PerformPostRequest ${POLICY_PAP_IP} /policy/pap/v1/pdps/deployments/batch 202 ${postjson} null ${policyadmin} + [Documentation] Deploy the policy in apex-pdp engine + ${postjson}= Get File ${CURDIR}/data/policy_deploy.json + ${postjson}= evaluate json.loads('''${postjson}''') json + set to dictionary ${postjson['groups'][0]['deploymentSubgroups'][0]['policies'][0]} name=${policyName} + ${postjson}= evaluate json.dumps(${postjson}) json + ${policyadmin}= PolicyAdminAuth + PerformPostRequest ${POLICY_PAP_IP} /policy/pap/v1/pdps/deployments/batch 202 ${postjson} null ${policyadmin} RunEventOnApexEngine [Documentation] Send event to verify policy execution Create Session apexSession http://${APEX_EVENTS_IP} max_retries=1 - ${data}= Get Binary File ${CURDIR}/data/event.json + ${data}= Get Binary File ${CURDIR}/data/event.json &{headers}= Create Dictionary Content-Type=application/json Accept=application/json ${resp}= PUT On Session apexSession /apex/FirstConsumer/EventIn data=${data} headers=${headers} Should Be Equal As Strings ${resp.status_code} 200 @@ -32,8 +32,8 @@ CheckLogMessage Should Contain ${result} ${expectedMsg} ValidateEventExecution - [Arguments] ${eventStartTime} ${eventEndTime} ${eventsNo} - [Documentation] Check that X amount of events were exeuted per second + [Arguments] ${eventStartTime} ${eventEndTime} ${eventsNo} + [Documentation] Check that X amount of events were executed per second ${eventTimeTaken}= Subtract Date From Date ${eventEndTime} ${eventStartTime} ${eventResult}= Set Variable ${eventTimeTaken * ${1000}} ${eventsPerSecond}= Set Variable ${${1000} / ${eventResult}} diff --git a/csit/resources/tests/apex-pdp-test.robot b/csit/resources/tests/apex-pdp-test.robot index 3989ec46..0de2b908 100644 --- a/csit/resources/tests/apex-pdp-test.robot +++ b/csit/resources/tests/apex-pdp-test.robot @@ -1,96 +1,96 @@ *** Settings *** -Library Collections -Library RequestsLibrary -Library OperatingSystem -Library json -Library Process +Library Collections +Library RequestsLibrary +Library OperatingSystem +Library json +Library Process Resource common-library.robot Resource apex-pdp-common.robot *** Test Cases *** Healthcheck - [Documentation] Runs Apex PDP Health check - ${hcauth}= PolicyAdminAuth - ${resp}= PerformGetRequest ${APEX_IP} /policy/apex-pdp/v1/healthcheck 200 null ${hcauth} - Should Be Equal As Strings ${resp.json()['code']} 200 - Set Suite Variable ${pdpName} ${resp.json()['name']} + [Documentation] Runs Apex PDP Health check + ${hcauth}= PolicyAdminAuth + ${resp}= PerformGetRequest ${APEX_IP} /policy/apex-pdp/v1/healthcheck 200 null ${hcauth} + Should Be Equal As Strings ${resp.json()['code']} 200 + Set Suite Variable ${pdpName} ${resp.json()['name']} ExecuteApexSampleDomainPolicy - # [Tags] docker - Set Test Variable ${policyName} onap.policies.native.apex.Sampledomain - ${postjson}= Get File ${CURDIR}/data/${policyName}.json - CreatePolicySuccessfully /policy/api/v1/policytypes/onap.policies.native.Apex/versions/1.0.0/policies ${postjson} ${policyName} 1.0.0 - DeployPolicy - Wait Until Keyword Succeeds 2 min 5 sec QueryPolicyStatus ${policyName} defaultGroup apex ${pdpName} onap.policies.native.Apex - Wait Until Keyword Succeeds 4 min 5 sec RunEventOnApexEngine + # [Tags] docker + Set Test Variable ${policyName} onap.policies.native.apex.Sampledomain + ${postjson}= Get File ${CURDIR}/data/${policyName}.json + CreatePolicySuccessfully /policy/api/v1/policytypes/onap.policies.native.Apex/versions/1.0.0/policies ${postjson} ${policyName} 1.0.0 + DeployPolicy + Wait Until Keyword Succeeds 2 min 5 sec QueryPolicyStatus ${policyName} defaultGroup apex ${pdpName} onap.policies.native.Apex + Wait Until Keyword Succeeds 4 min 5 sec RunEventOnApexEngine ExecuteApexTestPnfPolicy - Set Test Variable ${policyName} onap.policies.apex.pnf.Test - ${postjson}= Get File ${CURDIR}/data/${policyName}.json - CreatePolicySuccessfully /policy/api/v1/policytypes/onap.policies.native.Apex/versions/1.0.0/policies ${postjson} ${policyName} 1.0.0 - DeployPolicy - Wait Until Keyword Succeeds 2 min 5 sec QueryPolicyStatus ${policyName} defaultGroup apex ${pdpName} onap.policies.native.Apex - GetKafkaTopic apex-cl-mgt - Wait Until Keyword Succeeds 2 min 5 sec TriggerAndVerifyTestPnfPolicy apex-cl-mgt + Set Test Variable ${policyName} onap.policies.apex.pnf.Test + ${postjson}= Get File ${CURDIR}/data/${policyName}.json + CreatePolicySuccessfully /policy/api/v1/policytypes/onap.policies.native.Apex/versions/1.0.0/policies ${postjson} ${policyName} 1.0.0 + DeployPolicy + Wait Until Keyword Succeeds 2 min 5 sec QueryPolicyStatus ${policyName} defaultGroup apex ${pdpName} onap.policies.native.Apex + GetKafkaTopic apex-cl-mgt + TriggerAndVerifyTestPnfPolicy apex-cl-mgt #ExecuteApexTestVnfPolicy -# Set Test Variable ${policyName} onap.policies.apex.vnf.Test -# ${postjson}= Get File ${CURDIR}/data/${policyName}.json -# CreatePolicySuccessfully /policy/api/v1/policytypes/onap.policies.native.Apex/versions/1.0.0/policies ${postjson} ${policyName} 1.0.0 -# DeployPolicy -# Wait Until Keyword Succeeds 2 min 5 sec QueryPolicyStatus ${policyName} defaultGroup apex ${pdpName} onap.policies.native.Apex -# GetTopic apex-cl-mgt -# Wait Until Keyword Succeeds 2 min 5 sec TriggerAndVerifyTestVnfPolicy +# Set Test Variable ${policyName} onap.policies.apex.vnf.Test +# ${postjson}= Get File ${CURDIR}/data/${policyName}.json +# CreatePolicySuccessfully /policy/api/v1/policytypes/onap.policies.native.Apex/versions/1.0.0/policies ${postjson} ${policyName} 1.0.0 +# DeployPolicy +# Wait Until Keyword Succeeds 2 min 5 sec QueryPolicyStatus ${policyName} defaultGroup apex ${pdpName} onap.policies.native.Apex +# GetKafkaTopic apex-cl-mgt +# TriggerAndVerifyTestVnfPolicy apex-cl-mgt ExecuteApexTestPnfPolicyWithMetadataSet - Set Test Variable ${policyName} onap.policies.apex.pnf.metadataSet.Test - ${postjson}= Get File ${CURDIR}/data/${policyName}.json - CreatePolicySuccessfully /policy/api/v1/policytypes/onap.policies.native.Apex/versions/1.0.0/policies ${postjson} ${policyName} 1.0.0 - ${postjson}= Get File ${CURDIR}/data/onap.pnf.metadataSet.Test.json - CreateNodeTemplate /policy/api/v1/nodetemplates 201 ${postjson} 1 - DeployPolicy - Wait Until Keyword Succeeds 2 min 5 sec QueryPolicyStatus ${policyName} defaultGroup apex ${pdpName} onap.policies.native.Apex - GetKafkaTopic apex-cl-mgt2 - Wait Until Keyword Succeeds 2 min 5 sec TriggerAndVerifyTestPnfPolicy apex-cl-mgt2 + Set Test Variable ${policyName} onap.policies.apex.pnf.metadataSet.Test + ${postjson}= Get File ${CURDIR}/data/${policyName}.json + CreatePolicySuccessfully /policy/api/v1/policytypes/onap.policies.native.Apex/versions/1.0.0/policies ${postjson} ${policyName} 1.0.0 + ${postjson}= Get File ${CURDIR}/data/onap.pnf.metadataSet.Test.json + CreateNodeTemplate /policy/api/v1/nodetemplates 201 ${postjson} 1 + DeployPolicy + Wait Until Keyword Succeeds 2 min 5 sec QueryPolicyStatus ${policyName} defaultGroup apex ${pdpName} onap.policies.native.Apex + GetKafkaTopic apex-cl-mgt2 + TriggerAndVerifyTestPnfPolicy apex-cl-mgt2 Metrics - [Documentation] Verify policy-apex-pdp is exporting prometheus metrics - ${auth}= PolicyAdminAuth - ${resp}= PerformGetRequest ${APEX_IP} /metrics 200 null ${auth} - Should Contain ${resp.text} pdpa_policy_deployments_total{operation="deploy",status="TOTAL",} 3.0 - Should Contain ${resp.text} pdpa_policy_deployments_total{operation="deploy",status="SUCCESS",} 3.0 - Should Contain ${resp.text} pdpa_policy_executions_total{status="SUCCESS",} 6.0 - Should Contain ${resp.text} pdpa_policy_executions_total{status="TOTAL",} 6.0 - Should Match ${resp.text} *pdpa_engine_event_executions{engine_instance_id="NSOApexEngine-*:0.0.1",}* - Should Match ${resp.text} *pdpa_engine_event_executions{engine_instance_id="MyApexEngine-*:0.0.1",}* - Should Match ${resp.text} *pdpa_engine_state{engine_instance_id=*,} 2.0* - Should Contain ${resp.text} pdpa_engine_event_executions - Should Contain ${resp.text} pdpa_engine_average_execution_time_seconds - Should Contain ${resp.text} pdpa_engine_last_execution_time_bucket - Should Contain ${resp.text} pdpa_engine_last_execution_time_count - Should Contain ${resp.text} pdpa_engine_last_execution_time_sum - Should Match ${resp.text} *pdpa_engine_last_start_timestamp_epoch{engine_instance_id="NSOApexEngine-*:0.0.1",}*E12* - Should Match ${resp.text} *pdpa_engine_last_start_timestamp_epoch{engine_instance_id="MyApexEngine-*:0.0.1",}*E12* - Should Contain ${resp.text} jvm_threads_current + [Documentation] Verify policy-apex-pdp is exporting prometheus metrics + ${auth}= PolicyAdminAuth + ${resp}= PerformGetRequest ${APEX_IP} /metrics 200 null ${auth} + Should Contain ${resp.text} pdpa_policy_deployments_total{operation="deploy",status="TOTAL"} 3.0 + Should Contain ${resp.text} pdpa_policy_deployments_total{operation="deploy",status="SUCCESS"} 3.0 + Should Contain ${resp.text} pdpa_policy_executions_total{status="SUCCESS"} 3.0 + Should Contain ${resp.text} pdpa_policy_executions_total{status="TOTAL"} 3.0 + Should Match ${resp.text} *pdpa_engine_event_executions{engine_instance_id="NSOApexEngine-*:0.0.1"}* + Should Match ${resp.text} *pdpa_engine_event_executions{engine_instance_id="MyApexEngine-*:0.0.1"}* + Should Match ${resp.text} *pdpa_engine_state{engine_instance_id=*} 2.0* + Should Contain ${resp.text} pdpa_engine_event_executions + Should Contain ${resp.text} pdpa_engine_average_execution_time_seconds + Should Contain ${resp.text} pdpa_engine_last_execution_time_bucket + Should Contain ${resp.text} pdpa_engine_last_execution_time_count + Should Contain ${resp.text} pdpa_engine_last_execution_time_sum + Should Match ${resp.text} *pdpa_engine_last_start_timestamp_epoch{engine_instance_id="NSOApexEngine-*:0.0.1"}*E12* + Should Match ${resp.text} *pdpa_engine_last_start_timestamp_epoch{engine_instance_id="MyApexEngine-*:0.0.1"}*E12* + Should Contain ${resp.text} jvm_threads_current *** Keywords *** TriggerAndVerifyTestPnfPolicy [Documentation] Send TestPnf policy trigger event to Kafka and read notifications to verify policy execution [Arguments] ${topic} - ${data}= Get Binary File ${CURDIR}/data/VesEventForPnfPolicy.json + ${data}= Get Binary File ${CURDIR}/data/VesEventForPnfPolicy.json ${resp}= Run Process ${CURDIR}/kafka_producer.py unauthenticated.dcae_cl_output ${data} ${KAFKA_IP} - Run Keyword CheckLogMessage ${topic} ACTIVE VES event has been received. Going to fetch details from AAI. - Run Keyword CheckLogMessage ${topic} SUCCESS Received response from AAI successfully. Hostname in AAI matches with the one in Ves event. Going to make the update-config request to CDS. - Run Keyword CheckLogMessage ${topic} FINAL_SUCCESS Successfully processed the VES event. Hostname is updated. + Wait Until Keyword Succeeds 4 x 10 sec CheckLogMessage ${topic} ACTIVE VES event has been received. Going to fetch details from AAI. + Wait Until Keyword Succeeds 4 x 10 sec CheckLogMessage ${topic} SUCCESS Received response from AAI successfully. Hostname in AAI matches with the one in Ves event. Going to make the update-config request to CDS. + Wait Until Keyword Succeeds 4 x 10 sec CheckLogMessage ${topic} FINAL_SUCCESS Successfully processed the VES event. Hostname is updated. TriggerAndVerifyTestVnfPolicy [Documentation] Send TestVnf policy trigger event to Kafka and read notifications to verify policy execution [Arguments] ${topic} - ${data}= Get Binary File ${CURDIR}/data/VesEventForVnfPolicy.json + ${data}= Get Binary File ${CURDIR}/data/VesEventForVnfPolicy.json ${resp}= Run Process ${CURDIR}/kafka_producer.py unauthenticated.dcae_policy_example_output ${data} ${KAFKA_IP} - Run Keyword CheckLogMessage ${topic} ACTIVE VES event has been received. Going to fetch VNF details from AAI. - Run Keyword CheckLogMessage ${topic} SUCCESS VNF details are received from AAI successfully. Sending ConfigModify request to CDS. - Run Keyword CheckLogMessage ${topic} SUCCESS ConfigModify request is successful. Sending restart request to CDS. - Run Keyword CheckLogMessage ${topic} FINAL_SUCCESS Successfully processed the VES Event. Restart is complete. + Wait Until Keyword Succeeds 4 x 10 sec CheckLogMessage ${topic} ACTIVE VES event has been received. Going to fetch VNF details from AAI. + Wait Until Keyword Succeeds 4 x 10 sec CheckLogMessage ${topic} SUCCESS VNF details are received from AAI successfully. Sending ConfigModify request to CDS. + Wait Until Keyword Succeeds 4 x 10 sec CheckLogMessage ${topic} SUCCESS ConfigModify request is successful. Sending restart request to CDS. + Wait Until Keyword Succeeds 4 x 10 sec CheckLogMessage ${topic} FINAL_SUCCESS Successfully processed the VES Event. Restart is complete. diff --git a/csit/resources/tests/apex-slas-3.robot b/csit/resources/tests/apex-slas-3.robot index 1ceb9b77..c8fc2582 100644 --- a/csit/resources/tests/apex-slas-3.robot +++ b/csit/resources/tests/apex-slas-3.robot @@ -17,7 +17,7 @@ Healthcheck Set Suite Variable ${pdpName} ${resp.json()['name']} ValidatePolicyExecutionAndEventRateLowComplexity - [Documentation] Validate that a moderate complexity policity can be executed in less than 100ms and minimum 30 events triggered per second + [Documentation] Validate that a moderate complexity policy can be executed in less than 100ms and minimum 30 events triggered per second Set Test Variable ${policyName} onap.policies.apex.pnf.Test ${postjson}= Get File ${CURDIR}/data/${policyName}.json CreatePolicySuccessfully /policy/api/v1/policytypes/onap.policies.native.Apex/versions/1.0.0/policies ${postjson} ${policyName} 1.0.0 @@ -31,7 +31,7 @@ ValidatePolicyExecutionAndEventRateLowComplexity ValidateEventExecution ${eventStartTime} ${eventEndTime} 30 ValidatePolicyExecutionAndEventRateHighComplexity - [Documentation] Validate that a high complexity policity can be executed in less than 5000ms and minimum 0.6 events triggered per second + [Documentation] Validate that a high complexity policy can be executed in less than 5000ms and minimum 0.6 events triggered per second Set Test Variable ${policyName} onap.policies.apex.pnf.metadataSet.Test ${postjson}= Get File ${CURDIR}/data/${policyName}.json CreatePolicySuccessfully /policy/api/v1/policytypes/onap.policies.native.Apex/versions/1.0.0/policies ${postjson} ${policyName} 1.0.0 @@ -47,7 +47,7 @@ ValidatePolicyExecutionAndEventRateHighComplexity ValidateEventExecution ${eventStartTime} ${eventEndTime} 0.6 ValidatePolicyExecutionAndEventRateModerateComplexity - [Documentation] Validate that a low complexity policity can be executed in less than 1000ms and minimum 3 events triggered per second + [Documentation] Validate that a low complexity policy can be executed in less than 1000ms and minimum 3 events triggered per second Set Test Variable ${policyName} onap.policies.native.apex.Sampledomain ${postjson}= Get File ${CURDIR}/data/${policyName}.json CreatePolicySuccessfully /policy/api/v1/policytypes/onap.policies.native.Apex/versions/1.0.0/policies ${postjson} ${policyName} 1.0.0 diff --git a/csit/resources/tests/apex-slas.robot b/csit/resources/tests/apex-slas.robot index 760bc348..e27f0da2 100644 --- a/csit/resources/tests/apex-slas.robot +++ b/csit/resources/tests/apex-slas.robot @@ -10,11 +10,11 @@ Resource apex-pdp-common.robot *** Test Cases *** Healthcheck - [Documentation] Runs Apex PDP Health check - ${hcauth}= PolicyAdminAuth - ${resp}= PerformGetRequest ${APEX_IP} /policy/apex-pdp/v1/healthcheck 200 null ${hcauth} - Should Be Equal As Strings ${resp.json()['code']} 200 - Set Suite Variable ${pdpName} ${resp.json()['name']} + [Documentation] Runs Apex PDP Health check + ${hcauth}= PolicyAdminAuth + ${resp}= PerformGetRequest ${APEX_IP} /policy/apex-pdp/v1/healthcheck 200 null ${hcauth} + Should Be Equal As Strings ${resp.json()['code']} 200 + Set Suite Variable ${pdpName} ${resp.json()['name']} ValidatePolicyExecutionAndEventRateLowComplexity [Documentation] Validate that a moderate complexity policy can be executed in less than 100ms and minimum 10 events triggered per second @@ -23,8 +23,8 @@ ValidatePolicyExecutionAndEventRateLowComplexity CreatePolicySuccessfully /policy/api/v1/policytypes/onap.policies.native.Apex/versions/1.0.0/policies ${postjson} ${policyName} 1.0.0 DeployPolicy Wait Until Keyword Succeeds 2 min 5 sec QueryPolicyStatus ${policyName} defaultGroup apex ${pdpName} onap.policies.native.Apex - GetKafkaTopic apex-cl-mgt - ${data}= Get Binary File ${CURDIR}/data/VesEventForPnfPolicy.json + GetKafkaTopic apex-cl-mgt + ${data}= Get Binary File ${CURDIR}/data/VesEventForPnfPolicy.json ${eventStartTime}= Get Current Date ${resp}= Run Process ${CURDIR}/kafka_producer.py unauthenticated.dcae_cl_output ${data} ${KAFKA_IP} ${eventEndTime}= Get Current Date @@ -50,8 +50,8 @@ ValidatePolicyExecutionAndEventRateHighComplexity CreateNodeTemplate /policy/api/v1/nodetemplates 201 ${postjson} 1 DeployPolicy Wait Until Keyword Succeeds 2 min 5 sec QueryPolicyStatus ${policyName} defaultGroup apex ${pdpName} onap.policies.native.Apex - GetKafkaTopic apex-cl-mgt2 - ${data}= Get Binary File ${CURDIR}/data/VesEventForVnfPolicy.json + GetKafkaTopic apex-cl-mgt2 + ${data}= Get Binary File ${CURDIR}/data/VesEventForVnfPolicy.json ${eventStartTime}= Get Current Date ${resp}= Run Process ${CURDIR}/kafka_producer.py unauthenticated.dcae_policy_example_output ${data} ${KAFKA_IP} ${eventEndTime}= Get Current Date diff --git a/csit/resources/tests/api-test.robot b/csit/resources/tests/api-test.robot index 29c2fba4..e1b8fd47 100644 --- a/csit/resources/tests/api-test.robot +++ b/csit/resources/tests/api-test.robot @@ -16,7 +16,7 @@ Healthcheck RetrievePolicyTypes [Documentation] Retrieve all policy types - FetchPolicyTypes /policy/api/v1/policytypes 37 + FetchPolicyTypes /policy/api/v1/policytypes 38 CreateTCAPolicyTypeV1 [Documentation] Create an existing policy type with modification and keeping the same version should result in error. diff --git a/csit/resources/tests/common-library.robot b/csit/resources/tests/common-library.robot index e0b1c0f1..89a9c726 100644 --- a/csit/resources/tests/common-library.robot +++ b/csit/resources/tests/common-library.robot @@ -11,6 +11,15 @@ PolicyAdminAuth ${policyadmin}= Create list policyadmin zb!XztG34 RETURN ${policyadmin} +PerformPatchRequest + [Arguments] ${domain} ${url} ${expectedstatus} ${patchjson} ${params} ${auth} + Log Creating session http://${domain} + ${session}= Create Session policy http://${domain} auth=${auth} + ${headers}= Create Dictionary Accept=application/json Content-Type=application/json + ${resp}= PATCH On Session policy ${url} data=${patchjson} params=${params} headers=${headers} expected_status=${expectedstatus} + Log Received response from policy ${resp.text} + RETURN ${resp} + PerformPostRequest [Arguments] ${domain} ${url} ${expectedstatus} ${postjson} ${params} ${auth} Log Creating session http://${domain} @@ -20,6 +29,15 @@ PerformPostRequest Log Received response from policy ${resp.text} RETURN ${resp} +PerformPostRequestWithYaml + [Arguments] ${domain} ${url} ${expectedstatus} ${postyaml} ${params} ${auth} + Log Creating session http://${domain} + ${session}= Create Session policy http://${domain} auth=${auth} + ${headers}= Create Dictionary Accept=application/yaml Content-Type=application/yaml + ${resp}= POST On Session policy ${url} data=${postyaml} params=${params} headers=${headers} expected_status=${expectedstatus} + Log Received response from policy ${resp.text} + RETURN ${resp} + PerformPutRequest [Arguments] ${domain} ${url} ${expectedstatus} ${params} ${auth} Log Creating session http://${domain} @@ -52,6 +70,20 @@ CreatePolicy ${policyadmin}= PolicyAdminAuth ${resp}= PerformPostRequest ${POLICY_API_IP} ${url} ${expectedstatus} ${postjson} null ${policyadmin} +CreatePolicyWithYaml + [Arguments] ${url} ${expectedstatus} ${postyaml} + [Documentation] Create the specific policy + ${policyadmin}= PolicyAdminAuth + ${resp}= PerformPostRequestWithYaml ${POLICY_API_IP} ${url} ${expectedstatus} ${postyaml} null ${policyadmin} + +CreateFailurePolicyWithYaml + [Arguments] ${url} ${expectedstatus} ${postyaml} ${keyword} + [Documentation] Trying to create policy with Invalid Data + ${policyadmin}= PolicyAdminAuth + ${resp}= PerformPostRequestWithYaml ${POLICY_API_IP} ${url} ${expectedstatus} ${postyaml} null ${policyadmin} + Should Contain ${resp.text} ${keyword} + + CreatePolicySuccessfully [Arguments] ${url} ${postjson} ${policyname} ${policyversion} [Documentation] Create the specific policy @@ -164,4 +196,4 @@ ValidatePolicyExecution ${resp}= QueryPrometheus ${url} ${rawNumber}= Evaluate ${resp['data']['result'][0]['value'][1]} ${actualTime}= Set Variable ${rawNumber * ${1000}} - Should Be True ${actualTime} <= ${executionTime}
\ No newline at end of file + Should Be True ${actualTime} <= ${executionTime} diff --git a/csit/resources/tests/data/acelement-usecase.yaml b/csit/resources/tests/data/acelement-usecase.yaml index 937ed6e6..b727a68f 100644 --- a/csit/resources/tests/data/acelement-usecase.yaml +++ b/csit/resources/tests/data/acelement-usecase.yaml @@ -27,176 +27,6 @@ data_types: type: string required: true - onap.datatypes.native.apex.EngineService: - derived_from: tosca.datatypes.Root - properties: - name: - type: string - description: Specifies the engine name - required: false - default: "ApexEngineService" - version: - type: string - description: Specifies the engine version in double dotted format - required: false - default: "1.0.0" - id: - type: integer - description: Specifies the engine id - required: true - instance_count: - type: integer - description: Specifies the number of engine threads that should be run - required: true - deployment_port: - type: integer - description: Specifies the port to connect to for engine administration - required: false - default: 1 - policy_model_file_name: - type: string - description: The name of the file from which to read the APEX policy model - required: false - policy_type_impl: - type: string - description: The policy type implementation from which to read the APEX policy model - required: false - periodic_event_period: - type: string - description: The time interval in milliseconds for the periodic scanning event, 0 means don't scan - required: false - engine: - type: onap.datatypes.native.apex.engineservice.Engine - description: The parameters for all engines in the APEX engine service - required: true - onap.datatypes.native.apex.EventHandler: - derived_from: tosca.datatypes.Root - properties: - name: - type: string - description: Specifies the event handler name, if not specified this is set to the key name - required: false - carrier_technology: - type: onap.datatypes.native.apex.CarrierTechnology - description: Specifies the carrier technology of the event handler (such as REST/Web Socket/Kafka) - required: true - event_protocol: - type: onap.datatypes.native.apex.EventProtocol - description: Specifies the event protocol of events for the event handler (such as Yaml/JSON/XML/POJO) - required: true - event_name: - type: string - description: Specifies the event name for events on this event handler, if not specified, the event name is read from or written to the event being received or sent - required: false - event_name_filter: - type: string - description: Specifies a filter as a regular expression, events that do not match the filter are dropped, the default is to let all events through - required: false - synchronous_mode: - type: boolean - description: Specifies the event handler is syncronous (receive event and send response) - required: false - default: false - synchronous_peer: - type: string - description: The peer event handler (output for input or input for output) of this event handler in synchronous mode, this parameter is mandatory if the event handler is in synchronous mode - required: false - synchronous_timeout: - type: integer - description: The timeout in milliseconds for responses to be issued by APEX torequests, this parameter is mandatory if the event handler is in synchronous mode - required: false - requestor_mode: - type: boolean - description: Specifies the event handler is in requestor mode (send event and wait for response mode) - required: false - default: false - requestor_peer: - type: string - description: The peer event handler (output for input or input for output) of this event handler in requestor mode, this parameter is mandatory if the event handler is in requestor mode - required: false - requestor_timeout: - type: integer - description: The timeout in milliseconds for wait for responses to requests, this parameter is mandatory if the event handler is in requestor mode - required: false - onap.datatypes.native.apex.CarrierTechnology: - derived_from: tosca.datatypes.Root - properties: - label: - type: string - description: The label (name) of the carrier technology (such as REST, Kafka, WebSocket) - required: true - plugin_parameter_class_name: - type: string - description: The class name of the class that overrides default handling of event input or output for this carrier technology, defaults to the supplied input or output class - required: false - onap.datatypes.native.apex.EventProtocol: - derived_from: tosca.datatypes.Root - properties: - label: - type: string - description: The label (name) of the event protocol (such as Yaml, JSON, XML, or POJO) - required: true - event_protocol_plugin_class: - type: string - description: The class name of the class that overrides default handling of the event protocol for this carrier technology, defaults to the supplied event protocol class - required: false - onap.datatypes.native.apex.Environment: - derived_from: tosca.datatypes.Root - properties: - name: - type: string - description: The name of the environment variable - required: true - value: - type: string - description: The value of the environment variable - required: true - onap.datatypes.native.apex.engineservice.Engine: - derived_from: tosca.datatypes.Root - properties: - context: - type: onap.datatypes.native.apex.engineservice.engine.Context - description: The properties for handling context in APEX engines, defaults to using Java maps for context - required: false - executors: - type: map - description: The plugins for policy executors used in engines such as javascript, MVEL, Jython - required: true - entry_schema: - description: The plugin class path for this policy executor - type: string - onap.datatypes.native.apex.engineservice.engine.Context: - derived_from: tosca.datatypes.Root - properties: - distributor: - type: onap.datatypes.native.apex.Plugin - description: The plugin to be used for distributing context between APEX PDPs at runtime - required: false - schemas: - type: map - description: The plugins for context schemas available in APEX PDPs such as Java and Avro - required: false - entry_schema: - type: onap.datatypes.native.apex.Plugin - locking: - type: onap.datatypes.native.apex.Plugin - description: The plugin to be used for locking context in and between APEX PDPs at runtime - required: false - persistence: - type: onap.datatypes.native.apex.Plugin - description: The plugin to be used for persisting context for APEX PDPs at runtime - required: false - onap.datatypes.native.apex.Plugin: - derived_from: tosca.datatypes.Root - properties: - name: - type: string - description: The name of the executor such as Javascript, Jython or MVEL - required: true - plugin_class_name: - type: string - description: The class path of the plugin class for this executor - org.onap.datatypes.policy.clamp.acm.httpAutomationCompositionElement.RestRequest: version: 1.0.0 derived_from: tosca.datatypes.Root @@ -244,37 +74,6 @@ data_types: type_version: 1.0.0 description: A sequence of REST commands to send to the REST endpoint -policy_types: - onap.policies.Native: - derived_from: tosca.policies.Root - description: a base policy type for all native PDP policies - version: 1.0.0 - name: onap.policies.Native - onap.policies.native.Apex: - derived_from: onap.policies.Native - description: a policy type for native apex policies - version: 1.0.0 - name: onap.policies.native.Apex - properties: - engine_service: - type: onap.datatypes.native.apex.EngineService - description: APEX Engine Service Parameters - inputs: - type: map - description: Inputs for handling events coming into the APEX engine - entry_schema: - type: onap.datatypes.native.apex.EventHandler - outputs: - type: map - description: Outputs for handling events going out of the APEX engine - entry_schema: - type: onap.datatypes.native.apex.EventHandler - environment: - type: list - description: Envioronmental parameters for the APEX engine - entry_schema: - type: onap.datatypes.native.apex.Environment - node_types: org.onap.policy.clamp.acm.Participant: version: 1.0.1 @@ -536,601 +335,3 @@ topology_template: version: 1.2.3 - name: onap.policy.clamp.ac.element.Http_SinkAutomationCompositionElement version: 1.2.3 - - policies: - - onap.policies.native.apex.ac.element: - type: onap.policies.native.Apex - type_version: 1.0.0 - properties: - engineServiceParameters: - name: MyApexEngine - version: 0.0.1 - id: 45 - instanceCount: 2 - deploymentPort: 12561 - engineParameters: - executorParameters: - JAVASCRIPT: - parameterClassName: org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters - contextParameters: - parameterClassName: org.onap.policy.apex.context.parameters.ContextParameters - schemaParameters: - Json: - parameterClassName: org.onap.policy.apex.plugins.context.schema.json.JsonSchemaHelperParameters - policy_type_impl: - policies: - key: - name: APEXacElementPolicy_Policies - version: 0.0.1 - policyMap: - entry: - - key: - name: ReceiveEventPolicy - version: 0.0.1 - value: - policyKey: - name: ReceiveEventPolicy - version: 0.0.1 - template: Freestyle - state: - entry: - - key: DecideForwardingState - value: - stateKey: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: DecideForwardingState - trigger: - name: AcElementEvent - version: 0.0.1 - stateOutputs: - entry: - - key: CreateForwardPayload - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: DecideForwardingState - localName: CreateForwardPayload - outgoingEvent: - name: DmaapResponseStatusEvent - version: 0.0.1 - outgoingEventReference: - - name: DmaapResponseStatusEvent - version: 0.0.1 - nextState: - parentKeyName: 'NULL' - parentKeyVersion: 0.0.0 - parentLocalName: 'NULL' - localName: 'NULL' - contextAlbumReference: [] - taskSelectionLogic: - key: - parentKeyName: 'NULL' - parentKeyVersion: 0.0.0 - parentLocalName: 'NULL' - localName: 'NULL' - logicFlavour: UNDEFINED - logic: '' - stateFinalizerLogicMap: - entry: [] - defaultTask: - name: ForwardPayloadTask - version: 0.0.1 - taskReferences: - entry: - - key: - name: ForwardPayloadTask - version: 0.0.1 - value: - key: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: DecideForwardingState - localName: ReceiveEventPolicy - outputType: DIRECT - output: - parentKeyName: ReceiveEventPolicy - parentKeyVersion: 0.0.1 - parentLocalName: DecideForwardingState - localName: CreateForwardPayload - firstState: DecideForwardingState - tasks: - key: - name: APEXacElementPolicy_Tasks - version: 0.0.1 - taskMap: - entry: - - key: - name: ForwardPayloadTask - version: 0.0.1 - value: - key: - name: ForwardPayloadTask - version: 0.0.1 - inputEvent: - key: - name: AcElementEvent - version: 0.0.1 - nameSpace: org.onap.policy.apex.ac.element - source: Dmaap - target: APEX - parameter: - entry: - - key: DmaapResponseEvent - value: - key: - parentKeyName: AcElementEvent - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: DmaapResponseEvent - fieldSchemaKey: - name: ACEventType - version: 0.0.1 - optional: false - toscaPolicyState: ENTRY - outputEvents: - entry: - - key: DmaapResponseStatusEvent - value: - key: - name: DmaapResponseStatusEvent - version: 0.0.1 - nameSpace: org.onap.policy.apex.ac.element - source: APEX - target: Dmaap - parameter: - entry: - - key: DmaapResponseStatusEvent - value: - key: - parentKeyName: DmaapResponseStatusEvent - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: DmaapResponseStatusEvent - fieldSchemaKey: - name: ACEventType - version: 0.0.1 - optional: false - toscaPolicyState: '' - taskParameters: - entry: [] - contextAlbumReference: - - name: ACElementAlbum - version: 0.0.1 - taskLogic: - key: - parentKeyName: ForwardPayloadTask - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: TaskLogic - logicFlavour: JAVASCRIPT - logic: "/*\n * ============LICENSE_START=======================================================\n\ - \ * Copyright (C) 2022 Nordix. All rights reserved.\n * ================================================================================\n\ - \ * Licensed under the Apache License, Version 2.0 (the 'License');\n\ - \ * you may not use this file except in compliance with the\ - \ License.\n * You may obtain a copy of the License at\n *\n\ - \ * http://www.apache.org/licenses/LICENSE-2.0\n *\n\ - \ * Unless required by applicable law or agreed to in writing,\ - \ software\n * distributed under the License is distributed\ - \ on an 'AS IS' BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS\ - \ OF ANY KIND, either express or implied.\n * See the License\ - \ for the specific language governing permissions and\n *\ - \ limitations under the License.\n *\n * SPDX-License-Identifier:\ - \ Apache-2.0\n * ============LICENSE_END=========================================================\n\ - \ */\n\nexecutor.logger.info(executor.subject.id);\nexecutor.logger.info(executor.inFields);\n\ - \nvar msgResponse = executor.inFields.get('DmaapResponseEvent');\n\ - executor.logger.info('Task in progress with mesages: ' + msgResponse);\n\ - \nvar elementId = msgResponse.get('elementId').get('name');\n\ - \nif (msgResponse.get('messageType') == 'STATUS' &&\n (elementId\ - \ == 'onap.policy.clamp.ac.startertobridge'\n || elementId\ - \ == 'onap.policy.clamp.ac.bridgetosink')) {\n\n var receiverId\ - \ = '';\n if (elementId == 'onap.policy.clamp.ac.startertobridge')\ - \ {\n receiverId = 'onap.policy.clamp.ac.bridge';\n\ - \ } else {\n receiverId = 'onap.policy.clamp.ac.sink';\n\ - \ }\n\n var elementIdResponse = new java.util.HashMap();\n\ - \ elementIdResponse.put('name', receiverId);\n elementIdResponse.put('version',\ - \ msgResponse.get('elementId').get('version'));\n\n var\ - \ dmaapResponse = new java.util.HashMap();\n dmaapResponse.put('elementId',\ - \ elementIdResponse);\n\n var message = msgResponse.get('message')\ - \ + ' trace added from policy';\n dmaapResponse.put('message',\ - \ message);\n dmaapResponse.put('messageType', 'STATUS');\n\ - \ dmaapResponse.put('messageId', msgResponse.get('messageId'));\n\ - \ dmaapResponse.put('timestamp', msgResponse.get('timestamp'));\n\ - \n executor.logger.info('Sending forwarding Event to Ac\ - \ element: ' + dmaapResponse);\n\n executor.outFields.put('DmaapResponseStatusEvent',\ - \ dmaapResponse);\n}\n\ntrue;" - events: - key: - name: APEXacElementPolicy_Events - version: 0.0.1 - eventMap: - entry: - - key: - name: AcElementEvent - version: 0.0.1 - value: - key: - name: AcElementEvent - version: 0.0.1 - nameSpace: org.onap.policy.apex.ac.element - source: Dmaap - target: APEX - parameter: - entry: - - key: DmaapResponseEvent - value: - key: - parentKeyName: AcElementEvent - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: DmaapResponseEvent - fieldSchemaKey: - name: ACEventType - version: 0.0.1 - optional: false - toscaPolicyState: ENTRY - - key: - name: DmaapResponseStatusEvent - version: 0.0.1 - value: - key: - name: DmaapResponseStatusEvent - version: 0.0.1 - nameSpace: org.onap.policy.apex.ac.element - source: APEX - target: Dmaap - parameter: - entry: - - key: DmaapResponseStatusEvent - value: - key: - parentKeyName: DmaapResponseStatusEvent - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: DmaapResponseStatusEvent - fieldSchemaKey: - name: ACEventType - version: 0.0.1 - optional: false - toscaPolicyState: '' - - key: - name: LogEvent - version: 0.0.1 - value: - key: - name: LogEvent - version: 0.0.1 - nameSpace: org.onap.policy.apex.ac.element - source: APEX - target: file - parameter: - entry: - - key: final_status - value: - key: - parentKeyName: LogEvent - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: final_status - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - - key: message - value: - key: - parentKeyName: LogEvent - parentKeyVersion: 0.0.1 - parentLocalName: 'NULL' - localName: message - fieldSchemaKey: - name: SimpleStringType - version: 0.0.1 - optional: false - toscaPolicyState: '' - albums: - key: - name: APEXacElementPolicy_Albums - version: 0.0.1 - albums: - entry: - - key: - name: ACElementAlbum - version: 0.0.1 - value: - key: - name: ACElementAlbum - version: 0.0.1 - scope: policy - isWritable: true - itemSchema: - name: ACEventType - version: 0.0.1 - schemas: - key: - name: APEXacElementPolicy_Schemas - version: 0.0.1 - schemas: - entry: - - key: - name: ACEventType - version: 0.0.1 - value: - key: - name: ACEventType - version: 0.0.1 - schemaFlavour: Json - schemaDefinition: "{\n \"$schema\": \"http://json-schema.org/draft-04/schema#\"\ - ,\n \"type\": \"object\",\n \"properties\": {\n \ - \ \"elementId\": {\n \"type\": \"object\",\n \ - \ \"properties\": {\n \"name\": {\n \ - \ \"type\": \"string\"\n },\n\ - \ \"version\": {\n \"type\"\ - : \"string\"\n }\n },\n \ - \ \"required\": [\n \"name\",\n \ - \ \"version\"\n ]\n },\n \"message\"\ - : {\n \"type\": \"string\"\n },\n \"\ - messageType\": {\n \"type\": \"string\"\n \ - \ }\n },\n \"required\": [\n \"elementId\",\n \ - \ \"message\",\n \"messageType\"\n ]\n}" - - key: - name: SimpleIntType - version: 0.0.1 - value: - key: - name: SimpleIntType - version: 0.0.1 - schemaFlavour: Java - schemaDefinition: java.lang.Integer - - key: - name: SimpleStringType - version: 0.0.1 - value: - key: - name: SimpleStringType - version: 0.0.1 - schemaFlavour: Java - schemaDefinition: java.lang.String - - key: - name: UUIDType - version: 0.0.1 - value: - key: - name: UUIDType - version: 0.0.1 - schemaFlavour: Java - schemaDefinition: java.util.UUID - key: - name: APEXacElementPolicy - version: 0.0.1 - keyInformation: - key: - name: APEXacElementPolicy_KeyInfo - version: 0.0.1 - keyInfoMap: - entry: - - key: - name: ACElementAlbum - version: 0.0.1 - value: - key: - name: ACElementAlbum - version: 0.0.1 - UUID: 7cddfab8-6d3f-3f7f-8ac3-e2eb5979c900 - description: Generated description for concept referred to by - key "ACElementAlbum:0.0.1" - - key: - name: ACEventType - version: 0.0.1 - value: - key: - name: ACEventType - version: 0.0.1 - UUID: dab78794-b666-3929-a75b-70d634b04fe5 - description: Generated description for concept referred to by - key "ACEventType:0.0.1" - - key: - name: APEXacElementPolicy - version: 0.0.1 - value: - key: - name: APEXacElementPolicy - version: 0.0.1 - UUID: da478611-7d77-3c46-b4be-be968769ba4e - description: Generated description for concept referred to by - key "APEXacElementPolicy:0.0.1" - - key: - name: APEXacElementPolicy_Albums - version: 0.0.1 - value: - key: - name: APEXacElementPolicy_Albums - version: 0.0.1 - UUID: fa8dc15e-8c8d-3de3-a0f8-585b76511175 - description: Generated description for concept referred to by - key "APEXacElementPolicy_Albums:0.0.1" - - key: - name: APEXacElementPolicy_Events - version: 0.0.1 - value: - key: - name: APEXacElementPolicy_Events - version: 0.0.1 - UUID: 8508cd65-8dd2-342d-a5c6-1570810dbe2b - description: Generated description for concept referred to by - key "APEXacElementPolicy_Events:0.0.1" - - key: - name: APEXacElementPolicy_KeyInfo - version: 0.0.1 - value: - key: - name: APEXacElementPolicy_KeyInfo - version: 0.0.1 - UUID: 09e6927d-c5ac-3779-919f-9333994eed22 - description: Generated description for concept referred to by - key "APEXacElementPolicy_KeyInfo:0.0.1" - - key: - name: APEXacElementPolicy_Policies - version: 0.0.1 - value: - key: - name: APEXacElementPolicy_Policies - version: 0.0.1 - UUID: cade3c9a-1600-3642-a6f4-315612187f46 - description: Generated description for concept referred to by - key "APEXacElementPolicy_Policies:0.0.1" - - key: - name: APEXacElementPolicy_Schemas - version: 0.0.1 - value: - key: - name: APEXacElementPolicy_Schemas - version: 0.0.1 - UUID: 5bb4a8e9-35fa-37db-9a49-48ef036a7ba9 - description: Generated description for concept referred to by - key "APEXacElementPolicy_Schemas:0.0.1" - - key: - name: APEXacElementPolicy_Tasks - version: 0.0.1 - value: - key: - name: APEXacElementPolicy_Tasks - version: 0.0.1 - UUID: 2527eeec-0d1f-3094-ad3f-212622b12836 - description: Generated description for concept referred to by - key "APEXacElementPolicy_Tasks:0.0.1" - - key: - name: AcElementEvent - version: 0.0.1 - value: - key: - name: AcElementEvent - version: 0.0.1 - UUID: 32c013e2-2740-3986-a626-cbdf665b63e9 - description: Generated description for concept referred to by - key "AcElementEvent:0.0.1" - - key: - name: DmaapResponseStatusEvent - version: 0.0.1 - value: - key: - name: DmaapResponseStatusEvent - version: 0.0.1 - UUID: 2715cb6c-2778-3461-8b69-871e79f95935 - description: Generated description for concept referred to by - key "DmaapResponseStatusEvent:0.0.1" - - key: - name: ForwardPayloadTask - version: 0.0.1 - value: - key: - name: ForwardPayloadTask - version: 0.0.1 - UUID: 51defa03-1ecf-3314-bf34-2a652bce57fa - description: Generated description for concept referred to by - key "ForwardPayloadTask:0.0.1" - - key: - name: LogEvent - version: 0.0.1 - value: - key: - name: LogEvent - version: 0.0.1 - UUID: c540f048-96af-35e3-a36e-e9c29377cba7 - description: Generated description for concept referred to by - key "LogEvent:0.0.1" - - key: - name: ReceiveEventPolicy - version: 0.0.1 - value: - key: - name: ReceiveEventPolicy - version: 0.0.1 - UUID: 568b7345-9de1-36d3-b6a3-9b857e6809a1 - description: Generated description for concept referred to by - key "ReceiveEventPolicy:0.0.1" - - key: - name: SimpleIntType - version: 0.0.1 - value: - key: - name: SimpleIntType - version: 0.0.1 - UUID: 153791fd-ae0a-36a7-88a5-309a7936415d - description: Generated description for concept referred to by - key "SimpleIntType:0.0.1" - - key: - name: SimpleStringType - version: 0.0.1 - value: - key: - name: SimpleStringType - version: 0.0.1 - UUID: 8a4957cf-9493-3a76-8c22-a208e23259af - description: Generated description for concept referred to by - key "SimpleStringType:0.0.1" - - key: - name: UUIDType - version: 0.0.1 - value: - key: - name: UUIDType - version: 0.0.1 - UUID: 6a8cc68e-dfc8-3403-9c6d-071c886b319c - description: Generated description for concept referred to by - key "UUIDType:0.0.1" - eventInputParameters: - DmaapConsumer: - carrierTechnologyParameters: - carrierTechnology: KAFKA - parameterClassName: org.onap.policy.apex.plugins.event.carrier.kafka.KafkaCarrierTechnologyParameters - parameters: - bootstrapServers: kafka:9092 - groupId: clamp-grp - enableAutoCommit: true - autoCommitTime: 1000 - sessionTimeout: 30000 - consumerPollTime: 100 - consumerTopicList: - - ac_element_msg - keyDeserializer: org.apache.kafka.common.serialization.StringDeserializer - valueDeserializer: org.apache.kafka.common.serialization.StringDeserializer - kafkaProperties: [ ] - eventProtocolParameters: - eventProtocol: JSON - parameters: - pojoField: DmaapResponseEvent - eventName: AcElementEvent - eventNameFilter: AcElementEvent - eventOutputParameters: - logOutputter: - carrierTechnologyParameters: - carrierTechnology: FILE - parameters: - fileName: outputevents.log - eventProtocolParameters: - eventProtocol: JSON - DmaapReplyProducer: - carrierTechnologyParameters: - carrierTechnology: KAFKA - parameterClassName: org.onap.policy.apex.plugins.event.carrier.kafka.KafkaCarrierTechnologyParameters - parameters: - bootstrapServers: kafka:9092 - acks: all - retries: 0 - batchSize: 16384 - lingerTime: 1 - bufferMemory: 33554432 - producerTopic: policy_update_msg - keySerializer: org.apache.kafka.common.serialization.StringSerializer - valueSerializer: org.apache.kafka.common.serialization.StringSerializer - kafkaProperties: [ ] - eventProtocolParameters: - eventProtocol: JSON - parameters: - pojoField: DmaapResponseStatusEvent - eventNameFilter: LogEvent|DmaapResponseStatusEvent - name: onap.policies.native.apex.ac.element - version: 1.0.0 diff --git a/csit/resources/tests/data/onap.policy.opa.pdp.data-empty.json b/csit/resources/tests/data/onap.policy.opa.pdp.data-empty.json new file mode 100644 index 00000000..432476a7 --- /dev/null +++ b/csit/resources/tests/data/onap.policy.opa.pdp.data-empty.json @@ -0,0 +1,12 @@ +{ + "data": { + "system": { + "version": { + "build_commit": "", + "build_hostname": "", + "build_timestamp": "", + "version": "1.1.0" + } + } + } +} diff --git a/csit/resources/tests/data/onap.policy.opa.pdp.decision.zone-incorrect-policyfilter.json b/csit/resources/tests/data/onap.policy.opa.pdp.decision.zone-incorrect-policyfilter.json new file mode 100644 index 00000000..1c7f8b8f --- /dev/null +++ b/csit/resources/tests/data/onap.policy.opa.pdp.decision.zone-incorrect-policyfilter.json @@ -0,0 +1,19 @@ +{ + "onapName": "CDS", + "onapComponent": "CDS", + "onapInstance": "CDS", + "currentDate": "2024-11-22", + "policyName": "zoneB", + "policyFilter": ["has_ze_access"], + "input": { + "actions": ["view"], + "log_id": "log1", + "datatypes": ["access", "user"], + "time_period": { + "from": "2024-11-01T09:00:00Z", + "to": "2024-11-01T10:00:00Z" + }, + "zone_id": "zoneA" + } +} + diff --git a/csit/resources/tests/data/onap.policy.opa.pdp.decision.zone-incorrect-policyname.json b/csit/resources/tests/data/onap.policy.opa.pdp.decision.zone-incorrect-policyname.json new file mode 100644 index 00000000..dfa088b4 --- /dev/null +++ b/csit/resources/tests/data/onap.policy.opa.pdp.decision.zone-incorrect-policyname.json @@ -0,0 +1,19 @@ +{ + "onapName": "CDS", + "onapComponent": "CDS", + "onapInstance": "CDS", + "currentDate": "2024-11-22", + "policyName": "zoeB", + "policyFilter": ["has_zone_access"], + "input": { + "actions": ["view"], + "log_id": "log1", + "datatypes": ["access", "user"], + "time_period": { + "from": "2024-11-01T09:00:00Z", + "to": "2024-11-01T10:00:00Z" + }, + "zone_id": "zoneA" + } +} + diff --git a/csit/resources/tests/data/onap.policy.opa.pdp.decision.zone-policy-output.json b/csit/resources/tests/data/onap.policy.opa.pdp.decision.zone-policy-output.json new file mode 100644 index 00000000..1e7228dd --- /dev/null +++ b/csit/resources/tests/data/onap.policy.opa.pdp.decision.zone-policy-output.json @@ -0,0 +1,12 @@ +{ + "output": { + "has_zone_access": [ + { + "access": "granted", + "user": "user1" + } + ] + }, + "policyName": "zoneB", + "statusMessage": "OPA Allowed" +} diff --git a/csit/resources/tests/data/onap.policy.opa.pdp.dyn-data-add-output.json b/csit/resources/tests/data/onap.policy.opa.pdp.dyn-data-add-output.json new file mode 100644 index 00000000..eac292e5 --- /dev/null +++ b/csit/resources/tests/data/onap.policy.opa.pdp.dyn-data-add-output.json @@ -0,0 +1,19 @@ +{ + "data": { + "round": "trail", + "vehicles": [ + { + "owner": "user1", + "status": "available", + "type": "car", + "vehicle_id": "v1" + }, + { + "owner": "user2", + "status": "in use", + "type": "bike", + "vehicle_id": "v2" + } + ] + } +} diff --git a/csit/resources/tests/data/onap.policy.opa.pdp.dyn-data-add.json b/csit/resources/tests/data/onap.policy.opa.pdp.dyn-data-add.json new file mode 100644 index 00000000..04478eec --- /dev/null +++ b/csit/resources/tests/data/onap.policy.opa.pdp.dyn-data-add.json @@ -0,0 +1 @@ +{"onapName": "CDS","onapComponent": "CDS","onapInstance": "CDS","currentDateTime": "2025-01-17T08:26:41.857Z","currentDate": "2025-01-17","currentTime": "08:26:41.857Z","timeZone": "UTC","timeOffset": "+08:45","policyName": "vehicle","data": [{"op": "add","path": "/round","value": "trail"}]} diff --git a/csit/resources/tests/data/onap.policy.opa.pdp.dyn-data-remove.json b/csit/resources/tests/data/onap.policy.opa.pdp.dyn-data-remove.json new file mode 100644 index 00000000..a4cac2f3 --- /dev/null +++ b/csit/resources/tests/data/onap.policy.opa.pdp.dyn-data-remove.json @@ -0,0 +1,17 @@ +{ + "onapName": "CDS", + "onapComponent": "CDS", + "onapInstance": "CDS", + "currentDateTime": "2025-01-17T08:26:41.857Z", + "currentDate": "2025-01-17", + "currentTime": "08:26:41.857Z", + "timeZone": "UTC", + "timeOffset": "+08:45", + "policyName": "vehicle", + "data": [ + { + "op": "remove", + "path": "/round" + } + ] +} diff --git a/csit/resources/tests/data/onap.policy.opa.pdp.dyn-data-replace-output.json b/csit/resources/tests/data/onap.policy.opa.pdp.dyn-data-replace-output.json new file mode 100644 index 00000000..8c00e047 --- /dev/null +++ b/csit/resources/tests/data/onap.policy.opa.pdp.dyn-data-replace-output.json @@ -0,0 +1,19 @@ +{ + "data": { + "round": 578, + "vehicles": [ + { + "owner": "user1", + "status": "available", + "type": "car", + "vehicle_id": "v1" + }, + { + "owner": "user2", + "status": "in use", + "type": "bike", + "vehicle_id": "v2" + } + ] + } +} diff --git a/csit/resources/tests/data/onap.policy.opa.pdp.dyn-data-replace.json b/csit/resources/tests/data/onap.policy.opa.pdp.dyn-data-replace.json new file mode 100644 index 00000000..c45138c0 --- /dev/null +++ b/csit/resources/tests/data/onap.policy.opa.pdp.dyn-data-replace.json @@ -0,0 +1,18 @@ +{ + "onapName": "CDS", + "onapComponent": "CDS", + "onapInstance": "CDS", + "currentDateTime": "2025-01-17T08:26:41.857Z", + "currentDate": "2025-01-17", + "currentTime": "08:26:41.857Z", + "timeZone": "UTC", + "timeOffset": "+08:45", + "policyName": "vehicle", + "data": [ + { + "op": "replace", + "path": "/round", + "value": 578 + } + ] +} diff --git a/csit/resources/tests/data/onap.policy.opa.pdp.policy-abac-create.yaml b/csit/resources/tests/data/onap.policy.opa.pdp.policy-abac-create.yaml new file mode 100644 index 00000000..759fc162 --- /dev/null +++ b/csit/resources/tests/data/onap.policy.opa.pdp.policy-abac-create.yaml @@ -0,0 +1,16 @@ +tosca_definitions_version: tosca_simple_yaml_1_1_0 +topology_template: + policies: + - abac: + type: onap.policies.native.opa + type_version: 1.0.0 + properties: + data: + node.abac: ewogICAgInNlbnNvcl9kYXRhIjogWwogICAgICAgIHsKICAgICAgICAgICAgImlkIjogIjAwMDEiLAogICAgICAgICAgICAibG9jYXRpb24iOiAiU3JpIExhbmthIiwKICAgICAgICAgICAgInRlbXBlcmF0dXJlIjogIjI4IEMiLAogICAgICAgICAgICAicHJlY2lwaXRhdGlvbiI6ICIxMDAwIG1tIiwKICAgICAgICAgICAgIndpbmRzcGVlZCI6ICI1LjUgbS9zIiwKICAgICAgICAgICAgImh1bWlkaXR5IjogIjQwJSIsCiAgICAgICAgICAgICJwYXJ0aWNsZV9kZW5zaXR5IjogIjEuMyBnL2wiLAogICAgICAgICAgICAidGltZXN0YW1wIjogIjIwMjQtMDItMjYiCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICAgICJpZCI6ICIwMDAyIiwKICAgICAgICAgICAgImxvY2F0aW9uIjogIkNvbG9tYm8iLAogICAgICAgICAgICAidGVtcGVyYXR1cmUiOiAiMzAgQyIsCiAgICAgICAgICAgICJwcmVjaXBpdGF0aW9uIjogIjEyMDAgbW0iLAogICAgICAgICAgICAid2luZHNwZWVkIjogIjYuMCBtL3MiLAogICAgICAgICAgICAiaHVtaWRpdHkiOiAiNDUlIiwKICAgICAgICAgICAgInBhcnRpY2xlX2RlbnNpdHkiOiAiMS41IGcvbCIsCiAgICAgICAgICAgICJ0aW1lc3RhbXAiOiAiMjAyNC0wMi0yNiIKICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgICAgImlkIjogIjAwMDMiLAogICAgICAgICAgICAibG9jYXRpb24iOiAiS2FuZHkiLAogICAgICAgICAgICAidGVtcGVyYXR1cmUiOiAiMjUgQyIsCiAgICAgICAgICAgICJwcmVjaXBpdGF0aW9uIjogIjgwMCBtbSIsCiAgICAgICAgICAgICJ3aW5kc3BlZWQiOiAiNC41IG0vcyIsCiAgICAgICAgICAgICJodW1pZGl0eSI6ICI2MCUiLAogICAgICAgICAgICAicGFydGljbGVfZGVuc2l0eSI6ICIxLjEgZy9sIiwKICAgICAgICAgICAgInRpbWVzdGFtcCI6ICIyMDI0LTAyLTI2IgogICAgICAgIH0sCiAgICAgICAgewogICAgICAgICAgICAiaWQiOiAiMDAwNCIsCiAgICAgICAgICAgICJsb2NhdGlvbiI6ICJHYWxsZSIsCiAgICAgICAgICAgICJ0ZW1wZXJhdHVyZSI6ICIzNSBDIiwKICAgICAgICAgICAgInByZWNpcGl0YXRpb24iOiAiNTAwIG1tIiwKICAgICAgICAgICAgIndpbmRzcGVlZCI6ICI3LjIgbS9zIiwKICAgICAgICAgICAgImh1bWlkaXR5IjogIjMwJSIsCiAgICAgICAgICAgICJwYXJ0aWNsZV9kZW5zaXR5IjogIjEuOCBnL2wiLAogICAgICAgICAgICAidGltZXN0YW1wIjogIjIwMjQtMDItMjciCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICAgICJpZCI6ICIwMDA1IiwKICAgICAgICAgICAgImxvY2F0aW9uIjogIkphZmZuYSIsCiAgICAgICAgICAgICJ0ZW1wZXJhdHVyZSI6ICItNSBDIiwKICAgICAgICAgICAgInByZWNpcGl0YXRpb24iOiAiMzAwIG1tIiwKICAgICAgICAgICAgIndpbmRzcGVlZCI6ICIzLjggbS9zIiwKICAgICAgICAgICAgImh1bWlkaXR5IjogIjIwJSIsCiAgICAgICAgICAgICJwYXJ0aWNsZV9kZW5zaXR5IjogIjAuOSBnL2wiLAogICAgICAgICAgICAidGltZXN0YW1wIjogIjIwMjQtMDItMjciCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICAgICJpZCI6ICIwMDA2IiwKICAgICAgICAgICAgImxvY2F0aW9uIjogIlRyaW5jb21hbGVlIiwKICAgICAgICAgICAgInRlbXBlcmF0dXJlIjogIjIwIEMiLAogICAgICAgICAgICAicHJlY2lwaXRhdGlvbiI6ICIxMDAwIG1tIiwKICAgICAgICAgICAgIndpbmRzcGVlZCI6ICI1LjAgbS9zIiwKICAgICAgICAgICAgImh1bWlkaXR5IjogIjU1JSIsCiAgICAgICAgICAgICJwYXJ0aWNsZV9kZW5zaXR5IjogIjEuMiBnL2wiLAogICAgICAgICAgICAidGltZXN0YW1wIjogIjIwMjQtMDItMjgiCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICAgICJpZCI6ICIwMDA3IiwKICAgICAgICAgICAgImxvY2F0aW9uIjogIk51d2FyYSBFbGl5YSIsCiAgICAgICAgICAgICJ0ZW1wZXJhdHVyZSI6ICIyNSBDIiwKICAgICAgICAgICAgInByZWNpcGl0YXRpb24iOiAiNjAwIG1tIiwKICAgICAgICAgICAgIndpbmRzcGVlZCI6ICI0LjAgbS9zIiwKICAgICAgICAgICAgImh1bWlkaXR5IjogIjUwJSIsCiAgICAgICAgICAgICJwYXJ0aWNsZV9kZW5zaXR5IjogIjEuMyBnL2wiLAogICAgICAgICAgICAidGltZXN0YW1wIjogIjIwMjQtMDItMjgiCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICAgICJpZCI6ICIwMDA4IiwKICAgICAgICAgICAgImxvY2F0aW9uIjogIkFudXJhZGhhcHVyYSIsCiAgICAgICAgICAgICJ0ZW1wZXJhdHVyZSI6ICIyOCBDIiwKICAgICAgICAgICAgInByZWNpcGl0YXRpb24iOiAiNzAwIG1tIiwKICAgICAgICAgICAgIndpbmRzcGVlZCI6ICI1LjggbS9zIiwKICAgICAgICAgICAgImh1bWlkaXR5IjogIjQwJSIsCiAgICAgICAgICAgICJwYXJ0aWNsZV9kZW5zaXR5IjogIjEuNCBnL2wiLAogICAgICAgICAgICAidGltZXN0YW1wIjogIjIwMjQtMDItMjkiCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICAgICJpZCI6ICIwMDA5IiwKICAgICAgICAgICAgImxvY2F0aW9uIjogIk1hdGFyYSIsCiAgICAgICAgICAgICJ0ZW1wZXJhdHVyZSI6ICIzMiBDIiwKICAgICAgICAgICAgInByZWNpcGl0YXRpb24iOiAiOTAwIG1tIiwKICAgICAgICAgICAgIndpbmRzcGVlZCI6ICI2LjUgbS9zIiwKICAgICAgICAgICAgImh1bWlkaXR5IjogIjY1JSIsCiAgICAgICAgICAgICJwYXJ0aWNsZV9kZW5zaXR5IjogIjEuNiBnL2wiLAogICAgICAgICAgICAidGltZXN0YW1wIjogIjIwMjQtMDItMjkiCiAgICAgICAgfQogICAgXQp9 + policy: + abac: cGFja2FnZSBhYmFjCgppbXBvcnQgcmVnby52MQoKZGVmYXVsdCBhbGxvdyA6PSBmYWxzZQoKYWxsb3cgaWYgewogdmlld2FibGVfc2Vuc29yX2RhdGEKIGFjdGlvbl9pc19yZWFkCn0KCmFjdGlvbl9pc19yZWFkIGlmICJyZWFkIiBpbiBpbnB1dC5hY3Rpb25zCgp2aWV3YWJsZV9zZW5zb3JfZGF0YSBjb250YWlucyB2aWV3X2RhdGEgaWYgewogc29tZSBzZW5zb3JfZGF0YSBpbiBkYXRhLm5vZGUuYWJhYy5zZW5zb3JfZGF0YQogc2Vuc29yX2RhdGEudGltZXN0YW1wID49IGlucHV0LnRpbWVfcGVyaW9kLmZyb20KIHNlbnNvcl9kYXRhLnRpbWVzdGFtcCA8IGlucHV0LnRpbWVfcGVyaW9kLnRvCgogdmlld19kYXRhIDo9IHtkYXRhdHlwZTogc2Vuc29yX2RhdGFbZGF0YXR5cGVdIHwgZGF0YXR5cGUgaW4gaW5wdXQuZGF0YXR5cGVzfQp9 + name: abac + version: 1.0.7 + metadata: + policy-id: abac + policy-version: 1.0.7 diff --git a/csit/resources/tests/data/onap.policy.opa.pdp.policy-abac-deploy.json b/csit/resources/tests/data/onap.policy.opa.pdp.policy-abac-deploy.json new file mode 100644 index 00000000..15c88261 --- /dev/null +++ b/csit/resources/tests/data/onap.policy.opa.pdp.policy-abac-deploy.json @@ -0,0 +1,9 @@ +{ + "policies": [ + { + "policy-id": "abac", + "policy-version": "1.0.7" + } + ] +} + diff --git a/csit/resources/tests/data/onap.policy.opa.pdp.policy-abac-duplicate-create.yaml b/csit/resources/tests/data/onap.policy.opa.pdp.policy-abac-duplicate-create.yaml new file mode 100644 index 00000000..776b654b --- /dev/null +++ b/csit/resources/tests/data/onap.policy.opa.pdp.policy-abac-duplicate-create.yaml @@ -0,0 +1,16 @@ +tosca_definitions_version: tosca_simple_yaml_1_1_0 +topology_template: + policies: + - abac: + type: onap.policies.native.opa + type_version: 1.0.0 + properties: + data: + node.abac: cGFja2FnZSBvcmdfYWNjZXNzX2NvbnRyb2wucG9saWN5CmltcG9ydCByZWdvLnYxCmltcG9ydCBkYXRhLm9yZ19hY2Nlc3NfY29udHJvbC5yb2xlcwppbXBvcnQgZGF0YS5vcmdfYWNjZXNzX2NvbnRyb2wudXNlcnMKaW1wb3J0IGRhdGEub3JnX2FjY2Vzc19jb250cm9sLmdyb3VwcwppbXBvcnQgZGF0YS5vcmdfYWNjZXNzX2NvbnRyb2wuZG9jdW1lbnRzCmRlZmF1bHQgYWxsb3cgPSBmYWxzZQojIEFsbG93IGFjY2VzcyBpZiB0aGUgdXNlciBoYXMgdGhlIHJlcXVpcmVkIHBlcm1pc3Npb24KYWxsb3cgaWZ7CiAgICBpbnB1dC51c2VyID0gdXNlcgogICAgaW5wdXQuYWN0aW9uID0gYWN0aW9uCiAgICB1c2VyX2hhc19wZXJtaXNzaW9uKHVzZXIsIGFjdGlvbikKfQojIENoZWNrIGlmIHRoZSB1c2VyIGhhcyBwZXJtaXNzaW9uIGJhc2VkIG9uIHRoZWlyIHJvbGUKdXNlcl9oYXNfcGVybWlzc2lvbih1c2VyLCBhY3Rpb24pIGlmewogICAgcm9sZSA6PSB1c2Vyc1t1c2VyXS5yb2xlIAogICAgYWN0aW9uIGluIHJvbGVzW3JvbGVdCn0KIyBBbGxvdyBhY2Nlc3MgZm9yIGEgZ3JvdXAgaWYgYW55IHVzZXIgaW4gdGhlIGdyb3VwIGhhcyB0aGUgcmVxdWlyZWQgcGVybWlzc2lvbgphbGxvd19ncm91cCBpZnsKICAgIGlucHV0Lmdyb3VwID0gZ3JvdXAKICAgIGlucHV0LmFjdGlvbiA9IGFjdGlvbgogICAgdXNlcl9pbl9ncm91cCA6PSBncm91cHNbZ3JvdXBdCiAgICB1c2VyX2hhc19wZXJtaXNzaW9uKHVzZXJfaW5fZ3JvdXAsIGFjdGlvbikgCn0KIyBBbGxvdyBhY2Nlc3MgdG8gZG9jdW1lbnRzIGJhc2VkIG9uIHRoZSB1c2VyJ3MgZG9jdW1lbnQgb3duZXJzaGlwCmFsbG93X2RvY3VtZW50X2FjY2VzcyBpZnsKICAgIGlucHV0LnVzZXIgPSB1c2VyCiAgICBpbnB1dC5kb2N1bWVudF9pZCA9IGRvY3VtZW50X2lkCiAgICBkb2N1bWVudF9vd25lciA6PSBkb2N1bWVudHNbZG9jdW1lbnRfaWRdLm93bmVyCiAgICB1c2VyID09IGRvY3VtZW50X293bmVyCn0= + policy: + abac: cGFja2FnZSBhYmFjCgppbXBvcnQgcmVnby52MQoKZGVmYXVsdCBhbGxvdyA6PSBmYWxzZQoKYWxsb3cgaWYgewogdmlld2FibGVfc2Vuc29yX2RhdGEKIGFjdGlvbl9pc19yZWFkCn0KCmFjdGlvbl9pc19yZWFkIGlmICJyZWFkIiBpbiBpbnB1dC5hY3Rpb25zCgp2aWV3YWJsZV9zZW5zb3JfZGF0YSBjb250YWlucyB2aWV3X2RhdGEgaWYgewogc29tZSBzZW5zb3JfZGF0YSBpbiBkYXRhLmFiYWMuc2Vuc29yX2RhdGEKIHNlbnNvcl9kYXRhLnRpbWVzdGFtcCA+PSBpbnB1dC50aW1lX3BlcmlvZC5mcm9tCiBzZW5zb3JfZGF0YS50aW1lc3RhbXAgPCBpbnB1dC50aW1lX3BlcmlvZC50bwoKIHZpZXdfZGF0YSA6PSB7ZGF0YXR5cGU6IHNlbnNvcl9kYXRhW2RhdGF0eXBlXSB8IGRhdGF0eXBlIGluIGlucHV0LmRhdGF0eXBlc30KfQ== + name: abac + version: 1.0.7 + metadata: + policy-id: abac + policy-version: 1.0.7 diff --git a/csit/resources/tests/data/onap.policy.opa.pdp.policy-abac-output.json b/csit/resources/tests/data/onap.policy.opa.pdp.policy-abac-output.json new file mode 100644 index 00000000..87c968bb --- /dev/null +++ b/csit/resources/tests/data/onap.policy.opa.pdp.policy-abac-output.json @@ -0,0 +1,96 @@ +{ + "data": { + "sensor_data": [ + { + "humidity": "40%", + "id": "0001", + "location": "Sri Lanka", + "particle_density": "1.3 g/l", + "precipitation": "1000 mm", + "temperature": "28 C", + "timestamp": "2024-02-26", + "windspeed": "5.5 m/s" + }, + { + "humidity": "45%", + "id": "0002", + "location": "Colombo", + "particle_density": "1.5 g/l", + "precipitation": "1200 mm", + "temperature": "30 C", + "timestamp": "2024-02-26", + "windspeed": "6.0 m/s" + }, + { + "humidity": "60%", + "id": "0003", + "location": "Kandy", + "particle_density": "1.1 g/l", + "precipitation": "800 mm", + "temperature": "25 C", + "timestamp": "2024-02-26", + "windspeed": "4.5 m/s" + }, + { + "humidity": "30%", + "id": "0004", + "location": "Galle", + "particle_density": "1.8 g/l", + "precipitation": "500 mm", + "temperature": "35 C", + "timestamp": "2024-02-27", + "windspeed": "7.2 m/s" + }, + { + "humidity": "20%", + "id": "0005", + "location": "Jaffna", + "particle_density": "0.9 g/l", + "precipitation": "300 mm", + "temperature": "-5 C", + "timestamp": "2024-02-27", + "windspeed": "3.8 m/s" + }, + { + "humidity": "55%", + "id": "0006", + "location": "Trincomalee", + "particle_density": "1.2 g/l", + "precipitation": "1000 mm", + "temperature": "20 C", + "timestamp": "2024-02-28", + "windspeed": "5.0 m/s" + }, + { + "humidity": "50%", + "id": "0007", + "location": "Nuwara Eliya", + "particle_density": "1.3 g/l", + "precipitation": "600 mm", + "temperature": "25 C", + "timestamp": "2024-02-28", + "windspeed": "4.0 m/s" + }, + { + "humidity": "40%", + "id": "0008", + "location": "Anuradhapura", + "particle_density": "1.4 g/l", + "precipitation": "700 mm", + "temperature": "28 C", + "timestamp": "2024-02-29", + "windspeed": "5.8 m/s" + }, + { + "humidity": "65%", + "id": "0009", + "location": "Matara", + "particle_density": "1.6 g/l", + "precipitation": "900 mm", + "temperature": "32 C", + "timestamp": "2024-02-29", + "windspeed": "6.5 m/s" + } + ] + } +} diff --git a/csit/resources/tests/data/onap.policy.opa.pdp.policy-resource-not-found.json b/csit/resources/tests/data/onap.policy.opa.pdp.policy-resource-not-found.json new file mode 100644 index 00000000..3fd7170e --- /dev/null +++ b/csit/resources/tests/data/onap.policy.opa.pdp.policy-resource-not-found.json @@ -0,0 +1,5 @@ +{ + "errorMessage": "Error in getting data - storage_not_found_error: /node/vehicle: document does not exist", + "policyName": "", + "responseCode": "resource_not_found" +} diff --git a/csit/resources/tests/data/onap.policy.opa.pdp.policy-vehicle-create.yaml b/csit/resources/tests/data/onap.policy.opa.pdp.policy-vehicle-create.yaml new file mode 100644 index 00000000..93af4a93 --- /dev/null +++ b/csit/resources/tests/data/onap.policy.opa.pdp.policy-vehicle-create.yaml @@ -0,0 +1,17 @@ +tosca_definitions_version: tosca_simple_yaml_1_1_0 +topology_template: + policies: + - vehicle: + type: onap.policies.native.opa + type_version: 1.0.0 + properties: + data: + node.vehicle: ewogICJ2ZWhpY2xlcyI6IFsKICAgIHsgInZlaGljbGVfaWQiOiAidjEiLCAib3duZXIiOiAidXNlcjEiLCAidHlwZSI6ICJjYXIiLCAic3RhdHVzIjogImF2YWlsYWJsZSIgfSwKICAgIHsgInZlaGljbGVfaWQiOiAidjIiLCAib3duZXIiOiAidXNlcjIiLCAidHlwZSI6ICJiaWtlIiwgInN0YXR1cyI6ICJpbiB1c2UiIH0KICBdCn0K + policy: + vehicle: cGFja2FnZSB2ZWhpY2xlCgppbXBvcnQgIHJlZ28udjEKCmRlZmF1bHQgYWxsb3cgOj0gZmFsc2UKCmFsbG93IGlmIHsKICAgIHVzZXJfaGFzX3ZlaGljbGVfYWNjZXNzCiAgICBhY3Rpb25faXNfZ3JhbnRlZAp9CgphY3Rpb25faXNfZ3JhbnRlZCBpZiB7CiAgICAidXNlIiBpbiBpbnB1dC5hY3Rpb25zCn0KCnVzZXJfaGFzX3ZlaGljbGVfYWNjZXNzIGNvbnRhaW5zIHZlaGljbGVfZGF0YSBpZiB7CiAgICBzb21lIHZlaGljbGUgaW4gZGF0YS5ub2RlLnZlaGljbGUudmVoaWNsZXMKICAgIHZlaGljbGUudmVoaWNsZV9pZCA9PSBpbnB1dC52ZWhpY2xlX2lkCiAgICB2ZWhpY2xlLm93bmVyID09IGlucHV0LnVzZXIKICAgIHZlaGljbGVfZGF0YSA6PSB7aW5mbzogdmVoaWNsZVtpbmZvXSB8IGluZm8gaW4gaW5wdXQuYXR0cmlidXRlc30KfQo= + name: vehicle + version: 1.0.6 + metadata: + policy-id: vehicle + policy-version: 1.0.6 + diff --git a/csit/resources/tests/data/onap.policy.opa.pdp.policy-vehicle-deploy.json b/csit/resources/tests/data/onap.policy.opa.pdp.policy-vehicle-deploy.json new file mode 100644 index 00000000..ed275a25 --- /dev/null +++ b/csit/resources/tests/data/onap.policy.opa.pdp.policy-vehicle-deploy.json @@ -0,0 +1,9 @@ +{ + "policies": [ + { + "policy-id": "vehicle", + "policy-version": "1.0.6" + } + ] +} + diff --git a/csit/resources/tests/data/onap.policy.opa.pdp.policy-vehicle-output.json b/csit/resources/tests/data/onap.policy.opa.pdp.policy-vehicle-output.json new file mode 100644 index 00000000..09148079 --- /dev/null +++ b/csit/resources/tests/data/onap.policy.opa.pdp.policy-vehicle-output.json @@ -0,0 +1,18 @@ +{ + "data": { + "vehicles": [ + { + "owner": "user1", + "status": "available", + "type": "car", + "vehicle_id": "v1" + }, + { + "owner": "user2", + "status": "in use", + "type": "bike", + "vehicle_id": "v2" + } + ] + } +} diff --git a/csit/resources/tests/data/onap.policy.opa.pdp.policy-zone-create.yaml b/csit/resources/tests/data/onap.policy.opa.pdp.policy-zone-create.yaml new file mode 100644 index 00000000..47179c29 --- /dev/null +++ b/csit/resources/tests/data/onap.policy.opa.pdp.policy-zone-create.yaml @@ -0,0 +1,17 @@ +tosca_definitions_version: tosca_simple_yaml_1_1_0 +topology_template: + policies: + - zoneB: + type: onap.policies.native.opa + type_version: 1.0.0 + properties: + data: + node.zoneB: ewogICJ6b25lIjogewogICAgInpvbmVfYWNjZXNzX2xvZ3MiOiBbCiAgICAgIHsgImxvZ19pZCI6ICJsb2cxIiwgInRpbWVzdGFtcCI6ICIyMDI0LTExLTAxVDA5OjAwOjAwWiIsICJ6b25lX2lkIjogInpvbmVBIiwgImFjY2VzcyI6ICJncmFudGVkIiwgInVzZXIiOiAidXNlcjEiIH0sCiAgICAgIHsgImxvZ19pZCI6ICJsb2cyIiwgInRpbWVzdGFtcCI6ICIyMDI0LTExLTAxVDEwOjMwOjAwWiIsICJ6b25lX2lkIjogInpvbmVBIiwgImFjY2VzcyI6ICJkZW5pZWQiLCAidXNlciI6ICJ1c2VyMiIgfSwKICAgICAgeyAibG9nX2lkIjogImxvZzMiLCAidGltZXN0YW1wIjogIjIwMjQtMTEtMDFUMTE6MDA6MDBaIiwgInpvbmVfaWQiOiAiem9uZUIiLCAiYWNjZXNzIjogImdyYW50ZWQiLCAidXNlciI6ICJ1c2VyMyIgfQogICAgXQogIH0KfQ== + policy: + zoneB: cGFja2FnZSB6b25lQgogCmltcG9ydCByZWdvLnYxCiAKZGVmYXVsdCBhbGxvdyA6PSBmYWxzZQogCmFsbG93IGlmIHsKICAgIGhhc196b25lX2FjY2VzcwogICAgYWN0aW9uX2lzX2xvZ192aWV3Cn0KIAphY3Rpb25faXNfbG9nX3ZpZXcgaWYgewogICAgInZpZXciIGluIGlucHV0LmFjdGlvbnMKfQogCmhhc196b25lX2FjY2VzcyBjb250YWlucyBhY2Nlc3NfZGF0YSBpZiB7CiAgICBzb21lIHpvbmVfZGF0YSBpbiBkYXRhLm5vZGUuem9uZUIuem9uZS56b25lX2FjY2Vzc19sb2dzCiAgICB6b25lX2RhdGEudGltZXN0YW1wID49IGlucHV0LnRpbWVfcGVyaW9kLmZyb20KICAgIHpvbmVfZGF0YS50aW1lc3RhbXAgPCBpbnB1dC50aW1lX3BlcmlvZC50bwogICAgem9uZV9kYXRhLnpvbmVfaWQgPT0gaW5wdXQuem9uZV9pZAogICAgYWNjZXNzX2RhdGEgOj0ge2RhdGF0eXBlOiB6b25lX2RhdGFbZGF0YXR5cGVdIHwgZGF0YXR5cGUgaW4gaW5wdXQuZGF0YXR5cGVzfQp9 + name: zoneB + version: 1.0.6 + metadata: + policy-id: zoneB + policy-version: 1.0.6 + diff --git a/csit/resources/tests/data/onap.policy.opa.pdp.policy-zone-deploy.json b/csit/resources/tests/data/onap.policy.opa.pdp.policy-zone-deploy.json new file mode 100644 index 00000000..ad5b3bd9 --- /dev/null +++ b/csit/resources/tests/data/onap.policy.opa.pdp.policy-zone-deploy.json @@ -0,0 +1,8 @@ +{ + "policies": [ + { + "policy-id": "zoneB", + "policy-version": "1.0.6" + } + ] +} diff --git a/csit/resources/tests/data/onap.policy.opa.pdp.policy-zone-output.json b/csit/resources/tests/data/onap.policy.opa.pdp.policy-zone-output.json new file mode 100644 index 00000000..d1d8e687 --- /dev/null +++ b/csit/resources/tests/data/onap.policy.opa.pdp.policy-zone-output.json @@ -0,0 +1,27 @@ +{ + "data":{ + "zone_access_logs":[ + { + "access":"granted", + "log_id":"log1", + "timestamp":"2024-11-01T09:00:00Z", + "user":"user1", + "zone_id":"zoneA" + }, + { + "access":"denied", + "log_id":"log2", + "timestamp":"2024-11-01T10:30:00Z", + "user":"user2", + "zone_id":"zoneA" + }, + { + "access":"granted", + "log_id":"log3", + "timestamp":"2024-11-01T11:00:00Z", + "user":"user3", + "zone_id":"zoneB" + } + ] + } +} diff --git a/csit/resources/tests/data/onap.policy.policy.opa.pdp.decision.abac-incorrect-policyfilter.json b/csit/resources/tests/data/onap.policy.policy.opa.pdp.decision.abac-incorrect-policyfilter.json new file mode 100644 index 00000000..223dddbb --- /dev/null +++ b/csit/resources/tests/data/onap.policy.policy.opa.pdp.decision.abac-incorrect-policyfilter.json @@ -0,0 +1,16 @@ +{ + "onapName": "CDS", + "onapComponent": "CDS", + "onapInstance": "CDS", + "currentDate": "2024-11-22", + "policyName": "abac", + "policyFilter": ["viewable_sesor_data"], + "input": { + "actions": ["read"], + "datatypes": ["location", "temperature", "precipitation", "windspeed"], + "time_period": { + "from": "2024-02-27", + "to": "2024-02-29" + } + } +} diff --git a/csit/resources/tests/data/onap.policy.policy.opa.pdp.decision.abac-incorrect-policyname.json b/csit/resources/tests/data/onap.policy.policy.opa.pdp.decision.abac-incorrect-policyname.json new file mode 100644 index 00000000..a1628bb9 --- /dev/null +++ b/csit/resources/tests/data/onap.policy.policy.opa.pdp.decision.abac-incorrect-policyname.json @@ -0,0 +1,16 @@ +{ + "onapName": "CDS", + "onapComponent": "CDS", + "onapInstance": "CDS", + "currentDate": "2024-11-22", + "policyName": "abc", + "policyFilter": ["viewable_sensor_data"], + "input": { + "actions": ["read"], + "datatypes": ["location", "temperature", "precipitation", "windspeed"], + "time_period": { + "from": "2024-02-27", + "to": "2024-02-29" + } + } +} diff --git a/csit/resources/tests/data/onap.policy.policy.opa.pdp.decision.abac-output.json b/csit/resources/tests/data/onap.policy.policy.opa.pdp.decision.abac-output.json new file mode 100644 index 00000000..f3bd987d --- /dev/null +++ b/csit/resources/tests/data/onap.policy.policy.opa.pdp.decision.abac-output.json @@ -0,0 +1,32 @@ +{ + "output": { + "viewable_sensor_data": [ + { + "location": "Galle", + "precipitation": "500 mm", + "temperature": "35 C", + "windspeed": "7.2 m/s" + }, + { + "location": "Jaffna", + "precipitation": "300 mm", + "temperature": "-5 C", + "windspeed": "3.8 m/s" + }, + { + "location": "Nuwara Eliya", + "precipitation": "600 mm", + "temperature": "25 C", + "windspeed": "4.0 m/s" + }, + { + "location": "Trincomalee", + "precipitation": "1000 mm", + "temperature": "20 C", + "windspeed": "5.0 m/s" + } + ] + }, + "policyName": "abac", + "statusMessage": "OPA Allowed" +} diff --git a/csit/resources/tests/data/onap.policy.policy.opa.pdp.decision.abac-pemit-policy.json b/csit/resources/tests/data/onap.policy.policy.opa.pdp.decision.abac-pemit-policy.json new file mode 100644 index 00000000..fadf05bb --- /dev/null +++ b/csit/resources/tests/data/onap.policy.policy.opa.pdp.decision.abac-pemit-policy.json @@ -0,0 +1,16 @@ +{ + "onapName": "CDS", + "onapComponent": "CDS", + "onapInstance": "CDS", + "currentDate": "2024-11-22", + "policyName": "abac", + "policyFilter": ["viewable_sensor_data"], + "input": { + "actions": ["read"], + "datatypes": ["location", "temperature", "precipitation", "windspeed"], + "time_period": { + "from": "2024-02-27", + "to": "2024-02-29" + } + } +} diff --git a/csit/resources/tests/data/onap.policy.policy.opa.pdp.decision.vehicle-incorect-policyfilter.json b/csit/resources/tests/data/onap.policy.policy.opa.pdp.decision.vehicle-incorect-policyfilter.json new file mode 100644 index 00000000..290fd60d --- /dev/null +++ b/csit/resources/tests/data/onap.policy.policy.opa.pdp.decision.vehicle-incorect-policyfilter.json @@ -0,0 +1,15 @@ +{ + "onapName": "CDS", + "onapComponent": "CDS", + "onapInstance": "CDS", + "currentDate": "2024-11-22", + "policyName": "vehicle", + "policyFilter": ["user_has_vecle_access"], + "input": { + "actions": ["use"], + "user": "user1", + "vehicle_id": "v1", + "attributes": ["type", "status"] + } +} + diff --git a/csit/resources/tests/data/onap.policy.policy.opa.pdp.decision.vehicle-incorect-policyname.json b/csit/resources/tests/data/onap.policy.policy.opa.pdp.decision.vehicle-incorect-policyname.json new file mode 100644 index 00000000..b5f50b64 --- /dev/null +++ b/csit/resources/tests/data/onap.policy.policy.opa.pdp.decision.vehicle-incorect-policyname.json @@ -0,0 +1,15 @@ +{ + "onapName": "CDS", + "onapComponent": "CDS", + "onapInstance": "CDS", + "currentDate": "2024-11-22", + "policyName": "vehile", + "policyFilter": ["user_has_vehicle_access"], + "input": { + "actions": ["use"], + "user": "user1", + "vehicle_id": "v1", + "attributes": ["type", "status"] + } +} + diff --git a/csit/resources/tests/data/onap.policy.policy.opa.pdp.decision.vehicle_input.json b/csit/resources/tests/data/onap.policy.policy.opa.pdp.decision.vehicle_input.json new file mode 100644 index 00000000..4ea1638a --- /dev/null +++ b/csit/resources/tests/data/onap.policy.policy.opa.pdp.decision.vehicle_input.json @@ -0,0 +1,14 @@ +{ + "onapName": "CDS", + "onapComponent": "CDS", + "onapInstance": "CDS", + "currentDate": "2024-11-22", + "policyName": "vehicle", + "policyFilter": ["user_has_vehicle_access"], + "input": { + "actions": ["use"], + "user": "user1", + "vehicle_id": "v1", + "attributes": ["type", "status"] + } +} diff --git a/csit/resources/tests/data/onap.policy.policy.opa.pdp.decision.vehicle_output.json b/csit/resources/tests/data/onap.policy.policy.opa.pdp.decision.vehicle_output.json new file mode 100644 index 00000000..c6271b21 --- /dev/null +++ b/csit/resources/tests/data/onap.policy.policy.opa.pdp.decision.vehicle_output.json @@ -0,0 +1,12 @@ +{ + "output": { + "user_has_vehicle_access": [ + { + "status": "available", + "type": "car" + } + ] + }, + "policyName": "vehicle", + "statusMessage": "OPA Allowed" +} diff --git a/csit/resources/tests/data/onap.policy.policy.opa.pdp.decision.zone-policy-input.json b/csit/resources/tests/data/onap.policy.policy.opa.pdp.decision.zone-policy-input.json new file mode 100644 index 00000000..0dca9cdc --- /dev/null +++ b/csit/resources/tests/data/onap.policy.policy.opa.pdp.decision.zone-policy-input.json @@ -0,0 +1,18 @@ +{ + "onapName": "CDS", + "onapComponent": "CDS", + "onapInstance": "CDS", + "currentDate": "2024-11-22", + "policyName": "zoneB", + "policyFilter": ["has_zone_access"], + "input": { + "actions": ["view"], + "log_id": "log1", + "datatypes": ["access", "user"], + "time_period": { + "from": "2024-11-01T09:00:00Z", + "to": "2024-11-01T10:00:00Z" + }, + "zone_id": "zoneA" + } +} diff --git a/csit/resources/tests/drools-applications-test.robot b/csit/resources/tests/drools-applications-test.robot index 4ceb288b..61d77591 100644 --- a/csit/resources/tests/drools-applications-test.robot +++ b/csit/resources/tests/drools-applications-test.robot @@ -1,10 +1,10 @@ *** Settings *** -Library Collections -Library String -Library RequestsLibrary -Library OperatingSystem -Library Process -Library json +Library Collections +Library String +Library RequestsLibrary +Library OperatingSystem +Library Process +Library json Resource common-library.robot *** Test Cases *** @@ -29,18 +29,18 @@ Controller AssertTopicsOnKafkaClient [Documentation] Verify that the Policy topics policy-pdp-pap and policy-cl-mgt are available on kafka - GetKafkaTopic policy-pdp-pap - GetKafkaTopic policy-cl-mgt + GetKafkaTopic policy-pdp-pap + GetKafkaTopic policy-cl-mgt CheckTopics - [Documentation] List the topics registered with TopicManager + [Documentation] List the topics registered with TopicManager ${resp}= PerformGetRequestOnDrools /policy/pdp/engine/topics ${DROOLS_IP_2} 200 Should Contain ${resp.text} policy-cl-mgt Should Contain ${resp.text} policy-pdp-pap Should Contain ${resp.text} dcae_topic CheckEngineFeatures - [Documentation] List the features available in the drools engine + [Documentation] List the features available in the drools engine ${resp}= PerformGetRequestOnDrools /policy/pdp/engine/features ${DROOLS_IP_2} 200 Should Contain ${resp.text} "org.onap.policy.drools.lifecycle.LifecycleFeature" Should Contain ${resp.text} "org.onap.policy.drools.apps.controlloop.feature.usecases.UsecasesFeature" @@ -98,7 +98,7 @@ DeployXacmlPolicies [Documentation] Deploys the Policies to Xacml DeployPolicy deploy.xacml.policies.json Sleep 5s - @{otherMessages}= Create List deployed-policies onap.scaleout.tca onap.restart.tca + @{otherMessages}= Create List deployed-policies onap.scaleout.tca onap.restart.tca AssertMessageFromTopic policy-notification onap.vfirewall.tca ${otherMessages} VerifyDeployedXacmlPolicies @@ -106,14 +106,14 @@ VerifyDeployedXacmlPolicies ${resp}= GetDeployedPolicies @{policies}= Create List onap.vfirewall.tca onap.scaleout.tca onap.restart.tca FOR ${policy} IN @{policies} - Should Contain ${resp.text} ${policy} + Should Contain ${resp.text} ${policy} END DeployDroolsPolicies [Documentation] Deploys the Policies to Drools DeployPolicy deploy.drools.policies.json Sleep 5s - @{otherMessages}= Create List deployed-policies operational.scaleout operational.restart + @{otherMessages}= Create List deployed-policies operational.scaleout operational.restart AssertMessageFromTopic policy-notification operational.modifyconfig ${otherMessages} VerifyDeployedDroolsPolicies @@ -121,68 +121,68 @@ VerifyDeployedDroolsPolicies ${resp}= GetDeployedPolicies @{policies}= Create List operational.modifyconfig operational.scaleout operational.restart FOR ${policy} IN @{policies} - Should Contain ${resp.text} ${policy} + Should Contain ${resp.text} ${policy} END VcpeExecute [Documentation] Executes VCPE Policy - OnSet ${CURDIR}/data/drools/vcpeOnset.json + OnSet ${CURDIR}/data/drools/vcpeOnset.json ${policyExecuted}= Set Variable ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e @{otherMessages}= Create List ACTIVE - AssertMessageFromTopic policy-cl-mgt ${policyExecuted} ${otherMessages} + AssertMessageFromTopic policy-cl-mgt ${policyExecuted} ${otherMessages} @{otherMessages}= Create List ${policyExecuted} OPERATION - AssertMessageFromTopic policy-cl-mgt Sending guard query for APPC Restart ${otherMessages} + AssertMessageFromTopic policy-cl-mgt Sending guard query for APPC Restart ${otherMessages} - AssertMessageFromTopic policy-cl-mgt Guard result for APPC Restart is Permit ${otherMessages} + AssertMessageFromTopic policy-cl-mgt Guard result for APPC Restart is Permit ${otherMessages} - AssertMessageFromTopic policy-cl-mgt actor=APPC,operation=Restart ${otherMessages} + AssertMessageFromTopic policy-cl-mgt actor=APPC,operation=Restart ${otherMessages} # @{otherMessages}= Create List OPERATION: SUCCESS actor=APPC,operation=Restart -# AssertMessageFromTopic policy-cl-mgt ${policyExecuted} ${otherMessages} +# AssertMessageFromTopic policy-cl-mgt ${policyExecuted} ${otherMessages} # # @{otherMessages}= Create List FINAL: SUCCESS APPC Restart -# AssertMessageFromTopic policy-cl-mgt ${policyExecuted} ${otherMessages} +# AssertMessageFromTopic policy-cl-mgt ${policyExecuted} ${otherMessages} VdnsExecute [Documentation] Executes VDNS Policy - OnSet ${CURDIR}/data/drools/vdnsOnset.json + OnSet ${CURDIR}/data/drools/vdnsOnset.json ${policyExecuted}= Set Variable ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3 @{otherMessages}= Create List ACTIVE - AssertMessageFromTopic policy-cl-mgt ${policyExecuted} ${otherMessages} + AssertMessageFromTopic policy-cl-mgt ${policyExecuted} ${otherMessages} @{otherMessages}= Create List ${policyExecuted} OPERATION - AssertMessageFromTopic policy-cl-mgt Sending guard query for SO VF Module Create ${otherMessages} + AssertMessageFromTopic policy-cl-mgt Sending guard query for SO VF Module Create ${otherMessages} - AssertMessageFromTopic policy-cl-mgt Guard result for SO VF Module Create is Permit ${otherMessages} + AssertMessageFromTopic policy-cl-mgt Guard result for SO VF Module Create is Permit ${otherMessages} - AssertMessageFromTopic policy-cl-mgt actor=SO,operation=VF Module Create ${otherMessages} + AssertMessageFromTopic policy-cl-mgt actor=SO,operation=VF Module Create ${otherMessages} @{otherMessages}= Create List ${policyExecuted} OPERATION: SUCCESS - AssertMessageFromTopic policy-cl-mgt actor=SO,operation=VF Module Create ${otherMessages} + AssertMessageFromTopic policy-cl-mgt actor=SO,operation=VF Module Create ${otherMessages} @{otherMessages}= Create List ${policyExecuted} FINAL: SUCCESS SO - AssertMessageFromTopic policy-cl-mgt VF Module Create ${otherMessages} + AssertMessageFromTopic policy-cl-mgt VF Module Create ${otherMessages} VfwExecute [Documentation] Executes VFW Policy - OnSet ${CURDIR}/data/drools/vfwOnset.json + OnSet ${CURDIR}/data/drools/vfwOnset.json ${policyExecuted}= Set Variable ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a @{otherMessages}= Create List ACTIVE - AssertMessageFromTopic policy-cl-mgt ${policyExecuted} ${otherMessages} + AssertMessageFromTopic policy-cl-mgt ${policyExecuted} ${otherMessages} @{otherMessages}= Create List ${policyExecuted} OPERATION - AssertMessageFromTopic policy-cl-mgt Sending guard query for APPC ModifyConfig ${otherMessages} + AssertMessageFromTopic policy-cl-mgt Sending guard query for APPC ModifyConfig ${otherMessages} - AssertMessageFromTopic policy-cl-mgt Guard result for APPC ModifyConfig is Permit ${otherMessages} + AssertMessageFromTopic policy-cl-mgt Guard result for APPC ModifyConfig is Permit ${otherMessages} - AssertMessageFromTopic policy-cl-mgt actor=APPC,operation=ModifyConfig ${otherMessages} + AssertMessageFromTopic policy-cl-mgt actor=APPC,operation=ModifyConfig ${otherMessages} # @{otherMessages}= Create List OPERATION: SUCCESS actor=APPC,operation=ModifyConfig -# AssertMessageFromTopic policy-cl-mgt ${policyExecuted} ${otherMessages} +# AssertMessageFromTopic policy-cl-mgt ${policyExecuted} ${otherMessages} # # @{otherMessages}= Create List FINAL: SUCCESS APPC ModifyConfig -# AssertMessageFromTopic policy-cl-mgt ${policyExecuted} ${otherMessages} +# AssertMessageFromTopic policy-cl-mgt ${policyExecuted} ${otherMessages} *** Keywords *** @@ -192,25 +192,25 @@ VerifyController Should Be Equal As Strings ${resp.json()['usecases']} 1 PerformGetRequestOnDrools - [Arguments] ${url} ${domain} ${expectedstatus} - ${auth}= Create List demo@people.osaaf.org demo123456! - Log Creating session http://${domain} - ${session}= Create Session policy http://${domain} auth=${auth} - ${headers}= Create Dictionary Accept=application/json Content-Type=application/json - ${resp}= GET On Session policy ${url} headers=${headers} expected_status=${expectedstatus} - Log Received response from policy ${resp.text} - RETURN ${resp} + [Arguments] ${url} ${domain} ${expectedstatus} + ${auth}= Create List demo@people.osaaf.org demo123456! + Log Creating session http://${domain} + ${session}= Create Session policy http://${domain} auth=${auth} + ${headers}= Create Dictionary Accept=application/json Content-Type=application/json + ${resp}= GET On Session policy ${url} headers=${headers} expected_status=${expectedstatus} + Log Received response from policy ${resp.text} + RETURN ${resp} PerformPostRequest - [Arguments] ${url} ${domain} ${file} ${folder} ${contenttype} ${expectedstatus} - ${auth}= Create List policyadmin zb!XztG34 - ${body}= Get file ${folder}/${file} - Log Creating session http://${domain} - ${session}= Create Session policy http://${domain} auth=${auth} - ${headers}= Create Dictionary Accept=application/${contenttype} Content-Type=application/${contenttype} - ${resp}= POST On Session policy ${url} data=${body} headers=${headers} expected_status=${expectedstatus} - Log Received response from policy ${resp.text} - RETURN ${resp} + [Arguments] ${url} ${domain} ${file} ${folder} ${contenttype} ${expectedstatus} + ${auth}= Create List policyadmin zb!XztG34 + ${body}= Get file ${folder}/${file} + Log Creating session http://${domain} + ${session}= Create Session policy http://${domain} auth=${auth} + ${headers}= Create Dictionary Accept=application/${contenttype} Content-Type=application/${contenttype} + ${resp}= POST On Session policy ${url} data=${body} headers=${headers} expected_status=${expectedstatus} + Log Received response from policy ${resp.text} + RETURN ${resp} OnSet [Arguments] ${file} @@ -220,18 +220,18 @@ OnSet RETURN ${resp.stdout} CreatePolicy - [Arguments] ${policyFile} ${contenttype} + [Arguments] ${policyFile} ${contenttype} PerformPostRequest /policy/api/v1/policies ${POLICY_API_IP} ${policyFile} ${DATA} ${contenttype} 201 DeployPolicy - [Arguments] ${policyName} + [Arguments] ${policyName} PerformPostRequest /policy/pap/v1/pdps/deployments/batch ${POLICY_PAP_IP} ${policyName} ${CURDIR}/data/drools json 202 AssertMessageFromTopic - [Arguments] ${topic} ${topicMessage} ${otherMessages} + [Arguments] ${topic} ${topicMessage} ${otherMessages} ${response}= Wait Until Keyword Succeeds 4 x 10 sec CheckKafkaTopic ${topic} ${topicMessage} FOR ${msg} IN @{otherMessages} - Should Contain ${response} ${msg} + Should Contain ${response} ${msg} END GetDeployedPolicies diff --git a/csit/resources/tests/opa-pdp-common.robot b/csit/resources/tests/opa-pdp-common.robot new file mode 100644 index 00000000..c4eba43a --- /dev/null +++ b/csit/resources/tests/opa-pdp-common.robot @@ -0,0 +1,11 @@ +*** Settings *** + +*** Keywords *** + +Is Variable Dictionary + [Arguments] ${variable} + ${is_dict}= Set Variable False + ${status} ${result}= Run Keyword And Ignore Error Should Contain ${variable} data + Run Keyword If '${status}' + ... Set Variable ${is_dict}= True # It means it's a dictionary. + RETURN ${is_dict} diff --git a/csit/resources/tests/opa-pdp-test.robot b/csit/resources/tests/opa-pdp-test.robot new file mode 100644 index 00000000..98e413c4 --- /dev/null +++ b/csit/resources/tests/opa-pdp-test.robot @@ -0,0 +1,172 @@ +*** Settings *** +Library RequestsLibrary +Library Collections +Library OperatingSystem +Library Process +Library json +Resource common-library.robot +Resource opa-pdp-common.robot +*** Variables *** +${OPA_PDP_HOST} /policy/pdpo/v1/healthcheck +${url} /policy/pdpo/v1/decision +${DATA_URL} /policy/pdpo/v1/data/ + +*** Test Cases *** +Healthcheck + [Documentation] Verify OPA PDP health check + PdpxGetReq ${OPA_PDP_HOST} <Response [200]> + +ValidateDataBeforePolicyDeployment + ValidateGetDynamicData ${DATA_URL} 200 onap.policy.opa.pdp.data-empty.json data + +ValidatesZonePolicy + CreateOpaPolicy onap.policy.opa.pdp.policy-zone-create.yaml zoneB 1.0.3 201 + DeployOpaPolicy onap.policy.opa.pdp.policy-zone-deploy.json zoneB + ${URL_CONTEXT}= Set Variable node/zoneB/zone + ${DYNAMIC_URL}= Set Variable ${DATA_URL}${URL_CONTEXT} + ValidateGetDynamicData ${DYNAMIC_URL} 200 onap.policy.opa.pdp.policy-zone-output.json data + ValidatePolicyResponse onap.policy.policy.opa.pdp.decision.zone-policy-input.json 200 onap.policy.opa.pdp.decision.zone-policy-output.json + ValidateIncorrectPolicyNameResponse onap.policy.opa.pdp.decision.zone-incorrect-policyname.json 400 + ValidateIncorrectPolicyFilterResponse onap.policy.opa.pdp.decision.zone-incorrect-policyfilter.json 200 + UndeployOpaPolicy /policy/pap/v1/pdps/policies/zoneB 202 + UndeployOpaPolicy /policy/pap/v1/pdps/policies/zoneB 400 + +ValidatesVehiclePolicy + CreateOpaPolicy onap.policy.opa.pdp.policy-vehicle-create.yaml vehicle 1.0.3 201 + DeployOpaPolicy onap.policy.opa.pdp.policy-vehicle-deploy.json vehicle + ${URL_CONTEXT}= Set Variable node/vehicle + ${DYNAMIC_URL}= Set Variable ${DATA_URL}${URL_CONTEXT} + ValidateGetDynamicData ${DYNAMIC_URL} 200 onap.policy.opa.pdp.policy-vehicle-output.json data + ValidatePatchDynamicData ${DYNAMIC_URL} onap.policy.opa.pdp.dyn-data-add.json 204 + ValidateGetDynamicData ${DYNAMIC_URL} 200 onap.policy.opa.pdp.dyn-data-add-output.json data + ValidatePatchDynamicData ${DYNAMIC_URL} onap.policy.opa.pdp.dyn-data-replace.json 204 + ValidateGetDynamicData ${DYNAMIC_URL} 200 onap.policy.opa.pdp.dyn-data-replace-output.json data + ValidatePatchDynamicData ${DYNAMIC_URL} onap.policy.opa.pdp.dyn-data-remove.json 204 + ValidateGetDynamicData ${DYNAMIC_URL} 200 onap.policy.opa.pdp.policy-vehicle-output.json data + ValidatePolicyResponse onap.policy.policy.opa.pdp.decision.vehicle_input.json 200 onap.policy.policy.opa.pdp.decision.vehicle_output.json + ValidateIncorrectPolicyNameResponse onap.policy.policy.opa.pdp.decision.vehicle-incorect-policyname.json 400 + ValidateIncorrectPolicyFilterResponse onap.policy.policy.opa.pdp.decision.vehicle-incorect-policyfilter.json 200 + UndeployOpaPolicy /policy/pap/v1/pdps/policies/vehicle 202 + UndeployOpaPolicy /policy/pap/v1/pdps/policies/vehicle 400 + ValidateGetDynamicData ${DYNAMIC_URL} 404 onap.policy.opa.pdp.policy-resource-not-found.json responseCode + ValidatePatchDynamicData ${DYNAMIC_URL} onap.policy.opa.pdp.dyn-data-remove.json 400 + +ValidatesAbacPolicy + CreateOpaPolicy onap.policy.opa.pdp.policy-abac-create.yaml abac 1.0.2 201 + DeployOpaPolicy onap.policy.opa.pdp.policy-abac-deploy.json abac + ${URL_CONTEXT}= Set Variable node/abac + ${DYNAMIC_URL}= Set Variable ${DATA_URL}${URL_CONTEXT} + ValidateGetDynamicData ${DYNAMIC_URL} 200 onap.policy.opa.pdp.policy-abac-output.json data + ValidatePolicyResponse onap.policy.policy.opa.pdp.decision.abac-pemit-policy.json 200 onap.policy.policy.opa.pdp.decision.abac-output.json + ValidateIncorrectPolicyNameResponse onap.policy.policy.opa.pdp.decision.abac-incorrect-policyname.json 400 + ValidateIncorrectPolicyFilterResponse onap.policy.policy.opa.pdp.decision.abac-incorrect-policyfilter.json 200 + CreatePolicyDeployFailure onap.policy.opa.pdp.policy-abac-duplicate-create.yaml 406 NOT_ACCEPTABLE + UndeployOpaPolicy /policy/pap/v1/pdps/policies/abac 202 + UndeployOpaPolicy /policy/pap/v1/pdps/policies/abac 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} + +CreateOpaPolicy + [Documentation] Create a opa policy + [Arguments] ${jsonfile} ${policy_name} ${policy_version} ${expected_status} + ${postjson}= Get file ${CURDIR}/data/${jsonfile} + CreatePolicyWithYaml /policy/api/v1/policytypes/onap.policies.native.opa/versions/1.0.0/policies ${expected_status} ${postjson} + +CreatePolicyDeployFailure + [Documentation] Create a Failure opa policy + [Arguments] ${jsonfile} ${expected_status} ${keyword} + ${postjson}= Get file ${CURDIR}/data/onap.policy.opa.pdp.policy-abac-duplicate-create.yaml + CreateFailurePolicyWithYaml /policy/api/v1/policytypes/onap.policies.native.opa/versions/1.0.0/policies ${expected_status} ${postjson} ${keyword} + +DeployOpaPolicy + [Documentation] Runs Policy PAP to deploy a policy + [Arguments] ${jsonfile} ${policy_name} + ${postjson}= Get file ${CURDIR}/data/${jsonfile} + ${policyadmin}= PolicyAdminAuth + PerformPostRequest ${POLICY_PAP_IP} /policy/pap/v1/pdps/policies 202 ${postjson} null ${policyadmin} + Sleep 20sec + ${result}= CheckKafkaTopic policy-notification ${policy_name} + Should Contain ${result} deployed-policies + +UndeployOpaPolicy + [Documentation] Runs Policy PAP to undeploy a policy + [Arguments] ${url} ${expected_status} + ${policyadmin}= PolicyAdminAuth + PerformDeleteRequest ${POLICY_PAP_IP} ${url} ${expected_status} ${policyadmin} + +ValidatePolicyResponse + [Documentation] Validating the output for the policy + [Arguments] ${jsonfile} ${status} ${jsonfile1} + ${expectedStatus}= Set Variable ${status} + ${postjson}= Get file ${CURDIR}/data/${jsonfile} + ${expected_data}= Get file ${CURDIR}/data/${jsonfile1} + ${hcauth}= PolicyAdminAuth + ${resp}= PerformPostRequest ${POLICY_OPA_IP} ${url} ${expectedStatus} ${postjson} abbrev=true ${hcauth} + ${response_data}= Get From Dictionary ${resp.json()} output + ${expected_value}= Evaluate json.loads('''${expected_data}''') json + ${expected_output}= Get From Dictionary ${expected_value} output + Dictionaries Should Be Equal ${response_data} ${expected_output} + +ValidateGetDynamicData + [Documentation] Validating the output for the policy + [Arguments] ${dyn_url} ${status} ${jsonfile1} ${json_key_name} + ${expectedStatus}= Set Variable ${status} + ${expected_data}= Get file ${CURDIR}/data/${jsonfile1} + ${hcauth}= PolicyAdminAuth + ${resp}= PerformGetRequest ${POLICY_OPA_IP} ${dyn_url} ${expectedStatus} abbrev=true ${hcauth} + ${response_data}= Get From Dictionary ${resp.json()} ${json_key_name} + ${expected_value}= Evaluate json.loads('''${expected_data}''') json + ${expected_output}= Get From Dictionary ${expected_value} ${json_key_name} + ${is_dict}= Is Variable Dictionary ${response_data} + Run Keyword If ${is_dict} + ... Should Be Equal ${response_data} ${expected_output} + Run Keyword If not ${is_dict} + ... Should Be Equal As Strings ${response_data} ${expected_output} + +ValidatePatchDynamicData + [Documentation] Validating the output for the policy + [Arguments] ${dyn_url} ${jsonfile} ${status} + ${expectedStatus}= Set Variable ${status} + ${patchjson}= Get file ${CURDIR}/data/${jsonfile} + ${hcauth}= PolicyAdminAuth + ${resp}= PerformPatchRequest ${POLICY_OPA_IP} ${dyn_url} ${expectedStatus} ${patchjson} abbrev=true ${hcauth} + Should Be Equal As Integers ${resp.status_code} ${expectedStatus} + +ValidatePolicyResponseWithoutFilter + [Documentation] Validating the output for the policy + [Arguments] ${jsonfile} ${status} ${jsonfile1} + ${expectedStatus}= Set Variable ${status} + ${postjson}= Get file ${CURDIR}/data/${jsonfile} + ${expected_data}= Get file ${CURDIR}/data/${jsonfile1} + ${hcauth}= PolicyAdminAuth + ${resp}= PerformPostRequest ${POLICY_OPA_IP} ${url} ${expectedStatus} ${postjson} abbrev=true ${hcauth} + ${response_data}= Get From Dictionary ${resp.json()} responseCode + ${expected_value}= Evaluate json.loads('''${expected_data}''') json + ${expected_output}= Get From Dictionary ${expected_value} responseCode + Should Be Equal As Strings ${response_data} ${expected_output} + +ValidateIncorrectPolicyNameResponse + [Documentation] Validating the incorrect name output for the policy + [Arguments] ${jsonfile} ${status} + ${expectedStatus}= Set Variable ${status} + ${postjson}= Get file ${CURDIR}/data/${jsonfile} + ${hcauth}= PolicyAdminAuth + ${resp}= PerformPostRequest ${POLICY_OPA_IP} ${url} ${expectedStatus} ${postjson} abbrev=true ${hcauth} + ${response_data}= Get From Dictionary ${resp.json()} responseCode + Should Be Equal As Strings ${response_data} bad_request + +ValidateIncorrectPolicyFilterResponse + [Documentation] Validating the incorrect filter output for the policy + [Arguments] ${jsonfile} ${status} + ${expectedStatus}= Set Variable ${status} + ${postjson}= Get file ${CURDIR}/data/${jsonfile} + ${hcauth}= PolicyAdminAuth + ${resp}= PerformPostRequest ${POLICY_OPA_IP} ${url} ${expectedStatus} ${postjson} abbrev=true ${hcauth} + ${response_data}= Get From Dictionary ${resp.json()} output + Should Be Equal As Strings ${response_data} None diff --git a/csit/resources/tests/xacml-pdp-slas.robot b/csit/resources/tests/xacml-pdp-slas.robot index e3d2d910..98a44a80 100644 --- a/csit/resources/tests/xacml-pdp-slas.robot +++ b/csit/resources/tests/xacml-pdp-slas.robot @@ -7,13 +7,6 @@ WaitForPrometheusServer [Documentation] Sleep time to wait for Prometheus server to gather all metrics Sleep 1 minute -ValidatePolicyDecisionsGauge - [Documentation] Validate policy execution gauge using prometheus metrics - ValidatePrometheusMetric pdpx_policy_decisions_created{application="optimization",status="permit", instance="policy-xacml-pdp:6969", job="xacml-pdp-metrics"} 1.8E9 - ValidatePrometheusMetric pdpx_policy_decisions_created{application="guard",status="not_applicable", instance="policy-xacml-pdp:6969", job="xacml-pdp-metrics"} 1.8E9 - ValidatePrometheusMetric pdpx_policy_decisions_created{application="monitoring",status="permit", instance="policy-xacml-pdp:6969", job="xacml-pdp-metrics"} 1.8E9 - ValidatePrometheusMetric pdpx_policy_decisions_created{application="naming",status="permit", instance="policy-xacml-pdp:6969", job="xacml-pdp-metrics"} 1.8E9 - ValidatePolicyDecisionsTotalCounter [Documentation] Validate policy decision counters using prometheus metrics ValidatePrometheusMetric pdpx_policy_decisions_total{application="optimization",status="permit", instance="policy-xacml-pdp:6969", job="xacml-pdp-metrics"} 1 |