Ejemplo n.º 1
0
        public async Task <bool> PostSelfExposureKeys(SelfDiagnosisSubmissionDTO selfDiagnosisSubmissionDTO, IEnumerable <ExposureKeyModel> temporaryExposureKeys, BaseWebService service)
        {
            ApiResponse response;
            bool        requestedAnonToken;

            if (AuthenticationState.PersonalData?.AnonymousTokensEnabled == true)
            {
                requestedAnonToken = true;
                response           = await PostSelfExposureKeysWithAnonTokens(selfDiagnosisSubmissionDTO, temporaryExposureKeys, service);
            }
            else
            {
                requestedAnonToken = false;
                response           = await service.Post(selfDiagnosisSubmissionDTO, Conf.URL_PUT_UPLOAD_DIAGNOSIS_KEYS);
            }
            // HandleErrorsSilently happens even if IsSuccessfull is true other places in the code, but here
            // we have an if-else to avoid having to create the redacted key list if we don't have to
            if (!response.IsSuccessfull)
            {
                string redactedKeysJson = RedactedTekListHelper.CreateRedactedTekList(temporaryExposureKeys);
                HandleErrorsSilently(response, new PostExposureKeysErrorHandler(redactedKeysJson));
            }
            else
            {
                HandleErrorsSilently(response);
            }

            ENDeveloperToolsViewModel.UpdatePushKeysInfo(response, selfDiagnosisSubmissionDTO, JsonSerializerSettings, requestedAnonToken);

            return(response.IsSuccessfull);
        }
Ejemplo n.º 2
0
        public async Task Post_Null_ReturnWrongStatusShouldBeUnsuccessfulAndReturnException()
        {
            string testApiPath = "/profiles/withdrawconsent";

            ApiStubHelper.StubServer
            .Given(Request.Create().WithPath(testApiPath).UsingPost())
            .RespondWith(
                Response.Create()
                .WithStatusCode(0)
                .WithBodyAsJson("Successfully send POST request")
                );
            BaseWebService baseService = new BaseWebService();

            ApiResponse response = await baseService.Post(ApiStubHelper.StubServerUrl + testApiPath);

            var returnedFailResponseWithException = !response.IsSuccessfull && response.Exception != null;

            returnedFailResponseWithException.Should().BeTrue();
        }