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"); }
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); }
public static void ShouldCreateRequestWithRememberMeId() { YotiTokenRequest yotiTokenRequest = YotiTokenRequest.Builder() .WithRememberMeId(_someRememberMeId) .Build(); Assert.Equal(_someRememberMeId, yotiTokenRequest.RememberMeId); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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))); }
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); }
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"); }
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); }
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); }
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); }