aboutsummaryrefslogtreecommitdiffstats
path: root/robot/resources/cds_interface.robot
blob: 358ef64ee5323ab91b5eb5664561bb56c071e155 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
*** Settings ***
Documentation     The main interface for interacting with CDS. It handles low level stuff like managing the http request library and CDS required fields
Library               RequestsLibrary
Resource          global_properties.robot
Library           SSHLibrary
Library           OperatingSystem
Library           String

*** Variables ***
${CDS_HEALTH_CHECK_PATH}    /api/v1/execution-service/health-check
${CDS_HEALTH_ENDPOINT}     ${GLOBAL_CCSDK_CDS_SERVER_PROTOCOL}://${GLOBAL_INJECTED_CCSDK_CDS_BLUEPRINT_PROCESSOR_IP_ADDR}:${GLOBAL_CCSDK_CDS_HEALTH_SERVER_PORT}
${CDS_CREATE_DATA_DICTIONARY_ENDPOINT}               /api/v1/dictionary/definition
${CDS_RETRIEVE_DATA_DICTIONARY_ENDPOINT}             /api/v1/dictionary/search/
${CDS_BOOTSTRAP_ENDPOINT}                            /api/v1/blueprint-model/bootstrap
${CDS_CBA_ENRICH_ENDPOINT}                           /api/v1/blueprint-model/enrich
${CDS_CBA_PUBLISH_ENDPOINT}                          /api/v1/blueprint-model/publish
${CDS_CBA_PROCESS_API_ENDPOINT}                      /api/v1/execution-service/process
${CDS_CBA_DELETE_ENDPOINT}                           /api/v1/blueprint-model/
${CREATE_DICTIONARY_JSON_PATH}                       ${CURDIR}${/}../assets/cds/create_dictionary.json
${BOOTSTRAP_JSON_PATH}                               ${CURDIR}${/}../assets/cds/bootstrap.json
${CDS_CBA_PROCESS_FILE_PATH}                         ${CURDIR}${/}../assets/cds/cba_process.json
${CDS_CBA_PACKAGE_FILE}                              ${CURDIR}${/}../assets/cds/cba.zip
${CDS_CBA_ENRICHED_FILE}                             ${CURDIR}${/}../assets/cds/enriched-cba.zip
${CDS_CD_TAG}                    restmock
${SUCCESS}                                           EVENT_COMPONENT_EXECUTED

*** Keywords ***
Run CDS Basic Health Check
    [Documentation]    Runs a CDS health check
    ${auth}=  Create List  ${GLOBAL_CCSDK_CDS_USERNAME}    ${GLOBAL_CCSDK_CDS_PASSWORD}
    ${session}=    Create Session       cds    ${CDS_HEALTH_ENDPOINT}    auth=${auth}
    ${headers}=  Create Dictionary    Accept=application/json    Content-Type=application/json
    ${resp}=    Get Request     cds    ${CDS_HEALTH_CHECK_PATH}     headers=${headers}
    Log    Received response code from cds ${resp}
    Log    Received content from cds ${resp.content}
    Should Be Equal As Strings  ${resp.status_code}     200

Run CDS Create Data Dictionary Health Check
    [Documentation]    Runs CDS Create Data Dictionary Health Check
    ${auth}=  Create List  ${GLOBAL_CCSDK_CDS_USERNAME}    ${GLOBAL_CCSDK_CDS_PASSWORD}
    ${session}=    Create Session       cds    ${CDS_HEALTH_ENDPOINT}    auth=${auth}
    ${headers}=  Create Dictionary    Accept=application/json    Content-Type=application/json
    ${json}      Get Binary File          ${CREATE_DICTIONARY_JSON_PATH}
    ${resp}=    Post Request     cds    ${CDS_CREATE_DATA_DICTIONARY_ENDPOINT}        data=${json}              headers=${headers}
    Log    Received response code from cds ${resp}
    Log    Received content from cds ${resp.content}
    Should Be Equal As Strings  ${resp.status_code}     200

Run CDS GET Data Dictionary Health Check
    [Documentation]    Runs CDS Get Data Dictionary health check
    ${auth}=  Create List  ${GLOBAL_CCSDK_CDS_USERNAME}    ${GLOBAL_CCSDK_CDS_PASSWORD}
    ${session}=    Create Session       cds    ${CDS_HEALTH_ENDPOINT}    auth=${auth}
    ${headers}=  Create Dictionary    Accept=application/json    Content-Type=application/json
    ${resp}=    Get Request     cds    ${CDS_RETRIEVE_DATA_DICTIONARY_ENDPOINT}${CDS_CD_TAG}     headers=${headers}
    Log    Received response code from cds ${resp}
    Log    Received content from cds ${resp.content}
    Should Be Equal As Strings  ${resp.status_code}     200
    ${res_body}=   Convert to string     ${resp.content}
    Should Contain   ${res_body}     ${CDS_CD_TAG}

