add forgot endpoint
This commit is contained in:
@@ -16,7 +16,7 @@ SK = 'sk'
|
||||
# https://docs.pytest.org/en/7.1.x/reference/reference.html#pytest.hookspec.pytest_configure
|
||||
def pytest_configure():
|
||||
os.environ['TZ'] = 'America/Sao_Paulo'
|
||||
os.environ['OAUTH2_TABLE'] = PYTEST_TABLE_NAME
|
||||
os.environ['USER_TABLE'] = PYTEST_TABLE_NAME
|
||||
os.environ['SESSION_SECRET'] = 'secret'
|
||||
os.environ['DYNAMODB_PARTITION_KEY'] = PK
|
||||
os.environ['DYNAMODB_SORT_KEY'] = SK
|
||||
|
||||
0
id.saladeaula.digital/tests/events/__init__.py
Normal file
0
id.saladeaula.digital/tests/events/__init__.py
Normal file
19
id.saladeaula.digital/tests/events/test_send_forgot_email.py
Normal file
19
id.saladeaula.digital/tests/events/test_send_forgot_email.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from aws_lambda_powertools.utilities.typing.lambda_context import LambdaContext
|
||||
|
||||
import events.send_forgot_email as app
|
||||
|
||||
|
||||
def test_send_forgot_email(monkeypatch, lambda_context: LambdaContext):
|
||||
monkeypatch.setattr(app.sesv2_client, 'send_email', lambda *args, **kwargs: ...)
|
||||
|
||||
event = {
|
||||
'detail': {
|
||||
'new_image': {
|
||||
'id': 'PASSWORD_RESET',
|
||||
'sk': 'CODE#123',
|
||||
'name': 'Sérgio R Siqueira',
|
||||
'email': 'sergio@somosbeta.com.br',
|
||||
}
|
||||
}
|
||||
}
|
||||
assert app.lambda_handler(event, lambda_context) # type: ignore
|
||||
37
id.saladeaula.digital/tests/routes/test_forgot.py
Normal file
37
id.saladeaula.digital/tests/routes/test_forgot.py
Normal file
@@ -0,0 +1,37 @@
|
||||
from http import HTTPMethod
|
||||
|
||||
from layercake.dynamodb import DynamoDBPersistenceLayer, PartitionKey
|
||||
|
||||
from ..conftest import HttpApiProxy, LambdaContext
|
||||
|
||||
|
||||
def test_forgot(
|
||||
app,
|
||||
seeds,
|
||||
dynamodb_persistence_layer: DynamoDBPersistenceLayer,
|
||||
http_api_proxy: HttpApiProxy,
|
||||
lambda_context: LambdaContext,
|
||||
):
|
||||
r = app.lambda_handler(
|
||||
http_api_proxy(
|
||||
raw_path='/forgot',
|
||||
method=HTTPMethod.POST,
|
||||
body={'username': '07879819908'},
|
||||
),
|
||||
lambda_context,
|
||||
)
|
||||
assert 's****io@somosbeta.com.br' == r['body']['email']
|
||||
|
||||
app.lambda_handler(
|
||||
http_api_proxy(
|
||||
raw_path='/forgot',
|
||||
method=HTTPMethod.POST,
|
||||
body={'username': '07879819908'},
|
||||
),
|
||||
lambda_context,
|
||||
)
|
||||
|
||||
forgot = dynamodb_persistence_layer.collection.query(
|
||||
PartitionKey('PASSWORD_RESET'),
|
||||
)
|
||||
assert len(forgot['items']) == 3
|
||||
Reference in New Issue
Block a user