blob: 55667c3c123bfad807dd52a3af503d61b22d9dcf [file] [log] [blame]
lukegleesonfa389b52021-07-05 14:59:49 +01001# ============LICENSE_START=======================================================
2# Copyright (c) 2021 Pantheon.tech.
puthuparambil.adityaebfa4072022-02-14 10:56:35 +00003# Modifications Copyright (C) 2022 Bell Canada.
lukegleesonfa389b52021-07-05 14:59:49 +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
Ruslan Kashapovd44fcee2021-02-26 11:42:29 +020020*** Settings ***
21Documentation CPS Core - Data REST API
22
23Library Collections
24Library OperatingSystem
25Library RequestsLibrary
26
tragaitdd6021e2021-10-19 16:46:21 +010027Suite Setup Create Session CPS_URL http://${CPS_CORE_HOST}:${CPS_CORE_PORT}
Ruslan Kashapovd44fcee2021-02-26 11:42:29 +020028
29*** Variables ***
30
Bruno Sakotof05a5032021-03-03 18:27:54 -050031${auth} Basic Y3BzdXNlcjpjcHNyMGNrcyE=
Ruslan Kashapovd44fcee2021-02-26 11:42:29 +020032${basePath} /cps/api
33${dataspaceName} CSIT-Dataspace
34${anchorName} CSIT-Anchor
35
36*** Test Cases ***
37Create Data Node
38 ${uri}= Set Variable ${basePath}/v1/dataspaces/${dataspaceName}/anchors/${anchorName}/nodes
Bruno Sakotof05a5032021-03-03 18:27:54 -050039 ${headers} Create Dictionary Content-Type=application/json Authorization=${auth}
Ruslan Kashapovd44fcee2021-02-26 11:42:29 +020040 ${jsonData}= Get Binary File ${DATADIR}${/}test-tree.json
puthuparambil.adityab46d1372021-07-09 12:51:10 +010041 ${response}= POST On Session CPS_URL ${uri} headers=${headers} data=${jsonData}
Ruslan Kashapovd44fcee2021-02-26 11:42:29 +020042 Should Be Equal As Strings ${response.status_code} 201
43
44Get Data Node by XPath
45 ${uri}= Set Variable ${basePath}/v1/dataspaces/${dataspaceName}/anchors/${anchorName}/node
46 ${params}= Create Dictionary xpath=/test-tree/branch[@name='Left']/nest
Bruno Sakotof05a5032021-03-03 18:27:54 -050047 ${headers}= Create Dictionary Authorization=${auth}
puthuparambil.adityab46d1372021-07-09 12:51:10 +010048 ${response}= Get On Session CPS_URL ${uri} params=${params} headers=${headers} expected_status=200
puthuparambil.adityaebfa4072022-02-14 10:56:35 +000049 ${responseJson}= Set Variable ${response.json()['nest']}
Ruslan Kashapovd44fcee2021-02-26 11:42:29 +020050 Should Be Equal As Strings ${responseJson['name']} Small
51
52