Migrate Get Requests invocations(libraries)
[integration/test.git] / csit / suites / iotdm / basic / 092_ResourceHierarchyAE_CNT_CIN.robot
1 *** Settings ***
2 Documentation       Test for hierarchy of resources: AE/CONTAINER/CONTENTINSTANCE
3
4 Resource            ../../../libraries/SubStrings.robot
5 Library             ../../../libraries/IoTDM/criotdm.py
6 Library             Collections
7 Resource            ../../../variables/Variables.robot
8 Resource            ../../../libraries/IoTDM/IoTDMKeywords.robot
9
10 Suite Setup         IOTDM Basic Suite Setup    ${ODL_SYSTEM_1_IP}    ${ODL_RESTCONF_USER}    ${ODL_RESTCONF_PASSWORD}
11 Suite Teardown      Kill The Tree    ${ODL_SYSTEM_1_IP}    InCSE1    admin    admin
12
13
14 *** Variables ***
15 ${rt_ae}                    2
16 ${rt_container}             3
17 ${rt_contentInstance}       4
18
19
20 *** Test Cases ***
21 1.11 Valid Input for AE without name
22     [Documentation]    Valid Input for AE without name
23     ${attr} =    Set Variable    "api":"jb","apn":"jb2","or":"http://hey/you","rr":true
24     ${r} =    Create Resource    ${iserver}    InCSE1    ${rt_ae}    ${attr}
25     Response Is Correct    ${r}
26
27 1.12 Valid Input for AE with name
28     ${attr} =    Set Variable    "api":"jb","apn":"jb2","or":"http://hey/you","rr":true,"rn":"ODL3"
29     ${r} =    Create Resource    ${iserver}    InCSE1    ${rt_ae}    ${attr}
30     Response Is Correct    ${r}
31
32 1.13 Invalid Input for AE with name Already Exist, should return error
33     [Documentation]    Invalid Input for AE with name Already Exist, should return error
34     ${attr} =    Set Variable    "api":"jb","apn":"jb2","or":"http://hey/you","rr":true,"rn":"ODL3"
35     ${error} =    Run Keyword And Expect Error    *    Create Resource    ${iserver}    InCSE1    ${rt_ae}
36     ...    ${attr}
37     Should Start with    ${error}    Cannot create this resource [409]
38
39 1.14 Invalid Input for AE (AE cannot be created under AE)
40     [Documentation]    Invalid Input for AE (AE cannot be created under AE), expect error
41     ${attr} =    Set Variable    "api":"jb","apn":"jb2","or":"http://hey/you","rr":true,"rn":"ODL4"
42     ${error} =    Run Keyword And Expect Error    *    Create Resource    ${iserver}    InCSE1/ODL3    ${rt_ae}
43     ...    ${attr}
44     Should Start with    ${error}    Cannot create this resource [405]
45     # -----------------    Update and Retrieve -------------
46
47 1.15 Valid Update AE's label
48     [Documentation]    Valid Update AE's label
49     ${attr} =    Set Variable    "lbl":["aaa","bbb","ccc"]
50     ${r} =    Update Resource    ${iserver}    InCSE1/ODL3    ${rt_ae}    ${attr}
51     Response Is Correct    ${r}
52     # Retrieve and test the lbl
53     ${r} =    Retrieve Resource    ${iserver}    InCSE1/ODL3
54     Should Contain All Sub Strings    ${r.text}    "aaa"    "bbb"    "ccc"
55     #==================================================
56     #    Container Test
57     #==================================================
58
59 2.11 Create Container without name under AE
60     [Documentation]    Create Container under AE without name
61     ${attr} =    Set Variable    "cr":null,"mni":1,"mbs":15,"or":"http://hey/you"
62     Connect And Create Resource    InCSE1/ODL3    ${rt_container}    ${attr}
63
64 2.12 Create Container with name under AE
65     [Documentation]    Create Container Under AE with name containerUnderAE and retrieve it to check if it is created
66     ${attr} =    Set Variable    "cr":null,"mni":1,"mbs":15,"or":"http://hey/you","rn":"containerUnderAE"
67     ${r} =    Create Resource    ${iserver}    /InCSE1/ODL3    ${rt_container}    ${attr}
68     ${container} =    Location    ${r}
69     Response Is Correct    ${r}
70     # retrieve it
71     ${result} =    Retrieve Resource    ${iserver}    ${container}
72     Should Contain    ${result.text}    containerUnderAE
73
74 2.13 Invalid Input for Container Under AE with name (Already exist)
75     [Documentation]    Invalid Input for Container Under AE with name (Already exist)
76     ${attr} =    Set Variable    "cr":null,"mni":1,"mbs":15,"or":"http://hey/you","rn":"containerUnderAE"
77     ${error} =    Run Keyword And Expect Error
78     ...    *
79     ...    Connect And Create Resource
80     ...    InCSE1/ODL3
81     ...    ${rt_container}
82     ...    ${attr}
83     Should Start with    ${error}    Cannot create this resource [409]
84
85 2.14 Update Container Label
86     [Documentation]    Update Label to ["aaa","bbb","ccc"]
87     ${attr} =    Set Variable    "lbl":["aaa","bbb","ccc"]
88     ${r} =    Update Resource    ${iserver}    InCSE1/ODL3/containerUnderAE    ${rt_container}    ${attr}
89     Response Is Correct    ${r}
90     # Retrieve and test the lbl
91     ${r} =    Retrieve Resource    ${iserver}    InCSE1/ODL3/containerUnderAE
92     Should Contain All Sub Strings    ${r.text}    "aaa"    "bbb"    "ccc"
93     #----------------------------------------------------------------------
94
95 2.21 Create Container under InCSE1 without name
96     [Documentation]    Create Container under InCSE1 without name
97     ${attr} =    Set Variable    "cr":null,"mni":1,"mbs":15,"or":"http://hey/you"
98     ${r} =    Create Resource    ${iserver}    InCSE1    ${rt_container}    ${attr}
99     Response Is Correct    ${r}
100
101 2.22 Create Container under CSE with name
102     [Documentation]    Create Container under CSE with name
103     ${attr} =    Set Variable    "cr":null,"mni":1,"mbs":15,"or":"http://hey/you","rn":"containerUnderCSE"
104     ${r} =    Create Resource    ${iserver}    InCSE1    ${rt_container}    ${attr}
105     Response Is Correct    ${r}
106     # retrieve it
107     ${result} =    Retrieve Resource    ${iserver}    InCSE1/containerUnderCSE
108     Should Contain    ${result.text}    containerUnderCSE
109
110 2.23 Invalid Input for Container Under CSE with name (Already exist)
111     [Documentation]    Invalid Input for Container Under CSE with name (Already exist)
112     ${attr} =    Set Variable    "cr":null,"mni":1,"mbs":15,"or":"http://hey/you","rn":"containerUnderCSE"
113     ${error} =    Run Keyword And Expect Error    *    Create Resource    ${iserver}    InCSE1    ${rt_container}
114     ...    ${attr}
115     Should Start with    ${error}    Cannot create this resource [409]
116
117 2.24 Update Container Label
118     [Documentation]    Update Container Label
119     ${attr} =    Set Variable    "lbl":["aaa","bbb","ccc"]
120     ${r} =    Update Resource    ${iserver}    InCSE1/containerUnderCSE    ${rt_container}    ${attr}
121     Response Is Correct    ${r}
122     # Retrieve and test the lbl
123     ${r} =    Retrieve Resource    ${iserver}    InCSE1/containerUnderCSE
124     Should Contain All Sub Strings    ${r.text}    "aaa"    "bbb"    "ccc"
125     #----------------------------------------------------------------------
126
127 2.31 Create Container under Container without name
128     [Documentation]    Create Container under Container without name
129     ${attr} =    Set Variable    "cr":null,"mni":1,"mbs":15,"or":"http://hey/you"
130     ${r} =    Create Resource    ${iserver}    InCSE1/containerUnderCSE    ${rt_container}    ${attr}
131     Response Is Correct    ${r}
132
133 2.32 Create Container under Container with name
134     [Documentation]    Create Container under Container with name
135     ${attr} =    Set Variable    "cr":null,"mni":1,"mbs":15,"or":"http://hey/you","rn":"containerUnderContainer"
136     ${r} =    Create Resource    ${iserver}    InCSE1/containerUnderCSE    ${rt_container}    ${attr}
137     ${container} =    Location    ${r}
138     Response Is Correct    ${r}
139     # retrieve it
140     ${result} =    Retrieve Resource    ${iserver}    ${container}
141     Should Contain    ${result.text}    containerUnderContainer
142
143 2.33 Invalid Input for Container Under Container with name (Already exist)
144     [Documentation]    Invalid Input for Container Under Container with name (Already exist)
145     ${attr} =    Set Variable    "cr":null,"mni":1,"mbs":15,"or":"http://hey/you","rn":"containerUnderContainer"
146     ${error} =    Run Keyword And Expect Error
147     ...    *
148     ...    Create Resource
149     ...    ${iserver}
150     ...    InCSE1/containerUnderCSE
151     ...    ${rt_container}
152     ...    ${attr}
153     Should Start with    ${error}    Cannot create this resource [409]
154
155 2.34 Update Container Label
156     [Documentation]    Update Container Label to ["aaa","bbb","ccc"]
157     ${attr} =    Set Variable    "lbl":["aaa","bbb","ccc"]
158     ${r} =    Update Resource
159     ...    ${iserver}
160     ...    InCSE1/containerUnderCSE/containerUnderContainer
161     ...    ${rt_container}
162     ...    ${attr}
163     Response Is Correct    ${r}
164     # Retrieve and test the lbl
165     ${r} =    Retrieve Resource    ${iserver}    InCSE1/containerUnderCSE/containerUnderContainer
166     Should Contain All Sub Strings    ${r.text}    "aaa"    "bbb"    "ccc"
167
168 2.41 Invalid Input for AE under container with name(mess up layer)
169     [Documentation]    Invalid Input for AE under container withoutname(mess up layer)
170     ${attr} =    Set Variable    "api":"jb","apn":"jb2","or":"http://hey/you","rr":true,"rn":"ODL4"
171     ${error} =    Run Keyword And Expect Error
172     ...    *
173     ...    Create Resource
174     ...    ${iserver}
175     ...    InCSE1/containerUnderCSE
176     ...    ${rt_ae}
177     ...    ${attr}
178     Should Start with    ${error}    Cannot create this resource [405]
179     Should Contain    ${error}    Cannot create AE under this resource type: 3
180     #==================================================
181     #    ContentInstance Test
182     #==================================================
183
184 3.11 Valid contentInstance under CSEBase/container without name
185     [Documentation]    Valid contentInstance under CSEBase/container without name
186     ${attr} =    Set Variable    "cnf": "1","or": "http://hey/you","con":"101"
187     ${r} =    Create Resource    ${iserver}    InCSE1/containerUnderCSE    ${rt_contentInstance}    ${attr}
188     Response Is Correct    ${r}
189
190 3.12 Valid contentInstance under CSEBase/container with name
191     [Documentation]    Valid contentInstance under CSEBase/container with name
192     ${attr} =    Set Variable    "cnf": "1","or": "http://hey/you","con":"102","rn":"conIn1"
193     ${r} =    Create Resource    ${iserver}    InCSE1/containerUnderCSE    ${rt_contentInstance}    ${attr}
194     Response Is Correct    ${r}
195
196 3.13 Invalid contentInstance under CSEBase
197     [Documentation]    Invalid contentInstance under CSEBase
198     ${attr} =    Set Variable    "cnf": "1","or": "http://hey/you","con":"101"
199     ${error} =    Run Keyword And Expect Error    *    Create Resource    ${iserver}    InCSE1    ${rt_contentInstance}
200     ...    ${attr}
201     Should Start with    ${error}    Cannot create this resource [405]
202     Should Contain    ${error}    Cannot create ContentInstance under this resource type: 5
203
204 3.14 Invalid contentInstance under AE
205     [Documentation]    Invalid contentInstance under AE
206     ${attr} =    Set Variable    "cnf": "1","or": "http://hey/you","con":"101"
207     ${error} =    Run Keyword And Expect Error
208     ...    *
209     ...    Create Resource
210     ...    ${iserver}
211     ...    InCSE1/ODL3
212     ...    ${rt_contentInstance}
213     ...    ${attr}
214     Should Start with    ${error}    Cannot create this resource [405]
215     Should Contain    ${error}    Cannot create ContentInstance under this resource type: 2
216
217 3.15 Invalid contentInstance under contentInstance
218     [Documentation]    Invalid contentInstance under contentInstance
219     ${attr} =    Set Variable    "cnf": "1","or": "http://hey/you","con":"101"
220     ${error} =    Run Keyword And Expect Error
221     ...    *
222     ...    Create Resource
223     ...    ${iserver}
224     ...    InCSE1/containerUnderCSE/conIn1
225     ...    ${rt_contentInstance}
226     ...    ${attr}
227     Should Start with    ${error}    Cannot create this resource [405]
228     Should Contain    ${error}    Cannot create ContentInstance under this resource type: 4
229
230 3.16 Invalid AE under contentInstance
231     [Documentation]    Invalid AE under contentInstance
232     ${attr} =    Set Variable    "api":"jb","apn":"jb2","or":"http://hey/you","rr":true
233     ${error} =    Run Keyword And Expect Error
234     ...    *
235     ...    Create Resource
236     ...    ${iserver}
237     ...    InCSE1/containerUnderCSE/conIn1
238     ...    ${rt_ae}
239     ...    ${attr}
240     Should Start with    ${error}    Cannot create this resource [405]
241     Should Contain    ${error}    Cannot create AE under this resource type: 4
242
243 3.17 Invalid container under contentInstance
244     [Documentation]    Invalid container under contentInstance
245     ${attr} =    Set Variable    "cr":null,"lbl":["aaa","bbb","ccc"]
246     ${error} =    Run Keyword And Expect Error
247     ...    *
248     ...    Create Resource
249     ...    ${iserver}
250     ...    InCSE1/containerUnderCSE/conIn1
251     ...    ${rt_container}
252     ...    ${attr}
253     Should Start with    ${error}    Cannot create this resource [405]
254     Should Contain    ${error}    Cannot create Container under this resource type: 4
255     #==================================================
256     #    Delete Test
257     #==================================================
258
259 4.11 Delete AE without child resource
260     [Documentation]    Delete AE without child resource
261     ${attr} =    Set Variable    "api":"jb","apn":"jb2","or":"http://hey/you","rr":true
262     ${r} =    Create Resource    ${iserver}    InCSE1    ${rt_ae}    ${attr},"rn":"AeName"
263     ${ae} =    Location    ${r}
264     Response Is Correct    ${r}
265     ${deleteRes} =    Delete Resource    ${iserver}    ${ae}
266     ${status_code} =    Status Code    ${deleteRes}
267     Should Be Equal As Integers    ${status_code}    200
268     # Delete AE that does not exist/has been deleted should return error
269     ${error} =    Run Keyword And Expect Error    *    Delete Resource    ${iserver}    ${ae}
270     Should Start with    ${error}    Cannot delete this resource [404]
271
272 4.12 Delete Container without child resource
273     [Documentation]    Delete Container without child resource
274     ${attr} =    Set Variable    "cr":null,"mni":1,"mbs":15,"or":"http://hey/you"
275     ${r} =    Create Resource    ${iserver}    InCSE1/ODL3    ${rt_container}    ${attr}
276     ${container} =    Location    ${r}
277     Response Is Correct    ${r}
278     ${deleteRes} =    Delete Resource    ${iserver}    ${container}
279     ${status_code} =    Status Code    ${deleteRes}
280     Should Be Equal As Integers    ${status_code}    200
281     # Delete container that does not exist/has been deleted should return error
282     ${error} =    Run Keyword And Expect Error    *    Delete Resource    ${iserver}    ${container}
283     Should Start with    ${error}    Cannot delete this resource [404]
284
285 Delete the Container Under CSEBase
286     [Documentation]    Delete the Container and AE Under CSEBase
287     ${deleteRes} =    Delete Resource    ${iserver}    InCSE1/containerUnderCSE
288     ${status_code} =    Status Code    ${deleteRes}
289     Should Be Equal As Integers    ${status_code}    200
290     ${deleteRes} =    Delete Resource    ${iserver}    InCSE1/ODL3
291     ${status_code} =    Status Code    ${deleteRes}
292     Should Be Equal As Integers    ${status_code}    200
293
294
295 *** Keywords ***
296 Connect And Create Resource
297     [Arguments]    ${targetURI}    ${resoutceType}    ${attr}
298     ${iserver} =    Connect To Iotdm    ${ODL_SYSTEM_1_IP}    ${ODL_RESTCONF_USER}    ${ODL_RESTCONF_PASSWORD}    http
299     ${r} =    Create Resource    ${iserver}    ${targetURI}    ${resoutceType}    ${attr}
300     ${container} =    Resid    ${r}
301     ${status_code} =    Status Code    ${r}
302     Should Be Equal As Integers    ${status_code}    201
303
304 Response Is Correct
305     [Arguments]    ${r}
306     ${status_code} =    Status Code    ${r}
307     Should Be True    199 < ${status_code} < 299
308     ${text} =    Text    ${r}
309     LOG    ${text}
310     ${json} =    Json    ${r}
311     LOG    ${json}