]> git.proxmox.com Git - mirror_frr.git/blame - tests/topotests/ospf_basic_functionality/test_ospf_authentication.py
tests: Disable test which fails under micronet
[mirror_frr.git] / tests / topotests / ospf_basic_functionality / test_ospf_authentication.py
CommitLineData
4256a209 1#!/usr/bin/python
2
3#
4# Copyright (c) 2020 by VMware, Inc. ("VMware")
5# Used Copyright (c) 2018 by Network Device Education Foundation, Inc.
6# ("NetDEF") in this file.
7#
8# Permission to use, copy, modify, and/or distribute this software
9# for any purpose with or without fee is hereby granted, provided
10# that the above copyright notice and this permission notice appear
11# in all copies.
12#
13# THE SOFTWARE IS PROVIDED "AS IS" AND VMWARE DISCLAIMS ALL WARRANTIES
14# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL VMWARE BE LIABLE FOR
16# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
17# DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
18# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
19# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
20# OF THIS SOFTWARE.
21#
22
23
24"""OSPF Basic Functionality Automation."""
25import os
26import sys
27import time
28import pytest
29from time import sleep
30from copy import deepcopy
31import json
9fd80543 32from lib.topotest import frr_unicode
4256a209 33
34# Save the Current Working Directory to find configuration files.
35CWD = os.path.dirname(os.path.realpath(__file__))
36sys.path.append(os.path.join(CWD, "../"))
37sys.path.append(os.path.join(CWD, "../lib/"))
38
39# pylint: disable=C0413
40# Import topogen and topotest helpers
8db751b8 41from lib.micronet_compat import Topo
4256a209 42from lib.topogen import Topogen, get_topogen
43
44# Import topoJson from lib, to create topology and initial configuration
45from lib.common_config import (
46 start_topology,
47 write_test_header,
48 write_test_footer,
49 reset_config_on_routers,
50 step,
51 shutdown_bringup_interface,
701a0192 52 topo_daemons,
4256a209 53)
54from lib.topolog import logger
55from lib.topojson import build_topo_from_json, build_config_from_json
56from lib.ospf import verify_ospf_neighbor, config_ospf_interface, clear_ospf
57from ipaddress import IPv4Address
58
6ff492b1
DS
59pytestmark = [pytest.mark.ospfd]
60
61
4256a209 62# Global variables
63topo = None
4256a209 64"""
65TOPOOLOGY =
66 Please view in a fixed-width font such as Courier.
67 +---+ A1 +---+
68 +R1 +------------+R2 |
69 +-+-+- +--++
70 | -- -- |
71 | -- A0 -- |
72 A0| ---- |
73 | ---- | A2
74 | -- -- |
75 | -- -- |
76 +-+-+- +-+-+
77 +R0 +-------------+R3 |
78 +---+ A3 +---+
79
80TESTCASES =
811. Verify ospf authentication with Simple password authentication.
822. Verify ospf authentication with MD5 authentication.
833. Verify ospf authentication with different authentication methods.
84
85 """
86
87
4256a209 88def setup_module(mod):
89 """
90 Sets up the pytest environment
91
92 * `mod`: module name
93 """
4256a209 94 testsuite_run_time = time.asctime(time.localtime(time.time()))
95 logger.info("Testsuite start time: {}".format(testsuite_run_time))
96 logger.info("=" * 40)
97
98 logger.info("Running setup_module to create topology")
99
100 # This function initiates the topology build with Topogen...
e82b531d
CH
101 json_file = "{}/ospf_authentication.json".format(CWD)
102 tgen = Topogen(json_file, mod.__name__)
103 global topo
104 topo = tgen.json_topo
4256a209 105 # ... and here it calls Mininet initialization functions.
106
035267a3 107 # get list of daemons needs to be started for this suite.
108 daemons = topo_daemons(tgen, topo)
109
4256a209 110 # Starting topology, create tmp files which are loaded to routers
111 # to start deamons and then start routers
035267a3 112 start_topology(tgen, daemons)
4256a209 113
114 # Creating configuration from JSON
115 build_config_from_json(tgen, topo)
116
117 # Don't run this test if we have any failure.
118 if tgen.routers_have_failure():
119 pytest.skip(tgen.errors)
120
121 ospf_covergence = verify_ospf_neighbor(tgen, topo)
122 assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format(
123 ospf_covergence
124 )
125
126 logger.info("Running setup_module() done")
127
128
129def teardown_module(mod):
130 """
131 Teardown the pytest environment.
132
133 * `mod`: module name
134 """
135
136 logger.info("Running teardown_module to delete topology")
137
138 tgen = get_topogen()
139
140 # Stop toplogy and Remove tmp files
141 tgen.stop_topology()
142
143 logger.info(
144 "Testsuite end time: {}".format(time.asctime(time.localtime(time.time())))
145 )
146 logger.info("=" * 40)
147
148
149# ##################################
150# Test cases start here.
151# ##################################
152
153
154def test_ospf_authentication_simple_pass_tc28_p1(request):
155 """
156 OSPF Authentication - Verify ospf authentication with Simple
157 password authentication.
158
159 """
160 tc_name = request.node.name
161 write_test_header(tc_name)
162 tgen = get_topogen()
163 global topo
164 step("Bring up the base config.")
165 reset_config_on_routers(tgen)
166 step(
167 "Configure ospf with on R1 and R2, enable ospf on R1 interface"
168 "connected to R2 with simple password authentication using ip ospf "
169 "authentication Simple password cmd."
170 )
171
172 r1_ospf_auth = {
173 "r1": {
174 "links": {
175 "r2": {"ospf": {"authentication": True, "authentication-key": "ospf"}}
176 }
177 }
178 }
179 result = config_ospf_interface(tgen, topo, r1_ospf_auth)
180 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
181
182 step("clear ip ospf after configuring the authentication.")
183 clear_ospf(tgen, "r1")
184
185 step("Verify that the neighbour is not FULL between R1 and R2.")
186 dut = "r1"
a81774ec 187 ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut, expected=False)
4256a209 188 assert ospf_covergence is not True, "setup_module :Failed \n Error:" " {}".format(
189 ospf_covergence
190 )
191
192 step(
193 "On R2 enable ospf on interface with simple password authentication "
194 "using ip ospf authentication Simple password cmd."
195 )
196
197 r2_ospf_auth = {
198 "r2": {
199 "links": {
200 "r1": {"ospf": {"authentication": True, "authentication-key": "ospf"}}
201 }
202 }
203 }
204 result = config_ospf_interface(tgen, topo, r2_ospf_auth)
205 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
206
207 step(
208 "Verify that the neighbour is FULL between R1 and R2 "
209 "using show ip ospf neighbor cmd."
210 )
211
212 dut = "r2"
213 ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut)
214 assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format(
215 ospf_covergence
216 )
217
218 step(
219 "Disable simple password authentication on R2 using no ip ospf "
220 "authentication Simple password cmd."
221 )
222 r2_ospf_auth = {
223 "r2": {
224 "links": {
225 "r1": {
226 "ospf": {
227 "authentication": True,
228 "authentication-key": "ospf",
229 "del_action": True,
230 }
231 }
232 }
233 }
234 }
235 result = config_ospf_interface(tgen, topo, r2_ospf_auth)
236 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
237
238 step("Verify on R1 neighbour is deleted for R2 after dead interval expiry")
a81774ec 239 # wait till the dead time expiry
240 sleep(6)
4256a209 241 dut = "r2"
a81774ec 242 ospf_covergence = verify_ospf_neighbor(
ed776e38 243 tgen, topo, dut=dut, expected=False, retry_timeout=10
a81774ec 244 )
4256a209 245 assert ospf_covergence is not True, "setup_module :Failed \n Error:" " {}".format(
246 ospf_covergence
247 )
248
249 step("Again On R2 enable ospf on interface with Simple password auth")
250 r2_ospf_auth = {
251 "r2": {
252 "links": {
253 "r1": {"ospf": {"authentication": True, "authentication-key": "ospf"}}
254 }
255 }
256 }
257 result = config_ospf_interface(tgen, topo, r2_ospf_auth)
258 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
259
260 step(
261 "Verify that the neighbour is FULL between R1 and R2 using"
262 " show ip ospf neighbor cmd."
263 )
264
265 dut = "r2"
266 ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut)
267 assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format(
268 ospf_covergence
269 )
270
271 step("Shut no shut interface on R1")
272 dut = "r1"
273 intf = topo["routers"]["r1"]["links"]["r2"]["interface"]
274 shutdown_bringup_interface(tgen, dut, intf, False)
275
276 dut = "r2"
277 step(
278 "Verify that the neighbour is not FULL between R1 and R2 using "
279 "show ip ospf neighbor cmd."
280 )
281 ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut, expected=False)
282 assert ospf_covergence is not True, "setup_module :Failed \n Error:" " {}".format(
283 ospf_covergence
284 )
285
286 dut = "r1"
287 shutdown_bringup_interface(tgen, dut, intf, True)
288
289 step(
290 "Verify that the neighbour is FULL between R1 and R2 using "
291 "show ip ospf neighbor cmd."
292 )
293
294 dut = "r2"
295 ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut)
296 assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format(
297 ospf_covergence
298 )
299
300 step("Change Ip address on R1 and R2")
301
302 topo_modify_change_ip = deepcopy(topo)
303 intf_ip = topo_modify_change_ip["routers"]["r1"]["links"]["r2"]["ipv4"]
304 topo_modify_change_ip["routers"]["r1"]["links"]["r2"]["ipv4"] = str(
9fd80543 305 IPv4Address(frr_unicode(intf_ip.split("/")[0])) + 3
4256a209 306 ) + "/{}".format(intf_ip.split("/")[1])
307
308 build_config_from_json(tgen, topo_modify_change_ip, save_bkup=False)
309
310 reset_config_on_routers(tgen, routerName="r1")
311 dut = "r1"
312 intf = topo["routers"]["r1"]["links"]["r2"]["interface"]
313 shutdown_bringup_interface(tgen, dut, intf, False)
4256a209 314 shutdown_bringup_interface(tgen, dut, intf, True)
315
316 # clear ip ospf after configuring the authentication.
317 clear_ospf(tgen, "r1")
318
319 r1_ospf_auth = {
320 "r1": {
321 "links": {
322 "r2": {"ospf": {"authentication": True, "authentication-key": "ospf"}}
323 }
324 }
325 }
326 result = config_ospf_interface(tgen, topo, r1_ospf_auth)
327 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
328
329 step(
330 "Verify that the neighbour is FULL between R1 and R2 with new "
331 "ip address using show ip ospf "
332 )
333
334 dut = "r1"
335 ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut)
336 assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format(
337 ospf_covergence
338 )
339
340 write_test_footer(tc_name)
341
342
343def test_ospf_authentication_md5_tc29_p1(request):
344 """
345 OSPF Authentication - Verify ospf authentication with MD5 authentication.
346
347 """
348 tc_name = request.node.name
349 write_test_header(tc_name)
350 tgen = get_topogen()
351 global topo
352 step("Bring up the base config.")
353 reset_config_on_routers(tgen)
354 step(
355 "Configure ospf with on R1 and R2, enable ospf on R1 interface "
356 "connected to R2 with message-digest authentication using ip "
357 "ospf authentication message-digest cmd."
358 )
359
360 r1_ospf_auth = {
361 "r1": {
362 "links": {
363 "r2": {
364 "ospf": {
365 "authentication": "message-digest",
366 "authentication-key": "ospf",
367 "message-digest-key": "10",
368 }
369 }
370 }
371 }
372 }
373 result = config_ospf_interface(tgen, topo, r1_ospf_auth)
374 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
375
4256a209 376 step("Verify that the neighbour is not FULL between R1 and R2.")
a81774ec 377 # wait for dead time expiry.
378 sleep(6)
4256a209 379 dut = "r1"
a81774ec 380 ospf_covergence = verify_ospf_neighbor(
ed776e38 381 tgen, topo, dut=dut, expected=False, retry_timeout=6
a81774ec 382 )
4256a209 383 assert ospf_covergence is not True, "setup_module :Failed \n Error:" " {}".format(
384 ospf_covergence
385 )
386
387 step(
388 "On R2 enable ospf on interface with message-digest authentication"
389 " using ip ospf authentication message-digest password cmd."
390 )
391
392 r2_ospf_auth = {
393 "r2": {
394 "links": {
395 "r1": {
396 "ospf": {
397 "authentication": "message-digest",
398 "authentication-key": "ospf",
399 "message-digest-key": "10",
400 }
401 }
402 }
403 }
404 }
405 result = config_ospf_interface(tgen, topo, r2_ospf_auth)
406 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
407
408 step(
409 "Verify that the neighbour is FULL between R1 and R2 "
410 "using show ip ospf neighbor cmd."
411 )
412
413 dut = "r2"
414 ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut)
415 assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format(
416 ospf_covergence
417 )
418
419 step(
420 "Disable message-digest authentication on R2 using no ip ospf "
421 "authentication message-digest password cmd."
422 )
423
424 r2_ospf_auth = {
425 "r2": {
426 "links": {
427 "r1": {
428 "ospf": {
429 "authentication": "message-digest",
430 "authentication-key": "ospf",
431 "message-digest-key": "10",
432 "del_action": True,
433 }
434 }
435 }
436 }
437 }
438 result = config_ospf_interface(tgen, topo, r2_ospf_auth)
439 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
440
441 step("Verify on R1 ,nbr is deleted for R2 after dead interval expiry")
a81774ec 442 # wait till the dead timer expiry
443 sleep(6)
4256a209 444 dut = "r2"
a81774ec 445 ospf_covergence = verify_ospf_neighbor(
ed776e38 446 tgen, topo, dut=dut, expected=False, retry_timeout=10
a81774ec 447 )
4256a209 448 assert ospf_covergence is not True, "setup_module :Failed \n Error:" " {}".format(
449 ospf_covergence
450 )
451
452 step("Again On R2 enable ospf on interface with message-digest auth")
453 r2_ospf_auth = {
454 "r2": {
455 "links": {
456 "r1": {
457 "ospf": {
458 "authentication": "message-digest",
459 "authentication-key": "ospf",
460 "message-digest-key": "10",
461 }
462 }
463 }
464 }
465 }
466 result = config_ospf_interface(tgen, topo, r2_ospf_auth)
467 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
468
469 step(
470 "Verify that the neighbour is FULL between R1 and R2 using"
471 " show ip ospf neighbor cmd."
472 )
473
474 dut = "r2"
475 ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut)
476 assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format(
477 ospf_covergence
478 )
479
480 step("Shut no shut interface on R1")
481 dut = "r1"
482 intf = topo["routers"]["r1"]["links"]["r2"]["interface"]
483 shutdown_bringup_interface(tgen, dut, intf, False)
484
485 dut = "r2"
486 step(
487 "Verify that the neighbour is not FULL between R1 and R2 using "
488 "show ip ospf neighbor cmd."
489 )
490 ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut, expected=False)
491 assert ospf_covergence is not True, "setup_module :Failed \n Error:" " {}".format(
492 ospf_covergence
493 )
494
495 dut = "r1"
496 shutdown_bringup_interface(tgen, dut, intf, True)
497
498 step(
499 "Verify that the neighbour is FULL between R1 and R2 using "
500 "show ip ospf neighbor cmd."
501 )
502
503 dut = "r2"
504 ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut)
505 assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format(
506 ospf_covergence
507 )
508
509 step("Change Ip address on R1 and R2")
510
511 topo_modify_change_ip = deepcopy(topo)
512
513 intf_ip = topo_modify_change_ip["routers"]["r1"]["links"]["r2"]["ipv4"]
514
515 topo_modify_change_ip["routers"]["r1"]["links"]["r2"]["ipv4"] = str(
9fd80543 516 IPv4Address(frr_unicode(intf_ip.split("/")[0])) + 3
4256a209 517 ) + "/{}".format(intf_ip.split("/")[1])
518
519 build_config_from_json(tgen, topo_modify_change_ip, save_bkup=False)
520
521 reset_config_on_routers(tgen, routerName="r1")
522 dut = "r1"
523 intf = topo["routers"]["r1"]["links"]["r2"]["interface"]
524 shutdown_bringup_interface(tgen, dut, intf, False)
4256a209 525 shutdown_bringup_interface(tgen, dut, intf, True)
526 clear_ospf(tgen, "r1")
527 r1_ospf_auth = {
528 "r1": {
529 "links": {
530 "r2": {
531 "ospf": {
532 "authentication": "message-digest",
533 "authentication-key": "ospf",
534 "message-digest-key": "10",
535 }
536 }
537 }
538 }
539 }
540 result = config_ospf_interface(tgen, topo, r1_ospf_auth)
541 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
542
543 step(
544 "Verify that the neighbour is FULL between R1 and R2 with new "
545 "ip address using show ip ospf "
546 )
547
548 dut = "r1"
549 ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut)
550 assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format(
551 ospf_covergence
552 )
553
554 write_test_footer(tc_name)
555
556
557def test_ospf_authentication_different_auths_tc30_p1(request):
558 """
559 OSPF Authentication - Verify ospf authentication with different
560 authentication methods.
561
562 """
563 tc_name = request.node.name
564 write_test_header(tc_name)
565 tgen = get_topogen()
566 global topo
567 step("Bring up the base config.")
568 reset_config_on_routers(tgen)
569 step(
570 "Configure ospf with on R1 and R2, enable ospf on R1 interface "
571 "connected to R2 with message-digest authentication using ip "
572 "ospf authentication message-digest cmd."
573 )
574
575 r1_ospf_auth = {
576 "r1": {
577 "links": {
578 "r2": {
579 "ospf": {
580 "authentication": "message-digest",
581 "authentication-key": "ospf",
582 "message-digest-key": "10",
583 }
584 }
585 }
586 }
587 }
588 result = config_ospf_interface(tgen, topo, r1_ospf_auth)
589 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
590
a81774ec 591 # wait for dead timer expiry
592 sleep(6)
4256a209 593 step("Verify that the neighbour is not FULL between R1 and R2.")
4256a209 594 dut = "r1"
a81774ec 595 ospf_covergence = verify_ospf_neighbor(
ed776e38 596 tgen, topo, dut=dut, expected=False, retry_timeout=10
a81774ec 597 )
4256a209 598 assert ospf_covergence is not True, "setup_module :Failed \n Error:" " {}".format(
599 ospf_covergence
600 )
601
602 step(
603 "On R2 enable ospf on interface with message-digest authentication"
604 " using ip ospf authentication message-digest password cmd."
605 )
606
607 r2_ospf_auth = {
608 "r2": {
609 "links": {
610 "r1": {
611 "ospf": {
612 "authentication": "message-digest",
613 "authentication-key": "ospf",
614 "message-digest-key": "10",
615 }
616 }
617 }
618 }
619 }
620 result = config_ospf_interface(tgen, topo, r2_ospf_auth)
621 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
622
623 step(
624 "Verify that the neighbour is FULL between R1 and R2 "
625 "using show ip ospf neighbor cmd."
626 )
627
628 dut = "r2"
629 ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut)
630 assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format(
631 ospf_covergence
632 )
633
634 step(" Delete the configured password on both the routers.")
635
636 r2_ospf_auth = {
637 "r2": {
638 "links": {
639 "r1": {
640 "ospf": {
641 "authentication": "message-digest",
642 "authentication-key": "ospf",
643 "message-digest-key": "10",
644 "del_action": True,
645 }
646 }
647 }
648 }
649 }
650 result = config_ospf_interface(tgen, topo, r2_ospf_auth)
651 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
652
653 r1_ospf_auth = {
654 "r1": {
655 "links": {
656 "r2": {
657 "ospf": {
658 "authentication": "message-digest",
659 "authentication-key": "ospf",
660 "message-digest-key": "10",
661 "del_action": True,
662 }
663 }
664 }
665 }
666 }
667 result = config_ospf_interface(tgen, topo, r1_ospf_auth)
668 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
669
670 step(
671 "Verify that the deletion is successful and neighbour is FULL"
672 " between R1 and R2 using show ip ospf neighbor cmd."
673 )
674
675 dut = "r2"
676 ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut)
677 assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format(
678 ospf_covergence
679 )
680
681 step("Change the authentication type to simple password.")
682 r1_ospf_auth = {
683 "r1": {
684 "links": {
685 "r2": {"ospf": {"authentication": True, "authentication-key": "ospf"}}
686 }
687 }
688 }
689 result = config_ospf_interface(tgen, topo, r1_ospf_auth)
690 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
691
692 r2_ospf_auth = {
693 "r2": {
694 "links": {
695 "r1": {"ospf": {"authentication": True, "authentication-key": "ospf"}}
696 }
697 }
698 }
699 result = config_ospf_interface(tgen, topo, r2_ospf_auth)
700 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
701
702 step(
703 "Verify that the deletion is successful and neighbour is"
704 " FULL between R1 and R2 using show ip "
705 )
706
707 dut = "r2"
708 ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut)
709 assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format(
710 ospf_covergence
711 )
712
713 step("Change the password in simple password.")
714
715 r1_ospf_auth = {
716 "r1": {
717 "links": {
718 "r2": {"ospf": {"authentication": True, "authentication-key": "OSPFv4"}}
719 }
720 }
721 }
722 result = config_ospf_interface(tgen, topo, r1_ospf_auth)
723 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
724
725 r2_ospf_auth = {
726 "r2": {
727 "links": {
728 "r1": {"ospf": {"authentication": True, "authentication-key": "OSPFv4"}}
729 }
730 }
731 }
732 result = config_ospf_interface(tgen, topo, r2_ospf_auth)
733 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
734
735 step(
736 "Verify that the deletion is successful and neighbour is"
737 " FULL between R1 and R2 using show ip "
738 )
739
740 dut = "r2"
741 ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut)
742 assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format(
743 ospf_covergence
744 )
745
746 step("Delete the password authentication on the interface ")
747
748 r1_ospf_auth = {
749 "r1": {
750 "links": {
751 "r2": {
752 "ospf": {
753 "authentication": True,
754 "authentication-key": "OSPFv4",
755 "del_action": True,
756 }
757 }
758 }
759 }
760 }
761 result = config_ospf_interface(tgen, topo, r1_ospf_auth)
762 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
763
764 r2_ospf_auth = {
765 "r2": {
766 "links": {
767 "r1": {
768 "ospf": {
769 "authentication": True,
770 "authentication-key": "OSPFv4",
771 "del_action": True,
772 }
773 }
774 }
775 }
776 }
777 result = config_ospf_interface(tgen, topo, r2_ospf_auth)
778 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
779
780 step(
781 "Verify that the deletion is successful and neighbour is"
782 " FULL between R1 and R2 using show ip "
783 )
784
785 dut = "r2"
786 ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut)
787 assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format(
788 ospf_covergence
789 )
790
791 step("Enable Md5 authentication on the interface")
792
793 r1_ospf_auth = {
794 "r1": {
795 "links": {
796 "r2": {
797 "ospf": {
798 "authentication": "message-digest",
799 "authentication-key": "ospf",
800 "message-digest-key": "10",
801 }
802 }
803 }
804 }
805 }
806 result = config_ospf_interface(tgen, topo, r1_ospf_auth)
807 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
808
809 r2_ospf_auth = {
810 "r2": {
811 "links": {
812 "r1": {
813 "ospf": {
814 "authentication": "message-digest",
815 "authentication-key": "ospf",
816 "message-digest-key": "10",
817 }
818 }
819 }
820 }
821 }
822 result = config_ospf_interface(tgen, topo, r2_ospf_auth)
823 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
824
825 step(
826 "Verify that the neighbour is FULL between R1 and R2 using"
827 " show ip ospf neighbor cmd."
828 )
829
830 dut = "r2"
831 ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut)
832 assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format(
833 ospf_covergence
834 )
835
836 step("Change the MD5 authentication password")
837
838 r1_ospf_auth = {
839 "r1": {
840 "links": {
841 "r2": {
842 "ospf": {
843 "authentication": "message-digest",
844 "authentication-key": "OSPFv4",
845 "message-digest-key": "10",
846 }
847 }
848 }
849 }
850 }
851 result = config_ospf_interface(tgen, topo, r1_ospf_auth)
852 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
853
854 r2_ospf_auth = {
855 "r2": {
856 "links": {
857 "r1": {
858 "ospf": {
859 "authentication": "message-digest",
860 "authentication-key": "OSPFv4",
861 "message-digest-key": "10",
862 }
863 }
864 }
865 }
866 }
867 result = config_ospf_interface(tgen, topo, r2_ospf_auth)
868 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
869
870 write_test_footer(tc_name)
871
872
873if __name__ == "__main__":
874 args = ["-s"] + sys.argv[1:]
875 sys.exit(pytest.main(args))