Exemplo n.º 1
0
        public void CreateSessionShouldSucceed()
        {
            string clientSessionToken    = "e8b1c85f-f9e7-405b-88eb-f1c318371f16";
            int    clientSessionTokenTtl = 500;
            string sessionId             = "4edd81c4-c612-4b0c-b385-7c90f0de6845";

            CreateSessionResult createSessionResult = new CreateSessionResult
            {
                ClientSessionToken    = clientSessionToken,
                ClientSessionTokenTtl = clientSessionTokenTtl,
                SessionId             = sessionId
            };

            string jsonResponse = JsonConvert.SerializeObject(createSessionResult);

            var successResponse = new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent(jsonResponse),
            };

            Mock <HttpMessageHandler> handlerMock = Auth.Tests.Common.Http.SetupMockMessageHandler(successResponse);
            var httpClient = new HttpClient(handlerMock.Object);

            DocScanClient docScanClient = new DocScanClient(_sdkId, _keyPair, httpClient);

            CreateSessionResult result = docScanClient.CreateSession(
                new SessionSpecificationBuilder().Build());

            Assert.AreEqual(clientSessionToken, result.ClientSessionToken);
            Assert.AreEqual(clientSessionTokenTtl, result.ClientSessionTokenTtl);
            Assert.AreEqual(sessionId, result.SessionId);
        }
Exemplo n.º 2
0
        public void CreateSessionShouldThrowForNonSuccessStatusCode(HttpStatusCode httpStatusCode)
        {
            DocScanClient docScanClient = SetupDocScanClientResponse(httpStatusCode);

            var aggregateException = Assert.ThrowsException <AggregateException>(() =>
            {
                CreateSessionResult result = docScanClient.CreateSession(
                    new SessionSpecificationBuilder().Build());
            });

            Assert.IsTrue(TestTools.Exceptions.IsExceptionInAggregateException <DocScanException>(aggregateException));
        }
Exemplo n.º 3
0
        public IActionResult Index()
        {
            //Build Session Spec
            var sessionSpec = new SessionSpecificationBuilder()
                              .WithClientSessionTokenTtl(600)
                              .WithResourcesTtl(90000)
                              .WithUserTrackingId("some-user-tracking-id")
                              //Add Checks (using builders)
                              .WithRequestedCheck(
                new RequestedDocumentAuthenticityCheckBuilder()
                .WithManualCheckAlways()
                .Build()
                )
                              .WithRequestedCheck(
                new RequestedLivenessCheckBuilder()
                .ForZoomLiveness()
                .Build()
                )
                              .WithRequestedCheck(
                new RequestedFaceMatchCheckBuilder()
                .WithManualCheckAlways()
                .Build()
                )
                              .WithRequestedCheck(
                new RequestedIdDocumentComparisonCheckBuilder()
                .Build())
                              .WithRequestedCheck(
                new RequestedThirdPartyIdentityCheckBuilder()
                .Build())
                              .WithRequestedCheck(
                new RequestedWatchlistScreeningCheckBuilder()
                .ForAdverseMedia()
                .ForSanctions()
                .Build()
                )
                              //Add Tasks (using builders)
                              .WithRequestedTask(
                new RequestedTextExtractionTaskBuilder()
                .WithManualCheckAlways()
                .WithChipDataDesired()
                .Build()
                )
                              .WithRequestedTask(
                new RequestedSupplementaryDocTextExtractionTaskBuilder()
                .WithManualCheckAlways()
                .Build()
                )
                              //Add Sdk Config (with builder)
                              .WithSdkConfig(
                new SdkConfigBuilder()
                .WithAllowsCameraAndUpload()
                .WithPrimaryColour("#2d9fff")
                .WithSecondaryColour("#FFFFFF")
                .WithFontColour("#FFFFFF")
                .WithLocale("en-GB")
                .WithPresetIssuingCountry("GBR")
                .WithSuccessUrl($"{_baseUrl}/idverify/success")
                .WithErrorUrl($"{_baseUrl}/idverify/error")
                .WithPrivacyPolicyUrl($"{_baseUrl}/privacy-policy")
                .WithAllowHandoff(false)
                .Build()
                )
                              //Add Required Documents (with builders)
                              .WithRequiredDocument(
                new RequiredIdDocumentBuilder()
                .WithFilter(
                    (new OrthogonalRestrictionsFilterBuilder())
                    .WithIncludedDocumentTypes(new List <string> {
                "PASSPORT"
            })
                    .Build()
                    )
                .Build()
                )
                              .WithRequiredDocument(
                new RequiredIdDocumentBuilder()
                .WithFilter(
                    (new OrthogonalRestrictionsFilterBuilder())
                    .WithIncludedDocumentTypes(new List <string> {
                "DRIVING_LICENCE"
            })
                    .Build()
                    )
                .Build()
                )
                              .WithRequiredDocument(
                new RequiredSupplementaryDocumentBuilder()
                .WithObjective(
                    new ProofOfAddressObjectiveBuilder().Build())
                .Build()
                )
                              .Build();

            CreateSessionResult createSessionResult = _client.CreateSession(sessionSpec);
            string sessionId = createSessionResult.SessionId;

            string path = $"web/index.html?sessionID={sessionId}&sessionToken={createSessionResult.ClientSessionToken}";
            Uri    uri  = new Uri(_apiUrl, path);

            ViewBag.iframeUrl = uri.ToString();

            TempData["sessionId"] = sessionId;
            return(View());
        }