JvD_Ericsson | 74d7d7d | 2023-11-29 10:43:19 +0000 | [diff] [blame] | 1 | /* |
| 2 | * ============LICENSE_START======================================================= |
JvD_Ericsson | 820235c | 2024-01-22 13:32:34 +0000 | [diff] [blame] | 3 | * Copyright (C) 2023-2024 Nordix Foundation |
JvD_Ericsson | 74d7d7d | 2023-11-29 10:43:19 +0000 | [diff] [blame] | 4 | * ================================================================================ |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | * |
| 17 | * SPDX-License-Identifier: Apache-2.0 |
| 18 | * ============LICENSE_END========================================================= |
| 19 | */ |
| 20 | |
| 21 | *** Settings *** |
| 22 | Documentation Trust Level Test |
| 23 | |
| 24 | Library Collections |
| 25 | Library OperatingSystem |
| 26 | Library RequestsLibrary |
| 27 | Library BuiltIn |
| 28 | Library ConfluentKafkaLibrary |
| 29 | |
| 30 | Suite Setup Create Session CPS_URL http://${CPS_CORE_HOST}:${CPS_CORE_PORT} |
| 31 | |
| 32 | *** Variables *** |
| 33 | ${auth} Basic Y3BzdXNlcjpjcHNyMGNrcyE= |
| 34 | ${ncmpInventoryBasePath} /ncmpInventory |
| 35 | ${ncmpBasePath} /ncmp/v1 |
| 36 | ${dmiUrl} http://${DMI_HOST}:${DMI_PORT} |
| 37 | ${jsonCreateCmHandles} {"dmiPlugin":"${dmiUrl}","dmiDataPlugin":"","dmiModelPlugin":"","createdCmHandles":[{"trustLevel":"COMPLETE","cmHandle":"CH-1"},{"trustLevel":"COMPLETE","cmHandle":"CH-2"},{"cmHandle":"CH-3"},{"trustLevel":"NONE","cmHandle":"CH-4"}]} |
| 38 | ${jsonTrustLevelPropertyQueryParameters} {"cmHandleQueryParameters": [{"conditionName": "cmHandleWithTrustLevel", "conditionParameters": [ {"trustLevel": "COMPLETE"} ] }]} |
Lee Anjella Macabuhay | 48ecbae | 2024-08-21 12:54:31 +0000 | [diff] [blame^] | 39 | ${jsonTrustLevelQueryResponse} {"data":{"attributeValueChange":[{"attributeName":"trustLevel","newAttributeValue":"NONE"}]}} |
JvD_Ericsson | 74d7d7d | 2023-11-29 10:43:19 +0000 | [diff] [blame] | 40 | |
| 41 | *** Test Cases *** |
mpriyank | 58d3763 | 2024-01-12 11:12:13 +0000 | [diff] [blame] | 42 | Register data node |
| 43 | ${uri}= Set Variable ${ncmpInventoryBasePath}/v1/ch |
| 44 | ${headers}= Create Dictionary Content-Type=application/json Authorization=${auth} |
| 45 | ${response}= POST On Session CPS_URL ${uri} headers=${headers} data=${jsonCreateCmHandles} |
| 46 | Should Be Equal As Strings ${response.status_code} 200 |
mpriyank | 58d3763 | 2024-01-12 11:12:13 +0000 | [diff] [blame] | 47 | |
| 48 | Verify notification |
| 49 | ${group_id}= Create Consumer auto_offset_reset=earliest |
JvD_Ericsson | 820235c | 2024-01-22 13:32:34 +0000 | [diff] [blame] | 50 | Subscribe Topic topics=cm-events group_id=${group_id} |
| 51 | ${result}= Poll group_id=${group_id} only_value=False poll_attempts=5 |
| 52 | ${headers} Set Variable ${result[0].headers()} |
| 53 | ${payload} Set Variable ${result[0].value()} |
JvD_Ericsson | 74d7d7d | 2023-11-29 10:43:19 +0000 | [diff] [blame] | 54 | FOR ${header_key_value_pair} IN @{headers} |
| 55 | Compare Header Values ${header_key_value_pair[0]} ${header_key_value_pair[1]} "ce_specversion" "1.0" |
| 56 | Compare Header Values ${header_key_value_pair[0]} ${header_key_value_pair[1]} "ce_source" "NCMP" |
| 57 | Compare Header Values ${header_key_value_pair[0]} ${header_key_value_pair[1]} "ce_type" "org.onap.cps.ncmp.events.avc.ncmp_to_client.AvcEvent" |
Lee Anjella Macabuhay | 48ecbae | 2024-08-21 12:54:31 +0000 | [diff] [blame^] | 58 | Compare Header Values ${header_key_value_pair[0]} ${header_key_value_pair[1]} "ce_correlationid" "CH-4" |
JvD_Ericsson | 74d7d7d | 2023-11-29 10:43:19 +0000 | [diff] [blame] | 59 | END |
Lee Anjella Macabuhay | 48ecbae | 2024-08-21 12:54:31 +0000 | [diff] [blame^] | 60 | Should Be Equal As Strings ${payload} ${jsonTrustLevelQueryResponse} |
JvD_Ericsson | 74d7d7d | 2023-11-29 10:43:19 +0000 | [diff] [blame] | 61 | [Teardown] Basic Teardown ${group_id} |
| 62 | |
| 63 | Retrieve CM Handle ids where query parameters Match (trust level query) |
| 64 | ${uri}= Set Variable ${ncmpBasePath}/ch/id-searches |
| 65 | ${headers}= Create Dictionary Content-Type=application/json Authorization=${auth} |
| 66 | ${response}= POST On Session CPS_URL ${uri} headers=${headers} data=${jsonTrustLevelPropertyQueryParameters} |
| 67 | ${responseJson}= Set Variable ${response.json()} |
| 68 | Should Be Equal As Strings ${response.status_code} 200 |
| 69 | Should Contain ${responseJson} CH-1 |
| 70 | Should Contain ${responseJson} CH-2 |
| 71 | Should Contain ${responseJson} CH-3 |
| 72 | Should Not Contain ${responseJson} CH-4 |
| 73 | |
| 74 | *** Keywords *** |
JvD_Ericsson | 74d7d7d | 2023-11-29 10:43:19 +0000 | [diff] [blame] | 75 | |
| 76 | Compare Header Values |
| 77 | [Arguments] ${header_key} ${header_value} ${header_to_check} ${expected_header_value} |
| 78 | IF "${header_key}" == ${header_to_check} |
| 79 | Should Be Equal As Strings "${header_value}" ${expected_header_value} |
| 80 | END |
| 81 | |
| 82 | Basic Teardown |
| 83 | [Arguments] ${group_id} |
| 84 | Unsubscribe ${group_id} |
| 85 | Close Consumer ${group_id} |