def test_should_return_200_when_call_sum_with_valid_values_with_external_headers( client_app ): headers = { "Content-Type": "multipart/form-data", "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36", "X-Correlation-Id": CorrelationId.generate().value, "X-Onboarding-Clientid": "petisco", "X-Onboarding-Userid": UserId.generate().value, } multipart_data = dict(value_1=2, value_2=3) response = client_app.post( "/petisco/sum", headers=headers, data=multipart_data, content_type="multipart/form-data", ) assert response.status_code == 200 assert response.json["result"] == 5
def random(): return InfoId( ClientId("petisco-client"), UserId.generate(), CorrelationId.generate() )
def controller(): return Success(UserId.generate())
def test_should_declare_a_user_id_generated_automatically(): user_id = UserId.generate() assert isinstance(user_id, UserId) assert len(user_id.value) == 36
import pytest from petisco.domain.value_objects.client_id import ClientId from petisco.domain.value_objects.user_id import UserId from petisco.security.token_decoder.token_decoder import TokenDecoder @pytest.mark.unit @pytest.mark.parametrize( "type_token,client_id,user_id", [ ("ADMIN_TOKEN", ClientId("client-id"), None), ("ADMIN_TOKEN", ClientId("client-id"), UserId.generate()), ("BACKEND_TOKEN", ClientId("client-id"), UserId.generate()), ], ) def test_should_decode_a_token_successfully(type_token, client_id, user_id, given_auth_token_headers_creator): auth_token = given_auth_token_headers_creator(type_token, client_id, user_id)["Authorization"] token_decoder = TokenDecoder() token = token_decoder.execute(auth_token).unwrap() assert token.token_type == type_token assert token.client_id == client_id assert token.user_id == user_id
def create(name: Name): user = User(name, UserId.generate()) user.record(UserCreated(user.user_id, user.name)) return user