add test
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import json
|
||||
from http import HTTPMethod, HTTPStatus
|
||||
|
||||
from layercake.dynamodb import DynamoDBPersistenceLayer
|
||||
from layercake.dynamodb import DynamoDBPersistenceLayer, SortKey, TransactKey
|
||||
|
||||
from ..conftest import HttpApiProxy, LambdaContext
|
||||
|
||||
@@ -31,7 +31,7 @@ def test_preexisting_user(
|
||||
assert r['statusCode'] == HTTPStatus.OK
|
||||
|
||||
|
||||
def test_preexisting_update_email(
|
||||
def test_preexisting_user_conflict(
|
||||
app,
|
||||
seeds,
|
||||
dynamodb_persistence_layer: DynamoDBPersistenceLayer,
|
||||
@@ -58,6 +58,47 @@ def test_preexisting_update_email(
|
||||
assert r['statusCode'] == HTTPStatus.CONFLICT
|
||||
|
||||
|
||||
def test_preexisting_user_update_email(
|
||||
app,
|
||||
seeds,
|
||||
dynamodb_persistence_layer: DynamoDBPersistenceLayer,
|
||||
http_api_proxy: HttpApiProxy,
|
||||
lambda_context: LambdaContext,
|
||||
):
|
||||
r = app.lambda_handler(
|
||||
http_api_proxy(
|
||||
raw_path='/register',
|
||||
method=HTTPMethod.POST,
|
||||
body={
|
||||
'id': '357db1c5-7442-4075-98a3-fbe5c938a419',
|
||||
'name': 'Sérgio R Siqueira',
|
||||
'cpf': '07879819908',
|
||||
'password': 'Led@Zepellin',
|
||||
'email': 'osergiosiqueira+pytest@gmail.com',
|
||||
},
|
||||
),
|
||||
lambda_context,
|
||||
)
|
||||
assert r['statusCode'] == HTTPStatus.OK
|
||||
|
||||
user = dynamodb_persistence_layer.collection.get_items(
|
||||
TransactKey(
|
||||
'357db1c5-7442-4075-98a3-fbe5c938a419',
|
||||
)
|
||||
+ SortKey('0')
|
||||
+ SortKey('emails#osergiosiqueira+pytest@gmail.com')
|
||||
+ SortKey('emails#sergio@somosbeta.com.br'),
|
||||
flatten_top=False,
|
||||
)
|
||||
assert user['0']['email'] == 'osergiosiqueira+pytest@gmail.com'
|
||||
assert 'emails#osergiosiqueira+pytest@gmail.com' in user
|
||||
assert 'emails#sergio@somosbeta.com.br' in user
|
||||
assert user['0']['emails'] == {
|
||||
'sergio@somosbeta.com.br',
|
||||
'osergiosiqueira+pytest@gmail.com',
|
||||
}
|
||||
|
||||
|
||||
def test_non_preexisting_user(
|
||||
app,
|
||||
dynamodb_persistence_layer: DynamoDBPersistenceLayer,
|
||||
|
||||
@@ -12,7 +12,9 @@
|
||||
{"id": "SESSION", "sk": "36af142e-9f6d-49d3-bfe9-6a6bd6ab2712", "user_id": "357db1c5-7442-4075-98a3-fbe5c938a419"}
|
||||
|
||||
// User data
|
||||
{"id": "357db1c5-7442-4075-98a3-fbe5c938a419", "sk": "0", "name": "Sérgio R Siqueira", "email": "sergio@somosbeta.com.br", "cpf": "07879819908"}
|
||||
{"id": "357db1c5-7442-4075-98a3-fbe5c938a419", "sk": "0", "name": "Sérgio R Siqueira", "email": "sergio@somosbeta.com.br", "cpf": "07879819908", "emails": ["sergio@somosbeta.com.br"]}
|
||||
// Post-migrations (users): rename `emails#` to `EMAIL#`
|
||||
{"id": "357db1c5-7442-4075-98a3-fbe5c938a419", "sk": "emails#sergio@somosbeta.com.br", "email_verified": true}
|
||||
{"id": "357db1c5-7442-4075-98a3-fbe5c938a419", "sk": "PASSWORD", "hash": "$pbkdf2-sha256$29000$IuTcm7M2BiAEgPB.b.3dGw$d8xVCbx8zxg7MeQBrOvCOgniiilsIHEMHzoH/OXftLQ"}
|
||||
{"id": "357db1c5-7442-4075-98a3-fbe5c938a419", "sk": "SCOPE", "scope": ["openid", "profile", "email", "offline_access", "apps:admin"]}
|
||||
{"id": "357db1c5-7442-4075-98a3-fbe5c938a419", "sk": "SESSION#36af142e-9f6d-49d3-bfe9-6a6bd6ab2712", "created_at": "2025-09-17T13:44:34.544491-03:00", "ttl": 1760719474}
|
||||
|
||||
Reference in New Issue
Block a user