public void ShouldReturnCorrectSupplementaryDocResourceResponse()
        {
            FileResponse documentFile = new FileResponse {
                Media = new MediaResponse()
            };
            var supplementaryDocs = new List <SupplementaryDocResourceResponse>
            {
                new SupplementaryDocResourceResponse
                {
                    DocumentType   = "PASSPORT",
                    IssuingCountry = "FRA",
                    Pages          = new List <PageResponse>(),
                    DocumentFields = new DocumentFieldsResponse(),
                    DocumentFile   = documentFile
                }
            };

            GetSessionResult sessionResult = new GetSessionResult {
                Resources = new ResourceContainer {
                    SupplementaryDocuments = supplementaryDocs
                }
            };
            SupplementaryDocResourceResponse result = sessionResult.Resources.SupplementaryDocuments.Single();

            Assert.AreEqual("PASSPORT", result.DocumentType);
            Assert.IsNotNull(result.IssuingCountry);
            Assert.IsNotNull(result.Pages);
            Assert.IsNotNull(result.DocumentFields);
            Assert.IsNotNull(result.DocumentFile.Media);
        }
        public void LivenessResourceResponsesAreParsed(string livenessResourceResponseTypeString, Type expectedType)
        {
            var livenessCapture = new List <LivenessResourceResponse>
            {
                new LivenessResourceResponse
                {
                    LivenessType = livenessResourceResponseTypeString
                }
            };

            var resourceContainer = new ResourceContainer {
                LivenessCapture = livenessCapture
            };

            var initialGetSessionResult = new GetSessionResult
            {
                Resources = resourceContainer
            };

            string json = JsonConvert.SerializeObject(initialGetSessionResult);

            GetSessionResult getSessionResultWithConverter =
                JsonConvert.DeserializeObject <GetSessionResult>(json);

            Assert.IsInstanceOfType(getSessionResultWithConverter.Resources.LivenessCapture.Single(), expectedType);
        }
        public void ShouldFilterTextExtractionTasks()
        {
            var tasks = new List <TaskResponse>
            {
                new SupplementaryDocTextExtractionTaskResponse(),
                new TaskResponse()
            };

            var supplementaryDocuments = new List <SupplementaryDocResourceResponse>
            {
                new SupplementaryDocResourceResponse {
                    Tasks = tasks
                }
            };

            GetSessionResult getSessionResult = new GetSessionResult {
                Resources = new ResourceContainer {
                    SupplementaryDocuments = supplementaryDocuments
                }
            };

            var result = getSessionResult.Resources.SupplementaryDocuments.Single();

            Assert.AreEqual(
                2,
                result.Tasks.Count);

            Assert.AreEqual(
                1,
                result.GetTextExtractionTasks().Count);
        }
