JosephKeenan | d181b0e | 2021-10-01 10:40:47 +0100 | [diff] [blame] | 1 | /* |
| 2 | * ============LICENSE_START======================================================= |
sourabh_sourabh | 02d8bf8 | 2024-01-04 17:01:27 +0000 | [diff] [blame] | 3 | * Copyright (C) 2021-2024 Nordix Foundation |
JosephKeenan | d181b0e | 2021-10-01 10:40:47 +0100 | [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 NCMP |
| 23 | |
| 24 | Library Collections |
| 25 | Library OperatingSystem |
| 26 | Library RequestsLibrary |
| 27 | Library BuiltIn |
| 28 | |
tragait | dd6021e | 2021-10-19 16:46:21 +0100 | [diff] [blame] | 29 | Suite Setup Create Session CPS_URL http://${CPS_CORE_HOST}:${CPS_CORE_PORT} |
JosephKeenan | d181b0e | 2021-10-01 10:40:47 +0100 | [diff] [blame] | 30 | |
| 31 | *** Variables *** |
| 32 | |
| 33 | ${auth} Basic Y3BzdXNlcjpjcHNyMGNrcyE= |
| 34 | ${ncmpBasePath} /ncmp |
| 35 | ${netconf} NETCONF |
| 36 | |
| 37 | *** Test Cases *** |
| 38 | |
JosephKeenan | f31c7f8 | 2022-05-24 18:59:25 +0100 | [diff] [blame] | 39 | Get for Passthrough Operational (CF, RO) with fields & topic |
sourabh_sourabh | 02d8bf8 | 2024-01-04 17:01:27 +0000 | [diff] [blame] | 40 | ${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 |
JosephKeenan | f31c7f8 | 2022-05-24 18:59:25 +0100 | [diff] [blame] | 41 | ${headers}= Create Dictionary Authorization=${auth} |
| 42 | ${response}= Get On Session CPS_URL ${uri} headers=${headers} expected_status=200 |
JosephKeenan | f31c7f8 | 2022-05-24 18:59:25 +0100 | [diff] [blame] | 43 | Should Be Equal As Strings ${response.status_code} 200 |
| 44 | |
emaclee | 02a89e4 | 2022-02-03 15:45:26 +0000 | [diff] [blame] | 45 | Get for Passthrough Operational (CF, RO) with fields |
sourabh_sourabh | 02d8bf8 | 2024-01-04 17:01:27 +0000 | [diff] [blame] | 46 | ${uri}= Set Variable ${ncmpBasePath}/v1/ch/ietfYang-PNFDemo/data/ds/ncmp-datastore:passthrough-operational?resourceIdentifier=ietf-netconf-monitoring:netconf-state&options=(fields=schemas/schema) |
JosephKeenan | d181b0e | 2021-10-01 10:40:47 +0100 | [diff] [blame] | 47 | ${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 | |
DylanB95EST | 8c9b4a2 | 2021-11-23 15:16:15 +0000 | [diff] [blame] | 54 | Create to bookstore using passthrough-running |
sourabh_sourabh | 02d8bf8 | 2024-01-04 17:01:27 +0000 | [diff] [blame] | 55 | ${uri}= Set Variable ${ncmpBasePath}/v1/ch/ietfYang-PNFDemo/data/ds/ncmp-datastore:passthrough-running?resourceIdentifier=stores:bookstore |
JosephKeenan | d181b0e | 2021-10-01 10:40:47 +0100 | [diff] [blame] | 56 | ${headers}= Create Dictionary Content-Type=application/json Authorization=${auth} |
JvD_Ericsson | 14d3730 | 2023-12-07 15:33:09 +0000 | [diff] [blame] | 57 | ${jsonData}= Get Binary File ${DATADIR_NCMP}${/}bookstoreCreateExample.json |
JosephKeenan | d181b0e | 2021-10-01 10:40:47 +0100 | [diff] [blame] | 58 | ${response}= POST On Session CPS_URL ${uri} headers=${headers} data=${jsonData} |
| 59 | Should Be Equal As Strings ${response.status_code} 201 |
| 60 | |
DylanB95EST | 8c9b4a2 | 2021-11-23 15:16:15 +0000 | [diff] [blame] | 61 | Verify create to bookstore using passthrough-running |
sourabh_sourabh | 02d8bf8 | 2024-01-04 17:01:27 +0000 | [diff] [blame] | 62 | ${uri}= Set Variable ${ncmpBasePath}/v1/ch/ietfYang-PNFDemo/data/ds/ncmp-datastore:passthrough-running?resourceIdentifier=stores:bookstore |
JosephKeenan | d181b0e | 2021-10-01 10:40:47 +0100 | [diff] [blame] | 63 | ${headers}= Create Dictionary Authorization=${auth} |
| 64 | ${response}= Get On Session CPS_URL ${uri} headers=${headers} |
JosephKeenan | d181b0e | 2021-10-01 10:40:47 +0100 | [diff] [blame] | 65 | Should Be Equal As Strings ${response.status_code} 200 |
JvD_Ericsson | 14d3730 | 2023-12-07 15:33:09 +0000 | [diff] [blame] | 66 | FOR ${item} IN @{response.json()['stores:bookstore']['categories']} |
DylanB95EST | 8c9b4a2 | 2021-11-23 15:16:15 +0000 | [diff] [blame] | 67 | 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" |
JosephKeenan | d181b0e | 2021-10-01 10:40:47 +0100 | [diff] [blame] | 74 | END |
| 75 | END |
DylanB95EST | 8c9b4a2 | 2021-11-23 15:16:15 +0000 | [diff] [blame] | 76 | |
JvD_Ericsson | 0945f43 | 2023-12-19 09:33:37 +0000 | [diff] [blame] | 77 | Update Bookstore using passthrough-running update Category 01 (replace category) |
sourabh_sourabh | 02d8bf8 | 2024-01-04 17:01:27 +0000 | [diff] [blame] | 78 | ${uri}= Set Variable ${ncmpBasePath}/v1/ch/ietfYang-PNFDemo/data/ds/ncmp-datastore:passthrough-running?resourceIdentifier=stores:bookstore/categories=01 |
DylanB95EST | 8c9b4a2 | 2021-11-23 15:16:15 +0000 | [diff] [blame] | 79 | ${headers}= Create Dictionary Content-Type=application/json Authorization=${auth} |
JvD_Ericsson | 14d3730 | 2023-12-07 15:33:09 +0000 | [diff] [blame] | 80 | ${jsonData}= Get Binary File ${DATADIR_NCMP}${/}bookstoreUpdateExample.json |
DylanB95EST | 8c9b4a2 | 2021-11-23 15:16:15 +0000 | [diff] [blame] | 81 | ${response}= PUT On Session CPS_URL ${uri} headers=${headers} data=${jsonData} |
| 82 | Should Be Equal As Strings ${response.status_code} 200 |
| 83 | |
| 84 | Verify update to bookstore using passthrough-running updated category 01 |
sourabh_sourabh | 02d8bf8 | 2024-01-04 17:01:27 +0000 | [diff] [blame] | 85 | ${uri}= Set Variable ${ncmpBasePath}/v1/ch/ietfYang-PNFDemo/data/ds/ncmp-datastore:passthrough-running?resourceIdentifier=stores:bookstore/categories=01 |
DylanB95EST | 8c9b4a2 | 2021-11-23 15:16:15 +0000 | [diff] [blame] | 86 | ${headers}= Create Dictionary Authorization=${auth} |
| 87 | ${response}= Get On Session CPS_URL ${uri} headers=${headers} |
DylanB95EST | 8c9b4a2 | 2021-11-23 15:16:15 +0000 | [diff] [blame] | 88 | Should Be Equal As Strings ${response.status_code} 200 |
JvD_Ericsson | 14d3730 | 2023-12-07 15:33:09 +0000 | [diff] [blame] | 89 | FOR ${item} IN @{response.json()['stores:categories']} |
DylanB95EST | 8c9b4a2 | 2021-11-23 15:16:15 +0000 | [diff] [blame] | 90 | IF "${item['code']}" == "01" |
| 91 | Should Be Equal As Strings "${item['name']}" "Updated Sci-Fi Category Name" |
| 92 | END |
| 93 | END |
| 94 | |
| 95 | Verify update to bookstore using passthrough-running did not remove category 02 |
sourabh_sourabh | 02d8bf8 | 2024-01-04 17:01:27 +0000 | [diff] [blame] | 96 | ${uri}= Set Variable ${ncmpBasePath}/v1/ch/ietfYang-PNFDemo/data/ds/ncmp-datastore:passthrough-running?resourceIdentifier=stores:bookstore |
DylanB95EST | 8c9b4a2 | 2021-11-23 15:16:15 +0000 | [diff] [blame] | 97 | ${headers}= Create Dictionary Authorization=${auth} |
| 98 | ${response}= Get On Session CPS_URL ${uri} headers=${headers} |
DylanB95EST | 8c9b4a2 | 2021-11-23 15:16:15 +0000 | [diff] [blame] | 99 | Should Be Equal As Strings ${response.status_code} 200 |
JvD_Ericsson | 14d3730 | 2023-12-07 15:33:09 +0000 | [diff] [blame] | 100 | ${schemaCount}= Get length ${response.json()['stores:bookstore']['categories']} |
DylanB95EST | f0712fb | 2021-11-30 15:07:35 +0000 | [diff] [blame] | 101 | Should Be Equal As Numbers ${schemaCount} 2 |
| 102 | |
| 103 | Delete Bookstore using passthrough-running for Category 01 |
sourabh_sourabh | 02d8bf8 | 2024-01-04 17:01:27 +0000 | [diff] [blame] | 104 | ${uri}= Set Variable ${ncmpBasePath}/v1/ch/ietfYang-PNFDemo/data/ds/ncmp-datastore:passthrough-running?resourceIdentifier=stores:bookstore/categories=01 |
DylanB95EST | f0712fb | 2021-11-30 15:07:35 +0000 | [diff] [blame] | 105 | ${headers}= Create Dictionary Content-Type=application/json Authorization=${auth} |
ToineSiebelink | 18a79eb | 2021-12-23 12:36:40 +0000 | [diff] [blame] | 106 | ${response}= DELETE On Session CPS_URL ${uri} headers=${headers} |
DylanB95EST | f0712fb | 2021-11-30 15:07:35 +0000 | [diff] [blame] | 107 | Should Be Equal As Strings ${response.status_code} 204 |
| 108 | |
| 109 | Verify delete to bookstore using passthrough-running removed only category 01 |
sourabh_sourabh | 02d8bf8 | 2024-01-04 17:01:27 +0000 | [diff] [blame] | 110 | ${uri}= Set Variable ${ncmpBasePath}/v1/ch/ietfYang-PNFDemo/data/ds/ncmp-datastore:passthrough-running?resourceIdentifier=stores:bookstore |
DylanB95EST | f0712fb | 2021-11-30 15:07:35 +0000 | [diff] [blame] | 111 | ${headers}= Create Dictionary Authorization=${auth} |
| 112 | ${response}= Get On Session CPS_URL ${uri} headers=${headers} |
JvD_Ericsson | 14d3730 | 2023-12-07 15:33:09 +0000 | [diff] [blame] | 113 | ${responseJson}= Set Variable ${response.json()['stores:bookstore']['categories']} |
DylanB95EST | f0712fb | 2021-11-30 15:07:35 +0000 | [diff] [blame] | 114 | Should Be Equal As Strings ${response.status_code} 200 |
JvD_Ericsson | 14d3730 | 2023-12-07 15:33:09 +0000 | [diff] [blame] | 115 | ${schemaCount}= Get length ${responseJson} |
DylanB95EST | f0712fb | 2021-11-30 15:07:35 +0000 | [diff] [blame] | 116 | Should Be Equal As Numbers ${schemaCount} 1 |
JvD_Ericsson | 14d3730 | 2023-12-07 15:33:09 +0000 | [diff] [blame] | 117 | FOR ${item} IN @{responseJson} |
DylanB95EST | f0712fb | 2021-11-30 15:07:35 +0000 | [diff] [blame] | 118 | IF "${item['code']}" == "02" |
| 119 | Should Be Equal As Strings "${item['name']}" "Horror" |
| 120 | END |
| 121 | END |
tragait | ecd7f5e | 2022-01-13 13:15:14 +0000 | [diff] [blame] | 122 | |
| 123 | Patch will add new category with new book and add a new book to an existing category |
sourabh_sourabh | 02d8bf8 | 2024-01-04 17:01:27 +0000 | [diff] [blame] | 124 | ${uri}= Set Variable ${ncmpBasePath}/v1/ch/ietfYang-PNFDemo/data/ds/ncmp-datastore:passthrough-running?resourceIdentifier=stores:bookstore |
tragait | ecd7f5e | 2022-01-13 13:15:14 +0000 | [diff] [blame] | 125 | ${headers}= Create Dictionary Content-Type=application/yang.patch+json Authorization=${auth} |
JvD_Ericsson | 14d3730 | 2023-12-07 15:33:09 +0000 | [diff] [blame] | 126 | ${jsonData}= Get Binary File ${DATADIR_NCMP}${/}bookstorePatchExample.json |
tragait | ecd7f5e | 2022-01-13 13:15:14 +0000 | [diff] [blame] | 127 | ${response}= PATCH On Session CPS_URL ${uri} headers=${headers} data=${jsonData} |
| 128 | Should Be Equal As Strings ${response.status_code} 200 |
sourabh_sourabh | 02d8bf8 | 2024-01-04 17:01:27 +0000 | [diff] [blame] | 129 | ${verifyUri}= Set Variable ${ncmpBasePath}/v1/ch/ietfYang-PNFDemo/data/ds/ncmp-datastore:passthrough-running?resourceIdentifier=stores:bookstore/categories=100 |
tragait | ecd7f5e | 2022-01-13 13:15:14 +0000 | [diff] [blame] | 130 | ${verifyHeaders}= Create Dictionary Authorization=${auth} |
| 131 | ${verifyResponse}= Get On Session CPS_URL ${verifyUri} headers=${verifyHeaders} |
tragait | ecd7f5e | 2022-01-13 13:15:14 +0000 | [diff] [blame] | 132 | Should Be Equal As Strings ${verifyResponse.status_code} 200 |
JvD_Ericsson | 14d3730 | 2023-12-07 15:33:09 +0000 | [diff] [blame] | 133 | FOR ${item} IN @{verifyResponse.json()['stores:categories']} |
tragait | ecd7f5e | 2022-01-13 13:15:14 +0000 | [diff] [blame] | 134 | IF "${item['code']}" == "100" |
| 135 | Should Be Equal As Strings "${item['name']}" "Category100" |
| 136 | END |
| 137 | END |
sourabh_sourabh | 02d8bf8 | 2024-01-04 17:01:27 +0000 | [diff] [blame] | 138 | ${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 |
tragait | ecd7f5e | 2022-01-13 13:15:14 +0000 | [diff] [blame] | 139 | ${verifyResponse}= Get On Session CPS_URL ${verifyUri} headers=${verifyHeaders} |
JosephKeenan | f31c7f8 | 2022-05-24 18:59:25 +0100 | [diff] [blame] | 140 | Should Be Equal As Strings ${verifyResponse.status_code} 200 |