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