コード例 #1
0
        public YotiTokenRequestBuilder WithDocumentImages(SandboxDocumentImages documentImages, List <SandboxAnchor> anchors)
        {
            Validation.NotNull(documentImages, nameof(documentImages));

            SandboxAttribute sandboxAttribute = CreateAttribute(UserProfile.DocumentImagesAttribute, documentImages.GetValue(), anchors);

            return(WithAttribute(sandboxAttribute));
        }
コード例 #2
0
        public YotiTokenRequestBuilder WithAttribute(SandboxAttribute sandboxAttribute)
        {
            Validation.NotNull(sandboxAttribute, nameof(sandboxAttribute));
            string key = sandboxAttribute.Derivation ?? sandboxAttribute.Name;

            _attributes[key] = sandboxAttribute;
            return(this);
        }
コード例 #3
0
        public YotiTokenRequestBuilder WithDateOfBirth(DateTime value)
        {
            SandboxAttribute sandboxAttribute = CreateAttribute(
                UserProfile.DateOfBirthAttribute,
                value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture));

            return(WithAttribute(sandboxAttribute));
        }
コード例 #4
0
 private static SandboxAttribute CreateAttribute(string name, string value, List <SandboxAnchor> anchors)
 {
     return(SandboxAttribute.Builder()
            .WithName(name)
            .WithValue(value)
            .WithAnchors(anchors)
            .Build());
 }
コード例 #5
0
 public SandboxAttribute ToAttribute()
 {
     return(SandboxAttribute.Builder()
            .WithName(UserProfile.DateOfBirthAttribute)
            .WithValue(_dateOfBirth.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture))
            .WithDerivation(_supportedAgeDerivation)
            .WithAnchors(_anchors)
            .Build());
 }
コード例 #6
0
        public YotiTokenRequestBuilder WithDocumentDetails(string value, List <SandboxAnchor> anchors)
        {
            SandboxAttribute sandboxAttribute = SandboxAttribute.Builder()
                                                .WithName(UserProfile.DocumentDetailsAttribute)
                                                .WithValue(value)
                                                .WithAnchors(anchors)
                                                .Build();

            return(WithAttribute(sandboxAttribute));
        }
コード例 #7
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);
        }
コード例 #8
0
        public static void ShouldNotBeOptionalByDefault()
        {
            SandboxAttribute result = SandboxAttribute.Builder()
                                      .WithName(_someName)
                                      .WithDerivation(_someDerivation)
                                      .WithValue(_someValue)
                                      .Build();

            Assert.Equal(_someName, result.Name);
            Assert.Equal(_someDerivation, result.Derivation);
            Assert.Equal(_someValue, result.Value);
#pragma warning disable 0618
            Assert.Equal("False", result.Optional); //NOSONAR
#pragma warning restore 0618
        }
コード例 #9
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);
        }
コード例 #10
0
        public static void ShouldCreateAgeUnderSandboxAttribute()
        {
            SandboxAttribute result = SandboxAgeVerification.Builder()
                                      .WithDateOfBirth(_validDateString)
                                      .WithAgeUnder(16)
                                      .Build()
                                      .ToAttribute();

            Assert.Equal(Yoti.Auth.Constants.UserProfile.DateOfBirthAttribute, result.Name);
            Assert.Equal(_validDateString, result.Value);
            Assert.Equal($"{Yoti.Auth.Constants.UserProfile.AgeUnderAttribute}:{16}", result.Derivation);
#pragma warning disable 0618
            Assert.Equal("False", result.Optional); //NOSONAR
#pragma warning restore 0618
            Assert.Empty(result.Anchors);
        }
コード例 #11
0
        public static void ShouldBeOptionalWhenSpecified()
        {
#pragma warning disable 0618
            SandboxAttribute result = SandboxAttribute.Builder()
                                      .WithName(_someName)
                                      .WithDerivation(_someDerivation)
                                      .WithValue(_someValue)
                                      .WithOptional(true) //NOSONAR
#pragma warning restore 0618

                                      .Build();

            Assert.Equal(_someName, result.Name);
            Assert.Equal(_someDerivation, result.Derivation);
            Assert.Equal(_someValue, result.Value);
#pragma warning disable 0618
            Assert.Equal("True", result.Optional); //NOSONAR
#pragma warning restore 0618
        }
コード例 #12
0
        public YotiTokenRequestBuilder WithDateOfBirth(string value)
        {
            SandboxAttribute sandboxAttribute = CreateAttribute(UserProfile.DateOfBirthAttribute, value);

            return(WithAttribute(sandboxAttribute));
        }
コード例 #13
0
        public YotiTokenRequestBuilder WithStructuredPostalAddress(string value, List <SandboxAnchor> anchors)
        {
            SandboxAttribute sandboxAttribute = CreateAttribute(UserProfile.StructuredPostalAddressAttribute, value, anchors);

            return(WithAttribute(sandboxAttribute));
        }
コード例 #14
0
        public YotiTokenRequestBuilder WithFullName(string value, List <SandboxAnchor> anchors)
        {
            SandboxAttribute sandboxAttribute = CreateAttribute(UserProfile.FullNameAttribute, value, anchors);

            return(WithAttribute(sandboxAttribute));
        }
コード例 #15
0
        public YotiTokenRequestBuilder WithNationality(string value)
        {
            SandboxAttribute sandboxAttribute = CreateAttribute(UserProfile.NationalityAttribute, value);

            return(WithAttribute(sandboxAttribute));
        }
コード例 #16
0
        public YotiTokenRequestBuilder WithBase64Selfie(string value)
        {
            SandboxAttribute sandboxAttribute = CreateAttribute(UserProfile.SelfieAttribute, value);

            return(WithAttribute(sandboxAttribute));
        }
コード例 #17
0
        public YotiTokenRequestBuilder WithEmailAddress(string value)
        {
            SandboxAttribute sandboxAttribute = CreateAttribute(UserProfile.EmailAddressAttribute, value);

            return(WithAttribute(sandboxAttribute));
        }
コード例 #18
0
        public YotiTokenRequestBuilder WithFamilyName(string value)
        {
            SandboxAttribute sandboxAttribute = CreateAttribute(UserProfile.FamilyNameAttribute, value);

            return(WithAttribute(sandboxAttribute));
        }
コード例 #19
0
        public YotiTokenRequestBuilder WithPhoneNumber(string value)
        {
            SandboxAttribute sandboxAttribute = CreateAttribute(UserProfile.PhoneNumberAttribute, value);

            return(WithAttribute(sandboxAttribute));
        }