Adapt robot files to RFC 8040 (controller)
[integration/test.git] / basic / 024_ResourceAttributesACP.robot
1 *** Settings ***
2 Documentation     Tests for Access Control Policy (ACP) resource attributes
3 Suite Setup       IOTDM Basic Suite Setup    ${ODL_SYSTEM_1_IP}    ${ODL_RESTCONF_USER}    ${ODL_RESTCONF_PASSWORD}
4 Suite Teardown    Kill The Tree    ${ODL_SYSTEM_1_IP}    InCSE1    admin    admin
5 Resource          ../../../libraries/SubStrings.robot
6 Library           ../../../libraries/IoTDM/criotdm.py
7 Library           Collections
8 Resource          ../../../variables/Variables.robot
9 Resource          ../../../libraries/IoTDM/IoTDMKeywords.robot
10
11 *** Variables ***
12 ${rt_ae}          2
13 ${rt_container}    3
14 ${rt_contentInstance}    4
15 ${rt_acp}         1
16
17 *** Test Cases ***
18 1.0.0 Test whether default ACP exist
19     Modify Headers Origin    ${iserver}    admin
20     ${r} =    Retrieve Resource    ${iserver}    InCSE1/_defaultACP
21     ${text} =    Text    ${r}
22     LOG    ${text}
23     ${status_code} =    Status Code    ${r}
24     Should Be True    199 < ${status_code} < 299
25
26 1.0.1 ACP C/R resource with mandatory common and specific attributes only
27     [Documentation]    After Created, test whether all the mandatory attribtues exist.
28     ${attr} =    Set Variable    "pv":{"acr":[{"acor" : ["111","222"],"acop":35}, {"acor" : ["111","222"],"acop":35}]}, "pvs":{"acr":[{"acor" : ["111","222"],"acop":7}, {"acor" : ["111","222"],"acop":9}]}, "rn":"Acp1"
29     ${r}=    Create Resource    ${iserver}    InCSE1    ${rt_acp}    ${attr}
30     ${status_code} =    Status Code    ${r}
31     Should Be Equal As Integers    ${status_code}    201
32     ${text} =    Convert To String    ${r.text}
33     Should Contain All Sub Strings    ${text}    "ct":    "lt":    "ty"    "ri":    "pi":
34
35 1.0.2 ACP D/R: resource with mandatory common and specific attributes only
36     [Tags]    not-implemented    exclude
37     TODO
38
39 2 ACP common attributes
40     [Documentation]    (TODO remove when implemented), next TCs verifies particular common attribute of ACP.
41     [Tags]    not-implemented    exclude
42     TODO
43
44 2.01 ACP common attribute: resourceName
45     [Tags]    not-implemented    exclude
46     TODO
47
48 2.02 ACP common attribute: resourceType
49     [Tags]    not-implemented    exclude
50     TODO
51
52 2.03 ACP common attribute: resourceID
53     [Tags]    not-implemented    exclude
54     TODO
55
56 2.04 ACP common attribute: parentID
57     [Tags]    not-implemented    exclude
58     TODO
59
60 2.05 ACP common attribute: expirationTime
61     [Tags]    not-implemented    exclude
62     TODO
63
64 2.06 ACP common attribute: labels
65     [Tags]    not-implemented    exclude
66     TODO
67
68 2.07 ACP common attribute: creationTime
69     [Tags]    not-implemented    exclude
70     TODO
71
72 2.08 ACP common attribute: lastModifiedTime
73     [Tags]    not-implemented    exclude
74     TODO
75
76 2.09 ACP common attribute: announceTo
77     [Tags]    not-implemented    exclude
78     TODO
79
80 2.10 ACP common attribute: announcedAttribute
81     [Tags]    not-implemented    exclude
82     TODO
83
84 3 ACP specific attributes
85     [Documentation]    (TODO remove when implemented), next TCs verifies particular specific attribute of ACP.
86     [Tags]    not-implemented    exclude
87     TODO
88
89 3.01 ACP specific attributes: priviliges, selfPrivileges
90     [Tags]    not-implemented    exclude
91     # TODO TCs here should implement all sub-cases as described in the help file
92     # TODO next TC definities just shows subset of TCs and how it could be done
93     TODO
94
95 3.01.01 ACP U/R: priviliges attribute: Update priviliges attribute only
96     [Documentation]    Update only priviliges attribute of ACP and verify by Retrieve operation.
97     [Tags]    not-implemented    exclude
98     TODO
99
100 3.01.02 ACP U/R: selfPriviliges attribute: Update selfPriviliges attribute only
101     [Documentation]    Update only selfPriviliges attribute of ACP and verify by Retrieve operation.
102     [Tags]    not-implemented    exclude
103     TODO
104
105 3.01.03 ACP U/R: priviliges attribute: Delete priviliges attribute only
106     [Documentation]    NEGATIVE: Use Update operation to set priviliges attribute to null. Verify error message and
107     ...    verify original ACP resource by Retrieve operation.
108     [Tags]    not-implemented    exclude
109     TODO
110
111 3.01.04 ACP U/R: selfPriviliges attribute: Delete selfPriviliges attribute only
112     [Documentation]    NEGATIVE: Use Update operation to set selfPriviliges attribute to null. Verify error message and
113     ...    verify original ACP resource by Retrieve operation.
114     [Tags]    not-implemented    exclude
115     TODO
116
117 3.02 ACP elements of specific attributes: priviliges, selfPrivileges
118     [Tags]    not-implemented    exclude
119     # TODO TCs here should implement all sub-cases as described in the help file
120     # TODO next TC definities just shows subset of TCs and how it could be done
121     TODO
122
123 3.02.01 ACP C/R: priviliges, selfPrivileges attributes: With valid IPv4 acip element
124     [Documentation]    After Created, test whether all the mandatory elements exist.
125     ${attr} =    Set Variable    "pv":{"acr":[{"acor" : ["111","222"],"acop":35,"acco":[{"acip":{"ipv4":["127.0.0.1"]}}]},{"acor" : ["111","222"],"acop":35}]},"pvs":{"acr":[{"acor" : ["111","222"],"acop":7},{"acor" : ["111","222"],"acop":9}]},"rn":"Acp2"
126     ${r}=    Create Resource    ${iserver}    InCSE1    ${rt_acp}    ${attr}
127     ${status_code} =    Status Code    ${r}
128     Should Be Equal As Integers    ${status_code}    201
129     ${text} =    Convert To String    ${r.text}
130     Should Contain All Sub Strings    ${text}    "ct":    "lt":    "ty"    "ri":    "pi":
131
132 3.02.02 ACP U/R: priviliges, selfPrivileges attributes: With valid IPv4 acip element
133     [Documentation]    After Updated, test whether all the mandatory elements exist.
134     ...    Update resources with/without tested element.
135     [Tags]    not-implemented    exclude
136     TODO
137
138 3.02.03 ACP D/R: priviliges, selfPrivileges attributes: With valid IPv4 acip element
139     [Documentation]    After Deleted, verify by Retrieve operation. Delete resources with/without tested element.
140     [Tags]    not-implemented    exclude
141     TODO
142
143 3.02.04 ACP C/R: priviliges, selfPrivileges attributes: With invalid IPv4 acip element
144     [Documentation]    NEGATIVE: Create with invalid ipv4 address, check error message and verify by Retrieve operation.
145     ${attr} =    Set Variable    "pv":{"acr":[{"acor" : ["111","222"],"acop":35,"acco":[{"acip":{"ipv4":["127.0.01"]}}]},{"acor" : ["111","222"],"acop":35}]},"pvs":{"acr":[{"acor" : ["111","222"],"acop":7},{"acor" : ["111","222"],"acop":9}]},"rn":"Acp3"
146     ${error}=    Run Keyword And Expect Error    *    Create Resource    ${iserver}    InCSE1    ${rt_acp}
147     ...    ${attr}
148     Should Start with    ${error}    Cannot create this resource [400]
149     Should Contain    ${error}    not a valid Ipv4 address
150     # TODO Verify by Retrieve no operation
151
152 3.02.05 ACP U/R: priviliges, selfPrivileges attributes: With invalid IPv4 acip element
153     [Documentation]    NEGATIVE: Update with invalid ipv4 address, check error message and verify by Retrieve operation.
154     ...    Update resources with/without tested element.
155     [Tags]    not-implemented    exclude
156     TODO
157
158 3.02.06 ACP C/R: priviliges, selfPrivileges attributes: With valid IPv6 acip element
159     [Documentation]    After Created, test whether all the mandatory elements exist.
160     ${attr} =    Set Variable    "pv":{"acr":[{"acor" : ["111","222"],"acop":35,"acco":[{"acip":{"ipv6":["2001:db8:0:0:0:ff00:42:8329"]}}]},{"acor" : ["111","222"],"acop":35}]},"pvs":{"acr":[{"acor" : ["111","222"],"acop":7},{"acor" : ["111","222"],"acop":9}]},"rn":"Acp4"
161     ${r}=    Create Resource    ${iserver}    InCSE1    ${rt_acp}    ${attr}
162     ${status_code} =    Status Code    ${r}
163     Should Be Equal As Integers    ${status_code}    201
164     ${text} =    Convert To String    ${r.text}
165     Should Contain All Sub Strings    ${text}    "ct":    "lt":    "ty"    "ri":    "pi":
166     # TODO verify by Retrieve operation
167
168 3.02.07 ACP U/R: priviliges, selfPrivileges attributes: With valid IPv6 acip element
169     [Documentation]    After Updated, test whether all the mandatory elements exist. Update ACP resources with/without
170     ...    tested element.
171     [Tags]    not-implemented    exclude
172     TODO
173
174 3.02.08 ACP D/R: priviliges, selfPrivileges attributes: With valid IPv6 acip element
175     [Documentation]    After Deleted, test whether all the mandatory elements exist. Delete ACP resources with/without
176     ...    tested element.
177     [Tags]    not-implemented    exclude
178     TODO
179
180 3.02.09 ACP C/R: priviliges, selfPrivileges attributes: With invalid IPv6 acip element
181     [Documentation]    NEGATIVE: Create with invalid ipv6 address, check error message and verify by Retrieve operation.
182     ${attr} =    Set Variable    "pv":{"acr":[{"acor" : ["111","222"],"acop":35,"acco":[{"acip":{"ipv6":["2001:db8:0:0:0:ff00:42"]}}]},{"acor" : ["111","222"],"acop":35}]},"pvs":{"acr":[{"acor" : ["111","222"],"acop":7},{"acor" : ["111","222"],"acop":9}]},"rn":"Acp3"
183     ${error}=    Run Keyword And Expect Error    *    Create Resource    ${iserver}    InCSE1    ${rt_acp}
184     ...    ${attr}
185     Should Start with    ${error}    Cannot create this resource [400]
186     Should Contain    ${error}    not a valid Ipv6 address
187     # TODO: verify by retrieve operation
188
189 3.02.10 ACP U/R: priviliges, selfPrivileges attributes: With invalid IPv6 acip element
190     [Documentation]    NEGATIVE: Update with invalid ipv6 address, check error message and verify by Retrieve operation.
191     ...    Update resources with/without tested element.
192     [Tags]    not-implemented    exclude
193     TODO
194
195 3.03.01 ACP C/R: priviliges, selfPrivileges attributes: With accessControlWindow element
196     [Documentation]    Create ACP with accessControlWindow element and verify by Retrieve operation.
197     [Tags]    not-implemented    exclude
198     TODO
199
200 3.03.02 ACP U/R: priviliges, selfPrivileges attributes: With accessControlWindow element
201     [Documentation]    Update the accessControlWindow element of ACP resources with/without tested element and verify
202     ...    by Retrieve operation.
203     [Tags]    not-implemented    exclude
204     TODO
205
206 3.03.03 ACP D/R: priviliges, selfPrivileges attributes: With accessControlWindow element
207     [Documentation]    Delete ACP with accessControlWindow element and verify by Retrieve operation.
208     [Tags]    not-implemented    exclude
209     TODO
210
211 3.03.04 ACP C/R: priviliges, selfPrivileges attributes: With invalid accessControlWindow element
212     [Documentation]    NEGTIVE: Create ACP with invalid accessControlWindow element and check error message and
213     ...    verify by Retrieve operation.
214     [Tags]    not-implemented    exclude
215     TODO
216
217 3.03.05 ACP U/R: priviliges, selfPrivileges attributes: With invalid accessControlWindow element
218     [Documentation]    Update the invalid value of accessControlWindow element of ACP resources with/without tested
219     ...    element and verify by Retrieve operation.
220     [Tags]    not-implemented    exclude
221     TODO
222
223 3.03.06 ACP C/R: priviliges, selfPrivileges attributes: With multiple accessControlWindow elements
224     [Documentation]    Create ACP with multiple accessControlWindow elements and verify by Retrieve operation.
225     [Tags]    not-implemented    exclude
226     TODO
227
228 3.03.07 ACP U/R: priviliges, selfPrivileges attributes: With multiple accessControlWindow elements
229     [Documentation]    Update multiple accessControlWindow elements of ACP resources with/without tested elements and verify
230     ...    by Retrieve operation.
231     [Tags]    not-implemented    exclude
232     TODO
233
234 3.03.08 ACP D/R: priviliges, selfPrivileges attributes: With multiple accessControlWindow elements
235     [Documentation]    Delete ACP with multiple accessControlWindow elements and verify by Retrieve operation.
236     [Tags]    not-implemented    exclude
237     TODO
238
239 3.03.09 ACP C/R: priviliges, selfPrivileges attributes: With multiple invalid accessControlWindow elements
240     [Documentation]    NEGTIVE: Create ACP with multiple invalid accessControlWindow elements and check error message and
241     ...    verify by Retrieve operation.
242     ...    Test also combinations of valid and invalid elements.
243     [Tags]    not-implemented    exclude
244     TODO
245
246 3.03.10 ACP U/R: priviliges, selfPrivileges attributes: With multiple invalid accessControlWindow elements
247     [Documentation]    Update the invalid value of accessControlWindow element of ACP resources with/without tested
248     ...    element and verify by Retrieve operation.
249     ...    Test also combinations of valid and invalid elements.
250     [Tags]    not-implemented    exclude
251     TODO
252
253 3.03.11 ACP C/R: priviliges, selfPrivileges attributes: With accessControlLocationRegions element
254     [Documentation]    Create ACP with accessControlLocationRegions element and verify by Retrieve operation.
255     [Tags]    not-implemented    exclude
256     TODO
257
258 3.03.12 ACP U/R: priviliges, selfPrivileges attributes: With accessControlLocationRegions element
259     [Documentation]    Update the accessControlLocationRegions element of ACP resources with/without tested element and verify
260     ...    by Retrieve operation.
261     [Tags]    not-implemented    exclude
262     TODO
263
264 3.03.13 ACP D/R: priviliges, selfPrivileges attributes: With accessControlLocationRegions element
265     [Documentation]    Delete ACP with accessControlLocationRegions element and verify by Retrieve operation.
266     [Tags]    not-implemented    exclude
267     TODO
268
269 3.03.14 ACP C/R: priviliges, selfPrivileges attributes: With invalid accessControlLocationRegions element
270     [Documentation]    NEGTIVE: Create ACP with invalid accessControlLocationRegions element and check error message and
271     ...    verify by Retrieve operation.
272     [Tags]    not-implemented    exclude
273     TODO
274
275 3.03.15 ACP U/R: priviliges, selfPrivileges attributes: With invalid accessControlLocationRegions element
276     [Documentation]    Update the invalid value of accessControlLocationRegions element of ACP resources with/without tested
277     ...    element and verify by Retrieve operation.
278     [Tags]    not-implemented    exclude
279     TODO
280
281 3.03.16 ACP C/R: priviliges, selfPrivileges attributes: With accessControlAuthenticationFlag element
282     [Documentation]    Create ACP with accessControlAuthenticationFlag element and verify by Retrieve operation.
283     [Tags]    not-implemented    exclude
284     TODO
285
286 3.03.17 ACP U/R: priviliges, selfPrivileges attributes: With accessControlAuthenticationFlag element
287     [Documentation]    Update the accessControlAuthenticationFlag element of ACP resources with/without tested element and verify
288     ...    by Retrieve operation.
289     [Tags]    not-implemented    exclude
290     TODO
291
292 3.03.18 ACP D/R: priviliges, selfPrivileges attributes: With accessControlAuthenticationFlag element
293     [Documentation]    Delete ACP with accessControlAuthenticationFlag element and verify by Retrieve operation.
294     [Tags]    not-implemented    exclude
295     TODO
296
297 3.03.19 ACP C/R: priviliges, selfPrivileges attributes: With invalid accessControlAuthenticationFlag element
298     [Documentation]    NEGTIVE: Create ACP with invalid accessControlAuthenticationFlag element and check error message and
299     ...    verify by Retrieve operation.
300     [Tags]    not-implemented    exclude
301     TODO
302
303 3.03.20 ACP U/R: priviliges, selfPrivileges attributes: With invalid accessControlAuthenticationFlag element
304     [Documentation]    Update the invalid value of accessControlAuthenticationFlag element of ACP resources with/without tested
305     ...    element and verify by Retrieve operation.
306     [Tags]    not-implemented    exclude
307     TODO
308
309 3.03.21 ACP C/R: priviliges, selfPrivileges attributes: With multiple accessControlContext (acco) elements
310     [Documentation]    Create ACP with multiple accessControlContext elements and verify by Retrieve operation.
311     [Tags]    not-implemented    exclude
312     TODO
313
314 3.03.22 ACP U/R: priviliges, selfPrivileges attributes: With multiple accessControlContext (acco) elements
315     [Documentation]    Update ACP with multiple accessControlContext elements and verify by Retrieve operation.
316     [Tags]    not-implemented    exclude
317     TODO
318
319 3.03.23 ACP D/R: priviliges, selfPrivileges attributes: With multiple accessControlContext (acco) elements
320     [Documentation]    Delete ACP with multiple accessControlContext elements and verify by Retrieve operation.
321     [Tags]    not-implemented    exclude
322     TODO
323
324 3.03.24 ACP C/R: priviliges, selfPrivileges attributes: With multiple accessControlRules elements
325     [Documentation]    Create ACP with multiple accessControlRules element and verify by Retrieve operation.
326     [Tags]    not-implemented    exclude
327     TODO
328
329 4.01 ACP C/R: With all mandatory and optional common and specific attributes
330     [Tags]    not-implemented    exclude
331     TODO
332
333 4.02 ACP U(modify)/R: With all mandatory and optional common and specific attributes
334     [Tags]    not-implemented    exclude
335     TODO
336
337 4.03 ACP D/R: With all mandatory and optional common and specific attributes
338     [Tags]    not-implemented    exclude
339     TODO
340
341 4.04 ACP Test Create and Update operations with non-existing attributes and elements
342     [Tags]    not-implemented    exclude
343     # TODO use the approach described in the help file
344     TODO
345
346 5.00 ACP CRUD with all valid RCN values
347     [Documentation]    CRUD operations with all mandatory and optiona common and specific attributes, test all RCN values
348     [Tags]    not-implemented    exclude
349     TODO
350
351 *** Keywords ***
352 Connect And Create Resource
353     [Arguments]    ${targetURI}    ${resoutceType}    ${attr}    ${resourceName}=${EMPTY}
354     ${iserver} =    Connect To Iotdm    ${ODL_SYSTEM_1_IP}    ${ODL_RESTCONF_USER}    ${ODL_RESTCONF_PASSWORD}    http
355     ${r} =    Create Resource    ${iserver}    ${targetURI}    ${resoutceType}    ${attr}    ${resourceName}
356     ${status_code} =    Status Code    ${r}
357     Should Be Equal As Integers    ${status_code}    201
358
359 Response Is Correct
360     [Arguments]    ${r}
361     ${text} =    Text    ${r}
362     LOG    ${text}
363     ${json} =    Json    ${r}
364     LOG    ${json}
365     ${status_code} =    Status Code    ${r}
366     Should Be True    199 < ${status_code} < 299
367
368 TODO
369     Fail    "Not implemented"