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