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}
36 ${resp}= REST Get List of Intents
37 : FOR ${intent_id} IN @{all_intents_ids}
38 \ Should Contain ${resp} ${intent_id}
39 ${size}= Get Length ${all_intents_correct}
40 : FOR ${index} IN RANGE ${size}
41 \ ${intent}= Get From List ${all_intents_correct} ${index}
42 \ ${intent_id}= Get From List ${all_intents_ids} ${index}
43 \ REST Update Intent By Id ${intent_id} @{intent}
44 \ ${intent_from}= Get From List ${intent} 0
45 \ ${intent_to}= Get From List ${intent} 1
46 \ ${intent_permission}= Get From List ${intent} 2
47 \ ${resp}= REST Get Intent From Id ${intent_id}
48 \ Should Contain ${resp} ${intent_from}
49 \ Should Contain ${resp} ${intent_to}
50 \ Should Contain ${resp} ${intent_permission}
51 : FOR ${id} IN @{all_intents_ids}
52 \ REST Delete Intent By Id ${id}
55 REST Get List of Intents
56 [Documentation] Get the list of intents configured
57 ${resp} RequestsLibrary.Get Request session ${INTENT_CONTEXT}
58 Should Be Equal As Strings ${resp.status_code} 200
59 Should Contain ${resp.content} "intents"
60 [Return] ${resp.content}
62 REST Get Intent From Id
64 [Documentation] Get the intent detail from id
65 ${resp} RequestsLibrary.Get Request session ${INTENT_CONTEXT}/intent/${id}
66 Log Json ${resp.content}
67 Should Be Equal As Strings ${resp.status_code} 200
68 Should Contain ${resp.content} ${id}
69 [Return] ${resp.content}
72 [Documentation] Generates random UUID for use with creating intents on REST API. Has the format
73 ... (alphanumeric) 8-4-4-4-12.
74 ${id1}= Generate Random String 8 [NUMBERS]abcdef
75 ${id2}= Generate Random String 4 [NUMBERS]abcdef
76 ${id3}= Generate Random String 4 [NUMBERS]abcdef
77 ${id4}= Generate Random String 4 [NUMBERS]abcdef
78 ${id5}= Generate Random String 12 [NUMBERS]abcdef
79 ${id}= Catenate SEPARATOR=- ${id1} ${id2} ${id3} ${id4}
84 [Arguments] ${intent_from} ${intent_to} ${intent_permission}
85 [Documentation] Make an Intent and return the id of the new intent
86 ${headers}= Create Dictionary Content-Type=application/json
87 ${id}= Generate Random UUID
88 ${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}": {}}]}}
89 ${resp} RequestsLibrary.Post Request session ${INTENT_CONTEXT} headers=${headers} data=${data}
90 Should Be Equal As Strings ${resp.status_code} 204
93 REST Update Intent By Id
94 [Arguments] ${id} ${intent_from} ${intent_to} ${intent_permission}
95 [Documentation] Make an Intent and return the id of the new intent
96 ${headers}= Create Dictionary Content-Type=application/json
97 ${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}": {}}]}}
98 ${resp} RequestsLibrary.Put Request session ${INTENT_CONTEXT}/intent/${id} headers=${headers} data=${data}
99 Should Be Equal As Strings ${resp.status_code} 200
102 REST Delete All Intents
103 [Documentation] Delete all of the Intents
104 ${headers}= Create Dictionary Content-Type=application/json
105 ${resp} RequestsLibrary.Delete Request session ${INTENT_CONTEXT} headers=${headers}
107 Should Be Equal As Strings ${resp.status_code} 200
108 [Return] ${resp.content}
110 REST Delete Intent By Id
112 [Documentation] Delete Intent by Id
113 ${headers}= Create Dictionary Content-Type=application/json
114 ${resp} RequestsLibrary.Delete Request session ${INTENT_CONTEXT}/intent/${id} headers=${headers}
116 Should Be Equal As Strings ${resp.status_code} 200
117 [Return] ${resp.content}