blob: 844b5d53f6873bee89c574d4879f8568aaa9e92f [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.
emaclee75a71632022-05-24 11:51:19 +01004# Modifications Copyright (C) 2022 Nordix Foundation.
lukegleesonfa389b52021-07-05 14:59:49 +01005# ================================================================================
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 Kashapovd44fcee2021-02-26 11:42:29 +020021*** Settings ***
22Documentation CPS Core - Data REST API
23
24Library Collections
25Library OperatingSystem
26Library RequestsLibrary
27
tragaitdd6021e2021-10-19 16:46:21 +010028Suite Setup Create Session CPS_URL http://${CPS_CORE_HOST}:${CPS_CORE_PORT}
Ruslan Kashapovd44fcee2021-02-26 11:42:29 +020029
30*** Variables ***
31
Bruno Sakotof05a5032021-03-03 18:27:54 -050032${auth} Basic Y3BzdXNlcjpjcHNyMGNrcyE=
Ruslan Kashapovd44fcee2021-02-26 11:42:29 +020033${basePath} /cps/api
34${dataspaceName} CSIT-Dataspace
35${anchorName} CSIT-Anchor
36
37*** Test Cases ***
38Create Data Node
39 ${uri}= Set Variable ${basePath}/v1/dataspaces/${dataspaceName}/anchors/${anchorName}/nodes
Bruno Sakotof05a5032021-03-03 18:27:54 -050040 ${headers} Create Dictionary Content-Type=application/json Authorization=${auth}
Ruslan Kashapovd44fcee2021-02-26 11:42:29 +020041 ${jsonData}= Get Binary File ${DATADIR}${/}test-tree.json
puthuparambil.adityab46d1372021-07-09 12:51:10 +010042 ${response}= POST On Session CPS_URL ${uri} headers=${headers} data=${jsonData}
Ruslan Kashapovd44fcee2021-02-26 11:42:29 +020043 Should Be Equal As Strings ${response.status_code} 201
44
45Get Data Node by XPath
46 ${uri}= Set Variable ${basePath}/v1/dataspaces/${dataspaceName}/anchors/${anchorName}/node
47 ${params}= Create Dictionary xpath=/test-tree/branch[@name='Left']/nest
Bruno Sakotof05a5032021-03-03 18:27:54 -050048 ${headers}= Create Dictionary Authorization=${auth}
puthuparambil.adityab46d1372021-07-09 12:51:10 +010049 ${response}= Get On Session CPS_URL ${uri} params=${params} headers=${headers} expected_status=200
emaclee75a71632022-05-24 11:51:19 +010050 ${responseJson}= Set Variable ${response.json()['test-tree:nest']}
Ruslan Kashapovd44fcee2021-02-26 11:42:29 +020051 Should Be Equal As Strings ${responseJson['name']} Small
52
53