Skip to content

Commit

Permalink
Abzu/replace dependencies (#169)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
ajasonca and Jason Carter authored Oct 13, 2022
1 parent c5c0188 commit 3d7e026
Show file tree
Hide file tree
Showing 10 changed files with 101 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class AzureADB2CAuthenticationTests
private string EssB2CCustomizedToken { get; set; }
public DataHelper DataHelper { get; set; }
private string FssJwtToken { get; set; }
private readonly List<string> CleanUpBatchIdList = new List<string>();
private readonly string SinceDateTime = DateTime.Now.AddDays(-5).ToString("ddd, dd MMM yyyy HH':'mm':'ss 'GMT'", CultureInfo.InvariantCulture);
private readonly List<string> cleanUpBatchIdList = new List<string>();
private readonly string sinceDateTime = DateTime.Now.AddDays(-5).ToString("ddd, dd MMM yyyy HH':'mm':'ss 'GMT'", CultureInfo.InvariantCulture);

[SetUp]
public async Task SetupAsync()
Expand All @@ -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.");
}
Expand All @@ -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.");
}
Expand All @@ -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.");
}
Expand All @@ -70,15 +70,15 @@ 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
await apiResponse.CheckModelStructureForSuccessResponse();

//Get the BatchId
var batchId = await apiResponse.GetBatchId();
CleanUpBatchIdList.Add(batchId);
cleanUpBatchIdList.Add(batchId);

}
#endregion
Expand All @@ -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.");
}
Expand All @@ -124,7 +124,7 @@ public async Task WhenICallTheProductIdentifiersApiWithAValidB2cToken_ThenACorre

//Get the BatchId
var batchId = await apiResponse.GetBatchId();
CleanUpBatchIdList.Add(batchId);
cleanUpBatchIdList.Add(batchId);
}
#endregion

