예제 #1
0
        public static void ShouldCreateRequestWithMultipleAgeVerifications()
        {
            SandboxAgeVerification ageOver = SandboxAgeVerification.Builder()
                                             .WithDateOfBirth(_dobOver18)
                                             .WithAgeOver(18)
                                             .Build();
            SandboxAgeVerification ageUnder = SandboxAgeVerification.Builder()
                                              .WithDateOfBirth(_dobOver18)
                                              .WithAgeUnder(18)
                                              .Build();
            YotiTokenRequest yotiTokenRequest = YotiTokenRequest.Builder()
                                                .WithAgeVerification(ageOver)
                                                .WithAgeVerification(ageUnder)
                                                .Build();

            ReadOnlyCollection <SandboxAttribute> result = yotiTokenRequest.SandboxAttributes;

            Assert.True(result.Count == 2);
            AttributeMatcher.AssertContainsDerivedAttribute(
                result,
                Yoti.Auth.Constants.UserProfile.DateOfBirthAttribute,
                _dobOver18,
                "age_over:18");
            AttributeMatcher.AssertContainsDerivedAttribute(
                result,
                Yoti.Auth.Constants.UserProfile.DateOfBirthAttribute,
                _dobOver18,
                "age_under:18");
        }
예제 #2
0
        public static void ShouldCreateRequestWithExtraData()
        {
            SandboxAttributeIssuanceDetails sandboxAttributeIssuanceDetails =
                new SandboxAttributeIssuanceDetailsBuilder()
                .WithDefinition("attributeName")
                .WithExpiryDate(new DateTime(2030, 12, 31, 12, 23, 59, 999))
                .WithIssuanceToken("issuanceToken")
                .Build();

            var extraData = new SandboxExtraData(
                new List <SandboxBaseDataEntry> {
                sandboxAttributeIssuanceDetails
            });

            YotiTokenRequest yotiTokenRequest = YotiTokenRequest.Builder()
                                                .WithExtraData(extraData)
                                                .Build();

            var baseResult = yotiTokenRequest.ExtraData.DataEntries.Single();
            var result     = baseResult as SandboxDataEntry <SandboxAttributeIssuanceDetailsValue>;

            Assert.Equal("THIRD_PARTY_ATTRIBUTE", result.Type);
            Assert.Equal("attributeName", result.Value.IssuingAttributes.Definitions.Single().Name);
            Assert.Equal("2030-12-31T12:23:59.999Z", result.Value.IssuingAttributes.ExpiryDate);
            Assert.Equal("issuanceToken", result.Value.IssuanceToken);
        }
예제 #3
0
        public static void ShouldCreateRequestWithRememberMeId()
        {
            YotiTokenRequest yotiTokenRequest = YotiTokenRequest.Builder()
                                                .WithRememberMeId(_someRememberMeId)
                                                .Build();

            Assert.Equal(_someRememberMeId, yotiTokenRequest.RememberMeId);
        }
예제 #4
0
        public static void ShouldAddAnAttributeOnlyOnce()
        {
            YotiTokenRequest yotiTokenRequest = YotiTokenRequest.Builder()
                                                .WithAttribute(SOME_ATTRIBUTE)
                                                .WithAttribute(SOME_ATTRIBUTE)
                                                .Build();

            Assert.True(yotiTokenRequest.SandboxAttributes.Count == 1);
            Assert.Contains(SOME_ATTRIBUTE, yotiTokenRequest.SandboxAttributes);
        }
예제 #5
0
        public static void ShouldCreateRequestWithDateOfBirthFromStringAndAnchors()
        {
            YotiTokenRequest yotiTokenRequest = YotiTokenRequest.Builder()
                                                .WithDateOfBirth(_someDoB, anchors)
                                                .Build();

            ReadOnlyCollection <SandboxAttribute> result = yotiTokenRequest.SandboxAttributes;

            Assert.True(result.Count == 1);
            AttributeMatcher.AssertContainsAttribute(result, Yoti.Auth.Constants.UserProfile.DateOfBirthAttribute, _someDoB, anchors);
        }
