Remove certOnly and basicAuth from authentication methods CSIT VES
[integration/csit.git] / tests / dcaegen2 / testcases / dcae_ves.robot
1 *** Settings ***
2 Documentation     Testing DCAE VES Listener with various event feeds from VoLTE, vDNS, vFW and cCPE use scenarios
3 Library     RequestsLibrary
4 Library           OperatingSystem
5 Library           Collections
6 Library           DcaeLibrary
7 Resource          resources/dcae_keywords.robot
8 Resource          ../../common.robot
9 Resource          resources/dcae_properties.robot
10 Test Setup        Cleanup VES Events
11 Suite Setup       Run keywords  VES Collector Suite Setup DMaaP  Create sessions  Create header
12 Suite Teardown    VES Collector Suite Shutdown DMaaP    
13
14 *** Variables ***
15 ${VESC_URL_HTTPS}                        https://%{VESC_IP}:8443
16 ${VESC_URL}                              http://%{VESC_IP}:8080
17 ${VES_ANY_EVENT_PATH}                    /eventListener/v5
18 ${VES_BATCH_EVENT_PATH}                  /eventListener/v5/eventBatch
19 ${VES_THROTTLE_STATE_EVENT_PATH}         /eventListener/v5/clientThrottlingState
20 ${VES_ENDPOINT}                          /eventListener/v7
21 ${VES_VALID_JSON_V7}                     %{WORKSPACE}/tests/dcaegen2/testcases/assets/json_events/ves7_valid.json
22 ${VES_INVALID_JSON_V7}                   %{WORKSPACE}/tests/dcaegen2/testcases/assets/json_events/ves7_invalid.json
23 ${EVENT_DATA_FILE}                       %{WORKSPACE}/tests/dcaegen2/testcases/assets/json_events/ves_volte_single_fault_event.json
24 ${EVENT_MEASURE_FILE}                    %{WORKSPACE}/tests/dcaegen2/testcases/assets/json_events/ves_vfirewall_measurement.json
25 ${EVENT_DATA_FILE_BAD}                   %{WORKSPACE}/tests/dcaegen2/testcases/assets/json_events/ves_volte_single_fault_event_bad.json
26 ${EVENT_BATCH_DATA_FILE}                 %{WORKSPACE}/tests/dcaegen2/testcases/assets/json_events/ves_volte_fault_eventlist_batch.json
27 ${EVENT_THROTTLING_STATE_DATA_FILE}      %{WORKSPACE}/tests/dcaegen2/testcases/assets/json_events/ves_volte_fault_provide_throttle_state.json
28 ${EVENT_PNF_REGISTRATION}                %{WORKSPACE}/tests/dcaegen2/testcases/assets/json_events/ves_pnf_registration_event.json
29
30 #DCAE Health Check
31 ${CONFIG_BINDING_URL}                    http://localhost:8443
32 ${CB_HEALTHCHECK_PATH}                   /healthcheck
33 ${CB_SERVICE_COMPONENT_PATH}             /service_component/
34 ${VES_Service_Name1}                     dcae-controller-ves-collector
35 ${VES_Service_Name2}                     ves-collector-not-exist
36
37 *** Test Cases ***
38
39 #No authorization tests
40
41 VES Collector HTTP Health Check
42     [Tags]    DCAE-VESC-R1
43     [Documentation]   Ves Collector Health Check
44     ${uuid}=    Generate UUID
45     ${headers}=  Create Dictionary     Accept=*/*     X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid}    X-FromAppId=${GLOBAL_APPLICATION_ID}
46     ${resp}=    Get Request     ${suite_dcae_vesc_url_session}  /healthcheck        headers=${headers}
47     Should Be Equal As Strings  ${resp.status_code}     200
48
49 Publish Single VES VNF Measurement Event API V7
50     [Tags]    DCAE-VESC-R1
51     [Documentation]   Post single event and expect 202 Response
52     ${evtdata}=   Get Data From File   ${VES_VALID_JSON_V7}
53     ${resp}=  Publish Event To VES Collector No Auth    ${VES_ENDPOINT}  ${evtdata}
54     Log    Receive HTTP Status code ${resp.status_code}
55     Should Be Equal As Strings  ${resp.status_code}     202
56     ${isEmpty}=   Is Json Empty    ${resp}
57     Run Keyword If   '${isEmpty}' == False   Log  ${resp.json()}
58     ${ret}=  DMaaP Message Receive    ab305d54-85b4-a31b-7db2-fb6b9e546015
59     Should Be Equal As Strings    ${ret}    true
60
61
62 Publish Single VES VNF Measurement Event with wrong JSON
63     [Tags]    DCAE-VESC-R1
64     [Documentation]   Post single event and expect 400 Response
65     ${evtdata}=   Get Data From File   ${VES_INVALID_JSON_V7}
66     ${resp}=  Publish Event To VES Collector No Auth  ${VES_ENDPOINT}  ${evtdata}
67     Log    Receive HTTP Status code ${resp.status_code}
68     Should Be Equal As Strings  ${resp.status_code}     400
69     ${isEmpty}=   Is Json Empty    ${resp}
70     Run Keyword If   '${isEmpty}' == False   Log  ${resp.json()}
71
72 Publish Single VES VNF Measurement Event with No Auth over HTTPS
73     [Tags]    DCAE-VESC-R1
74     [Documentation]   Post single event and expect ConnectionError
75     ${evtdata}=   Get Data From File   ${VES_VALID_JSON_V7}
76     ${err_msg}=  Run Keyword And Expect Error  ConnectionError:*   Publish Event To VES Collector   ${VES_ENDPOINT}  ${evtdata}
77     Should Contain  ${err_msg}  Errno 111
78     Log  Recieved error message ${err_msg}
79
80 Publish Single VES VoLTE Fault Event
81     [Tags]    DCAE-VESC-R1
82     [Documentation]   Post single event and expect 202 Response
83     ${evtdata}=   Get Data From File   ${EVENT_DATA_FILE}
84     ${resp}=  Publish Event To VES Collector No Auth    ${VES_ANY_EVENT_PATH}  ${evtdata}
85     Log    Receive HTTP Status code ${resp.status_code}
86     Should Be Equal As Strings  ${resp.status_code}     202
87     ${isEmpty}=   Is Json Empty    ${resp}
88     Run Keyword If   '${isEmpty}' == False   Log  ${resp.json()}
89     ${ret}=  DMaaP Message Receive    ab305d54-85b4-a31b-7db2-fb6b9e546015
90     Should Be Equal As Strings    ${ret}    true
91
92 Publish Single VES VNF Measurement Event API V5
93     [Tags]    DCAE-VESC-R1
94     [Documentation]   Post single event and expect 202 Response
95     ${evtdata}=   Get Data From File   ${EVENT_MEASURE_FILE}
96     ${resp}=  Publish Event To VES Collector No Auth    ${VES_ANY_EVENT_PATH}  ${evtdata}
97     Log    Receive HTTP Status code ${resp.status_code}
98     Should Be Equal As Strings  ${resp.status_code}     202
99     ${isEmpty}=   Is Json Empty    ${resp}
100     Run Keyword If   '${isEmpty}' == False   Log  ${resp.json()}
101     ${ret}=  DMaaP Message Receive    0b2b5790-3673-480a-a4bd-5a00b88e5af6
102     Should Be Equal As Strings    ${ret}    true
103
104 Publish VES VoLTE Fault Batch Events
105     [Tags]    DCAE-VESC-R1
106     [Documentation]   Post batched events and expect 202 Response
107     ${evtdata}=   Get Data From File   ${EVENT_BATCH_DATA_FILE}
108     ${resp}=  Publish Event To VES Collector No Auth    ${VES_BATCH_EVENT_PATH}  ${evtdata}
109     Log    Receive HTTP Status code ${resp.status_code}
110     Should Be Equal As Strings  ${resp.status_code}     202
111     ${isEmpty}=   Is Json Empty    ${resp}
112     Run Keyword If   '${isEmpty}' == False   Log  ${resp.json()}
113     ${ret}=  DMaaP Message Receive    ab305d54-85b4-a31b-7db2-fb6b9e546025
114     Should Be Equal As Strings    ${ret}    true
115
116
117 Publish VES Event With Invalid Method
118     [Tags]    DCAE-VESC-R1
119     [Documentation]    Use invalid Put instead of Post method to expect 405 response
120     ${evtdata}=   Get Data From File   ${EVENT_DATA_FILE}
121     Log   Send HTTP Request with invalid method Put instead of Post
122     ${resp}=  Publish Event To VES Collector With Put Method No Auth  ${VES_ANY_EVENT_PATH}  ${evtdata}
123     Log    Receive HTTP Status code ${resp.status_code}
124     Should Be Equal As Strings  ${resp.status_code}     405
125     ${isEmpty}=   Is Json Empty    ${resp}
126     Run Keyword If   '${isEmpty}' == False   Log  ${resp.json()}
127
128 Publish VES Event With Invalid URL Path
129     [Tags]    DCAE-VESC-R1
130     [Documentation]    Use invalid url path to expect 404 response
131     ${evtdata}=   Get Data From File   ${EVENT_DATA_FILE}
132     Log   Send HTTP Request with invalid /listener/v5/ instead of /eventListener/v5 path
133     ${resp}=  Publish Event To VES Collector No Auth    /listener/v5/  ${evtdata}
134     Log    Receive HTTP Status code ${resp.status_code}
135     Should Be Equal As Strings  ${resp.status_code}     404
136     ${isEmpty}=   Is Json Empty    ${resp}
137     Run Keyword If   '${isEmpty}' == False   Log  ${resp.json()}
138
139 Publish PNF Registration Event
140     [Tags]    DCAE-VESC-R1
141     [Documentation]   Post PNF registration event and expect 200 Response
142     ${evtdata}=   Get Data From File   ${EVENT_PNF_REGISTRATION}
143     ${resp}=  Publish Event To VES Collector No Auth    ${VES_ANY_EVENT_PATH}  ${evtdata}
144     Log    Receive HTTP Status code ${resp.status_code}
145     Should Be Equal As Strings  ${resp.status_code}     202
146     ${isEmpty}=   Is Json Empty    ${resp}
147     Run Keyword If   '${isEmpty}' == False   Log  ${resp.json()}
148     ${ret}=  DMaaP Message Receive    QTFCOC540002E-reg
149     Should Be Equal As Strings    ${ret}    true
150
151
152 # Auth by certificate and basic auth username / password
153
154 Enable VESC HTTPS with certBasicAuth
155     [Tags]    DCAE-VESC-R1
156     [Documentation]  Enable VESC Https and Authentication and Run Health Check
157     Enable VESC with certBasicAuth
158     ${uuid}=    Generate UUID
159     ${headers}=  Create Dictionary     Accept=*/*     X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid}    X-FromAppId=${GLOBAL_APPLICATION_ID}
160     ${resp}=    Get Request     ${suite_dcae_vesc_url_session}  /healthcheck        headers=${headers}
161     Should Be Equal As Strings  ${resp.status_code}     200
162
163
164 Publish Single VES Fault Event Over HTTPS
165     [Tags]    DCAE-VESC-R1
166     [Documentation]   Post single event and expect 202 Response
167     ${evtdata}=   Get Data From File   ${EVENT_DATA_FILE}
168     Log  Login User=${VESC_HTTPS_USER}, Pd=${VESC_HTTPS_PD}
169     ${resp}=  Publish Event To VES Collector    ${VES_ANY_EVENT_PATH}  ${evtdata}
170     Log    Receive HTTPS Status code ${resp.status_code}
171     Should Be Equal As Strings  ${resp.status_code}     202
172     ${isEmpty}=   Is Json Empty    ${resp}
173     Run Keyword If   '${isEmpty}' == False   Log  ${resp.json()}
174     ${ret}=  DMaaP Message Receive    ab305d54-85b4-a31b-7db2-fb6b9e546015
175     Should Be Equal As Strings    ${ret}    true
176
177 Publish Single VES Measurement Event Over HTTPS
178     [Tags]    DCAE-VESC-R1
179     [Documentation]   Post single event and expect 202 Response
180     ${evtdata}=   Get Data From File   ${EVENT_MEASURE_FILE}
181     ${resp}=  Publish Event To VES Collector  ${VES_ANY_EVENT_PATH}  ${evtdata}
182     Log    Receive HTTPS Status code ${resp.status_code}
183     Should Be Equal As Strings  ${resp.status_code}     202
184     ${isEmpty}=   Is Json Empty    ${resp}
185     Run Keyword If   '${isEmpty}' == False   Log  ${resp.json()}
186     ${ret}=  DMaaP Message Receive    0b2b5790-3673-480a-a4bd-5a00b88e5af6
187     Should Be Equal As Strings    ${ret}    true
188
189 Publish VES Fault Batch Events Over HTTPS
190     [Tags]    DCAE-VESC-R1
191     [Documentation]   Post batched events and expect 202 Response
192     ${evtdata}=   Get Data From File   ${EVENT_BATCH_DATA_FILE}
193     ${resp}=  Publish Event To VES Collector  ${VES_BATCH_EVENT_PATH}  ${evtdata}
194     Should Be Equal As Strings  ${resp.status_code}     202
195     ${isEmpty}=   Is Json Empty    ${resp}
196     Run Keyword If   '${isEmpty}' == False   Log  ${resp.json()}
197     ${ret}=  DMaaP Message Receive    ab305d54-85b4-a31b-7db2-fb6b9e546025
198     Should Be Equal As Strings    ${ret}    true
199
200
201 Publish VES Event With Invalid URL Path HTTPS
202     [Tags]    DCAE-VESC-R1
203     [Documentation]    Use invalid url path to expect 404 response
204     ${evtdata}=   Get Data From File   ${EVENT_DATA_FILE}
205     Log   Send HTTP Request with invalid /eventlistener/v5/ instead of /eventListener/v5 path
206     ${resp}=  Publish Event To VES Collector  /eventlistener/v5  ${evtdata}
207     Log    Receive HTTPS Status code ${resp.status_code}
208     Should Be Equal As Strings  ${resp.status_code}     404
209     ${isEmpty}=   Is Json Empty    ${resp}
210     Run Keyword If   '${isEmpty}' == False   Log  ${resp.json()}
211
212 Publish Single VES VNF Measurement Event over HTTP
213     [Tags]    DCAE-VESC-R1
214     [Documentation]   Post single event over HTTP and expect 400 Response
215     ${evtdata}=   Get Data From File   ${VES_VALID_JSON_V7}
216     ${resp}=  Publish Event To VES Collector No Auth    ${VES_ENDPOINT}  ${evtdata}
217     Log    Receive HTTP Status code ${resp.status_code}
218     Should Be Equal As Strings  ${resp.status_code}     400
219     ${isEmpty}=   Is Json Empty    ${resp}
220     Run Keyword If   '${isEmpty}' == False   Log  ${resp.json()}
221
222
223 Publish Single VES VNF Measurement Event with certBasicAuth over HTTPS
224     [Tags]    DCAE-VESC-R1
225     [Documentation]   Post single event and expect 202 Response
226     ${evtdata}=   Get Data From File   ${VES_VALID_JSON_V7}
227     ${resp}=  Publish Event To VES Collector   ${VES_ENDPOINT}  ${evtdata}
228     Log    Receive HTTPS Status code ${resp.status_code}
229     Should Be Equal As Strings  ${resp.status_code}     202
230     ${isEmpty}=   Is Json Empty    ${resp}
231     Run Keyword If   '${isEmpty}' == False   Log  ${resp.json()}
232     ${ret}=  DMaaP Message Receive    ab305d54-85b4-a31b-7db2-fb6b9e546015
233     Should Be Equal As Strings    ${ret}    true
234
235 Publish Single VES VNF Measurement Event over HTTPS with wrong JSON
236     [Tags]    DCAE-VESC-R1
237     [Documentation]   Post single event and expect 400 Response
238     ${evtdata}=   Get Data From File   ${VES_INVALID_JSON_V7}
239     ${resp}=  Publish Event To VES Collector   ${VES_ENDPOINT}  ${evtdata}
240     Log    Receive HTTPS Status code ${resp.status_code}
241     Should Be Equal As Strings  ${resp.status_code}     400
242     ${isEmpty}=   Is Json Empty    ${resp}
243     Run Keyword If   '${isEmpty}' == False   Log  ${resp.json()}
244
245 Publish Single VES VNF Measurement Event With Wrong Auth
246     [Tags]  DCAE-VESC-R1
247     [Documentation]  Post single event and expect 401 response
248     ${evtdata}=  Get Data From File  ${VES_VALID_JSON_V7}
249     ${resp}=  Publish Event To VES Collector With Wrong Auth   ${VES_ENDPOINT}  ${evtdata}
250     Log    Receive HTTPS Status code ${resp.status_code}
251     Should Be Equal As Strings  ${resp.status_code}  401
252     ${isEmpty}=   Is Json Empty    ${resp}
253     Run Keyword If   '${isEmpty}' == False   Log  ${resp.json()}
254
255 Publish Single VES VNF Measurement Event With Cert
256     [Tags]  DCAE-VESC-R1
257     [Documentation]  Post single event and expect 202 response
258     ${evtdata}=  Get Data From File  ${VES_VALID_JSON_V7}
259     ${resp}=  Publish Event To VES Collector With Cert  ${VES_ENDPOINT}  ${evtdata}
260     Log    Receive HTTPS Status code ${resp.status_code}
261     Should Be Equal As Strings  ${resp.status_code}     202
262     ${isEmpty}=   Is Json Empty    ${resp}
263     Run Keyword If   '${isEmpty}' == False   Log  ${resp.json()}
264     ${ret}=  DMaaP Message Receive    ab305d54-85b4-a31b-7db2-fb6b9e546015
265     Should Be Equal As Strings    ${ret}    true
266
267 Publish Single VES VNF Measurement Event With Wrong Cert
268     [Tags]  DCAE-VESC-R1
269     [Documentation]  Post single event and expect SSLError with bad handshake
270     ${evtdata}=  Get Data From File  ${VES_VALID_JSON_V7}
271     ${err_msg}=  Run Keyword And Expect Error  SSLError:*  Publish Event To VES Collector With Wrong Cert  ${VES_ENDPOINT}  ${evtdata}
272     Should Contain  ${err_msg}  bad handshake
273     Should Contain  ${err_msg}  certificate unknown
274     Log  Recieved error message ${err_msg}
275
276 Publish Single VES VNF Measurement Event Without Auth And Cert
277     [Tags]  DCAE-VESC-R1
278     [Documentation]  Post single event and expect 401 response
279     ${evtdata}=  Get Data From File  ${VES_VALID_JSON_V7}
280     ${resp}=  Publish Event To VES Collector Without Auth And Cert  ${VES_ENDPOINT}  ${evtdata}
281     Log    Receive HTTPS Status code ${resp.status_code}
282     Should Be Equal As Strings  ${resp.status_code}  401
283     ${isEmpty}=   Is Json Empty    ${resp}
284     Run Keyword If   '${isEmpty}' == False   Log  ${resp.json()}