public static void ShouldBuildSandboxExtraData() { string type = "SOME_TYPE"; var extraData = new SandboxExtraDataBuilder() .WithDataEntry(new SandboxBaseDataEntry(type)) .Build(); Assert.Equal(type, extraData.DataEntries.Single().Type); }
public static void ShouldNotBuildWithEmptyDataEntries() { var exception = Assert.Throws <InvalidOperationException>(() => { var extraData = new SandboxExtraDataBuilder() .Build(); }); Assert.Contains("dataEntries", exception.Message, StringComparison.Ordinal); }
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()); }