From 3de1e4150a56326b4ebd9e166a0216f4a905a52e Mon Sep 17 00:00:00 2001 From: mehmet-yoti Date: Tue, 16 Jun 2026 13:19:38 +0100 Subject: [PATCH] feat(SDK-2787): .NET - Add support for retrieving the extraction_image_ids field from the IDV pages [dotnet] --- .../AdvancedIdentityShareController.cs | 12 +- .../Controllers/HomeController.cs | 12 +- .../Controllers/SuccessController.cs | 10 +- .../DigitalIdentity/Startup.cs | 2 +- .../Controllers/DbsController.cs | 8 +- .../Controllers/HomeController.cs | 10 +- .../Controllers/IdentityProfileController.cs | 4 +- .../DocScanExample/Models/DisplayHelper.cs | 48 +- .../CoreExample/Controllers/HomeController.cs | 16 +- src/Yoti.Auth/CryptoEngine.cs | 14 +- .../DigitalIdentity/DigitalIdentityService.cs | 48 +- src/Yoti.Auth/DigitalIdentity/ErrorDetails.cs | 2 +- src/Yoti.Auth/DigitalIdentity/ErrorReason.cs | 4 +- .../Policy/AdvancedIdentityProfile.cs | 2 +- .../DigitalIdentity/Policy/Notification.cs | 2 +- .../Policy/NotificationBuilder.cs | 10 +- .../DigitalIdentity/Policy/Policy.cs | 6 +- .../DigitalIdentity/Policy/PolicyBuilder.cs | 2 +- .../Policy/WantedAttributeBuilder.cs | 2 +- .../DigitalIdentity/QrRequestBuilder.cs | 4 +- .../DigitalIdentity/ShareSessionRequest.cs | 8 +- .../DigitalIdentity/ShareSessionResult.cs | 2 +- src/Yoti.Auth/DigitalIdentityClient.cs | 10 +- src/Yoti.Auth/DigitalIdentityClientEngine.cs | 12 +- src/Yoti.Auth/DocScan/DocScanService.cs | 8 +- .../Advanced/RequestedCaMatchingStrategy.cs | 16 +- .../Check/Advanced/RequestedCaSources.cs | 16 +- .../RequestedFuzzyMatchingStrategy.cs | 20 +- .../Advanced/RequestedSearchProfileSources.cs | 20 +- .../Advanced/RequestedTypeListSources.cs | 20 +- ...dWatchlistAdvancedCaConfigCustomAccount.cs | 40 +- ...tedWatchlistAdvancedCaConfigYotiAccount.cs | 16 +- .../RequestedFaceComparisonCheckBuilder.cs | 2 +- ...istAdvancedCaCheckBuilder.CustomAccount.cs | 2 +- ...hlistAdvancedCaCheckBuilder.YotiAccount.cs | 16 +- ...equestedWatchlistAdvancedCaCheckBuilder.cs | 2 +- ...RequestedWatchlistScreeningCheckBuilder.cs | 90 +-- .../Create/NotificationConfigBuilder.cs | 4 +- .../Session/Create/SdkConfigBuilder.cs | 2 +- .../Session/Create/SessionSpecification.cs | 2 +- .../Create/SessionSpecificationBuilder.cs | 2 +- .../FailureReasonResponse.cs | 2 +- .../Retrieve/Check/ProfileCheckResponse.cs | 16 +- .../CaMatchingStrategyResponse.cs | 16 +- .../WatchlistSummary/CaSourcesResponse.cs | 10 +- .../ExactMatchingStrategyResponse.cs | 10 +- .../FuzzyMatchingStrategyResponse.cs | 10 +- .../Check/WatchlistSummary/ISearchConfig.cs | 12 +- .../Check/WatchlistSummary/RawResults.cs | 10 +- .../ReportResponseWithSummary.cs | 10 +- .../SearchProfileSourcesResponse.cs | 10 +- .../TypeListSourcesResponse.cs | 10 +- ...WatchlistAdvancedCaSearchConfigResponse.cs | 32 +- ...ncedCaSearchConfigResponseCustomAccount.cs | 22 +- ...vancedCaSearchConfigResponseYotiAccount.cs | 6 +- .../WatchlistScreeningConfig.cs | 10 +- ...WatchlistSummaryReportBaseCheckResponse.cs | 6 +- .../Session/Retrieve/GetSessionResult.cs | 2 +- .../IdentityProfile/FailureReasonResponse.cs | 2 +- .../DocScan/Session/Retrieve/PageResponse.cs | 3 + .../Resource/LivenessResourceResponse.cs | 2 +- .../Exceptions/YotiProfileException.cs | 50 +- src/Yoti.Auth/GlobalSuppressions.cs | 3 +- .../ShareUrl/Policy/DynamicPolicy.cs | 6 +- .../ShareUrl/Policy/DynamicPolicyBuilder.cs | 2 +- .../ShareUrl/Policy/WantedAttributeBuilder.cs | 2 +- src/Yoti.Auth/Web/RequestBuilder.cs | 12 +- test/Yoti.Auth.Tests/CryptoEngineTests.cs | 2 +- .../Policy/DynamicPolicyBuilderTests.cs | 8 +- .../DigitalIdentity/QrRequestBuilderTests.cs | 4 +- .../RequirementNotMetDetails.cs | 6 +- .../ShareSessionRequestBuilderTests.cs | 4 +- .../DigitalIdentityClientEngineTests.cs | 286 ++++---- .../DigitalIdentityClientTests.cs | 4 +- .../DocScan/DocScanClientTests.cs | 4 +- ...stedWatchlistScreeningCheckBuilderTests.cs | 2 +- .../Session/Create/NotificationConfigTests.cs | 4 +- .../SessionSpecificationBuilderTests.cs | 12 +- .../Retrieve/Check/CheckResponseTests.cs | 71 ++ .../Session/Retrieve/GetSessionResultTests.cs | 6 +- .../ShareUrl/DynamicScenarioBuilderTests.cs | 2 +- .../Policy/DynamicPolicyBuilderTests.cs | 2 +- .../TestData/IdentityProfiles.cs | 6 +- .../Yoti.Auth.Tests/TestTools/ShareSession.cs | 2 +- test/Yoti.Auth.Tests/YotiClientEngineTests.cs | 608 +++++++++--------- 85 files changed, 956 insertions(+), 881 deletions(-) diff --git a/src/Examples/DigitalIdentity/DigitalIdentity/Controllers/AdvancedIdentityShareController.cs b/src/Examples/DigitalIdentity/DigitalIdentity/Controllers/AdvancedIdentityShareController.cs index b6cf7f5b..e511d0da 100644 --- a/src/Examples/DigitalIdentity/DigitalIdentity/Controllers/AdvancedIdentityShareController.cs +++ b/src/Examples/DigitalIdentity/DigitalIdentity/Controllers/AdvancedIdentityShareController.cs @@ -20,7 +20,7 @@ public AdvancedIdentityShareController(ILogger _clientSdkId = Environment.GetEnvironmentVariable("YOTI_CLIENT_SDK_ID"); _logger.LogInformation(string.Format("Yoti Client SDK ID='{0}'", _clientSdkId)); } - + // GET: /advanced-identity-share [Route("advanced-identity-share")] public IActionResult DigitalIdentity() @@ -36,7 +36,7 @@ public IActionResult DigitalIdentity() StreamReader privateKeyStream = System.IO.File.OpenText(yotiKeyFilePath); var yotiClient = new DigitalIdentityClient(_clientSdkId, privateKeyStream); - + string advancedIdentityProfileJson = @" { ""profiles"": [ @@ -60,9 +60,9 @@ public IActionResult DigitalIdentity() ] }"; - + var advancedIdentityProfile = JsonConvert.DeserializeObject(advancedIdentityProfileJson); - + var policy = new PolicyBuilder() .WithAdvancedIdentityProfileRequirements(advancedIdentityProfile) .Build(); @@ -85,10 +85,10 @@ public IActionResult DigitalIdentity() exception: e, message: e.Message); - TempData["Error"] = e.Message; + TempData["Error"] = e.Message; TempData["InnerException"] = e.InnerException?.Message; return RedirectToAction("Error", "Success"); } } - } + } } diff --git a/src/Examples/DigitalIdentity/DigitalIdentity/Controllers/HomeController.cs b/src/Examples/DigitalIdentity/DigitalIdentity/Controllers/HomeController.cs index 04a06bfa..c6f33a77 100644 --- a/src/Examples/DigitalIdentity/DigitalIdentity/Controllers/HomeController.cs +++ b/src/Examples/DigitalIdentity/DigitalIdentity/Controllers/HomeController.cs @@ -19,7 +19,7 @@ public HomeController(ILogger logger) _clientSdkId = Environment.GetEnvironmentVariable("YOTI_CLIENT_SDK_ID"); _logger.LogInformation(string.Format("Yoti Client SDK ID='{0}'", _clientSdkId)); } - + // GET: /generate-share [Route("generate-share")] public IActionResult DigitalIdentity() @@ -40,13 +40,13 @@ public IActionResult DigitalIdentity() .WithName("given_names") .WithOptional(false) .Build(); - + var notification = new NotificationBuilder() .WithUrl("https://example.com/webhook") .WithMethod("POST") .WithVerifyTls(true) .Build(); - + var policy = new PolicyBuilder() .WithWantedAttribute(givenNamesWantedAttribute) .WithFullName() @@ -57,7 +57,7 @@ public IActionResult DigitalIdentity() .WithNationality() .WithGender() .WithDocumentDetails() - .WithDocumentImages() + .WithDocumentImages() .Build(); var sessionReq = new ShareSessionRequestBuilder().WithPolicy(policy) @@ -81,10 +81,10 @@ public IActionResult DigitalIdentity() exception: e, message: e.Message); - TempData["Error"] = e.Message; + TempData["Error"] = e.Message; TempData["InnerException"] = e.InnerException?.Message; return RedirectToAction("Error", "Success"); } } - } + } } diff --git a/src/Examples/DigitalIdentity/DigitalIdentity/Controllers/SuccessController.cs b/src/Examples/DigitalIdentity/DigitalIdentity/Controllers/SuccessController.cs index aeac61a2..354352c5 100644 --- a/src/Examples/DigitalIdentity/DigitalIdentity/Controllers/SuccessController.cs +++ b/src/Examples/DigitalIdentity/DigitalIdentity/Controllers/SuccessController.cs @@ -43,9 +43,9 @@ public IActionResult ReceiptInfo(string ReceiptID) StreamReader privateKeyStream = System.IO.File.OpenText(yotiKeyFilePath); var yotiClient = new DigitalIdentityClient(_clientSdkId, privateKeyStream); - + var ReceiptResult = yotiClient.GetShareReceipt(ReceiptID); - + DisplayAttributes displayAttributes = CreateDisplayAttributes(ReceiptResult.UserContent.UserProfile.AttributeCollection); if (ReceiptResult.UserContent.UserProfile.FullName != null) { @@ -58,7 +58,7 @@ public IActionResult ReceiptInfo(string ReceiptID) displayAttributes.Base64Selfie = selfie.GetValue().GetBase64URI(); } ViewBag.YotiClientSdkId = _clientSdkId; - + return View("SuccessResult", displayAttributes); } catch (Exception e) @@ -72,7 +72,7 @@ public IActionResult ReceiptInfo(string ReceiptID) return RedirectToAction("Error", "Success"); } } - + private static DisplayAttributes CreateDisplayAttributes(ReadOnlyCollection attributes) { var displayAttributes = new DisplayAttributes(); @@ -159,5 +159,5 @@ private static void AddDisplayAttribute(string name, string icon, BaseAttribu if (baseAttribute is YotiAttribute yotiAttribute) displayAttributes.Add(name, icon, yotiAttribute.GetAnchors(), yotiAttribute.GetValue()); } - } + } } diff --git a/src/Examples/DigitalIdentity/DigitalIdentity/Startup.cs b/src/Examples/DigitalIdentity/DigitalIdentity/Startup.cs index 04dd3919..2cb1b56a 100644 --- a/src/Examples/DigitalIdentity/DigitalIdentity/Startup.cs +++ b/src/Examples/DigitalIdentity/DigitalIdentity/Startup.cs @@ -46,7 +46,7 @@ public void ConfigureServices(IServiceCollection services) options.Cookie.IsEssential = true; }); } - + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { diff --git a/src/Examples/DocScan/DocScanExample/Controllers/DbsController.cs b/src/Examples/DocScan/DocScanExample/Controllers/DbsController.cs index 8de33104..f137b3bc 100644 --- a/src/Examples/DocScan/DocScanExample/Controllers/DbsController.cs +++ b/src/Examples/DocScan/DocScanExample/Controllers/DbsController.cs @@ -13,7 +13,7 @@ using Yoti.Auth.DocScan.Session.Create.Filter; using Yoti.Auth.DocScan.Session.Create.Objectives; using Yoti.Auth.DocScan.Session.Create.Task; - + namespace DocScanExample.Controllers { public class DbsController : Controller @@ -26,7 +26,7 @@ public class DbsController : Controller public DbsController(IHttpContextAccessor httpContextAccessor) { var request = httpContextAccessor.HttpContext.Request; - + _baseUrl = $"{request.Scheme}://{request.Host}"; ; _apiUrl = GetApiUrl(); _client = GetDocScanClient(_apiUrl); @@ -92,12 +92,12 @@ public IActionResult Index() .WithSubject(new { subject_id = "some_subject_id_string" - }) + }) .Build(); CreateSessionResult createSessionResult = _client.CreateSession(sessionSpec); string sessionId = createSessionResult.SessionId; - + string path = $"web/index.html?sessionID={sessionId}&sessionToken={createSessionResult.ClientSessionToken}"; Uri uri = new Uri(_apiUrl, path); diff --git a/src/Examples/DocScan/DocScanExample/Controllers/HomeController.cs b/src/Examples/DocScan/DocScanExample/Controllers/HomeController.cs index 2aecebd1..0b4b2628 100644 --- a/src/Examples/DocScan/DocScanExample/Controllers/HomeController.cs +++ b/src/Examples/DocScan/DocScanExample/Controllers/HomeController.cs @@ -13,7 +13,7 @@ using Yoti.Auth.DocScan.Session.Create.Filter; using Yoti.Auth.DocScan.Session.Create.Objectives; using Yoti.Auth.DocScan.Session.Create.Task; - + namespace DocScanExample.Controllers { public class HomeController : Controller @@ -26,7 +26,7 @@ public class HomeController : Controller public HomeController(IHttpContextAccessor httpContextAccessor) { var request = httpContextAccessor.HttpContext.Request; - + _baseUrl = $"{request.Scheme}://{request.Host}"; ; _apiUrl = GetApiUrl(); _client = GetDocScanClient(_apiUrl); @@ -126,16 +126,16 @@ public IActionResult Index() .Build() ) .WithRequiredDocument( - new RequiredSupplementaryDocumentBuilder() + new RequiredSupplementaryDocumentBuilder() .WithObjective( new ProofOfAddressObjectiveBuilder().Build()) .Build() - ) + ) .Build(); CreateSessionResult createSessionResult = _client.CreateSession(sessionSpec); string sessionId = createSessionResult.SessionId; - + string path = $"web/index.html?sessionID={sessionId}&sessionToken={createSessionResult.ClientSessionToken}"; Uri uri = new Uri(_apiUrl, path); diff --git a/src/Examples/DocScan/DocScanExample/Controllers/IdentityProfileController.cs b/src/Examples/DocScan/DocScanExample/Controllers/IdentityProfileController.cs index 55c88587..533c8082 100644 --- a/src/Examples/DocScan/DocScanExample/Controllers/IdentityProfileController.cs +++ b/src/Examples/DocScan/DocScanExample/Controllers/IdentityProfileController.cs @@ -13,7 +13,7 @@ using Yoti.Auth.DocScan.Session.Create.Filter; using Yoti.Auth.DocScan.Session.Create.Objectives; using Yoti.Auth.DocScan.Session.Create.Task; - + namespace DocScanExample.Controllers { public class IdentityProfileController : Controller @@ -98,7 +98,7 @@ public IActionResult Index() CreateSessionResult createSessionResult = _client.CreateSession(sessionSpec); string sessionId = createSessionResult.SessionId; - + string path = $"web/index.html?sessionID={sessionId}&sessionToken={createSessionResult.ClientSessionToken}"; Uri uri = new Uri(_apiUrl, path); diff --git a/src/Examples/DocScan/DocScanExample/Models/DisplayHelper.cs b/src/Examples/DocScan/DocScanExample/Models/DisplayHelper.cs index 76243113..b39e9ef2 100644 --- a/src/Examples/DocScan/DocScanExample/Models/DisplayHelper.cs +++ b/src/Examples/DocScan/DocScanExample/Models/DisplayHelper.cs @@ -4,29 +4,29 @@ namespace DocScanExample.Models { - public static class DisplayHelper + public static class DisplayHelper { - public static string GetSummaryResponseKindText(ReportResponseWithSummary advancedReport) - { - var searchConfigType = advancedReport.WatchlistSummary.SearchConfig.GetType(); - if (searchConfigType == typeof(WatchlistAdvancedCaSearchConfigResponseYotiAccount)) - { - return "Yoti Account"; - } - if (searchConfigType == typeof(WatchlistAdvancedCaSearchConfigResponseCustomAccount)) - { - return "Custom Account"; - } - if (searchConfigType == typeof(WatchlistScreeningConfig)) - { - return "Watchlist Screening"; - } - return "N/A"; - } - public static string GetPrettifiedWatchlistSearchConfig(ReportResponseWithSummary advancedReport) - { - var json = JsonConvert.SerializeObject(advancedReport.WatchlistSummary.SearchConfig); - return JValue.Parse(json).ToString(Formatting.Indented); - } - } + public static string GetSummaryResponseKindText(ReportResponseWithSummary advancedReport) + { + var searchConfigType = advancedReport.WatchlistSummary.SearchConfig.GetType(); + if (searchConfigType == typeof(WatchlistAdvancedCaSearchConfigResponseYotiAccount)) + { + return "Yoti Account"; + } + if (searchConfigType == typeof(WatchlistAdvancedCaSearchConfigResponseCustomAccount)) + { + return "Custom Account"; + } + if (searchConfigType == typeof(WatchlistScreeningConfig)) + { + return "Watchlist Screening"; + } + return "N/A"; + } + public static string GetPrettifiedWatchlistSearchConfig(ReportResponseWithSummary advancedReport) + { + var json = JsonConvert.SerializeObject(advancedReport.WatchlistSummary.SearchConfig); + return JValue.Parse(json).ToString(Formatting.Indented); + } + } } \ No newline at end of file diff --git a/src/Examples/Profile/CoreExample/Controllers/HomeController.cs b/src/Examples/Profile/CoreExample/Controllers/HomeController.cs index b7223432..9b147f2b 100644 --- a/src/Examples/Profile/CoreExample/Controllers/HomeController.cs +++ b/src/Examples/Profile/CoreExample/Controllers/HomeController.cs @@ -102,14 +102,14 @@ public IActionResult DBSStandard() DynamicPolicy dynamicPolicy = new DynamicPolicyBuilder() .WithIdentityProfileRequirements(new - { - trust_framework = "UK_TFIDA", - scheme = new - { - type = "DBS", - objective = "BASIC" - } - }) + { + trust_framework = "UK_TFIDA", + scheme = new + { + type = "DBS", + objective = "BASIC" + } + }) .Build(); var dynamicScenario = new DynamicScenarioBuilder() diff --git a/src/Yoti.Auth/CryptoEngine.cs b/src/Yoti.Auth/CryptoEngine.cs index 6951da93..07402527 100644 --- a/src/Yoti.Auth/CryptoEngine.cs +++ b/src/Yoti.Auth/CryptoEngine.cs @@ -43,10 +43,10 @@ internal static byte[] DecipherAes(byte[] key, byte[] iv, byte[] cipherBytes) var result = new byte[numOutputBytes]; Array.Copy(outputBuffer, result, numOutputBytes); - + return result; } - + internal static byte[] DecryptRsa(byte[] cipherBytes, AsymmetricCipherKeyPair keypair) { // decrypt using rsa with private key and PKCS 1 v1.5 padding @@ -133,14 +133,14 @@ internal static string GetAuthKey(AsymmetricCipherKeyPair keyPair) return Conversion.BytesToBase64(publicKey); } - + public static byte[] DecryptAesGcm(byte[] cipherText, byte[] iv, byte[] secret) { try { GcmBlockCipher cipher = new GcmBlockCipher(new Org.BouncyCastle.Crypto.Engines.AesEngine()); ParametersWithIV parameters = new ParametersWithIV(new KeyParameter(secret), iv); - + cipher.Init(false, parameters); byte[] plainText = new byte[cipher.GetOutputSize(cipherText.Length)]; @@ -154,7 +154,7 @@ public static byte[] DecryptAesGcm(byte[] cipherText, byte[] iv, byte[] secret) throw new Exception($"Failed to decrypt receipt key: {ex.Message}", ex); } } - + public static byte[] UnwrapReceiptKey(byte[] wrappedReceiptKey, byte[] encryptedItemKey, byte[] itemKeyIv, AsymmetricCipherKeyPair key) { try @@ -170,7 +170,7 @@ public static byte[] UnwrapReceiptKey(byte[] wrappedReceiptKey, byte[] encrypted throw new Exception($"Failed to unwrap receipt key: {ex.Message}", ex); } } - + public static byte[] DecryptReceiptContent(byte[] content, byte[] receiptContentKey) { try @@ -185,7 +185,7 @@ public static byte[] DecryptReceiptContent(byte[] content, byte[] receiptContent return DecipherAes(receiptContentKey, decodedData.Iv.ToByteArray(), decodedData.CipherText.ToByteArray()); } - catch(Exception ex) + catch (Exception ex) { throw new Exception($"Failed to decrypt receipt content: {ex.Message}", ex); } diff --git a/src/Yoti.Auth/DigitalIdentity/DigitalIdentityService.cs b/src/Yoti.Auth/DigitalIdentity/DigitalIdentityService.cs index 3043fca8..37c2d921 100644 --- a/src/Yoti.Auth/DigitalIdentity/DigitalIdentityService.cs +++ b/src/Yoti.Auth/DigitalIdentity/DigitalIdentityService.cs @@ -70,7 +70,7 @@ internal static async Task GetSession(HttpClient httpClient, U Validation.NotNull(apiUrl, nameof(apiUrl)); Validation.NotNull(sdkId, nameof(sdkId)); Validation.NotNull(keyPair, nameof(keyPair)); - Validation.NotNull(sessionId, nameof(sessionId)); + Validation.NotNull(sessionId, nameof(sessionId)); Request getSessionRequest = new RequestBuilder() @@ -96,7 +96,7 @@ internal static async Task GetSession(HttpClient httpClient, U } } - internal static async Task CreateQrCode(HttpClient httpClient, Uri apiUrl, string sdkId, AsymmetricCipherKeyPair keyPair, string sessionId,QrRequest qrRequestPayload) + internal static async Task CreateQrCode(HttpClient httpClient, Uri apiUrl, string sdkId, AsymmetricCipherKeyPair keyPair, string sessionId, QrRequest qrRequestPayload) { Validation.NotNull(httpClient, nameof(httpClient)); Validation.NotNull(apiUrl, nameof(apiUrl)); @@ -121,7 +121,7 @@ internal static async Task CreateQrCode(HttpClient httpClient, U .WithHttpMethod(HttpMethod.Post) .WithContent(body) .Build(); - + using (HttpResponseMessage response = await createQrRequest.Execute(httpClient).ConfigureAwait(false)) { if (!response.IsSuccessStatusCode) @@ -135,7 +135,7 @@ internal static async Task CreateQrCode(HttpClient httpClient, U return deserialized; } } - + internal static async Task GetQrCode(HttpClient httpClient, Uri apiUrl, string sdkId, AsymmetricCipherKeyPair keyPair, string qrCodeId) { Validation.NotNull(httpClient, nameof(httpClient)); @@ -166,17 +166,17 @@ internal static async Task GetQrCode(HttpClient httpClient, Uri return deserialized; } } - - private static async Task GetReceipt(HttpClient httpClient, string receiptId, string sdkId,Uri apiUrl, AsymmetricCipherKeyPair keyPair) + + private static async Task GetReceipt(HttpClient httpClient, string receiptId, string sdkId, Uri apiUrl, AsymmetricCipherKeyPair keyPair) { Validation.NotNull(httpClient, nameof(httpClient)); Validation.NotNull(apiUrl, nameof(apiUrl)); Validation.NotNull(sdkId, nameof(sdkId)); Validation.NotNull(keyPair, nameof(keyPair)); - string receiptUrl = Base64ToBase64URL(receiptId); + string receiptUrl = Base64ToBase64URL(receiptId); string endpoint = string.Format(receiptRetrieval, receiptUrl); - + Request ReceiptRequest = new RequestBuilder() .WithKeyPair(keyPair) .WithBaseUri(apiUrl) @@ -199,7 +199,7 @@ private static async Task GetReceipt(HttpClient httpClient, str return deserialized; } } - + public static string Base64ToBase64URL(string base64Str) { @@ -214,7 +214,7 @@ public static string Base64ToBase64URL(string base64Str) } catch (FormatException) { - return ""; + return ""; } } @@ -225,7 +225,7 @@ public static async Task GetShareReceipt(HttpClient httpC { var receiptResponse = await GetReceipt(httpClient, receiptId, clientSdkId, apiUrl, key); var itemKeyId = receiptResponse.WrappedItemKeyId; - + var encryptedItemKeyResponse = await GetReceiptItemKey(httpClient, itemKeyId, clientSdkId, apiUrl, key); var receiptContentKey = CryptoEngine.UnwrapReceiptKey(receiptResponse.WrappedKey, encryptedItemKeyResponse.Value, encryptedItemKeyResponse.Iv, key); @@ -236,10 +236,10 @@ public static async Task GetShareReceipt(HttpClient httpC throw new Exception($"An unexpected error occurred: {decryptAttrDataError.Message}"); } - var parsedAttributesApp = AttributeConverter.ConvertToBaseAttributes(attrData); + var parsedAttributesApp = AttributeConverter.ConvertToBaseAttributes(attrData); var appProfile = new ApplicationProfile(parsedAttributesApp ); - + var (attrOtherData, aOtherExtra, decryptOtherAttrDataError) = DecryptReceiptContent(receiptResponse.OtherPartyContent, receiptContentKey); if (decryptAttrDataError != null) { @@ -249,11 +249,11 @@ public static async Task GetShareReceipt(HttpClient httpC var userProfile = new YotiProfile(); if (attrOtherData != null) { - var parsedAttributesUser = AttributeConverter.ConvertToBaseAttributes(attrOtherData); + var parsedAttributesUser = AttributeConverter.ConvertToBaseAttributes(attrOtherData); userProfile = new YotiProfile(parsedAttributesUser); } - - + + ExtraData userExtraData = new ExtraData(); if (aOtherExtra != null) { @@ -262,10 +262,10 @@ public static async Task GetShareReceipt(HttpClient httpC ExtraData appExtraData = new ExtraData(); if (aextra != null) { - + appExtraData = ExtraDataConverter.ParseExtraDataProto(aextra); } - + var sharedReceiptResponse = new SharedReceiptResponse { ID = receiptResponse.ID, @@ -285,15 +285,15 @@ public static async Task GetShareReceipt(HttpClient httpC }, Error = receiptResponse.Error, ErrorDetails = receiptResponse.ErrorDetails - + }; return sharedReceiptResponse; } - catch (Exception ex) + catch (Exception ex) { throw new Exception($"An unexpected error occurred: {ex.Message}"); - + } } @@ -364,10 +364,10 @@ public static (AttributeList attrData, byte[] aextra, Exception error) DecryptRe } } } - + return (attrData, aextra, null); } } - - + + } diff --git a/src/Yoti.Auth/DigitalIdentity/ErrorDetails.cs b/src/Yoti.Auth/DigitalIdentity/ErrorDetails.cs index b100a87d..ca42d168 100644 --- a/src/Yoti.Auth/DigitalIdentity/ErrorDetails.cs +++ b/src/Yoti.Auth/DigitalIdentity/ErrorDetails.cs @@ -13,5 +13,5 @@ public ErrorReason GetErrorReason() return ErrorReason; } } - + } diff --git a/src/Yoti.Auth/DigitalIdentity/ErrorReason.cs b/src/Yoti.Auth/DigitalIdentity/ErrorReason.cs index f6244513..94da5592 100644 --- a/src/Yoti.Auth/DigitalIdentity/ErrorReason.cs +++ b/src/Yoti.Auth/DigitalIdentity/ErrorReason.cs @@ -8,7 +8,7 @@ namespace Yoti.Auth.DigitalIdentity public class ErrorReason { public RequirementNotMetDetails RequirementNotMetDetails { get; private set; } - + } - + } diff --git a/src/Yoti.Auth/DigitalIdentity/Policy/AdvancedIdentityProfile.cs b/src/Yoti.Auth/DigitalIdentity/Policy/AdvancedIdentityProfile.cs index 40896fdd..3dd66502 100644 --- a/src/Yoti.Auth/DigitalIdentity/Policy/AdvancedIdentityProfile.cs +++ b/src/Yoti.Auth/DigitalIdentity/Policy/AdvancedIdentityProfile.cs @@ -26,5 +26,5 @@ public class Scheme [JsonProperty(PropertyName = "type")] public string Type { get; set; } } - + } diff --git a/src/Yoti.Auth/DigitalIdentity/Policy/Notification.cs b/src/Yoti.Auth/DigitalIdentity/Policy/Notification.cs index a385526d..46c5bdf9 100644 --- a/src/Yoti.Auth/DigitalIdentity/Policy/Notification.cs +++ b/src/Yoti.Auth/DigitalIdentity/Policy/Notification.cs @@ -14,7 +14,7 @@ public class Notification public Dictionary Headers { get; set; } // Optional [JsonProperty(PropertyName = "verifyTls")] public bool VerifyTls { get; set; } = true; // Optional, defaults to 'true' if URL is HTTPS - + public Notification(string url, string method, Dictionary headers, bool verifyTls) { Url = url; diff --git a/src/Yoti.Auth/DigitalIdentity/Policy/NotificationBuilder.cs b/src/Yoti.Auth/DigitalIdentity/Policy/NotificationBuilder.cs index 57ffe60e..7472e068 100644 --- a/src/Yoti.Auth/DigitalIdentity/Policy/NotificationBuilder.cs +++ b/src/Yoti.Auth/DigitalIdentity/Policy/NotificationBuilder.cs @@ -8,7 +8,7 @@ public class NotificationBuilder private string _method; private Dictionary _headers; private bool _verifyTls; - + /// /// Set the URL for the notification, required if 'notification' is defined, required /// @@ -19,7 +19,7 @@ public NotificationBuilder WithUrl(string url) _url = url; return this; } - + /// /// Set the method for the notification, defaults to 'POST', optional /// @@ -30,7 +30,7 @@ public NotificationBuilder WithMethod(string method) _method = method; return this; } - + /// /// Set the headers for the notification, optional /// @@ -41,7 +41,7 @@ public NotificationBuilder WithHeaders(Dictionary headers) _headers = headers; return this; } - + /// /// Set to false to disable TLS verification, defaults to 'true' if URL is HTTPS, optional /// @@ -52,7 +52,7 @@ public NotificationBuilder WithVerifyTls(bool verifyTls) _verifyTls = verifyTls; return this; } - + public Notification Build() { Validation.NotNullOrEmpty(_url, nameof(_url)); diff --git a/src/Yoti.Auth/DigitalIdentity/Policy/Policy.cs b/src/Yoti.Auth/DigitalIdentity/Policy/Policy.cs index 9bd799ec..979df712 100644 --- a/src/Yoti.Auth/DigitalIdentity/Policy/Policy.cs +++ b/src/Yoti.Auth/DigitalIdentity/Policy/Policy.cs @@ -32,7 +32,7 @@ public class Policy [JsonProperty(PropertyName = "advanced_identity_profile_requirements")] private readonly object _advancedIdentityProfileRequirements; - + public Policy( ICollection wantedAttributes, HashSet wantedAuthTypes, @@ -47,7 +47,7 @@ public Policy( _isWantedRememberMeIdOptional = false; _identityProfileRequirements = identityProfileRequirements; _advancedIdentityProfileRequirements = advancedIdentityProfileRequirements; - + } /// @@ -97,7 +97,7 @@ public object IdentityProfileRequirements return _identityProfileRequirements; } } - + /// /// AdvancedIdentityProfileRequirements requested in the policy /// diff --git a/src/Yoti.Auth/DigitalIdentity/Policy/PolicyBuilder.cs b/src/Yoti.Auth/DigitalIdentity/Policy/PolicyBuilder.cs index d85c9694..3c2a07c1 100644 --- a/src/Yoti.Auth/DigitalIdentity/Policy/PolicyBuilder.cs +++ b/src/Yoti.Auth/DigitalIdentity/Policy/PolicyBuilder.cs @@ -158,7 +158,7 @@ public PolicyBuilder WithIdentityProfileRequirements(object identityProfileRequi _identityProfileRequirements = identityProfileRequirements; return this; } - + /// /// Use an Advanced Identity Profile Requirement object for the share /// diff --git a/src/Yoti.Auth/DigitalIdentity/Policy/WantedAttributeBuilder.cs b/src/Yoti.Auth/DigitalIdentity/Policy/WantedAttributeBuilder.cs index 34bfc1fa..d66ab920 100644 --- a/src/Yoti.Auth/DigitalIdentity/Policy/WantedAttributeBuilder.cs +++ b/src/Yoti.Auth/DigitalIdentity/Policy/WantedAttributeBuilder.cs @@ -21,7 +21,7 @@ public WantedAttributeBuilder WithOptional(bool optional) _optional = optional; return this; } - + public WantedAttributeBuilder WithDerivation(string derivation) { _derivation = derivation; diff --git a/src/Yoti.Auth/DigitalIdentity/QrRequestBuilder.cs b/src/Yoti.Auth/DigitalIdentity/QrRequestBuilder.cs index 2e066d3d..d6c40f4d 100644 --- a/src/Yoti.Auth/DigitalIdentity/QrRequestBuilder.cs +++ b/src/Yoti.Auth/DigitalIdentity/QrRequestBuilder.cs @@ -27,13 +27,13 @@ public QrRequestBuilder WithTransport(string transport) /// with a Display Mode added public QrRequestBuilder WithDisplayMode(string displayMode) { - _displayMode = displayMode ; + _displayMode = displayMode; return this; } public QrRequest Build() { - return new QrRequest(_transport,_displayMode); + return new QrRequest(_transport, _displayMode); } } } diff --git a/src/Yoti.Auth/DigitalIdentity/ShareSessionRequest.cs b/src/Yoti.Auth/DigitalIdentity/ShareSessionRequest.cs index c1d24ddc..1976a3a3 100644 --- a/src/Yoti.Auth/DigitalIdentity/ShareSessionRequest.cs +++ b/src/Yoti.Auth/DigitalIdentity/ShareSessionRequest.cs @@ -7,7 +7,7 @@ namespace Yoti.Auth.DigitalIdentity { public class ShareSessionRequest { - + [JsonProperty(PropertyName = "policy")] private readonly Policy.Policy _dynamicPolicy; @@ -18,12 +18,12 @@ public class ShareSessionRequest private readonly object _subject; [JsonProperty(PropertyName = "redirectUri")] - public string _redirectUri { get; set; } + public string _redirectUri { get; set; } [JsonProperty(PropertyName = "notification")] - public Notification _notification { get; set; } + public Notification _notification { get; set; } + - [JsonIgnore] public Policy.Policy DynamicPolicy diff --git a/src/Yoti.Auth/DigitalIdentity/ShareSessionResult.cs b/src/Yoti.Auth/DigitalIdentity/ShareSessionResult.cs index eb04f88d..67605c04 100644 --- a/src/Yoti.Auth/DigitalIdentity/ShareSessionResult.cs +++ b/src/Yoti.Auth/DigitalIdentity/ShareSessionResult.cs @@ -20,5 +20,5 @@ public class ShareSessionResult } - + } \ No newline at end of file diff --git a/src/Yoti.Auth/DigitalIdentityClient.cs b/src/Yoti.Auth/DigitalIdentityClient.cs index 628a1a06..9f6acbf9 100644 --- a/src/Yoti.Auth/DigitalIdentityClient.cs +++ b/src/Yoti.Auth/DigitalIdentityClient.cs @@ -57,7 +57,7 @@ public DigitalIdentityClient(HttpClient httpClient, string sdkId, AsymmetricCiph _yotiDigitalClientEngine = new DigitalIdentityClientEngine(httpClient); } - + /// /// Initiate a sharing process based on a . /// @@ -91,18 +91,18 @@ public SharedReceiptResponse GetShareReceipt(string receiptId) Task task = Task.Run(async () => await _yotiDigitalClientEngine.GetShareReceipt(_sdkId, _keyPair, ApiUri, receiptId).ConfigureAwait(false)); return task.Result; } - - + + public async Task CreateQrCode(string sessionId, QrRequest qrRequest) { return await _yotiDigitalClientEngine.CreateQrCodeAsync(_sdkId, _keyPair, ApiUri, sessionId, qrRequest).ConfigureAwait(false); } - + public async Task GetQrCode(string qrCodeId) { return await _yotiDigitalClientEngine.GetQrCodeAsync(_sdkId, _keyPair, ApiUri, qrCodeId).ConfigureAwait(false); } - + public async Task GetSession(string sessionId) { return await _yotiDigitalClientEngine.GetSession(_sdkId, _keyPair, ApiUri, sessionId).ConfigureAwait(false); diff --git a/src/Yoti.Auth/DigitalIdentityClientEngine.cs b/src/Yoti.Auth/DigitalIdentityClientEngine.cs index 0db68023..08df2f8d 100644 --- a/src/Yoti.Auth/DigitalIdentityClientEngine.cs +++ b/src/Yoti.Auth/DigitalIdentityClientEngine.cs @@ -17,11 +17,11 @@ public DigitalIdentityClientEngine(HttpClient httpClient) { _httpClient = httpClient; - #if NET452 || NET462 || NET472 || NET48 +#if NET452 || NET462 || NET472 || NET48 ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; - #endif +#endif } - + public async Task CreateShareSessionAsync(string sdkId, AsymmetricCipherKeyPair keyPair, Uri apiUrl, ShareSessionRequest shareSessionRequest) { ShareSessionResult result = await Task.Run(async () => await DigitalIdentityService.CreateShareSession( @@ -39,7 +39,7 @@ public async Task GetShareReceipt(string sdkId, Asymmetri return result; } - + public async Task CreateQrCodeAsync(string sdkId, AsymmetricCipherKeyPair keyPair, Uri apiUrl, string sessionid, QrRequest qRRequest) { CreateQrResult result = await Task.Run(async () => await DigitalIdentityService.CreateQrCode( @@ -48,7 +48,7 @@ public async Task CreateQrCodeAsync(string sdkId, AsymmetricCiph return result; } - + public async Task GetQrCodeAsync(string sdkId, AsymmetricCipherKeyPair keyPair, Uri apiUrl, string qrcodeId) { GetQrCodeResult result = await Task.Run(async () => await DigitalIdentityService.GetQrCode( @@ -57,7 +57,7 @@ public async Task GetQrCodeAsync(string sdkId, AsymmetricCipher return result; } - + public async Task GetSession(string sdkId, AsymmetricCipherKeyPair keyPair, Uri apiUrl, string sessionId) { var result = await Task.Run(async () => await DigitalIdentityService.GetSession( diff --git a/src/Yoti.Auth/DocScan/DocScanService.cs b/src/Yoti.Auth/DocScan/DocScanService.cs index fff51c41..c9c56c57 100644 --- a/src/Yoti.Auth/DocScan/DocScanService.cs +++ b/src/Yoti.Auth/DocScan/DocScanService.cs @@ -155,7 +155,7 @@ public async Task GetMediaContent(string sdkId, AsymmetricCipherKeyP { return null; } - + if (response.Content.Headers.ContentType == null) { return null; @@ -165,7 +165,7 @@ public async Task GetMediaContent(string sdkId, AsymmetricCipherKeyP { return null; } - + string contentType = response.Content.Headers.ContentType.MediaType; var responseObject = await response.Content.ReadAsByteArrayAsync(); @@ -213,7 +213,7 @@ public async Task GetSupportedDocuments(string sdkId .WithHttpMethod(HttpMethod.Get) .WithBaseUri(ApiUri) .WithEndpoint("/supported-documents") - .WithQueryParam("includeNonLatin", isStrictlyLatin ? "1": "0") + .WithQueryParam("includeNonLatin", isStrictlyLatin ? "1" : "0") .WithQueryParam("sdkId", sdkId) .Build(); @@ -260,7 +260,7 @@ public async Task CreateFaceCaptureResource(s Response.CreateYotiExceptionFromStatusCode(response); } - + var responseObject = await response.Content.ReadAsStringAsync(); var deserialized = await Task.Factory.StartNew(() => JsonConvert.DeserializeObject(responseObject)); diff --git a/src/Yoti.Auth/DocScan/Session/Create/Check/Advanced/RequestedCaMatchingStrategy.cs b/src/Yoti.Auth/DocScan/Session/Create/Check/Advanced/RequestedCaMatchingStrategy.cs index cd59f520..c5ab2e55 100644 --- a/src/Yoti.Auth/DocScan/Session/Create/Check/Advanced/RequestedCaMatchingStrategy.cs +++ b/src/Yoti.Auth/DocScan/Session/Create/Check/Advanced/RequestedCaMatchingStrategy.cs @@ -3,12 +3,12 @@ namespace Yoti.Auth.DocScan.Session.Create.Check.Advanced { - [JsonConverter(typeof(JsonSubtypes), "type")] - [JsonSubtypes.KnownSubType(typeof(RequestedExactMatchingStrategy), Constants.DocScanConstants.Exact)] - [JsonSubtypes.KnownSubType(typeof(RequestedFuzzyMatchingStrategy), Constants.DocScanConstants.Fuzzy)] - public abstract class RequestedCaMatchingStrategy - { - [JsonProperty(PropertyName = "type")] - public abstract string Type { get; } - } + [JsonConverter(typeof(JsonSubtypes), "type")] + [JsonSubtypes.KnownSubType(typeof(RequestedExactMatchingStrategy), Constants.DocScanConstants.Exact)] + [JsonSubtypes.KnownSubType(typeof(RequestedFuzzyMatchingStrategy), Constants.DocScanConstants.Fuzzy)] + public abstract class RequestedCaMatchingStrategy + { + [JsonProperty(PropertyName = "type")] + public abstract string Type { get; } + } } \ No newline at end of file diff --git a/src/Yoti.Auth/DocScan/Session/Create/Check/Advanced/RequestedCaSources.cs b/src/Yoti.Auth/DocScan/Session/Create/Check/Advanced/RequestedCaSources.cs index 78e7c6c2..c4ab8851 100644 --- a/src/Yoti.Auth/DocScan/Session/Create/Check/Advanced/RequestedCaSources.cs +++ b/src/Yoti.Auth/DocScan/Session/Create/Check/Advanced/RequestedCaSources.cs @@ -3,12 +3,12 @@ namespace Yoti.Auth.DocScan.Session.Create.Check.Advanced { - [JsonConverter(typeof(JsonSubtypes), "type")] - [JsonSubtypes.KnownSubType(typeof(RequestedTypeListSources), Constants.DocScanConstants.TypeList)] - [JsonSubtypes.KnownSubType(typeof(RequestedSearchProfileSources), Constants.DocScanConstants.Profile)] - public abstract class RequestedCaSources - { - [JsonProperty(PropertyName = "type")] - public abstract string Type { get; } - } + [JsonConverter(typeof(JsonSubtypes), "type")] + [JsonSubtypes.KnownSubType(typeof(RequestedTypeListSources), Constants.DocScanConstants.TypeList)] + [JsonSubtypes.KnownSubType(typeof(RequestedSearchProfileSources), Constants.DocScanConstants.Profile)] + public abstract class RequestedCaSources + { + [JsonProperty(PropertyName = "type")] + public abstract string Type { get; } + } } \ No newline at end of file diff --git a/src/Yoti.Auth/DocScan/Session/Create/Check/Advanced/RequestedFuzzyMatchingStrategy.cs b/src/Yoti.Auth/DocScan/Session/Create/Check/Advanced/RequestedFuzzyMatchingStrategy.cs index 688bb173..eb1417f0 100644 --- a/src/Yoti.Auth/DocScan/Session/Create/Check/Advanced/RequestedFuzzyMatchingStrategy.cs +++ b/src/Yoti.Auth/DocScan/Session/Create/Check/Advanced/RequestedFuzzyMatchingStrategy.cs @@ -3,16 +3,16 @@ namespace Yoti.Auth.DocScan.Session.Create.Check.Advanced { - public class RequestedFuzzyMatchingStrategy : RequestedCaMatchingStrategy - { - public override string Type => DocScanConstants.Fuzzy; + public class RequestedFuzzyMatchingStrategy : RequestedCaMatchingStrategy + { + public override string Type => DocScanConstants.Fuzzy; - [JsonProperty(PropertyName = "fuzziness")] - public double Fuzziness { get; } + [JsonProperty(PropertyName = "fuzziness")] + public double Fuzziness { get; } - public RequestedFuzzyMatchingStrategy(double fuzziness) - { - Fuzziness = fuzziness; - } - } + public RequestedFuzzyMatchingStrategy(double fuzziness) + { + Fuzziness = fuzziness; + } + } } \ No newline at end of file diff --git a/src/Yoti.Auth/DocScan/Session/Create/Check/Advanced/RequestedSearchProfileSources.cs b/src/Yoti.Auth/DocScan/Session/Create/Check/Advanced/RequestedSearchProfileSources.cs index 3f870c19..d9996789 100644 --- a/src/Yoti.Auth/DocScan/Session/Create/Check/Advanced/RequestedSearchProfileSources.cs +++ b/src/Yoti.Auth/DocScan/Session/Create/Check/Advanced/RequestedSearchProfileSources.cs @@ -3,16 +3,16 @@ namespace Yoti.Auth.DocScan.Session.Create.Check.Advanced { - public class RequestedSearchProfileSources : RequestedCaSources - { - public override string Type => DocScanConstants.Profile; + public class RequestedSearchProfileSources : RequestedCaSources + { + public override string Type => DocScanConstants.Profile; - [JsonProperty(PropertyName = "search_profile")] - public string SearchProfile { get; } + [JsonProperty(PropertyName = "search_profile")] + public string SearchProfile { get; } - public RequestedSearchProfileSources(string searchProfile) - { - SearchProfile = searchProfile; - } - } + public RequestedSearchProfileSources(string searchProfile) + { + SearchProfile = searchProfile; + } + } } \ No newline at end of file diff --git a/src/Yoti.Auth/DocScan/Session/Create/Check/Advanced/RequestedTypeListSources.cs b/src/Yoti.Auth/DocScan/Session/Create/Check/Advanced/RequestedTypeListSources.cs index 9dcb3f33..9e24f102 100644 --- a/src/Yoti.Auth/DocScan/Session/Create/Check/Advanced/RequestedTypeListSources.cs +++ b/src/Yoti.Auth/DocScan/Session/Create/Check/Advanced/RequestedTypeListSources.cs @@ -4,16 +4,16 @@ namespace Yoti.Auth.DocScan.Session.Create.Check.Advanced { - public class RequestedTypeListSources : RequestedCaSources - { - public override string Type => DocScanConstants.TypeList; + public class RequestedTypeListSources : RequestedCaSources + { + public override string Type => DocScanConstants.TypeList; - [JsonProperty(PropertyName = "types")] - public List Types { get; } + [JsonProperty(PropertyName = "types")] + public List Types { get; } - public RequestedTypeListSources(List types) - { - Types = types; - } - } + public RequestedTypeListSources(List types) + { + Types = types; + } + } } \ No newline at end of file diff --git a/src/Yoti.Auth/DocScan/Session/Create/Check/Advanced/RequestedWatchlistAdvancedCaConfigCustomAccount.cs b/src/Yoti.Auth/DocScan/Session/Create/Check/Advanced/RequestedWatchlistAdvancedCaConfigCustomAccount.cs index 8d9e29ff..b5e8369c 100644 --- a/src/Yoti.Auth/DocScan/Session/Create/Check/Advanced/RequestedWatchlistAdvancedCaConfigCustomAccount.cs +++ b/src/Yoti.Auth/DocScan/Session/Create/Check/Advanced/RequestedWatchlistAdvancedCaConfigCustomAccount.cs @@ -4,29 +4,29 @@ namespace Yoti.Auth.DocScan.Session.Create.Check.Advanced { - public class RequestedWatchlistAdvancedCaConfigCustomAccount : RequestedWatchlistAdvancedCaConfig - { - public override string Type => DocScanConstants.WithCustomAccount; + public class RequestedWatchlistAdvancedCaConfigCustomAccount : RequestedWatchlistAdvancedCaConfig + { + public override string Type => DocScanConstants.WithCustomAccount; - public RequestedWatchlistAdvancedCaConfigCustomAccount(bool removeDeceased, bool shareUrl, RequestedCaSources sources, RequestedCaMatchingStrategy matchingStrategy, string apiKey, bool monitoring, Dictionary tags, string clientRef) - : base(removeDeceased, shareUrl, sources, matchingStrategy) - { - ApiKey = apiKey; - Monitoring = monitoring; - Tags = tags; - ClientRef = clientRef; - } + public RequestedWatchlistAdvancedCaConfigCustomAccount(bool removeDeceased, bool shareUrl, RequestedCaSources sources, RequestedCaMatchingStrategy matchingStrategy, string apiKey, bool monitoring, Dictionary tags, string clientRef) + : base(removeDeceased, shareUrl, sources, matchingStrategy) + { + ApiKey = apiKey; + Monitoring = monitoring; + Tags = tags; + ClientRef = clientRef; + } - [JsonProperty(PropertyName = "api_key")] - public string ApiKey { get; } + [JsonProperty(PropertyName = "api_key")] + public string ApiKey { get; } - [JsonProperty(PropertyName = "monitoring")] - public bool Monitoring { get; } + [JsonProperty(PropertyName = "monitoring")] + public bool Monitoring { get; } - [JsonProperty(PropertyName = "tags")] - public Dictionary Tags { get; } + [JsonProperty(PropertyName = "tags")] + public Dictionary Tags { get; } - [JsonProperty(PropertyName = "client_ref")] - public string ClientRef { get; } - } + [JsonProperty(PropertyName = "client_ref")] + public string ClientRef { get; } + } } \ No newline at end of file diff --git a/src/Yoti.Auth/DocScan/Session/Create/Check/Advanced/RequestedWatchlistAdvancedCaConfigYotiAccount.cs b/src/Yoti.Auth/DocScan/Session/Create/Check/Advanced/RequestedWatchlistAdvancedCaConfigYotiAccount.cs index f1f91fd2..cd9cb141 100644 --- a/src/Yoti.Auth/DocScan/Session/Create/Check/Advanced/RequestedWatchlistAdvancedCaConfigYotiAccount.cs +++ b/src/Yoti.Auth/DocScan/Session/Create/Check/Advanced/RequestedWatchlistAdvancedCaConfigYotiAccount.cs @@ -3,12 +3,12 @@ namespace Yoti.Auth.DocScan.Session.Create.Check.Advanced { - public class RequestedWatchlistAdvancedCaConfigYotiAccount : RequestedWatchlistAdvancedCaConfig - { - public override string Type => DocScanConstants.WithYotiAccount; - public RequestedWatchlistAdvancedCaConfigYotiAccount(bool removeDeceased, bool shareUrl, RequestedCaSources sources, RequestedCaMatchingStrategy matchingStrategy) - : base(removeDeceased, shareUrl, sources, matchingStrategy) - { - } - } + public class RequestedWatchlistAdvancedCaConfigYotiAccount : RequestedWatchlistAdvancedCaConfig + { + public override string Type => DocScanConstants.WithYotiAccount; + public RequestedWatchlistAdvancedCaConfigYotiAccount(bool removeDeceased, bool shareUrl, RequestedCaSources sources, RequestedCaMatchingStrategy matchingStrategy) + : base(removeDeceased, shareUrl, sources, matchingStrategy) + { + } + } } \ No newline at end of file diff --git a/src/Yoti.Auth/DocScan/Session/Create/Check/RequestedFaceComparisonCheckBuilder.cs b/src/Yoti.Auth/DocScan/Session/Create/Check/RequestedFaceComparisonCheckBuilder.cs index 7f8b8600..add788a5 100644 --- a/src/Yoti.Auth/DocScan/Session/Create/Check/RequestedFaceComparisonCheckBuilder.cs +++ b/src/Yoti.Auth/DocScan/Session/Create/Check/RequestedFaceComparisonCheckBuilder.cs @@ -5,7 +5,7 @@ namespace Yoti.Auth.DocScan.Session.Create.Check public class RequestedFaceComparisonCheckBuilder { private string _manualCheck; - + /// /// Requires that only an automated Check is performed. No manual follow-up Check will ever be initiated /// diff --git a/src/Yoti.Auth/DocScan/Session/Create/Check/RequestedWatchlistAdvancedCaCheckBuilder.CustomAccount.cs b/src/Yoti.Auth/DocScan/Session/Create/Check/RequestedWatchlistAdvancedCaCheckBuilder.CustomAccount.cs index 5e2ed516..f2ff0a19 100644 --- a/src/Yoti.Auth/DocScan/Session/Create/Check/RequestedWatchlistAdvancedCaCheckBuilder.CustomAccount.cs +++ b/src/Yoti.Auth/DocScan/Session/Create/Check/RequestedWatchlistAdvancedCaCheckBuilder.CustomAccount.cs @@ -37,7 +37,7 @@ public RequestedWatchlistAdvancedCaCheckBuilderCustomAccount WithClientRef(strin public override RequestedWatchlistAdvancedCaCheck Build() { var config = new RequestedWatchlistAdvancedCaConfigCustomAccount(_removeDeceased, _shareUrl, _sources, _matchingStrategy, _apiKey, _monitoring, _tags, _clientRef); - + return new RequestedWatchlistAdvancedCaCheck(config); } } diff --git a/src/Yoti.Auth/DocScan/Session/Create/Check/RequestedWatchlistAdvancedCaCheckBuilder.YotiAccount.cs b/src/Yoti.Auth/DocScan/Session/Create/Check/RequestedWatchlistAdvancedCaCheckBuilder.YotiAccount.cs index eb3d1205..0e2ba1eb 100644 --- a/src/Yoti.Auth/DocScan/Session/Create/Check/RequestedWatchlistAdvancedCaCheckBuilder.YotiAccount.cs +++ b/src/Yoti.Auth/DocScan/Session/Create/Check/RequestedWatchlistAdvancedCaCheckBuilder.YotiAccount.cs @@ -2,13 +2,13 @@ namespace Yoti.Auth.DocScan.Session.Create.Check { - public class RequestedWatchlistAdvancedCaCheckBuilderYotiAccount : RequestedWatchlistAdvancedCaCheckBuilder - { - public override RequestedWatchlistAdvancedCaCheck Build() - { - var config = new RequestedWatchlistAdvancedCaConfigYotiAccount(_removeDeceased, _shareUrl, _sources, _matchingStrategy); + public class RequestedWatchlistAdvancedCaCheckBuilderYotiAccount : RequestedWatchlistAdvancedCaCheckBuilder + { + public override RequestedWatchlistAdvancedCaCheck Build() + { + var config = new RequestedWatchlistAdvancedCaConfigYotiAccount(_removeDeceased, _shareUrl, _sources, _matchingStrategy); - return new RequestedWatchlistAdvancedCaCheck(config); - } - } + return new RequestedWatchlistAdvancedCaCheck(config); + } + } } \ No newline at end of file diff --git a/src/Yoti.Auth/DocScan/Session/Create/Check/RequestedWatchlistAdvancedCaCheckBuilder.cs b/src/Yoti.Auth/DocScan/Session/Create/Check/RequestedWatchlistAdvancedCaCheckBuilder.cs index 37f25df6..272b4c11 100644 --- a/src/Yoti.Auth/DocScan/Session/Create/Check/RequestedWatchlistAdvancedCaCheckBuilder.cs +++ b/src/Yoti.Auth/DocScan/Session/Create/Check/RequestedWatchlistAdvancedCaCheckBuilder.cs @@ -26,7 +26,7 @@ public RequestedWatchlistAdvancedCaCheckBuilder WithSources(RequestedCaSources s _sources = sources; return this; } - + public RequestedWatchlistAdvancedCaCheckBuilder WithMatchingStrategy(RequestedCaMatchingStrategy matchingStrategy) { _matchingStrategy = matchingStrategy; diff --git a/src/Yoti.Auth/DocScan/Session/Create/Check/RequestedWatchlistScreeningCheckBuilder.cs b/src/Yoti.Auth/DocScan/Session/Create/Check/RequestedWatchlistScreeningCheckBuilder.cs index ab09cc9c..77193e9f 100644 --- a/src/Yoti.Auth/DocScan/Session/Create/Check/RequestedWatchlistScreeningCheckBuilder.cs +++ b/src/Yoti.Auth/DocScan/Session/Create/Check/RequestedWatchlistScreeningCheckBuilder.cs @@ -3,54 +3,54 @@ namespace Yoti.Auth.DocScan.Session.Create.Check { - /// - /// Builds the using the configured using the methods here. - /// - /// - /// A watchlist screening check is a type of AML (Anti Money Laundering) check against watchlists.
- /// Note: To request a WatchlistScreeningCheck you must request ID_DOCUMENT_TEXT_DATA_EXTRACTION as a minimum
- /// (e.g. using and ) - ///
- public class RequestedWatchlistScreeningCheckBuilder - { - private readonly List _categories = new List(); + /// + /// Builds the using the configured using the methods here. + /// + /// + /// A watchlist screening check is a type of AML (Anti Money Laundering) check against watchlists.
+ /// Note: To request a WatchlistScreeningCheck you must request ID_DOCUMENT_TEXT_DATA_EXTRACTION as a minimum
+ /// (e.g. using and ) + ///
+ public class RequestedWatchlistScreeningCheckBuilder + { + private readonly List _categories = new List(); - /// - /// Adds SANCTIONS to the list of categories to check in the watchlist screening check - /// - /// The builder - public RequestedWatchlistScreeningCheckBuilder ForSanctions() - { - return WithCategory(Constants.DocScanConstants.Sanctions); - } + /// + /// Adds SANCTIONS to the list of categories to check in the watchlist screening check + /// + /// The builder + public RequestedWatchlistScreeningCheckBuilder ForSanctions() + { + return WithCategory(Constants.DocScanConstants.Sanctions); + } - /// - /// Adds ADVERSE_MEDIA to the list of categories to check in the watchlist screening check - /// - /// The builder - public RequestedWatchlistScreeningCheckBuilder ForAdverseMedia() - { - return WithCategory(Constants.DocScanConstants.AdverseMedia); - } + /// + /// Adds ADVERSE_MEDIA to the list of categories to check in the watchlist screening check + /// + /// The builder + public RequestedWatchlistScreeningCheckBuilder ForAdverseMedia() + { + return WithCategory(Constants.DocScanConstants.AdverseMedia); + } - /// - /// Adds a category to the list of categories for the watchlist screening check - /// - /// the category to add - /// The builder - public RequestedWatchlistScreeningCheckBuilder WithCategory(string category) - { - Validation.NotNullOrWhiteSpace(category, nameof(category)); - if (!_categories.Contains(category)) - _categories.Add(category); - return this; - } + /// + /// Adds a category to the list of categories for the watchlist screening check + /// + /// the category to add + /// The builder + public RequestedWatchlistScreeningCheckBuilder WithCategory(string category) + { + Validation.NotNullOrWhiteSpace(category, nameof(category)); + if (!_categories.Contains(category)) + _categories.Add(category); + return this; + } - public RequestedWatchlistScreeningCheck Build() - { - var config = new RequestedWatchlistScreeningConfig(_categories); + public RequestedWatchlistScreeningCheck Build() + { + var config = new RequestedWatchlistScreeningConfig(_categories); - return new RequestedWatchlistScreeningCheck(config); - } - } + return new RequestedWatchlistScreeningCheck(config); + } + } } \ No newline at end of file diff --git a/src/Yoti.Auth/DocScan/Session/Create/NotificationConfigBuilder.cs b/src/Yoti.Auth/DocScan/Session/Create/NotificationConfigBuilder.cs index 4644888c..cc4c7488 100644 --- a/src/Yoti.Auth/DocScan/Session/Create/NotificationConfigBuilder.cs +++ b/src/Yoti.Auth/DocScan/Session/Create/NotificationConfigBuilder.cs @@ -11,7 +11,7 @@ public class NotificationConfigBuilder private string _authToken; private string _authType; private string _endpoint; - + /// /// Sets the authorization token to be included in callback messages /// @@ -19,7 +19,7 @@ public class NotificationConfigBuilder /// The builder public NotificationConfigBuilder WithAuthToken(string authToken) { - _authToken = authToken; + _authToken = authToken; return this; } diff --git a/src/Yoti.Auth/DocScan/Session/Create/SdkConfigBuilder.cs b/src/Yoti.Auth/DocScan/Session/Create/SdkConfigBuilder.cs index 00157f36..96e9d22b 100644 --- a/src/Yoti.Auth/DocScan/Session/Create/SdkConfigBuilder.cs +++ b/src/Yoti.Auth/DocScan/Session/Create/SdkConfigBuilder.cs @@ -234,7 +234,7 @@ public SdkConfigBuilder WithIdDocumentTextExtractionGenericAttempts(int genericA { WithIdDocumentTextExtractionCategoryAttempts(DocScanConstants.Generic, genericAttempts); return this; - } + } /// /// Builds the based on values supplied to the builder diff --git a/src/Yoti.Auth/DocScan/Session/Create/SessionSpecification.cs b/src/Yoti.Auth/DocScan/Session/Create/SessionSpecification.cs index 0d06c84b..3cfcfd32 100644 --- a/src/Yoti.Auth/DocScan/Session/Create/SessionSpecification.cs +++ b/src/Yoti.Auth/DocScan/Session/Create/SessionSpecification.cs @@ -66,7 +66,7 @@ internal SessionSpecification(int? clientSessionTokenTtl, int? resourcesTtl, str [JsonProperty(PropertyName = "subject")] public object Subject { get; } - + [JsonProperty(PropertyName = "advanced_identity_profile_requirements")] public object AdvancedIdentityProfileRequirements { get; } diff --git a/src/Yoti.Auth/DocScan/Session/Create/SessionSpecificationBuilder.cs b/src/Yoti.Auth/DocScan/Session/Create/SessionSpecificationBuilder.cs index 9138f0ea..f093ec33 100644 --- a/src/Yoti.Auth/DocScan/Session/Create/SessionSpecificationBuilder.cs +++ b/src/Yoti.Auth/DocScan/Session/Create/SessionSpecificationBuilder.cs @@ -153,7 +153,7 @@ public SessionSpecificationBuilder WithIdentityProfileRequirements(object identi _identityProfileRequirements = identityProfileRequirements; return this; } - + /// /// Sets the Subject object for the session diff --git a/src/Yoti.Auth/DocScan/Session/Retrieve/AdvancedIdentityProfile/FailureReasonResponse.cs b/src/Yoti.Auth/DocScan/Session/Retrieve/AdvancedIdentityProfile/FailureReasonResponse.cs index b55c83d8..03f524f8 100644 --- a/src/Yoti.Auth/DocScan/Session/Retrieve/AdvancedIdentityProfile/FailureReasonResponse.cs +++ b/src/Yoti.Auth/DocScan/Session/Retrieve/AdvancedIdentityProfile/FailureReasonResponse.cs @@ -5,6 +5,6 @@ namespace Yoti.Auth.DocScan.Session.Retrieve.AdvancedIdentityProfile public class FailureReasonResponse { [JsonProperty(PropertyName = "reason_code")] - public string ReasonCode { get; private set; } + public string ReasonCode { get; private set; } } } diff --git a/src/Yoti.Auth/DocScan/Session/Retrieve/Check/ProfileCheckResponse.cs b/src/Yoti.Auth/DocScan/Session/Retrieve/Check/ProfileCheckResponse.cs index 2e81bc19..68ebd31e 100644 --- a/src/Yoti.Auth/DocScan/Session/Retrieve/Check/ProfileCheckResponse.cs +++ b/src/Yoti.Auth/DocScan/Session/Retrieve/Check/ProfileCheckResponse.cs @@ -2,12 +2,12 @@ namespace Yoti.Auth.DocScan.Session.Retrieve.Check { - /// - /// Abstract base for API check responses that include a GeneratedProfile - /// - public abstract class ProfileCheckResponse : CheckResponse - { - [JsonProperty(PropertyName = "generated_profile")] - public GeneratedProfileResponse GeneratedProfile { get; internal set; } - } + /// + /// Abstract base for API check responses that include a GeneratedProfile + /// + public abstract class ProfileCheckResponse : CheckResponse + { + [JsonProperty(PropertyName = "generated_profile")] + public GeneratedProfileResponse GeneratedProfile { get; internal set; } + } } \ No newline at end of file diff --git a/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/CaMatchingStrategyResponse.cs b/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/CaMatchingStrategyResponse.cs index 69ef0cf4..479eb6ac 100644 --- a/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/CaMatchingStrategyResponse.cs +++ b/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/CaMatchingStrategyResponse.cs @@ -3,12 +3,12 @@ namespace Yoti.Auth.DocScan.Session.Retrieve.Check.WatchlistSummary { - [JsonConverter(typeof(JsonSubtypes), "type")] - [JsonSubtypes.KnownSubType(typeof(ExactMatchingStrategyResponse), Constants.DocScanConstants.Exact)] - [JsonSubtypes.KnownSubType(typeof(FuzzyMatchingStrategyResponse), Constants.DocScanConstants.Fuzzy)] - public abstract class CaMatchingStrategyResponse - { - [JsonProperty(PropertyName = "type")] - public string Type { get; internal set; } - } + [JsonConverter(typeof(JsonSubtypes), "type")] + [JsonSubtypes.KnownSubType(typeof(ExactMatchingStrategyResponse), Constants.DocScanConstants.Exact)] + [JsonSubtypes.KnownSubType(typeof(FuzzyMatchingStrategyResponse), Constants.DocScanConstants.Fuzzy)] + public abstract class CaMatchingStrategyResponse + { + [JsonProperty(PropertyName = "type")] + public string Type { get; internal set; } + } } \ No newline at end of file diff --git a/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/CaSourcesResponse.cs b/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/CaSourcesResponse.cs index 6880bec7..e98f566c 100644 --- a/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/CaSourcesResponse.cs +++ b/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/CaSourcesResponse.cs @@ -3,12 +3,12 @@ namespace Yoti.Auth.DocScan.Session.Retrieve.Check.WatchlistSummary { - [JsonConverter(typeof(JsonSubtypes), "type")] + [JsonConverter(typeof(JsonSubtypes), "type")] [JsonSubtypes.KnownSubType(typeof(SearchProfileSourcesResponse), Constants.DocScanConstants.Profile)] [JsonSubtypes.KnownSubType(typeof(TypeListSourcesResponse), Constants.DocScanConstants.TypeList)] public abstract class CaSourcesResponse - { - [JsonProperty(PropertyName = "type")] - public string Type { get; internal set; } - } + { + [JsonProperty(PropertyName = "type")] + public string Type { get; internal set; } + } } \ No newline at end of file diff --git a/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/ExactMatchingStrategyResponse.cs b/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/ExactMatchingStrategyResponse.cs index 16894d05..0d624c02 100644 --- a/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/ExactMatchingStrategyResponse.cs +++ b/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/ExactMatchingStrategyResponse.cs @@ -2,9 +2,9 @@ namespace Yoti.Auth.DocScan.Session.Retrieve.Check.WatchlistSummary { - public class ExactMatchingStrategyResponse : CaMatchingStrategyResponse - { - [JsonProperty(PropertyName = "exact_match")] - public bool ExactMatch { get; internal set; } - } + public class ExactMatchingStrategyResponse : CaMatchingStrategyResponse + { + [JsonProperty(PropertyName = "exact_match")] + public bool ExactMatch { get; internal set; } + } } \ No newline at end of file diff --git a/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/FuzzyMatchingStrategyResponse.cs b/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/FuzzyMatchingStrategyResponse.cs index cf3647d7..cd425295 100644 --- a/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/FuzzyMatchingStrategyResponse.cs +++ b/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/FuzzyMatchingStrategyResponse.cs @@ -2,9 +2,9 @@ namespace Yoti.Auth.DocScan.Session.Retrieve.Check.WatchlistSummary { - public class FuzzyMatchingStrategyResponse : CaMatchingStrategyResponse - { - [JsonProperty(PropertyName = "fuzziness")] - public double Fuzziness { get; internal set; } - } + public class FuzzyMatchingStrategyResponse : CaMatchingStrategyResponse + { + [JsonProperty(PropertyName = "fuzziness")] + public double Fuzziness { get; internal set; } + } } \ No newline at end of file diff --git a/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/ISearchConfig.cs b/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/ISearchConfig.cs index a7382303..fe2e88ba 100644 --- a/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/ISearchConfig.cs +++ b/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/ISearchConfig.cs @@ -3,10 +3,10 @@ namespace Yoti.Auth.DocScan.Session.Retrieve.Check.WatchlistSummary { - [JsonConverter(typeof(JsonSubtypes))] - [JsonSubtypes.KnownSubTypeWithProperty(typeof(WatchlistAdvancedCaSearchConfigResponse), "type")] - [JsonSubtypes.KnownSubTypeWithProperty(typeof(WatchlistScreeningConfig), "categories")] - public interface ISearchConfig - { - } + [JsonConverter(typeof(JsonSubtypes))] + [JsonSubtypes.KnownSubTypeWithProperty(typeof(WatchlistAdvancedCaSearchConfigResponse), "type")] + [JsonSubtypes.KnownSubTypeWithProperty(typeof(WatchlistScreeningConfig), "categories")] + public interface ISearchConfig + { + } } \ No newline at end of file diff --git a/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/RawResults.cs b/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/RawResults.cs index 91523dc4..4056db07 100644 --- a/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/RawResults.cs +++ b/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/RawResults.cs @@ -2,9 +2,9 @@ namespace Yoti.Auth.DocScan.Session.Retrieve.Check.WatchlistSummary { - public class RawResults - { - [JsonProperty(PropertyName = "media")] - public MediaResponse Media { get; private set; } - } + public class RawResults + { + [JsonProperty(PropertyName = "media")] + public MediaResponse Media { get; private set; } + } } \ No newline at end of file diff --git a/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/ReportResponseWithSummary.cs b/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/ReportResponseWithSummary.cs index 00486812..03b74031 100644 --- a/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/ReportResponseWithSummary.cs +++ b/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/ReportResponseWithSummary.cs @@ -2,9 +2,9 @@ namespace Yoti.Auth.DocScan.Session.Retrieve.Check.WatchlistSummary { - public class ReportResponseWithSummary : ReportResponse - { - [JsonProperty(PropertyName = "watchlist_summary")] - public WatchlistSummary WatchlistSummary { get; internal set; } - } + public class ReportResponseWithSummary : ReportResponse + { + [JsonProperty(PropertyName = "watchlist_summary")] + public WatchlistSummary WatchlistSummary { get; internal set; } + } } \ No newline at end of file diff --git a/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/SearchProfileSourcesResponse.cs b/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/SearchProfileSourcesResponse.cs index 597dc86c..460a216a 100644 --- a/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/SearchProfileSourcesResponse.cs +++ b/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/SearchProfileSourcesResponse.cs @@ -2,9 +2,9 @@ namespace Yoti.Auth.DocScan.Session.Retrieve.Check.WatchlistSummary { - public class SearchProfileSourcesResponse : CaSourcesResponse - { - [JsonProperty(PropertyName = "search_profile")] - public string SearchProfile { get; internal set; } - } + public class SearchProfileSourcesResponse : CaSourcesResponse + { + [JsonProperty(PropertyName = "search_profile")] + public string SearchProfile { get; internal set; } + } } \ No newline at end of file diff --git a/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/TypeListSourcesResponse.cs b/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/TypeListSourcesResponse.cs index d98d5128..956d1803 100644 --- a/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/TypeListSourcesResponse.cs +++ b/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/TypeListSourcesResponse.cs @@ -3,9 +3,9 @@ namespace Yoti.Auth.DocScan.Session.Retrieve.Check.WatchlistSummary { - public class TypeListSourcesResponse : CaSourcesResponse - { - [JsonProperty(PropertyName = "types")] - public List Types { get; internal set; } - } + public class TypeListSourcesResponse : CaSourcesResponse + { + [JsonProperty(PropertyName = "types")] + public List Types { get; internal set; } + } } \ No newline at end of file diff --git a/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/WatchlistAdvancedCaSearchConfigResponse.cs b/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/WatchlistAdvancedCaSearchConfigResponse.cs index 4dc9f3b7..68274edb 100644 --- a/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/WatchlistAdvancedCaSearchConfigResponse.cs +++ b/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/WatchlistAdvancedCaSearchConfigResponse.cs @@ -6,24 +6,24 @@ namespace Yoti.Auth.DocScan.Session.Retrieve.Check.WatchlistSummary { - [JsonConverter(typeof(JsonSubtypes), "type")] - [JsonSubtypes.KnownSubType(typeof(WatchlistAdvancedCaSearchConfigResponseYotiAccount), Yoti.Auth.Constants.DocScanConstants.WithYotiAccount)] - [JsonSubtypes.KnownSubType(typeof(WatchlistAdvancedCaSearchConfigResponseCustomAccount), Yoti.Auth.Constants.DocScanConstants.WithCustomAccount)] - public abstract class WatchlistAdvancedCaSearchConfigResponse : ISearchConfig - { - [JsonProperty(PropertyName = "type")] - public string Type { get; internal set; } + [JsonConverter(typeof(JsonSubtypes), "type")] + [JsonSubtypes.KnownSubType(typeof(WatchlistAdvancedCaSearchConfigResponseYotiAccount), Yoti.Auth.Constants.DocScanConstants.WithYotiAccount)] + [JsonSubtypes.KnownSubType(typeof(WatchlistAdvancedCaSearchConfigResponseCustomAccount), Yoti.Auth.Constants.DocScanConstants.WithCustomAccount)] + public abstract class WatchlistAdvancedCaSearchConfigResponse : ISearchConfig + { + [JsonProperty(PropertyName = "type")] + public string Type { get; internal set; } - [JsonProperty(PropertyName = "remove_deceased")] - public bool RemoveDeceased { get; internal set; } + [JsonProperty(PropertyName = "remove_deceased")] + public bool RemoveDeceased { get; internal set; } - [JsonProperty(PropertyName = "share_url")] - public bool ShareUrl { get; internal set; } + [JsonProperty(PropertyName = "share_url")] + public bool ShareUrl { get; internal set; } - [JsonProperty(PropertyName = "sources")] - public CaSourcesResponse Sources { get; internal set; } + [JsonProperty(PropertyName = "sources")] + public CaSourcesResponse Sources { get; internal set; } - [JsonProperty(PropertyName = "matching_strategy")] - public CaMatchingStrategyResponse MatchingStrategy { get; internal set; } - } + [JsonProperty(PropertyName = "matching_strategy")] + public CaMatchingStrategyResponse MatchingStrategy { get; internal set; } + } } diff --git a/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/WatchlistAdvancedCaSearchConfigResponseCustomAccount.cs b/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/WatchlistAdvancedCaSearchConfigResponseCustomAccount.cs index 3f97cda5..ffd434dc 100644 --- a/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/WatchlistAdvancedCaSearchConfigResponseCustomAccount.cs +++ b/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/WatchlistAdvancedCaSearchConfigResponseCustomAccount.cs @@ -3,18 +3,18 @@ namespace Yoti.Auth.DocScan.Session.Retrieve.Check.WatchlistSummary { - public class WatchlistAdvancedCaSearchConfigResponseCustomAccount : WatchlistAdvancedCaSearchConfigResponse - { - [JsonProperty(PropertyName = "api_key")] - public string ApiKey { get; internal set; } + public class WatchlistAdvancedCaSearchConfigResponseCustomAccount : WatchlistAdvancedCaSearchConfigResponse + { + [JsonProperty(PropertyName = "api_key")] + public string ApiKey { get; internal set; } - [JsonProperty(PropertyName = "monitoring")] - public bool Monitoring { get; internal set; } + [JsonProperty(PropertyName = "monitoring")] + public bool Monitoring { get; internal set; } - [JsonProperty(PropertyName = "tags")] - public Dictionary Tags { get; internal set; } + [JsonProperty(PropertyName = "tags")] + public Dictionary Tags { get; internal set; } - [JsonProperty(PropertyName = "client_ref")] - public string ClientRef { get; internal set; } - } + [JsonProperty(PropertyName = "client_ref")] + public string ClientRef { get; internal set; } + } } \ No newline at end of file diff --git a/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/WatchlistAdvancedCaSearchConfigResponseYotiAccount.cs b/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/WatchlistAdvancedCaSearchConfigResponseYotiAccount.cs index 6ccf97bc..56da0533 100644 --- a/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/WatchlistAdvancedCaSearchConfigResponseYotiAccount.cs +++ b/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/WatchlistAdvancedCaSearchConfigResponseYotiAccount.cs @@ -1,6 +1,6 @@ namespace Yoti.Auth.DocScan.Session.Retrieve.Check.WatchlistSummary { - public class WatchlistAdvancedCaSearchConfigResponseYotiAccount : WatchlistAdvancedCaSearchConfigResponse - { - } + public class WatchlistAdvancedCaSearchConfigResponseYotiAccount : WatchlistAdvancedCaSearchConfigResponse + { + } } \ No newline at end of file diff --git a/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/WatchlistScreeningConfig.cs b/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/WatchlistScreeningConfig.cs index d2716bf4..4080fa46 100644 --- a/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/WatchlistScreeningConfig.cs +++ b/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummary/WatchlistScreeningConfig.cs @@ -3,9 +3,9 @@ namespace Yoti.Auth.DocScan.Session.Retrieve.Check.WatchlistSummary { - public class WatchlistScreeningConfig : ISearchConfig - { - [JsonProperty(PropertyName = "categories")] - public List Categories { get; private set; } - } + public class WatchlistScreeningConfig : ISearchConfig + { + [JsonProperty(PropertyName = "categories")] + public List Categories { get; private set; } + } } \ No newline at end of file diff --git a/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummaryReportBaseCheckResponse.cs b/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummaryReportBaseCheckResponse.cs index 54036dc6..591a43a4 100644 --- a/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummaryReportBaseCheckResponse.cs +++ b/src/Yoti.Auth/DocScan/Session/Retrieve/Check/WatchlistSummaryReportBaseCheckResponse.cs @@ -1,6 +1,6 @@ namespace Yoti.Auth.DocScan.Session.Retrieve.Check { - public abstract class WatchlistSummaryReportBaseCheckResponse : ProfileCheckResponse - { - } + public abstract class WatchlistSummaryReportBaseCheckResponse : ProfileCheckResponse + { + } } \ No newline at end of file diff --git a/src/Yoti.Auth/DocScan/Session/Retrieve/GetSessionResult.cs b/src/Yoti.Auth/DocScan/Session/Retrieve/GetSessionResult.cs index 89e67609..c91661b2 100644 --- a/src/Yoti.Auth/DocScan/Session/Retrieve/GetSessionResult.cs +++ b/src/Yoti.Auth/DocScan/Session/Retrieve/GetSessionResult.cs @@ -61,7 +61,7 @@ public class GetSessionResult [JsonProperty(PropertyName = "advanced_identity_profile_preview")] public IdentityProfilePreviewResponse AdvancedIdentityProfilePreviewResponse { get; internal set; } - + public List GetAuthenticityChecks() { if (Checks == null) diff --git a/src/Yoti.Auth/DocScan/Session/Retrieve/IdentityProfile/FailureReasonResponse.cs b/src/Yoti.Auth/DocScan/Session/Retrieve/IdentityProfile/FailureReasonResponse.cs index 682b69db..45874cf9 100644 --- a/src/Yoti.Auth/DocScan/Session/Retrieve/IdentityProfile/FailureReasonResponse.cs +++ b/src/Yoti.Auth/DocScan/Session/Retrieve/IdentityProfile/FailureReasonResponse.cs @@ -6,7 +6,7 @@ public class FailureReasonResponse { [JsonProperty(PropertyName = "reason_code")] public string ReasonCode { get; private set; } - + [JsonProperty(PropertyName = "requirements_not_met_details")] public RequirementNotMetDetails RequirementNotMetDetails { get; private set; } } diff --git a/src/Yoti.Auth/DocScan/Session/Retrieve/PageResponse.cs b/src/Yoti.Auth/DocScan/Session/Retrieve/PageResponse.cs index 14dbbb81..7807b084 100644 --- a/src/Yoti.Auth/DocScan/Session/Retrieve/PageResponse.cs +++ b/src/Yoti.Auth/DocScan/Session/Retrieve/PageResponse.cs @@ -16,5 +16,8 @@ public class PageResponse : IResponseWithMediaProperty [JsonProperty(PropertyName = "frames")] public List Frames { get; internal set; } + + [JsonProperty(PropertyName = "extraction_image_ids")] + public List ExtractionImageIds { get; private set; } = new List(); } } \ No newline at end of file diff --git a/src/Yoti.Auth/DocScan/Session/Retrieve/Resource/LivenessResourceResponse.cs b/src/Yoti.Auth/DocScan/Session/Retrieve/Resource/LivenessResourceResponse.cs index 31783a1d..92eb9849 100644 --- a/src/Yoti.Auth/DocScan/Session/Retrieve/Resource/LivenessResourceResponse.cs +++ b/src/Yoti.Auth/DocScan/Session/Retrieve/Resource/LivenessResourceResponse.cs @@ -11,4 +11,4 @@ public class LivenessResourceResponse : ResourceResponse [JsonProperty(PropertyName = "liveness_type")] public string LivenessType { get; internal set; } } -} \ No newline at end of file +} \ No newline at end of file diff --git a/src/Yoti.Auth/Exceptions/YotiProfileException.cs b/src/Yoti.Auth/Exceptions/YotiProfileException.cs index 5e9e2234..0a15bbb2 100644 --- a/src/Yoti.Auth/Exceptions/YotiProfileException.cs +++ b/src/Yoti.Auth/Exceptions/YotiProfileException.cs @@ -3,33 +3,33 @@ namespace Yoti.Auth.Exceptions { - public class YotiProfileException : YotiException - { - public YotiProfileException() - : base() - { - } + public class YotiProfileException : YotiException + { + public YotiProfileException() + : base() + { + } - public YotiProfileException(string message) - : base(message) - { - } + public YotiProfileException(string message) + : base(message) + { + } - public YotiProfileException(string message, string responseContent) - : base(message) - { - ResponseContent = responseContent; - dynamic jsonResponse = JObject.Parse(responseContent); - if (jsonResponse.error_details != null && jsonResponse.error_details.error_code != null) - ErrorCode = jsonResponse.error_details.error_code; - } + public YotiProfileException(string message, string responseContent) + : base(message) + { + ResponseContent = responseContent; + dynamic jsonResponse = JObject.Parse(responseContent); + if (jsonResponse.error_details != null && jsonResponse.error_details.error_code != null) + ErrorCode = jsonResponse.error_details.error_code; + } - public YotiProfileException(string message, Exception innerException) - : base(message, innerException) - { - } + public YotiProfileException(string message, Exception innerException) + : base(message, innerException) + { + } - public string ResponseContent { get; private set; } - public string ErrorCode { get; private set; } - } + public string ResponseContent { get; private set; } + public string ErrorCode { get; private set; } + } } \ No newline at end of file diff --git a/src/Yoti.Auth/GlobalSuppressions.cs b/src/Yoti.Auth/GlobalSuppressions.cs index a3825d88..fe7e0602 100644 --- a/src/Yoti.Auth/GlobalSuppressions.cs +++ b/src/Yoti.Auth/GlobalSuppressions.cs @@ -25,7 +25,8 @@ [assembly: SuppressMessage("Style", "IDE0063:Use simple 'using' statement", Justification = "Does not compile on older versions", Scope = "member", Target = "~M:Yoti.Auth.Aml.RemoteAmlService.PerformCheck(System.Net.Http.HttpClient,Org.BouncyCastle.Crypto.AsymmetricCipherKeyPair,System.Uri,System.String,System.Byte[])~System.Threading.Tasks.Task{Yoti.Auth.Aml.AmlResult}")] [assembly: SuppressMessage("Style", "IDE0063:Use simple 'using' statement", Justification = "Does not compile on older versions", Scope = "member", Target = "~M:Yoti.Auth.ShareUrl.DynamicSharingService.CreateShareURL(System.Net.Http.HttpClient,System.Uri,System.String,Org.BouncyCastle.Crypto.AsymmetricCipherKeyPair,Yoti.Auth.ShareUrl.DynamicScenario)~System.Threading.Tasks.Task{Yoti.Auth.ShareUrl.ShareUrlResult}")] [assembly: SuppressMessage("Style", "IDE0063:Use simple 'using' statement", Justification = "Does not compile on older versions", Scope = "member", Target = "~M:Yoti.Auth.YotiClientEngine.GetActivityDetailsAsync(System.String,System.String,Org.BouncyCastle.Crypto.AsymmetricCipherKeyPair,System.Uri)~System.Threading.Tasks.Task{Yoti.Auth.ActivityDetails}")] -[assembly: SuppressMessage("Usage", "CA2237:Mark ISerializable types with serializable", Justification = "[Serializable] not available in 'netstandard' target framework", Scope = "type", Target = "~T:Yoti.Auth.Exceptions.ExtraDataException")][assembly: SuppressMessage("Style", "IDE0066:Convert switch statement to expression", Justification = "Other switch cases can all be represented more concisely by the default case", Scope = "member", Target = "~M:Yoti.Auth.Web.Response.CreateExceptionFromStatusCode``1(System.Net.Http.HttpResponseMessage)")] +[assembly: SuppressMessage("Usage", "CA2237:Mark ISerializable types with serializable", Justification = "[Serializable] not available in 'netstandard' target framework", Scope = "type", Target = "~T:Yoti.Auth.Exceptions.ExtraDataException")] +[assembly: SuppressMessage("Style", "IDE0066:Convert switch statement to expression", Justification = "Other switch cases can all be represented more concisely by the default case", Scope = "member", Target = "~M:Yoti.Auth.Web.Response.CreateExceptionFromStatusCode``1(System.Net.Http.HttpResponseMessage)")] [assembly: SuppressMessage("Style", "IDE0063:Use simple 'using' statement", Justification = "Preview feature, not available in older versions of .NET SDK", Scope = "member", Target = "~M:Yoti.Auth.ShareUrl.DynamicSharingService.CreateShareURL(System.Net.Http.HttpClient,System.Uri,System.String,Org.BouncyCastle.Crypto.AsymmetricCipherKeyPair,Yoti.Auth.ShareUrl.DynamicScenario)~System.Threading.Tasks.Task{Yoti.Auth.ShareUrl.ShareUrlResult}")] [assembly: SuppressMessage("Style", "IDE0063:Use simple 'using' statement", Justification = "Preview feature, not available in older versions of .NET SDK", Scope = "member", Target = "~M:Yoti.Auth.Anchors.AnchorCertificateParser.GetListOfStringsFromExtension(System.Security.Cryptography.X509Certificates.X509Certificate2,System.String)~System.Collections.Generic.List{System.String}")] [assembly: SuppressMessage("Style", "IDE0063:Use simple 'using' statement", Justification = "Preview feature, not available in older versions of .NET SDK", Scope = "member", Target = "~M:Yoti.Auth.Aml.RemoteAmlService.PerformCheck(System.Net.Http.HttpClient,Org.BouncyCastle.Crypto.AsymmetricCipherKeyPair,System.Uri,System.String,System.Byte[])~System.Threading.Tasks.Task{Yoti.Auth.Aml.AmlResult}")] diff --git a/src/Yoti.Auth/ShareUrl/Policy/DynamicPolicy.cs b/src/Yoti.Auth/ShareUrl/Policy/DynamicPolicy.cs index 787ff990..46d650a3 100644 --- a/src/Yoti.Auth/ShareUrl/Policy/DynamicPolicy.cs +++ b/src/Yoti.Auth/ShareUrl/Policy/DynamicPolicy.cs @@ -6,7 +6,7 @@ namespace Yoti.Auth.ShareUrl.Policy /// /// Set of data required to request a sharing transaction /// - public class DynamicPolicy + public class DynamicPolicy { internal const int SelfieAuthType = 1; internal const int PinAuthType = 2; @@ -29,7 +29,7 @@ public class DynamicPolicy [JsonProperty(PropertyName = "identity_profile_requirements")] private readonly object _identityProfileRequirements; - + [JsonProperty(PropertyName = "advanced_identity_profile_requirements")] private readonly object _advancedIdentityProfileRequirements; @@ -96,7 +96,7 @@ public object IdentityProfileRequirements return _identityProfileRequirements; } } - + /// /// AdvancedIdentityProfileRequirements requested in the policy /// diff --git a/src/Yoti.Auth/ShareUrl/Policy/DynamicPolicyBuilder.cs b/src/Yoti.Auth/ShareUrl/Policy/DynamicPolicyBuilder.cs index ee476783..56361ff5 100644 --- a/src/Yoti.Auth/ShareUrl/Policy/DynamicPolicyBuilder.cs +++ b/src/Yoti.Auth/ShareUrl/Policy/DynamicPolicyBuilder.cs @@ -159,7 +159,7 @@ public DynamicPolicyBuilder WithIdentityProfileRequirements(object identityProfi _identityProfileRequirements = identityProfileRequirements; return this; } - + /// /// Use an AdvancedIdentity Profile Requirement object for the share /// diff --git a/src/Yoti.Auth/ShareUrl/Policy/WantedAttributeBuilder.cs b/src/Yoti.Auth/ShareUrl/Policy/WantedAttributeBuilder.cs index f4f35cb4..e6577653 100644 --- a/src/Yoti.Auth/ShareUrl/Policy/WantedAttributeBuilder.cs +++ b/src/Yoti.Auth/ShareUrl/Policy/WantedAttributeBuilder.cs @@ -21,7 +21,7 @@ public WantedAttributeBuilder WithOptional(bool optional) _optional = optional; return this; } - + public WantedAttributeBuilder WithDerivation(string derivation) { _derivation = derivation; diff --git a/src/Yoti.Auth/Web/RequestBuilder.cs b/src/Yoti.Auth/Web/RequestBuilder.cs index bb7da5aa..74eabf64 100644 --- a/src/Yoti.Auth/Web/RequestBuilder.cs +++ b/src/Yoti.Auth/Web/RequestBuilder.cs @@ -140,7 +140,7 @@ public RequestBuilder WithHttpMethod(HttpMethod httpMethod) public RequestBuilder WithContent(byte[] content) { Validation.IsNull(_multipartFormDataContent, nameof(_multipartFormDataContent)); - + _content = content; return this; } @@ -158,7 +158,7 @@ public RequestBuilder WithMultipartBoundary(string multipartBoundaryName) Validation.NotNullOrWhiteSpace(multipartBoundaryName, nameof(multipartBoundaryName)); Validation.IsNull(_content, nameof(_content)); - _multipartFormDataContent = new MultipartFormDataContent(multipartBoundaryName); + _multipartFormDataContent = new MultipartFormDataContent(multipartBoundaryName); return this; } @@ -176,15 +176,15 @@ public RequestBuilder WithMultipartBoundary(string multipartBoundaryName) public RequestBuilder WithMultipartBinaryContent( string name, byte[] payload, - string contentType, + string contentType, string fileName) { Validation.NotNull(_multipartFormDataContent, nameof(_multipartFormDataContent)); Validation.NotNullOrWhiteSpace(name, nameof(name)); Validation.NotNull(payload, nameof(payload)); Validation.NotNull(contentType, nameof(contentType)); - Validation.NotNullOrWhiteSpace(fileName, nameof(fileName)); - + Validation.NotNullOrWhiteSpace(fileName, nameof(fileName)); + var binaryContent = new ByteArrayContent(payload); binaryContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(contentType); _multipartFormDataContent.Add(binaryContent, name, fileName); @@ -221,7 +221,7 @@ public Request Build() httpRequestMessage.Content = byteContent; contentForHeaderCreation = byteContent.ReadAsByteArrayAsync().Result; } - else if(_multipartFormDataContent != null) + else if (_multipartFormDataContent != null) { httpRequestMessage.Content = _multipartFormDataContent; contentForHeaderCreation = _multipartFormDataContent.ReadAsByteArrayAsync().Result; diff --git a/test/Yoti.Auth.Tests/CryptoEngineTests.cs b/test/Yoti.Auth.Tests/CryptoEngineTests.cs index 134cdc95..e10067de 100644 --- a/test/Yoti.Auth.Tests/CryptoEngineTests.cs +++ b/test/Yoti.Auth.Tests/CryptoEngineTests.cs @@ -36,7 +36,7 @@ public void DecryptAesGcm_EmptySecretsThrowsError() byte[] iv = new byte[12]; byte[] secret = new byte[16]; byte[] cipherText = new byte[32]; - + var exception = Assert.ThrowsException(() => { CryptoEngine.DecryptAesGcm(cipherText, iv, secret); diff --git a/test/Yoti.Auth.Tests/DigitalIdentity/Policy/DynamicPolicyBuilderTests.cs b/test/Yoti.Auth.Tests/DigitalIdentity/Policy/DynamicPolicyBuilderTests.cs index b1fec0d3..b24e23aa 100644 --- a/test/Yoti.Auth.Tests/DigitalIdentity/Policy/DynamicPolicyBuilderTests.cs +++ b/test/Yoti.Auth.Tests/DigitalIdentity/Policy/DynamicPolicyBuilderTests.cs @@ -7,7 +7,7 @@ namespace Yoti.Auth.Tests.DigitalIdentity.Policy { - + [TestClass] public class DynamicPolicyBuilderTests { @@ -327,12 +327,12 @@ public void ShouldBuildWithIdentityProfileRequirements() Assert.AreEqual(identityProfileRequirements, result.IdentityProfileRequirements); } - + [TestMethod] public void ShouldBuildWithAdvancedIdentityProfileRequirements() { var advancedIdentityProfileRequirements = IdentityProfiles.CreateAdvancedIdentityProfileRequirements(); - + Auth.DigitalIdentity.Policy.Policy result = new PolicyBuilder() .WithAdvancedIdentityProfileRequirements(advancedIdentityProfileRequirements) .Build(); @@ -341,5 +341,5 @@ public void ShouldBuildWithAdvancedIdentityProfileRequirements() } } - + } diff --git a/test/Yoti.Auth.Tests/DigitalIdentity/QrRequestBuilderTests.cs b/test/Yoti.Auth.Tests/DigitalIdentity/QrRequestBuilderTests.cs index 42295715..bc6ebd7d 100644 --- a/test/Yoti.Auth.Tests/DigitalIdentity/QrRequestBuilderTests.cs +++ b/test/Yoti.Auth.Tests/DigitalIdentity/QrRequestBuilderTests.cs @@ -21,10 +21,10 @@ public void ShouldBuildADynamicScenario() .WithTransport(_someTransportString) .Build(); - + Assert.AreEqual(_someDisplayMode, result.DisplayMode); Assert.AreEqual(_someTransportString, result.Transport); } - + } } \ No newline at end of file diff --git a/test/Yoti.Auth.Tests/DigitalIdentity/RequirementNotMetDetails.cs b/test/Yoti.Auth.Tests/DigitalIdentity/RequirementNotMetDetails.cs index 9fb6a132..c446f4d6 100644 --- a/test/Yoti.Auth.Tests/DigitalIdentity/RequirementNotMetDetails.cs +++ b/test/Yoti.Auth.Tests/DigitalIdentity/RequirementNotMetDetails.cs @@ -17,7 +17,7 @@ public void DeserializeValidJsonCreatesRequirementNotMetDetails() ""document_country_iso_code"": ""USA"", ""document_type"": ""PASSPORT"" }"; - + var details = JsonConvert.DeserializeObject(json); Assert.IsNotNull(details); @@ -27,7 +27,7 @@ public void DeserializeValidJsonCreatesRequirementNotMetDetails() Assert.AreEqual("USA", details.DocumentCountryIsoCode); Assert.AreEqual("PASSPORT", details.DocumentType); } - + [TestMethod] public void PropertyGettersReturnCorrectValues() @@ -42,7 +42,7 @@ public void PropertyGettersReturnCorrectValues() }"; var details = JsonConvert.DeserializeObject(json); - + Assert.AreEqual("DOCUMENT_EXPIRED", details.FailureType); Assert.AreEqual("The document has expired.", details.Details); Assert.AreEqual("AUDIT123", details.AuditId); diff --git a/test/Yoti.Auth.Tests/DigitalIdentity/ShareSessionRequestBuilderTests.cs b/test/Yoti.Auth.Tests/DigitalIdentity/ShareSessionRequestBuilderTests.cs index bc52fe01..93c47166 100644 --- a/test/Yoti.Auth.Tests/DigitalIdentity/ShareSessionRequestBuilderTests.cs +++ b/test/Yoti.Auth.Tests/DigitalIdentity/ShareSessionRequestBuilderTests.cs @@ -26,7 +26,7 @@ public class ShareSessionRequestBuilderTests .WithRadius(1500) .Build(); - + [TestMethod] public void ShouldBuildADynamicScenario() { @@ -67,6 +67,6 @@ public void ShouldBuildADynamicScenario() Assert.AreEqual(expectedJson, serializedScenario); } - + } } \ No newline at end of file diff --git a/test/Yoti.Auth.Tests/DigitalIdentityClientEngineTests.cs b/test/Yoti.Auth.Tests/DigitalIdentityClientEngineTests.cs index 8dddfe73..02f85b66 100644 --- a/test/Yoti.Auth.Tests/DigitalIdentityClientEngineTests.cs +++ b/test/Yoti.Auth.Tests/DigitalIdentityClientEngineTests.cs @@ -13,31 +13,31 @@ namespace Yoti.Auth.Tests { - [TestClass] - public class DigitalIdentityClientEngineTests - { - private const string EncryptedToken = "b6H19bUCJhwh6WqQX/sEHWX9RP+A/ANr1fkApwA4Dp2nJQFAjrF9e6YCXhNBpAIhfHnN0iXubyXxXZMNwNMSQ5VOxkqiytrvPykfKQWHC6ypSbfy0ex8ihndaAXG5FUF+qcU8QaFPMy6iF3x0cxnY0Ij0kZj0Ng2t6oiNafb7AhT+VGXxbFbtZu1QF744PpWMuH0LVyBsAa5N5GJw2AyBrnOh67fWMFDKTJRziP5qCW2k4h5vJfiYr/EOiWKCB1d/zINmUm94ZffGXxcDAkq+KxhN1ZuNhGlJ2fKcFh7KxV0BqlUWPsIEiwS0r9CJ2o1VLbEs2U/hCEXaqseEV7L29EnNIinEPVbL4WR7vkF6zQCbK/cehlk2Qwda+VIATqupRO5grKZN78R9lBitvgilDaoE7JB/VFcPoljGQ48kX0wje1mviX4oJHhuO8GdFITS5LTbojGVQWT7LUNgAUe0W0j+FLHYYck3v84OhWTqads5/jmnnLkp9bdJSRuJF0e8pNdePnn2lgF+GIcyW/0kyGVqeXZrIoxnObLpF+YeUteRBKTkSGFcy7a/V/DLiJMPmH8UXDLOyv8TVt3ppzqpyUrLN2JVMbL5wZ4oriL2INEQKvw/boDJjZDGeRlu5m1y7vGDNBRDo64+uQM9fRUULPw+YkABNwC0DeShswzT00="; - private readonly AsymmetricCipherKeyPair _keyPair = KeyPair.Get(); - private static HttpRequestMessage _httpRequestMessage; - private const string SdkId = "fake-sdk-id"; - - [TestMethod] - public async Task CreateSessionAsyncShouldReturnCorrectValues() - { - string refId = "NpdmVVGC-28356678-c236-4518-9de4-7a93009ccaf0-c5f92f2a-5539-453e-babc-9b06e1d6b7de"; - - Mock handlerMock = SetupMockMessageHandler( - HttpStatusCode.OK, + [TestClass] + public class DigitalIdentityClientEngineTests + { + private const string EncryptedToken = "b6H19bUCJhwh6WqQX/sEHWX9RP+A/ANr1fkApwA4Dp2nJQFAjrF9e6YCXhNBpAIhfHnN0iXubyXxXZMNwNMSQ5VOxkqiytrvPykfKQWHC6ypSbfy0ex8ihndaAXG5FUF+qcU8QaFPMy6iF3x0cxnY0Ij0kZj0Ng2t6oiNafb7AhT+VGXxbFbtZu1QF744PpWMuH0LVyBsAa5N5GJw2AyBrnOh67fWMFDKTJRziP5qCW2k4h5vJfiYr/EOiWKCB1d/zINmUm94ZffGXxcDAkq+KxhN1ZuNhGlJ2fKcFh7KxV0BqlUWPsIEiwS0r9CJ2o1VLbEs2U/hCEXaqseEV7L29EnNIinEPVbL4WR7vkF6zQCbK/cehlk2Qwda+VIATqupRO5grKZN78R9lBitvgilDaoE7JB/VFcPoljGQ48kX0wje1mviX4oJHhuO8GdFITS5LTbojGVQWT7LUNgAUe0W0j+FLHYYck3v84OhWTqads5/jmnnLkp9bdJSRuJF0e8pNdePnn2lgF+GIcyW/0kyGVqeXZrIoxnObLpF+YeUteRBKTkSGFcy7a/V/DLiJMPmH8UXDLOyv8TVt3ppzqpyUrLN2JVMbL5wZ4oriL2INEQKvw/boDJjZDGeRlu5m1y7vGDNBRDo64+uQM9fRUULPw+YkABNwC0DeShswzT00="; + private readonly AsymmetricCipherKeyPair _keyPair = KeyPair.Get(); + private static HttpRequestMessage _httpRequestMessage; + private const string SdkId = "fake-sdk-id"; + + [TestMethod] + public async Task CreateSessionAsyncShouldReturnCorrectValues() + { + string refId = "NpdmVVGC-28356678-c236-4518-9de4-7a93009ccaf0-c5f92f2a-5539-453e-babc-9b06e1d6b7de"; + + Mock handlerMock = SetupMockMessageHandler( + HttpStatusCode.OK, "{\"id\":\"" + refId + "\",\"status\":\"SOME_STATUS\",\"expiry\":\"SOME_EXPIRY\",\"created\":\"SOME_CREATED\",\"updated\":\"SOME_UPDATED\",\"qrCode\":{\"id\":\"SOME_QRCODE_ID\"},\"receipt\":{\"id\":\"SOME_RECEIPT_ID\"}}"); var engine = new DigitalIdentityClientEngine(new HttpClient(handlerMock.Object)); ShareSessionRequest shareSessionRequest = TestTools.ShareSession.CreateStandardShareSessionRequest(); - ShareSessionResult shareSessionResult = await engine.CreateShareSessionAsync(SdkId, _keyPair, new Uri(Constants.Api.DefaultYotiShareApiUrl), shareSessionRequest); + ShareSessionResult shareSessionResult = await engine.CreateShareSessionAsync(SdkId, _keyPair, new Uri(Constants.Api.DefaultYotiShareApiUrl), shareSessionRequest); - Assert.IsNotNull(shareSessionResult); - Assert.AreEqual(refId, shareSessionResult.Id); - } + Assert.IsNotNull(shareSessionResult); + Assert.AreEqual(refId, shareSessionResult.Id); + } [TestMethod] public async Task CreateQrCodeAsyncShouldReturnCorrectValues() @@ -101,158 +101,158 @@ public async Task GetSessionShouldReturnCorrectValues() Assert.AreEqual(status, result.Status); Assert.AreEqual(expiry, result.Expiry); } - + [DataTestMethod] - [DataRow(HttpStatusCode.BadRequest)] - [DataRow(HttpStatusCode.Unauthorized)] - [DataRow(HttpStatusCode.InternalServerError)] - [DataRow(HttpStatusCode.RequestTimeout)] - [DataRow(HttpStatusCode.NotFound)] - [DataRow(HttpStatusCode.Forbidden)] - public void CreateShareSessionNonSuccessStatusCodesShouldThrowException(HttpStatusCode httpStatusCode) - { - Mock handlerMock = SetupMockMessageHandler( - httpStatusCode, - "{\"status\":\"bad\""); - - var engine = new DigitalIdentityClientEngine(new HttpClient(handlerMock.Object)); + [DataRow(HttpStatusCode.BadRequest)] + [DataRow(HttpStatusCode.Unauthorized)] + [DataRow(HttpStatusCode.InternalServerError)] + [DataRow(HttpStatusCode.RequestTimeout)] + [DataRow(HttpStatusCode.NotFound)] + [DataRow(HttpStatusCode.Forbidden)] + public void CreateShareSessionNonSuccessStatusCodesShouldThrowException(HttpStatusCode httpStatusCode) + { + Mock handlerMock = SetupMockMessageHandler( + httpStatusCode, + "{\"status\":\"bad\""); + + var engine = new DigitalIdentityClientEngine(new HttpClient(handlerMock.Object)); ShareSessionRequest shareSessionRequest = TestTools.ShareSession.CreateStandardShareSessionRequest(); - var aggregateException = Assert.ThrowsException(() => - { - engine.CreateShareSessionAsync(SdkId, _keyPair, new Uri(Constants.Api.DefaultYotiApiUrl), shareSessionRequest).Wait(); - }); - - Assert.IsTrue(TestTools.Exceptions.IsExceptionInAggregateException(aggregateException)); - } - - [DataTestMethod] - [DataRow(HttpStatusCode.BadRequest)] - [DataRow(HttpStatusCode.Unauthorized)] - [DataRow(HttpStatusCode.InternalServerError)] - [DataRow(HttpStatusCode.RequestTimeout)] - [DataRow(HttpStatusCode.NotFound)] - [DataRow(HttpStatusCode.Forbidden)] - public void GetShareReceiptNonSuccessStatusCodesShouldThrowException(HttpStatusCode httpStatusCode) - { - Mock handlerMock = SetupMockMessageHandler( - httpStatusCode, - "{\"status\":\"bad\"}"); - - var engine = new DigitalIdentityClientEngine(new HttpClient(handlerMock.Object)); + var aggregateException = Assert.ThrowsException(() => + { + engine.CreateShareSessionAsync(SdkId, _keyPair, new Uri(Constants.Api.DefaultYotiApiUrl), shareSessionRequest).Wait(); + }); + + Assert.IsTrue(TestTools.Exceptions.IsExceptionInAggregateException(aggregateException)); + } + + [DataTestMethod] + [DataRow(HttpStatusCode.BadRequest)] + [DataRow(HttpStatusCode.Unauthorized)] + [DataRow(HttpStatusCode.InternalServerError)] + [DataRow(HttpStatusCode.RequestTimeout)] + [DataRow(HttpStatusCode.NotFound)] + [DataRow(HttpStatusCode.Forbidden)] + public void GetShareReceiptNonSuccessStatusCodesShouldThrowException(HttpStatusCode httpStatusCode) + { + Mock handlerMock = SetupMockMessageHandler( + httpStatusCode, + "{\"status\":\"bad\"}"); + + var engine = new DigitalIdentityClientEngine(new HttpClient(handlerMock.Object)); Uri apiUrl = new Uri("https://example.com/api"); string receiptId = "some_receiptid"; - var aggregateException = Assert.ThrowsException(() => - { - engine.GetShareReceipt(SdkId, _keyPair, apiUrl, receiptId).Wait(); - }); + var aggregateException = Assert.ThrowsException(() => + { + engine.GetShareReceipt(SdkId, _keyPair, apiUrl, receiptId).Wait(); + }); - Assert.IsTrue(TestTools.Exceptions.IsExceptionInAggregateException(aggregateException)); - } + Assert.IsTrue(TestTools.Exceptions.IsExceptionInAggregateException(aggregateException)); + } [DataTestMethod] - [DataRow(HttpStatusCode.BadRequest)] - [DataRow(HttpStatusCode.Unauthorized)] - [DataRow(HttpStatusCode.InternalServerError)] - [DataRow(HttpStatusCode.RequestTimeout)] - [DataRow(HttpStatusCode.NotFound)] - [DataRow(HttpStatusCode.Forbidden)] - public void CreateQrCodeAsyncNonSuccessStatusCodesShouldThrowException(HttpStatusCode httpStatusCode) - { - Mock handlerMock = SetupMockMessageHandler( - httpStatusCode, - "{\"status\":\"bad\"}"); - - var engine = new DigitalIdentityClientEngine(new HttpClient(handlerMock.Object)); + [DataRow(HttpStatusCode.BadRequest)] + [DataRow(HttpStatusCode.Unauthorized)] + [DataRow(HttpStatusCode.InternalServerError)] + [DataRow(HttpStatusCode.RequestTimeout)] + [DataRow(HttpStatusCode.NotFound)] + [DataRow(HttpStatusCode.Forbidden)] + public void CreateQrCodeAsyncNonSuccessStatusCodesShouldThrowException(HttpStatusCode httpStatusCode) + { + Mock handlerMock = SetupMockMessageHandler( + httpStatusCode, + "{\"status\":\"bad\"}"); + + var engine = new DigitalIdentityClientEngine(new HttpClient(handlerMock.Object)); QrRequest qrRequest = TestTools.CreateQr.CreateQrStandard(); string sessionId = "test-session-id"; - var aggregateException = Assert.ThrowsException(() => - { - engine.CreateQrCodeAsync(SdkId, _keyPair, new Uri(Constants.Api.DefaultYotiShareApiUrl), sessionId, qrRequest).Wait(); - }); + var aggregateException = Assert.ThrowsException(() => + { + engine.CreateQrCodeAsync(SdkId, _keyPair, new Uri(Constants.Api.DefaultYotiShareApiUrl), sessionId, qrRequest).Wait(); + }); - Assert.IsTrue(TestTools.Exceptions.IsExceptionInAggregateException(aggregateException)); - } + Assert.IsTrue(TestTools.Exceptions.IsExceptionInAggregateException(aggregateException)); + } [DataTestMethod] - [DataRow(HttpStatusCode.BadRequest)] - [DataRow(HttpStatusCode.Unauthorized)] - [DataRow(HttpStatusCode.InternalServerError)] - [DataRow(HttpStatusCode.RequestTimeout)] - [DataRow(HttpStatusCode.NotFound)] - [DataRow(HttpStatusCode.Forbidden)] - public void GetQrCodeAsyncNonSuccessStatusCodesShouldThrowException(HttpStatusCode httpStatusCode) - { - Mock handlerMock = SetupMockMessageHandler( - httpStatusCode, - "{\"status\":\"bad\"}"); - - var engine = new DigitalIdentityClientEngine(new HttpClient(handlerMock.Object)); + [DataRow(HttpStatusCode.BadRequest)] + [DataRow(HttpStatusCode.Unauthorized)] + [DataRow(HttpStatusCode.InternalServerError)] + [DataRow(HttpStatusCode.RequestTimeout)] + [DataRow(HttpStatusCode.NotFound)] + [DataRow(HttpStatusCode.Forbidden)] + public void GetQrCodeAsyncNonSuccessStatusCodesShouldThrowException(HttpStatusCode httpStatusCode) + { + Mock handlerMock = SetupMockMessageHandler( + httpStatusCode, + "{\"status\":\"bad\"}"); + + var engine = new DigitalIdentityClientEngine(new HttpClient(handlerMock.Object)); string qrCodeId = "test-qr-code-id"; - var aggregateException = Assert.ThrowsException(() => - { - engine.GetQrCodeAsync(SdkId, _keyPair, new Uri(Constants.Api.DefaultYotiShareApiUrl), qrCodeId).Wait(); - }); + var aggregateException = Assert.ThrowsException(() => + { + engine.GetQrCodeAsync(SdkId, _keyPair, new Uri(Constants.Api.DefaultYotiShareApiUrl), qrCodeId).Wait(); + }); - Assert.IsTrue(TestTools.Exceptions.IsExceptionInAggregateException(aggregateException)); - } + Assert.IsTrue(TestTools.Exceptions.IsExceptionInAggregateException(aggregateException)); + } [DataTestMethod] - [DataRow(HttpStatusCode.BadRequest)] - [DataRow(HttpStatusCode.Unauthorized)] - [DataRow(HttpStatusCode.InternalServerError)] - [DataRow(HttpStatusCode.RequestTimeout)] - [DataRow(HttpStatusCode.NotFound)] - [DataRow(HttpStatusCode.Forbidden)] - public void GetSessionNonSuccessStatusCodesShouldThrowException(HttpStatusCode httpStatusCode) - { - Mock handlerMock = SetupMockMessageHandler( - httpStatusCode, - "{\"status\":\"bad\"}"); - - var engine = new DigitalIdentityClientEngine(new HttpClient(handlerMock.Object)); + [DataRow(HttpStatusCode.BadRequest)] + [DataRow(HttpStatusCode.Unauthorized)] + [DataRow(HttpStatusCode.InternalServerError)] + [DataRow(HttpStatusCode.RequestTimeout)] + [DataRow(HttpStatusCode.NotFound)] + [DataRow(HttpStatusCode.Forbidden)] + public void GetSessionNonSuccessStatusCodesShouldThrowException(HttpStatusCode httpStatusCode) + { + Mock handlerMock = SetupMockMessageHandler( + httpStatusCode, + "{\"status\":\"bad\"}"); + + var engine = new DigitalIdentityClientEngine(new HttpClient(handlerMock.Object)); string sessionId = "test-session-id"; - var aggregateException = Assert.ThrowsException(() => - { - engine.GetSession(SdkId, _keyPair, new Uri(Constants.Api.DefaultYotiShareApiUrl), sessionId).Wait(); - }); - - Assert.IsTrue(TestTools.Exceptions.IsExceptionInAggregateException(aggregateException)); - } - - private static Mock SetupMockMessageHandler(HttpStatusCode httpStatusCode, string responseContent) - { - var handlerMock = new Mock(MockBehavior.Loose); - handlerMock - .Protected() - .Setup>( - "SendAsync", - ItExpr.IsAny(), - ItExpr.IsAny() - ) - .ReturnsAsync(new HttpResponseMessage() - { - StatusCode = httpStatusCode, - Content = new StringContent(responseContent) - }) - .Callback((http, token) => _httpRequestMessage = http) - .Verifiable(); - - return handlerMock; - } + var aggregateException = Assert.ThrowsException(() => + { + engine.GetSession(SdkId, _keyPair, new Uri(Constants.Api.DefaultYotiShareApiUrl), sessionId).Wait(); + }); + + Assert.IsTrue(TestTools.Exceptions.IsExceptionInAggregateException(aggregateException)); + } + + private static Mock SetupMockMessageHandler(HttpStatusCode httpStatusCode, string responseContent) + { + var handlerMock = new Mock(MockBehavior.Loose); + handlerMock + .Protected() + .Setup>( + "SendAsync", + ItExpr.IsAny(), + ItExpr.IsAny() + ) + .ReturnsAsync(new HttpResponseMessage() + { + StatusCode = httpStatusCode, + Content = new StringContent(responseContent) + }) + .Callback((http, token) => _httpRequestMessage = http) + .Verifiable(); + + return handlerMock; + } [TestMethod] public void ConstructorShouldAcceptHttpClient() { var httpClient = new HttpClient(); - + var engine = new DigitalIdentityClientEngine(httpClient); - + Assert.IsNotNull(engine); } @@ -384,5 +384,5 @@ public async Task GetSessionShouldHandleNullQrCodeAndReceiptInResponse() Assert.IsNull(result.QrCode); Assert.IsNull(result.Receipt); } - } + } } diff --git a/test/Yoti.Auth.Tests/DigitalIdentityClientTests.cs b/test/Yoti.Auth.Tests/DigitalIdentityClientTests.cs index 805165de..cdf50714 100644 --- a/test/Yoti.Auth.Tests/DigitalIdentityClientTests.cs +++ b/test/Yoti.Auth.Tests/DigitalIdentityClientTests.cs @@ -84,7 +84,7 @@ public void EmptyReceiptShouldThrowException() }); var status = TestTools.Exceptions.IsExceptionInAggregateException(aggregateException); - Assert.IsTrue(!status); + Assert.IsTrue(!status); } [DataTestMethod] @@ -143,7 +143,7 @@ public void ApiUriSetForStreamInitialisation() DigitalIdentityClient yotiClient = new DigitalIdentityClient(_someSdkId, privateStreamKey); Assert.AreEqual(_expectedDefaultUri, yotiClient.ApiUri); - } + } [TestMethod] public void ApiUriSetForStreamInitialisationHttpClient() diff --git a/test/Yoti.Auth.Tests/DocScan/DocScanClientTests.cs b/test/Yoti.Auth.Tests/DocScan/DocScanClientTests.cs index 243aec81..44310979 100644 --- a/test/Yoti.Auth.Tests/DocScan/DocScanClientTests.cs +++ b/test/Yoti.Auth.Tests/DocScan/DocScanClientTests.cs @@ -686,7 +686,7 @@ public void ShouldParseIdentityProfileResponse() Assert.AreEqual(mediaId, result.IdentityProfile.Report["media"]["id"]); } - + [TestMethod] public void ShouldParseAdvancedIdentityProfileResponse() { @@ -709,7 +709,7 @@ public void ShouldParseAdvancedIdentityProfileResponse() DocScanClient docScanClient = new DocScanClient(_sdkId, _keyPair, httpClient); GetSessionResult result = docScanClient.GetSession("some-session-id"); - + Assert.AreEqual("DONE", result.AdvancedIdentityProfile.Result); Assert.AreEqual("someStringHere", result.AdvancedIdentityProfile.SubjectId); Assert.AreEqual("MANDATORY_DOCUMENT_COULD_NOT_BE_PROVIDED", result.AdvancedIdentityProfile.FailureReason.ReasonCode); diff --git a/test/Yoti.Auth.Tests/DocScan/Session/Create/Check/RequestedWatchlistScreeningCheckBuilderTests.cs b/test/Yoti.Auth.Tests/DocScan/Session/Create/Check/RequestedWatchlistScreeningCheckBuilderTests.cs index 1957aa1c..48cb5f3e 100644 --- a/test/Yoti.Auth.Tests/DocScan/Session/Create/Check/RequestedWatchlistScreeningCheckBuilderTests.cs +++ b/test/Yoti.Auth.Tests/DocScan/Session/Create/Check/RequestedWatchlistScreeningCheckBuilderTests.cs @@ -6,7 +6,7 @@ namespace Yoti.Auth.Tests.DocScan.Session.Create.Check { - [TestClass] + [TestClass] public class RequestedWatchlistScreeningCheckBuilderTests { [TestMethod] diff --git a/test/Yoti.Auth.Tests/DocScan/Session/Create/NotificationConfigTests.cs b/test/Yoti.Auth.Tests/DocScan/Session/Create/NotificationConfigTests.cs index 54d6ac93..f4c3304a 100644 --- a/test/Yoti.Auth.Tests/DocScan/Session/Create/NotificationConfigTests.cs +++ b/test/Yoti.Auth.Tests/DocScan/Session/Create/NotificationConfigTests.cs @@ -11,7 +11,7 @@ public class NotificationConfigTests [TestMethod] public void ShouldBeConstructableWithoutAuthType() { - string authToken = "someAuthToken"; + string authToken = "someAuthToken"; string endpoint = "someEndpoint"; string topicName = "someTopic"; List topics = new List { topicName }; @@ -32,7 +32,7 @@ public void ShouldBeConstructableWithAuthType() string authToken = "someAuthToken"; string endpoint = "someEndpoint"; string topicName = "someTopic"; - List topics = new List{ topicName }; + List topics = new List { topicName }; string authType = "BASIC"; NotificationConfig notificationConfig = diff --git a/test/Yoti.Auth.Tests/DocScan/Session/Create/SessionSpecificationBuilderTests.cs b/test/Yoti.Auth.Tests/DocScan/Session/Create/SessionSpecificationBuilderTests.cs index 871165a2..5132745c 100644 --- a/test/Yoti.Auth.Tests/DocScan/Session/Create/SessionSpecificationBuilderTests.cs +++ b/test/Yoti.Auth.Tests/DocScan/Session/Create/SessionSpecificationBuilderTests.cs @@ -196,7 +196,7 @@ public void ShoudBuildWithAdvancedIdentityProfileRequirements() } ] }"; - + var sessionSpec = new SessionSpecificationBuilder() .WithIdentityProfileRequirements(advancedIdentityProfileJson) .Build(); @@ -205,9 +205,9 @@ public void ShoudBuildWithAdvancedIdentityProfileRequirements() Assert.IsTrue(sessionSpecJson.Contains("UK_TFIDA")); Assert.IsTrue(sessionSpecJson.Contains("YOTI_GLOBAL")); Assert.IsTrue(sessionSpecJson.Contains("IDENTITY")); - + } - + [TestMethod] public void ShouldNotImplicitlySetAValueForAdvancedIdentityProfileRequirements() { @@ -217,7 +217,7 @@ public void ShouldNotImplicitlySetAValueForAdvancedIdentityProfileRequirements() Assert.IsNull(sessionSpec.AdvancedIdentityProfileRequirements); } - + [TestMethod] public void ShoudBuildWithSubject() { @@ -342,7 +342,7 @@ public void ShouldBuildWithIdentityProfilePreview() Assert.AreEqual(identityProfileRequirements, sessionSpec.IdentityProfileRequirements); } - + [TestMethod] public void ShouldBuildWithAdvancedIdentityProfilePreview() { @@ -356,7 +356,7 @@ public void ShouldBuildWithAdvancedIdentityProfilePreview() Assert.AreEqual(advancedIdentityProfileRequirements, sessionSpec.AdvancedIdentityProfileRequirements); } - + [TestMethod] public void ShouldBuildWithAdvancedIdentityProfileRequirements() { diff --git a/test/Yoti.Auth.Tests/DocScan/Session/Retrieve/Check/CheckResponseTests.cs b/test/Yoti.Auth.Tests/DocScan/Session/Retrieve/Check/CheckResponseTests.cs index faa5bc28..0530276d 100644 --- a/test/Yoti.Auth.Tests/DocScan/Session/Retrieve/Check/CheckResponseTests.cs +++ b/test/Yoti.Auth.Tests/DocScan/Session/Retrieve/Check/CheckResponseTests.cs @@ -191,6 +191,77 @@ public void CheckPageResponseIsParsed() AssertMediaValuesCorrect((pageResponse.frames as IEnumerable).First().media, response.Frames.First(), typeof(FrameResponse)); } + [TestMethod] + public void CheckPageResponseExtractionImageIdsParsedWithSingleId() + { + dynamic pageResponse = new + { + capture_method = "CAMERA", + media = GetMediaResponse(), + extraction_image_ids = new List { "a1b2c3d4-0000-0000-0000-000000000001" } + }; + + string json = JsonConvert.SerializeObject(pageResponse); + PageResponse response = JsonConvert.DeserializeObject(json); + + CollectionAssert.AreEqual(new List { "a1b2c3d4-0000-0000-0000-000000000001" }, response.ExtractionImageIds); + } + + [TestMethod] + public void CheckPageResponseExtractionImageIdsParsedWithMultipleIds() + { + var expectedIds = new List + { + "a1b2c3d4-0000-0000-0000-000000000001", + "a1b2c3d4-0000-0000-0000-000000000002" + }; + + dynamic pageResponse = new + { + capture_method = "CAMERA", + media = GetMediaResponse(), + extraction_image_ids = expectedIds + }; + + string json = JsonConvert.SerializeObject(pageResponse); + PageResponse response = JsonConvert.DeserializeObject(json); + + CollectionAssert.AreEqual(expectedIds, response.ExtractionImageIds); + } + + [TestMethod] + public void CheckPageResponseExtractionImageIdsDefaultsToEmptyListWhenEmptyArray() + { + dynamic pageResponse = new + { + capture_method = "CAMERA", + media = GetMediaResponse(), + extraction_image_ids = new List() + }; + + string json = JsonConvert.SerializeObject(pageResponse); + PageResponse response = JsonConvert.DeserializeObject(json); + + Assert.IsNotNull(response.ExtractionImageIds); + Assert.AreEqual(0, response.ExtractionImageIds.Count); + } + + [TestMethod] + public void CheckPageResponseExtractionImageIdsDefaultsToEmptyListWhenFieldAbsent() + { + dynamic pageResponse = new + { + capture_method = "CAMERA", + media = GetMediaResponse() + }; + + string json = JsonConvert.SerializeObject(pageResponse); + PageResponse response = JsonConvert.DeserializeObject(json); + + Assert.IsNotNull(response.ExtractionImageIds); + Assert.AreEqual(0, response.ExtractionImageIds.Count); + } + [TestMethod] public void CheckFaceCaptureResourceResponseIsParsed() { diff --git a/test/Yoti.Auth.Tests/DocScan/Session/Retrieve/GetSessionResultTests.cs b/test/Yoti.Auth.Tests/DocScan/Session/Retrieve/GetSessionResultTests.cs index bdf2cb56..86696f96 100644 --- a/test/Yoti.Auth.Tests/DocScan/Session/Retrieve/GetSessionResultTests.cs +++ b/test/Yoti.Auth.Tests/DocScan/Session/Retrieve/GetSessionResultTests.cs @@ -339,7 +339,7 @@ public void CheckIdentityProfilePreviewResponseIsParsed() { dynamic identityProfilePreviewResponse = new { - media = GetMediaResponse() + media = GetMediaResponse() }; string json = JsonConvert.SerializeObject(identityProfilePreviewResponse); @@ -348,13 +348,13 @@ public void CheckIdentityProfilePreviewResponseIsParsed() AssertMediaValuesCorrect(identityProfilePreviewResponse.media, response.Media, typeof(MediaResponse)); } - + [TestMethod] public void CheckAdvancedIdentityProfilePreviewResponseIsParsed() { dynamic advancedIdentityProfilePreviewResponse = new { - media = GetMediaResponse() + media = GetMediaResponse() }; string json = JsonConvert.SerializeObject(advancedIdentityProfilePreviewResponse); diff --git a/test/Yoti.Auth.Tests/ShareUrl/DynamicScenarioBuilderTests.cs b/test/Yoti.Auth.Tests/ShareUrl/DynamicScenarioBuilderTests.cs index 3bdb9fec..a8e50f8e 100644 --- a/test/Yoti.Auth.Tests/ShareUrl/DynamicScenarioBuilderTests.cs +++ b/test/Yoti.Auth.Tests/ShareUrl/DynamicScenarioBuilderTests.cs @@ -37,7 +37,7 @@ public void ShouldBuildADynamicScenario() .WithPolicy(somePolicy) .WithExtension(extension1) .WithExtension(extension2) - + .WithSubject(someSubject) .Build(); diff --git a/test/Yoti.Auth.Tests/ShareUrl/Policy/DynamicPolicyBuilderTests.cs b/test/Yoti.Auth.Tests/ShareUrl/Policy/DynamicPolicyBuilderTests.cs index d65f4d1b..c47a9eb0 100644 --- a/test/Yoti.Auth.Tests/ShareUrl/Policy/DynamicPolicyBuilderTests.cs +++ b/test/Yoti.Auth.Tests/ShareUrl/Policy/DynamicPolicyBuilderTests.cs @@ -325,7 +325,7 @@ public void ShouldBuildWithIdentityProfileRequirements() Assert.AreEqual(identityProfileRequirements, result.IdentityProfileRequirements); } - + [TestMethod] public void ShouldBuildWithAdvancedIdentityProfileRequirements() { diff --git a/test/Yoti.Auth.Tests/TestData/IdentityProfiles.cs b/test/Yoti.Auth.Tests/TestData/IdentityProfiles.cs index 1ad07105..dd2a6bc7 100644 --- a/test/Yoti.Auth.Tests/TestData/IdentityProfiles.cs +++ b/test/Yoti.Auth.Tests/TestData/IdentityProfiles.cs @@ -17,7 +17,7 @@ public static object CreateStandardIdentityProfileRequirements() } }; } - + public static AdvancedIdentityProfile CreateAdvancedIdentityProfileRequirements() { string advancedIdentityProfileJson = @" @@ -61,7 +61,7 @@ public static object CreateStandardSubject() subject_id = "some_subject_id_string" }; } - + public static object CreateStandardAdvancedIdentityProfileRequirements() { string advancedIdentityProfileJson = @" @@ -94,7 +94,7 @@ public static object CreateStandardAdvancedIdentityProfileRequirements() } ] }"; - + return advancedIdentityProfileJson; } } diff --git a/test/Yoti.Auth.Tests/TestTools/ShareSession.cs b/test/Yoti.Auth.Tests/TestTools/ShareSession.cs index 7be4792a..ae2c6fd5 100644 --- a/test/Yoti.Auth.Tests/TestTools/ShareSession.cs +++ b/test/Yoti.Auth.Tests/TestTools/ShareSession.cs @@ -11,7 +11,7 @@ public static ShareSessionRequest CreateStandardShareSessionRequest() { return new ShareSessionRequest(CreateStandardPolicy(), "redirecturi"); } - + public static Policy CreateStandardPolicy() { return new PolicyBuilder() diff --git a/test/Yoti.Auth.Tests/YotiClientEngineTests.cs b/test/Yoti.Auth.Tests/YotiClientEngineTests.cs index 63aaedcf..3b93d59b 100644 --- a/test/Yoti.Auth.Tests/YotiClientEngineTests.cs +++ b/test/Yoti.Auth.Tests/YotiClientEngineTests.cs @@ -15,355 +15,355 @@ namespace Yoti.Auth.Tests { - [TestClass] - public class YotiClientEngineTests - { - private const string EncryptedToken = "b6H19bUCJhwh6WqQX/sEHWX9RP+A/ANr1fkApwA4Dp2nJQFAjrF9e6YCXhNBpAIhfHnN0iXubyXxXZMNwNMSQ5VOxkqiytrvPykfKQWHC6ypSbfy0ex8ihndaAXG5FUF+qcU8QaFPMy6iF3x0cxnY0Ij0kZj0Ng2t6oiNafb7AhT+VGXxbFbtZu1QF744PpWMuH0LVyBsAa5N5GJw2AyBrnOh67fWMFDKTJRziP5qCW2k4h5vJfiYr/EOiWKCB1d/zINmUm94ZffGXxcDAkq+KxhN1ZuNhGlJ2fKcFh7KxV0BqlUWPsIEiwS0r9CJ2o1VLbEs2U/hCEXaqseEV7L29EnNIinEPVbL4WR7vkF6zQCbK/cehlk2Qwda+VIATqupRO5grKZN78R9lBitvgilDaoE7JB/VFcPoljGQ48kX0wje1mviX4oJHhuO8GdFITS5LTbojGVQWT7LUNgAUe0W0j+FLHYYck3v84OhWTqads5/jmnnLkp9bdJSRuJF0e8pNdePnn2lgF+GIcyW/0kyGVqeXZrIoxnObLpF+YeUteRBKTkSGFcy7a/V/DLiJMPmH8UXDLOyv8TVt3ppzqpyUrLN2JVMbL5wZ4oriL2INEQKvw/boDJjZDGeRlu5m1y7vGDNBRDo64+uQM9fRUULPw+YkABNwC0DeShswzT00="; - private readonly AsymmetricCipherKeyPair _keyPair = KeyPair.Get(); - private static HttpRequestMessage _httpRequestMessage; - private const string SdkId = "fake-sdk-id"; - - [DataTestMethod] - [DataRow(null)] - [DataRow("")] - public void InvalidTokenShouldThrowException(string encryptedToken) - { - var engine = new YotiClientEngine(new HttpClient()); - - var profileException = Assert.ThrowsExceptionAsync(async () => - { - await engine.GetActivityDetailsAsync(encryptedToken, SdkId, _keyPair, new Uri(Constants.Api.DefaultYotiApiUrl)); - }).Result; - - Assert.IsTrue(profileException.Message.Contains("'encryptedConnectToken' must not be empty or null")); - } - - [TestMethod] - public void SharingFailureShouldReturnSharingFailure() - { - Mock handlerMock = SetupMockMessageHandler( - HttpStatusCode.OK, - "{\"session_data\":null,\"receipt\":{\"receipt_id\": null,\"other_party_profile_content\": null,\"policy_uri\":null,\"personal_key\":null,\"remember_me_id\":null, \"sharing_outcome\":\"FAILURE\",\"timestamp\":\"2016-09-23T13:04:11Z\"}}"); - - var engine = new YotiClientEngine(new HttpClient(handlerMock.Object)); - - var profileException = Assert.ThrowsExceptionAsync(async () => - { - await engine.GetActivityDetailsAsync(EncryptedToken, SdkId, _keyPair, new Uri(Constants.Api.DefaultYotiApiUrl)); - }).Result; - - Assert.IsTrue(profileException.Message.StartsWith("The share was not successful")); - } - - [TestMethod] - public void SharingFailureWithErrorCodeShouldThrowExceptionWithErrorCode() - { - string jsonResponse = System.IO.File.ReadAllText("TestData/ShareFailure.json"); - - Mock handlerMock = SetupMockMessageHandler( - HttpStatusCode.OK, jsonResponse); - - var engine = new YotiClientEngine(new HttpClient(handlerMock.Object)); - - var profileException = Assert.ThrowsExceptionAsync(async () => - { - await engine.GetActivityDetailsAsync(EncryptedToken, SdkId, _keyPair, new Uri(Constants.Api.DefaultYotiApiUrl)); - }).Result; - - Assert.IsTrue(profileException.Message.StartsWith("The share was not successful")); - Assert.AreEqual("SOME_ERROR_CODE", profileException.ErrorCode); - } - - [TestMethod] - public void SharingFailureShouldThrowExceptionWithWholeResponseExposed() - { - string jsonResponse = System.IO.File.ReadAllText("TestData/ShareFailure.json"); - - Mock handlerMock = SetupMockMessageHandler( - HttpStatusCode.OK, jsonResponse); - - var engine = new YotiClientEngine(new HttpClient(handlerMock.Object)); - - var profileException = Assert.ThrowsExceptionAsync(async () => - { - await engine.GetActivityDetailsAsync(EncryptedToken, SdkId, _keyPair, new Uri(Constants.Api.DefaultYotiApiUrl)); - }).Result; + [TestClass] + public class YotiClientEngineTests + { + private const string EncryptedToken = "b6H19bUCJhwh6WqQX/sEHWX9RP+A/ANr1fkApwA4Dp2nJQFAjrF9e6YCXhNBpAIhfHnN0iXubyXxXZMNwNMSQ5VOxkqiytrvPykfKQWHC6ypSbfy0ex8ihndaAXG5FUF+qcU8QaFPMy6iF3x0cxnY0Ij0kZj0Ng2t6oiNafb7AhT+VGXxbFbtZu1QF744PpWMuH0LVyBsAa5N5GJw2AyBrnOh67fWMFDKTJRziP5qCW2k4h5vJfiYr/EOiWKCB1d/zINmUm94ZffGXxcDAkq+KxhN1ZuNhGlJ2fKcFh7KxV0BqlUWPsIEiwS0r9CJ2o1VLbEs2U/hCEXaqseEV7L29EnNIinEPVbL4WR7vkF6zQCbK/cehlk2Qwda+VIATqupRO5grKZN78R9lBitvgilDaoE7JB/VFcPoljGQ48kX0wje1mviX4oJHhuO8GdFITS5LTbojGVQWT7LUNgAUe0W0j+FLHYYck3v84OhWTqads5/jmnnLkp9bdJSRuJF0e8pNdePnn2lgF+GIcyW/0kyGVqeXZrIoxnObLpF+YeUteRBKTkSGFcy7a/V/DLiJMPmH8UXDLOyv8TVt3ppzqpyUrLN2JVMbL5wZ4oriL2INEQKvw/boDJjZDGeRlu5m1y7vGDNBRDo64+uQM9fRUULPw+YkABNwC0DeShswzT00="; + private readonly AsymmetricCipherKeyPair _keyPair = KeyPair.Get(); + private static HttpRequestMessage _httpRequestMessage; + private const string SdkId = "fake-sdk-id"; + + [DataTestMethod] + [DataRow(null)] + [DataRow("")] + public void InvalidTokenShouldThrowException(string encryptedToken) + { + var engine = new YotiClientEngine(new HttpClient()); + + var profileException = Assert.ThrowsExceptionAsync(async () => + { + await engine.GetActivityDetailsAsync(encryptedToken, SdkId, _keyPair, new Uri(Constants.Api.DefaultYotiApiUrl)); + }).Result; + + Assert.IsTrue(profileException.Message.Contains("'encryptedConnectToken' must not be empty or null")); + } + + [TestMethod] + public void SharingFailureShouldReturnSharingFailure() + { + Mock handlerMock = SetupMockMessageHandler( + HttpStatusCode.OK, + "{\"session_data\":null,\"receipt\":{\"receipt_id\": null,\"other_party_profile_content\": null,\"policy_uri\":null,\"personal_key\":null,\"remember_me_id\":null, \"sharing_outcome\":\"FAILURE\",\"timestamp\":\"2016-09-23T13:04:11Z\"}}"); + + var engine = new YotiClientEngine(new HttpClient(handlerMock.Object)); + + var profileException = Assert.ThrowsExceptionAsync(async () => + { + await engine.GetActivityDetailsAsync(EncryptedToken, SdkId, _keyPair, new Uri(Constants.Api.DefaultYotiApiUrl)); + }).Result; + + Assert.IsTrue(profileException.Message.StartsWith("The share was not successful")); + } + + [TestMethod] + public void SharingFailureWithErrorCodeShouldThrowExceptionWithErrorCode() + { + string jsonResponse = System.IO.File.ReadAllText("TestData/ShareFailure.json"); + + Mock handlerMock = SetupMockMessageHandler( + HttpStatusCode.OK, jsonResponse); + + var engine = new YotiClientEngine(new HttpClient(handlerMock.Object)); + + var profileException = Assert.ThrowsExceptionAsync(async () => + { + await engine.GetActivityDetailsAsync(EncryptedToken, SdkId, _keyPair, new Uri(Constants.Api.DefaultYotiApiUrl)); + }).Result; + + Assert.IsTrue(profileException.Message.StartsWith("The share was not successful")); + Assert.AreEqual("SOME_ERROR_CODE", profileException.ErrorCode); + } + + [TestMethod] + public void SharingFailureShouldThrowExceptionWithWholeResponseExposed() + { + string jsonResponse = System.IO.File.ReadAllText("TestData/ShareFailure.json"); + + Mock handlerMock = SetupMockMessageHandler( + HttpStatusCode.OK, jsonResponse); + + var engine = new YotiClientEngine(new HttpClient(handlerMock.Object)); + + var profileException = Assert.ThrowsExceptionAsync(async () => + { + await engine.GetActivityDetailsAsync(EncryptedToken, SdkId, _keyPair, new Uri(Constants.Api.DefaultYotiApiUrl)); + }).Result; - Assert.IsTrue(profileException.Message.StartsWith("The share was not successful")); - Assert.AreEqual("SOME_ERROR_CODE", profileException.ErrorCode); - Assert.AreEqual(jsonResponse, profileException.ResponseContent); - } + Assert.IsTrue(profileException.Message.StartsWith("The share was not successful")); + Assert.AreEqual("SOME_ERROR_CODE", profileException.ErrorCode); + Assert.AreEqual(jsonResponse, profileException.ResponseContent); + } - [TestMethod] - public void SharingFailureShouldThrowExceptionWithWholeResponseExposedRegardlessOfFormOfJson() - { - string jsonResponse = System.IO.File.ReadAllText("TestData/ShareFailureMinimal.json"); + [TestMethod] + public void SharingFailureShouldThrowExceptionWithWholeResponseExposedRegardlessOfFormOfJson() + { + string jsonResponse = System.IO.File.ReadAllText("TestData/ShareFailureMinimal.json"); - Mock handlerMock = SetupMockMessageHandler( - HttpStatusCode.OK, jsonResponse); + Mock handlerMock = SetupMockMessageHandler( + HttpStatusCode.OK, jsonResponse); - var engine = new YotiClientEngine(new HttpClient(handlerMock.Object)); + var engine = new YotiClientEngine(new HttpClient(handlerMock.Object)); - var profileException = Assert.ThrowsExceptionAsync(async () => - { - await engine.GetActivityDetailsAsync(EncryptedToken, SdkId, _keyPair, new Uri(Constants.Api.DefaultYotiApiUrl)); - }).Result; + var profileException = Assert.ThrowsExceptionAsync(async () => + { + await engine.GetActivityDetailsAsync(EncryptedToken, SdkId, _keyPair, new Uri(Constants.Api.DefaultYotiApiUrl)); + }).Result; - Assert.IsTrue(profileException.Message.StartsWith("The share was not successful")); - Assert.AreEqual(default(string), profileException.ErrorCode); - Assert.AreEqual(jsonResponse, profileException.ResponseContent); - } + Assert.IsTrue(profileException.Message.StartsWith("The share was not successful")); + Assert.AreEqual(default(string), profileException.ErrorCode); + Assert.AreEqual(jsonResponse, profileException.ResponseContent); + } - [TestMethod] - public void SharingFailureExceptionShouldExposeResponseContentRegardlessOfFormOfJson() - { - string jsonResponse = System.IO.File.ReadAllText("TestData/ShareFailureMinimal.json"); + [TestMethod] + public void SharingFailureExceptionShouldExposeResponseContentRegardlessOfFormOfJson() + { + string jsonResponse = System.IO.File.ReadAllText("TestData/ShareFailureMinimal.json"); - YotiProfileException profileException = new YotiProfileException("msg", jsonResponse); + YotiProfileException profileException = new YotiProfileException("msg", jsonResponse); - Assert.AreEqual(default(string), profileException.ErrorCode); - Assert.AreEqual(jsonResponse, profileException.ResponseContent); - } + Assert.AreEqual(default(string), profileException.ErrorCode); + Assert.AreEqual(jsonResponse, profileException.ResponseContent); + } - [TestMethod] - public void SharingFailureExceptionShouldExposeResponseContentRegardlessOfFormOfJson_MissingErrorDetails() - { - string jsonResponse = System.IO.File.ReadAllText("TestData/ShareFailureMissingErrorDetails.json"); + [TestMethod] + public void SharingFailureExceptionShouldExposeResponseContentRegardlessOfFormOfJson_MissingErrorDetails() + { + string jsonResponse = System.IO.File.ReadAllText("TestData/ShareFailureMissingErrorDetails.json"); - YotiProfileException profileException = new YotiProfileException("msg", jsonResponse); + YotiProfileException profileException = new YotiProfileException("msg", jsonResponse); - Assert.AreEqual(default(string), profileException.ErrorCode); - Assert.AreEqual(jsonResponse, profileException.ResponseContent); - } + Assert.AreEqual(default(string), profileException.ErrorCode); + Assert.AreEqual(jsonResponse, profileException.ResponseContent); + } - [TestMethod] - public void SharingFailureExceptionShouldExposeResponseContentRegardlessOfFormOfJson_MissingErrorCode() - { - string jsonResponse = System.IO.File.ReadAllText("TestData/ShareFailureMissingErrorCode.json"); + [TestMethod] + public void SharingFailureExceptionShouldExposeResponseContentRegardlessOfFormOfJson_MissingErrorCode() + { + string jsonResponse = System.IO.File.ReadAllText("TestData/ShareFailureMissingErrorCode.json"); - YotiProfileException profileException = new YotiProfileException("msg", jsonResponse); + YotiProfileException profileException = new YotiProfileException("msg", jsonResponse); - Assert.AreEqual(default(string), profileException.ErrorCode); - Assert.AreEqual(jsonResponse, profileException.ResponseContent); - } + Assert.AreEqual(default(string), profileException.ErrorCode); + Assert.AreEqual(jsonResponse, profileException.ResponseContent); + } - [TestMethod] - public void NullReceiptShouldThrowException() - { - Mock handlerMock = SetupMockMessageHandler( - HttpStatusCode.OK, - "{\"session_data\":null,\"receipt\":null}"); + [TestMethod] + public void NullReceiptShouldThrowException() + { + Mock handlerMock = SetupMockMessageHandler( + HttpStatusCode.OK, + "{\"session_data\":null,\"receipt\":null}"); - var engine = new YotiClientEngine(new HttpClient(handlerMock.Object)); + var engine = new YotiClientEngine(new HttpClient(handlerMock.Object)); - var profileException = Assert.ThrowsExceptionAsync(async () => - { - await engine.GetActivityDetailsAsync(EncryptedToken, SdkId, _keyPair, new Uri(Constants.Api.DefaultYotiApiUrl)); - }).Result; + var profileException = Assert.ThrowsExceptionAsync(async () => + { + await engine.GetActivityDetailsAsync(EncryptedToken, SdkId, _keyPair, new Uri(Constants.Api.DefaultYotiApiUrl)); + }).Result; - Assert.IsTrue(profileException.Message.StartsWith("The receipt of the parsed response is null")); - } + Assert.IsTrue(profileException.Message.StartsWith("The receipt of the parsed response is null")); + } - [TestMethod] - public void SuccessfulShareShouldReturnCorrectValues() - { - const string wrappedReceiptKey = "kyHPjq2+Y48cx+9yS/XzmW09jVUylSdhbP+3Q9Tc9p6bCEnyfa8vj38AIu744RzzE+Dc4qkSF21VfzQKtJVILfOXu5xRc7MYa5k3zWhjiesg/gsrv7J4wDyyBpHIJB8TWXnubYMbSYQJjlsfwyxE9kGe0YI08pRo2Tiht0bfR5Z/YrhAk4UBvjp84D+oyug/1mtGhKphA4vgPhQ9/y2wcInYxju7Q6yzOsXGaRUXR38Tn2YmY9OBgjxiTnhoYJFP1X9YJkHeWMW0vxF1RHxgIVrpf7oRzdY1nq28qzRg5+wC7cjRpS2i/CKUAo0oVG4pbpXsaFhaTewStVC7UFtA77JHb3EnF4HcSWMnK5FM7GGkL9MMXQenh11NZHKPWXpux0nLZ6/vwffXZfsiyTIcFL/NajGN8C/hnNBljoQ+B3fzWbjcq5ueUOPwARZ1y38W83UwMynzkud/iEdHLaZIu4qUCRkfSxJg7Dc+O9/BdiffkOn2GyFmNjVeq754DCUypxzMkjYxokedN84nK13OU4afVyC7t5DDxAK/MqAc69NCBRLqMi5f8BMeOZfMcSWPGC9a2Qu8VgG125TuZT4+wIykUhGyj3Bb2/fdPsxwuKFR+E0uqs0ZKvcv1tkNRRtKYBqTacgGK9Yoehg12cyLrITLdjU1fmIDn4/vrhztN5w="; - const string otherPartyProfileContent = "ChCZAib1TBm9Q5GYfFrS1ep9EnAwQB5shpAPWLBgZgFgt6bCG3S5qmZHhrqUbQr3yL6yeLIDwbM7x4nuT/MYp+LDXgmFTLQNYbDTzrEzqNuO2ZPn9Kpg+xpbm9XtP7ZLw3Ep2BCmSqtnll/OdxAqLb4DTN4/wWdrjnFC+L/oQEECu646"; - const string rememberMeId = "remember_me_id0123456789"; - const string parentRememberMeId = "parent_remember_me_id0123456789"; - const string receiptId = "receipt_id_123"; + [TestMethod] + public void SuccessfulShareShouldReturnCorrectValues() + { + const string wrappedReceiptKey = "kyHPjq2+Y48cx+9yS/XzmW09jVUylSdhbP+3Q9Tc9p6bCEnyfa8vj38AIu744RzzE+Dc4qkSF21VfzQKtJVILfOXu5xRc7MYa5k3zWhjiesg/gsrv7J4wDyyBpHIJB8TWXnubYMbSYQJjlsfwyxE9kGe0YI08pRo2Tiht0bfR5Z/YrhAk4UBvjp84D+oyug/1mtGhKphA4vgPhQ9/y2wcInYxju7Q6yzOsXGaRUXR38Tn2YmY9OBgjxiTnhoYJFP1X9YJkHeWMW0vxF1RHxgIVrpf7oRzdY1nq28qzRg5+wC7cjRpS2i/CKUAo0oVG4pbpXsaFhaTewStVC7UFtA77JHb3EnF4HcSWMnK5FM7GGkL9MMXQenh11NZHKPWXpux0nLZ6/vwffXZfsiyTIcFL/NajGN8C/hnNBljoQ+B3fzWbjcq5ueUOPwARZ1y38W83UwMynzkud/iEdHLaZIu4qUCRkfSxJg7Dc+O9/BdiffkOn2GyFmNjVeq754DCUypxzMkjYxokedN84nK13OU4afVyC7t5DDxAK/MqAc69NCBRLqMi5f8BMeOZfMcSWPGC9a2Qu8VgG125TuZT4+wIykUhGyj3Bb2/fdPsxwuKFR+E0uqs0ZKvcv1tkNRRtKYBqTacgGK9Yoehg12cyLrITLdjU1fmIDn4/vrhztN5w="; + const string otherPartyProfileContent = "ChCZAib1TBm9Q5GYfFrS1ep9EnAwQB5shpAPWLBgZgFgt6bCG3S5qmZHhrqUbQr3yL6yeLIDwbM7x4nuT/MYp+LDXgmFTLQNYbDTzrEzqNuO2ZPn9Kpg+xpbm9XtP7ZLw3Ep2BCmSqtnll/OdxAqLb4DTN4/wWdrjnFC+L/oQEECu646"; + const string rememberMeId = "remember_me_id0123456789"; + const string parentRememberMeId = "parent_remember_me_id0123456789"; + const string receiptId = "receipt_id_123"; - Mock handlerMock = SetupMockMessageHandler( - HttpStatusCode.OK, - "{\"receipt\":{\"wrapped_receipt_key\": \"" + wrappedReceiptKey + "\",\"other_party_profile_content\": \"" + otherPartyProfileContent + "\",\"remember_me_id\":\"" + rememberMeId + "\",\"parent_remember_me_id\":\"" + parentRememberMeId + "\",\"receipt_id\":\"" + receiptId + "\", \"sharing_outcome\":\"SUCCESS\", \"timestamp\":\"2016-01-01T00:00:00Z\"}}"); + Mock handlerMock = SetupMockMessageHandler( + HttpStatusCode.OK, + "{\"receipt\":{\"wrapped_receipt_key\": \"" + wrappedReceiptKey + "\",\"other_party_profile_content\": \"" + otherPartyProfileContent + "\",\"remember_me_id\":\"" + rememberMeId + "\",\"parent_remember_me_id\":\"" + parentRememberMeId + "\",\"receipt_id\":\"" + receiptId + "\", \"sharing_outcome\":\"SUCCESS\", \"timestamp\":\"2016-01-01T00:00:00Z\"}}"); - var engine = new YotiClientEngine(new HttpClient(handlerMock.Object)); + var engine = new YotiClientEngine(new HttpClient(handlerMock.Object)); - ActivityDetails activityDetails = engine.GetActivityDetailsAsync(EncryptedToken, SdkId, _keyPair, new Uri(Constants.Api.DefaultYotiApiUrl)).Result; + ActivityDetails activityDetails = engine.GetActivityDetailsAsync(EncryptedToken, SdkId, _keyPair, new Uri(Constants.Api.DefaultYotiApiUrl)).Result; - Assert.IsNotNull(activityDetails); + Assert.IsNotNull(activityDetails); - Assert.IsNotNull(activityDetails.Profile); + Assert.IsNotNull(activityDetails.Profile); - Assert.AreEqual(receiptId, activityDetails.ReceiptId); + Assert.AreEqual(receiptId, activityDetails.ReceiptId); - Assert.AreEqual(rememberMeId, activityDetails.RememberMeId); - Assert.AreEqual(parentRememberMeId, activityDetails.ParentRememberMeId); - Assert.IsNull(activityDetails.ExtraData.AttributeIssuanceDetails); + Assert.AreEqual(rememberMeId, activityDetails.RememberMeId); + Assert.AreEqual(parentRememberMeId, activityDetails.ParentRememberMeId); + Assert.IsNull(activityDetails.ExtraData.AttributeIssuanceDetails); - Assert.AreEqual(new DateTime(2016, 1, 1, 0, 0, 0), activityDetails.Timestamp); + Assert.AreEqual(new DateTime(2016, 1, 1, 0, 0, 0), activityDetails.Timestamp); - Assert.IsNotNull(activityDetails.Profile.Selfie); - Assert.AreEqual(Convert.ToBase64String(Encoding.UTF8.GetBytes("selfie0123456789")), Convert.ToBase64String(activityDetails.Profile.Selfie.GetValue().GetContent())); + Assert.IsNotNull(activityDetails.Profile.Selfie); + Assert.AreEqual(Convert.ToBase64String(Encoding.UTF8.GetBytes("selfie0123456789")), Convert.ToBase64String(activityDetails.Profile.Selfie.GetValue().GetContent())); - Assert.AreEqual("phone_number0123456789", activityDetails.Profile.MobileNumber.GetValue()); + Assert.AreEqual("phone_number0123456789", activityDetails.Profile.MobileNumber.GetValue()); - Assert.AreEqual(new DateTime(1980, 1, 1), activityDetails.Profile.DateOfBirth.GetValue()); - } + Assert.AreEqual(new DateTime(1980, 1, 1), activityDetails.Profile.DateOfBirth.GetValue()); + } - [TestMethod] - public void ShouldAddAuthKeyHeaderToProfileRequest() - { - Mock handlerMock = SetupMockMessageHandler( - HttpStatusCode.OK, - "{\"receipt\":{\"wrapped_receipt_key\": \"kyHPjq2+Y48cx+9yS/XzmW09jVUylSdhbP+3Q9Tc9p6bCEnyfa8vj38AIu744RzzE+Dc4qkSF21VfzQKtJVILfOXu5xRc7MYa5k3zWhjiesg/gsrv7J4wDyyBpHIJB8TWXnubYMbSYQJjlsfwyxE9kGe0YI08pRo2Tiht0bfR5Z/YrhAk4UBvjp84D+oyug/1mtGhKphA4vgPhQ9/y2wcInYxju7Q6yzOsXGaRUXR38Tn2YmY9OBgjxiTnhoYJFP1X9YJkHeWMW0vxF1RHxgIVrpf7oRzdY1nq28qzRg5+wC7cjRpS2i/CKUAo0oVG4pbpXsaFhaTewStVC7UFtA77JHb3EnF4HcSWMnK5FM7GGkL9MMXQenh11NZHKPWXpux0nLZ6/vwffXZfsiyTIcFL/NajGN8C/hnNBljoQ+B3fzWbjcq5ueUOPwARZ1y38W83UwMynzkud/iEdHLaZIu4qUCRkfSxJg7Dc+O9/BdiffkOn2GyFmNjVeq754DCUypxzMkjYxokedN84nK13OU4afVyC7t5DDxAK/MqAc69NCBRLqMi5f8BMeOZfMcSWPGC9a2Qu8VgG125TuZT4+wIykUhGyj3Bb2/fdPsxwuKFR+E0uqs0ZKvcv1tkNRRtKYBqTacgGK9Yoehg12cyLrITLdjU1fmIDn4/vrhztN5w=\",\"other_party_profile_content\": \"ChCZAib1TBm9Q5GYfFrS1ep9EnAwQB5shpAPWLBgZgFgt6bCG3S5qmZHhrqUbQr3yL6yeLIDwbM7x4nuT/MYp+LDXgmFTLQNYbDTzrEzqNuO2ZPn9Kpg+xpbm9XtP7ZLw3Ep2BCmSqtnll/OdxAqLb4DTN4/wWdrjnFC+L/oQEECu646\",\"remember_me_id\":\"remember_me_id0123456789\",\"parent_remember_me_id\":\"parent_remember_me_id0123456789\",\"receipt_id\":\"receipt_id_123\", \"sharing_outcome\":\"SUCCESS\", \"timestamp\":\"2016-01-01T00:00:00Z\"}}"); + [TestMethod] + public void ShouldAddAuthKeyHeaderToProfileRequest() + { + Mock handlerMock = SetupMockMessageHandler( + HttpStatusCode.OK, + "{\"receipt\":{\"wrapped_receipt_key\": \"kyHPjq2+Y48cx+9yS/XzmW09jVUylSdhbP+3Q9Tc9p6bCEnyfa8vj38AIu744RzzE+Dc4qkSF21VfzQKtJVILfOXu5xRc7MYa5k3zWhjiesg/gsrv7J4wDyyBpHIJB8TWXnubYMbSYQJjlsfwyxE9kGe0YI08pRo2Tiht0bfR5Z/YrhAk4UBvjp84D+oyug/1mtGhKphA4vgPhQ9/y2wcInYxju7Q6yzOsXGaRUXR38Tn2YmY9OBgjxiTnhoYJFP1X9YJkHeWMW0vxF1RHxgIVrpf7oRzdY1nq28qzRg5+wC7cjRpS2i/CKUAo0oVG4pbpXsaFhaTewStVC7UFtA77JHb3EnF4HcSWMnK5FM7GGkL9MMXQenh11NZHKPWXpux0nLZ6/vwffXZfsiyTIcFL/NajGN8C/hnNBljoQ+B3fzWbjcq5ueUOPwARZ1y38W83UwMynzkud/iEdHLaZIu4qUCRkfSxJg7Dc+O9/BdiffkOn2GyFmNjVeq754DCUypxzMkjYxokedN84nK13OU4afVyC7t5DDxAK/MqAc69NCBRLqMi5f8BMeOZfMcSWPGC9a2Qu8VgG125TuZT4+wIykUhGyj3Bb2/fdPsxwuKFR+E0uqs0ZKvcv1tkNRRtKYBqTacgGK9Yoehg12cyLrITLdjU1fmIDn4/vrhztN5w=\",\"other_party_profile_content\": \"ChCZAib1TBm9Q5GYfFrS1ep9EnAwQB5shpAPWLBgZgFgt6bCG3S5qmZHhrqUbQr3yL6yeLIDwbM7x4nuT/MYp+LDXgmFTLQNYbDTzrEzqNuO2ZPn9Kpg+xpbm9XtP7ZLw3Ep2BCmSqtnll/OdxAqLb4DTN4/wWdrjnFC+L/oQEECu646\",\"remember_me_id\":\"remember_me_id0123456789\",\"parent_remember_me_id\":\"parent_remember_me_id0123456789\",\"receipt_id\":\"receipt_id_123\", \"sharing_outcome\":\"SUCCESS\", \"timestamp\":\"2016-01-01T00:00:00Z\"}}"); - var engine = new YotiClientEngine(new HttpClient(handlerMock.Object)); + var engine = new YotiClientEngine(new HttpClient(handlerMock.Object)); - ActivityDetails _ = engine.GetActivityDetailsAsync(EncryptedToken, SdkId, _keyPair, new Uri(Constants.Api.DefaultYotiApiUrl)).Result; + ActivityDetails _ = engine.GetActivityDetailsAsync(EncryptedToken, SdkId, _keyPair, new Uri(Constants.Api.DefaultYotiApiUrl)).Result; - Assert.IsTrue(_httpRequestMessage.Headers.Contains(Constants.Api.AuthKeyHeader)); - } + Assert.IsTrue(_httpRequestMessage.Headers.Contains(Constants.Api.AuthKeyHeader)); + } - [TestMethod] - public void EmptyStringParentRememberMeIdShouldBeHandled() - { - const string wrappedReceiptKey = "kyHPjq2+Y48cx+9yS/XzmW09jVUylSdhbP+3Q9Tc9p6bCEnyfa8vj38AIu744RzzE+Dc4qkSF21VfzQKtJVILfOXu5xRc7MYa5k3zWhjiesg/gsrv7J4wDyyBpHIJB8TWXnubYMbSYQJjlsfwyxE9kGe0YI08pRo2Tiht0bfR5Z/YrhAk4UBvjp84D+oyug/1mtGhKphA4vgPhQ9/y2wcInYxju7Q6yzOsXGaRUXR38Tn2YmY9OBgjxiTnhoYJFP1X9YJkHeWMW0vxF1RHxgIVrpf7oRzdY1nq28qzRg5+wC7cjRpS2i/CKUAo0oVG4pbpXsaFhaTewStVC7UFtA77JHb3EnF4HcSWMnK5FM7GGkL9MMXQenh11NZHKPWXpux0nLZ6/vwffXZfsiyTIcFL/NajGN8C/hnNBljoQ+B3fzWbjcq5ueUOPwARZ1y38W83UwMynzkud/iEdHLaZIu4qUCRkfSxJg7Dc+O9/BdiffkOn2GyFmNjVeq754DCUypxzMkjYxokedN84nK13OU4afVyC7t5DDxAK/MqAc69NCBRLqMi5f8BMeOZfMcSWPGC9a2Qu8VgG125TuZT4+wIykUhGyj3Bb2/fdPsxwuKFR+E0uqs0ZKvcv1tkNRRtKYBqTacgGK9Yoehg12cyLrITLdjU1fmIDn4/vrhztN5w="; - const string parentRememberMeId = ""; + [TestMethod] + public void EmptyStringParentRememberMeIdShouldBeHandled() + { + const string wrappedReceiptKey = "kyHPjq2+Y48cx+9yS/XzmW09jVUylSdhbP+3Q9Tc9p6bCEnyfa8vj38AIu744RzzE+Dc4qkSF21VfzQKtJVILfOXu5xRc7MYa5k3zWhjiesg/gsrv7J4wDyyBpHIJB8TWXnubYMbSYQJjlsfwyxE9kGe0YI08pRo2Tiht0bfR5Z/YrhAk4UBvjp84D+oyug/1mtGhKphA4vgPhQ9/y2wcInYxju7Q6yzOsXGaRUXR38Tn2YmY9OBgjxiTnhoYJFP1X9YJkHeWMW0vxF1RHxgIVrpf7oRzdY1nq28qzRg5+wC7cjRpS2i/CKUAo0oVG4pbpXsaFhaTewStVC7UFtA77JHb3EnF4HcSWMnK5FM7GGkL9MMXQenh11NZHKPWXpux0nLZ6/vwffXZfsiyTIcFL/NajGN8C/hnNBljoQ+B3fzWbjcq5ueUOPwARZ1y38W83UwMynzkud/iEdHLaZIu4qUCRkfSxJg7Dc+O9/BdiffkOn2GyFmNjVeq754DCUypxzMkjYxokedN84nK13OU4afVyC7t5DDxAK/MqAc69NCBRLqMi5f8BMeOZfMcSWPGC9a2Qu8VgG125TuZT4+wIykUhGyj3Bb2/fdPsxwuKFR+E0uqs0ZKvcv1tkNRRtKYBqTacgGK9Yoehg12cyLrITLdjU1fmIDn4/vrhztN5w="; + const string parentRememberMeId = ""; - Mock handlerMock = SetupMockMessageHandler( - HttpStatusCode.OK, - "{\"receipt\":{\"wrapped_receipt_key\": \"" + wrappedReceiptKey + "\",\"parent_remember_me_id\":\"" + parentRememberMeId + "\", \"sharing_outcome\":\"SUCCESS\", \"timestamp\":\"2016-01-01T00:00:00Z\"}}"); + Mock handlerMock = SetupMockMessageHandler( + HttpStatusCode.OK, + "{\"receipt\":{\"wrapped_receipt_key\": \"" + wrappedReceiptKey + "\",\"parent_remember_me_id\":\"" + parentRememberMeId + "\", \"sharing_outcome\":\"SUCCESS\", \"timestamp\":\"2016-01-01T00:00:00Z\"}}"); - var engine = new YotiClientEngine(new HttpClient(handlerMock.Object)); + var engine = new YotiClientEngine(new HttpClient(handlerMock.Object)); - ActivityDetails activityDetails = engine.GetActivityDetailsAsync(EncryptedToken, SdkId, _keyPair, new Uri(Constants.Api.DefaultYotiApiUrl)).Result; + ActivityDetails activityDetails = engine.GetActivityDetailsAsync(EncryptedToken, SdkId, _keyPair, new Uri(Constants.Api.DefaultYotiApiUrl)).Result; - Assert.AreEqual(string.Empty, activityDetails.ParentRememberMeId); - } + Assert.AreEqual(string.Empty, activityDetails.ParentRememberMeId); + } - [TestMethod] - public void ShouldHandleMissingValuesInReceipt() - { - const string wrappedReceiptKey = "kyHPjq2+Y48cx+9yS/XzmW09jVUylSdhbP+3Q9Tc9p6bCEnyfa8vj38AIu744RzzE+Dc4qkSF21VfzQKtJVILfOXu5xRc7MYa5k3zWhjiesg/gsrv7J4wDyyBpHIJB8TWXnubYMbSYQJjlsfwyxE9kGe0YI08pRo2Tiht0bfR5Z/YrhAk4UBvjp84D+oyug/1mtGhKphA4vgPhQ9/y2wcInYxju7Q6yzOsXGaRUXR38Tn2YmY9OBgjxiTnhoYJFP1X9YJkHeWMW0vxF1RHxgIVrpf7oRzdY1nq28qzRg5+wC7cjRpS2i/CKUAo0oVG4pbpXsaFhaTewStVC7UFtA77JHb3EnF4HcSWMnK5FM7GGkL9MMXQenh11NZHKPWXpux0nLZ6/vwffXZfsiyTIcFL/NajGN8C/hnNBljoQ+B3fzWbjcq5ueUOPwARZ1y38W83UwMynzkud/iEdHLaZIu4qUCRkfSxJg7Dc+O9/BdiffkOn2GyFmNjVeq754DCUypxzMkjYxokedN84nK13OU4afVyC7t5DDxAK/MqAc69NCBRLqMi5f8BMeOZfMcSWPGC9a2Qu8VgG125TuZT4+wIykUhGyj3Bb2/fdPsxwuKFR+E0uqs0ZKvcv1tkNRRtKYBqTacgGK9Yoehg12cyLrITLdjU1fmIDn4/vrhztN5w="; + [TestMethod] + public void ShouldHandleMissingValuesInReceipt() + { + const string wrappedReceiptKey = "kyHPjq2+Y48cx+9yS/XzmW09jVUylSdhbP+3Q9Tc9p6bCEnyfa8vj38AIu744RzzE+Dc4qkSF21VfzQKtJVILfOXu5xRc7MYa5k3zWhjiesg/gsrv7J4wDyyBpHIJB8TWXnubYMbSYQJjlsfwyxE9kGe0YI08pRo2Tiht0bfR5Z/YrhAk4UBvjp84D+oyug/1mtGhKphA4vgPhQ9/y2wcInYxju7Q6yzOsXGaRUXR38Tn2YmY9OBgjxiTnhoYJFP1X9YJkHeWMW0vxF1RHxgIVrpf7oRzdY1nq28qzRg5+wC7cjRpS2i/CKUAo0oVG4pbpXsaFhaTewStVC7UFtA77JHb3EnF4HcSWMnK5FM7GGkL9MMXQenh11NZHKPWXpux0nLZ6/vwffXZfsiyTIcFL/NajGN8C/hnNBljoQ+B3fzWbjcq5ueUOPwARZ1y38W83UwMynzkud/iEdHLaZIu4qUCRkfSxJg7Dc+O9/BdiffkOn2GyFmNjVeq754DCUypxzMkjYxokedN84nK13OU4afVyC7t5DDxAK/MqAc69NCBRLqMi5f8BMeOZfMcSWPGC9a2Qu8VgG125TuZT4+wIykUhGyj3Bb2/fdPsxwuKFR+E0uqs0ZKvcv1tkNRRtKYBqTacgGK9Yoehg12cyLrITLdjU1fmIDn4/vrhztN5w="; - Mock handlerMock = SetupMockMessageHandler( - HttpStatusCode.OK, - "{\"receipt\":{\"wrapped_receipt_key\": \"" + wrappedReceiptKey + "\", \"sharing_outcome\":\"SUCCESS\", \"timestamp\":\"2016-01-01T00:00:00Z\"}}"); + Mock handlerMock = SetupMockMessageHandler( + HttpStatusCode.OK, + "{\"receipt\":{\"wrapped_receipt_key\": \"" + wrappedReceiptKey + "\", \"sharing_outcome\":\"SUCCESS\", \"timestamp\":\"2016-01-01T00:00:00Z\"}}"); - var engine = new YotiClientEngine(new HttpClient(handlerMock.Object)); + var engine = new YotiClientEngine(new HttpClient(handlerMock.Object)); - ActivityDetails activityDetails = engine.GetActivityDetailsAsync(EncryptedToken, SdkId, _keyPair, new Uri(Constants.Api.DefaultYotiApiUrl)).Result; + ActivityDetails activityDetails = engine.GetActivityDetailsAsync(EncryptedToken, SdkId, _keyPair, new Uri(Constants.Api.DefaultYotiApiUrl)).Result; - Assert.IsNotNull(activityDetails.Profile); + Assert.IsNotNull(activityDetails.Profile); #pragma warning disable CS0618 // Type or member is obsolete - Assert.AreEqual(0, activityDetails.ApplicationProfile.Attributes.Count); + Assert.AreEqual(0, activityDetails.ApplicationProfile.Attributes.Count); #pragma warning restore CS0618 // Type or member is obsolete - Assert.AreEqual(0, activityDetails.ApplicationProfile.AttributeCollection.Count); - - Assert.IsNull(activityDetails.ReceiptId); - Assert.IsNull(activityDetails.RememberMeId); - Assert.IsNull(activityDetails.ParentRememberMeId); - } - - [TestMethod] - public async Task PerformAmlCheckAsyncShouldReturnCorrectValues() - { - Mock handlerMock = SetupMockMessageHandler( - HttpStatusCode.OK, - "{\"on_fraud_list\":true,\"on_pep_list\":false,\"on_watch_list\":false}"); - - var engine = new YotiClientEngine(new HttpClient(handlerMock.Object)); - - AmlProfile amlProfile = TestTools.Aml.CreateStandardAmlProfile(); - - AmlResult amlResult = await engine.PerformAmlCheckAsync( - SdkId, _keyPair, - new Uri(Constants.Api.DefaultYotiApiUrl), - amlProfile); - - Assert.IsNotNull(amlResult); - Assert.IsTrue(amlResult.IsOnFraudList()); - Assert.IsFalse(amlResult.IsOnPepList()); - Assert.IsFalse(amlResult.IsOnWatchList()); - } - - [DataTestMethod] - [DataRow(HttpStatusCode.BadRequest)] - [DataRow(HttpStatusCode.Unauthorized)] - [DataRow(HttpStatusCode.InternalServerError)] - [DataRow(HttpStatusCode.RequestTimeout)] - [DataRow(HttpStatusCode.NotFound)] - [DataRow(HttpStatusCode.Forbidden)] - public void AmlBadRequestShouldThrowException(HttpStatusCode httpStatusCode) - { - Mock handlerMock = SetupMockMessageHandler( - httpStatusCode, - "{\"status\":\"bad\""); - - var engine = new YotiClientEngine(new HttpClient(handlerMock.Object)); - - AmlProfile amlProfile = TestTools.Aml.CreateStandardAmlProfile(); - - Assert.ThrowsExceptionAsync(async () => - { - await engine.PerformAmlCheckAsync(SdkId, _keyPair, new Uri(Constants.Api.DefaultYotiApiUrl), amlProfile); - }); - } - - [TestMethod] - public async Task CreateShareURLAsyncShouldReturnCorrectValues() - { - string shareUrl = @"https://yoti.com/shareurl"; - string refId = "NpdmVVGC-28356678-c236-4518-9de4-7a93009ccaf0-c5f92f2a-5539-453e-babc-9b06e1d6b7de"; - - Mock handlerMock = SetupMockMessageHandler( - HttpStatusCode.OK, - "{\"qrcode\":\"" + shareUrl + "\",\"ref_id\":\"" + refId + "\"}"); - - var engine = new YotiClientEngine(new HttpClient(handlerMock.Object)); - DynamicScenario dynamicScenario = TestTools.ShareUrl.CreateStandardDynamicScenario(); - - ShareUrlResult shareUrlResult = await engine.CreateShareURLAsync(SdkId, _keyPair, new Uri(Constants.Api.DefaultYotiApiUrl), dynamicScenario); - - Assert.IsNotNull(shareUrlResult); - Assert.AreEqual(new Uri(shareUrl), shareUrlResult.Url); - Assert.AreEqual(refId, shareUrlResult.RefId); - } - - [DataTestMethod] - [DataRow(HttpStatusCode.BadRequest)] - [DataRow(HttpStatusCode.Unauthorized)] - [DataRow(HttpStatusCode.InternalServerError)] - [DataRow(HttpStatusCode.RequestTimeout)] - [DataRow(HttpStatusCode.NotFound)] - [DataRow(HttpStatusCode.Forbidden)] - public void ShareURLNonSuccessStatusCodesShouldThrowException(HttpStatusCode httpStatusCode) - { - Mock handlerMock = SetupMockMessageHandler( - httpStatusCode, - "{\"status\":\"bad\""); - - var engine = new YotiClientEngine(new HttpClient(handlerMock.Object)); - - DynamicScenario dynamicScenario = TestTools.ShareUrl.CreateStandardDynamicScenario(); - - var aggregateException = Assert.ThrowsException(() => - { - engine.CreateShareURLAsync(SdkId, _keyPair, new Uri(Constants.Api.DefaultYotiApiUrl), dynamicScenario).Wait(); - }); - - Assert.IsTrue(TestTools.Exceptions.IsExceptionInAggregateException(aggregateException)); - } - - private static Mock SetupMockMessageHandler(HttpStatusCode httpStatusCode, string responseContent) - { - var handlerMock = new Mock(MockBehavior.Strict); - handlerMock - .Protected() - .Setup>( - "SendAsync", - ItExpr.IsAny(), - ItExpr.IsAny() - ) - .ReturnsAsync(new HttpResponseMessage() - { - StatusCode = httpStatusCode, - Content = new StringContent(responseContent) - }) - .Callback((http, token) => _httpRequestMessage = http) - .Verifiable(); - return handlerMock; - } - } + Assert.AreEqual(0, activityDetails.ApplicationProfile.AttributeCollection.Count); + + Assert.IsNull(activityDetails.ReceiptId); + Assert.IsNull(activityDetails.RememberMeId); + Assert.IsNull(activityDetails.ParentRememberMeId); + } + + [TestMethod] + public async Task PerformAmlCheckAsyncShouldReturnCorrectValues() + { + Mock handlerMock = SetupMockMessageHandler( + HttpStatusCode.OK, + "{\"on_fraud_list\":true,\"on_pep_list\":false,\"on_watch_list\":false}"); + + var engine = new YotiClientEngine(new HttpClient(handlerMock.Object)); + + AmlProfile amlProfile = TestTools.Aml.CreateStandardAmlProfile(); + + AmlResult amlResult = await engine.PerformAmlCheckAsync( + SdkId, _keyPair, + new Uri(Constants.Api.DefaultYotiApiUrl), + amlProfile); + + Assert.IsNotNull(amlResult); + Assert.IsTrue(amlResult.IsOnFraudList()); + Assert.IsFalse(amlResult.IsOnPepList()); + Assert.IsFalse(amlResult.IsOnWatchList()); + } + + [DataTestMethod] + [DataRow(HttpStatusCode.BadRequest)] + [DataRow(HttpStatusCode.Unauthorized)] + [DataRow(HttpStatusCode.InternalServerError)] + [DataRow(HttpStatusCode.RequestTimeout)] + [DataRow(HttpStatusCode.NotFound)] + [DataRow(HttpStatusCode.Forbidden)] + public void AmlBadRequestShouldThrowException(HttpStatusCode httpStatusCode) + { + Mock handlerMock = SetupMockMessageHandler( + httpStatusCode, + "{\"status\":\"bad\""); + + var engine = new YotiClientEngine(new HttpClient(handlerMock.Object)); + + AmlProfile amlProfile = TestTools.Aml.CreateStandardAmlProfile(); + + Assert.ThrowsExceptionAsync(async () => + { + await engine.PerformAmlCheckAsync(SdkId, _keyPair, new Uri(Constants.Api.DefaultYotiApiUrl), amlProfile); + }); + } + + [TestMethod] + public async Task CreateShareURLAsyncShouldReturnCorrectValues() + { + string shareUrl = @"https://yoti.com/shareurl"; + string refId = "NpdmVVGC-28356678-c236-4518-9de4-7a93009ccaf0-c5f92f2a-5539-453e-babc-9b06e1d6b7de"; + + Mock handlerMock = SetupMockMessageHandler( + HttpStatusCode.OK, + "{\"qrcode\":\"" + shareUrl + "\",\"ref_id\":\"" + refId + "\"}"); + + var engine = new YotiClientEngine(new HttpClient(handlerMock.Object)); + DynamicScenario dynamicScenario = TestTools.ShareUrl.CreateStandardDynamicScenario(); + + ShareUrlResult shareUrlResult = await engine.CreateShareURLAsync(SdkId, _keyPair, new Uri(Constants.Api.DefaultYotiApiUrl), dynamicScenario); + + Assert.IsNotNull(shareUrlResult); + Assert.AreEqual(new Uri(shareUrl), shareUrlResult.Url); + Assert.AreEqual(refId, shareUrlResult.RefId); + } + + [DataTestMethod] + [DataRow(HttpStatusCode.BadRequest)] + [DataRow(HttpStatusCode.Unauthorized)] + [DataRow(HttpStatusCode.InternalServerError)] + [DataRow(HttpStatusCode.RequestTimeout)] + [DataRow(HttpStatusCode.NotFound)] + [DataRow(HttpStatusCode.Forbidden)] + public void ShareURLNonSuccessStatusCodesShouldThrowException(HttpStatusCode httpStatusCode) + { + Mock handlerMock = SetupMockMessageHandler( + httpStatusCode, + "{\"status\":\"bad\""); + + var engine = new YotiClientEngine(new HttpClient(handlerMock.Object)); + + DynamicScenario dynamicScenario = TestTools.ShareUrl.CreateStandardDynamicScenario(); + + var aggregateException = Assert.ThrowsException(() => + { + engine.CreateShareURLAsync(SdkId, _keyPair, new Uri(Constants.Api.DefaultYotiApiUrl), dynamicScenario).Wait(); + }); + + Assert.IsTrue(TestTools.Exceptions.IsExceptionInAggregateException(aggregateException)); + } + + private static Mock SetupMockMessageHandler(HttpStatusCode httpStatusCode, string responseContent) + { + var handlerMock = new Mock(MockBehavior.Strict); + handlerMock + .Protected() + .Setup>( + "SendAsync", + ItExpr.IsAny(), + ItExpr.IsAny() + ) + .ReturnsAsync(new HttpResponseMessage() + { + StatusCode = httpStatusCode, + Content = new StringContent(responseContent) + }) + .Callback((http, token) => _httpRequestMessage = http) + .Verifiable(); + return handlerMock; + } + } } \ No newline at end of file