Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

194580 - productversions integration with scs stub #418

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
8182600
194580 - initial code changes to call scs productVersions endpoint AB…
chaital14503 Dec 31, 2024
2ddb834
194580 - Merged common changes AB#194580 AB#196244
chaital14503 Dec 31, 2024
6776695
194580 - Merged common changes AB#194580 AB#196244
chaital14503 Jan 2, 2025
18f7533
194580 - Merged common changes AB#194580 AB#196244
chaital14503 Jan 2, 2025
a08ea75
194580 - Merged common changes AB#194580 AB#196244
chaital14503 Jan 2, 2025
87f861d
194580 - minor code changes AB#194580 AB#196244
chaital14503 Jan 2, 2025
3b26fde
Merge branch 'dev/s100-scs-api-integration' into dev/194580-productve…
chaital14503 Jan 2, 2025
e3a147a
194580 - Updated ES and SCS response for 304 NotModified AB#194580 AB…
chaital14503 Jan 2, 2025
929cea6
194580 - minor code changes AB#194580 AB#196244
chaital14503 Jan 2, 2025
42536bc
Merge branch 'develop-s100' into dev/194580-productversions-integrati…
chaital14503 Jan 7, 2025
eb7df99
194580 - common changes AB#194580 AB#196244
chaital14503 Jan 7, 2025
323ff06
194580 - minor changes AB#194580 AB#196244
chaital14503 Jan 7, 2025
d85a2ef
Merge branch 'dev/s100-scs-api-integration' into dev/194580-productve…
chaital14503 Jan 7, 2025
dd227f8
Merge branch 'develop-s100' into dev/194580-productversions-integrati…
chaital14503 Jan 7, 2025
5b9b99e
194580 - Added UTs AB#194580 AB#196245
chaital14503 Jan 7, 2025
06c7d68
Merge branch 'develop-s100' into dev/194580-productversions-integrati…
chaital14503 Jan 8, 2025
9e4c2fd
194580 - test case renamed AB#194580 AB#196245 UT
chaital14503 Jan 8, 2025
d078a1d
Merge branch 'dev/s100-scs-api-integration' into dev/194580-productve…
chaital14503 Jan 8, 2025
593f112
Merge branch 'dev/195922-Create_stubs_for_S100-SCS-API_productVersion…
chaital14503 Jan 8, 2025
26358eb
194580 - Resolved review comments AB#194580 AB#196244
chaital14503 Jan 9, 2025
c5aea92
194580 - added Functional Tests and mock data - AB#194580 AB#196210
Jan 9, 2025
55619ed
code refactored
MastekRohitChettri Jan 9, 2025
18b4b89
194580 - added FT AB#194580 AB#196210
Jan 9, 2025
b88d554
194580 - Merged common changes AB#194580 AB#196244
chaital14503 Jan 10, 2025
0d90bfd
194580 modify responses AB#194580
shirinbt14926 Jan 10, 2025
7970646
194580 - Updated UTs and code for 400BadRequest AB#194580 AB#196244
chaital14503 Jan 10, 2025
c0d883d
194580 - added cancellationToken AB#194580 AB#196244
chaital14503 Jan 10, 2025
aae081c
194580 - BadRequest error format updated AB#194580 AB#196244
chaital14503 Jan 10, 2025
99d3246
194580 - review comments fixed AB#194580 AB#196244
chaital14503 Jan 10, 2025
07f26e3
194580 - minor code changesAB#194580 AB#196244
chaital14503 Jan 10, 2025
50a7296
194580 - Updated Functional Tests AB#194580 AB#197855
Jan 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace UKHO.ExchangeSetService.API.FunctionalTests.FunctionalTests.S_100
{
public class S100EssEndPointsAuthorizationScenarios : ObjectStorage
public class S100EssEndPointsScenarios : ObjectStorage
{
private string sinceDateTime;
private UpdatesSinceModel sinceDateTimePayload;
Expand All @@ -21,10 +21,8 @@ public void OneTimeSetUp()
sinceDateTimePayload = DataHelper.GetSinceDateTime(sinceDateTime);
ProductVersionData =
[
DataHelper.GetProductVersionModelData("101GB40079ABCDEFG", 7, 10),
DataHelper.GetProductVersionModelData("102NO32904820801012", 36, 0),
DataHelper.GetProductVersionModelData("104US00_CHES_TYPE1_20210630_0600", 7, 10),
DataHelper.GetProductVersionModelData("111US00_ches_dcf8_20190703T00Z", 36, 0)
DataHelper.GetProductVersionModelData("102NO32904820801012",7, 1),
DataHelper.GetProductVersionModelData("104US00_CHES_TYPE1_20210630_0600", 1, 0),
];
productNames = DataHelper.GetProductNamesForS100();
}
Expand Down Expand Up @@ -56,7 +54,7 @@ public async Task WhenICallS100ProductNamesEndPointWithValidTokenAndOneOfTheInva
var apiResponse = await ExchangeSetApiClient.GetProductIdentifiersDataAsync(productNames, null, EssJwtToken, "s100");
Assert.That((int)apiResponse.StatusCode, Is.EqualTo(202), $"Incorrect status code is returned {apiResponse.StatusCode}, instead of the expected 202.");
var expectedRequestedProductsNotInExchangeSet = new Dictionary<string, string> { { "102NO32904820801012", "invalidProduct" } };
await apiResponse.VerifyEssS100ApiResponseBodyDetails(4, 4, 0, expectedRequestedProductsNotInExchangeSet);
await apiResponse.VerifyEssS100ApiResponseBodyDetails(4, 3, 0, expectedRequestedProductsNotInExchangeSet);
}

