blob: a16446a743154824b034d5e77eeeefc20c993743 [file] [log] [blame]
JosephKeenandeac4772022-03-28 12:26:07 +01001/*
2 * ============LICENSE_START=======================================================
sourabh_sourabh02d8bf82024-01-04 17:01:27 +00003 * Copyright (C) 2022-2024 Nordix Foundation
JosephKeenandeac4772022-03-28 12:26:07 +01004 * ================================================================================
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 Public Properties Query Test
23
24Library Collections
25Library OperatingSystem
26Library RequestsLibrary
27Library BuiltIn
28
29Suite Setup Create Session CPS_URL http://${CPS_CORE_HOST}:${CPS_CORE_PORT}
30
31*** Variables ***
32
33${auth} Basic Y3BzdXNlcjpjcHNyMGNrcyE=
34${ncmpBasePath} /ncmp/v1
kissande9ed5812022-05-12 15:59:18 +020035${jsonModuleAndPropertyQueryParameters} {"cmHandleQueryParameters": [{"conditionName": "hasAllModules", "conditionParameters": [ {"moduleName": "iana-crypt-hash"} ]}, {"conditionName": "hasAllProperties", "conditionParameters": [ {"Contact": "newemailforstore@bookstore.com"} ]}]}
36${jsonEmptyQueryParameters} {}
37${jsonMissingPropertyQueryParameters} {"cmHandleQueryParameters": [{"conditionName": "hasAllProperties", "conditionParameters": [{"" : "doesnt matter"}]}]}
JosephKeenandeac4772022-03-28 12:26:07 +010038
39*** Test Cases ***
kissande9ed5812022-05-12 15:59:18 +020040Retrieve CM Handle ids where query parameters Match (module and property query)
41 ${uri}= Set Variable ${ncmpBasePath}/ch/id-searches
JosephKeenandeac4772022-03-28 12:26:07 +010042 ${headers}= Create Dictionary Content-Type=application/json Authorization=${auth}
kissande9ed5812022-05-12 15:59:18 +020043 ${response}= POST On Session CPS_URL ${uri} headers=${headers} data=${jsonModuleAndPropertyQueryParameters}
kissande9ed5812022-05-12 15:59:18 +020044 Should Be Equal As Strings ${response.status_code} 200
sourabh_sourabh02d8bf82024-01-04 17:01:27 +000045 Should Contain ${response.json()} ietfYang-PNFDemo
kissande9ed5812022-05-12 15:59:18 +020046
47Retrieve CM Handle ids where query parameters Match (empty query)
48 ${uri}= Set Variable ${ncmpBasePath}/ch/id-searches
49 ${headers}= Create Dictionary Content-Type=application/json Authorization=${auth}
50 ${response}= POST On Session CPS_URL ${uri} headers=${headers} data=${jsonEmptyQueryParameters}
JosephKeenandeac4772022-03-28 12:26:07 +010051 Should Be Equal As Strings ${response.status_code} 200
sourabh_sourabh02d8bf82024-01-04 17:01:27 +000052 Should Contain ${response.json()} ietfYang-PNFDemo
JosephKeenandeac4772022-03-28 12:26:07 +010053
54Throw 400 when Structure of Request is Incorrect
kissande9ed5812022-05-12 15:59:18 +020055 ${uri}= Set Variable ${ncmpBasePath}/ch/id-searches
JosephKeenandeac4772022-03-28 12:26:07 +010056 ${headers}= Create Dictionary Content-Type=application/json Authorization=${auth}
57 ${response}= POST On Session CPS_URL ${uri} headers=${headers} data=${jsonMissingPropertyQueryParameters} expected_status=400
58 Should Be Equal As Strings ${response} <Response [400]>