f6e126942a5b198e50e7f012a5aca2dee86adebd
[integration/test.git] / csit / suites / sfc / SFC_Basic / 120__sfc_service_function_acl.robot
1 *** Settings ***
2 Documentation     Test suite for SFC Service Function ACL, Operates functions from Restconf APIs.
3 Suite Setup       Create Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}
4 Suite Teardown    Delete All Sessions
5 Test Setup        Remove All Elements If Exist    ${SERVICE_FUNCTION_ACLS_URI}
6 Test Teardown     Remove All Elements At URI    ${SERVICE_FUNCTION_ACLS_URI}
7 Library           SSHLibrary
8 Library           Collections
9 Library           OperatingSystem
10 Library           RequestsLibrary
11 Resource          ../../../variables/sfc/Variables.robot
12 Resource          ../../../libraries/Utils.robot
13
14 *** Variables ***
15 ${SERVICE_FUNCTION_ACL_FILE}    ${CURDIR}/../../../variables/sfc/master/service-function-acl.json
16
17 *** Test Cases ***
18 Add ACL
19     [Documentation]    Add Service Function ACL from JSON file
20     Add Elements To URI From File    ${SERVICE_FUNCTION_ACLS_URI}    ${SERVICE_FUNCTION_ACL_FILE}
21     ${body}    OperatingSystem.Get File    ${SERVICE_FUNCTION_ACL_FILE}
22     ${jsonbody}    To Json    ${body}
23     ${functions}    Get From Dictionary    ${jsonbody}    access-lists
24     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_FUNCTION_ACLS_URI}
25     ${result}    To JSON    ${resp.content}
26     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
27     ${function}    Get From Dictionary    ${result}    access-lists
28     Lists Should be Equal    ${function}    ${functions}
29
30 Delete All ACLs
31     [Documentation]    Delete all ACL
32     ${body}    OperatingSystem.Get File    ${SERVICE_FUNCTION_ACL_FILE}
33     Add Elements To URI From File    ${SERVICE_FUNCTION_ACLS_URI}    ${SERVICE_FUNCTION_ACL_FILE}
34     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_FUNCTION_ACLS_URI}
35     Should Be Equal As Strings    ${resp.status_code}    200
36     Remove All Elements At URI    ${SERVICE_FUNCTION_ACLS_URI}
37     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_FUNCTION_ACLS_URI}
38     Should Be Equal As Strings    ${resp.status_code}    404
39     [Teardown]    NONE
40
41 Get one ACL
42     [Documentation]    Get one ACL
43     Add Elements To URI From File    ${SERVICE_FUNCTION_ACLS_URI}    ${SERVICE_FUNCTION_ACL_FILE}
44     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_FUNCTION_ACLS_URI}/acl/ietf-access-control-list:ipv4-acl/ACL1
45     Should Be Equal As Strings    ${resp.status_code}    200
46
47 Get A Non-existing ACL
48     [Documentation]    Get A Non-existing ACL
49     Add Elements To URI From File    ${SERVICE_FUNCTION_ACLS_URI}    ${SERVICE_FUNCTION_ACL_FILE}
50     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_FUNCTION_ACLS_URI}/acl/unexisting-acl
51     Should Be Equal As Strings    ${resp.status_code}    404
52
53 Delete An ACL
54     [Documentation]    Delete an ACL
55     Add Elements To URI From File    ${SERVICE_FUNCTION_ACLS_URI}    ${SERVICE_FUNCTION_ACL_FILE}
56     Remove All Elements At URI    ${SERVICE_FUNCTION_ACLS_URI}/acl/ietf-access-control-list:ipv4-acl/ACL1
57     ${resp}    RequestsLibrary.Get Request    session    ${SERVICE_FUNCTION_ACLS_URI}
58     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
59     Should Not Contain    ${resp.text}    ACL1