//PBI 194403: Azure AD Authorization
Expand All @@ -76,11 +74,11 @@ public async Task WhenICallS100ProductNamesEndPointWithValidTokenAndDuplicatePro
//PBI 194579: Integrate S-100 ESS API Endpoint /productNames with corresponding SCS Stub
[Test]
[Category("QCOnlyTest-AIOEnabled")]
public async Task WhenICallS100ProductNamesEndPointWithValidTokenAndNonExistingProduct_ThenResponseCodeReturnedIs500InternalServerError()
public async Task WhenICallS100ProductNamesEndPointWithValidTokenAndNonExistingProduct_ThenResponseCodeReturnedIs400BadRequest()
{
var nonExistingProduct = new List<string>() { "103GB40079ABCDEFG" };
var apiResponse = await ExchangeSetApiClient.GetProductIdentifiersDataAsync(nonExistingProduct, null, EssJwtToken, "s100");
Assert.That((int)apiResponse.StatusCode, Is.EqualTo(500), $"Incorrect status code is returned {apiResponse.StatusCode}, instead of the expected 500.");
Assert.That((int)apiResponse.StatusCode, Is.EqualTo(400), $"Incorrect status code is returned {apiResponse.StatusCode}, instead of the expected 500.");
}

//PBI 194403: Azure AD Authorization
Expand All @@ -93,18 +91,55 @@ public async Task WhenICallS100ProductNamesEndPointWithInvalidToken_ThenResponse
}

//PBI 194403: Azure AD Authorization
//PBI 194580: Integrate S-100 ESS API Endpoint /productVersions with corresponding SCS Stub
[Test]
[Category("QCOnlyTest-AIOEnabled")]
public async Task WhenICallS100ProductVersionsEndPointWithValidToken_ThenResponseCodeReturnedIs202Accepted()
public async Task WhenICallS100ProductVersionsEndPointWithValidTokenAndOneOfTheInvalidProduct_ThenResponseCodeReturnedIs202Accepted()
{
var apiResponse = await ExchangeSetApiClient.GetProductVersionsAsync(ProductVersionData, null, EssJwtToken, "s100");
Assert.That((int)apiResponse.StatusCode, Is.EqualTo(202), $"Incorrect status code is returned {apiResponse.StatusCode}, instead of the expected 202.");
var expectedRequestedProductsNotInExchangeSet = new Dictionary<string, string> { { "104US00_CHES_TYPE1_20210630_0600", "invalidProduct" } };
await apiResponse.VerifyEssS100ApiResponseBodyDetails(2, 1, 0, expectedRequestedProductsNotInExchangeSet);
}