예제 #6
0
        public static void ShouldCreateRequestWithPhoneNumber()
        {
            YotiTokenRequest yotiTokenRequest = YotiTokenRequest.Builder()
                                                .WithPhoneNumber(_somePhoneNumber)
                                                .Build();

            ReadOnlyCollection <SandboxAttribute> result = yotiTokenRequest.SandboxAttributes;

            Assert.True(result.Count == 1);
            AttributeMatcher.AssertContainsAttribute(result, Yoti.Auth.Constants.UserProfile.PhoneNumberAttribute, _somePhoneNumber);
        }
예제 #7
0
        public static void ShouldCreateRequestWithStructuredAddress()
        {
            YotiTokenRequest yotiTokenRequest = YotiTokenRequest.Builder()
                                                .WithStructuredPostalAddress(_somePostalAddress)
                                                .Build();

            ReadOnlyCollection <SandboxAttribute> result = yotiTokenRequest.SandboxAttributes;

            Assert.True(result.Count == 1);
            AttributeMatcher.AssertContainsAttribute(result, Yoti.Auth.Constants.UserProfile.StructuredPostalAddressAttribute, _somePostalAddress);
        }
예제 #8
0
        public static void ShouldCreateRequestWithBase64SelfieAndAnchors()
        {
            YotiTokenRequest yotiTokenRequest = YotiTokenRequest.Builder()
                                                .WithBase64Selfie(_someBase64Selfie, anchors)
                                                .Build();

            ReadOnlyCollection <SandboxAttribute> result = yotiTokenRequest.SandboxAttributes;

            Assert.True(result.Count == 1);
            AttributeMatcher.AssertContainsAttribute(result, Yoti.Auth.Constants.UserProfile.SelfieAttribute, _someBase64Selfie, anchors);
        }
예제 #9
0
        public static void ShouldCreateRequestWithDocumentDetailsString()
        {
            YotiTokenRequest yotiTokenRequest = YotiTokenRequest.Builder()
                                                .WithDocumentDetails(_someDocumentDetails)
                                                .Build();

            ReadOnlyCollection <SandboxAttribute> result = yotiTokenRequest.SandboxAttributes;

            Assert.True(result.Count == 1);
            AttributeMatcher.AssertContainsAttribute(result, Yoti.Auth.Constants.UserProfile.DocumentDetailsAttribute, _someDocumentDetails);
        }
예제 #10
0
        public static void ShouldCreateRequestWithFamilyName()
        {
            YotiTokenRequest yotiTokenRequest = YotiTokenRequest.Builder()
                                                .WithFamilyName(_someFamilyName)
                                                .Build();

            ReadOnlyCollection <SandboxAttribute> result = yotiTokenRequest.SandboxAttributes;

            Assert.True(result.Count == 1);
            AttributeMatcher.AssertContainsAttribute(
                result,
                name: Yoti.Auth.Constants.UserProfile.FamilyNameAttribute,
                value: _someFamilyName);
        }
예제 #11
0
        public static void ShouldAddAttributes()
        {
            SandboxAttribute otherAttribute = SandboxAttribute.Builder()
                                              .WithName("otherAttributeName")
                                              .Build();

            YotiTokenRequest yotiTokenRequest = YotiTokenRequest.Builder()
                                                .WithAttribute(SOME_ATTRIBUTE)
                                                .WithAttribute(otherAttribute)
                                                .Build();

            Assert.True(yotiTokenRequest.SandboxAttributes.Count == 2);
            Assert.Contains(SOME_ATTRIBUTE, yotiTokenRequest.SandboxAttributes);
            Assert.Contains(otherAttribute, yotiTokenRequest.SandboxAttributes);
        }
