示例#1
0
        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 static void BuilderShouldUseDefaultApiUri()
        {
            var sandboxClient = SandboxClient.Builder()
                                .WithClientSdkId(_someSdkId)
                                .WithKeyPair(KeyPair.Get())
                                .Build();

            Assert.Equal(new Uri("https://api.yoti.com/sandbox/idverify/v1"), sandboxClient.DocScanSandboxApiUrl);
        }
        public static void BuilderShouldUseGivenApiUri()
        {
            var sandboxClient = SandboxClient.Builder()
                                .WithClientSdkId(_someSdkId)
                                .WithKeyPair(KeyPair.Get())
                                .WithApiUri(_someUri)
                                .Build();

            Assert.Equal(_someUri, sandboxClient.DocScanSandboxApiUrl);
        }
示例#4
0
        public DocScanSandboxClientTests()
        {
            _yotiDocScanSandboxClient = SandboxClient.Builder()
                                        .WithApiUri(_someUri)
                                        .WithClientSdkId(_someSdkId)
                                        .WithKeyPair(KeyPair.Get())
                                        .Build();

            _sandboxResponseConfig = new ResponseConfigBuilder().Build();
        }
示例#5
0
        public static void BuilderShouldCreateClient()
        {
            var sandboxClient = SandboxClient.Builder()
                                .WithClientSdkId(_someSdkId)
                                .WithKeyPair(KeyPair.Get())
                                .WithApiUri(_someUri)
                                .Build();

            Assert.NotNull(sandboxClient);
        }
示例#6
0
        public static void BuilderShouldThrowForMissingKey()
        {
            var exception = Assert.Throws <ArgumentNullException>(() =>
            {
                SandboxClient.Builder()
                .WithApiUri(_someUri)
                .WithClientSdkId(_someSdkId)
                .Build();
            });

            Assert.Contains("keyPair", exception.Message, StringComparison.Ordinal);
        }
示例#7
0
        public DocScanSandboxClientTests()
        {
            using (HttpClientHandler handler = new HttpClientHandler())
            {
                handler.ServerCertificateCustomValidationCallback +=
                    (sender, cert, chain, sslPolicyErrors) => true;

                using var httpClient = new HttpClient(handler);
                _yotiSandboxClient   = new SandboxClientBuilder(httpClient)
                                       .WithApiUri(_someUri)
                                       .WithClientSdkId(_someSdkId)
                                       .WithKeyPair(KeyPair.Get())
                                       .Build();
            }

            _yotiTokenRequest = new YotiTokenRequestBuilder().Build();
        }
示例#8
0
        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);
            };
        }
示例#9
0
        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);
            };
        }