//PBI 194403: Azure AD Authorization
//PBI 194580: Integrate S-100 ESS API Endpoint /productVersions with corresponding SCS Stub
[Test]
[Category("QCOnlyTest-AIOEnabled")]
public async Task WhenICallS100ProductVersionsEndPointWithValidTokenAndNonExistingProduct_ThenResponseCodeReturnedIs400BadRequest()
{
List<ProductVersionModel> nonExistingProductVersionData = [ DataHelper.GetProductVersionModelData("103GB40079ABCDEFG", 10, 0) ];
var apiResponse = await ExchangeSetApiClient.GetProductVersionsAsync(nonExistingProductVersionData, null, EssJwtToken, "s100");
Assert.That((int)apiResponse.StatusCode, Is.EqualTo(400), $"Incorrect status code is returned {apiResponse.StatusCode}, instead of the expected 500.");
}

//PBI 194403: Azure AD Authorization
//PBI 194580: Integrate S-100 ESS API Endpoint /productVersions with corresponding SCS Stub
[Test]
[Category("QCOnlyTest-AIOEnabled")]
public async Task WhenICallS100ProductVersionsEndPointWithValidTokenAndProductWithNoUpdates_ThenResponseCodeReturnedIs202Accepted()
{
List<ProductVersionModel> nonModifiedProductVersionData = [DataHelper.GetProductVersionModelData("101GB40079ABCDEFG", 4, 1)];
var apiResponse = await ExchangeSetApiClient.GetProductVersionsAsync(nonModifiedProductVersionData, null, EssJwtToken, "s100");
Assert.That((int)apiResponse.StatusCode, Is.EqualTo(202), $"Incorrect status code is returned {apiResponse.StatusCode}, instead of the expected 202.");
await apiResponse.VerifyEssS100ApiResponseBodyDetails(1, 0, 1);
}

//PBI 194403: Azure AD Authorization
//PBI 194580: Integrate S-100 ESS API Endpoint /productVersions with corresponding SCS Stub
[Test]
[Category("QCOnlyTest-AIOEnabled")]
public async Task WhenICallS100ProductVersionsEndPointWithValidTokenAndProductHavingInvalidEdition_ThenResponseCodeReturnedIs400BadRequest()
{
List<ProductVersionModel> invalidEditionProductVersionData = [DataHelper.GetProductVersionModelData("102NO32904820801012", -2, 0)];
var apiResponse = await ExchangeSetApiClient.GetProductVersionsAsync(invalidEditionProductVersionData, null, EssJwtToken, "s100");
Assert.That((int)apiResponse.StatusCode, Is.EqualTo(400), $"Incorrect status code is returned {apiResponse.StatusCode}, instead of the expected 400.");
}

