diff --git a/Examples/Yoti.Auth.Sandbox.Examples/Yoti.Auth.Sandbox.Examples.csproj b/Examples/Yoti.Auth.Sandbox.Examples/Yoti.Auth.Sandbox.Examples.csproj index e01f137..cd3782b 100644 --- a/Examples/Yoti.Auth.Sandbox.Examples/Yoti.Auth.Sandbox.Examples.csproj +++ b/Examples/Yoti.Auth.Sandbox.Examples/Yoti.Auth.Sandbox.Examples.csproj @@ -7,10 +7,10 @@ - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Yoti.Auth.Sandbox.Tests/DocScan/DocScanSandboxClientTests.cs b/Yoti.Auth.Sandbox.Tests/DocScan/DocScanSandboxClientTests.cs index 67b9644..aa22673 100644 --- a/Yoti.Auth.Sandbox.Tests/DocScan/DocScanSandboxClientTests.cs +++ b/Yoti.Auth.Sandbox.Tests/DocScan/DocScanSandboxClientTests.cs @@ -62,9 +62,11 @@ public void ConfigureSessionResponseShouldNotThrowException() .WithKeyPair(KeyPair.Get()) .Build(); - docScanSandboxClient.ConfigureSessionResponse( + var ex = Record.Exception(() => docScanSandboxClient.ConfigureSessionResponse( _someSessionId, - _sandboxResponseConfig); + _sandboxResponseConfig)); + + Assert.Null(ex); }; } diff --git a/Yoti.Auth.Sandbox.Tests/Yoti.Auth.Sandbox.Tests.csproj b/Yoti.Auth.Sandbox.Tests/Yoti.Auth.Sandbox.Tests.csproj index 1856ae1..fcad952 100644 --- a/Yoti.Auth.Sandbox.Tests/Yoti.Auth.Sandbox.Tests.csproj +++ b/Yoti.Auth.Sandbox.Tests/Yoti.Auth.Sandbox.Tests.csproj @@ -16,7 +16,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -24,9 +24,9 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + + all diff --git a/Yoti.Auth.Sandbox/DocScan/Request/SandboxClient.cs b/Yoti.Auth.Sandbox/DocScan/Request/SandboxClient.cs index 7f635e4..1c8b87c 100644 --- a/Yoti.Auth.Sandbox/DocScan/Request/SandboxClient.cs +++ b/Yoti.Auth.Sandbox/DocScan/Request/SandboxClient.cs @@ -32,54 +32,76 @@ internal SandboxClient(string sdkId, AsymmetricCipherKeyPair keyPair, Uri apiUri public void ConfigureSessionResponse(string sessionId, ResponseConfig sandboxExpection) { - string serializedSandboxResponseConfig = JsonConvert.SerializeObject( + try + { + string serializedSandboxResponseConfig = JsonConvert.SerializeObject( sandboxExpection, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); - byte[] body = Encoding.UTF8.GetBytes(serializedSandboxResponseConfig); + byte[] body = Encoding.UTF8.GetBytes(serializedSandboxResponseConfig); - Yoti.Auth.Web.Request request = new RequestBuilder() - .WithKeyPair(_keyPair) - .WithBaseUri(DocScanSandboxApiUrl) - .WithEndpoint($"/sessions/{sessionId}/response-config") - .WithHttpMethod(HttpMethod.Put) - .WithContent(body) - .WithQueryParam("sdkId", _sdkId) - .Build(); + Yoti.Auth.Web.Request request = new RequestBuilder() + .WithKeyPair(_keyPair) + .WithBaseUri(DocScanSandboxApiUrl) + .WithEndpoint($"/sessions/{sessionId}/response-config") + .WithHttpMethod(HttpMethod.Put) + .WithContent(body) + .WithQueryParam("sdkId", _sdkId) + .Build(); - HttpResponseMessage response = request.Execute(_httpClient).Result; + HttpResponseMessage response = request.Execute(_httpClient).Result; - if (!response.IsSuccessStatusCode) + if (!response.IsSuccessStatusCode) + { + Response.CreateYotiExceptionFromStatusCode(response); + } + } + catch (SandboxException) + { + throw; + } + catch (Exception ex) { - Response.CreateYotiExceptionFromStatusCode(response); + throw new SandboxException(Properties.Resources.DocScanSessionResponseError, ex); } } public void ConfigureApplicationResponse(ResponseConfig sandboxExpection) { - string serializedSandboxResponseConfig = JsonConvert.SerializeObject( + try + { + string serializedSandboxResponseConfig = JsonConvert.SerializeObject( sandboxExpection, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); - byte[] body = Encoding.UTF8.GetBytes(serializedSandboxResponseConfig); + byte[] body = Encoding.UTF8.GetBytes(serializedSandboxResponseConfig); - Yoti.Auth.Web.Request request = new RequestBuilder() - .WithKeyPair(_keyPair) - .WithBaseUri(DocScanSandboxApiUrl) - .WithEndpoint($"/apps/{_sdkId}/response-config") - .WithHttpMethod(HttpMethod.Put) - .WithContent(body) - .Build(); + Yoti.Auth.Web.Request request = new RequestBuilder() + .WithKeyPair(_keyPair) + .WithBaseUri(DocScanSandboxApiUrl) + .WithEndpoint($"/apps/{_sdkId}/response-config") + .WithHttpMethod(HttpMethod.Put) + .WithContent(body) + .Build(); - HttpResponseMessage response = request.Execute(_httpClient).Result; + HttpResponseMessage response = request.Execute(_httpClient).Result; - if (!response.IsSuccessStatusCode) + if (!response.IsSuccessStatusCode) + { + Response.CreateYotiExceptionFromStatusCode(response); + } + } + catch (SandboxException) + { + throw; + } + catch (Exception ex) { - Response.CreateYotiExceptionFromStatusCode(response); + throw new SandboxException(Properties.Resources.DocScanApplicationResponseError, ex); } } } diff --git a/Yoti.Auth.Sandbox/Yoti.Auth.Sandbox.csproj b/Yoti.Auth.Sandbox/Yoti.Auth.Sandbox.csproj index 4ddcc98..40f60c6 100644 --- a/Yoti.Auth.Sandbox/Yoti.Auth.Sandbox.csproj +++ b/Yoti.Auth.Sandbox/Yoti.Auth.Sandbox.csproj @@ -12,7 +12,7 @@ Yoti.Sandbox https://developers.yoti.com/yoti-app/web-integration false - 1.6.0 + 1.6.1 @@ -33,12 +33,12 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 4b7062a..b41fd04 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -27,7 +27,7 @@ steps: scannerMode: 'MSBuild' projectKey: 'getyoti:dotnet-sandbox' projectName: '.NET SDK Sandbox' - projectVersion: '1.6.0' + projectVersion: '1.6.1' extraProperties: | sonar.cs.opencover.reportsPaths="**/coverage.opencover.xml" sonar.links.scm = https://github.com/getyoti/yoti-dotnet-sdk-sandbox