Ejemplo n.º 4
0
        public IActionResult Success()
        {
            string sessionId = TempData["sessionId"].ToString();

            TempData.Keep("sessionId");

            GetSessionResult getSessionResult = _client.GetSession(sessionId);

            return(View(getSessionResult));
        }
        public void TextDataChecksShouldReturnEmptyCollectionWhenNoneOfTypeArePresent()
        {
            var getSessionResult = new GetSessionResult
            {
                Checks = new List <CheckResponse>
                {
                    new AuthenticityCheckResponse()
                }
            };

            Assert.AreEqual(0, getSessionResult.GetIdDocumentTextDataChecks().Count);
        }
        public void WatchlistScreeningChecksShouldReturnEmptyCollectionWhenNoneOfTypeArePresent()
        {
            var getSessionResult = new GetSessionResult
            {
                Checks = new List <CheckResponse>
                {
                    new AuthenticityCheckResponse()
                }
            };

            Assert.AreEqual(0, getSessionResult.GetWatchlistScreeningChecks().Count);
        }
        public void ThirdPartyIdentityFraudOneChecksShouldReturnEmptyCollectionWhenNoneOfTypeArePresent()
        {
            var getSessionResult = new GetSessionResult
            {
                Checks = new List <CheckResponse>
                {
                    new AuthenticityCheckResponse()
                }
            };

            Assert.AreEqual(0, getSessionResult.GetThirdPartyIdentityFraudOneChecks().Count);
        }
        public void WatchlistAdvancedCaChecksShouldFilterChecks()
        {
            var getSessionResult = new GetSessionResult
            {
                Checks = new List <CheckResponse>
                {
                    new LivenessCheckResponse(),
                    new WatchlistAdvancedCaCheckResponse()
                }
            };

            Assert.AreEqual(1, getSessionResult.GetWatchlistAdvancedCaChecks().Count);
            Assert.IsInstanceOfType(getSessionResult.GetWatchlistAdvancedCaChecks().First(), typeof(WatchlistAdvancedCaCheckResponse));
        }
        public void ThirdPartyIdentityFraudOneChecksShouldFilterChecks()
        {
            var getSessionResult = new GetSessionResult
            {
                Checks = new List <CheckResponse>
                {
                    new LivenessCheckResponse(),
                    new ThirdPartyIdentityFraudOneCheckResponse()
                }
            };

            Assert.AreEqual(1, getSessionResult.GetThirdPartyIdentityFraudOneChecks().Count);
            Assert.IsInstanceOfType(getSessionResult.GetThirdPartyIdentityFraudOneChecks().First(), typeof(ThirdPartyIdentityFraudOneCheckResponse));
        }
        public void SupplementaryDocTextDataChecksShouldFilterChecks()
        {
            var getSessionResult = new GetSessionResult
            {
                Checks = new List <CheckResponse>
                {
                    new LivenessCheckResponse(),
                    new SupplementaryDocTextDataCheckResponse()
                }
            };

            Assert.AreEqual(1, getSessionResult.GetSupplementaryDocTextDataChecks().Count);
            Assert.IsInstanceOfType(getSessionResult.GetSupplementaryDocTextDataChecks().First(), typeof(SupplementaryDocTextDataCheckResponse));
        }
        public void IdDocumentComaprisonChecksShouldFilterChecks()
        {
            var getSessionResult = new GetSessionResult
            {
                Checks = new List <CheckResponse>
                {
                    new LivenessCheckResponse(),
                    new IdDocumentComparisonCheckResponse()
                }
            };

            Assert.AreEqual(1, getSessionResult.GetIdDocumentComparisonChecks().Count);
            Assert.IsInstanceOfType(getSessionResult.GetIdDocumentComparisonChecks().First(), typeof(IdDocumentComparisonCheckResponse));
        }
        public void LivenessChecksShouldFilterChecks()
        {
            var getSessionResult = new GetSessionResult
            {
                Checks = new List <CheckResponse>
                {
                    new LivenessCheckResponse(),
                    new AuthenticityCheckResponse()
                }
            };

            Assert.AreEqual(1, getSessionResult.GetLivenessChecks().Count);
            Assert.IsInstanceOfType(getSessionResult.GetLivenessChecks().First(), typeof(LivenessCheckResponse));
        }
        public void FaceMatchChecksShouldFilterChecks()
        {
            var getSessionResult = new GetSessionResult
            {
                Checks = new List <CheckResponse>
                {
                    new FaceMatchCheckResponse(),
                    new TextDataCheckResponse()
                }
            };

            Assert.AreEqual(1, getSessionResult.GetFaceMatchChecks().Count);
            Assert.IsInstanceOfType(getSessionResult.GetFaceMatchChecks().First(), typeof(FaceMatchCheckResponse));
        }
