-
Notifications
You must be signed in to change notification settings - Fork 786
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '3078-otp-generator' into develop
- Loading branch information
Showing
7 changed files
with
100 additions
and
1 deletion.
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
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
18 changes: 18 additions & 0 deletions
18
.../monkey_island/cc/services/authentication_service/authentication_service_otp_generator.py
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,18 @@ | ||
from .authentication_facade import AuthenticationFacade | ||
from .i_otp_generator import IOTPGenerator | ||
from .types import OTP | ||
|
||
|
||
class AuthenticationServiceOTPGenerator(IOTPGenerator): | ||
""" | ||
Generates OTPs | ||
""" | ||
|
||
def __init__(self, authentication_facade: AuthenticationFacade): | ||
self._authentication_facade = authentication_facade | ||
|
||
def generate_otp(self) -> OTP: | ||
""" | ||
Generates a new OTP | ||
""" | ||
return self._authentication_facade.generate_otp() |
13 changes: 13 additions & 0 deletions
13
monkey/monkey_island/cc/services/authentication_service/i_otp_generator.py
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,13 @@ | ||
from abc import ABC, abstractmethod | ||
|
||
from .types import OTP | ||
|
||
|
||
class IOTPGenerator(ABC): | ||
"""Generator for OTPs""" | ||
|
||
@abstractmethod | ||
def generate_otp(self) -> OTP: | ||
""" | ||
Generates a new OTP | ||
""" |
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
15 changes: 15 additions & 0 deletions
15
...ey_island/cc/services/authentication_service/test_authentication_service_otp_generator.py
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,15 @@ | ||
from unittest.mock import MagicMock | ||
|
||
from monkey_island.cc.services.authentication_service import AuthenticationServiceOTPGenerator | ||
from monkey_island.cc.services.authentication_service.authentication_facade import ( | ||
AuthenticationFacade, | ||
) | ||
|
||
|
||
def test_authentication_service_otp_generator__generates_otp(): | ||
mock_authentication_facade = MagicMock(spec=AuthenticationFacade) | ||
|
||
otp_generator = AuthenticationServiceOTPGenerator(mock_authentication_facade) | ||
otp_generator.generate_otp() | ||
|
||
assert mock_authentication_facade.generate_otp.called_once |
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