a3aef42b8ae4573d8cb9822db16cda3b90cda5a3
[integration/csit.git] / tests / dmaap-buscontroller / with_dr / 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 ${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 ${FEED1_DATA}  { "feedName":"feed1", "feedVersion": "csit", "feedDescription":"generated for CSIT", "owner":"dgl", "asprClassification": "unclassified" }
21 ${FEED2_DATA}  { "feedName":"feed2", "feedVersion": "csit", "feedDescription":"generated for CSIT", "owner":"dgl", "asprClassification": "unclassified" }
22 ${PUB2_DATA}   { "dcaeLocationName": "${LOC}", "username": "pub2", "userpwd": "topSecret123", "feedId": "2" }
23 ${SUB2_DATA}   { "dcaeLocationName": "${LOC}", "username": "sub2", "userpwd": "someSecret123", "deliveryURL": "https://${DMAAPBC_IP}:8443/webapi/noURI", "feedId": "2" }
24 ${TOPIC2_DATA}  { "topicName":"singleMRtopic2", "topicDescription":"generated for CSIT", "owner":"dgl", "clients": [ ${PUB}, ${SUB}] }
25 ${TOPIC3_DATA}  { "topicName":"singleMRtopic3", "topicDescription":"generated for CSIT", "owner":"dgl"}
26 #${PUB3_DATA}    { "fqtn": "${TOPIC_NS}.singleMRtopic3", ${PUB_CORE} }
27 #${SUB3_DATA}    { "fqtn": "${TOPIC_NS}.singleMRtopic3", ${SUB_CORE} }
28
29
30
31 *** Test Cases ***
32 Url Test
33     [Documentation]    Check if www.onap.org can be reached
34     Create Session     sanity          http://onap.readthedocs.io
35     ${resp}=           Get Request   sanity    /  
36     Should Be Equal As Integers  ${resp.status_code}  200
37
38 (DMAAP-441c1)
39     [Documentation]        Create Feed w no clients POST ${DBC_URI}/feeds endpoint
40     ${resp}=         PostCall    ${DBC_URL}/feeds    ${FEED1_DATA}
41     Should Be Equal As Integers  ${resp.status_code}  200   
42
43 (DMAAP-441c2)
44     [Documentation]        Create Feed w clients POST ${DBC_URI}/feeds endpoint
45     ${resp}=         PostCall    ${DBC_URL}/feeds    ${FEED2_DATA}
46     Should Be Equal As Integers  ${resp.status_code}  200   
47
48 (DMAAP-441c3)
49     [Documentation]        Add Publisher to existing feed
50     ${resp}=         PostCall    ${DBC_URL}/dr_pubs    ${PUB2_DATA}
51     Should Be Equal As Integers  ${resp.status_code}  201   
52     ${tmp}=          Get Json Value      ${resp.text}           /pubId
53     ${tmp}=          Remove String       ${tmp}         \"
54     Set Suite Variable          ${pubId}    ${tmp}
55
56 (DMAAP-441c4)
57     [Documentation]        Add Subscriber to existing feed
58     ${resp}=         PostCall    ${DBC_URL}/dr_subs    ${SUB2_DATA}
59     Should Be Equal As Integers  ${resp.status_code}  201   
60     ${tmp}=          Get Json Value      ${resp.text}           /subId
61     ${tmp}=          Remove String       ${tmp}         \"
62     Set Suite Variable          ${subId}    ${tmp}
63
64 (DMAAP-443)
65     [Documentation]        List existing feeds
66     Create Session     get          ${DBC_URL}
67     ${resp}=         Get Request    get       /feeds
68     Should Be Equal As Integers  ${resp.status_code}  200
69
70 (DMAAP-444)
71     [Documentation]        Delete existing subscriber
72     ${resp}=         DelCall    ${DBC_URL}/dr_subs/${subId}
73     Should Be Equal As Integers  ${resp.status_code}  204
74
75 (DMAAP-445)
76     [Documentation]        Delete existing publisher
77     ${resp}=         DelCall    ${DBC_URL}/dr_pubs/${pubId}
78     Should Be Equal As Integers  ${resp.status_code}  204
79
80 #(DMAAP-294)
81 #    [Documentation]        Create Topic w pub and sub clients POST ${DBC_URI}/topics endpoint
82 #    ${resp}=         PostCall    ${DBC_URL}/topics    ${TOPIC2_DATA}
83 #    Should Be Equal As Integers  ${resp.status_code}  201
84 #
85 #(DMAAP-295)
86 #    [Documentation]        Create Topic w no clients and then add a client POST ${DBC_URI}/mr_clients endpoint
87 #    ${resp}=         PostCall    ${DBC_URL}/topics    ${TOPIC3_DATA}
88 #    Should Be Equal As Integers  ${resp.status_code}  201   
89 #    ${resp}=         PostCall    ${DBC_URL}/mr_clients    ${PUB3_DATA}
90 #    Should Be Equal As Integers  ${resp.status_code}  200   
91 #    ${resp}=         PostCall    ${DBC_URL}/mr_clients    ${SUB3_DATA}
92 #    Should Be Equal As Integers  ${resp.status_code}  200   
93 #
94 #(DMAAP-297)
95 #    [Documentation]    Query for all topics and specific topic
96 #    Create Session     get          ${DBC_URL}
97 #    ${resp}=           Get Request   get    /topics  
98 #    Should Be Equal As Integers  ${resp.status_code}  200
99 #    ${resp}=           Get Request   get    /topics/${TOPIC_NS}.singleMRtopic3
100 #    Should Be Equal As Integers  ${resp.status_code}  200
101 #
102 #(DMAAP-301)
103 #    [Documentation]    Delete a subscriber
104 #    Create Session     get          ${DBC_URL}
105 #    ${resp}=           Get Request   get    /topics/${TOPIC_NS}.singleMRtopic3
106 #    Should Be Equal As Integers  ${resp.status_code}  200
107 #       ${tmp}=            Get Json Value      ${resp.text}           /clients/1/mrClientId
108 #       ${clientId}=       Remove String       ${tmp}         \"
109 #    ${resp}=           DelCall   ${DBC_URL}/mr_clients/${clientId}
110 #    Should Be Equal As Integers  ${resp.status_code}  204
111 #
112 #(DMAAP-302)
113 #    [Documentation]    Delete a publisher
114 #    Create Session     get          ${DBC_URL}
115 #    ${resp}=           Get Request   get    /topics/${TOPIC_NS}.singleMRtopic3
116 #    Should Be Equal As Integers  ${resp.status_code}  200
117 #       ${tmp}=            Get Json Value      ${resp.text}           /clients/0/mrClientId
118 #       ${clientId}=       Remove String       ${tmp}         \"
119 #    ${resp}=           DelCall   ${DBC_URL}/mr_clients/${clientId}
120 #    Should Be Equal As Integers  ${resp.status_code}  204
121
122
123 *** Keywords ***
124 CheckDir
125     [Arguments]                 ${path}
126     Directory Should Exist      ${path}
127
128 CheckUrl
129     [Arguments]                  ${session}   ${path}     ${expect}
130     ${resp}=                     Get  Request          ${session} ${path} 
131     Should Be Equal As Integers  ${resp.status_code}  ${expect}
132
133 PostCall
134     [Arguments]    ${url}           ${data}
135     ${headers}=    Create Dictionary    Accept=application/json    Content-Type=application/json
136     ${resp}=       Evaluate    requests.post('${url}',data='${data}', headers=${headers},verify=False)    requests
137     [Return]       ${resp}
138
139 DelCall
140     [Arguments]    ${url}           
141     ${headers}=    Create Dictionary    Accept=application/json    Content-Type=application/json
142     ${resp}=       Evaluate    requests.delete('${url}', headers=${headers},verify=False)    requests
143     [Return]       ${resp}