2 Documentation Test suite to verify Restconf is OK
3 Suite Setup Create Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH} headers=${HEADERS_XML}
4 Suite Teardown Delete All Sessions
5 Library RequestsLibrary
7 Library HttpLibrary.HTTP
8 Variables ../../../variables/Variables.py
9 Resource ../../../libraries/Utils.robot
12 ${REST_CONTEXT} /restconf/modules
13 ${INTENT_CONTEXT} /restconf/config/intent:intents
14 @{intent1_correct} 10.0.0.5 10.0.0.2,10.0.0.3 allow
15 @{intent2_correct} 10.0.0.5 10.0.0.2,10.0.0.10 block
16 @{intent3_correct} 10.0.0.1,10.0.0.4 10.0.0.2 allow
17 @{all_intents_correct} ${intent1_correct} ${intent2_correct} ${intent3_correct}
18 @{intent1_bad} 10.0.0.3 10.0.0.22,10.0.0.33 allow
19 @{intent2_bad} 10.0.0.1 10.0.0.12,10.0.0.102 block
20 @{intent3_bad} 10.0.0.2,10.0.0.10 10.0.0.42 allow
21 @{all_intents_bad} ${intent1_bad} ${intent2_bad} ${intent3_bad}
25 Get Controller Modules
26 [Documentation] Get the controller modules via Restconf
27 ${resp} RequestsLibrary.Get Request session ${REST_CONTEXT}
29 Should Be Equal As Strings ${resp.status_code} 200
30 Should Contain ${resp.content} ietf-restconf
32 Verify REST Command Add, Update and Remove
33 FOR ${intent} IN @{all_intents_bad}
34 ${intent_id}= REST Add Intent @{intent}
35 Append To List ${all_intents_ids} ${intent_id}
37 ${resp}= REST Get List of Intents
38 FOR ${intent_id} IN @{all_intents_ids}
39 Should Contain ${resp} ${intent_id}
41 ${size}= Get Length ${all_intents_correct}
42 FOR ${index} IN RANGE ${size}
43 ${intent}= Get From List ${all_intents_correct} ${index}
44 ${intent_id}= Get From List ${all_intents_ids} ${index}
45 REST Update Intent By Id ${intent_id} @{intent}
46 ${intent_from}= Get From List ${intent} 0
47 ${intent_to}= Get From List ${intent} 1
48 ${intent_permission}= Get From List ${intent} 2
49 ${resp}= REST Get Intent From Id ${intent_id}
50 Should Contain ${resp} ${intent_from}
51 Should Contain ${resp} ${intent_to}
52 Should Contain ${resp} ${intent_permission}
54 FOR ${id} IN @{all_intents_ids}
55 REST Delete Intent By Id ${id}
59 REST Get List of Intents
60 [Documentation] Get the list of intents configured
61 ${resp} RequestsLibrary.Get Request session ${INTENT_CONTEXT}
62 Should Be Equal As Strings ${resp.status_code} 200
63 Should Contain ${resp.content} "intents"
64 [Return] ${resp.content}
66 REST Get Intent From Id
68 [Documentation] Get the intent detail from id
69 ${resp} RequestsLibrary.Get Request session ${INTENT_CONTEXT}/intent/${id}
70 Log Json ${resp.content}
71 Should Be Equal As Strings ${resp.status_code} 200
72 Should Contain ${resp.content} ${id}
73 [Return] ${resp.content}
76 [Documentation] Generates random UUID for use with creating intents on REST API. Has the format
77 ... (alphanumeric) 8-4-4-4-12.
78 ${id1}= Generate Random String 8 [NUMBERS]abcdef
79 ${id2}= Generate Random String 4 [NUMBERS]abcdef
80 ${id3}= Generate Random String 4 [NUMBERS]abcdef
81 ${id4}= Generate Random String 4 [NUMBERS]abcdef
82 ${id5}= Generate Random String 12 [NUMBERS]abcdef
83 ${id}= Catenate SEPARATOR=- ${id1} ${id2} ${id3} ${id4}
88 [Arguments] ${intent_from} ${intent_to} ${intent_permission}
89 [Documentation] Make an Intent and return the id of the new intent
90 ${headers}= Create Dictionary Content-Type=application/json
91 ${id}= Generate Random UUID
92 ${data}= Catenate {"intent":{"id": "${id}","subjects":[{"order": 1,"end-point-group": {"name": "${intent_from}"}},{"order": 2,"end-point-group": { "name": "${intent_to}"}}],"actions": [{"order": 1,"${intent_permission}": {}}]}}
93 ${resp} RequestsLibrary.Post Request session ${INTENT_CONTEXT} headers=${headers} data=${data}
94 Should Be Equal As Strings ${resp.status_code} 204
97 REST Update Intent By Id
98 [Arguments] ${id} ${intent_from} ${intent_to} ${intent_permission}
99 [Documentation] Make an Intent and return the id of the new intent
100 ${headers}= Create Dictionary Content-Type=application/json
101 ${data}= Catenate {"intent":{"id": "${id}","subjects":[{"order": 1,"end-point-group": {"name": "${intent_from}"}},{"order": 2,"end-point-group": { "name": "${intent_to}"}}],"actions": [{"order": 1,"${intent_permission}": {}}]}}
102 ${resp} RequestsLibrary.Put Request session ${INTENT_CONTEXT}/intent/${id} headers=${headers} data=${data}
103 Should Be Equal As Strings ${resp.status_code} 200
106 REST Delete All Intents
107 [Documentation] Delete all of the Intents
108 ${headers}= Create Dictionary Content-Type=application/json
109 ${resp} RequestsLibrary.Delete Request session ${INTENT_CONTEXT} headers=${headers}
111 Should Be Equal As Strings ${resp.status_code} 200
112 [Return] ${resp.content}
114 REST Delete Intent By Id
116 [Documentation] Delete Intent by Id
117 ${headers}= Create Dictionary Content-Type=application/json
118 ${resp} RequestsLibrary.Delete Request session ${INTENT_CONTEXT}/intent/${id} headers=${headers}
120 Should Be Equal As Strings ${resp.status_code} 200
121 [Return] ${resp.content}