public void ConfigureSessionResponseShouldThrowForNonSuccessCode() { using (var httpResponseMessage = new HttpResponseMessage { StatusCode = HttpStatusCode.BadRequest, Content = new StringContent("{}") }) { SandboxClient docScanSandboxClient; Mock <HttpMessageHandler> handlerMock = HttpMock.SetupMockMessageHandler(httpResponseMessage); using var httpClient = new HttpClient(handlerMock.Object); docScanSandboxClient = SandboxClient.Builder(httpClient) .WithClientSdkId(_someSdkId) .WithKeyPair(KeyPair.Get()) .Build(); var exception = Assert.Throws <SandboxException>(() => { docScanSandboxClient.ConfigureSessionResponse( _someSessionId, _sandboxResponseConfig); }); Assert.Contains("Failed validation - Status Code: '400' (BadRequest). Content: '{}'", exception.Message, StringComparison.Ordinal); }; }
public void SetupSharingProfileShouldReturnToken() { string tokenValue = "kyHPjq2+Y48cx+9yS/XzmW09jVUylSdhbP+3Q9Tc9p6bCEnyfa8vj38"; using (var httpResponseMessage = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent("{\"token\": \"" + tokenValue + "\"}") }) { SandboxClient yotiSandboxClient; Mock <HttpMessageHandler> handlerMock = HttpMock.SetupMockMessageHandler(httpResponseMessage); using var httpClient = new HttpClient(handlerMock.Object); yotiSandboxClient = new SandboxClientBuilder(httpClient) .WithClientSdkId(_someSdkId) .WithKeyPair(KeyPair.Get()) .Build(); string result = yotiSandboxClient.SetupSharingProfile( _yotiTokenRequest); Assert.Equal(tokenValue, result); }; }
public void SetupSharingProfileShouldThrowForNonSuccessCode() { using (var httpResponseMessage = new HttpResponseMessage { StatusCode = HttpStatusCode.BadRequest, Content = new StringContent("{}") }) { SandboxClient yotiSandboxClient; Mock <HttpMessageHandler> handlerMock = HttpMock.SetupMockMessageHandler(httpResponseMessage); using var httpClient = new HttpClient(handlerMock.Object); yotiSandboxClient = new SandboxClientBuilder(httpClient) .WithClientSdkId(_someSdkId) .WithKeyPair(KeyPair.Get()) .Build(); var exception = Assert.Throws <SandboxException>(() => { yotiSandboxClient.SetupSharingProfile( _yotiTokenRequest); }); Assert.Contains("Error when setting up sharing profile", exception.Message, StringComparison.Ordinal); }; }
public void ConfigureSessionResponseShouldNotThrowException() { using (var httpResponseMessage = new HttpResponseMessage { StatusCode = HttpStatusCode.OK }) { SandboxClient docScanSandboxClient; Mock <HttpMessageHandler> handlerMock = HttpMock.SetupMockMessageHandler(httpResponseMessage); using var httpClient = new HttpClient(handlerMock.Object); docScanSandboxClient = SandboxClient.Builder(httpClient) .WithClientSdkId(_someSdkId) .WithKeyPair(KeyPair.Get()) .Build(); docScanSandboxClient.ConfigureSessionResponse( _someSessionId, _sandboxResponseConfig); }; }
public void ConfigureApplicationResponseShouldNotError() { string tokenValue = "kyHPjq2+Y48cx+9yS/XzmW09jVUylSdhbP+3Q9Tc9p6bCEnyfa8vj38"; using (var httpResponseMessage = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent("{\"token\": \"" + tokenValue + "\"}") }) { SandboxClient docScanSandboxClient; Mock <HttpMessageHandler> handlerMock = HttpMock.SetupMockMessageHandler(httpResponseMessage); using var httpClient = new HttpClient(handlerMock.Object); docScanSandboxClient = SandboxClient.Builder(httpClient) .WithClientSdkId(_someSdkId) .WithKeyPair(KeyPair.Get()) .Build(); docScanSandboxClient.ConfigureApplicationResponse( _sandboxResponseConfig); }; }