Update PM Mapper Setup & Test Case
[integration/csit.git] / tests / dcaegen2-pmmapper / pmmapper / pmmapper.robot
1 *** Settings ***
2 Documentation     Testing PM Mapper functionality
3 Library           Collections
4 Library           OperatingSystem
5 Library           RequestsLibrary
6 Library           Process
7
8 Test Setup        Create Session  mapper_session  ${PMMAPPER_BASE_URL}
9 Test Teardown     Delete All Sessions
10
11
12 *** Variables ***
13 ${CLI_EXEC_CLI_CONFIG}                   { head -n 5 | tail -1;} < /tmp/pmmapper.log
14 ${CLI_EXEC_CLI_SUBS}                     curl -k https://${DR_PROV_IP}:8443/internal/prov
15 ${PMMAPPER_BASE_URL}                     http://${PMMAPPER_IP}:8081
16 ${DELIVERY_ENDPOINT}                     /delivery
17
18 *** Test Cases ***
19
20 Verify PM Mapper Receive Configuraton From Config Binding Service
21     [Tags]                          PM_MAPPER_01
22     [Documentation]                 Verify 3gpp pm mapper successfully receive config data from CBS
23     ${cli_cmd_output}=              Run Process                     ${CLI_EXEC_CLI_CONFIG}                     shell=yes
24     Log                             ${cli_cmd_output.stdout}
25     Should Be Equal As Strings      ${cli_cmd_output.rc}            0
26     Should Contain                  ${cli_cmd_output.stdout}        Received pm-mapper configuration
27
28 Verify 3GPP PM Mapper Subscribes to Data Router
29     [Tags]                          PM_MAPPER_02
30     [Documentation]                 Verify 3gpp pm mapper subscribes to data router
31     ${cli_cmd_output}=              Run Process                     ${CLI_EXEC_CLI_SUBS}                     shell=yes
32     Log                             ${cli_cmd_output.stdout}
33     Should Be Equal As Strings      ${cli_cmd_output.rc}            0
34     Should Contain                  ${cli_cmd_output.stdout}        3gpppmmapper
35
36 Verify 3GPP PM Mapper responds appropriately when no metadata is provided
37     [Tags]                          PM_MAPPER_10
38     [Documentation]                 Verify 3GPP PM Mapper responds 400 with the message "Missing Metadata." when no metadata is provided
39     [Timeout]                       1 minute
40     ${headers}=                     Create Dictionary               X-ONAP-RequestID=1  Content-Type=application/xml
41     ${resp}=                        Put Request                     mapper_session  ${DELIVERY_ENDPOINT}/filename    data='${EMPTY}'    headers=${headers}
42     Should Be Equal As Strings      ${resp.status_code}             400
43     Should Be Equal As Strings      ${resp.content}                 Missing Metadata.
44
45 Verify 3GPP PM Mapper responds appropriately when invalid metadata is provided
46     [Tags]                          PM_MAPPER_11
47     [Documentation]                 Verify 3GPP PM Mapper responds 400 with the message "Malformed Metadata." when invalid metadata is provided
48     [Timeout]                       1 minute
49     ${headers}=                     Create Dictionary               X-ONAP-RequestID=1  X-DMAAP-DR-META='not metadata'  Content-Type=application/xml
50     ${resp}=                        Put Request                     mapper_session  ${DELIVERY_ENDPOINT}/filename  data='${EMPTY}'  headers=${headers}
51     Should Be Equal As Strings      ${resp.status_code}             400
52     Should Be Equal As Strings      ${resp.content}                 Malformed Metadata.
53
54 *** Keywords ***
55
56 PostCall
57     [Arguments]    ${url}           ${data}
58     ${headers}=    Create Dictionary    Accept=application/json    Content-Type=application/json
59     ${resp}=       Evaluate    requests.post('${url}',data='${data}', headers=${headers},verify=False)    requests
60     [Return]       ${resp}