[DMAAP] Refactoring dmaap suites
[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 ${DBC_URI}     webapi
13 ${DBC_URL}     http://${DMAAPBC_IP}:8080/${DBC_URI}
14 ${LOC}          csit-sanfrancisco
15 ${FEED1_DATA}  { "feedName":"feed1", "feedVersion": "csit", "feedDescription":"generated for CSIT", "owner":"dgl", "asprClassification": "unclassified" }
16 ${FEED2_DATA}  { "feedName":"feed2", "feedVersion": "csit", "feedDescription":"generated for CSIT", "owner":"dgl", "asprClassification": "unclassified" }
17 ${PUB2_DATA}   { "dcaeLocationName": "${LOC}", "username": "pub2", "userpwd": "topSecret123", "feedId": "2" }
18 ${SUB2_DATA}   { "dcaeLocationName": "${LOC}", "username": "sub2", "userpwd": "someSecret123", "deliveryURL": "https://${DMAAPBC_IP}:8443/webapi/noURI", "feedId": "2" }
19
20
21 *** Test Cases ***
22 (DMAAP-441c1)
23     [Documentation]        Create Feed w no clients POST ${DBC_URI}/feeds endpoint
24     ${resp}=         PostCall     ${DBC_URL}/feeds    ${FEED1_DATA}
25     Should Be Equal As Integers   ${resp.status_code}  200
26
27 (DMAAP-441c2)
28     [Documentation]        Create Feed w clients POST ${DBC_URI}/feeds endpoint
29     ${resp}=         PostCall     ${DBC_URL}/feeds    ${FEED2_DATA}
30     Should Be Equal As Integers   ${resp.status_code}  200
31
32 (DMAAP-441c3)
33     [Documentation]        Add Publisher to existing feed
34     ${resp}=         PostCall      ${DBC_URL}/dr_pubs    ${PUB2_DATA}
35     Should Be Equal As Integers    ${resp.status_code}  201
36     ${JSON}=         Evaluate      json.loads(r"""${resp.content}""", strict=False)
37     ${result}=       Set Variable  ${JSON['pubId']}
38     Set Suite Variable             ${pubId}    ${result}
39
40 (DMAAP-441c4)
41     [Documentation]        Add Subscriber to existing feed
42     ${resp}=         PostCall      ${DBC_URL}/dr_subs    ${SUB2_DATA}
43     Should Be Equal As Integers    ${resp.status_code}  201
44     ${JSON}=         Evaluate      json.loads(r"""${resp.content}""", strict=False)
45     ${result}=       Set Variable  ${JSON['subId']}
46     Set Suite Variable             ${subId}    ${result}
47
48 (DMAAP-443)
49     [Documentation]        List existing feeds
50     Create Session     get          ${DBC_URL}
51     ${resp}=         GET On Session    get       /feeds
52     Should Be Equal As Integers     ${resp.status_code}  200
53
54 (DMAAP-444)
55     [Documentation]        Delete existing subscriber
56     ${resp}=         DelCall        ${DBC_URL}/dr_subs/${subId}
57     Should Be Equal As Integers     ${resp.status_code}  204
58
59 (DMAAP-445)
60     [Documentation]        Delete existing publisher
61     ${resp}=         DelCall        ${DBC_URL}/dr_pubs/${pubId}
62     Should Be Equal As Integers     ${resp.status_code}  204
63
64
65 *** Keywords ***
66 PostCall
67     [Arguments]    ${url}           ${data}
68     ${headers}=    Create Dictionary    Accept=application/json    Content-Type=application/json
69     ${resp}=       Evaluate    requests.post('${url}',data='${data}', headers=${headers},verify=False)    requests
70     [Return]       ${resp}
71
72 DelCall
73     [Arguments]    ${url}           
74     ${headers}=    Create Dictionary    Accept=application/json    Content-Type=application/json
75     ${resp}=       Evaluate    requests.delete('${url}', headers=${headers},verify=False)    requests
76     [Return]       ${resp}