Esempio n. 1
0
        public void ShouldAddPngContent()
        {
            SandboxDocumentImages documentImages = new SandboxDocumentImagesBuilder()
                                                   .WithPngContent(_someContent)
                                                   .Build();

            Assert.Equal(_someContent, documentImages.Images[0].GetContent());
            Assert.Equal(expectedPngBase64DataUrl, documentImages.GetValue());
            Assert.Equal(_mimeTypePng, documentImages.Images.Single().GetMIMEType());
        }
Esempio n. 2
0
        public void ShouldAddMultipleImages()
        {
            SandboxDocumentImages documentImages = new SandboxDocumentImagesBuilder()
                                                   .WithPngContent(_someContent)
                                                   .WithPngContent(_someContent)
                                                   .WithJpegContent(_someContent)
                                                   .Build();

            Assert.Equal(3, documentImages.Images.Count);
            Assert.Equal(
                $"{expectedPngBase64DataUrl}&{expectedPngBase64DataUrl}&{expectedJpegBase64DataUrl}",
                documentImages.GetValue());
        }
Esempio n. 3
0
        public static void ShouldCreateRequestWithDocumentImages()
        {
            SandboxDocumentImages documentImages = new SandboxDocumentImagesBuilder()
                                                   .WithJpegContent(_someImageContent)
                                                   .WithPngContent(_someImageContent)
                                                   .Build();

            YotiTokenRequest yotiTokenRequest = YotiTokenRequest.Builder()
                                                .WithDocumentImages(documentImages)
                                                .Build();

            ReadOnlyCollection <SandboxAttribute> result = yotiTokenRequest.SandboxAttributes;

            Assert.True(result.Count == 1);
            AttributeMatcher.AssertContainsAttribute(
                result,
                Yoti.Auth.Constants.UserProfile.DocumentImagesAttribute,
                _expectedDocumentImagesAttributeValue);
        }
Esempio n. 4
0
        public void TestProfile()
        {
            Org.BouncyCastle.Crypto.AsymmetricCipherKeyPair sandboxKeyPair;

            using (StreamReader stream = File.OpenText("path/to/hub-private-key.pem"))
            {
                sandboxKeyPair = Yoti.Auth.CryptoEngine.LoadRsaKey(stream);
            }

            const string sandboxClientSdkid = "your SDK ID";

            SandboxClient sandboxClient = new SandboxClientBuilder()
                                          .WithClientSdkId(sandboxClientSdkid)
                                          .WithKeyPair(sandboxKeyPair)
                                          .Build();

            SandboxAgeVerification ageVerification = new SandboxAgeVerificationBuilder()
                                                     .WithDateOfBirth(new DateTime(2001, 12, 31))
                                                     .WithAgeOver(18)
                                                     .Build();

            DateTime expiryDate = DateTime.UtcNow.AddDays(1);

            var documentImages = new SandboxDocumentImagesBuilder()
                                 .WithJpegContent(Encoding.UTF8.GetBytes("some JPEG content"))
                                 .WithPngContent(Encoding.UTF8.GetBytes("some PNG content"))
                                 .Build();

            SandboxExtraData sandboxExtraData =
                new SandboxExtraDataBuilder()
                .WithDataEntry(
                    new SandboxAttributeIssuanceDetailsBuilder()
                    .WithDefinition("attribute.name")
                    .WithExpiryDate(expiryDate)
                    .WithIssuanceToken("some-issuance-token")
                    .Build())
                .Build();

            YotiTokenRequest tokenRequest = new YotiTokenRequestBuilder()
                                            .WithRememberMeId("some Remember Me ID")
                                            .WithGivenNames("some given names")
                                            .WithFamilyName("some family name")
                                            .WithFullName("some full name")
                                            .WithDateOfBirth(new DateTime(1980, 10, 30))
                                            .WithAgeVerification(ageVerification)
                                            .WithGender("some gender")
                                            .WithPhoneNumber("some phone number")
                                            .WithNationality("some nationality")
                                            .WithStructuredPostalAddress(Newtonsoft.Json.JsonConvert.SerializeObject(new
            {
                building_number = 1,
                address_line1   = "some address"
            }))
                                            .WithBase64Selfie(Convert.ToBase64String(Encoding.UTF8.GetBytes("some base64 encoded selfie")))
                                            .WithEmailAddress("some@email")
                                            .WithDocumentDetails("PASSPORT USA 1234abc")
                                            .WithDocumentImages(documentImages)
                                            .WithExtraData(sandboxExtraData)
                                            .Build();

            var sandboxOneTimeUseToken = sandboxClient.SetupSharingProfile(tokenRequest);

            var yotiClient = new YotiClient(new HttpClient(), sandboxClientSdkid, sandboxKeyPair);

            Uri sandboxUri = new UriBuilder(
                "https",
                "api.yoti.com",
                443,
                "sandbox/v1").Uri;

            yotiClient.OverrideApiUri(sandboxUri);

            ActivityDetails activityDetails = yotiClient.GetActivityDetails(sandboxOneTimeUseToken);

            // Perform tests
            Assert.AreEqual("some@email", activityDetails.Profile.EmailAddress.GetValue());
        }