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