From 5681262dacf3b3a559229ded818f4581bfc5bec6 Mon Sep 17 00:00:00 2001 From: Stuart Ferguson Date: Fri, 27 Mar 2026 19:08:08 +0000 Subject: [PATCH] Switch to OpenIddict auth, update tests and config Migrated FileProcessor API authentication from JwtBearer to OpenIddict validation, updating MiddlewareRegistry and adding required OpenIddict NuGet packages. Adjusted in-memory test config to include ApiName for audience validation. Updated feature and test files to remove estateManagement and voucherManagement scopes/resources, add required claims to transactionProcessor, and restrict serviceClient scopes. Removed obsolete BootstrapperTests.cs. Updated generated feature files to reflect these changes. --- .../MediatorTests.cs | 1 - .../Features/GetFileImportDetails.feature | 8 +- .../Features/GetFileImportDetails.feature.cs | 82 ++++++---------- .../Features/ProcessTopupCSV.feature | 8 +- .../Features/ProcessTopupCSV.feature.cs | 98 ++++++++----------- .../Features/ProcessVoucherCSV.feature | 8 +- .../Features/ProcessVoucherCSV.feature.cs | 90 +++++++---------- FileProcessor.Testing/TestData.cs | 1 + FileProcessor.Tests/BootstrapperTests.cs | 58 ----------- .../Bootstrapper/MiddlewareRegistry.cs | 55 ++++++----- FileProcessor/FileProcessor.csproj | 2 + 11 files changed, 143 insertions(+), 268 deletions(-) delete mode 100644 FileProcessor.Tests/BootstrapperTests.cs diff --git a/FileProcessor.BusinessLogic.Tests/MediatorTests.cs b/FileProcessor.BusinessLogic.Tests/MediatorTests.cs index 8c13726..1398ca3 100644 --- a/FileProcessor.BusinessLogic.Tests/MediatorTests.cs +++ b/FileProcessor.BusinessLogic.Tests/MediatorTests.cs @@ -49,7 +49,6 @@ public async Task Mediator_Send_RequestHandled() this.AddTestRegistrations(services, hostingEnvironment.Object); s.ConfigureContainer(services); - Startup.Container.AssertConfigurationIsValid(AssertMode.Full); List errors = new List(); IMediator mediator = Startup.Container.GetService(); diff --git a/FileProcessor.IntegrationTests/Features/GetFileImportDetails.feature b/FileProcessor.IntegrationTests/Features/GetFileImportDetails.feature index 8a745e7..ec199c2 100644 --- a/FileProcessor.IntegrationTests/Features/GetFileImportDetails.feature +++ b/FileProcessor.IntegrationTests/Features/GetFileImportDetails.feature @@ -4,21 +4,17 @@ Feature: GetFileImportDetails Background: Given I create the following api scopes | Name | DisplayName | Description | - | estateManagement | Estate Managememt REST Scope | A scope for Estate Managememt REST | | transactionProcessor | Transaction Processor REST Scope | A scope for Transaction Processor REST | - | voucherManagement | Voucher Management REST Scope | A scope for Voucher Management REST | | fileProcessor | File Processor REST Scope | A scope for File Processor REST | Given the following api resources exist | Name | DisplayName | Secret | Scopes | UserClaims | - | estateManagement | Estate Managememt REST | Secret1 | estateManagement | MerchantId, EstateId, role | - | transactionProcessor | Transaction Processor REST | Secret1 | transactionProcessor | | - | voucherManagement | Voucher Management REST | Secret1 | voucherManagement | | + | transactionProcessor | Transaction Processor REST | Secret1 | transactionProcessor | MerchantId, EstateId, role | | fileProcessor | File Processor REST | Secret1 | fileProcessor | | Given the following clients exist | ClientId | ClientName | Secret | Scopes | GrantTypes | - | serviceClient | Service Client | Secret1 | estateManagement,transactionProcessor,voucherManagement,fileProcessor | client_credentials | + | serviceClient | Service Client | Secret1 | transactionProcessor,fileProcessor | client_credentials | Given I have a token to access the estate management and transaction processor resources | ClientId | diff --git a/FileProcessor.IntegrationTests/Features/GetFileImportDetails.feature.cs b/FileProcessor.IntegrationTests/Features/GetFileImportDetails.feature.cs index 389a4f1..7e79ebf 100644 --- a/FileProcessor.IntegrationTests/Features/GetFileImportDetails.feature.cs +++ b/FileProcessor.IntegrationTests/Features/GetFileImportDetails.feature.cs @@ -117,18 +117,10 @@ public void ScenarioInitialize(global::Reqnroll.ScenarioInfo scenarioInfo, globa "Name", "DisplayName", "Description"}); - table1.AddRow(new string[] { - "estateManagement", - "Estate Managememt REST Scope", - "A scope for Estate Managememt REST"}); table1.AddRow(new string[] { "transactionProcessor", "Transaction Processor REST Scope", "A scope for Transaction Processor REST"}); - table1.AddRow(new string[] { - "voucherManagement", - "Voucher Management REST Scope", - "A scope for Voucher Management REST"}); table1.AddRow(new string[] { "fileProcessor", "File Processor REST Scope", @@ -142,31 +134,19 @@ public void ScenarioInitialize(global::Reqnroll.ScenarioInfo scenarioInfo, globa "Secret", "Scopes", "UserClaims"}); - table2.AddRow(new string[] { - "estateManagement", - "Estate Managememt REST", - "Secret1", - "estateManagement", - "MerchantId, EstateId, role"}); table2.AddRow(new string[] { "transactionProcessor", "Transaction Processor REST", "Secret1", "transactionProcessor", - ""}); - table2.AddRow(new string[] { - "voucherManagement", - "Voucher Management REST", - "Secret1", - "voucherManagement", - ""}); + "MerchantId, EstateId, role"}); table2.AddRow(new string[] { "fileProcessor", "File Processor REST", "Secret1", "fileProcessor", ""}); -#line 12 +#line 10 await testRunner.GivenAsync("the following api resources exist", ((string)(null)), table2, "Given "); #line hidden global::Reqnroll.Table table3 = new global::Reqnroll.Table(new string[] { @@ -179,16 +159,16 @@ public void ScenarioInitialize(global::Reqnroll.ScenarioInfo scenarioInfo, globa "serviceClient", "Service Client", "Secret1", - "estateManagement,transactionProcessor,voucherManagement,fileProcessor", + "transactionProcessor,fileProcessor", "client_credentials"}); -#line 19 +#line 15 await testRunner.GivenAsync("the following clients exist", ((string)(null)), table3, "Given "); #line hidden global::Reqnroll.Table table4 = new global::Reqnroll.Table(new string[] { "ClientId"}); table4.AddRow(new string[] { "serviceClient"}); -#line 23 +#line 19 await testRunner.GivenAsync("I have a token to access the estate management and transaction processor resource" + "s", ((string)(null)), table4, "Given "); #line hidden @@ -196,7 +176,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "EstateName"}); table5.AddRow(new string[] { "Test Estate 1"}); -#line 27 +#line 23 await testRunner.GivenAsync("I have created the following estates", ((string)(null)), table5, "Given "); #line hidden global::Reqnroll.Table table6 = new global::Reqnroll.Table(new string[] { @@ -214,7 +194,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Voucher", "True", "True"}); -#line 31 +#line 27 await testRunner.GivenAsync("I have created the following operators", ((string)(null)), table6, "Given "); #line hidden global::Reqnroll.Table table7 = new global::Reqnroll.Table(new string[] { @@ -226,7 +206,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and table7.AddRow(new string[] { "Test Estate 1", "Voucher"}); -#line 36 +#line 32 await testRunner.AndAsync("I have assigned the following operators to the estates", ((string)(null)), table7, "And "); #line hidden global::Reqnroll.Table table8 = new global::Reqnroll.Table(new string[] { @@ -241,7 +221,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Test Estate 1", "Voucher", "Hospital 1 Contract"}); -#line 41 +#line 37 await testRunner.GivenAsync("I create a contract with the following values", ((string)(null)), table8, "Given "); #line hidden global::Reqnroll.Table table9 = new global::Reqnroll.Table(new string[] { @@ -268,7 +248,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "10 KES", "", "Voucher"}); -#line 46 +#line 42 await testRunner.WhenAsync("I create the following Products", ((string)(null)), table9, "When "); #line hidden global::Reqnroll.Table table10 = new global::Reqnroll.Table(new string[] { @@ -287,7 +267,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Fixed", "Merchant Commission", "2.50"}); -#line 51 +#line 47 await testRunner.WhenAsync("I add the following Transaction Fees", ((string)(null)), table10, "When "); #line hidden global::Reqnroll.Table table11 = new global::Reqnroll.Table(new string[] { @@ -320,7 +300,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Test Contact 1", "testcontact1@merchant2.co.uk", "Test Estate 1"}); -#line 55 +#line 51 await testRunner.GivenAsync("I create the following merchants", ((string)(null)), table11, "Given "); #line hidden global::Reqnroll.Table table12 = new global::Reqnroll.Table(new string[] { @@ -353,7 +333,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "00000002", "10000002", "Test Estate 1"}); -#line 60 +#line 56 await testRunner.GivenAsync("I have assigned the following operator to the merchants", ((string)(null)), table12, "Given "); #line hidden global::Reqnroll.Table table13 = new global::Reqnroll.Table(new string[] { @@ -368,7 +348,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "123456781", "Test Merchant 2", "Test Estate 1"}); -#line 67 +#line 63 await testRunner.GivenAsync("I have assigned the following devices to the merchants", ((string)(null)), table13, "Given "); #line hidden global::Reqnroll.Table table14 = new global::Reqnroll.Table(new string[] { @@ -391,7 +371,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Test Estate 1", "Test Merchant 2", "Hospital 1 Contract"}); -#line 72 +#line 68 await testRunner.WhenAsync("I add the following contracts to the following merchants", ((string)(null)), table14, "When "); #line hidden global::Reqnroll.Table table15 = new global::Reqnroll.Table(new string[] { @@ -412,7 +392,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Today", "Test Merchant 2", "Test Estate 1"}); -#line 79 +#line 75 await testRunner.GivenAsync("I make the following manual merchant deposits", ((string)(null)), table15, "Given "); #line hidden } @@ -436,7 +416,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("Get File Import Log Details", null, tagsOfScenario, argumentsOfScenario, featureTags, pickleIndex); string[] tagsOfRule = ((string[])(null)); global::Reqnroll.RuleInfo ruleInfo = null; -#line 86 +#line 82 this.ScenarioInitialize(scenarioInfo, ruleInfo); #line hidden if ((global::Reqnroll.TagHelper.ContainsIgnoreTag(scenarioInfo.CombinedTags) || global::Reqnroll.TagHelper.ContainsIgnoreTag(featureTags))) @@ -465,7 +445,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "T", "1", ""}); -#line 87 +#line 83 await testRunner.GivenAsync("I have a file named \'SafarcomTopup1.txt\' with the following contents", ((string)(null)), table16, "Given "); #line hidden global::Reqnroll.Table table17 = new global::Reqnroll.Table(new string[] { @@ -478,7 +458,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Test Merchant 1", "B2A59ABF-293D-4A6B-B81B-7007503C3476", "ABA59ABF-293D-4A6B-B81B-7007503C3476"}); -#line 92 +#line 88 await testRunner.AndAsync("I upload this file for processing", ((string)(null)), table17, "And "); #line hidden global::Reqnroll.Table table18 = new global::Reqnroll.Table(new string[] { @@ -497,7 +477,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "T", "1", ""}); -#line 96 +#line 92 await testRunner.GivenAsync("I have a file named \'SafarcomTopup2.txt\' with the following contents", ((string)(null)), table18, "Given "); #line hidden global::Reqnroll.Table table19 = new global::Reqnroll.Table(new string[] { @@ -510,7 +490,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Test Merchant 2", "B2A59ABF-293D-4A6B-B81B-7007503C3476", "ABA59ABF-293D-4A6B-B81B-7007503C3476"}); -#line 101 +#line 97 await testRunner.AndAsync("I upload this file for processing", ((string)(null)), table19, "And "); #line hidden global::Reqnroll.Table table20 = new global::Reqnroll.Table(new string[] { @@ -538,7 +518,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "1", "", ""}); -#line 105 +#line 101 await testRunner.GivenAsync("I have a file named \'VoucherIssue1.txt\' with the following contents", ((string)(null)), table20, "Given "); #line hidden global::Reqnroll.Table table21 = new global::Reqnroll.Table(new string[] { @@ -551,7 +531,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Test Merchant 1", "8806EDBC-3ED6-406B-9E5F-A9078356BE99", "ABA59ABF-293D-4A6B-B81B-7007503C3476"}); -#line 111 +#line 107 await testRunner.AndAsync("I upload this file for processing", ((string)(null)), table21, "And "); #line hidden global::Reqnroll.Table table22 = new global::Reqnroll.Table(new string[] { @@ -560,7 +540,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and table22.AddRow(new string[] { "Today", "3"}); -#line 115 +#line 111 await testRunner.WhenAsync("I get the \'Test Estate 1\' import logs between \'Yesterday\' and \'Today\' the followi" + "ng data is returned", ((string)(null)), table22, "When "); #line hidden @@ -576,7 +556,7 @@ await testRunner.WhenAsync("I get the \'Test Estate 1\' import logs between \'Ye table23.AddRow(new string[] { "Test Merchant 1", "VoucherIssue1.txt"}); -#line 119 +#line 115 await testRunner.WhenAsync("I get the \'Test Estate 1\' import log for \'Today\' the following file information i" + "s returned", ((string)(null)), table23, "When "); #line hidden @@ -596,7 +576,7 @@ await testRunner.WhenAsync("I get the \'Test Estate 1\' import logs between \'Ye "2", "0", "0"}); -#line 125 +#line 121 await testRunner.WhenAsync("I get the file \'SafarcomTopup1.txt\' for Estate \'Test Estate 1\' the following file" + " information is returned", ((string)(null)), table24, "When "); #line hidden @@ -616,7 +596,7 @@ await testRunner.WhenAsync("I get the \'Test Estate 1\' import logs between \'Ye "3", "T,1,", "Ignored"}); -#line 129 +#line 125 await testRunner.WhenAsync("I get the file \'SafarcomTopup1.txt\' for Estate \'Test Estate 1\' the following file" + " lines are returned", ((string)(null)), table25, "When "); #line hidden @@ -636,7 +616,7 @@ await testRunner.WhenAsync("I get the \'Test Estate 1\' import logs between \'Ye "2", "0", "0"}); -#line 135 +#line 131 await testRunner.WhenAsync("I get the file \'SafarcomTopup2.txt\' for Estate \'Test Estate 1\' the following file" + " information is returned", ((string)(null)), table26, "When "); #line hidden @@ -656,7 +636,7 @@ await testRunner.WhenAsync("I get the \'Test Estate 1\' import logs between \'Ye "3", "T,1,", "Ignored"}); -#line 139 +#line 135 await testRunner.WhenAsync("I get the file \'SafarcomTopup2.txt\' for Estate \'Test Estate 1\' the following file" + " lines are returned", ((string)(null)), table27, "When "); #line hidden @@ -676,7 +656,7 @@ await testRunner.WhenAsync("I get the \'Test Estate 1\' import logs between \'Ye "2", "0", "0"}); -#line 145 +#line 141 await testRunner.WhenAsync("I get the file \'VoucherIssue1.txt\' for Estate \'Test Estate 1\' the following file " + "information is returned", ((string)(null)), table28, "When "); #line hidden @@ -700,7 +680,7 @@ await testRunner.WhenAsync("I get the \'Test Estate 1\' import logs between \'Ye "4", "T,1,,", "Ignored"}); -#line 149 +#line 145 await testRunner.WhenAsync("I get the file \'VoucherIssue1.txt\' for Estate \'Test Estate 1\' the following file " + "lines are returned", ((string)(null)), table29, "When "); #line hidden diff --git a/FileProcessor.IntegrationTests/Features/ProcessTopupCSV.feature b/FileProcessor.IntegrationTests/Features/ProcessTopupCSV.feature index b513002..bc3c9ab 100644 --- a/FileProcessor.IntegrationTests/Features/ProcessTopupCSV.feature +++ b/FileProcessor.IntegrationTests/Features/ProcessTopupCSV.feature @@ -4,21 +4,17 @@ Feature: Process Topup CSV Files Background: Given I create the following api scopes | Name | DisplayName | Description | - | estateManagement | Estate Managememt REST Scope | A scope for Estate Managememt REST | | transactionProcessor | Transaction Processor REST Scope | A scope for Transaction Processor REST | - | voucherManagement | Voucher Management REST Scope | A scope for Voucher Management REST | | fileProcessor | File Processor REST Scope | A scope for File Processor REST | Given the following api resources exist | Name | DisplayName | Secret | Scopes | UserClaims | - | estateManagement | Estate Managememt REST | Secret1 | estateManagement | MerchantId, EstateId, role | - | transactionProcessor | Transaction Processor REST | Secret1 | transactionProcessor | | - | voucherManagement | Voucher Management REST | Secret1 | voucherManagement | | + | transactionProcessor | Transaction Processor REST | Secret1 | transactionProcessor | MerchantId, EstateId, role | | fileProcessor | File Processor REST | Secret1 | fileProcessor | | Given the following clients exist | ClientId | ClientName | Secret | Scopes | GrantTypes | - | serviceClient | Service Client | Secret1 | estateManagement,transactionProcessor,voucherManagement,fileProcessor | client_credentials | + | serviceClient | Service Client | Secret1 | transactionProcessor,fileProcessor | client_credentials | Given I have a token to access the estate management and transaction processor resources | ClientId | diff --git a/FileProcessor.IntegrationTests/Features/ProcessTopupCSV.feature.cs b/FileProcessor.IntegrationTests/Features/ProcessTopupCSV.feature.cs index bdc9284..fcecbd5 100644 --- a/FileProcessor.IntegrationTests/Features/ProcessTopupCSV.feature.cs +++ b/FileProcessor.IntegrationTests/Features/ProcessTopupCSV.feature.cs @@ -115,18 +115,10 @@ public void ScenarioInitialize(global::Reqnroll.ScenarioInfo scenarioInfo, globa "Name", "DisplayName", "Description"}); - table30.AddRow(new string[] { - "estateManagement", - "Estate Managememt REST Scope", - "A scope for Estate Managememt REST"}); table30.AddRow(new string[] { "transactionProcessor", "Transaction Processor REST Scope", "A scope for Transaction Processor REST"}); - table30.AddRow(new string[] { - "voucherManagement", - "Voucher Management REST Scope", - "A scope for Voucher Management REST"}); table30.AddRow(new string[] { "fileProcessor", "File Processor REST Scope", @@ -140,31 +132,19 @@ public void ScenarioInitialize(global::Reqnroll.ScenarioInfo scenarioInfo, globa "Secret", "Scopes", "UserClaims"}); - table31.AddRow(new string[] { - "estateManagement", - "Estate Managememt REST", - "Secret1", - "estateManagement", - "MerchantId, EstateId, role"}); table31.AddRow(new string[] { "transactionProcessor", "Transaction Processor REST", "Secret1", "transactionProcessor", - ""}); - table31.AddRow(new string[] { - "voucherManagement", - "Voucher Management REST", - "Secret1", - "voucherManagement", - ""}); + "MerchantId, EstateId, role"}); table31.AddRow(new string[] { "fileProcessor", "File Processor REST", "Secret1", "fileProcessor", ""}); -#line 12 +#line 10 await testRunner.GivenAsync("the following api resources exist", ((string)(null)), table31, "Given "); #line hidden global::Reqnroll.Table table32 = new global::Reqnroll.Table(new string[] { @@ -177,16 +157,16 @@ public void ScenarioInitialize(global::Reqnroll.ScenarioInfo scenarioInfo, globa "serviceClient", "Service Client", "Secret1", - "estateManagement,transactionProcessor,voucherManagement,fileProcessor", + "transactionProcessor,fileProcessor", "client_credentials"}); -#line 19 +#line 15 await testRunner.GivenAsync("the following clients exist", ((string)(null)), table32, "Given "); #line hidden global::Reqnroll.Table table33 = new global::Reqnroll.Table(new string[] { "ClientId"}); table33.AddRow(new string[] { "serviceClient"}); -#line 23 +#line 19 await testRunner.GivenAsync("I have a token to access the estate management and transaction processor resource" + "s", ((string)(null)), table33, "Given "); #line hidden @@ -194,7 +174,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "EstateName"}); table34.AddRow(new string[] { "Test Estate 1"}); -#line 27 +#line 23 await testRunner.GivenAsync("I have created the following estates", ((string)(null)), table34, "Given "); #line hidden global::Reqnroll.Table table35 = new global::Reqnroll.Table(new string[] { @@ -212,7 +192,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Voucher", "True", "True"}); -#line 31 +#line 27 await testRunner.GivenAsync("I have created the following operators", ((string)(null)), table35, "Given "); #line hidden global::Reqnroll.Table table36 = new global::Reqnroll.Table(new string[] { @@ -224,7 +204,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and table36.AddRow(new string[] { "Test Estate 1", "Voucher"}); -#line 36 +#line 32 await testRunner.AndAsync("I have assigned the following operators to the estates", ((string)(null)), table36, "And "); #line hidden global::Reqnroll.Table table37 = new global::Reqnroll.Table(new string[] { @@ -239,7 +219,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Test Estate 1", "Voucher", "Hospital 1 Contract"}); -#line 41 +#line 37 await testRunner.GivenAsync("I create a contract with the following values", ((string)(null)), table37, "Given "); #line hidden global::Reqnroll.Table table38 = new global::Reqnroll.Table(new string[] { @@ -266,7 +246,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "10 KES", "", "Voucher"}); -#line 46 +#line 42 await testRunner.WhenAsync("I create the following Products", ((string)(null)), table38, "When "); #line hidden global::Reqnroll.Table table39 = new global::Reqnroll.Table(new string[] { @@ -285,7 +265,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Fixed", "Merchant Commission", "2.50"}); -#line 51 +#line 47 await testRunner.WhenAsync("I add the following Transaction Fees", ((string)(null)), table39, "When "); #line hidden global::Reqnroll.Table table40 = new global::Reqnroll.Table(new string[] { @@ -308,7 +288,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Test Contact 1", "testcontact1@merchant1.co.uk", "Test Estate 1"}); -#line 55 +#line 51 await testRunner.GivenAsync("I create the following merchants", ((string)(null)), table40, "Given "); #line hidden global::Reqnroll.Table table41 = new global::Reqnroll.Table(new string[] { @@ -329,7 +309,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "00000001", "10000001", "Test Estate 1"}); -#line 59 +#line 55 await testRunner.GivenAsync("I have assigned the following operator to the merchants", ((string)(null)), table41, "Given "); #line hidden global::Reqnroll.Table table42 = new global::Reqnroll.Table(new string[] { @@ -340,7 +320,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "123456780", "Test Merchant 1", "Test Estate 1"}); -#line 64 +#line 60 await testRunner.GivenAsync("I have assigned the following devices to the merchants", ((string)(null)), table42, "Given "); #line hidden global::Reqnroll.Table table43 = new global::Reqnroll.Table(new string[] { @@ -355,7 +335,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Test Estate 1", "Test Merchant 1", "Hospital 1 Contract"}); -#line 68 +#line 64 await testRunner.WhenAsync("I add the following contracts to the following merchants", ((string)(null)), table43, "When "); #line hidden global::Reqnroll.Table table44 = new global::Reqnroll.Table(new string[] { @@ -370,7 +350,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Today", "Test Merchant 1", "Test Estate 1"}); -#line 73 +#line 69 await testRunner.GivenAsync("I make the following manual merchant deposits", ((string)(null)), table44, "Given "); #line hidden } @@ -392,7 +372,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("Process Safaricom Topup File with 1 detail row", null, tagsOfScenario, argumentsOfScenario, featureTags, pickleIndex); string[] tagsOfRule = ((string[])(null)); global::Reqnroll.RuleInfo ruleInfo = null; -#line 78 +#line 74 this.ScenarioInitialize(scenarioInfo, ruleInfo); #line hidden if ((global::Reqnroll.TagHelper.ContainsIgnoreTag(scenarioInfo.CombinedTags) || global::Reqnroll.TagHelper.ContainsIgnoreTag(featureTags))) @@ -421,7 +401,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "T", "1", ""}); -#line 79 +#line 75 await testRunner.GivenAsync("I have a file named \'SafarcomTopup.txt\' with the following contents", ((string)(null)), table45, "Given "); #line hidden global::Reqnroll.Table table46 = new global::Reqnroll.Table(new string[] { @@ -434,7 +414,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Test Merchant 1", "B2A59ABF-293D-4A6B-B81B-7007503C3476", "ABA59ABF-293D-4A6B-B81B-7007503C3476"}); -#line 84 +#line 80 await testRunner.AndAsync("I upload this file for processing", ((string)(null)), table46, "And "); #line hidden } @@ -453,7 +433,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("Process Safaricom Topup File with 2 detail rows", null, tagsOfScenario, argumentsOfScenario, featureTags, pickleIndex); string[] tagsOfRule = ((string[])(null)); global::Reqnroll.RuleInfo ruleInfo = null; -#line 91 +#line 87 this.ScenarioInitialize(scenarioInfo, ruleInfo); #line hidden if ((global::Reqnroll.TagHelper.ContainsIgnoreTag(scenarioInfo.CombinedTags) || global::Reqnroll.TagHelper.ContainsIgnoreTag(featureTags))) @@ -486,7 +466,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "T", "2", ""}); -#line 92 +#line 88 await testRunner.GivenAsync("I have a file named \'SafarcomTopup.txt\' with the following contents", ((string)(null)), table47, "Given "); #line hidden global::Reqnroll.Table table48 = new global::Reqnroll.Table(new string[] { @@ -499,7 +479,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Test Merchant 1", "B2A59ABF-293D-4A6B-B81B-7007503C3476", "ABA59ABF-293D-4A6B-B81B-7007503C3476"}); -#line 98 +#line 94 await testRunner.AndAsync("I upload this file for processing", ((string)(null)), table48, "And "); #line hidden } @@ -518,7 +498,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("Process 2 Safaricom Topup Files", null, tagsOfScenario, argumentsOfScenario, featureTags, pickleIndex); string[] tagsOfRule = ((string[])(null)); global::Reqnroll.RuleInfo ruleInfo = null; -#line 105 +#line 101 this.ScenarioInitialize(scenarioInfo, ruleInfo); #line hidden if ((global::Reqnroll.TagHelper.ContainsIgnoreTag(scenarioInfo.CombinedTags) || global::Reqnroll.TagHelper.ContainsIgnoreTag(featureTags))) @@ -547,7 +527,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "T", "1", ""}); -#line 106 +#line 102 await testRunner.GivenAsync("I have a file named \'SafarcomTopup1.txt\' with the following contents", ((string)(null)), table49, "Given "); #line hidden global::Reqnroll.Table table50 = new global::Reqnroll.Table(new string[] { @@ -560,7 +540,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Test Merchant 1", "B2A59ABF-293D-4A6B-B81B-7007503C3476", "ABA59ABF-293D-4A6B-B81B-7007503C3476"}); -#line 111 +#line 107 await testRunner.AndAsync("I upload this file for processing", ((string)(null)), table50, "And "); #line hidden global::Reqnroll.Table table51 = new global::Reqnroll.Table(new string[] { @@ -583,7 +563,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "T", "2", ""}); -#line 115 +#line 111 await testRunner.GivenAsync("I have a file named \'SafarcomTopup2.txt\' with the following contents", ((string)(null)), table51, "Given "); #line hidden global::Reqnroll.Table table52 = new global::Reqnroll.Table(new string[] { @@ -596,7 +576,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Test Merchant 1", "B2A59ABF-293D-4A6B-B81B-7007503C3476", "ABA59ABF-293D-4A6B-B81B-7007503C3476"}); -#line 121 +#line 117 await testRunner.AndAsync("I upload this file for processing", ((string)(null)), table52, "And "); #line hidden } @@ -617,7 +597,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("Process Duplicate Safaricom Topup File with 1 detail row", null, tagsOfScenario, argumentsOfScenario, featureTags, pickleIndex); string[] tagsOfRule = ((string[])(null)); global::Reqnroll.RuleInfo ruleInfo = null; -#line 129 +#line 125 this.ScenarioInitialize(scenarioInfo, ruleInfo); #line hidden if ((global::Reqnroll.TagHelper.ContainsIgnoreTag(scenarioInfo.CombinedTags) || global::Reqnroll.TagHelper.ContainsIgnoreTag(featureTags))) @@ -650,7 +630,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "T", "1", ""}); -#line 130 +#line 126 await testRunner.GivenAsync("I have a file named \'SafarcomTopup1.txt\' with the following contents", ((string)(null)), table53, "Given "); #line hidden global::Reqnroll.Table table54 = new global::Reqnroll.Table(new string[] { @@ -663,7 +643,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Test Merchant 1", "B2A59ABF-293D-4A6B-B81B-7007503C3476", "ABA59ABF-293D-4A6B-B81B-7007503C3476"}); -#line 136 +#line 132 await testRunner.AndAsync("I upload this file for processing", ((string)(null)), table54, "And "); #line hidden global::Reqnroll.Table table55 = new global::Reqnroll.Table(new string[] { @@ -686,7 +666,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "T", "1", ""}); -#line 142 +#line 138 await testRunner.GivenAsync("I have a file named \'SafarcomTopup2.txt\' with the following contents", ((string)(null)), table55, "Given "); #line hidden global::Reqnroll.Table table56 = new global::Reqnroll.Table(new string[] { @@ -699,7 +679,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Test Merchant 1", "B2A59ABF-293D-4A6B-B81B-7007503C3476", "ABA59ABF-293D-4A6B-B81B-7007503C3476"}); -#line 148 +#line 144 await testRunner.AndAsync("I upload this file for processing an error should be returned indicating the file" + " is a duplicate", ((string)(null)), table56, "And "); #line hidden @@ -719,7 +699,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("Process Safaricom Topup File with Upload Date Time", null, tagsOfScenario, argumentsOfScenario, featureTags, pickleIndex); string[] tagsOfRule = ((string[])(null)); global::Reqnroll.RuleInfo ruleInfo = null; -#line 154 +#line 150 this.ScenarioInitialize(scenarioInfo, ruleInfo); #line hidden if ((global::Reqnroll.TagHelper.ContainsIgnoreTag(scenarioInfo.CombinedTags) || global::Reqnroll.TagHelper.ContainsIgnoreTag(featureTags))) @@ -748,7 +728,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "T", "1", ""}); -#line 155 +#line 151 await testRunner.GivenAsync("I have a file named \'SafarcomTopup.txt\' with the following contents", ((string)(null)), table57, "Given "); #line hidden global::Reqnroll.Table table58 = new global::Reqnroll.Table(new string[] { @@ -763,10 +743,10 @@ await testRunner.GivenAsync("I have a token to access the estate management and "B2A59ABF-293D-4A6B-B81B-7007503C3476", "ABA59ABF-293D-4A6B-B81B-7007503C3476", "Today"}); -#line 160 +#line 156 await testRunner.AndAsync("I upload this file for processing", ((string)(null)), table58, "And "); #line hidden -#line 164 +#line 160 await testRunner.WhenAsync("I get the import log for estate \'Test Estate 1\' the date on the import log is \'To" + "day\'", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); #line hidden @@ -786,7 +766,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "T", "1", ""}); -#line 166 +#line 162 await testRunner.GivenAsync("I have a file named \'SafarcomTopup1.txt\' with the following contents", ((string)(null)), table59, "Given "); #line hidden global::Reqnroll.Table table60 = new global::Reqnroll.Table(new string[] { @@ -801,10 +781,10 @@ await testRunner.GivenAsync("I have a token to access the estate management and "B2A59ABF-293D-4A6B-B81B-7007503C3476", "ABA59ABF-293D-4A6B-B81B-7007503C3476", "01/09/2021"}); -#line 171 +#line 167 await testRunner.AndAsync("I upload this file for processing", ((string)(null)), table60, "And "); #line hidden -#line 175 +#line 171 await testRunner.WhenAsync("I get the import log for estate \'Test Estate 1\' the date on the import log is \'01" + "/09/2021\'", ((string)(null)), ((global::Reqnroll.Table)(null)), "When "); #line hidden diff --git a/FileProcessor.IntegrationTests/Features/ProcessVoucherCSV.feature b/FileProcessor.IntegrationTests/Features/ProcessVoucherCSV.feature index bea65b6..50808dd 100644 --- a/FileProcessor.IntegrationTests/Features/ProcessVoucherCSV.feature +++ b/FileProcessor.IntegrationTests/Features/ProcessVoucherCSV.feature @@ -4,21 +4,17 @@ Feature: Process Voucher CSV Files Background: Given I create the following api scopes | Name | DisplayName | Description | - | estateManagement | Estate Managememt REST Scope | A scope for Estate Managememt REST | | transactionProcessor | Transaction Processor REST Scope | A scope for Transaction Processor REST | - | voucherManagement | Voucher Management REST Scope | A scope for Voucher Management REST | | fileProcessor | File Processor REST Scope | A scope for File Processor REST | Given the following api resources exist | Name | DisplayName | Secret | Scopes | UserClaims | - | estateManagement | Estate Managememt REST | Secret1 | estateManagement | MerchantId, EstateId, role | - | transactionProcessor | Transaction Processor REST | Secret1 | transactionProcessor | | - | voucherManagement | Voucher Management REST | Secret1 | voucherManagement | | + | transactionProcessor | Transaction Processor REST | Secret1 | transactionProcessor | MerchantId, EstateId, role | | fileProcessor | File Processor REST | Secret1 | fileProcessor | | Given the following clients exist | ClientId | ClientName | Secret | Scopes | GrantTypes | - | serviceClient | Service Client | Secret1 | estateManagement,transactionProcessor,voucherManagement,fileProcessor | client_credentials | + | serviceClient | Service Client | Secret1 | transactionProcessor,fileProcessor | client_credentials | Given I have a token to access the estate management and transaction processor resources | ClientId | diff --git a/FileProcessor.IntegrationTests/Features/ProcessVoucherCSV.feature.cs b/FileProcessor.IntegrationTests/Features/ProcessVoucherCSV.feature.cs index df8b6ae..6387541 100644 --- a/FileProcessor.IntegrationTests/Features/ProcessVoucherCSV.feature.cs +++ b/FileProcessor.IntegrationTests/Features/ProcessVoucherCSV.feature.cs @@ -117,18 +117,10 @@ public void ScenarioInitialize(global::Reqnroll.ScenarioInfo scenarioInfo, globa "Name", "DisplayName", "Description"}); - table61.AddRow(new string[] { - "estateManagement", - "Estate Managememt REST Scope", - "A scope for Estate Managememt REST"}); table61.AddRow(new string[] { "transactionProcessor", "Transaction Processor REST Scope", "A scope for Transaction Processor REST"}); - table61.AddRow(new string[] { - "voucherManagement", - "Voucher Management REST Scope", - "A scope for Voucher Management REST"}); table61.AddRow(new string[] { "fileProcessor", "File Processor REST Scope", @@ -142,31 +134,19 @@ public void ScenarioInitialize(global::Reqnroll.ScenarioInfo scenarioInfo, globa "Secret", "Scopes", "UserClaims"}); - table62.AddRow(new string[] { - "estateManagement", - "Estate Managememt REST", - "Secret1", - "estateManagement", - "MerchantId, EstateId, role"}); table62.AddRow(new string[] { "transactionProcessor", "Transaction Processor REST", "Secret1", "transactionProcessor", - ""}); - table62.AddRow(new string[] { - "voucherManagement", - "Voucher Management REST", - "Secret1", - "voucherManagement", - ""}); + "MerchantId, EstateId, role"}); table62.AddRow(new string[] { "fileProcessor", "File Processor REST", "Secret1", "fileProcessor", ""}); -#line 12 +#line 10 await testRunner.GivenAsync("the following api resources exist", ((string)(null)), table62, "Given "); #line hidden global::Reqnroll.Table table63 = new global::Reqnroll.Table(new string[] { @@ -179,16 +159,16 @@ public void ScenarioInitialize(global::Reqnroll.ScenarioInfo scenarioInfo, globa "serviceClient", "Service Client", "Secret1", - "estateManagement,transactionProcessor,voucherManagement,fileProcessor", + "transactionProcessor,fileProcessor", "client_credentials"}); -#line 19 +#line 15 await testRunner.GivenAsync("the following clients exist", ((string)(null)), table63, "Given "); #line hidden global::Reqnroll.Table table64 = new global::Reqnroll.Table(new string[] { "ClientId"}); table64.AddRow(new string[] { "serviceClient"}); -#line 23 +#line 19 await testRunner.GivenAsync("I have a token to access the estate management and transaction processor resource" + "s", ((string)(null)), table64, "Given "); #line hidden @@ -196,7 +176,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "EstateName"}); table65.AddRow(new string[] { "Test Estate 1"}); -#line 27 +#line 23 await testRunner.GivenAsync("I have created the following estates", ((string)(null)), table65, "Given "); #line hidden global::Reqnroll.Table table66 = new global::Reqnroll.Table(new string[] { @@ -214,7 +194,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Voucher", "True", "True"}); -#line 31 +#line 27 await testRunner.GivenAsync("I have created the following operators", ((string)(null)), table66, "Given "); #line hidden global::Reqnroll.Table table67 = new global::Reqnroll.Table(new string[] { @@ -226,7 +206,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and table67.AddRow(new string[] { "Test Estate 1", "Voucher"}); -#line 36 +#line 32 await testRunner.AndAsync("I have assigned the following operators to the estates", ((string)(null)), table67, "And "); #line hidden global::Reqnroll.Table table68 = new global::Reqnroll.Table(new string[] { @@ -241,7 +221,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Test Estate 1", "Voucher", "Hospital 1 Contract"}); -#line 41 +#line 37 await testRunner.GivenAsync("I create a contract with the following values", ((string)(null)), table68, "Given "); #line hidden global::Reqnroll.Table table69 = new global::Reqnroll.Table(new string[] { @@ -268,7 +248,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Custom", "", "Voucher"}); -#line 46 +#line 42 await testRunner.WhenAsync("I create the following Products", ((string)(null)), table69, "When "); #line hidden global::Reqnroll.Table table70 = new global::Reqnroll.Table(new string[] { @@ -295,7 +275,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Fixed", "Merchant Commission", "2.50"}); -#line 51 +#line 47 await testRunner.WhenAsync("I add the following Transaction Fees", ((string)(null)), table70, "When "); #line hidden global::Reqnroll.Table table71 = new global::Reqnroll.Table(new string[] { @@ -318,7 +298,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Test Contact 1", "testcontact1@merchant1.co.uk", "Test Estate 1"}); -#line 56 +#line 52 await testRunner.GivenAsync("I create the following merchants", ((string)(null)), table71, "Given "); #line hidden global::Reqnroll.Table table72 = new global::Reqnroll.Table(new string[] { @@ -339,7 +319,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "00000001", "10000001", "Test Estate 1"}); -#line 60 +#line 56 await testRunner.GivenAsync("I have assigned the following operator to the merchants", ((string)(null)), table72, "Given "); #line hidden global::Reqnroll.Table table73 = new global::Reqnroll.Table(new string[] { @@ -350,7 +330,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "123456780", "Test Merchant 1", "Test Estate 1"}); -#line 65 +#line 61 await testRunner.GivenAsync("I have assigned the following devices to the merchants", ((string)(null)), table73, "Given "); #line hidden global::Reqnroll.Table table74 = new global::Reqnroll.Table(new string[] { @@ -365,7 +345,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Test Estate 1", "Test Merchant 1", "Hospital 1 Contract"}); -#line 69 +#line 65 await testRunner.WhenAsync("I add the following contracts to the following merchants", ((string)(null)), table74, "When "); #line hidden global::Reqnroll.Table table75 = new global::Reqnroll.Table(new string[] { @@ -380,7 +360,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Today", "Test Merchant 1", "Test Estate 1"}); -#line 74 +#line 70 await testRunner.GivenAsync("I make the following manual merchant deposits", ((string)(null)), table75, "Given "); #line hidden } @@ -402,7 +382,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("Process Voucher File with 1 detail row for recipient email", null, tagsOfScenario, argumentsOfScenario, featureTags, pickleIndex); string[] tagsOfRule = ((string[])(null)); global::Reqnroll.RuleInfo ruleInfo = null; -#line 79 +#line 75 this.ScenarioInitialize(scenarioInfo, ruleInfo); #line hidden if ((global::Reqnroll.TagHelper.ContainsIgnoreTag(scenarioInfo.CombinedTags) || global::Reqnroll.TagHelper.ContainsIgnoreTag(featureTags))) @@ -435,7 +415,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "1", "", ""}); -#line 80 +#line 76 await testRunner.GivenAsync("I have a file named \'VoucherIssue.txt\' with the following contents", ((string)(null)), table76, "Given "); #line hidden global::Reqnroll.Table table77 = new global::Reqnroll.Table(new string[] { @@ -448,7 +428,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Test Merchant 1", "8806EDBC-3ED6-406B-9E5F-A9078356BE99", "ABA59ABF-293D-4A6B-B81B-7007503C3476"}); -#line 85 +#line 81 await testRunner.AndAsync("I upload this file for processing", ((string)(null)), table77, "And "); #line hidden } @@ -467,7 +447,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("Process Voucher File with 1 detail row for recipient mobile", null, tagsOfScenario, argumentsOfScenario, featureTags, pickleIndex); string[] tagsOfRule = ((string[])(null)); global::Reqnroll.RuleInfo ruleInfo = null; -#line 92 +#line 88 this.ScenarioInitialize(scenarioInfo, ruleInfo); #line hidden if ((global::Reqnroll.TagHelper.ContainsIgnoreTag(scenarioInfo.CombinedTags) || global::Reqnroll.TagHelper.ContainsIgnoreTag(featureTags))) @@ -500,7 +480,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "1", "", ""}); -#line 93 +#line 89 await testRunner.GivenAsync("I have a file named \'VoucherIssue.txt\' with the following contents", ((string)(null)), table78, "Given "); #line hidden global::Reqnroll.Table table79 = new global::Reqnroll.Table(new string[] { @@ -513,7 +493,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Test Merchant 1", "8806EDBC-3ED6-406B-9E5F-A9078356BE99", "ABA59ABF-293D-4A6B-B81B-7007503C3476"}); -#line 98 +#line 94 await testRunner.AndAsync("I upload this file for processing", ((string)(null)), table79, "And "); #line hidden } @@ -532,7 +512,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("Process Voucher File with 2 detail rows", null, tagsOfScenario, argumentsOfScenario, featureTags, pickleIndex); string[] tagsOfRule = ((string[])(null)); global::Reqnroll.RuleInfo ruleInfo = null; -#line 105 +#line 101 this.ScenarioInitialize(scenarioInfo, ruleInfo); #line hidden if ((global::Reqnroll.TagHelper.ContainsIgnoreTag(scenarioInfo.CombinedTags) || global::Reqnroll.TagHelper.ContainsIgnoreTag(featureTags))) @@ -570,7 +550,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "1", "", ""}); -#line 106 +#line 102 await testRunner.GivenAsync("I have a file named \'VoucherIssue.txt\' with the following contents", ((string)(null)), table80, "Given "); #line hidden global::Reqnroll.Table table81 = new global::Reqnroll.Table(new string[] { @@ -583,7 +563,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Test Merchant 1", "8806EDBC-3ED6-406B-9E5F-A9078356BE99", "ABA59ABF-293D-4A6B-B81B-7007503C3476"}); -#line 112 +#line 108 await testRunner.AndAsync("I upload this file for processing", ((string)(null)), table81, "And "); #line hidden } @@ -602,7 +582,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("Process 2 Voucher Files", null, tagsOfScenario, argumentsOfScenario, featureTags, pickleIndex); string[] tagsOfRule = ((string[])(null)); global::Reqnroll.RuleInfo ruleInfo = null; -#line 119 +#line 115 this.ScenarioInitialize(scenarioInfo, ruleInfo); #line hidden if ((global::Reqnroll.TagHelper.ContainsIgnoreTag(scenarioInfo.CombinedTags) || global::Reqnroll.TagHelper.ContainsIgnoreTag(featureTags))) @@ -640,7 +620,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "1", "", ""}); -#line 120 +#line 116 await testRunner.GivenAsync("I have a file named \'VoucherIssue1.txt\' with the following contents", ((string)(null)), table82, "Given "); #line hidden global::Reqnroll.Table table83 = new global::Reqnroll.Table(new string[] { @@ -653,7 +633,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Test Merchant 1", "8806EDBC-3ED6-406B-9E5F-A9078356BE99", "ABA59ABF-293D-4A6B-B81B-7007503C3476"}); -#line 126 +#line 122 await testRunner.AndAsync("I upload this file for processing", ((string)(null)), table83, "And "); #line hidden global::Reqnroll.Table table84 = new global::Reqnroll.Table(new string[] { @@ -681,7 +661,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "1", "", ""}); -#line 130 +#line 126 await testRunner.GivenAsync("I have a file named \'VoucherIssue2.txt\' with the following contents", ((string)(null)), table84, "Given "); #line hidden global::Reqnroll.Table table85 = new global::Reqnroll.Table(new string[] { @@ -694,7 +674,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Test Merchant 1", "8806EDBC-3ED6-406B-9E5F-A9078356BE99", "ABA59ABF-293D-4A6B-B81B-7007503C3476"}); -#line 136 +#line 132 await testRunner.AndAsync("I upload this file for processing", ((string)(null)), table85, "And "); #line hidden } @@ -715,7 +695,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("Process Duplicate Voucher Topup File with 1 detail row", null, tagsOfScenario, argumentsOfScenario, featureTags, pickleIndex); string[] tagsOfRule = ((string[])(null)); global::Reqnroll.RuleInfo ruleInfo = null; -#line 144 +#line 140 this.ScenarioInitialize(scenarioInfo, ruleInfo); #line hidden if ((global::Reqnroll.TagHelper.ContainsIgnoreTag(scenarioInfo.CombinedTags) || global::Reqnroll.TagHelper.ContainsIgnoreTag(featureTags))) @@ -753,7 +733,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "1", "", ""}); -#line 145 +#line 141 await testRunner.GivenAsync("I have a file named \'VoucherIssue1.txt\' with the following contents", ((string)(null)), table86, "Given "); #line hidden global::Reqnroll.Table table87 = new global::Reqnroll.Table(new string[] { @@ -766,7 +746,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Test Merchant 1", "8806EDBC-3ED6-406B-9E5F-A9078356BE99", "ABA59ABF-293D-4A6B-B81B-7007503C3476"}); -#line 151 +#line 147 await testRunner.AndAsync("I upload this file for processing", ((string)(null)), table87, "And "); #line hidden global::Reqnroll.Table table88 = new global::Reqnroll.Table(new string[] { @@ -794,7 +774,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "1", "", ""}); -#line 157 +#line 153 await testRunner.GivenAsync("I have a file named \'VoucherIssue2.txt\' with the following contents", ((string)(null)), table88, "Given "); #line hidden global::Reqnroll.Table table89 = new global::Reqnroll.Table(new string[] { @@ -807,7 +787,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Test Merchant 1", "8806EDBC-3ED6-406B-9E5F-A9078356BE99", "ABA59ABF-293D-4A6B-B81B-7007503C3476"}); -#line 164 +#line 160 await testRunner.AndAsync("I upload this file for processing an error should be returned indicating the file" + " is a duplicate", ((string)(null)), table89, "And "); #line hidden diff --git a/FileProcessor.Testing/TestData.cs b/FileProcessor.Testing/TestData.cs index 3a06950..9d6de4a 100644 --- a/FileProcessor.Testing/TestData.cs +++ b/FileProcessor.Testing/TestData.cs @@ -324,6 +324,7 @@ public static FileAggregate GetFileAggregateWithLinesAlreadyProcessed() ["ConnectionStrings:HealthCheck"] = "HeathCheckConnString", ["ConnectionStrings:TransactionProcessorReadModel"] = "EstateReportingReadModel", ["SecurityConfiguration:Authority"] = "https://127.0.0.1", + ["SecurityConfiguration:ApiName"] = "ApiName", ["EventStoreSettings:ConnectionString"] = "esdb://127.0.0.1:2113", ["EventStoreSettings:ConnectionName"] = "UnitTestConnection", ["EventStoreSettings:UserName"] = "admin", diff --git a/FileProcessor.Tests/BootstrapperTests.cs b/FileProcessor.Tests/BootstrapperTests.cs deleted file mode 100644 index 6262670..0000000 --- a/FileProcessor.Tests/BootstrapperTests.cs +++ /dev/null @@ -1,58 +0,0 @@ -using FileProcessor.Testing; - -namespace FileProcessor.Tests -{ - using System; - using System.Collections.Generic; - using System.Diagnostics; - using Lamar; - using Microsoft.AspNetCore.Hosting; - using Microsoft.Extensions.Configuration; - using Microsoft.Extensions.DependencyInjection; - using Microsoft.Extensions.Hosting; - using Moq; - using SecurityService.Client; - using Xunit; - - public class BootstrapperTests - { - [Fact] - public void VerifyBootstrapperIsValid() - { - Mock hostingEnvironment = new Mock(); - hostingEnvironment.Setup(he => he.EnvironmentName).Returns("Development"); - hostingEnvironment.Setup(he => he.ContentRootPath).Returns("/home"); - hostingEnvironment.Setup(he => he.ApplicationName).Returns("Test Application"); - - ServiceRegistry services = new ServiceRegistry(); - Startup s = new Startup(hostingEnvironment.Object); - Startup.Configuration = this.SetupMemoryConfiguration(); - - this.AddTestRegistrations(services, hostingEnvironment.Object); - s.ConfigureContainer(services); - - Startup.Container.AssertConfigurationIsValid(AssertMode.Full); - } - - private IConfigurationRoot SetupMemoryConfiguration() - { - IConfigurationBuilder builder = new ConfigurationBuilder(); - - builder.AddInMemoryCollection(TestData.DefaultAppSettings); - - return builder.Build(); - } - - private void AddTestRegistrations(ServiceRegistry services, - IWebHostEnvironment hostingEnvironment) - { - services.AddLogging(); - DiagnosticListener diagnosticSource = new DiagnosticListener(hostingEnvironment.ApplicationName); - services.AddSingleton(diagnosticSource); - services.AddSingleton(diagnosticSource); - services.AddSingleton(hostingEnvironment); - services.AddSingleton(hostingEnvironment); - services.AddSingleton(Startup.Configuration); - } - } -} \ No newline at end of file diff --git a/FileProcessor/Bootstrapper/MiddlewareRegistry.cs b/FileProcessor/Bootstrapper/MiddlewareRegistry.cs index dc5f7e3..2cce7b7 100644 --- a/FileProcessor/Bootstrapper/MiddlewareRegistry.cs +++ b/FileProcessor/Bootstrapper/MiddlewareRegistry.cs @@ -12,6 +12,7 @@ namespace FileProcessor.Bootstrapper using Microsoft.IdentityModel.Tokens; using Newtonsoft.Json; using Newtonsoft.Json.Serialization; + using OpenIddict.Validation.AspNetCore; using Shared.Authorisation; using Shared.EventStore.Extensions; using Shared.Extensions; @@ -73,33 +74,35 @@ public MiddlewareRegistry() this.AddAuthentication(options => - { - options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; - options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; - options.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; - }).AddJwtBearer(options => - { - options.BackchannelHttpHandler = new HttpClientHandler - { - ServerCertificateCustomValidationCallback = (message, - certificate, - chain, - sslPolicyErrors) => true - }; - options.Authority = ConfigurationReader.GetValue("SecurityConfiguration", "Authority"); - options.Audience = ConfigurationReader.GetValue("SecurityConfiguration", "ApiName"); - - options.TokenValidationParameters = new TokenValidationParameters - { - ValidateAudience = false, - ValidAudience = - ConfigurationReader.GetValue("SecurityConfiguration", "ApiName"), - ValidIssuer = - ConfigurationReader.GetValue("SecurityConfiguration", "Authority"), - }; - options.IncludeErrorDetails = true; - }); + { + options.DefaultScheme = OpenIddictValidationAspNetCoreDefaults.AuthenticationScheme; + }); + + this.AddOpenIddict() + .AddValidation(options => + { + // Same as your Authority + options.SetIssuer(new Uri(ConfigurationReader.GetValue("SecurityConfiguration", "Authority"))); + + // Enables discovery and HTTP backchannel support + options.UseSystemNetHttp() + .ConfigureHttpClientHandler(handler => + { + // DEV ONLY: bypass all certificate errors + handler.ServerCertificateCustomValidationCallback = + HttpClientHandler.DangerousAcceptAnyServerCertificateValidator; + }); + + // Register the ASP.NET Core integration + options.UseAspNetCore(); + + // Optionally set expected audience(s): + options.AddAudiences(ConfigurationReader.GetValue("SecurityConfiguration", "ApiName")); + + }); + this.AddAuthorization(); + this.AddControllers().AddNewtonsoftJson(options => { options.SerializerSettings.Culture = new CultureInfo("en-GB"); diff --git a/FileProcessor/FileProcessor.csproj b/FileProcessor/FileProcessor.csproj index 72652ec..d7661fe 100644 --- a/FileProcessor/FileProcessor.csproj +++ b/FileProcessor/FileProcessor.csproj @@ -6,6 +6,8 @@ + +