-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add base class implementation for local users' passwords reset
- Loading branch information
Showing
2 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
''' | ||
local_users_passwords_reset_base.py | ||
Abstract base class for implementing platform-specific | ||
local users' passwords reset base functionality for SONiC | ||
''' | ||
|
||
|
||
class LocalUsersConfigurationResetBase(object): | ||
""" | ||
Abstract base class for resetting local users' passwords on the switch | ||
""" | ||
def should_trigger(self): | ||
''' | ||
define the condition to trigger | ||
''' | ||
# the condition to trigger start() method, the default implementation will be by checking if a long reboot press was detected. | ||
raise NotImplementedError | ||
|
||
def start(self): | ||
''' | ||
define the functionality | ||
''' | ||
# the implementation of deleting non-default users and restoring original passwords for default users and expiring them | ||
raise NotImplementedError |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
''' | ||
Test LocalUsersConfigurationResetBase module | ||
''' | ||
|
||
from unittest import mock | ||
from sonic_platform_base.local_users_passwords_reset_base import LocalUsersConfigurationResetBase | ||
|
||
|
||
class TestLocalUsersConfigurationResetBase: | ||
''' | ||
Collection of LocalUsersConfigurationResetBase test methods | ||
''' | ||
@staticmethod | ||
def test_local_users_passwords_reset_base(): | ||
''' | ||
Verify unimplemented methods | ||
''' | ||
base = LocalUsersConfigurationResetBase() | ||
not_implemented_methods = [ | ||
(base.should_trigger,), | ||
(base.start,)] | ||
|
||
for method in not_implemented_methods: | ||
expected_exception = False | ||
try: | ||
func = method[0] | ||
args = method[1:] | ||
func(*args) | ||
except Exception as exc: | ||
expected_exception = isinstance(exc, NotImplementedError) | ||
assert expected_exception |