[DMAAP-BC] Consolidate bus controller repos
[dmaap/buscontroller.git] / csit / tests / with_mr / test1.robot
1 *** Settings ***
2 Library           Collections
3 Library           OperatingSystem
4 Library           RequestsLibrary
5
6
7 *** Variables ***
8 ${DBC_URI}      webapi
9 ${DBC_URL}      http://${DMAAP_BC_IP}:8080/${DBC_URI}
10 ${TOPIC_NS}     org.onap.dmaap.onapCSIT
11 ${LOC}          csit-sanfrancisco
12 ${PUB_CORE}     "dcaeLocationName": "${LOC}", "clientRole": "org.onap.dmaap.client.pub", "action": [ "pub", "view" ] 
13 ${SUB_CORE}     "dcaeLocationName": "${LOC}", "clientRole": "org.onap.dmaap.client.sub", "action": [ "sub", "view" ] 
14 ${PUB}          { ${PUB_CORE} }
15 ${SUB}          { ${SUB_CORE} }
16 ${TOPIC1_DATA}  { "topicName":"singleMRtopic1", "topicDescription":"generated for CSIT", "owner":"dgl"}
17 ${TOPIC2_DATA}  { "topicName":"singleMRtopic2", "topicDescription":"generated for CSIT", "owner":"dgl", "clients": [ ${PUB}, ${SUB}] }
18 ${TOPIC3_DATA}  { "topicName":"singleMRtopic3", "topicDescription":"generated for CSIT", "owner":"dgl"}
19 ${PUB3_DATA}    { "fqtn": "${TOPIC_NS}.singleMRtopic3", ${PUB_CORE} }
20 ${SUB3_DATA}    { "fqtn": "${TOPIC_NS}.singleMRtopic3", ${SUB_CORE} }
21
22
23 *** Test Cases ***
24 (DMAAP-293)
25     [Documentation]        Create Topic w no clients POST ${DBC_URI}/topics endpoint
26     ${resp}=         PostCall    ${DBC_URL}/topics    ${TOPIC1_DATA}
27     Should Be Equal As Integers  ${resp.status_code}  201   
28
29 (DMAAP-294)
30     [Documentation]        Create Topic w pub and sub clients POST ${DBC_URI}/topics endpoint
31     ${resp}=         PostCall    ${DBC_URL}/topics    ${TOPIC2_DATA}
32     Should Be Equal As Integers  ${resp.status_code}  201
33
34 (DMAAP-295)
35     [Documentation]        Create Topic w no clients and then add a client POST ${DBC_URI}/mr_clients endpoint
36     ${resp}=         PostCall    ${DBC_URL}/topics    ${TOPIC3_DATA}
37     Should Be Equal As Integers  ${resp.status_code}  201   
38     ${resp}=         PostCall    ${DBC_URL}/mr_clients    ${PUB3_DATA}
39     Should Be Equal As Integers  ${resp.status_code}  200   
40     ${resp}=         PostCall    ${DBC_URL}/mr_clients    ${SUB3_DATA}
41     Should Be Equal As Integers  ${resp.status_code}  200   
42
43 (DMAAP-297)
44     [Documentation]    Query for all topics and specific topic
45     ${resp}=           Evaluate    requests.get('${DBC_URL}/topics', verify=False)    requests
46     Should Be Equal As Integers  ${resp.status_code}  200
47     ${resp}=       Evaluate    requests.get('${DBC_URL}/topics/${TOPIC_NS}.singleMRtopic3', verify=False)    requests
48     Should Be Equal As Integers  ${resp.status_code}  200
49
50 (DMAAP-301)
51     [Documentation]    Delete a subscriber
52     ${resp}=           Evaluate    requests.get('${DBC_URL}/topics/${TOPIC_NS}.singleMRtopic3', verify=False)    requests
53     Should Be Equal As Integers  ${resp.status_code}  200
54     ${JSON}=           Evaluate      json.loads(r"""${resp.content}""", strict=False)
55     ${clientId}=       Set Variable  ${JSON['clients'][1]['mrClientId']}
56     ${resp}=           DelCall   ${DBC_URL}/mr_clients/${clientId}
57     Should Be Equal As Integers  ${resp.status_code}  204
58
59 (DMAAP-302)
60     [Documentation]    Delete a publisher
61     ${resp}=           Evaluate    requests.get('${DBC_URL}/topics/${TOPIC_NS}.singleMRtopic3', verify=False)    requests
62     Should Be Equal As Integers  ${resp.status_code}  200
63     ${JSON}=           Evaluate      json.loads(r"""${resp.content}""", strict=False)
64     ${clientId}=       Set Variable  ${JSON['clients'][0]['mrClientId']}
65     ${resp}=           DelCall   ${DBC_URL}/mr_clients/${clientId}
66     Should Be Equal As Integers  ${resp.status_code}  204
67
68
69 *** Keywords ***
70 PostCall
71     [Arguments]    ${url}           ${data}
72     ${headers}=    Create Dictionary    Accept=application/json    Content-Type=application/json
73     ${resp}=       Evaluate    requests.post('${url}',data='${data}', headers=${headers},verify=False)    requests
74     [Return]       ${resp}
75
76 DelCall
77     [Arguments]    ${url}           
78     ${headers}=    Create Dictionary    Accept=application/json    Content-Type=application/json
79     ${resp}=       Evaluate    requests.delete('${url}', headers=${headers},verify=False)    requests
80     [Return]       ${resp}