blob: 810bcf4d126126fa37ddc16248fa7bd48e6f613e [file] [log] [blame]
JvD_Ericsson74d7d7d2023-11-29 10:43:19 +00001/*
2 * ============LICENSE_START=======================================================
JvD_Ericsson820235c2024-01-22 13:32:34 +00003 * Copyright (C) 2023-2024 Nordix Foundation
JvD_Ericsson74d7d7d2023-11-29 10:43:19 +00004 * ================================================================================
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 ***
22Documentation Trust Level Test
23
24Library Collections
25Library OperatingSystem
26Library RequestsLibrary
27Library BuiltIn
28Library ConfluentKafkaLibrary
29
30Suite 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"} ] }]}
halil.cakal9237b072024-09-02 14:30:02 +010039${jsonTrustLevelEventPayload} {"data":{"attributeValueChange":[{"attributeName":"trustLevel","newAttributeValue":"NONE"}]}}
JvD_Ericsson74d7d7d2023-11-29 10:43:19 +000040
41*** Test Cases ***
mpriyank58d37632024-01-12 11:12:13 +000042Register 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
mpriyank58d37632024-01-12 11:12:13 +000047
48Verify notification
49 ${group_id}= Create Consumer auto_offset_reset=earliest
JvD_Ericsson820235c2024-01-22 13:32:34 +000050 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_Ericsson74d7d7d2023-11-29 10:43:19 +000054 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"
halil.cakal9237b072024-09-02 14:30:02 +010058 Compare Header Values ${header_key_value_pair[0]} ${header_key_value_pair[1]} "ce_correlationid" "CH-4"
JvD_Ericsson74d7d7d2023-11-29 10:43:19 +000059 END
halil.cakal80cde8a2024-08-22 16:16:45 +010060 Should Be Equal As Strings ${payload} ${jsonTrustLevelEventPayload}
JvD_Ericsson74d7d7d2023-11-29 10:43:19 +000061 [Teardown] Basic Teardown ${group_id}
62
63Retrieve 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_Ericsson74d7d7d2023-11-29 10:43:19 +000075
76Compare 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
82Basic Teardown
83 [Arguments] ${group_id}
84 Unsubscribe ${group_id}
85 Close Consumer ${group_id}