Migrate Get Requests invocations(libraries)
[integration/test.git] / csit / suites / sxp / basic / 040_SSL_Passwords.robot
1 *** Settings ***
2 Documentation       Test suite to test SSL security fuctionality
3
4 Library             RequestsLibrary
5 Library             SSHLibrary
6 Library             ../../../libraries/Sxp.py
7 Resource            ../../../libraries/SxpLib.robot
8 Resource            ../../../libraries/WaitForFailure.robot
9 Resource            ../../../libraries/SSHKeywords.robot
10
11 Suite Setup         Setup SXP Environment Local    5
12 Suite Teardown      Clean SXP Environment    5
13 Test Setup          Clean Nodes
14
15
16 *** Variables ***
17 ${version}          version4
18 ${password}         admin123
19 ${ssl_stores}       /tmp
20
21
22 *** Test Cases ***
23 SSL ConectivityCase 1
24     [Documentation]    Test of SSL security with two SXP-nodes both have each other in truststores
25     [Tags]    sxp    ssl
26     SxpLib.Add Connection    ${version}    speaker    127.0.0.2    64999    127.0.0.1    security_mode=TLS
27     SxpLib.Add Connection    ${version}    listener    127.0.0.1    64999    127.0.0.2    security_mode=TLS
28     BuiltIn.Wait Until Keyword Succeeds    120x    1s    SxpLib.Verify Connection    ${version}    speaker    127.0.0.2
29     ...    64999    127.0.0.1
30     BuiltIn.Wait Until Keyword Succeeds
31     ...    120x
32     ...    1s
33     ...    SxpLib.Verify Connection
34     ...    ${version}
35     ...    listener
36     ...    127.0.0.1
37     ...    64999
38     ...    127.0.0.2
39     SxpLib.Clean Connections    127.0.0.1
40     SxpLib.Clean Connections    127.0.0.2
41     SxpLib.Add Connection    ${version}    listener    127.0.0.2    64999    127.0.0.1    security_mode=TLS
42     SxpLib.Add Connection    ${version}    speaker    127.0.0.1    64999    127.0.0.2    security_mode=TLS
43     BuiltIn.Wait Until Keyword Succeeds
44     ...    120x
45     ...    1s
46     ...    SxpLib.Verify Connection
47     ...    ${version}
48     ...    listener
49     ...    127.0.0.2
50     ...    64999
51     ...    127.0.0.1
52     BuiltIn.Wait Until Keyword Succeeds    120x    1s    SxpLib.Verify Connection    ${version}    speaker    127.0.0.1
53     ...    64999    127.0.0.2
54     SxpLib.Clean Connections    127.0.0.1
55     SxpLib.Clean Connections    127.0.0.2
56     SxpLib.Add Connection    ${version}    both    127.0.0.2    64999    127.0.0.1    security_mode=TLS
57     SxpLib.Add Connection    ${version}    both    127.0.0.1    64999    127.0.0.2    security_mode=TLS
58     BuiltIn.Wait Until Keyword Succeeds    120x    1s    SxpLib.Verify Connection    ${version}    both    127.0.0.2
59     ...    64999    127.0.0.1
60     BuiltIn.Wait Until Keyword Succeeds    120x    1s    SxpLib.Verify Connection    ${version}    both    127.0.0.1
61     ...    64999    127.0.0.2
62
63 SSL ConectivityCase 2
64     [Documentation]    Test of SSL security with two SXP-nodes while node-1 does not contain node-3 in truststore
65     [Tags]    sxp    ssl
66     SxpLib.Add Connection    ${version}    speaker    127.0.0.3    64999    127.0.0.1    security_mode=TLS
67     SxpLib.Add Connection    ${version}    listener    127.0.0.1    64999    127.0.0.3    security_mode=TLS
68     WaitForFailure.Verify_Keyword_Never_Passes_Within_Timeout
69     ...    60
70     ...    1
71     ...    SxpLib.Verify Connection
72     ...    ${version}
73     ...    speaker
74     ...    127.0.0.3
75     ...    64999
76     ...    127.0.0.1
77     WaitForFailure.Verify_Keyword_Never_Passes_Within_Timeout
78     ...    60
79     ...    1
80     ...    SxpLib.Verify Connection
81     ...    ${version}
82     ...    listener
83     ...    127.0.0.1
84     ...    64999
85     ...    127.0.0.3
86     SxpLib.Clean Connections    127.0.0.1
87     SxpLib.Clean Connections    127.0.0.3
88     SxpLib.Add Connection    ${version}    listener    127.0.0.3    64999    127.0.0.1    security_mode=TLS
89     SxpLib.Add Connection    ${version}    speaker    127.0.0.1    64999    127.0.0.3    security_mode=TLS
90     WaitForFailure.Verify_Keyword_Never_Passes_Within_Timeout
91     ...    60
92     ...    1
93     ...    SxpLib.Verify Connection
94     ...    ${version}
95     ...    listener
96     ...    127.0.0.3
97     ...    64999
98     ...    127.0.0.1
99     WaitForFailure.Verify_Keyword_Never_Passes_Within_Timeout
100     ...    60
101     ...    1
102     ...    SxpLib.Verify Connection
103     ...    ${version}
104     ...    speaker
105     ...    127.0.0.1
106     ...    64999
107     ...    127.0.0.3
108     SxpLib.Clean Connections    127.0.0.1
109     SxpLib.Clean Connections    127.0.0.3
110     SxpLib.Add Connection    ${version}    both    127.0.0.3    64999    127.0.0.1    security_mode=TLS
111     SxpLib.Add Connection    ${version}    both    127.0.0.1    64999    127.0.0.3    security_mode=TLS
112     WaitForFailure.Verify_Keyword_Never_Passes_Within_Timeout
113     ...    60
114     ...    1
115     ...    SxpLib.Verify Connection
116     ...    ${version}
117     ...    both
118     ...    127.0.0.3
119     ...    64999
120     ...    127.0.0.1
121     WaitForFailure.Verify_Keyword_Never_Passes_Within_Timeout
122     ...    60
123     ...    1
124     ...    SxpLib.Verify Connection
125     ...    ${version}
126     ...    both
127     ...    127.0.0.1
128     ...    64999
129     ...    127.0.0.3
130
131 SSL ConectivityCase 3
132     [Documentation]    Test of SSL security with two SXP-nodes while both of nodes does not have each other in truststores
133     [Tags]    sxp    ssl
134     SxpLib.Add Connection    ${version}    speaker    127.0.0.4    64999    127.0.0.1    security_mode=TLS
135     SxpLib.Add Connection    ${version}    listener    127.0.0.1    64999    127.0.0.4    security_mode=TLS
136     WaitForFailure.Verify_Keyword_Never_Passes_Within_Timeout
137     ...    60
138     ...    1
139     ...    SxpLib.Verify Connection
140     ...    ${version}
141     ...    speaker
142     ...    127.0.0.4
143     ...    64999
144     ...    127.0.0.1
145     WaitForFailure.Verify_Keyword_Never_Passes_Within_Timeout
146     ...    60
147     ...    1
148     ...    SxpLib.Verify Connection
149     ...    ${version}
150     ...    listener
151     ...    127.0.0.1
152     ...    64999
153     ...    127.0.0.4
154     SxpLib.Clean Connections    127.0.0.1
155     SxpLib.Clean Connections    127.0.0.4
156     SxpLib.Add Connection    ${version}    listener    127.0.0.4    64999    127.0.0.1    security_mode=TLS
157     SxpLib.Add Connection    ${version}    speaker    127.0.0.1    64999    127.0.0.4    security_mode=TLS
158     WaitForFailure.Verify_Keyword_Never_Passes_Within_Timeout
159     ...    60
160     ...    1
161     ...    SxpLib.Verify Connection
162     ...    ${version}
163     ...    listener
164     ...    127.0.0.4
165     ...    64999
166     ...    127.0.0.1
167     WaitForFailure.Verify_Keyword_Never_Passes_Within_Timeout
168     ...    60
169     ...    1
170     ...    SxpLib.Verify Connection
171     ...    ${version}
172     ...    speaker
173     ...    127.0.0.1
174     ...    64999
175     ...    127.0.0.4
176     SxpLib.Clean Connections    127.0.0.1
177     SxpLib.Clean Connections    127.0.0.4
178     SxpLib.Add Connection    ${version}    both    127.0.0.4    64999    127.0.0.1    security_mode=TLS
179     SxpLib.Add Connection    ${version}    both    127.0.0.1    64999    127.0.0.4    security_mode=TLS
180     WaitForFailure.Verify_Keyword_Never_Passes_Within_Timeout
181     ...    60
182     ...    1
183     ...    SxpLib.Verify Connection
184     ...    ${version}
185     ...    both
186     ...    127.0.0.4
187     ...    64999
188     ...    127.0.0.1
189     WaitForFailure.Verify_Keyword_Never_Passes_Within_Timeout
190     ...    60
191     ...    1
192     ...    SxpLib.Verify Connection
193     ...    ${version}
194     ...    both
195     ...    127.0.0.1
196     ...    64999
197     ...    127.0.0.4
198
199 SSL ConectivityCase 4
200     [Documentation]    Test of SSL security in topology consisting of SXP-nodes that does not uses any security,
201     ...    uses TCP-MD5 and SSL security. Each node contains series of bindings that in the end should
202     ...    be all propagated to node-5 in topology.
203     [Tags]    sxp    ssl
204     SxpLib.Add Connection    ${version}    listener    127.0.0.2    64999    127.0.0.1    security_mode=TLS
205     SxpLib.Add Connection    ${version}    speaker    127.0.0.1    64999    127.0.0.2    security_mode=TLS
206     BuiltIn.Wait Until Keyword Succeeds
207     ...    120x
208     ...    1s
209     ...    SxpLib.Verify Connection
210     ...    ${version}
211     ...    listener
212     ...    127.0.0.2
213     ...    64999
214     ...    127.0.0.1
215     BuiltIn.Wait Until Keyword Succeeds    120x    1s    SxpLib.Verify Connection    ${version}    speaker    127.0.0.1
216     ...    64999    127.0.0.2
217     SxpLib.Add Connection    ${version}    listener    127.0.0.3    64999    127.0.0.1    paswd
218     SxpLib.Add Connection    ${version}    speaker    127.0.0.1    64999    127.0.0.3    paswd
219     BuiltIn.Wait Until Keyword Succeeds
220     ...    120x
221     ...    1s
222     ...    SxpLib.Verify Connection
223     ...    ${version}
224     ...    listener
225     ...    127.0.0.3
226     ...    64999
227     ...    127.0.0.1
228     BuiltIn.Wait Until Keyword Succeeds    120x    1s    SxpLib.Verify Connection    ${version}    speaker    127.0.0.1
229     ...    64999    127.0.0.3
230     SxpLib.Add Connection    ${version}    listener    127.0.0.4    64999    127.0.0.1
231     SxpLib.Add Connection    ${version}    speaker    127.0.0.1    64999    127.0.0.4
232     BuiltIn.Wait Until Keyword Succeeds
233     ...    120x
234     ...    1s
235     ...    SxpLib.Verify Connection
236     ...    ${version}
237     ...    listener
238     ...    127.0.0.4
239     ...    64999
240     ...    127.0.0.1
241     BuiltIn.Wait Until Keyword Succeeds    120x    1s    SxpLib.Verify Connection    ${version}    speaker    127.0.0.1
242     ...    64999    127.0.0.4
243     SxpLib.Add Connection    ${version}    speaker    127.0.0.5    64999    127.0.0.1    security_mode=TLS
244     SxpLib.Add Connection    ${version}    listener    127.0.0.1    64999    127.0.0.5    security_mode=TLS
245     BuiltIn.Wait Until Keyword Succeeds    120x    1s    SxpLib.Verify Connection    ${version}    speaker    127.0.0.5
246     ...    64999    127.0.0.1
247     BuiltIn.Wait Until Keyword Succeeds
248     ...    120x
249     ...    1s
250     ...    SxpLib.Verify Connection
251     ...    ${version}
252     ...    listener
253     ...    127.0.0.1
254     ...    64999
255     ...    127.0.0.5
256     BuiltIn.Wait Until Keyword Succeeds    120x    1s    Verify Topology Bindings    5
257
258
259 *** Keywords ***
260 Setup SXP Environment Local
261     [Documentation]    Create session to Controller, copy keystores to ODL machines and setup topology for testing
262     [Arguments]    ${node_range}
263     RequestsLibrary.Create Session
264     ...    session
265     ...    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}
266     ...    auth=${AUTH}
267     ...    timeout=${DEFAULT_TIMEOUT_HTTP}
268     ...    max_retries=0
269     SSHKeywords.Open_Connection_To_ODL_System
270     ${ODL_SYSTEM_JAVA_HOME}    SSHLibrary.Execute_Command
271     ...    java -XshowSettings:properties -version 2>&1 | grep java.home | sed 's/.*= //'
272     FOR    ${node}    IN RANGE    1    ${node_range}+1
273         SSHKeywords.Execute_Command_Should_Pass
274         ...    ${ODL_SYSTEM_JAVA_HOME}/bin/keytool -genkeypair -alias odl-sxp-${node} -keyalg RSA -storepass ${password} -keypass ${password} -dname "CN=www.opendaylight.org, OU=csit, O=ODL, L=N/A, S=N/A, C=N/A" -keystore csit-keystore-${node}
275         SSHKeywords.Execute_Command_Should_Pass
276         ...    ${ODL_SYSTEM_JAVA_HOME}/bin/keytool -exportcert -keystore csit-keystore-${node} -alias odl-sxp-${node} -storepass ${password} -file odl-sxp-${node}.cer
277         # Node-1 TRUSTS Node-2, Node-5
278     END
279     SSHKeywords.Execute_Command_Should_Pass
280     ...    ${ODL_SYSTEM_JAVA_HOME}/bin/keytool -importcert -keystore csit-truststore-1 -alias odl-sxp-2 -storepass ${password} -keypass ${password} -file odl-sxp-2.cer -noprompt
281     SSHKeywords.Execute_Command_Should_Pass
282     ...    ${ODL_SYSTEM_JAVA_HOME}/bin/keytool -importcert -keystore csit-truststore-1 -alias odl-sxp-5 -storepass ${password} -keypass ${password} -file odl-sxp-5.cer -noprompt
283     # Node-2 TRUSTS Node-1
284     SSHKeywords.Execute_Command_Should_Pass
285     ...    ${ODL_SYSTEM_JAVA_HOME}/bin/keytool -importcert -keystore csit-truststore-2 -alias odl-sxp-2 -storepass ${password} -keypass ${password} -file odl-sxp-1.cer -noprompt
286     # Node-3 TRUSTS Node-1
287     SSHKeywords.Execute_Command_Should_Pass
288     ...    ${ODL_SYSTEM_JAVA_HOME}/bin/keytool -importcert -keystore csit-truststore-3 -alias odl-sxp-2 -storepass ${password} -keypass ${password} -file odl-sxp-1.cer -noprompt
289     # Node-5 TRUSTS Node-1
290     SSHKeywords.Execute_Command_Should_Pass
291     ...    ${ODL_SYSTEM_JAVA_HOME}/bin/keytool -importcert -keystore csit-truststore-5 -alias odl-sxp-2 -storepass ${password} -keypass ${password} -file odl-sxp-1.cer -noprompt
292     SSHKeywords.Execute_Command_Should_Pass    cp csit-keystore-4 csit-truststore-4
293     SSHKeywords.Execute_Command_Should_Pass    rm odl-sxp-*.cer
294     SSHKeywords.Execute_Command_Should_Pass    mv ./csit-keystore-* ${ssl_stores}
295     SSHKeywords.Execute_Command_Should_Pass    mv ./csit-truststore-* ${ssl_stores}
296     SSHLibrary.Close Connection
297     FOR    ${node}    IN RANGE    1    ${node_range}+1
298         ${SSL}    BuiltIn.Create Dictionary
299         ...    truststore=${ssl_stores}/csit-truststore-${node}
300         ...    keystore=${ssl_stores}/csit-keystore-${node}
301         ...    password=${password}
302         ${rnd_retry_time}    BuiltIn.Evaluate    random.randint(1, 5)    modules=random
303         SxpLib.Add Node    127.0.0.${node}    ${EMPTY}    ssl_stores=${SSL}    retry_open_timer=${rnd_retry_time}
304         BuiltIn.Wait Until Keyword Succeeds
305         ...    20x
306         ...    10s
307         ...    SxpLib.Check Node started
308         ...    127.0.0.${node}
309         ...    system=${ODL_SYSTEM_IP}
310         SxpLib.Add Bindings    ${node}00    1.1.1.${node}/32    127.0.0.${node}
311         SxpLib.Add Bindings    ${node}00    2.2.2.${node}/32    127.0.0.${node}
312     END
313
314 Verify Topology Bindings
315     [Documentation]    Create session to Controller
316     [Arguments]    ${node_range}
317     ${resp}    SxpLib.Get Bindings    127.0.0.5
318     FOR    ${node}    IN RANGE    1    ${node_range}+1
319         SxpLib.Should Contain Binding    ${resp}    ${node}00    1.1.1.${node}/32
320         SxpLib.Should Contain Binding    ${resp}    ${node}00    2.2.2.${node}/32
321     END
322
323 Clean Nodes
324     [Documentation]    Cleanup of resources alocated by test suite
325     SxpLib.Clean Connections    127.0.0.1
326     SxpLib.Clean Connections    127.0.0.2
327     SxpLib.Clean Connections    127.0.0.3
328     SxpLib.Clean Connections    127.0.0.4
329     SxpLib.Clean Connections    127.0.0.5