//PBI 194403: Azure AD Authorization
[Test]
[Category("QCOnlyTest-AIOEnabled")]
public async Task WhenICallS100ProductVersionsEndPointWithInvalidToken_ThenResponseCodeReturnedIs401unauthorized()
public async Task WhenICallS100ProductVersionsEndPointWithInvalidToken_ThenResponseCodeReturnedIs401Unauthorized()
{
var apiResponse = await ExchangeSetApiClient.GetProductVersionsAsync(ProductVersionData, null, "InvalidEssJwtToken", "s100");
Assert.That((int)apiResponse.StatusCode, Is.EqualTo(401), $"Incorrect status code is returned {apiResponse.StatusCode}, instead of the expected 401.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Net.Http;
using System.Threading.Tasks;
using UKHO.ExchangeSetService.API.FunctionalTests.Models;
using static UKHO.ExchangeSetService.API.FunctionalTests.Models.EssS100ResponseModel;

namespace UKHO.ExchangeSetService.API.FunctionalTests.Helper
{
Expand Down Expand Up @@ -204,7 +205,6 @@ public static async Task CheckModelStructureForAioSuccessResponse(this HttpRespo
/// <param name="exchangeSetProductCount"></param>
/// <param name="requestedProductsAlreadyUpToDateCount"></param>
/// <param name="requestedProductsNotInExchangeSet"></param>
/// <returns></returns>
public static async Task VerifyEssS100ApiResponseBodyDetails(this HttpResponseMessage apiResponse, int requestedProductCount, int exchangeSetProductCount, int requestedProductsAlreadyUpToDateCount, Dictionary<string, string> requestedProductsNotInExchangeSet = null)
{
var responseBody = JsonConvert.DeserializeObject<ExchangeSetBatch>(await apiResponse.Content.ReadAsStringAsync());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,30 @@

namespace UKHO.ExchangeSetService.API.FunctionalTests.Models
{
public class ExchangeSetLinks
public class EssS100ResponseModel
{
public Uri ExchangeSetBatchStatusUri { get; set; }
public Uri ExchangeSetBatchDetailsUri { get; set; }
public Uri ExchangeSetFileUri { get; set; }
}
public class ExchangeSetLinks
{
public Uri ExchangeSetBatchStatusUri { get; set; }
public Uri ExchangeSetBatchDetailsUri { get; set; }
public Uri ExchangeSetFileUri { get; set; }
}

public class RequestedProductNotInExchangeSet
{
public string ProductName { get; set; }
public string Reason { get; set; }
}
public class RequestedProductNotInExchangeSet
{
public string ProductName { get; set; }
public string Reason { get; set; }
}

public class ExchangeSetBatch
{
public ExchangeSetLinks Links { get; set; }
public DateTime? ExchangeSetUrlExpiryDateTime { get; set; }
public int RequestedProductCount { get; set; }
public int ExchangeSetProductCount { get; set; }
public int RequestedProductsAlreadyUpToDateCount { get; set; }
public List<RequestedProductNotInExchangeSet> RequestedProductsNotInExchangeSet { get; set; }
public string FssBatchId { get; set; }
public class ExchangeSetBatch
{
public ExchangeSetLinks Links { get; set; }
public DateTime? ExchangeSetUrlExpiryDateTime { get; set; }
public int RequestedProductCount { get; set; }
public int ExchangeSetProductCount { get; set; }
public int RequestedProductsAlreadyUpToDateCount { get; set; }
public List<RequestedProductNotInExchangeSet> RequestedProductsNotInExchangeSet { get; set; }
public string FssBatchId { get; set; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public async Task WhenValidProductVersionsIsPassed_ThenPostProductVersionsReturn
new () { ProductName = "102NO32904820801012", EditionNumber = 36, UpdateNumber = 0 },
};

A.CallTo(() => _fakeExchangeSetStandardService.ProcessProductVersionsRequest(A<IEnumerable<ProductVersionRequest>>.Ignored, A<string>.Ignored, A<string>.Ignored, A<string>.Ignored, A<CancellationToken>.Ignored))
A.CallTo(() => _fakeExchangeSetStandardService.ProcessProductVersionsRequestAsync(A<IEnumerable<ProductVersionRequest>>.Ignored, A<ApiVersion>.Ignored, A<string>.Ignored, A<string>.Ignored, A<string>.Ignored, A<CancellationToken>.Ignored))
.Returns(ServiceResponseResult<ExchangeSetStandardServiceResponse>
.Accepted(null));

Expand All @@ -110,13 +110,13 @@ public async Task WhenValidProductVersionsIsPassed_ThenPostProductVersionsReturn

A.CallTo(_fakeLogger).Where(call => call.Method.Name == "Log"
&& call.GetArgument<LogLevel>(0) == LogLevel.Information
&& call.GetArgument<EventId>(1) == EventIds.PostProductVersionsRequestStart.ToEventId()
&& call.GetArgument<IEnumerable<KeyValuePair<string, object>>>(2)!.ToDictionary(c => c.Key, c => c.Value)["{OriginalFormat}"].ToString() == "ProductVersions endpoint request for _X-Correlation-ID:{correlationId} and ExchangeSetStandard:{exchangeSetStandard}").MustHaveHappened();
&& call.GetArgument<EventId>(1) == EventIds.ESSPostProductVersionsRequestStart.ToEventId()
&& call.GetArgument<IEnumerable<KeyValuePair<string, object>>>(2)!.ToDictionary(c => c.Key, c => c.Value)["{OriginalFormat}"].ToString() == "ProductVersions V2 endpoint request for _X-Correlation-ID:{correlationId} and ExchangeSetStandard:{exchangeSetStandard}").MustHaveHappened();

A.CallTo(_fakeLogger).Where(call => call.Method.Name == "Log"
&& call.GetArgument<LogLevel>(0) == LogLevel.Information
&& call.GetArgument<EventId>(1) == EventIds.PostProductVersionsRequestCompleted.ToEventId()
&& call.GetArgument<IEnumerable<KeyValuePair<string, object>>>(2)!.ToDictionary(c => c.Key, c => c.Value)["{OriginalFormat}"].ToString() == "ProductVersions endpoint request for _X-Correlation-ID:{correlationId} and ExchangeSetStandard:{exchangeSetStandard} Elapsed {Elapsed}").MustHaveHappened();
&& call.GetArgument<EventId>(1) == EventIds.ESSPostProductVersionsRequestCompleted.ToEventId()
&& call.GetArgument<IEnumerable<KeyValuePair<string, object>>>(2)!.ToDictionary(c => c.Key, c => c.Value)["{OriginalFormat}"].ToString() == "ProductVersions V2 endpoint request for _X-Correlation-ID:{correlationId} and ExchangeSetStandard:{exchangeSetStandard} Elapsed {Elapsed}").MustHaveHappened();
}

[Test]
Expand All @@ -128,7 +128,7 @@ public async Task WhenInvalidProductVersionsIsPassed_ThenPostProductVersionsRetu
new () { ProductName = "", EditionNumber = 10, UpdateNumber = 2 },
};

A.CallTo(() => _fakeExchangeSetStandardService.ProcessProductVersionsRequest(A<IEnumerable<ProductVersionRequest>>.Ignored, A<string>.Ignored, A<string>.Ignored, A<string>.Ignored, A<CancellationToken>.Ignored))
A.CallTo(() => _fakeExchangeSetStandardService.ProcessProductVersionsRequestAsync(A<IEnumerable<ProductVersionRequest>>.Ignored, A<ApiVersion>.Ignored, A<string>.Ignored, A<string>.Ignored, A<string>.Ignored, A<CancellationToken>.Ignored))
.Returns(ServiceResponseResult<ExchangeSetStandardServiceResponse>.BadRequest(new ErrorDescription { CorrelationId = Guid.NewGuid().ToString(), Errors = [new() { Source = "requestBody", Description = "Either body is null or malformed." }] }));

var result = await _controller.PostProductVersions(ExchangeSetStandard, productVersionRequest, _callbackUri);
Expand All @@ -137,13 +137,13 @@ public async Task WhenInvalidProductVersionsIsPassed_ThenPostProductVersionsRetu

A.CallTo(_fakeLogger).Where(call => call.Method.Name == "Log"
&& call.GetArgument<LogLevel>(0) == LogLevel.Information
&& call.GetArgument<EventId>(1) == EventIds.PostProductVersionsRequestStart.ToEventId()
&& call.GetArgument<IEnumerable<KeyValuePair<string, object>>>(2)!.ToDictionary(c => c.Key, c => c.Value)["{OriginalFormat}"].ToString() == "ProductVersions endpoint request for _X-Correlation-ID:{correlationId} and ExchangeSetStandard:{exchangeSetStandard}").MustHaveHappened();
&& call.GetArgument<EventId>(1) == EventIds.ESSPostProductVersionsRequestStart.ToEventId()
&& call.GetArgument<IEnumerable<KeyValuePair<string, object>>>(2)!.ToDictionary(c => c.Key, c => c.Value)["{OriginalFormat}"].ToString() == "ProductVersions V2 endpoint request for _X-Correlation-ID:{correlationId} and ExchangeSetStandard:{exchangeSetStandard}").MustHaveHappened();

A.CallTo(_fakeLogger).Where(call => call.Method.Name == "Log"
&& call.GetArgument<LogLevel>(0) == LogLevel.Information
&& call.GetArgument<EventId>(1) == EventIds.PostProductVersionsRequestCompleted.ToEventId()
&& call.GetArgument<IEnumerable<KeyValuePair<string, object>>>(2)!.ToDictionary(c => c.Key, c => c.Value)["{OriginalFormat}"].ToString() == "ProductVersions endpoint request for _X-Correlation-ID:{correlationId} and ExchangeSetStandard:{exchangeSetStandard} Elapsed {Elapsed}").MustHaveHappened();
&& call.GetArgument<EventId>(1) == EventIds.ESSPostProductVersionsRequestCompleted.ToEventId()
&& call.GetArgument<IEnumerable<KeyValuePair<string, object>>>(2)!.ToDictionary(c => c.Key, c => c.Value)["{OriginalFormat}"].ToString() == "ProductVersions V2 endpoint request for _X-Correlation-ID:{correlationId} and ExchangeSetStandard:{exchangeSetStandard} Elapsed {Elapsed}").MustHaveHappened();
}

[Test]
Expand Down
Loading