blob: 02689f336265b14bc8e038854127334a91cebbc8 [file] [log] [blame]
JosephKeenand181b0e2021-10-01 10:40:47 +01001/*
2 * ============LICENSE_START=======================================================
sourabh_sourabh02d8bf82024-01-04 17:01:27 +00003 * Copyright (C) 2021-2024 Nordix Foundation
JosephKeenand181b0e2021-10-01 10:40:47 +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 NCMP
23
24Library Collections
25Library OperatingSystem
26Library RequestsLibrary
27Library BuiltIn
28
tragaitdd6021e2021-10-19 16:46:21 +010029Suite Setup Create Session CPS_URL http://${CPS_CORE_HOST}:${CPS_CORE_PORT}
JosephKeenand181b0e2021-10-01 10:40:47 +010030
31*** Variables ***
32
33${auth} Basic Y3BzdXNlcjpjcHNyMGNrcyE=
34${ncmpBasePath} /ncmp
35${netconf} NETCONF
36
37*** Test Cases ***
38
JosephKeenanf31c7f82022-05-24 18:59:25 +010039Get for Passthrough Operational (CF, RO) with fields & topic
sourabh_sourabh02d8bf82024-01-04 17:01:27 +000040 ${uri}= Set Variable ${ncmpBasePath}/v1/ch/ietfYang-PNFDemo/data/ds/ncmp-datastore:passthrough-operational?resourceIdentifier=ietf-netconf-monitoring:netconf-state&options=(fields=schemas/schema)&topic=test-topic
JosephKeenanf31c7f82022-05-24 18:59:25 +010041 ${headers}= Create Dictionary Authorization=${auth}
42 ${response}= Get On Session CPS_URL ${uri} headers=${headers} expected_status=200
JosephKeenanf31c7f82022-05-24 18:59:25 +010043 Should Be Equal As Strings ${response.status_code} 200
44
emaclee02a89e42022-02-03 15:45:26 +000045Get for Passthrough Operational (CF, RO) with fields
sourabh_sourabh02d8bf82024-01-04 17:01:27 +000046 ${uri}= Set Variable ${ncmpBasePath}/v1/ch/ietfYang-PNFDemo/data/ds/ncmp-datastore:passthrough-operational?resourceIdentifier=ietf-netconf-monitoring:netconf-state&options=(fields=schemas/schema)
JosephKeenand181b0e2021-10-01 10:40:47 +010047 ${headers}= Create Dictionary Authorization=${auth}
48 ${response}= Get On Session CPS_URL ${uri} headers=${headers} expected_status=200
49 ${responseJson}= Set Variable ${response.json()}
50 ${schemaCount}= Get length ${responseJson['ietf-netconf-monitoring:netconf-state']['schemas']}
51 Should Be True ${schemaCount} >0
52 Should Contain ${responseJson['ietf-netconf-monitoring:netconf-state']['schemas']['schema'][0]['location']} ${netconf}
53
DylanB95EST8c9b4a22021-11-23 15:16:15 +000054Create to bookstore using passthrough-running
sourabh_sourabh02d8bf82024-01-04 17:01:27 +000055 ${uri}= Set Variable ${ncmpBasePath}/v1/ch/ietfYang-PNFDemo/data/ds/ncmp-datastore:passthrough-running?resourceIdentifier=stores:bookstore
JosephKeenand181b0e2021-10-01 10:40:47 +010056 ${headers}= Create Dictionary Content-Type=application/json Authorization=${auth}
JvD_Ericsson14d37302023-12-07 15:33:09 +000057 ${jsonData}= Get Binary File ${DATADIR_NCMP}${/}bookstoreCreateExample.json
JosephKeenand181b0e2021-10-01 10:40:47 +010058 ${response}= POST On Session CPS_URL ${uri} headers=${headers} data=${jsonData}
59 Should Be Equal As Strings ${response.status_code} 201
60
DylanB95EST8c9b4a22021-11-23 15:16:15 +000061Verify create to bookstore using passthrough-running
sourabh_sourabh02d8bf82024-01-04 17:01:27 +000062 ${uri}= Set Variable ${ncmpBasePath}/v1/ch/ietfYang-PNFDemo/data/ds/ncmp-datastore:passthrough-running?resourceIdentifier=stores:bookstore
JosephKeenand181b0e2021-10-01 10:40:47 +010063 ${headers}= Create Dictionary Authorization=${auth}
64 ${response}= Get On Session CPS_URL ${uri} headers=${headers}
JosephKeenand181b0e2021-10-01 10:40:47 +010065 Should Be Equal As Strings ${response.status_code} 200
JvD_Ericsson14d37302023-12-07 15:33:09 +000066 FOR ${item} IN @{response.json()['stores:bookstore']['categories']}
DylanB95EST8c9b4a22021-11-23 15:16:15 +000067 IF "${item['code']}" == "01"
68 Should Be Equal As Strings "${item['name']}" "Sci-Fi"
69 Should Be Equal As Strings "${item['books']}[0][title]" "A Sci-Fi book"
70 END
71 IF "${item['code']}" == "02"
72 Should Be Equal As Strings "${item['name']}" "Horror"
73 Should Be Equal As Strings "${item['books']}[0][title]" "A Horror book"
JosephKeenand181b0e2021-10-01 10:40:47 +010074 END
75 END
DylanB95EST8c9b4a22021-11-23 15:16:15 +000076
JvD_Ericsson0945f432023-12-19 09:33:37 +000077Update Bookstore using passthrough-running update Category 01 (replace category)
sourabh_sourabh02d8bf82024-01-04 17:01:27 +000078 ${uri}= Set Variable ${ncmpBasePath}/v1/ch/ietfYang-PNFDemo/data/ds/ncmp-datastore:passthrough-running?resourceIdentifier=stores:bookstore/categories=01
DylanB95EST8c9b4a22021-11-23 15:16:15 +000079 ${headers}= Create Dictionary Content-Type=application/json Authorization=${auth}
JvD_Ericsson14d37302023-12-07 15:33:09 +000080 ${jsonData}= Get Binary File ${DATADIR_NCMP}${/}bookstoreUpdateExample.json
DylanB95EST8c9b4a22021-11-23 15:16:15 +000081 ${response}= PUT On Session CPS_URL ${uri} headers=${headers} data=${jsonData}
82 Should Be Equal As Strings ${response.status_code} 200
83
84Verify update to bookstore using passthrough-running updated category 01
sourabh_sourabh02d8bf82024-01-04 17:01:27 +000085 ${uri}= Set Variable ${ncmpBasePath}/v1/ch/ietfYang-PNFDemo/data/ds/ncmp-datastore:passthrough-running?resourceIdentifier=stores:bookstore/categories=01
DylanB95EST8c9b4a22021-11-23 15:16:15 +000086 ${headers}= Create Dictionary Authorization=${auth}
87 ${response}= Get On Session CPS_URL ${uri} headers=${headers}
DylanB95EST8c9b4a22021-11-23 15:16:15 +000088 Should Be Equal As Strings ${response.status_code} 200
JvD_Ericsson14d37302023-12-07 15:33:09 +000089 FOR ${item} IN @{response.json()['stores:categories']}
DylanB95EST8c9b4a22021-11-23 15:16:15 +000090 IF "${item['code']}" == "01"
91 Should Be Equal As Strings "${item['name']}" "Updated Sci-Fi Category Name"
92 END
93 END
94
95Verify update to bookstore using passthrough-running did not remove category 02
sourabh_sourabh02d8bf82024-01-04 17:01:27 +000096 ${uri}= Set Variable ${ncmpBasePath}/v1/ch/ietfYang-PNFDemo/data/ds/ncmp-datastore:passthrough-running?resourceIdentifier=stores:bookstore
DylanB95EST8c9b4a22021-11-23 15:16:15 +000097 ${headers}= Create Dictionary Authorization=${auth}
98 ${response}= Get On Session CPS_URL ${uri} headers=${headers}
DylanB95EST8c9b4a22021-11-23 15:16:15 +000099 Should Be Equal As Strings ${response.status_code} 200
JvD_Ericsson14d37302023-12-07 15:33:09 +0000100 ${schemaCount}= Get length ${response.json()['stores:bookstore']['categories']}
DylanB95ESTf0712fb2021-11-30 15:07:35 +0000101 Should Be Equal As Numbers ${schemaCount} 2
102
103Delete Bookstore using passthrough-running for Category 01
sourabh_sourabh02d8bf82024-01-04 17:01:27 +0000104 ${uri}= Set Variable ${ncmpBasePath}/v1/ch/ietfYang-PNFDemo/data/ds/ncmp-datastore:passthrough-running?resourceIdentifier=stores:bookstore/categories=01
DylanB95ESTf0712fb2021-11-30 15:07:35 +0000105 ${headers}= Create Dictionary Content-Type=application/json Authorization=${auth}
ToineSiebelink18a79eb2021-12-23 12:36:40 +0000106 ${response}= DELETE On Session CPS_URL ${uri} headers=${headers}
DylanB95ESTf0712fb2021-11-30 15:07:35 +0000107 Should Be Equal As Strings ${response.status_code} 204
108
109Verify delete to bookstore using passthrough-running removed only category 01
sourabh_sourabh02d8bf82024-01-04 17:01:27 +0000110 ${uri}= Set Variable ${ncmpBasePath}/v1/ch/ietfYang-PNFDemo/data/ds/ncmp-datastore:passthrough-running?resourceIdentifier=stores:bookstore
DylanB95ESTf0712fb2021-11-30 15:07:35 +0000111 ${headers}= Create Dictionary Authorization=${auth}
112 ${response}= Get On Session CPS_URL ${uri} headers=${headers}
JvD_Ericsson14d37302023-12-07 15:33:09 +0000113 ${responseJson}= Set Variable ${response.json()['stores:bookstore']['categories']}
DylanB95ESTf0712fb2021-11-30 15:07:35 +0000114 Should Be Equal As Strings ${response.status_code} 200
JvD_Ericsson14d37302023-12-07 15:33:09 +0000115 ${schemaCount}= Get length ${responseJson}
DylanB95ESTf0712fb2021-11-30 15:07:35 +0000116 Should Be Equal As Numbers ${schemaCount} 1
JvD_Ericsson14d37302023-12-07 15:33:09 +0000117 FOR ${item} IN @{responseJson}
DylanB95ESTf0712fb2021-11-30 15:07:35 +0000118 IF "${item['code']}" == "02"
119 Should Be Equal As Strings "${item['name']}" "Horror"
120 END
121 END
tragaitecd7f5e2022-01-13 13:15:14 +0000122
123Patch will add new category with new book and add a new book to an existing category
sourabh_sourabh02d8bf82024-01-04 17:01:27 +0000124 ${uri}= Set Variable ${ncmpBasePath}/v1/ch/ietfYang-PNFDemo/data/ds/ncmp-datastore:passthrough-running?resourceIdentifier=stores:bookstore
tragaitecd7f5e2022-01-13 13:15:14 +0000125 ${headers}= Create Dictionary Content-Type=application/yang.patch+json Authorization=${auth}
JvD_Ericsson14d37302023-12-07 15:33:09 +0000126 ${jsonData}= Get Binary File ${DATADIR_NCMP}${/}bookstorePatchExample.json
tragaitecd7f5e2022-01-13 13:15:14 +0000127 ${response}= PATCH On Session CPS_URL ${uri} headers=${headers} data=${jsonData}
128 Should Be Equal As Strings ${response.status_code} 200
sourabh_sourabh02d8bf82024-01-04 17:01:27 +0000129 ${verifyUri}= Set Variable ${ncmpBasePath}/v1/ch/ietfYang-PNFDemo/data/ds/ncmp-datastore:passthrough-running?resourceIdentifier=stores:bookstore/categories=100
tragaitecd7f5e2022-01-13 13:15:14 +0000130 ${verifyHeaders}= Create Dictionary Authorization=${auth}
131 ${verifyResponse}= Get On Session CPS_URL ${verifyUri} headers=${verifyHeaders}
tragaitecd7f5e2022-01-13 13:15:14 +0000132 Should Be Equal As Strings ${verifyResponse.status_code} 200
JvD_Ericsson14d37302023-12-07 15:33:09 +0000133 FOR ${item} IN @{verifyResponse.json()['stores:categories']}
tragaitecd7f5e2022-01-13 13:15:14 +0000134 IF "${item['code']}" == "100"
135 Should Be Equal As Strings "${item['name']}" "Category100"
136 END
137 END
sourabh_sourabh02d8bf82024-01-04 17:01:27 +0000138 ${verifyUri}= Set Variable ${ncmpBasePath}/v1/ch/ietfYang-PNFDemo/data/ds/ncmp-datastore:passthrough-running?resourceIdentifier=stores:bookstore/categories=02/books=A%20New%20book%20in%20existing%20category
tragaitecd7f5e2022-01-13 13:15:14 +0000139 ${verifyResponse}= Get On Session CPS_URL ${verifyUri} headers=${verifyHeaders}
JosephKeenanf31c7f82022-05-24 18:59:25 +0100140 Should Be Equal As Strings ${verifyResponse.status_code} 200