From 3d7e02685dfa5a418fbfd476d271fd42a36166a6 Mon Sep 17 00:00:00 2001 From: Jason <105857749+ajasonca@users.noreply.github.com> Date: Thu, 13 Oct 2022 14:04:17 +0100 Subject: [PATCH] Abzu/replace dependencies (#169) * Rolled back removal of 'unused' dependencies as function used not reliable * Some package updates * Package updates to resolve security dependencies * invalid token is now always invalid - and some code cleanup Co-authored-by: Jason Carter --- .../AzureADB2CAuthenticationTests.cs | 63 ++++++++++--------- ...hangeSetService.API.FunctionalTests.csproj | 6 +- ...HO.ExchangeSetService.API.UnitTests.csproj | 5 +- .../UKHO.ExchangeSetService.API.csproj | 18 +++++- .../UKHO.ExchangeSetService.CleanUpJob.csproj | 10 ++- ...ExchangeSetService.Common.UnitTests.csproj | 3 +- .../UKHO.ExchangeSetService.Common.csproj | 12 +++- ...xchangeSetService.FulfilmentService.csproj | 23 ++++++- ...Service.Webjob.CleanUpJob.UnitTests.csproj | 3 +- ...ExchangeSetService.Webjob.UnitTests.csproj | 3 +- 10 files changed, 101 insertions(+), 45 deletions(-) diff --git a/UKHO.ExchangeSetService.API/UKHO.ExchangeSetService.API.FunctionalTests/FunctionalTests/AzureADB2CAuthenticationTests.cs b/UKHO.ExchangeSetService.API/UKHO.ExchangeSetService.API.FunctionalTests/FunctionalTests/AzureADB2CAuthenticationTests.cs index 2a1ee6649..e30b41097 100644 --- a/UKHO.ExchangeSetService.API/UKHO.ExchangeSetService.API.FunctionalTests/FunctionalTests/AzureADB2CAuthenticationTests.cs +++ b/UKHO.ExchangeSetService.API/UKHO.ExchangeSetService.API.FunctionalTests/FunctionalTests/AzureADB2CAuthenticationTests.cs @@ -17,8 +17,8 @@ class AzureADB2CAuthenticationTests private string EssB2CCustomizedToken { get; set; } public DataHelper DataHelper { get; set; } private string FssJwtToken { get; set; } - private readonly List CleanUpBatchIdList = new List(); - private readonly string SinceDateTime = DateTime.Now.AddDays(-5).ToString("ddd, dd MMM yyyy HH':'mm':'ss 'GMT'", CultureInfo.InvariantCulture); + private readonly List cleanUpBatchIdList = new List(); + private readonly string sinceDateTime = DateTime.Now.AddDays(-5).ToString("ddd, dd MMM yyyy HH':'mm':'ss 'GMT'", CultureInfo.InvariantCulture); [SetUp] public async Task SetupAsync() @@ -40,7 +40,7 @@ public async Task SetupAsync() public async Task WhenICallTheDateTimeApiWithOutAzureB2cToken_ThenAnUnauthorisedResponseIsReturned() { - var apiResponse = await ExchangeSetApiClient.GetExchangeSetBasedOnDateTimeAsync(SinceDateTime); + var apiResponse = await ExchangeSetApiClient.GetExchangeSetBasedOnDateTimeAsync(sinceDateTime); Assert.AreEqual(401, (int)apiResponse.StatusCode, $"Incorrect status code {apiResponse.StatusCode} is returned, instead of the expected 401."); } @@ -50,8 +50,8 @@ public async Task WhenICallTheDateTimeApiWithOutAzureB2cToken_ThenAnUnauthorised [Category("SmokeTest")] public async Task WhenICallTheDateTimeApiWithInvalidB2cToken_ThenAnUnauthorisedResponseIsReturned() { - string invalidB2cToken = EssB2CToken.Remove(EssB2CToken.Length - 2).Insert(EssB2CToken.Length - 2, "AA"); - var apiResponse = await ExchangeSetApiClient.GetExchangeSetBasedOnDateTimeAsync(SinceDateTime, accessToken: invalidB2cToken); + const string invalidB2CToken = "THIS-IS-NOT-A-HAPPY-TOKEN"; + var apiResponse = await ExchangeSetApiClient.GetExchangeSetBasedOnDateTimeAsync(sinceDateTime, accessToken: invalidB2CToken); Assert.AreEqual(401, (int)apiResponse.StatusCode, $"Incorrect status code {apiResponse.StatusCode} is returned, instead of the expected 401."); } @@ -61,7 +61,7 @@ public async Task WhenICallTheDateTimeApiWithInvalidB2cToken_ThenAnUnauthorisedR public async Task WhenICallTheDateTimeApiWithCustomB2cToken_ThenAnUnauthorisedResponseIsReturned() { - var apiResponse = await ExchangeSetApiClient.GetExchangeSetBasedOnDateTimeAsync(SinceDateTime, accessToken: EssB2CCustomizedToken); + var apiResponse = await ExchangeSetApiClient.GetExchangeSetBasedOnDateTimeAsync(sinceDateTime, accessToken: EssB2CCustomizedToken); Assert.AreEqual(401, (int)apiResponse.StatusCode, $"Incorrect status code {apiResponse.StatusCode} is returned, instead of the expected 401."); } @@ -70,7 +70,7 @@ public async Task WhenICallTheDateTimeApiWithCustomB2cToken_ThenAnUnauthorisedRe [Category("QCOnlyTest")] public async Task WhenICallTheDateTimeApiWithAValidB2cToken_ThenACorrectResponseIsReturned() { - var apiResponse = await ExchangeSetApiClient.GetExchangeSetBasedOnDateTimeAsync(SinceDateTime, accessToken: EssB2CToken); + var apiResponse = await ExchangeSetApiClient.GetExchangeSetBasedOnDateTimeAsync(sinceDateTime, accessToken: EssB2CToken); Assert.AreEqual(200, (int)apiResponse.StatusCode, $"Incorrect status code is returned {apiResponse.StatusCode}, instead of the expected 200."); //verify model structure @@ -78,7 +78,7 @@ public async Task WhenICallTheDateTimeApiWithAValidB2cToken_ThenACorrectResponse //Get the BatchId var batchId = await apiResponse.GetBatchId(); - CleanUpBatchIdList.Add(batchId); + cleanUpBatchIdList.Add(batchId); } #endregion @@ -97,8 +97,8 @@ public async Task WhenICallTheProductIdentifierApiWithOutAzureB2cToken_ThenAnUna [Category("SmokeTest")] public async Task WhenICallTheProductIdentifierApiWithInvalidB2cToken_ThenAnUnauthorisedResponseIsReturned() { - string invalidB2cToken = EssB2CToken.Remove(EssB2CToken.Length - 2).Insert(EssB2CToken.Length - 2, "AA"); - var apiResponse = await ExchangeSetApiClient.GetProductIdentifiersDataAsync(DataHelper.GetProductIdentifierData(), accessToken: invalidB2cToken); + const string invalidB2CToken = "THIS-IS-NOT-A-HAPPY-TOKEN"; + var apiResponse = await ExchangeSetApiClient.GetProductIdentifiersDataAsync(DataHelper.GetProductIdentifierData(), accessToken: invalidB2CToken); Assert.AreEqual(401, (int)apiResponse.StatusCode, $"Incorrect status code {apiResponse.StatusCode} is returned, instead of the expected 401."); } @@ -124,7 +124,7 @@ public async Task WhenICallTheProductIdentifiersApiWithAValidB2cToken_ThenACorre //Get the BatchId var batchId = await apiResponse.GetBatchId(); - CleanUpBatchIdList.Add(batchId); + cleanUpBatchIdList.Add(batchId); } #endregion @@ -133,11 +133,9 @@ public async Task WhenICallTheProductIdentifiersApiWithAValidB2cToken_ThenACorre [Category("SmokeTest")] public async Task WhenICallTheProductVersionApiWithOutB2cToken_ThenAnUnauthorisedResponseIsReturned() { - List ProductVersionData = new List(); + List productVersionData = new List { DataHelper.GetProductVersionModelData("DE416080", 9, 6) }; - ProductVersionData.Add(DataHelper.GetProductVersionModelData("DE416080", 9, 6)); - - var apiResponse = await ExchangeSetApiClient.GetProductVersionsAsync(ProductVersionData); + var apiResponse = await ExchangeSetApiClient.GetProductVersionsAsync(productVersionData); Assert.AreEqual(401, (int)apiResponse.StatusCode, $"Incorrect status code {apiResponse.StatusCode} is returned, instead of the expected 401."); } @@ -146,13 +144,14 @@ public async Task WhenICallTheProductVersionApiWithOutB2cToken_ThenAnUnauthorise [Category("SmokeTest")] public async Task WhenICallTheProductVersionApiWithInvalidB2cToken_ThenAnUnauthorisedResponseIsReturned() { - string invalidB2cToken = EssB2CToken.Remove(EssB2CToken.Length - 2).Insert(EssB2CToken.Length - 2, "AA"); - - List ProductVersionData = new List(); + const string invalidB2CToken = "THIS-IS-NOT-A-HAPPY-TOKEN"; - ProductVersionData.Add(DataHelper.GetProductVersionModelData("DE416080", 9, 6)); + List productVersionData = new List + { + DataHelper.GetProductVersionModelData("DE416080", 9, 6) + }; - var apiResponse = await ExchangeSetApiClient.GetProductVersionsAsync(ProductVersionData, accessToken: invalidB2cToken); + var apiResponse = await ExchangeSetApiClient.GetProductVersionsAsync(productVersionData, accessToken: invalidB2CToken); Assert.AreEqual(401, (int)apiResponse.StatusCode, $"Incorrect status code {apiResponse.StatusCode} is returned, instead of the expected 401."); } @@ -161,11 +160,12 @@ public async Task WhenICallTheProductVersionApiWithInvalidB2cToken_ThenAnUnautho [Category("SmokeTest")] public async Task WhenICallTheProductVersionApiWithCustomB2cToken_ThenAnUnauthorisedResponseIsReturned() { - List ProductVersionData = new List(); - - ProductVersionData.Add(DataHelper.GetProductVersionModelData("DE4NO18Q", 1, 0)); + List productVersionData = new List + { + DataHelper.GetProductVersionModelData("DE4NO18Q", 1, 0) + }; - var apiResponse = await ExchangeSetApiClient.GetProductVersionsAsync(ProductVersionData, accessToken: EssB2CCustomizedToken); + var apiResponse = await ExchangeSetApiClient.GetProductVersionsAsync(productVersionData, accessToken: EssB2CCustomizedToken); Assert.AreEqual(401, (int)apiResponse.StatusCode, $"Incorrect status code {apiResponse.StatusCode} is returned, instead of the expected 401."); } @@ -174,11 +174,12 @@ public async Task WhenICallTheProductVersionApiWithCustomB2cToken_ThenAnUnauthor [Category("QCOnlyTest")] public async Task WhenICallTheProductVersionApiWithAValidB2cToken_ThenTheCorrectResponseIsReturned() { - List ProductVersionData = new List(); - - ProductVersionData.Add(DataHelper.GetProductVersionModelData("DE416080", 9, 1)); + List productVersionData = new List + { + DataHelper.GetProductVersionModelData("DE416080", 9, 1) + }; - var apiResponse = await ExchangeSetApiClient.GetProductVersionsAsync(ProductVersionData, accessToken: EssB2CToken); + var apiResponse = await ExchangeSetApiClient.GetProductVersionsAsync(productVersionData, accessToken: EssB2CToken); Assert.AreEqual(200, (int)apiResponse.StatusCode, $"Incorrect status code {apiResponse.StatusCode} is returned, instead of the expected 200."); //verify model structure @@ -186,17 +187,17 @@ public async Task WhenICallTheProductVersionApiWithAValidB2cToken_ThenTheCorrect //Get the BatchId var batchId = await apiResponse.GetBatchId(); - CleanUpBatchIdList.Add(batchId); + cleanUpBatchIdList.Add(batchId); } #endregion [OneTimeTearDown] public async Task GlobalTeardown() { - if (CleanUpBatchIdList != null && CleanUpBatchIdList.Count > 0) + if (cleanUpBatchIdList != null && cleanUpBatchIdList.Count > 0) { //Clean up batches from local foldar - var apiResponse = await FssApiClient.CleanUpBatchesAsync(Config.FssConfig.BaseUrl, CleanUpBatchIdList, FssJwtToken); + var apiResponse = await FssApiClient.CleanUpBatchesAsync(Config.FssConfig.BaseUrl, cleanUpBatchIdList, FssJwtToken); Assert.AreEqual(200, (int)apiResponse.StatusCode, $"Incorrect status code {apiResponse.StatusCode} is returned for clean up batches, instead of the expected 200."); } } diff --git a/UKHO.ExchangeSetService.API/UKHO.ExchangeSetService.API.FunctionalTests/UKHO.ExchangeSetService.API.FunctionalTests.csproj b/UKHO.ExchangeSetService.API/UKHO.ExchangeSetService.API.FunctionalTests/UKHO.ExchangeSetService.API.FunctionalTests.csproj index b496a1fea..92592ca03 100644 --- a/UKHO.ExchangeSetService.API/UKHO.ExchangeSetService.API.FunctionalTests/UKHO.ExchangeSetService.API.FunctionalTests.csproj +++ b/UKHO.ExchangeSetService.API/UKHO.ExchangeSetService.API.FunctionalTests/UKHO.ExchangeSetService.API.FunctionalTests.csproj @@ -11,15 +11,17 @@ - + + - + + all diff --git a/UKHO.ExchangeSetService.API/UKHO.ExchangeSetService.API.UnitTests/UKHO.ExchangeSetService.API.UnitTests.csproj b/UKHO.ExchangeSetService.API/UKHO.ExchangeSetService.API.UnitTests/UKHO.ExchangeSetService.API.UnitTests.csproj index 3533684b6..cffd7aaea 100644 --- a/UKHO.ExchangeSetService.API/UKHO.ExchangeSetService.API.UnitTests/UKHO.ExchangeSetService.API.UnitTests.csproj +++ b/UKHO.ExchangeSetService.API/UKHO.ExchangeSetService.API.UnitTests/UKHO.ExchangeSetService.API.UnitTests.csproj @@ -16,7 +16,10 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + + + + all diff --git a/UKHO.ExchangeSetService.API/UKHO.ExchangeSetService.API/UKHO.ExchangeSetService.API.csproj b/UKHO.ExchangeSetService.API/UKHO.ExchangeSetService.API/UKHO.ExchangeSetService.API.csproj index 540cfa3c4..3bdaff1bc 100644 --- a/UKHO.ExchangeSetService.API/UKHO.ExchangeSetService.API/UKHO.ExchangeSetService.API.csproj +++ b/UKHO.ExchangeSetService.API/UKHO.ExchangeSetService.API/UKHO.ExchangeSetService.API.csproj @@ -11,21 +11,35 @@ + + - + + + + + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + diff --git a/UKHO.ExchangeSetService.API/UKHO.ExchangeSetService.CleanUpJob/UKHO.ExchangeSetService.CleanUpJob.csproj b/UKHO.ExchangeSetService.API/UKHO.ExchangeSetService.CleanUpJob/UKHO.ExchangeSetService.CleanUpJob.csproj index e5951ad98..a5d445bd5 100644 --- a/UKHO.ExchangeSetService.API/UKHO.ExchangeSetService.CleanUpJob/UKHO.ExchangeSetService.CleanUpJob.csproj +++ b/UKHO.ExchangeSetService.API/UKHO.ExchangeSetService.CleanUpJob/UKHO.ExchangeSetService.CleanUpJob.csproj @@ -21,12 +21,20 @@ + + + + - + + + + + diff --git a/UKHO.ExchangeSetService.API/UKHO.ExchangeSetService.Common.UnitTests/UKHO.ExchangeSetService.Common.UnitTests.csproj b/UKHO.ExchangeSetService.API/UKHO.ExchangeSetService.Common.UnitTests/UKHO.ExchangeSetService.Common.UnitTests.csproj index 2ff6aa05f..2c41de473 100644 --- a/UKHO.ExchangeSetService.API/UKHO.ExchangeSetService.Common.UnitTests/UKHO.ExchangeSetService.Common.UnitTests.csproj +++ b/UKHO.ExchangeSetService.API/UKHO.ExchangeSetService.Common.UnitTests/UKHO.ExchangeSetService.Common.UnitTests.csproj @@ -14,7 +14,8 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + + diff --git a/UKHO.ExchangeSetService.API/UKHO.ExchangeSetService.Common/UKHO.ExchangeSetService.Common.csproj b/UKHO.ExchangeSetService.API/UKHO.ExchangeSetService.Common/UKHO.ExchangeSetService.Common.csproj index db965c4a5..836dbaa2b 100644 --- a/UKHO.ExchangeSetService.API/UKHO.ExchangeSetService.Common/UKHO.ExchangeSetService.Common.csproj +++ b/UKHO.ExchangeSetService.API/UKHO.ExchangeSetService.Common/UKHO.ExchangeSetService.Common.csproj @@ -11,12 +11,20 @@ - - + + + + + + + + + + diff --git a/UKHO.ExchangeSetService.API/UKHO.ExchangeSetService.FulfilmentService/UKHO.ExchangeSetService.FulfilmentService.csproj b/UKHO.ExchangeSetService.API/UKHO.ExchangeSetService.FulfilmentService/UKHO.ExchangeSetService.FulfilmentService.csproj index 1cb048641..2960e8c10 100644 --- a/UKHO.ExchangeSetService.API/UKHO.ExchangeSetService.FulfilmentService/UKHO.ExchangeSetService.FulfilmentService.csproj +++ b/UKHO.ExchangeSetService.API/UKHO.ExchangeSetService.FulfilmentService/UKHO.ExchangeSetService.FulfilmentService.csproj @@ -22,18 +22,35 @@ - - + + + + + + + + + + + + + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + diff --git a/UKHO.ExchangeSetService.API/UKHO.ExchangeSetService.Webjob.CleanUpJob.UnitTests/UKHO.ExchangeSetService.Webjob.CleanUpJob.UnitTests.csproj b/UKHO.ExchangeSetService.API/UKHO.ExchangeSetService.Webjob.CleanUpJob.UnitTests/UKHO.ExchangeSetService.Webjob.CleanUpJob.UnitTests.csproj index 34e046b41..616c66bb0 100644 --- a/UKHO.ExchangeSetService.API/UKHO.ExchangeSetService.Webjob.CleanUpJob.UnitTests/UKHO.ExchangeSetService.Webjob.CleanUpJob.UnitTests.csproj +++ b/UKHO.ExchangeSetService.API/UKHO.ExchangeSetService.Webjob.CleanUpJob.UnitTests/UKHO.ExchangeSetService.Webjob.CleanUpJob.UnitTests.csproj @@ -14,7 +14,8 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + + all diff --git a/UKHO.ExchangeSetService.API/UKHO.ExchangeSetService.Webjob.UnitTests/UKHO.ExchangeSetService.Webjob.UnitTests.csproj b/UKHO.ExchangeSetService.API/UKHO.ExchangeSetService.Webjob.UnitTests/UKHO.ExchangeSetService.Webjob.UnitTests.csproj index efc183566..23e8de19f 100644 --- a/UKHO.ExchangeSetService.API/UKHO.ExchangeSetService.Webjob.UnitTests/UKHO.ExchangeSetService.Webjob.UnitTests.csproj +++ b/UKHO.ExchangeSetService.API/UKHO.ExchangeSetService.Webjob.UnitTests/UKHO.ExchangeSetService.Webjob.UnitTests.csproj @@ -14,7 +14,8 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + + all