-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add forgotten password feature
- Loading branch information
1 parent
467d05a
commit 5420614
Showing
6 changed files
with
131 additions
and
3 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
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
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,24 @@ | ||
from indykite_sdk.indykite.identity.v1beta2 import identity_management_api_pb2 as pb2 | ||
from indykite_sdk.indykite.identity.v1beta2 import model_pb2 as model | ||
import sys | ||
from indykite_sdk.utils.logger import handle_excepthook, logger_error | ||
|
||
|
||
def start_forgotten_password_flow(self, digital_twin_id, tenant_id): | ||
sys.excepthook = handle_excepthook | ||
try: | ||
response = self.stub.StartForgottenPasswordFlow( | ||
pb2.StartForgottenPasswordFlowRequest( | ||
digital_twin=model.DigitalTwin( | ||
id=str(digital_twin_id), | ||
tenant_id=str(tenant_id) | ||
) | ||
) | ||
) | ||
except Exception as exception: | ||
return logger_error(exception) | ||
|
||
if not response: | ||
return None | ||
|
||
return True |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
from indykite_sdk.identity import IdentityClient | ||
from indykite_sdk.model.digital_twin import DigitalTwin | ||
from helpers import data | ||
|
||
|
||
def test_forgotten_password_wrong_twin_id(capsys): | ||
digital_twin_id = "696e6479-6b69-465-8000-010f00000000" | ||
tenant_id = data.get_tenant() | ||
|
||
client = IdentityClient() | ||
assert client is not None | ||
|
||
response = client.start_forgotten_password_flow(digital_twin_id, tenant_id) | ||
captured = capsys.readouterr() | ||
|
||
assert ( | ||
"StatusCode.INVALID_ARGUMENT" in captured.err | ||
) | ||
|
||
|
||
def test_forgotten_password_wrong_tenant_id(capsys): | ||
digital_twin_id = data.get_digital_twin_test() | ||
tenant_id = "gid:AAAAAbHLUExsxkqsqRoI93amR30" | ||
|
||
client = IdentityClient() | ||
assert client is not None | ||
|
||
response = client.start_forgotten_password_flow(digital_twin_id, tenant_id) | ||
captured = capsys.readouterr() | ||
|
||
assert "tenantId is not valid Tenant identifier" in captured.err | ||
|
||
|
||
def test_forgotten_password_uuid_tenant_id(capsys): | ||
digital_twin_id = data.get_digital_twin_test() | ||
tenant_id = "696e6479-6b69-4465-8000-030f00000001" | ||
|
||
client = IdentityClient() | ||
assert client is not None | ||
|
||
response = client.start_forgotten_password_flow(digital_twin_id, tenant_id) | ||
captured = capsys.readouterr() | ||
|
||
"invalid DigitalTwin.Id: value length must be 16 bytes" in captured.err | ||
|
||
|
||
def test_forgotten_password_nonexisting_twin_id(capsys): | ||
digital_twin_id = "gid:AAAAAbHLUExsxkqsqRoI93amR30" | ||
tenant_id = data.get_tenant() | ||
|
||
client = IdentityClient() | ||
assert client is not None | ||
|
||
response = client.start_forgotten_password_flow(digital_twin_id, tenant_id) | ||
captured = capsys.readouterr() | ||
|
||
assert "StatusCode.INVALID_ARGUMENT" in captured.err | ||
|
||
|
||
def test_forgotten_password_success(capsys): | ||
digital_twin_id = data.get_digital_twin_test() | ||
tenant_id = data.get_tenant() | ||
|
||
client = IdentityClient() | ||
assert client is not None | ||
|
||
response = client.start_forgotten_password_flow(digital_twin_id, tenant_id) | ||
captured = capsys.readouterr() | ||
|
||
assert response is True |