Expand All @@ -133,11 +133,9 @@ public async Task WhenICallTheProductIdentifiersApiWithAValidB2cToken_ThenACorre
[Category("SmokeTest")]
public async Task WhenICallTheProductVersionApiWithOutB2cToken_ThenAnUnauthorisedResponseIsReturned()
{
List<ProductVersionModel> ProductVersionData = new List<ProductVersionModel>();
List<ProductVersionModel> productVersionData = new List<ProductVersionModel> { 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.");
}
Expand All @@ -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<ProductVersionModel> ProductVersionData = new List<ProductVersionModel>();
const string invalidB2CToken = "THIS-IS-NOT-A-HAPPY-TOKEN";

ProductVersionData.Add(DataHelper.GetProductVersionModelData("DE416080", 9, 6));
List<ProductVersionModel> productVersionData = new List<ProductVersionModel>
{
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.");
}
Expand All @@ -161,11 +160,12 @@ public async Task WhenICallTheProductVersionApiWithInvalidB2cToken_ThenAnUnautho
[Category("SmokeTest")]
public async Task WhenICallTheProductVersionApiWithCustomB2cToken_ThenAnUnauthorisedResponseIsReturned()
{
List<ProductVersionModel> ProductVersionData = new List<ProductVersionModel>();

ProductVersionData.Add(DataHelper.GetProductVersionModelData("DE4NO18Q", 1, 0));
List<ProductVersionModel> productVersionData = new List<ProductVersionModel>
{
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.");
}
Expand All @@ -174,29 +174,30 @@ public async Task WhenICallTheProductVersionApiWithCustomB2cToken_ThenAnUnauthor
[Category("QCOnlyTest")]
public async Task WhenICallTheProductVersionApiWithAValidB2cToken_ThenTheCorrectResponseIsReturned()
{
List<ProductVersionModel> ProductVersionData = new List<ProductVersionModel>();

ProductVersionData.Add(DataHelper.GetProductVersionModelData("DE416080", 9, 1));
List<ProductVersionModel> productVersionData = new List<ProductVersionModel>
{
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
await apiResponse.CheckModelStructureForSuccessResponse();

//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.");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.Storage.Blobs" Version="12.13.0" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.14.0" />
<PackageReference Include="JWT" Version="7.3.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
<PackageReference Include="Microsoft.Azure.Cosmos.Table" Version="1.0.8" />
<PackageReference Include="Microsoft.Azure.EventGrid" Version="3.2.1" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="5.0.0" />
<PackageReference Include="Microsoft.Identity.Client" Version="4.22.0" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.43.0.51858">
<PrivateAssets>all</PrivateAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="FakeItEasy" Version="7.3.1" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.20.0" />
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.43.0.51858">
<PrivateAssets>all</PrivateAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,35 @@

<ItemGroup>
<PackageReference Include="Azure.Extensions.AspNetCore.Configuration.Secrets" Version="1.2.2" />
<PackageReference Include="Azure.Identity" Version="1.7.0" />
<PackageReference Include="Azure.Security.KeyVault.Secrets" Version="4.4.0" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.1.1" />
<PackageReference Include="FluentValidation" Version="11.1.0" />
<PackageReference Include="FluentValidation" Version="11.2.2" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.18" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.20.0" />
<PackageReference Include="Microsoft.AspNetCore.HeaderPropagation" Version="3.1.15" />
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.2.7" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
<PackageReference Include="Microsoft.AspNetCore.Http.Features" Version="5.0.10" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.14" />
<PackageReference Include="Microsoft.Azure.EventGrid" Version="3.2.1" />
<PackageReference Include="Microsoft.Azure.Services.AppAuthentication" Version="1.6.1" />
<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="5.0.6" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="runtime.native.System.Net.Security" Version="4.3.1" />
<PackageReference Include="Serilog.Extensions.Logging.File" Version="2.0.0" />
<PackageReference Include="Serilog.Extensions.Logging.File" Version="3.0.0" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.43.0.51858">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="5.6.3" />
<PackageReference Include="Swashbuckle.AspNetCore.Filters" Version="6.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="5.6.3" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="5.6.3" />
<PackageReference Include="System.Net.Security" Version="4.3.2" />
<PackageReference Include="System.Net.WebSockets.Client" Version="4.3.2" />
<PackageReference Include="System.Text.Encodings.Web" Version="6.0.0" />
<PackageReference Include="UKHO.Logging.EventHubLogProvider" Version="1.22047.3" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,20 @@

<ItemGroup>
<PackageReference Include="Azure.Extensions.AspNetCore.Configuration.Secrets" Version="1.2.2" />
<PackageReference Include="Azure.Identity" Version="1.7.0" />
<PackageReference Include="Azure.Security.KeyVault.Secrets" Version="4.4.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.9" />
<PackageReference Include="Microsoft.Extensions.Logging.ApplicationInsights" Version="2.20.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="5.0.0" />
<PackageReference Include="runtime.native.System.Net.Security" Version="4.3.1" />
<PackageReference Include="Serilog" Version="2.10.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="3.0.1" />
<PackageReference Include="Serilog.Sinks.File" Version="4.1.0" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="System.Net.Security" Version="4.3.2" />
<PackageReference Include="System.Net.WebSockets.Client" Version="4.3.2" />
<PackageReference Include="System.Text.Encodings.Web" Version="6.0.0" />
<PackageReference Include="UKHO.Logging.EventHubLogProvider" Version="1.22047.3" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="FakeItEasy" Version="7.3.1" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="runtime.native.System.Net.Security" Version="4.3.1" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.43.0.51858">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,20 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.Identity" Version="1.6.0" />
<PackageReference Include="Azure.Storage.Queues" Version="12.11.0" />
<PackageReference Include="Azure.Identity" Version="1.7.0" />
<PackageReference Include="Azure.Security.KeyVault.Secrets" Version="4.4.0" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.14.0" />
<PackageReference Include="Azure.Storage.Queues" Version="12.12.0" />
<PackageReference Include="CsvHelper" Version="28.0.1" />
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.20.0" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.20.0" />
<PackageReference Include="Microsoft.Azure.Cosmos.Table" Version="1.0.8" />
<PackageReference Include="Microsoft.Azure.EventGrid" Version="3.2.1" />
<PackageReference Include="Microsoft.Azure.EventHubs" Version="4.3.2" />
<PackageReference Include="Microsoft.Azure.Management.ResourceManager.Fluent" Version="1.37.1" />
<PackageReference Include="Microsoft.Extensions.Logging.ApplicationInsights" Version="2.20.0" />
<PackageReference Include="Microsoft.IdentityModel.Logging" Version="6.12.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="5.0.1" />
<PackageReference Include="runtime.native.System.Net.Security" Version="4.3.1" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.43.0.51858">
Expand Down
Loading

0 comments on commit 3d7e026

Please sign in to comment.