예제 #12
0
        public static void ShouldCreateRequestWithSelfieBytes()
        {
            YotiTokenRequest yotiTokenRequest = YotiTokenRequest.Builder()
                                                .WithSelfie(Encoding.UTF8.GetBytes(_someBase64Selfie))
                                                .Build();

            ReadOnlyCollection <SandboxAttribute> result = yotiTokenRequest.SandboxAttributes;

            Assert.True(result.Count == 1);
            AttributeMatcher.AssertContainsAttribute(
                result,
                Yoti.Auth.Constants.UserProfile.SelfieAttribute,
                Conversion.BytesToBase64(
                    Encoding.UTF8.GetBytes(_someBase64Selfie)));
        }
예제 #13
0
        public static void ShouldAllowSameAttributeWithDifferingDerivationNames()
        {
            SandboxAttribute derivationAttribute = SandboxAttribute.Builder()
                                                   .WithName(_someAttributeName)
                                                   .WithDerivation("derivation1")
                                                   .Build();

            YotiTokenRequest yotiTokenRequest = YotiTokenRequest.Builder()
                                                .WithAttribute(SOME_ATTRIBUTE)
                                                .WithAttribute(derivationAttribute)
                                                .Build();

            Assert.True(yotiTokenRequest.SandboxAttributes.Count == 2);
            Assert.Contains(SOME_ATTRIBUTE, yotiTokenRequest.SandboxAttributes);
            Assert.Contains(derivationAttribute, yotiTokenRequest.SandboxAttributes);
        }
예제 #14
0
        public static void ShouldCreateRequestWithDocumentDetails()
        {
            DocumentDetails documentDetails = new DocumentDetailsBuilder()
                                              .WithType("type")
                                              .WithIssuingCountry("country")
                                              .WithNumber("number")
                                              .Build();
            YotiTokenRequest yotiTokenRequest = YotiTokenRequest.Builder()
                                                .WithDocumentDetails(documentDetails)
                                                .Build();

            ReadOnlyCollection <SandboxAttribute> result = yotiTokenRequest.SandboxAttributes;

            Assert.True(result.Count == 1);
            AttributeMatcher.AssertContainsAttribute(result, Yoti.Auth.Constants.UserProfile.DocumentDetailsAttribute, "type country number");
        }
예제 #15
0
        public static void ShouldCreateRequestWithDateOfBirthFromDateAndAnchors()

        {
            DateTime.TryParseExact(
                s: _someDoB,
                format: "yyyy-MM-dd",
                provider: CultureInfo.InvariantCulture,
                style: DateTimeStyles.None,
                result: out DateTime parsedDate);

            YotiTokenRequest yotiTokenRequest = YotiTokenRequest.Builder()
                                                .WithDateOfBirth(parsedDate, anchors)
                                                .Build();

            ReadOnlyCollection <SandboxAttribute> result = yotiTokenRequest.SandboxAttributes;

            Assert.True(result.Count == 1);
            AttributeMatcher.AssertContainsAttribute(result, Yoti.Auth.Constants.UserProfile.DateOfBirthAttribute, _someDoB, anchors);
        }
예제 #16
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);
        }
예제 #17
0
        public static void ShouldHaveNullExpiryDateIfNotSpecified()
        {
            SandboxAttributeIssuanceDetails sandboxAttributeIssuanceDetails =
                new SandboxAttributeIssuanceDetailsBuilder()
                .WithDefinition("attributeName")
                .WithIssuanceToken("issuanceToken")
                .Build();

            var extraData = new SandboxExtraData(
                new List <SandboxBaseDataEntry> {
                sandboxAttributeIssuanceDetails
            });

            YotiTokenRequest yotiTokenRequest = YotiTokenRequest.Builder()
                                                .WithExtraData(extraData)
                                                .Build();

            var baseResult = yotiTokenRequest.ExtraData.DataEntries.Single();
            var result     = baseResult as SandboxDataEntry <SandboxAttributeIssuanceDetailsValue>;

            Assert.Null(result.Value.IssuingAttributes.ExpiryDate);
        }