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