blob: 0df67b62457ec79effcfa94a5236b6090aba8107 [file] [log] [blame]
lukegleesonfa389b52021-07-05 14:59:49 +01001# ============LICENSE_START=======================================================
2# Copyright (c) 2021 Pantheon.tech.
3# ================================================================================
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16# SPDX-License-Identifier: Apache-2.0
17# ============LICENSE_END=========================================================
18
Ruslan Kashapovd44fcee2021-02-26 11:42:29 +020019*** Settings ***
20Documentation CPS Core - Admin REST API
21
22Library Collections
23Library OperatingSystem
24Library RequestsLibrary
25
tragaitdd6021e2021-10-19 16:46:21 +010026Suite Setup Create Session CPS_URL http://${CPS_CORE_HOST}:${CPS_CORE_PORT}
Ruslan Kashapovd44fcee2021-02-26 11:42:29 +020027
28*** Variables ***
29
Bruno Sakotof05a5032021-03-03 18:27:54 -050030${auth} Basic Y3BzdXNlcjpjcHNyMGNrcyE=
Ruslan Kashapovd44fcee2021-02-26 11:42:29 +020031${basePath} /cps/api
32${dataspaceName} CSIT-Dataspace
33${schemaSetName} CSIT-SchemaSet
34${anchorName} CSIT-Anchor
Bruno Sakotoddedbd12021-05-05 08:11:19 -040035${ranDataspaceName} NFP-Operational
Ruslan Kashapovd44fcee2021-02-26 11:42:29 +020036
37*** Test Cases ***
38Create Dataspace
39 ${uri}= Set Variable ${basePath}/v1/dataspaces
40 ${params}= Create Dictionary dataspace-name=${dataspaceName}
Bruno Sakotof05a5032021-03-03 18:27:54 -050041 ${headers}= Create Dictionary Authorization=${auth}
puthuparambil.adityab46d1372021-07-09 12:51:10 +010042 ${response}= POST On Session CPS_URL ${uri} params=${params} headers=${headers}
Ruslan Kashapovd44fcee2021-02-26 11:42:29 +020043 Should Be Equal As Strings ${response.status_code} 201
44
45Create Schema Set from YANG file
46 ${uri}= Set Variable ${basePath}/v1/dataspaces/${dataspaceName}/schema-sets
47 ${params}= Create Dictionary schema-set-name=${schemaSetName}
JvD_Ericsson14d37302023-12-07 15:33:09 +000048 ${fileData}= Get Binary File ${DATADIR_CPS_CORE}${/}test-tree.yang
Ruslan Kashapovd44fcee2021-02-26 11:42:29 +020049 ${fileTuple}= Create List test.yang ${fileData} application/zip
50 &{files}= Create Dictionary file=${fileTuple}
Bruno Sakotof05a5032021-03-03 18:27:54 -050051 ${headers}= Create Dictionary Authorization=${auth}
puthuparambil.adityab46d1372021-07-09 12:51:10 +010052 ${response}= POST On Session CPS_URL ${uri} files=${files} params=${params} headers=${headers}
Ruslan Kashapovd44fcee2021-02-26 11:42:29 +020053 Should Be Equal As Strings ${response.status_code} 201
54
55Create Schema Set from ZIP file
56 ${uri}= Set Variable ${basePath}/v1/dataspaces/${dataspaceName}/schema-sets
57 ${params}= Create Dictionary schema-set-name=ZipTestSchemaSet
JvD_Ericsson14d37302023-12-07 15:33:09 +000058 ${fileData}= Get Binary File ${DATADIR_CPS_CORE}${/}yang-resources.zip
Ruslan Kashapovd44fcee2021-02-26 11:42:29 +020059 ${fileTuple}= Create List test.zip ${fileData} application/zip
60 &{files}= Create Dictionary file=${fileTuple}
Bruno Sakotof05a5032021-03-03 18:27:54 -050061 ${headers}= Create Dictionary Authorization=${auth}
puthuparambil.adityab46d1372021-07-09 12:51:10 +010062 ${response}= POST On Session CPS_URL ${uri} files=${files} params=${params} headers=${headers}
Ruslan Kashapovd44fcee2021-02-26 11:42:29 +020063 Should Be Equal As Strings ${response.status_code} 201
64
65Get Schema Set info
66 ${uri}= Set Variable ${basePath}/v1/dataspaces/${dataspaceName}/schema-sets/${schemaSetName}
Bruno Sakotof05a5032021-03-03 18:27:54 -050067 ${headers}= Create Dictionary Authorization=${auth}
puthuparambil.adityab46d1372021-07-09 12:51:10 +010068 ${response}= Get On Session CPS_URL ${uri} headers=${headers} expected_status=200
Ruslan Kashapovd44fcee2021-02-26 11:42:29 +020069 ${responseJson}= Set Variable ${response.json()}
70 Should Be Equal As Strings ${responseJson['name']} ${schemaSetName}
71 Should Be Equal As Strings ${responseJson['dataspaceName']} ${dataspaceName}
72
73Create Anchor
74 ${uri}= Set Variable ${basePath}/v1/dataspaces/${dataspaceName}/anchors
75 ${params}= Create Dictionary schema-set-name=${schemaSetName} anchor-name=${anchorName}
Bruno Sakotof05a5032021-03-03 18:27:54 -050076 ${headers}= Create Dictionary Authorization=${auth}
puthuparambil.adityab46d1372021-07-09 12:51:10 +010077 ${response}= POST On Session CPS_URL ${uri} params=${params} headers=${headers}
Bruno Sakotoddedbd12021-05-05 08:11:19 -040078 Should Be Equal As Strings ${response.status_code} 201