SXP: Fix node stop status checking
[integration/test.git] / csit / suites / sxp / basic / 040_SSL_Passwords.robot
1 *** Settings ***
2 Documentation     Test suite to test SSL security fuctionality
3 Suite Setup       Setup SXP Environment Local    5
4 Suite Teardown    Clean SXP Environment    5
5 Test Setup        Clean Nodes
6 Library           RequestsLibrary
7 Library           SSHLibrary
8 Library           ../../../libraries/Sxp.py
9 Resource          ../../../libraries/SxpLib.robot
10 Resource          ../../../libraries/WaitForFailure.robot
11 Resource          ../../../libraries/SSHKeywords.robot
12
13 *** Variables ***
14 ${version}        version4
15 ${password}       admin123
16 ${ssl_stores}     /tmp
17
18 *** Test Cases ***
19 SSL ConectivityCase 1
20     [Documentation]    Test of SSL security with two SXP-nodes both have each other in truststores
21     [Tags]    SXP    SSL
22     SxpLib.Add Connection    ${version}    speaker    127.0.0.2    64999    127.0.0.1    security_mode=TLS
23     SxpLib.Add Connection    ${version}    listener    127.0.0.1    64999    127.0.0.2    security_mode=TLS
24     BuiltIn.Wait Until Keyword Succeeds    120x    1s    SxpLib.Verify Connection    ${version}    speaker    127.0.0.2
25     ...    64999    127.0.0.1
26     BuiltIn.Wait Until Keyword Succeeds    120x    1s    SxpLib.Verify Connection    ${version}    listener    127.0.0.1
27     ...    64999    127.0.0.2
28     SxpLib.Clean Connections    127.0.0.1
29     SxpLib.Clean Connections    127.0.0.2
30     SxpLib.Add Connection    ${version}    listener    127.0.0.2    64999    127.0.0.1    security_mode=TLS
31     SxpLib.Add Connection    ${version}    speaker    127.0.0.1    64999    127.0.0.2    security_mode=TLS
32     BuiltIn.Wait Until Keyword Succeeds    120x    1s    SxpLib.Verify Connection    ${version}    listener    127.0.0.2
33     ...    64999    127.0.0.1
34     BuiltIn.Wait Until Keyword Succeeds    120x    1s    SxpLib.Verify Connection    ${version}    speaker    127.0.0.1
35     ...    64999    127.0.0.2
36     SxpLib.Clean Connections    127.0.0.1
37     SxpLib.Clean Connections    127.0.0.2
38     SxpLib.Add Connection    ${version}    both    127.0.0.2    64999    127.0.0.1    security_mode=TLS
39     SxpLib.Add Connection    ${version}    both    127.0.0.1    64999    127.0.0.2    security_mode=TLS
40     BuiltIn.Wait Until Keyword Succeeds    120x    1s    SxpLib.Verify Connection    ${version}    both    127.0.0.2
41     ...    64999    127.0.0.1
42     BuiltIn.Wait Until Keyword Succeeds    120x    1s    SxpLib.Verify Connection    ${version}    both    127.0.0.1
43     ...    64999    127.0.0.2
44
45 SSL ConectivityCase 2
46     [Documentation]    Test of SSL security with two SXP-nodes while node-1 does not contain node-3 in truststore
47     [Tags]    SXP    SSL
48     SxpLib.Add Connection    ${version}    speaker    127.0.0.3    64999    127.0.0.1    security_mode=TLS
49     SxpLib.Add Connection    ${version}    listener    127.0.0.1    64999    127.0.0.3    security_mode=TLS
50     WaitForFailure.Verify_Keyword_Never_Passes_Within_Timeout    60    1    SxpLib.Verify Connection    ${version}    speaker    127.0.0.3
51     ...    64999    127.0.0.1
52     WaitForFailure.Verify_Keyword_Never_Passes_Within_Timeout    60    1    SxpLib.Verify Connection    ${version}    listener    127.0.0.1
53     ...    64999    127.0.0.3
54     SxpLib.Clean Connections    127.0.0.1
55     SxpLib.Clean Connections    127.0.0.3
56     SxpLib.Add Connection    ${version}    listener    127.0.0.3    64999    127.0.0.1    security_mode=TLS
57     SxpLib.Add Connection    ${version}    speaker    127.0.0.1    64999    127.0.0.3    security_mode=TLS
58     WaitForFailure.Verify_Keyword_Never_Passes_Within_Timeout    60    1    SxpLib.Verify Connection    ${version}    listener    127.0.0.3
59     ...    64999    127.0.0.1
60     WaitForFailure.Verify_Keyword_Never_Passes_Within_Timeout    60    1    SxpLib.Verify Connection    ${version}    speaker    127.0.0.1
61     ...    64999    127.0.0.3
62     SxpLib.Clean Connections    127.0.0.1
63     SxpLib.Clean Connections    127.0.0.3
64     SxpLib.Add Connection    ${version}    both    127.0.0.3    64999    127.0.0.1    security_mode=TLS
65     SxpLib.Add Connection    ${version}    both    127.0.0.1    64999    127.0.0.3    security_mode=TLS
66     WaitForFailure.Verify_Keyword_Never_Passes_Within_Timeout    60    1    SxpLib.Verify Connection    ${version}    both    127.0.0.3
67     ...    64999    127.0.0.1
68     WaitForFailure.Verify_Keyword_Never_Passes_Within_Timeout    60    1    SxpLib.Verify Connection    ${version}    both    127.0.0.1
69     ...    64999    127.0.0.3
70
71 SSL ConectivityCase 3
72     [Documentation]    Test of SSL security with two SXP-nodes while both of nodes does not have each other in truststores
73     [Tags]    SXP    SSL
74     SxpLib.Add Connection    ${version}    speaker    127.0.0.4    64999    127.0.0.1    security_mode=TLS
75     SxpLib.Add Connection    ${version}    listener    127.0.0.1    64999    127.0.0.4    security_mode=TLS
76     WaitForFailure.Verify_Keyword_Never_Passes_Within_Timeout    60    1    SxpLib.Verify Connection    ${version}    speaker    127.0.0.4
77     ...    64999    127.0.0.1
78     WaitForFailure.Verify_Keyword_Never_Passes_Within_Timeout    60    1    SxpLib.Verify Connection    ${version}    listener    127.0.0.1
79     ...    64999    127.0.0.4
80     SxpLib.Clean Connections    127.0.0.1
81     SxpLib.Clean Connections    127.0.0.4
82     SxpLib.Add Connection    ${version}    listener    127.0.0.4    64999    127.0.0.1    security_mode=TLS
83     SxpLib.Add Connection    ${version}    speaker    127.0.0.1    64999    127.0.0.4    security_mode=TLS
84     WaitForFailure.Verify_Keyword_Never_Passes_Within_Timeout    60    1    SxpLib.Verify Connection    ${version}    listener    127.0.0.4
85     ...    64999    127.0.0.1
86     WaitForFailure.Verify_Keyword_Never_Passes_Within_Timeout    60    1    SxpLib.Verify Connection    ${version}    speaker    127.0.0.1
87     ...    64999    127.0.0.4
88     SxpLib.Clean Connections    127.0.0.1
89     SxpLib.Clean Connections    127.0.0.4
90     SxpLib.Add Connection    ${version}    both    127.0.0.4    64999    127.0.0.1    security_mode=TLS
91     SxpLib.Add Connection    ${version}    both    127.0.0.1    64999    127.0.0.4    security_mode=TLS
92     WaitForFailure.Verify_Keyword_Never_Passes_Within_Timeout    60    1    SxpLib.Verify Connection    ${version}    both    127.0.0.4
93     ...    64999    127.0.0.1
94     WaitForFailure.Verify_Keyword_Never_Passes_Within_Timeout    60    1    SxpLib.Verify Connection    ${version}    both    127.0.0.1
95     ...    64999    127.0.0.4
96
97 SSL ConectivityCase 4
98     [Documentation]    Test of SSL security in topology consisting of SXP-nodes that does not uses any security,
99     ...    uses TCP-MD5 and SSL security. Each node contains series of bindings that in the end should
100     ...    be all propagated to node-5 in topology.
101     [Tags]    SXP    SSL
102     SxpLib.Add Connection    ${version}    listener    127.0.0.2    64999    127.0.0.1    security_mode=TLS
103     SxpLib.Add Connection    ${version}    speaker    127.0.0.1    64999    127.0.0.2    security_mode=TLS
104     BuiltIn.Wait Until Keyword Succeeds    120x    1s    SxpLib.Verify Connection    ${version}    listener    127.0.0.2
105     ...    64999    127.0.0.1
106     BuiltIn.Wait Until Keyword Succeeds    120x    1s    SxpLib.Verify Connection    ${version}    speaker    127.0.0.1
107     ...    64999    127.0.0.2
108     SxpLib.Add Connection    ${version}    listener    127.0.0.3    64999    127.0.0.1    paswd
109     SxpLib.Add Connection    ${version}    speaker    127.0.0.1    64999    127.0.0.3    paswd
110     BuiltIn.Wait Until Keyword Succeeds    120x    1s    SxpLib.Verify Connection    ${version}    listener    127.0.0.3
111     ...    64999    127.0.0.1
112     BuiltIn.Wait Until Keyword Succeeds    120x    1s    SxpLib.Verify Connection    ${version}    speaker    127.0.0.1
113     ...    64999    127.0.0.3
114     SxpLib.Add Connection    ${version}    listener    127.0.0.4    64999    127.0.0.1
115     SxpLib.Add Connection    ${version}    speaker    127.0.0.1    64999    127.0.0.4
116     BuiltIn.Wait Until Keyword Succeeds    120x    1s    SxpLib.Verify Connection    ${version}    listener    127.0.0.4
117     ...    64999    127.0.0.1
118     BuiltIn.Wait Until Keyword Succeeds    120x    1s    SxpLib.Verify Connection    ${version}    speaker    127.0.0.1
119     ...    64999    127.0.0.4
120     SxpLib.Add Connection    ${version}    speaker    127.0.0.5    64999    127.0.0.1    security_mode=TLS
121     SxpLib.Add Connection    ${version}    listener    127.0.0.1    64999    127.0.0.5    security_mode=TLS
122     BuiltIn.Wait Until Keyword Succeeds    120x    1s    SxpLib.Verify Connection    ${version}    speaker    127.0.0.5
123     ...    64999    127.0.0.1
124     BuiltIn.Wait Until Keyword Succeeds    120x    1s    SxpLib.Verify Connection    ${version}    listener    127.0.0.1
125     ...    64999    127.0.0.5
126     BuiltIn.Wait Until Keyword Succeeds    120x    1s    Verify Topology Bindings    5
127
128 *** Keywords ***
129 Setup SXP Environment Local
130     [Arguments]    ${node_range}
131     [Documentation]    Create session to Controller, copy keystores to ODL machines and setup topology for testing
132     RequestsLibrary.Create Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}    timeout=${DEFAULT_TIMEOUT_HTTP}    max_retries=0
133     SSHKeywords.Open_Connection_To_ODL_System
134     ${ODL_SYSTEM_JAVA_HOME}    SSHLibrary.Execute_Command    java -XshowSettings:properties -version 2>&1 | grep java.home | sed 's/.*= //'
135     : FOR    ${node}    IN RANGE    1    ${node_range}+1
136     \    SSHKeywords.Execute_Command_Should_Pass    ${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}
137     \    SSHKeywords.Execute_Command_Should_Pass    ${ODL_SYSTEM_JAVA_HOME}/bin/keytool -exportcert -keystore csit-keystore-${node} -alias odl-sxp-${node} -storepass ${password} -file odl-sxp-${node}.cer
138     # Node-1 TRUSTS Node-2, Node-5
139     SSHKeywords.Execute_Command_Should_Pass    ${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
140     SSHKeywords.Execute_Command_Should_Pass    ${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
141     # Node-2 TRUSTS Node-1
142     SSHKeywords.Execute_Command_Should_Pass    ${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
143     # Node-3 TRUSTS Node-1
144     SSHKeywords.Execute_Command_Should_Pass    ${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
145     # Node-5 TRUSTS Node-1
146     SSHKeywords.Execute_Command_Should_Pass    ${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
147     SSHKeywords.Execute_Command_Should_Pass    cp csit-keystore-4 csit-truststore-4
148     SSHKeywords.Execute_Command_Should_Pass    rm odl-sxp-*.cer
149     SSHKeywords.Execute_Command_Should_Pass    mv ./csit-keystore-* ${ssl_stores}
150     SSHKeywords.Execute_Command_Should_Pass    mv ./csit-truststore-* ${ssl_stores}
151     SSHLibrary.Close Connection
152     : FOR    ${node}    IN RANGE    1    ${node_range}+1
153     \    ${SSL}    BuiltIn.Create Dictionary    truststore=${ssl_stores}/csit-truststore-${node}    keystore=${ssl_stores}/csit-keystore-${node}    password=${password}
154     \    ${rnd_retry_time} =    BuiltIn.Evaluate    random.randint(1, 5)    modules=random
155     \    SxpLib.Add Node    127.0.0.${node}    ${EMPTY}    ssl_stores=${SSL}    retry_open_timer=${rnd_retry_time}
156     \    BuiltIn.Wait Until Keyword Succeeds    20x    10s    SxpLib.Check Node started    127.0.0.${node}    system=${ODL_SYSTEM_IP}
157     \    SxpLib.Add Bindings    ${node}00    1.1.1.${node}/32    127.0.0.${node}
158     \    SxpLib.Add Bindings    ${node}00    2.2.2.${node}/32    127.0.0.${node}
159
160 Verify Topology Bindings
161     [Arguments]    ${node_range}
162     [Documentation]    Create session to Controller
163     ${resp}    SxpLib.Get Bindings    127.0.0.5
164     : FOR    ${node}    IN RANGE    1    ${node_range}+1
165     \    SxpLib.Should Contain Binding    ${resp}    ${node}00    1.1.1.${node}/32
166     \    SxpLib.Should Contain Binding    ${resp}    ${node}00    2.2.2.${node}/32
167
168 Clean Nodes
169     [Documentation]    Cleanup of resources alocated by test suite
170     SxpLib.Clean Connections    127.0.0.1
171     SxpLib.Clean Connections    127.0.0.2
172     SxpLib.Clean Connections    127.0.0.3
173     SxpLib.Clean Connections    127.0.0.4
174     SxpLib.Clean Connections    127.0.0.5