Ejemplo n.º 14
0
        public void ShouldParseIdentityProfileResponse()
        {
            string mediaId = "c69ff2db-6caf-4e74-8386-037711bbc8d7";
            string getSessionResult;

            using (StreamReader r = File.OpenText("TestData/GetSessionResultWithIdentityProfile.json"))
            {
                getSessionResult = r.ReadToEnd();
            }

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

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

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

            GetSessionResult result = docScanClient.GetSession("some-session-id");

            Assert.AreEqual("DONE", result.IdentityProfile.Result);
            Assert.AreEqual("someStringHere", result.IdentityProfile.SubjectId);
            Assert.AreEqual("MANDATORY_DOCUMENT_COULD_NOT_BE_PROVIDED", result.IdentityProfile.FailureReason.ReasonCode);

            Assert.AreEqual("UK_TFIDA", result.IdentityProfile.Report["trust_framework"]);
            JToken expectedSchemesCompliance = JToken.FromObject(
                new[]
            {
                new
                {
                    scheme = new
                    {
                        type      = "DBS",
                        objective = "STANDARD"
                    },
                    requirements_met          = true,
                    requirements_not_met_info = "some string here"
                }
            });

            Assert.IsTrue(JToken.DeepEquals(
                              JToken.FromObject(expectedSchemesCompliance),
                              result.IdentityProfile.Report["schemes_compliance"]));

            Assert.AreEqual(mediaId, result.IdentityProfile.Report["media"]["id"]);
        }
        public void ShouldReturnEmptyListForEmptyTextExtractionTaskResponse()
        {
            var supplementaryDocs = new List <SupplementaryDocResourceResponse>
            {
                new SupplementaryDocResourceResponse {
                    Tasks = new List <TaskResponse>()
                }
            };

            GetSessionResult getSessionResult = new GetSessionResult {
                Resources = new ResourceContainer {
                    SupplementaryDocuments = supplementaryDocs
                }
            };

            CollectionAssert.AreEqual(new List <TextExtractionTaskResponse>(), getSessionResult.Resources.SupplementaryDocuments.Single().GetTextExtractionTasks());
        }
        public void ChecksShouldReturnEmptyListWhenNotPresent()
        {
            var getSessionResult = new GetSessionResult();

            Assert.AreEqual(0, getSessionResult.GetAuthenticityChecks().Count);
            Assert.AreEqual(0, getSessionResult.GetFaceMatchChecks().Count);
            Assert.AreEqual(0, getSessionResult.GetIdDocumentComparisonChecks().Count);
            Assert.AreEqual(0, getSessionResult.GetLivenessChecks().Count);
#pragma warning disable CS0618 // Type or member is obsolete
            Assert.AreEqual(0, getSessionResult.GetTextDataChecks().Count);
#pragma warning restore CS0618 // Type or member is obsolete
            Assert.AreEqual(0, getSessionResult.GetIdDocumentTextDataChecks().Count);
            Assert.AreEqual(0, getSessionResult.GetSupplementaryDocTextDataChecks().Count);
            Assert.AreEqual(0, getSessionResult.GetThirdPartyIdentityFraudOneChecks().Count);
            Assert.AreEqual(0, getSessionResult.GetThirdPartyIdentityChecks().Count);
            Assert.AreEqual(0, getSessionResult.GetWatchlistScreeningChecks().Count);
            Assert.AreEqual(0, getSessionResult.GetWatchlistAdvancedCaChecks().Count);
        }
        public void ShouldReturnEmptyListWhenNoTextExtractionTasks()
        {
            var supplementaryDocs = new List <SupplementaryDocResourceResponse>
            {
                new SupplementaryDocResourceResponse {
                    Tasks = null
                }
            };

            GetSessionResult getSessionResult = new GetSessionResult {
                Resources = new ResourceContainer {
                    SupplementaryDocuments = supplementaryDocs
                }
            };

            SupplementaryDocResourceResponse result = getSessionResult.Resources.SupplementaryDocuments.Single();

            Assert.IsNull(result.Tasks);
            Assert.AreEqual(0, result.GetTextExtractionTasks().Count);
        }
        public void ShouldReturnEmptyListWhenNoTextExtractionTasks()
        {
            var idDocuments = new List <IdDocumentResourceResponse>
            {
                new IdDocumentResourceResponse {
                    Tasks = null
                }
            };

            GetSessionResult getSessionResult = new GetSessionResult {
                Resources = new ResourceContainer {
                    IdDocuments = idDocuments
                }
            };

            var result = getSessionResult.Resources.IdDocuments.Single();

            Assert.IsNull(result.Tasks);
            Assert.AreEqual(0, result.GetTextExtractionTasks().Count);
        }
        public void ShouldParseAllChecks()
        {
            var checks = new List <CheckResponse>
            {
                new CheckResponse
                {
                    Type = "check1"
                },
                new CheckResponse
                {
                    Type = "ID_DOCUMENT_AUTHENTICITY"
                }
            };

            var getSessionResult = new GetSessionResult
            {
                Checks = checks
            };

            Assert.AreEqual(2, getSessionResult.Checks.Count);
        }
