This commit is contained in:
Zeeshaun
2026-03-13 09:28:55 -05:00
parent a675c5f5b0
commit 4e6099ff5c
184 changed files with 13756 additions and 0 deletions
@@ -0,0 +1,156 @@
using NUnit.Framework;
using System.Collections.Generic;
using LCU.Api.Internal.DataCleanUp.Configuration;
using LCU.Library.Internal.ApiSecurity.Enums;
using LCU.Library.Internal.ApiSecurity.Models;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreRequests;
using LCU.Library.Internal.LcuHttpClient.Utilities;
namespace LCU.Api.Internal.DataCleanUpTest.Utilities;
public class HttpUtilitiesTest
{
private const string ClientKeyValue = "DataCleanUp";
private const string IncludesParameterKey = "includes";
private readonly ApiSecurityConfiguration _apiSecurityConfigurationWithInternalKey = new ApiSecurityConfiguration()
{
ApiKeyAuthenticationFailureBehavior = ApiKeyAuthenticationFailureBehavior.Error,
ExternalApiKeySet = new Dictionary<string, string>(),
InternalApiKeySet = new Dictionary<string, string>()
{
{ ClientKeyValue, "some_guid-1234-5666" }
}
};
private readonly ApiSecurityConfiguration _apiSecurityConfigurationWithoutInternalKey = new ApiSecurityConfiguration()
{
ApiKeyAuthenticationFailureBehavior = ApiKeyAuthenticationFailureBehavior.Error,
ExternalApiKeySet = new Dictionary<string, string>(),
InternalApiKeySet = new Dictionary<string, string>()
};
private readonly CoreApiWrapperConfiguration _coreApiWrapperConfiguration = new CoreApiWrapperConfiguration()
{
CoreApiWrapperUrl = "https://localhost:44364",
AccessChannelPersons = "/api/core/AccessChannelPersons",
AccesschannelPersonWithIncludes = "/api/core/AccessChannelPersons/GetWithIncludes"
};
[SetUp]
public void Setup()
{
}
[Test]
public void HttpUtilities_GetApiKeyHeaders_Success()
{
var result = HttpUtilities.GetApiKeyHeaders(ClientKeyValue,
_apiSecurityConfigurationWithInternalKey.ExtractApiKey(ClientKeyValue, ApiKeySetName.InternalKeySet));
var modelValues = new Dictionary<string, string?>()
{
{"Client", ClientKeyValue },
{"ApiKey", "some_guid-1234-5666" }
};
Assert.IsNotNull(result);
Assert.AreEqual(modelValues, result);
}
[Test]
public void HttpUtilities_BuildEndPointWithModelParams_Success()
{
var request = new AccessChannelPersonsByPersonRequest()
{
PersonNumber = 145,
ActiveOnly = true,
IncludeCards = false
};
var path = $"{_coreApiWrapperConfiguration.CoreApiWrapperUrl}{_coreApiWrapperConfiguration.AccessChannelPersons}";
var result = HttpUtilities.BuildEndPointWithQueryParams(path, request);
Assert.IsNotNull(result);
Assert.AreEqual("https://localhost:44364/api/core/AccessChannelPersons?PersonNumber=145&ActiveOnly=True&IncludeCards=False", result);
}
[Test]
public void HttpUtilities_BuildEndPointWithDictionaryParams_Success()
{
var request = new AccessChannelPersonsByPersonRequest()
{
PersonNumber = 145,
ActiveOnly = true,
IncludeCards = false
};
var testPersonNumbers = new List<string>()
{
"111111"
};
var path = $"{_coreApiWrapperConfiguration.CoreApiWrapperUrl}{_coreApiWrapperConfiguration.AccesschannelPersonWithIncludes}";
var dictionaryOfParameters = HttpUtilities.BuildDictionaryValues(request);
foreach (var includedString in testPersonNumbers)
{
dictionaryOfParameters.Add(IncludesParameterKey, includedString);
}
var result = HttpUtilities.BuildEndPointWithQueryParams(path, dictionaryOfParameters);
Assert.IsNotNull(result);
Assert.AreEqual("https://localhost:44364/api/core/AccessChannelPersons/GetWithIncludes?PersonNumber=145&ActiveOnly=True&IncludeCards=False&includes=111111", result);
}
[Test]
public void HttpUtilities_BuildEndPointWithKeyValuePairModelListPropertyParams_Success()
{
var request = new AccountsByMajorMinorBranchAndStatusRequest()
{
MajorTypes = new List<string>() { "SAV"},
MinorTypes = new List<string>() { "SV01", "BS01"},
AccountStatuses = new List<string>() { "APPR"},
BranchCodes = new List<long>() { 1310 }
};
var testPersonNumbers = new List<string>()
{
"111111"
};
var path = $"{_coreApiWrapperConfiguration.CoreApiWrapperUrl}{_coreApiWrapperConfiguration.GetAccountsByMajorMinorBranchAndStatus}";
var keyValuePairs = HttpUtilities.BuildKeyValuePairs(request);
var result = HttpUtilities.BuildEndPointWithKeyValuePairs(path, keyValuePairs);
Assert.IsNotNull(result);
Assert.AreEqual("https://localhost:44364?MajorTypes=SAV&MinorTypes=SV01&MinorTypes=BS01&AccountStatuses=APPR&BranchCodes=1310", result);
}
[Test]
public void HttpUtilities_BuildEndPointWithKeyValuePairModelPropertyParams_Success()
{
var request = new AccessChannelPersonsByPersonRequest()
{
PersonNumber = 145,
ActiveOnly = true,
IncludeCards = false
};
var path = $"{_coreApiWrapperConfiguration.CoreApiWrapperUrl}{_coreApiWrapperConfiguration.AccessChannelPersons}";
var keyValuePairs = HttpUtilities.BuildKeyValuePairs(request);
var result = HttpUtilities.BuildEndPointWithKeyValuePairs(path, keyValuePairs);
Assert.IsNotNull(result);
Assert.AreEqual("https://localhost:44364/api/core/AccessChannelPersons?PersonNumber=145&ActiveOnly=True&IncludeCards=False", result);
}
}