def test_otp_code_success(otp: str) -> None: OtpCode().validate(otp) # type:ignore
def test_otp_code_failure(value: str) -> None: with raises(ValidationError): OtpCode().validate(value) # type:ignore
"Authentication for having the OTP Service and the HIS trust each other will be configured at " "the infrastructure level. " "The payload also contains the start date of the symptoms, so that the Exposure Ingestion " "Service can compute the Transmission Risk for each uploaded TEK.") @doc.consumes(OtpBody, location="body") @doc.consumes(HeaderImmuniContentTypeJson(), location="header", required=True) @doc.response( HTTPStatus.NO_CONTENT.value, None, description="OTP successfully authorised.", ) @doc_exception(SchemaValidationException) @doc_exception(OtpCollisionException) @validate( location=Location.JSON, otp=OtpCode(), symptoms_started_on=IsoDate(), ) @cache(no_store=True) async def authorize_otp(request: Request, otp: str, symptoms_started_on: date) -> HTTPResponse: """ Authorize the upload of the Mobile Client’s TEKs. :param request: the HTTP request object. :param otp: the OTP code to authorize. :param symptoms_started_on: the date of the first symptoms. :return: 204 on OTP successfully authorized, 400 on BadRequest, 409 on OTP already authorized. """ await store(otp=otp, otp_data=OtpData(symptoms_started_on=symptoms_started_on))