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. |
lukegleeson | fa389b5 | 2021-07-05 14:59:49 +0100 | [diff] [blame] | 4 | # ================================================================================ |
| 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 Kashapov | d44fcee | 2021-02-26 11:42:29 +0200 | [diff] [blame] | 20 | *** Settings *** |
| 21 | Documentation CPS Core - Data REST API |
| 22 | |
| 23 | Library Collections |
| 24 | Library OperatingSystem |
| 25 | Library RequestsLibrary |
| 26 | |
tragait | dd6021e | 2021-10-19 16:46:21 +0100 | [diff] [blame] | 27 | 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] | 28 | |
| 29 | *** Variables *** |
| 30 | |
Bruno Sakoto | f05a503 | 2021-03-03 18:27:54 -0500 | [diff] [blame] | 31 | ${auth} Basic Y3BzdXNlcjpjcHNyMGNrcyE= |
Ruslan Kashapov | d44fcee | 2021-02-26 11:42:29 +0200 | [diff] [blame] | 32 | ${basePath} /cps/api |
| 33 | ${dataspaceName} CSIT-Dataspace |
| 34 | ${anchorName} CSIT-Anchor |
| 35 | |
| 36 | *** Test Cases *** |
| 37 | Create Data Node |
| 38 | ${uri}= Set Variable ${basePath}/v1/dataspaces/${dataspaceName}/anchors/${anchorName}/nodes |
Bruno Sakoto | f05a503 | 2021-03-03 18:27:54 -0500 | [diff] [blame] | 39 | ${headers} Create Dictionary Content-Type=application/json Authorization=${auth} |
Ruslan Kashapov | d44fcee | 2021-02-26 11:42:29 +0200 | [diff] [blame] | 40 | ${jsonData}= Get Binary File ${DATADIR}${/}test-tree.json |
puthuparambil.aditya | b46d137 | 2021-07-09 12:51:10 +0100 | [diff] [blame] | 41 | ${response}= POST On Session CPS_URL ${uri} headers=${headers} data=${jsonData} |
Ruslan Kashapov | d44fcee | 2021-02-26 11:42:29 +0200 | [diff] [blame] | 42 | Should Be Equal As Strings ${response.status_code} 201 |
| 43 | |
| 44 | Get 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 Sakoto | f05a503 | 2021-03-03 18:27:54 -0500 | [diff] [blame] | 47 | ${headers}= Create Dictionary Authorization=${auth} |
puthuparambil.aditya | b46d137 | 2021-07-09 12:51:10 +0100 | [diff] [blame] | 48 | ${response}= Get On Session CPS_URL ${uri} params=${params} headers=${headers} expected_status=200 |
puthuparambil.aditya | ebfa407 | 2022-02-14 10:56:35 +0000 | [diff] [blame] | 49 | ${responseJson}= Set Variable ${response.json()['nest']} |
Ruslan Kashapov | d44fcee | 2021-02-26 11:42:29 +0200 | [diff] [blame] | 50 | Should Be Equal As Strings ${responseJson['name']} Small |
| 51 | |
| 52 | |