b71e0a62ed3ebf9e7c6b5d133277233f7fdfc5c2
[integration/test.git] / csit / suites / bgpcep / tcpmd5user / tcpmd5user.robot
1 *** Settings ***
2 Documentation       TCPMD5 user-facing feature system tests, using PCEP.
3 ...
4 ...                 Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
5 ...
6 ...                 This program and the accompanying materials are made available under the
7 ...                 terms of the Eclipse Public License v1.0 which accompanies this distribution,
8 ...                 and is available at http://www.eclipse.org/legal/epl-v10.html
9 ...
10 ...                 Test suite performs basic pcep md5 password authorization test cases:
11 ...                 (Run entire basic PCEP suite without passwords.)
12 ...                 Start pcc-mock (reconnecting mode): 1 pcc, 1 lsp, password set, check pcep-topology stays empty.
13 ...                 Use restconf to change PCEP configuration to use a wrong password, check pcep-topology stays empty.
14 ...                 Change ODL PCEP configuration to use the correct password, check pcep-topology shows the lsp.
15 ...                 Stop pcc-mock, check pcep-topology stays empty.
16 ...                 Start pcc-mock with new password, check pcep-topology stays empty.
17 ...                 Change ODL PCEP configuration to use the correct password, check pcep-topology shows the lsp.
18 ...                 Update the lsp, check a change in pcep-topology.
19 ...                 Change ODL PCEP configuration to not use password, pcep-topology empties, kill pcep-pcc-mock.
20 ...
21 ...                 Test cases no longer need netconf-connector-ssh, and they include comparison of
22 ...                 pcep-session-state.
23
24 Library             OperatingSystem
25 Library             RequestsLibrary
26 Library             SSHLibrary    prompt=]>
27 Resource            ../../../libraries/CompareStream.robot
28 Resource            ../../../libraries/FailFast.robot
29 Resource            ../../../libraries/KarafKeywords.robot
30 Resource            ../../../libraries/NexusKeywords.robot
31 Resource            ../../../libraries/TemplatedRequests.robot
32 Resource            ../../../libraries/RemoteBash.robot
33 Resource            ../../../libraries/WaitForFailure.robot
34 Resource            ../../../variables/Variables.robot
35 Variables           ../../../variables/tcpmd5user/${ODL_STREAM}/variables.py    ${TOOLS_SYSTEM_IP}
36
37 Suite Setup         Set_It_Up
38 Suite Teardown      Tear_It_Down
39 Test Setup          FailFast.Fail_This_Fast_On_Previous_Error
40 Test Teardown       FailFast.Start_Failing_Fast_If_This_Failed
41
42
43 *** Variables ***
44 ${DIR_WITH_TEMPLATES}       ${CURDIR}/../../../variables/tcpmd5user/${ODL_STREAM}
45 ${CONFIG_SESSION}           session
46 ${OLD_ERROR_ARGS}           \n"last-received-error": {},\n"last-sent-error": {},
47 ${NEW_ERROR_ARGS}           ${EMPTY}
48
49
50 *** Test Cases ***
51 Topology_Precondition
52     [Documentation]    Compare current pcep-topology to empty one.
53     ...    Timeout is long enough to see that pcep is ready, with no PCC connected.
54     [Tags]    critical
55     BuiltIn.Wait_Until_Keyword_Succeeds
56     ...    300s
57     ...    1s
58     ...    TemplatedRequests.Get_As_Json_Templated
59     ...    ${DIR_WITH_TEMPLATES}${/}default_off
60     ...    session=${CONFIG_SESSION}
61     ...    verify=True
62
63 Start_Secure_Pcc_Mock
64     [Documentation]    Execute pcc-mock on Mininet with password set, fail if pcc-mock promptly exits. Keep pcc-mock running for next test cases.
65     Start_Pcc_Mock_Tool_With_Password    password=topsecret
66
67 Topology_Unauthorized_1
68     [Documentation]    Try to catch a glimpse of pcc-mock in pcep-topology. Pass if no change from Precondition is detected over 10 seconds.
69     [Tags]    critical
70     WaitForFailure.Verify_Keyword_Does_Not_Fail_Within_Timeout    10s    1s    Test_Unauthorized
71
72 Set_Wrong_Password
73     [Documentation]    Configure password in pcep dispatcher for client with Mininet IP address.
74     ...    This password does not match what pcc-mock uses.
75     Replace_Password_On_Pcep_Node    password=changeme
76
77 Topology_Unauthorized_2
78     [Documentation]    The same logic as Topology_Unauthorized_1 as incorrect password was provided to ODL.
79     [Tags]    critical
80     WaitForFailure.Verify_Keyword_Does_Not_Fail_Within_Timeout    10s    1s    Test_Unauthorized
81
82 Set_Correct_Password
83     [Documentation]    Configure password in pcep dispatcher for client with Mininet IP address.
84     ...    This password finally matches what pcc-mock uses.
85     Replace_Password_On_Pcep_Node    password=topsecret
86
87 Topology_Intercondition
88     [Documentation]    Compare pcep-topology/path-computation-client to filled one, which includes a tunnel from pcc-mock.
89     &{mapping}    BuiltIn.Create_Dictionary
90     ...    IP=${TOOLS_SYSTEM_IP}
91     ...    CODE=${pcc_name_code}
92     ...    NAME=${pcc_name}
93     ...    IP_ODL=${ODL_SYSTEM_IP}
94     ...    ERRORS=${ERROR_ARGS}
95     BuiltIn.Wait_Until_Keyword_Succeeds
96     ...    30s
97     ...    1s
98     ...    TemplatedRequests.Get_As_Json_Templated
99     ...    ${DIR_WITH_TEMPLATES}${/}default_on_state
100     ...    ${mapping}
101     ...    ${CONFIG_SESSION}
102     ...    verify=True
103
104 Stop_Pcc_Mock_1
105     [Documentation]    Stops First instance of pcc-mock.
106     [Setup]    FailFast.Run_Even_When_Failing_Fast
107     Stop_Pcc_Mock_Tool
108     FailFast.Do_Not_Fail_Fast_From_Now_On
109     # NOTE: It is still possible to remain failing, if both previous and this test failed.
110     [Teardown]    FailFast.Do_Not_Start_Failing_If_This_Failed
111
112 Topology_Unauthorized_3
113     [Documentation]    The same logic as Topology_Unauthorized_1, with no pcc-mock running.
114     [Tags]    critical
115     BuiltIn.Wait_Until_Keyword_Succeeds    10s    1s    Test_Unauthorized
116
117 Start_Secure_Pcc_Mock_2
118     [Documentation]    Execute pcc-mock on Mininet with new password set, fail if pcc-mock promptly exits. Keep pcc-mock running for next test cases.
119     Start_Pcc_Mock_Tool_With_Password    password=newtopsecret
120
121 Topology_Unauthorized_4
122     [Documentation]    The same logic as Topology_Unauthorized_1, but ODL password became incorrect with new pcc-mock running.
123     [Tags]    critical
124     WaitForFailure.Verify_Keyword_Does_Not_Fail_Within_Timeout    10s    1s    Test_Unauthorized
125
126 Set_Correct_Password_2
127     [Documentation]    Configure password in pcep dispatcher for client with Mininet IP address.
128     ...    This password again matches what second pcc-mock instance uses.
129     Replace_Password_On_Pcep_Node    password=newtopsecret
130
131 Topology_Intercondition_2
132     [Documentation]    Compare pcep-topology/path-computation-client to filled one, which includes a tunnel from pcc-mock.
133     &{mapping}    BuiltIn.Create_Dictionary
134     ...    IP=${TOOLS_SYSTEM_IP}
135     ...    CODE=${pcc_name_code}
136     ...    NAME=${pcc_name}
137     ...    IP_ODL=${ODL_SYSTEM_IP}
138     ...    ERRORS=${ERROR_ARGS}
139     BuiltIn.Wait_Until_Keyword_Succeeds
140     ...    30s
141     ...    1s
142     ...    TemplatedRequests.Get_As_Json_Templated
143     ...    ${DIR_WITH_TEMPLATES}${/}default_on_state
144     ...    ${mapping}
145     ...    ${CONFIG_SESSION}
146     ...    verify=True
147
148 Update_Delegated
149     [Documentation]    Perform update-lsp on the mocked tunnel, check response is success.
150     &{mapping}    BuiltIn.Create_Dictionary    IP=${TOOLS_SYSTEM_IP}    NAME=${pcc_name}
151     ${response}    TemplatedRequests.Post_As_Xml_Templated
152     ...    ${DIR_WITH_TEMPLATES}${/}update_delegated
153     ...    ${mapping}
154     ...    ${CONFIG_SESSION}
155     ...    verify=False
156     Log    ${response}
157
158 Topology_Updated
159     [Documentation]    Compare pcep-topology/path-computation-client to default_on_updated, which includes the updated tunnel.
160     [Tags]    critical
161     &{mapping}    BuiltIn.Create_Dictionary
162     ...    IP=${TOOLS_SYSTEM_IP}
163     ...    CODE=${pcc_name_code}
164     ...    NAME=${pcc_name}
165     ...    IP_ODL=${ODL_SYSTEM_IP}
166     ...    ERRORS=${ERROR_ARGS}
167     BuiltIn.Wait_Until_Keyword_Succeeds
168     ...    30s
169     ...    1s
170     ...    TemplatedRequests.Get_As_Json_Templated
171     ...    ${DIR_WITH_TEMPLATES}${/}default_on_updated_state
172     ...    ${mapping}
173     ...    ${CONFIG_SESSION}
174     ...    verify=True
175
176 Unset_Password
177     [Documentation]    De-configure password for pcep dispatcher for client with Mininet IP address.
178     [Setup]    FailFast.Run_Even_When_Failing_Fast
179     Unset_Password_On_Pcep_Node
180     FailFast.Do_Not_Fail_Fast_From_Now_On
181     # NOTE: It is still possible to remain failing, if both previous and this test failed.
182     [Teardown]    FailFast.Do_Not_Start_Failing_If_This_Failed
183
184 Topology_Unauthorized_5
185     [Documentation]    Wait for pcep-topology to become empty again.
186     [Tags]    critical
187     BuiltIn.Wait_Until_Keyword_Succeeds    10s    1s    Test_Unauthorized
188
189 Stop_Pcc_Mock_2
190     [Documentation]    Stops second instance of pcc-mock
191     [Setup]    FailFast.Run_Even_When_Failing_Fast
192     Stop_Pcc_Mock_Tool
193     FailFast.Do_Not_Fail_Fast_From_Now_On
194     # NOTE: It is still possible to remain failing, if both previous and this test failed.
195     [Teardown]    FailFast.Do_Not_Start_Failing_If_This_Failed
196
197 Topology_Postcondition
198     [Documentation]    Verify that pcep-topology stays empty.
199     [Tags]    critical
200     WaitForFailure.Verify_Keyword_Does_Not_Fail_Within_Timeout    10s    1s    Test_Unauthorized
201
202 Delete_Pcep_Client_Module
203     [Documentation]    Delete Pcep client module.
204     &{mapping}    BuiltIn.Create_Dictionary    IP=${TOOLS_SYSTEM_IP}
205     TemplatedRequests.Delete_Templated    ${DIR_WITH_TEMPLATES}${/}pcep_topology_node    ${mapping}
206
207
208 *** Keywords ***
209 Set_It_Up
210     [Documentation]    Create SSH session to Mininet machine, prepare HTTP client session to Controller.
211     ...    Figure out latest pcc-mock version and download it from Nexus to Mininet.
212     ...    Also, delete and create directories for json diff handling.
213     KarafKeywords.Setup_Karaf_Keywords
214     TemplatedRequests.Create_Default_Session
215     NexusKeywords.Initialize_Artifact_Deployment_And_Usage
216     ${current_connection}    SSHLibrary.Get_Connection
217     ${current_prompt}    BuiltIn.Set_Variable    ${current_connection.prompt}
218     BuiltIn.Log    ${current_prompt}
219     BuiltIn.Set_Suite_Variable    ${prompt}    ${current_prompt}
220     RequestsLibrary.Create_Session    ${CONFIG_SESSION}    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}
221     ${name}    NexusKeywords.Deploy_Test_Tool    bgpcep    pcep-pcc-mock
222     BuiltIn.Set_Suite_Variable    ${filename}    ${name}
223     #Setting Pcc Name and its code for mapping for templates
224     FailFast.Do_Not_Fail_Fast_From_Now_On
225     ${ERROR_ARGS}    CompareStream.Set_Variable_If_At_Least_Neon    ${NEW_ERROR_ARGS}    ${OLD_ERROR_ARGS}
226     BuiltIn.Set_Suite_Variable    ${ERROR_ARGS}
227
228 Tear_It_Down
229     [Documentation]    Download pccmock.log and Log its contents.
230     ...    Compute and Log the diff between expected and actual normalized responses.
231     ...    Close both HTTP client session and SSH connection to Mininet.
232     SSHLibrary.Get_File    pccmock.log
233     ${pccmocklog}    OperatingSystem.Run    cat pccmock.log
234     BuiltIn.Log    ${pccmocklog}
235     RequestsLibrary.Delete_All_Sessions
236     SSHLibrary.Close_All_Connections
237
238 Test_Unauthorized
239     [Documentation]    Try to access pcep topology with wrong password, should get empty topology
240     TemplatedRequests.Get_As_Json_Templated
241     ...    ${DIR_WITH_TEMPLATES}${/}default_off
242     ...    session=${CONFIG_SESSION}
243     ...    verify=True
244
245 Read_Text_Before_Prompt
246     [Documentation]    Log text gathered by SSHLibrary.Read_Until_Prompt.
247     ...    This needs to be a separate keyword just because how Read_And_Fail_If_Prompt_Is_Seen is implemented.
248     ${text}    SSHLibrary.Read_Until_Prompt
249     BuiltIn.Log    ${text}
250
251 Replace_Password_On_Pcep_Node
252     [Documentation]    Send restconf PUT to replace the config module specifying PCEP password element.
253     [Arguments]    ${password}
254     &{mapping}    BuiltIn.Create_Dictionary    IP=${TOOLS_SYSTEM_IP}    PASSWD=${password}
255     TemplatedRequests.Put_As_Xml_Templated    ${DIR_WITH_TEMPLATES}${/}pcep_topology_node    mapping=${mapping}
256
257 Unset_Password_On_Pcep_Node
258     [Documentation]    Send restconf PUT to unset the config module.
259     &{mapping}    BuiltIn.Create_Dictionary    IP=${TOOLS_SYSTEM_IP}
260     TemplatedRequests.Put_As_Xml_Templated    ${DIR_WITH_TEMPLATES}${/}pcep_topology_node_empty    mapping=${mapping}
261
262 Stop_Pcc_Mock_Tool
263     [Documentation]    Send ctrl+c to pcc-mock, fails if no prompt is seen
264     ...    after 3 seconds (the default for SSHLibrary)
265     RemoteBash.Write_Bare_Ctrl_C
266     ${output}    SSHLibrary.Read_Until_Prompt
267     BuiltIn.Log    ${output}
268
269 Start_Pcc_Mock_Tool_With_Password
270     [Documentation]    Starts pcc-mock with password argument.
271     [Arguments]    ${password}
272     ${command}    NexusKeywords.Compose_Full_Java_Command
273     ...    -jar ${filename} --password ${password} --reconnect 1 --local-address ${TOOLS_SYSTEM_IP} --remote-address ${ODL_SYSTEM_IP} 2>&1 | tee pccmock.log
274     BuiltIn.Log    ${command}
275     SSHLibrary.Write    ${command}