Run CDS Bootstrap Health Check
    [Documentation]    Run CDS Bootstrap Health Check
    ${auth}=  Create List  ${GLOBAL_CCSDK_CDS_USERNAME}    ${GLOBAL_CCSDK_CDS_PASSWORD}
    ${session}=    Create Session       cds    ${CDS_HEALTH_ENDPOINT}    auth=${auth}
    ${headers}=  Create Dictionary    Accept=application/json    Content-Type=application/json
    ${json_bootstrap}      Get Binary File          ${BOOTSTRAP_JSON_PATH}
    ${resp}=    Post Request     cds    ${CDS_BOOTSTRAP_ENDPOINT}        data=${json_bootstrap}              headers=${headers}
    Log    Received response code from cds ${resp}
    Log    Received content from cds ${resp.content}
    Should Be Equal As Strings  ${resp.status_code}     200

Run CDS Enrich CBA Health Check
    [Documentation]    Runs a successful CDS enrich Post requests
    ${auth}=  Create List  ${GLOBAL_CCSDK_CDS_USERNAME}         ${GLOBAL_CCSDK_CDS_PASSWORD}
    ${session}=    Create Session       cds    ${CDS_HEALTH_ENDPOINT}    auth=${auth}
    ${data}=  Get Binary File   ${CDS_CBA_PACKAGE_FILE}
    ${file}=  Create Dictionary file=${data}
    ${resp}=    Post Request   cds    ${CDS_CBA_ENRICH_ENDPOINT}    files=${file}
    Should Be Equal As Strings  ${resp.status_code}    200
    Create File    ${CDS_CBA_ENRICHED_FILE}    ${resp.text}    encoding=ISO-8859-1

Run CDS Publish CBA Health Check
    [Documentation]    Runs a publish CDS upload enriched Post requests API
    ${auth}=  Create List  ${GLOBAL_CCSDK_CDS_USERNAME}       ${GLOBAL_CCSDK_CDS_PASSWORD}
    ${session}=    Create Session       cds    ${CDS_HEALTH_ENDPOINT}    auth=${auth}
    ${data}=  Get Binary File    ${CDS_CBA_ENRICHED_FILE}
    ${file}=  Create Dictionary file=${data}
    ${resp}=    Post Request   cds    ${CDS_CBA_PUBLISH_ENDPOINT}    files=${file}
    Should Be Equal As Strings  ${resp.status_code}    200      And    ${resp.json()['blueprintModel']['id']}!= ${NONE}
    Set Global Variable    ${blueprintModel}    ${resp.json()['blueprintModel']['id']}

Run CDS Process CBA Health Check
    [Documentation]    Runs a process CDS enriched CBA Post requests API
    ${auth}=  Create List  ${GLOBAL_CCSDK_CDS_USERNAME}       ${GLOBAL_CCSDK_CDS_PASSWORD}
    ${session}=    Create Session       cds    ${CDS_HEALTH_ENDPOINT}    auth=${auth}
    ${headers}=  Create Dictionary    Accept=*/*        Content-Type=application/json
    ${file}    Get Binary File                  ${CDS_CBA_PROCESS_FILE_PATH}
    ${resp}=    Post Request   cds    ${CDS_CBA_PROCESS_API_ENDPOINT}    data=${file}   headers=${headers}
    Should Be Equal As Strings  ${resp.status_code}    200
    Should Be Equal As Strings  ${resp.json()['status']['eventType']}   ${SUCCESS}

Run CDS Delete CBA Health Check
    [Documentation]    Runs a CDS Delete CBA Delete requests API
    ${auth}=  Create List  ${GLOBAL_CCSDK_CDS_USERNAME}       ${GLOBAL_CCSDK_CDS_PASSWORD}
    ${session}=    Create Session       cds    ${CDS_HEALTH_ENDPOINT}    auth=${auth}
    ${headers}=    Create Dictionary    Accept=*/*    Content-Type=application/json
    ${resp}=    Delete Request   cds    ${CDS_CBA_DELETE_ENDPOINT}${blueprintModel}       headers=${headers}
    Should Be Equal As Strings  ${resp.status_code}    200