Fix Cert-service tests
[integration/csit.git] / tests / dmaap-buscontroller / single-mr-suite / test1.robot
1 *** Settings ***
2 Resource          ../../common.robot
3 Library           Collections
4 Library           json
5 Library           OperatingSystem
6 Library           RequestsLibrary
7 Library           HttpLibrary.HTTP
8 Library           String
9
10
11 *** Variables ***
12 ${MESSAGE}    Hello, world!
13 ${DBC_URI}    webapi
14 ${DBC_URL}    http://${DMAAPBC_IP}:8080/${DBC_URI}
15 ${TOPIC_NS}     org.onap.dmaap.onapCSIT
16 ${LOC}          csit-sanfrancisco
17 ${PUB_CORE}     "dcaeLocationName": "${LOC}", "clientRole": "org.onap.dmaap.client.pub", "action": [ "pub", "view" ] 
18 ${SUB_CORE}     "dcaeLocationName": "${LOC}", "clientRole": "org.onap.dmaap.client.sub", "action": [ "sub", "view" ] 
19 ${PUB}          { ${PUB_CORE} }
20 ${SUB}          { ${SUB_CORE} }
21 ${TOPIC1_DATA}  { "topicName":"singleMRtopic1", "topicDescription":"generated for CSIT", "owner":"dgl"}
22 ${TOPIC2_DATA}  { "topicName":"singleMRtopic2", "topicDescription":"generated for CSIT", "owner":"dgl", "clients": [ ${PUB}, ${SUB}] }
23 ${TOPIC3_DATA}  { "topicName":"singleMRtopic3", "topicDescription":"generated for CSIT", "owner":"dgl"}
24 ${PUB3_DATA}    { "fqtn": "${TOPIC_NS}.singleMRtopic3", ${PUB_CORE} }
25 ${SUB3_DATA}    { "fqtn": "${TOPIC_NS}.singleMRtopic3", ${SUB_CORE} }
26
27
28
29 *** Test Cases ***
30 Url Test
31     [Documentation]    Check if www.onap.org can be reached
32     Create Session     sanity          http://onap.readthedocs.io
33     ${resp}=           Get Request   sanity    /  
34     Should Be Equal As Integers  ${resp.status_code}  200
35
36 (DMAAP-293)
37     [Documentation]        Create Topic w no clients POST ${DBC_URI}/topics endpoint
38     ${resp}=         PostCall    ${DBC_URL}/topics    ${TOPIC1_DATA}
39     Should Be Equal As Integers  ${resp.status_code}  201   
40
41 (DMAAP-294)
42     [Documentation]        Create Topic w pub and sub clients POST ${DBC_URI}/topics endpoint
43     ${resp}=         PostCall    ${DBC_URL}/topics    ${TOPIC2_DATA}
44     Should Be Equal As Integers  ${resp.status_code}  201
45
46 (DMAAP-295)
47     [Documentation]        Create Topic w no clients and then add a client POST ${DBC_URI}/mr_clients endpoint
48     ${resp}=         PostCall    ${DBC_URL}/topics    ${TOPIC3_DATA}
49     Should Be Equal As Integers  ${resp.status_code}  201   
50     ${resp}=         PostCall    ${DBC_URL}/mr_clients    ${PUB3_DATA}
51     Should Be Equal As Integers  ${resp.status_code}  200   
52     ${resp}=         PostCall    ${DBC_URL}/mr_clients    ${SUB3_DATA}
53     Should Be Equal As Integers  ${resp.status_code}  200   
54
55 (DMAAP-297)
56     [Documentation]    Query for all topics and specific topic
57     Create Session     get          ${DBC_URL}
58     ${resp}=           Get Request   get    /topics  
59     Should Be Equal As Integers  ${resp.status_code}  200
60     ${resp}=           Get Request   get    /topics/${TOPIC_NS}.singleMRtopic3
61     Should Be Equal As Integers  ${resp.status_code}  200
62
63 (DMAAP-301)
64     [Documentation]    Delete a subscriber
65     Create Session     get          ${DBC_URL}
66     ${resp}=           Get Request   get    /topics/${TOPIC_NS}.singleMRtopic3
67     Should Be Equal As Integers  ${resp.status_code}  200
68         ${tmp}=            Get Json Value      ${resp.text}           /clients/1/mrClientId
69         ${clientId}=       Remove String       ${tmp}         \"
70     ${resp}=           DelCall   ${DBC_URL}/mr_clients/${clientId}
71     Should Be Equal As Integers  ${resp.status_code}  204
72
73 (DMAAP-302)
74     [Documentation]    Delete a publisher
75     Create Session     get          ${DBC_URL}
76     ${resp}=           Get Request   get    /topics/${TOPIC_NS}.singleMRtopic3
77     Should Be Equal As Integers  ${resp.status_code}  200
78         ${tmp}=            Get Json Value      ${resp.text}           /clients/0/mrClientId
79         ${clientId}=       Remove String       ${tmp}         \"
80     ${resp}=           DelCall   ${DBC_URL}/mr_clients/${clientId}
81     Should Be Equal As Integers  ${resp.status_code}  204
82
83
84 *** Keywords ***
85 CheckDir
86     [Arguments]                 ${path}
87     Directory Should Exist      ${path}
88
89 CheckUrl
90     [Arguments]                  ${session}   ${path}     ${expect}
91     ${resp}=                     Get  Request          ${session} ${path} 
92     Should Be Equal As Integers  ${resp.status_code}  ${expect}
93
94 PostCall
95     [Arguments]    ${url}           ${data}
96     ${headers}=    Create Dictionary    Accept=application/json    Content-Type=application/json
97     ${resp}=       Evaluate    requests.post('${url}',data='${data}', headers=${headers},verify=False)    requests
98     [Return]       ${resp}
99
100 DelCall
101     [Arguments]    ${url}           
102     ${headers}=    Create Dictionary    Accept=application/json    Content-Type=application/json
103     ${resp}=       Evaluate    requests.delete('${url}', headers=${headers},verify=False)    requests
104     [Return]       ${resp}