Stavros Kanarakis | 40c1ddc | 2019-03-27 19:11:43 +0200 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Library RequestsLibrary |
| 3 | Library Collections |
| 4 | Library BbsLibrary.py |
| 5 | Resource ../../../common.robot |
| 6 | |
| 7 | *** Keywords *** |
| 8 | Create header |
| 9 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json |
| 10 | Set Suite Variable ${suite_headers} ${headers} |
| 11 | |
| 12 | Create sessions |
| 13 | Create Session dmaap_setup_session ${DMAAP_SIMULATOR_SETUP_URL} |
| 14 | Set Suite Variable ${dmaap_setup_session} dmaap_setup_session |
| 15 | Create Session aai_setup_session ${AAI_SIMULATOR_SETUP_URL} |
| 16 | Set Suite Variable ${aai_setup_session} aai_setup_session |
| 17 | |
| 18 | Reset Simulators |
| 19 | Reset AAI simulator |
| 20 | Reset DMaaP simulator |
| 21 | |
| 22 | Set AAI Records |
| 23 | [Timeout] 30s |
| 24 | ${data}= Get Data From File ${AAI_PNFS} |
| 25 | ${headers}= Create Dictionary Accept=application/json Content-Type=text/html |
| 26 | ${resp} = Put Request ${aai_setup_session} /set_pnfs headers=${headers} data=${data} |
| 27 | Should Be Equal As Strings ${resp.status_code} 200 |
| 28 | ${data}= Get Data From File ${AAI_SERVICES} |
| 29 | ${headers}= Create Dictionary Accept=application/json Content-Type=text/html |
| 30 | ${resp} = Put Request ${aai_setup_session} /set_services headers=${headers} data=${data} |
| 31 | Should Be Equal As Strings ${resp.status_code} 200 |
| 32 | ${data}= Get Data From File ${AAI_PNF_NOT_FOUND} |
| 33 | ${headers}= Create Dictionary Accept=application/json Content-Type=text/html |
| 34 | ${resp} = Put Request ${aai_setup_session} /set_pnf_not_found headers=${headers} data=${data} |
| 35 | Should Be Equal As Strings ${resp.status_code} 200 |
| 36 | |
| 37 | Invalid rgmac auth event processing |
| 38 | [Arguments] ${input_invalid_event_in_dmaap} |
| 39 | [Timeout] 30s |
| 40 | ${data}= Get Data From File ${input_invalid_event_in_dmaap} |
| 41 | Set event in DMaaP ${data} |
| 42 | ${err_msg}= Catenate SEPARATOR= \\n RGW MAC address taken from event (Optional[]) does not match with A&AI metadata corresponding value |
| 43 | Wait Until Keyword Succeeds 20x 2000ms Check BBS log ${err_msg} |
| 44 | |
| 45 | Invalid auth event processing |
| 46 | [Arguments] ${input_invalid_event_in_dmaap} |
| 47 | [Timeout] 30s |
| 48 | ${data}= Get Data From File ${input_invalid_event_in_dmaap} |
| 49 | Set event in DMaaP ${data} |
| 50 | ${json_obj}= Get invalid auth elements ${data} |
| 51 | Wait Until Keyword Succeeds 20x 2000ms Check BBS log Incorrect CPE Authentication JSON event: |
| 52 | Wait Until Keyword Succeeds 20x 2000ms Check BBS log ${json_obj} |
| 53 | Valid auth event processing |
| 54 | [Arguments] ${input_valid_event_in_dmaap} |
| 55 | [Timeout] 30s |
| 56 | ${data}= Get Data From File ${input_valid_event_in_dmaap} |
| 57 | Set event in DMaaP ${data} |
| 58 | Wait Until Keyword Succeeds 20x 2000ms Check policy ${AUTH_POLICY} |
| 59 | |
| 60 | Check policy |
| 61 | [Arguments] ${json_policy_file} |
| 62 | ${resp}= Get Request ${dmaap_setup_session} /events/dcaeClOutput headers=${suite_headers} |
| 63 | ${data}= Get Data From File ${json_policy_file} |
| 64 | ${result}= Compare policy ${resp.text} ${data} |
| 65 | Should Be Equal As Strings ${result} True |
| 66 | |
| 67 | Invalid update event processing |
| 68 | [Arguments] ${input_invalid_event_in_dmaap} |
| 69 | [Timeout] 30s |
| 70 | ${data}= Get Data From File ${input_invalid_event_in_dmaap} |
| 71 | Set event in DMaaP ${data} |
| 72 | ${json_obj}= Get invalid update elements ${data} |
| 73 | Wait Until Keyword Succeeds 20x 2000ms Check BBS log Incorrect Re-Registration |
| 74 | Wait Until Keyword Succeeds 20x 2000ms Check BBS log JSON event: |
| 75 | Wait Until Keyword Succeeds 20x 2000ms Check BBS log ${json_obj} |
| 76 | |
| 77 | |
| 78 | Valid update event processing |
| 79 | [Arguments] ${input_valid_event_in_dmaap} |
| 80 | [Timeout] 30s |
| 81 | ${data}= Get Data From File ${input_valid_event_in_dmaap} |
| 82 | Set event in DMaaP ${data} |
| 83 | Wait Until Keyword Succeeds 20x 2000ms Check policy ${UPDATE_POLICY} |
| 84 | |
| 85 | |
| 86 | Check BBS log |
| 87 | [Arguments] ${searched_log} |
| 88 | ${status}= Check for log ${searched_log} |
| 89 | Should Be Equal As Strings ${status} True |
| 90 | |
| 91 | Set PNF name in AAI |
| 92 | [Arguments] ${pnfs_name} |
| 93 | ${headers}= Create Dictionary Accept=application/json Content-Type=text/html |
| 94 | ${resp} = Put Request ${aai_setup_session} /set_pnfs headers=${headers} data=${pnfs_name} |
| 95 | Should Be Equal As Strings ${resp.status_code} 200 |
| 96 | |
| 97 | Set event in DMaaP |
| 98 | [Arguments] ${event_in_dmaap} |
| 99 | ${resp} = Put Request ${dmaap_setup_session} /set_get_event headers=${suite_headers} data=${event_in_dmaap} |
| 100 | Should Be Equal As Strings ${resp.status_code} 200 |
| 101 | |
| 102 | Reset AAI simulator |
| 103 | ${resp} = Post Request ${aai_setup_session} /reset |
| 104 | Should Be Equal As Strings ${resp.status_code} 200 |
| 105 | |
| 106 | Reset DMaaP simulator |
| 107 | ${resp}= Post Request ${dmaap_setup_session} /reset |
| 108 | Should Be Equal As Strings ${resp.status_code} 200 |