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