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