Ejemplo n.º 20
0
        public void CheckResponsesAreParsed(string checkResponsetypeString, Type expectedType)
        {
            var checks = new List <CheckResponse>
            {
                new CheckResponse
                {
                    Type = checkResponsetypeString
                }
            };

            var initialGetSessionResult = new GetSessionResult
            {
                Checks = checks
            };

            string json = JsonConvert.SerializeObject(initialGetSessionResult);

            GetSessionResult getSessionResult =
                JsonConvert.DeserializeObject <GetSessionResult>(json);

            Assert.IsInstanceOfType(getSessionResult.Checks.Single(), expectedType);
        }
        public void ShouldReturnEmptyListForSingleParentTextExtractionTaskResponse()
        {
            var tasks = new List <TaskResponse>
            {
                new TaskResponse()
            };

            var idDocuments = new List <IdDocumentResourceResponse>
            {
                new IdDocumentResourceResponse {
                    Tasks = tasks
                }
            };

            GetSessionResult getSessionResult = new GetSessionResult {
                Resources = new ResourceContainer {
                    IdDocuments = idDocuments
                }
            };

            CollectionAssert.AreEqual(new List <TextExtractionTaskResponse>(), getSessionResult.Resources.IdDocuments.Single().GetTextExtractionTasks());
        }
Ejemplo n.º 22
0
        public void GeneratedCheckResponsesAreParsed(string checkTypeString, Type expectedType)
        {
            var generatedChecks = new List <GeneratedCheckResponse>
            {
                new GeneratedCheckResponse
                {
                    Type = checkTypeString
                }
            };

            var initialGetSessionResult = new GetSessionResult
            {
                Resources = new ResourceContainer
                {
                    IdDocuments = new List <IdDocumentResourceResponse>()
                    {
                        new IdDocumentResourceResponse
                        {
                            Tasks = new List <TaskResponse>
                            {
                                new TaskResponse
                                {
                                    GeneratedChecks = generatedChecks
                                }
                            }
                        }
                    }
                }
            };

            string json = JsonConvert.SerializeObject(initialGetSessionResult);

            GetSessionResult getSessionResultWithConverter =
                JsonConvert.DeserializeObject <GetSessionResult>(json);

            Assert.IsInstanceOfType(getSessionResultWithConverter.Resources.IdDocuments.Single().Tasks.Single().GeneratedChecks.Single(), expectedType);
        }
Ejemplo n.º 23
0
        public void GetSessionSuccessShouldReturnResult()
        {
            var getSessionResult = new GetSessionResult {
                State = "COMPLETED"
            };

            string jsonResponse = JsonConvert.SerializeObject(getSessionResult);

            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);

            GetSessionResult result = docScanClient.GetSession("some-session-id");

            Assert.AreEqual("COMPLETED", result.State);
            Assert.IsNull(result.BiometricConsentTimestamp);
        }
Ejemplo n.º 24
0
        public void ShouldReturnBiometricConsentTimestamp()
        {
            var getSessionResult = new GetSessionResult
            {
                BiometricConsentTimestamp = new DateTime(2020, 1, 2, 3, 4, 5, DateTimeKind.Utc)
            };

            string jsonResponse = JsonConvert.SerializeObject(getSessionResult);

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

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

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

            GetSessionResult result = docScanClient.GetSession("some-session-id");

            Assert.AreEqual(new DateTime(2020, 1, 2, 3, 4, 5, DateTimeKind.Utc), result.BiometricConsentTimestamp);
        }