Ruslan Kashapov | d44fcee | 2021-02-26 11:42:29 +0200 | [diff] [blame^] | 1 | *** Settings *** |
| 2 | Documentation CPS Core - Admin REST API |
| 3 | |
| 4 | Library Collections |
| 5 | Library OperatingSystem |
| 6 | Library RequestsLibrary |
| 7 | |
| 8 | Suite Setup Create Session CPS_HOST ${CPS_HOST} |
| 9 | |
| 10 | *** Variables *** |
| 11 | |
| 12 | ${basePath} /cps/api |
| 13 | ${dataspaceName} CSIT-Dataspace |
| 14 | ${schemaSetName} CSIT-SchemaSet |
| 15 | ${anchorName} CSIT-Anchor |
| 16 | |
| 17 | *** Test Cases *** |
| 18 | Create Dataspace |
| 19 | ${uri}= Set Variable ${basePath}/v1/dataspaces |
| 20 | ${params}= Create Dictionary dataspace-name=${dataspaceName} |
| 21 | ${response}= POST On Session CPS_HOST ${uri} params=${params} |
| 22 | Should Be Equal As Strings ${response.status_code} 201 |
| 23 | |
| 24 | Create Schema Set from YANG file |
| 25 | ${uri}= Set Variable ${basePath}/v1/dataspaces/${dataspaceName}/schema-sets |
| 26 | ${params}= Create Dictionary schema-set-name=${schemaSetName} |
| 27 | ${fileData}= Get Binary File ${DATADIR}${/}test-tree.yang |
| 28 | ${fileTuple}= Create List test.yang ${fileData} application/zip |
| 29 | &{files}= Create Dictionary file=${fileTuple} |
| 30 | ${response}= POST On Session CPS_HOST ${uri} files=${files} params=${params} |
| 31 | Should Be Equal As Strings ${response.status_code} 201 |
| 32 | |
| 33 | Create Schema Set from ZIP file |
| 34 | ${uri}= Set Variable ${basePath}/v1/dataspaces/${dataspaceName}/schema-sets |
| 35 | ${params}= Create Dictionary schema-set-name=ZipTestSchemaSet |
| 36 | ${fileData}= Get Binary File ${DATADIR}${/}yang-resources.zip |
| 37 | ${fileTuple}= Create List test.zip ${fileData} application/zip |
| 38 | &{files}= Create Dictionary file=${fileTuple} |
| 39 | ${response}= POST On Session CPS_HOST ${uri} files=${files} params=${params} |
| 40 | Should Be Equal As Strings ${response.status_code} 201 |
| 41 | |
| 42 | Get Schema Set info |
| 43 | ${uri}= Set Variable ${basePath}/v1/dataspaces/${dataspaceName}/schema-sets/${schemaSetName} |
| 44 | ${response}= Get On Session CPS_HOST ${uri} expected_status=200 |
| 45 | ${responseJson}= Set Variable ${response.json()} |
| 46 | Should Be Equal As Strings ${responseJson['name']} ${schemaSetName} |
| 47 | Should Be Equal As Strings ${responseJson['dataspaceName']} ${dataspaceName} |
| 48 | |
| 49 | Create Anchor |
| 50 | ${uri}= Set Variable ${basePath}/v1/dataspaces/${dataspaceName}/anchors |
| 51 | ${params}= Create Dictionary schema-set-name=${schemaSetName} anchor-name=${anchorName} |
| 52 | ${response}= POST On Session CPS_HOST ${uri} params=${params} |
| 53 | Should Be Equal As Strings ${response.status_code} 201 |