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