lukegleeson | fa389b5 | 2021-07-05 14:59:49 +0100 | [diff] [blame] | 1 | # ============LICENSE_START======================================================= |
| 2 | # Copyright (c) 2021 Pantheon.tech. |
puthuparambil.aditya | ebfa407 | 2022-02-14 10:56:35 +0000 | [diff] [blame] | 3 | # Modifications Copyright (C) 2022 Bell Canada. |
halil.cakal | c4a583a | 2023-04-06 12:03:35 +0100 | [diff] [blame] | 4 | # Modifications Copyright (C) 2022-2023 Nordix Foundation. |
lukegleeson | fa389b5 | 2021-07-05 14:59:49 +0100 | [diff] [blame] | 5 | # ================================================================================ |
| 6 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | # you may not use this file except in compliance with the License. |
| 8 | # You may obtain a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, software |
| 13 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | # See the License for the specific language governing permissions and |
| 16 | # limitations under the License. |
| 17 | # |
| 18 | # SPDX-License-Identifier: Apache-2.0 |
| 19 | # ============LICENSE_END========================================================= |
| 20 | |
Ruslan Kashapov | d44fcee | 2021-02-26 11:42:29 +0200 | [diff] [blame] | 21 | *** Settings *** |
| 22 | Documentation CPS Core - Data REST API |
| 23 | |
| 24 | Library Collections |
| 25 | Library OperatingSystem |
| 26 | Library RequestsLibrary |
| 27 | |
tragait | dd6021e | 2021-10-19 16:46:21 +0100 | [diff] [blame] | 28 | Suite Setup Create Session CPS_URL http://${CPS_CORE_HOST}:${CPS_CORE_PORT} |
Ruslan Kashapov | d44fcee | 2021-02-26 11:42:29 +0200 | [diff] [blame] | 29 | |
| 30 | *** Variables *** |
| 31 | |
Bruno Sakoto | f05a503 | 2021-03-03 18:27:54 -0500 | [diff] [blame] | 32 | ${auth} Basic Y3BzdXNlcjpjcHNyMGNrcyE= |
Ruslan Kashapov | d44fcee | 2021-02-26 11:42:29 +0200 | [diff] [blame] | 33 | ${basePath} /cps/api |
| 34 | ${dataspaceName} CSIT-Dataspace |
| 35 | ${anchorName} CSIT-Anchor |
| 36 | |
| 37 | *** Test Cases *** |
| 38 | Create Data Node |
| 39 | ${uri}= Set Variable ${basePath}/v1/dataspaces/${dataspaceName}/anchors/${anchorName}/nodes |
Bruno Sakoto | f05a503 | 2021-03-03 18:27:54 -0500 | [diff] [blame] | 40 | ${headers} Create Dictionary Content-Type=application/json Authorization=${auth} |
JvD_Ericsson | 14d3730 | 2023-12-07 15:33:09 +0000 | [diff] [blame] | 41 | ${jsonData}= Get Binary File ${DATADIR_CPS_CORE}${/}test-tree.json |
puthuparambil.aditya | b46d137 | 2021-07-09 12:51:10 +0100 | [diff] [blame] | 42 | ${response}= POST On Session CPS_URL ${uri} headers=${headers} data=${jsonData} |
Ruslan Kashapov | d44fcee | 2021-02-26 11:42:29 +0200 | [diff] [blame] | 43 | Should Be Equal As Strings ${response.status_code} 201 |
| 44 | |
halil.cakal | c4a583a | 2023-04-06 12:03:35 +0100 | [diff] [blame] | 45 | Patch Data Node |
| 46 | ${uri}= Set Variable ${basePath}/v1/dataspaces/${dataspaceName}/anchors/${anchorName}/nodes |
| 47 | ${params}= Create Dictionary xpath=/test-tree/branch[@name='Right'] |
| 48 | ${headers} Create Dictionary Content-Type=application/json Authorization=${auth} |
JvD_Ericsson | 14d3730 | 2023-12-07 15:33:09 +0000 | [diff] [blame] | 49 | ${jsonData}= Get Binary File ${DATADIR_CPS_CORE}${/}testTreePatchExample.json |
halil.cakal | c4a583a | 2023-04-06 12:03:35 +0100 | [diff] [blame] | 50 | ${response}= PATCH On Session CPS_URL ${uri} params=${params} headers=${headers} data=${jsonData} |
| 51 | Should Be Equal As Strings ${response.status_code} 200 |
| 52 | |
| 53 | Get Updated Data Node by XPath |
| 54 | ${uri}= Set Variable ${basePath}/v1/dataspaces/${dataspaceName}/anchors/${anchorName}/node |
| 55 | ${params}= Create Dictionary xpath=/test-tree/branch[@name='Right']/nest |
| 56 | ${headers}= Create Dictionary Authorization=${auth} |
| 57 | ${response}= Get On Session CPS_URL ${uri} params=${params} headers=${headers} expected_status=200 |
| 58 | ${responseJson}= Set Variable ${response.json()['tree:nest']} |
| 59 | Should Be Equal As Strings ${responseJson['name']} Bigger |
halil.cakal | 6dae131 | 2023-12-05 17:09:42 +0000 | [diff] [blame] | 60 | ${length_birds}= Get Length ${responseJson['birds']} |
| 61 | Should Be Equal As Integers ${length_birds} 3 |
danielhanrahan | e2d8837 | 2024-02-08 15:04:05 +0000 | [diff] [blame] | 62 | Should Be Equal As Strings ${responseJson['birds']} ['Eagle', 'Falcon', 'Pigeon'] |
halil.cakal | c4a583a | 2023-04-06 12:03:35 +0100 | [diff] [blame] | 63 | |
Ruslan Kashapov | d44fcee | 2021-02-26 11:42:29 +0200 | [diff] [blame] | 64 | Get Data Node by XPath |
| 65 | ${uri}= Set Variable ${basePath}/v1/dataspaces/${dataspaceName}/anchors/${anchorName}/node |
emaclee | 5452b5e | 2022-12-21 09:29:24 +0000 | [diff] [blame] | 66 | ${params}= Create Dictionary xpath=/test-tree/branch[@name='LEFT/left']/nest |
Bruno Sakoto | f05a503 | 2021-03-03 18:27:54 -0500 | [diff] [blame] | 67 | ${headers}= Create Dictionary Authorization=${auth} |
puthuparambil.aditya | b46d137 | 2021-07-09 12:51:10 +0100 | [diff] [blame] | 68 | ${response}= Get On Session CPS_URL ${uri} params=${params} headers=${headers} expected_status=200 |
JvD_Ericsson | 14d3730 | 2023-12-07 15:33:09 +0000 | [diff] [blame] | 69 | Should Be Equal As Strings ${response.json()['tree:nest']['name']} SMALL/small |
Ruslan Kashapov | d44fcee | 2021-02-26 11:42:29 +0200 | [diff] [blame] | 70 | |
| 71 | |