1 # ============LICENSE_START=======================================================
2 # Copyright (c) 2021 Pantheon.tech.
3 # Modifications Copyright (C) 2022 Bell Canada.
4 # Modifications Copyright (C) 2022-2023 Nordix Foundation.
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
10 # http://www.apache.org/licenses/LICENSE-2.0
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.
18 # SPDX-License-Identifier: Apache-2.0
19 # ============LICENSE_END=========================================================
22 Documentation CPS Core - Data REST API
25 Library OperatingSystem
26 Library RequestsLibrary
28 Suite Setup Create Session CPS_URL http://${CPS_CORE_HOST}:${CPS_CORE_PORT}
32 ${auth} Basic Y3BzdXNlcjpjcHNyMGNrcyE=
34 ${dataspaceName} CSIT-Dataspace
35 ${anchorName} CSIT-Anchor
39 ${uri}= Set Variable ${basePath}/v1/dataspaces/${dataspaceName}/anchors/${anchorName}/nodes
40 ${headers} Create Dictionary Content-Type=application/json Authorization=${auth}
41 ${jsonData}= Get Binary File ${DATADIR_CPS_CORE}${/}test-tree.json
42 ${response}= POST On Session CPS_URL ${uri} headers=${headers} data=${jsonData}
43 Should Be Equal As Strings ${response.status_code} 201
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}
49 ${jsonData}= Get Binary File ${DATADIR_CPS_CORE}${/}testTreePatchExample.json
50 ${response}= PATCH On Session CPS_URL ${uri} params=${params} headers=${headers} data=${jsonData}
51 Should Be Equal As Strings ${response.status_code} 200
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
60 ${length_birds}= Get Length ${responseJson['birds']}
61 Should Be Equal As Integers ${length_birds} 3
62 Should Be Equal As Strings ${responseJson['birds']} ['Eagle', 'Falcon', 'Pigeon']
64 Get Data Node by XPath
65 ${uri}= Set Variable ${basePath}/v1/dataspaces/${dataspaceName}/anchors/${anchorName}/node
66 ${params}= Create Dictionary xpath=/test-tree/branch[@name='LEFT/left']/nest
67 ${headers}= Create Dictionary Authorization=${auth}
68 ${response}= Get On Session CPS_URL ${uri} params=${params} headers=${headers} expected_status=200
69 Should Be Equal As Strings ${response.json()['tree:nest']['name']} SMALL/small