public async Task WhenICallExchangeSetApiWithASpecifiedReissueProductVersion_ThenEncFilesWillBeCreatedForLatestProductVersion() { ProductVersionData = new List <ProductVersionModel>(); ProductVersionData.Add(DataHelper.GetProductVersionModelData("JP5BHTR7", 7, 6)); ApiEssResponse = await ExchangeSetApiClient.GetProductVersionsAsync(ProductVersionData, accessToken : EssJwtToken); //Get the BatchId var batchId = await ApiEssResponse.GetBatchId(); CleanUpBatchIdList.Add(batchId); DownloadedFolderPath = await FileContentHelper.CreateExchangeSetFile(ApiEssResponse, FssJwtToken); //Get the product details form sales catalogue service var apiScsResponse = await ScsApiClient.GetProductVersionsAsync(Config.ExchangeSetProductType, ProductVersionData, ScsJwtToken); Assert.AreEqual(200, (int)apiScsResponse.StatusCode, $"Incorrect status code is returned {apiScsResponse.StatusCode}, instead of the expected status 200."); var apiScsResponseData = await apiScsResponse.ReadAsTypeAsync <ScsProductResponseModel>(); foreach (var product in apiScsResponseData.Products) { string productName = product.ProductName; int editionNumber = product.EditionNumber; //Enc file downloaded verification foreach (var updateNumber in product.UpdateNumbers) { await FileContentHelper.GetDownloadedEncFilesAsync(Config.FssConfig.BaseUrl, Path.Combine(DownloadedFolderPath, Config.ExchangeSetEncRootFolder), productName, editionNumber, updateNumber, FssJwtToken); } } }
public async Task SetupAsync() { Config = new TestConfiguration(); ExchangeSetApiClient = new ExchangeSetApiClient(Config.EssBaseAddress); FssApiClient = new FssApiClient(); AuthTokenProvider authTokenProvider = new AuthTokenProvider(); EssJwtToken = await authTokenProvider.GetEssToken(); FssJwtToken = await authTokenProvider.GetFssToken(); DataHelper = new DataHelper(); ScsApiClient = new SalesCatalogueApiClient(Config.ScsAuthConfig.BaseUrl); ScsJwtToken = await authTokenProvider.GetScsToken(); ProductVersionData = new List <ProductVersionModel>(); ////Invalid Edition Number ProductVersionData.Add(DataHelper.GetProductVersionModelData("DE416040", 11, 1)); ApiEssResponse = await ExchangeSetApiClient.GetProductVersionsAsync(ProductVersionData, accessToken : EssJwtToken); //Get the BatchId var batchId = await ApiEssResponse.GetBatchId(); CleanUpBatchIdList.Add(batchId); DownloadedFolderPath = await FileContentHelper.CreateExchangeSetFile(ApiEssResponse, FssJwtToken); }
public async Task WhenICallTheProductVersionApiWithCustomB2cToken_ThenAnUnauthorisedResponseIsReturned() { List <ProductVersionModel> ProductVersionData = new List <ProductVersionModel>(); ProductVersionData.Add(DataHelper.GetProductVersionModelData("DE4NO18Q", 1, 0)); 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."); }
public async Task WhenICallTheApiWithOutAuthToken_ThenAnUnauthorisedResponseIsReturned() { List <ProductVersionModel> ProductVersiondata = new List <ProductVersionModel>(); ProductVersiondata.Add(DataHelper.GetProductVersionModelData("DE416080", 9, 6)); var apiResponse = await ExchangeSetApiClient.GetProductVersionsAsync(ProductVersiondata); Assert.AreEqual(401, (int)apiResponse.StatusCode, $"Incorrect status code {apiResponse.StatusCode} is returned, instead of the expected 401."); }
public async Task WhenICallTheApiWithAValidProductVersionWithInvalidCallbackURI_ThenABadRequestStatusIsReturned(string callBackUrl) { List <ProductVersionModel> ProductVersiondata = new List <ProductVersionModel>(); ProductVersiondata.Add(DataHelper.GetProductVersionModelData("DE416080", 9, 6)); var apiResponse = await ExchangeSetApiClient.GetProductVersionsAsync(ProductVersiondata, callBackUrl, accessToken : EssJwtToken); Assert.AreEqual(400, (int)apiResponse.StatusCode, $"Incorrect status code {apiResponse.StatusCode} is returned, instead of the expected 400."); }
public async Task WhenICallTheProductVersionApiWithInvalidB2cToken_ThenAnUnauthorisedResponseIsReturned() { string invalidB2cToken = EssB2CToken.Remove(EssB2CToken.Length - 2).Insert(EssB2CToken.Length - 2, "AA"); List <ProductVersionModel> ProductVersionData = new List <ProductVersionModel>(); ProductVersionData.Add(DataHelper.GetProductVersionModelData("DE416080", 9, 6)); 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."); }
public async Task WhenICallTheApiWithAnEmptyProductVersion_ThenABadRequestStatusIsReturned() { List <ProductVersionModel> ProductVersiondata = new List <ProductVersionModel>(); var apiResponse = await ExchangeSetApiClient.GetProductVersionsAsync(ProductVersiondata, accessToken : EssJwtToken); Assert.AreEqual(400, (int)apiResponse.StatusCode, $"Incorrect status code {apiResponse.StatusCode} is returned, instead of the expected 400."); var errorMessage = await apiResponse.ReadAsTypeAsync <ErrorDescriptionResponseModel>(); Assert.IsTrue(errorMessage.Errors.Any(e => e.Source == "requestBody")); Assert.IsTrue(errorMessage.Errors.Any(e => e.Description == "Either body is null or malformed.")); }
public async Task WhenICallExchangeSetProductVersionsApiWithACancelledProduct_ThenCatalogueFileUpdatedWithEditionNumberZero() { List <ProductVersionModel> ProductVersiondata = new List <ProductVersionModel>(); ProductVersiondata.Add(DataHelper.GetProductVersionModelData("DE516510", 2, 1)); var apiResponse = await ExchangeSetApiClient.GetProductVersionsAsync(ProductVersiondata, accessToken : EssJwtToken); Assert.AreEqual(200, (int)apiResponse.StatusCode, $"Incorrect status code {apiResponse.StatusCode} is returned, instead of the expected 200."); var apiResponseData = await apiResponse.ReadAsTypeAsync <ExchangeSetResponseModel>(); var batchStatusUrl = apiResponseData.Links.ExchangeSetBatchStatusUri.Href; var batchId = batchStatusUrl.Split('/')[5]; CleanUpBatchIdList.Add(batchId); var finalBatchStatusUrl = $"{Config.FssConfig.BaseUrl}/batch/{batchId}/status"; var batchStatus = await FssBatchHelper.CheckBatchIsCommitted(finalBatchStatusUrl.ToString(), FssJwtToken); Assert.AreEqual("Committed", batchStatus, $"Incorrect batch status is returned {batchStatus} for url {batchStatusUrl}, instead of the expected status Committed."); var downloadFileUrl = $"{Config.FssConfig.BaseUrl}/batch/{batchId}/files/{Config.ExchangeSetFileName}"; var extractDownloadedFolder = await FssBatchHelper.ExtractDownloadedFolder(downloadFileUrl.ToString(), FssJwtToken); var downloadFolder = FssBatchHelper.RenameFolder(extractDownloadedFolder); var downloadFolderPath = Path.Combine(Path.GetTempPath(), downloadFolder); //Verify Cancellation details var apiScsResponse = await ScsApiClient.GetProductVersionsAsync(Config.ExchangeSetProductType, ProductVersiondata, ScsJwtToken); Assert.AreEqual(200, (int)apiScsResponse.StatusCode, $"Incorrect status code is returned {apiScsResponse.StatusCode}, instead of the expected status 200."); var apiScsResponseData = await apiScsResponse.ReadAsTypeAsync <CancellationResponseModel>(); foreach (var product in apiScsResponseData.Products) { var productName = product.ProductName; var editionNumber = product.Cancellation.EditionNumber; Assert.AreEqual(0, editionNumber, $"Incorrect edition number is returned {editionNumber}, instead of 0."); var updateNumber = product.UpdateNumbers[product.UpdateNumbers.Count - 1]; CancellationFileHelper.CheckCatalogueFileContent(Path.Combine(downloadFolderPath, Config.ExchangeSetEncRootFolder, Config.ExchangeSetCatalogueFile), editionNumber, updateNumber, batchId); CancellationFileHelper.CheckProductFileContent(Path.Combine(downloadFolderPath, Config.ExchangeSetProductFilePath, Config.ExchangeSetProductFile), productName, editionNumber); } }
public async Task WhenICallTheApiWithNoRoleToken_ThenACorrectResponseIsReturned() { List <ProductVersionModel> ProductVersiondata = new List <ProductVersionModel>(); ProductVersiondata.Add(DataHelper.GetProductVersionModelData("DE416080", 9, 1)); var apiResponse = await ExchangeSetApiClient.GetProductVersionsAsync(ProductVersiondata, accessToken : EssJwtTokenNoRole); Assert.AreEqual(200, (int)apiResponse.StatusCode, $"Incorrect status code {apiResponse.StatusCode} is returned, instead of the expected 200."); //Get the BatchId var batchId = await apiResponse.GetBatchId(); CleanUpBatchIdList.Add(batchId); }
public async Task WhenICallTheApiWithNullProductVersion_ThenABadRequestStatusIsReturned(string productName, int?editionNumber, int?updateNumber, string sourceMessage, string descriptionMessage) { List <ProductVersionModel> ProductVersiondata = new List <ProductVersionModel>(); ProductVersiondata.Add(DataHelper.GetProductVersionModelData(productName, editionNumber, updateNumber)); var apiResponse = await ExchangeSetApiClient.GetProductVersionsAsync(ProductVersiondata, "https://fss.ukho.gov.uk/batch/7b4cdf10-adfa-4ed6-b2fe-d1543d8b7272", accessToken : EssJwtToken); Assert.AreEqual(400, (int)apiResponse.StatusCode, $"Incorrect status code {apiResponse.StatusCode} is returned, instead of the expected 400."); var errorMessage = await apiResponse.ReadAsTypeAsync <ErrorDescriptionResponseModel>(); Assert.IsTrue(errorMessage.Errors.Any(e => e.Source == sourceMessage)); Assert.IsTrue(errorMessage.Errors.Any(e => e.Description == descriptionMessage)); }
public async Task WhenICallTheApiWithAValidProductVersionWithCallbackURI_ThenASuccessStatusIsReturned() { List <ProductVersionModel> ProductVersiondata = new List <ProductVersionModel>(); ProductVersiondata.Add(DataHelper.GetProductVersionModelData("DE4NO18Q", 2, 0)); var apiResponse = await ExchangeSetApiClient.GetProductVersionsAsync(ProductVersiondata, "https://fss.ukho.gov.uk/batch/7b4cdf10-adfa-4ed6-b2fe-d1543d8b7272", accessToken : EssJwtToken); Assert.AreEqual(200, (int)apiResponse.StatusCode, $"Incorrect status code {apiResponse.StatusCode} is returned, instead of the expected 200."); //Get the BatchId var batchId = await apiResponse.GetBatchId(); CleanUpBatchIdList.Add(batchId); }
public async Task WhenICallTheProductVersionApiWithAValidB2cToken_ThenTheCorrectResponseIsReturned() { List <ProductVersionModel> ProductVersionData = new List <ProductVersionModel>(); ProductVersionData.Add(DataHelper.GetProductVersionModelData("DE416080", 9, 1)); 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); }
public async Task WhenICallTheApiWithAProductVersionNotAvailable_ThenASuccessStatusIsReturned(string productname, int editionnumber, int updatenumber) { List <ProductVersionModel> ProductVersiondata = new List <ProductVersionModel>(); ProductVersiondata.Add(DataHelper.GetProductVersionModelData(productname, editionnumber, updatenumber)); var apiResponse = await ExchangeSetApiClient.GetProductVersionsAsync(ProductVersiondata, "https://fss.ukho.gov.uk/batch/7b4cdf10-adfa-4ed6-b2fe-d1543d8b7272", accessToken : EssJwtToken); Assert.AreEqual(200, (int)apiResponse.StatusCode, $"Incorrect status code {apiResponse.StatusCode} is returned, instead of the expected 200."); var apiResponseData = await apiResponse.ReadAsTypeAsync <ExchangeSetResponseModel>(); //Verify requested product count Assert.AreEqual(1, apiResponseData.RequestedProductCount, $"Response body returned RequestedProductCount {apiResponseData.RequestedProductCount}, Instead of expected count is 1."); Assert.AreEqual(0, apiResponseData.RequestedProductsAlreadyUpToDateCount, $"Response body returned RequestedProductsAlreadyUpToDateCount : {apiResponseData.RequestedProductsAlreadyUpToDateCount}, Instead of expected RequestedProductsAlreadyUpToDateCount is 0."); // Verify ExchangeSetCellCount Assert.AreEqual(0, apiResponseData.ExchangeSetCellCount, $"Response body returned ExchangeSetCellCount {apiResponseData.ExchangeSetCellCount}, instead of expected ExchangeSetCellCount is 0."); //Check RequestedProductsNotInExchangeSet is not empty Assert.IsNotEmpty(apiResponseData.RequestedProductsNotInExchangeSet, "Response body returns Empty for RequestedProductsNotInExchangeSet, instead of Not Empty"); Assert.AreEqual("invalidProduct", apiResponseData.RequestedProductsNotInExchangeSet.FirstOrDefault().Reason, $"Exchange set returned Reason {apiResponseData.RequestedProductsNotInExchangeSet.FirstOrDefault().Reason}, instead of expected Reason 'invalidProduct'"); }
public async Task WhenICallTheApiWithValidAndInvalidProductVersion_ThenTheCorrectResponseIsReturned() { List <ProductVersionModel> ProductVersiondata = new List <ProductVersionModel>(); ProductVersiondata.Add(DataHelper.GetProductVersionModelData("DE416080", 9, 1)); ProductVersiondata.Add(DataHelper.GetProductVersionModelData("GB123789", 1, 0)); var apiResponse = await ExchangeSetApiClient.GetProductVersionsAsync(ProductVersiondata, accessToken : EssJwtToken); Assert.AreEqual(200, (int)apiResponse.StatusCode, $"Incorrect status code {apiResponse.StatusCode} is returned, instead of the expected 200."); //verify model structure await apiResponse.CheckModelStructureForSuccessResponse(); var apiResponseData = await apiResponse.ReadAsTypeAsync <ExchangeSetResponseModel>(); Assert.AreEqual("GB123789", apiResponseData.RequestedProductsNotInExchangeSet.FirstOrDefault().ProductName, $"Exchange set returned Product Name {apiResponseData.RequestedProductsNotInExchangeSet.FirstOrDefault().ProductName}, instead of expected Product Name 'GB123789'"); Assert.AreEqual("invalidProduct", apiResponseData.RequestedProductsNotInExchangeSet.FirstOrDefault().Reason, $"Exchange set returned Reason {apiResponseData.RequestedProductsNotInExchangeSet.FirstOrDefault().Reason}, instead of expected Reason 'invalidProduct'"); //Get the BatchId var batchId = await apiResponse.GetBatchId(); CleanUpBatchIdList.Add(batchId); }