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. |
emaclee | 75a7163 | 2022-05-24 11:51:19 +0100 | [diff] [blame] | 4 | # Modifications Copyright (C) 2022 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} |
Ruslan Kashapov | d44fcee | 2021-02-26 11:42:29 +0200 | [diff] [blame] | 41 | ${jsonData}= Get Binary File ${DATADIR}${/}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 | |
| 45 | Get Data Node by XPath |
| 46 | ${uri}= Set Variable ${basePath}/v1/dataspaces/${dataspaceName}/anchors/${anchorName}/node |
emaclee | 5452b5e | 2022-12-21 09:29:24 +0000 | [diff] [blame] | 47 | ${params}= Create Dictionary xpath=/test-tree/branch[@name='LEFT/left']/nest |
Bruno Sakoto | f05a503 | 2021-03-03 18:27:54 -0500 | [diff] [blame] | 48 | ${headers}= Create Dictionary Authorization=${auth} |
puthuparambil.aditya | b46d137 | 2021-07-09 12:51:10 +0100 | [diff] [blame] | 49 | ${response}= Get On Session CPS_URL ${uri} params=${params} headers=${headers} expected_status=200 |
ToineSiebelink | 14e5bf9 | 2022-10-27 17:29:04 +0100 | [diff] [blame] | 50 | ${responseJson}= Set Variable ${response.json()['tree:nest']} |
emaclee | 5452b5e | 2022-12-21 09:29:24 +0000 | [diff] [blame] | 51 | Should Be Equal As Strings ${responseJson['name']} SMALL/small |
Ruslan Kashapov | d44fcee | 2021-02-26 11:42:29 +0200 | [diff] [blame] | 52 | |
| 53 | |