blob: 5a16a343e9c0abefe20306d3f7556d1e77a1e16e [file] [log] [blame]
JvD_Ericsson74d7d7d2023-11-29 10:43:19 +00001/*
2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2023 Nordix Foundation
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 ***
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"} ] }]}
39${jsonTrustLevelQueryResponse} {"data":{"attributeValueChange":[{"attributeName":"trustLevel","newAttributeValue":"NONE"}]}}
40${partitionId} ${0}
41
42*** Test Cases ***
43Register data node and verify notification
44 ${group_id}= Create Consumer
45 ${topic_partition}= Create Topic Partition cm-events ${partitionId}
46 ${offset}= Get Watermark Offsets ${group_id} ${topic_partition}
47 ${tp}= Create Topic Partition cm-events ${partitionId} ${offset[1]}
48 Assign To Topic Partition ${group_id} ${tp}
49 Sleep 5sec
50 Register Data Nodes
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()}
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"
58 Compare Header Values ${header_key_value_pair[0]} ${header_key_value_pair[1]} "ce_correlationid" "CH-4"
59 END
60 Should Be Equal As Strings ${payload} ${jsonTrustLevelQueryResponse}
61 [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 ***
75Register Data Nodes
76 ${uri}= Set Variable ${ncmpInventoryBasePath}/v1/ch
77 ${headers}= Create Dictionary Content-Type=application/json Authorization=${auth}
78 ${response}= POST On Session CPS_URL ${uri} headers=${headers} data=${jsonCreateCmHandles}
79 Should Be Equal As Strings ${response.status_code} 200
80
81Compare Header Values
82 [Arguments] ${header_key} ${header_value} ${header_to_check} ${expected_header_value}
83 IF "${header_key}" == ${header_to_check}
84 Should Be Equal As Strings "${header_value}" ${expected_header_value}
85 END
86
87Basic Teardown
88 [Arguments] ${group_id}
89 Unsubscribe ${group_id}
90 Close Consumer ${group_id}