Skip to content

Commit e413c77

Browse files
committed
Add base class implementation for local users' passwords reset
1 parent 655a5ff commit e413c77

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
'''
2+
local_users_passwords_reset_base.py
3+
4+
Abstract base class for implementing platform-specific
5+
local users' passwords reset base functionality for SONiC
6+
'''
7+
8+
9+
class LocalUsersConfigurationResetBase(object):
10+
"""
11+
Abstract base class for resetting local users' passwords on the switch
12+
"""
13+
def should_trigger(self):
14+
'''
15+
define the condition to trigger
16+
'''
17+
# the condition to trigger start() method, the default implementation will be by checking if a long reboot press was detected.
18+
raise NotImplementedError
19+
20+
def start(self):
21+
'''
22+
define the functionality
23+
'''
24+
# the implementation of deleting non-default users and restoring original passwords for default users and expiring them
25+
raise NotImplementedError
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
'''
2+
Test LocalUsersConfigurationResetBase module
3+
'''
4+
5+
from unittest import mock
6+
from sonic_platform_base.local_users_passwords_reset_base import LocalUsersConfigurationResetBase
7+
8+
9+
class TestLocalUsersConfigurationResetBase:
10+
'''
11+
Collection of LocalUsersConfigurationResetBase test methods
12+
'''
13+
@staticmethod
14+
def test_fan_base():
15+
'''
16+
Verify unimplemented methods
17+
'''
18+
base = LocalUsersConfigurationResetBase()
19+
not_implemented_methods = [
20+
(base.should_trigger,),
21+
(base.start,)]
22+
23+
for method in not_implemented_methods:
24+
expected_exception = False
25+
try:
26+
func = method[0]
27+
args = method[1:]
28+
func(*args)
29+
except Exception as exc:
30+
expected_exception = isinstance(exc, NotImplementedError)
31+
assert expected_exception

0 commit comments

Comments
 (0)