diff --git a/EstateManagement.BusinessLogic/Services/EstateDomainService.cs b/EstateManagement.BusinessLogic/Services/EstateDomainService.cs index ed541c58..b13609e5 100644 --- a/EstateManagement.BusinessLogic/Services/EstateDomainService.cs +++ b/EstateManagement.BusinessLogic/Services/EstateDomainService.cs @@ -124,7 +124,7 @@ public async Task CreateEstateUser(Guid estateId, Claims = new Dictionary() }; - //createUserRequest.Roles.Add("Estate"); + createUserRequest.Roles.Add("Estate"); createUserRequest.Claims.Add("EstateId", estateId.ToString()); CreateUserResponse createUserResponse = await this.SecurityServiceClient.CreateUser(createUserRequest, cancellationToken); diff --git a/EstateManagement.BusinessLogic/Services/MerchantDomainService.cs b/EstateManagement.BusinessLogic/Services/MerchantDomainService.cs index 114187fd..a368bc7c 100644 --- a/EstateManagement.BusinessLogic/Services/MerchantDomainService.cs +++ b/EstateManagement.BusinessLogic/Services/MerchantDomainService.cs @@ -197,7 +197,7 @@ public async Task CreateMerchantUser(Guid estateId, Claims = new Dictionary() }; - //createUserRequest.Roles.Add("Estate"); + createUserRequest.Roles.Add("Merchant"); createUserRequest.Claims.Add("EstateId", estateId.ToString()); createUserRequest.Claims.Add("MerchantId", merchantId.ToString()); diff --git a/EstateManagement.IntegrationTests/Common/DockerHelper.cs b/EstateManagement.IntegrationTests/Common/DockerHelper.cs index 5575b1d1..4bd9ac5e 100644 --- a/EstateManagement.IntegrationTests/Common/DockerHelper.cs +++ b/EstateManagement.IntegrationTests/Common/DockerHelper.cs @@ -31,6 +31,7 @@ public class DockerHelper protected IContainerService EventStoreContainer; public IEstateClient EstateClient; + protected HttpClient HttpClient; protected String EventStoreConnectionString; diff --git a/EstateManagement.IntegrationTests/Estate/Estate.feature b/EstateManagement.IntegrationTests/Estate/Estate.feature index fab50c6d..9135d30d 100644 --- a/EstateManagement.IntegrationTests/Estate/Estate.feature +++ b/EstateManagement.IntegrationTests/Estate/Estate.feature @@ -2,6 +2,9 @@ Feature: Estate Background: + Given the following security roles exist + | RoleName | + | Estate | Scenario: Create Estate When I create the following estates @@ -13,6 +16,7 @@ Scenario: Create Operator Given I have created the following estates | EstateName | | Test Estate 1 | + When I create the following operators | EstateName | OperatorName | RequireCustomMerchantNumber | RequireCustomTerminalNumber | | Test Estate 1 | Test Operator 1 | True | True | diff --git a/EstateManagement.IntegrationTests/Estate/Estate.feature.cs b/EstateManagement.IntegrationTests/Estate/Estate.feature.cs index b25ea7fa..8549a646 100644 --- a/EstateManagement.IntegrationTests/Estate/Estate.feature.cs +++ b/EstateManagement.IntegrationTests/Estate/Estate.feature.cs @@ -84,6 +84,13 @@ public virtual void ScenarioCleanup() public virtual void FeatureBackground() { #line 4 +#line hidden + TechTalk.SpecFlow.Table table1 = new TechTalk.SpecFlow.Table(new string[] { + "RoleName"}); + table1.AddRow(new string[] { + "Estate"}); +#line 5 + testRunner.Given("the following security roles exist", ((string)(null)), table1, "Given "); #line hidden } @@ -99,7 +106,7 @@ public virtual void CreateEstate() { string[] tagsOfScenario = ((string[])(null)); TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Create Estate", null, ((string[])(null))); -#line 6 +#line 9 this.ScenarioInitialize(scenarioInfo); #line hidden bool isScenarioIgnored = default(bool); @@ -122,12 +129,12 @@ public virtual void CreateEstate() #line 4 this.FeatureBackground(); #line hidden - TechTalk.SpecFlow.Table table1 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table2 = new TechTalk.SpecFlow.Table(new string[] { "EstateName"}); - table1.AddRow(new string[] { + table2.AddRow(new string[] { "Test Estate 1"}); -#line 7 - testRunner.When("I create the following estates", ((string)(null)), table1, "When "); +#line 10 + testRunner.When("I create the following estates", ((string)(null)), table2, "When "); #line hidden } this.ScenarioCleanup(); @@ -143,7 +150,7 @@ public virtual void CreateOperator() "PRTest"}; TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Create Operator", null, new string[] { "PRTest"}); -#line 12 +#line 15 this.ScenarioInitialize(scenarioInfo); #line hidden bool isScenarioIgnored = default(bool); @@ -166,25 +173,25 @@ public virtual void CreateOperator() #line 4 this.FeatureBackground(); #line hidden - TechTalk.SpecFlow.Table table2 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table3 = new TechTalk.SpecFlow.Table(new string[] { "EstateName"}); - table2.AddRow(new string[] { + table3.AddRow(new string[] { "Test Estate 1"}); -#line 13 - testRunner.Given("I have created the following estates", ((string)(null)), table2, "Given "); +#line 16 + testRunner.Given("I have created the following estates", ((string)(null)), table3, "Given "); #line hidden - TechTalk.SpecFlow.Table table3 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table4 = new TechTalk.SpecFlow.Table(new string[] { "EstateName", "OperatorName", "RequireCustomMerchantNumber", "RequireCustomTerminalNumber"}); - table3.AddRow(new string[] { + table4.AddRow(new string[] { "Test Estate 1", "Test Operator 1", "True", "True"}); -#line 16 - testRunner.When("I create the following operators", ((string)(null)), table3, "When "); +#line 20 + testRunner.When("I create the following operators", ((string)(null)), table4, "When "); #line hidden } this.ScenarioCleanup(); @@ -200,7 +207,7 @@ public virtual void CreateSecurityUser() "PRTest"}; TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Create Security User", null, new string[] { "PRTest"}); -#line 21 +#line 25 this.ScenarioInitialize(scenarioInfo); #line hidden bool isScenarioIgnored = default(bool); @@ -223,27 +230,27 @@ public virtual void CreateSecurityUser() #line 4 this.FeatureBackground(); #line hidden - TechTalk.SpecFlow.Table table4 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table5 = new TechTalk.SpecFlow.Table(new string[] { "EstateName"}); - table4.AddRow(new string[] { + table5.AddRow(new string[] { "Test Estate 1"}); -#line 22 - testRunner.Given("I have created the following estates", ((string)(null)), table4, "Given "); +#line 26 + testRunner.Given("I have created the following estates", ((string)(null)), table5, "Given "); #line hidden - TechTalk.SpecFlow.Table table5 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table6 = new TechTalk.SpecFlow.Table(new string[] { "EmailAddress", "Password", "GivenName", "FamilyName", "EstateName"}); - table5.AddRow(new string[] { + table6.AddRow(new string[] { "estateuser1@testestate1.co.uk", "123456", "TestEstate", "User1", "Test Estate 1"}); -#line 25 - testRunner.When("I create the following security users", ((string)(null)), table5, "When "); +#line 29 + testRunner.When("I create the following security users", ((string)(null)), table6, "When "); #line hidden } this.ScenarioCleanup(); diff --git a/EstateManagement.IntegrationTests/EstateManagement.IntegrationTests.csproj b/EstateManagement.IntegrationTests/EstateManagement.IntegrationTests.csproj index 2b1b750e..68142f23 100644 --- a/EstateManagement.IntegrationTests/EstateManagement.IntegrationTests.csproj +++ b/EstateManagement.IntegrationTests/EstateManagement.IntegrationTests.csproj @@ -13,7 +13,7 @@ - + diff --git a/EstateManagement.IntegrationTests/Merchant/Merchant.feature b/EstateManagement.IntegrationTests/Merchant/Merchant.feature index 851963be..5575210e 100644 --- a/EstateManagement.IntegrationTests/Merchant/Merchant.feature +++ b/EstateManagement.IntegrationTests/Merchant/Merchant.feature @@ -5,29 +5,36 @@ Background: Given I have created the following estates | EstateName | | Test Estate 1 | + Given I have created the following operators | EstateName | OperatorName | RequireCustomMerchantNumber | RequireCustomTerminalNumber | | Test Estate 1 | Test Operator 1 | True | True | -Scenario: Create Merchant + Given the following security roles exist + | RoleName | + | Merchant | + +Scenario: Create Merchant When I create the following merchants | MerchantName | AddressLine1 | Town | Region | Country | ContactName | EmailAddress | EstateName | | Test Merchant 1 | Address Line 1 | TestTown | Test Region | United Kingdom | Test Contact 1 | testcontact1@merchant1.co.uk | Test Estate 1 | @PRTest -Scenario: Assign Operator To Merchant +Scenario: Assign Operator To Merchant Given I create the following merchants | MerchantName | AddressLine1 | Town | Region | Country | ContactName | EmailAddress | EstateName | | Test Merchant 1 | Address Line 1 | TestTown | Test Region | United Kingdom | Test Contact 1 | testcontact1@merchant1.co.uk | Test Estate 1 | + When I assign the following operator to the merchants | OperatorName | MerchantName | MerchantNumber | TerminalNumber | | Test Operator 1 | Test Merchant 1 | 00000001 | 10000001 | @PRTest -Scenario: Create Security User +Scenario: Create Security User Given I create the following merchants | MerchantName | AddressLine1 | Town | Region | Country | ContactName | EmailAddress | EstateName | | Test Merchant 1 | Address Line 1 | TestTown | Test Region | United Kingdom | Test Contact 1 | testcontact1@merchant1.co.uk | Test Estate 1 | + When I create the following security users | EmailAddress | Password | GivenName | FamilyName | MerchantName | | merchantuser1@testmerchant1.co.uk | 123456 | TestMerchant | User1 | Test Merchant 1 | diff --git a/EstateManagement.IntegrationTests/Merchant/Merchant.feature.cs b/EstateManagement.IntegrationTests/Merchant/Merchant.feature.cs index bddc900f..d4fd9385 100644 --- a/EstateManagement.IntegrationTests/Merchant/Merchant.feature.cs +++ b/EstateManagement.IntegrationTests/Merchant/Merchant.feature.cs @@ -85,25 +85,32 @@ public virtual void FeatureBackground() { #line 4 #line hidden - TechTalk.SpecFlow.Table table6 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table7 = new TechTalk.SpecFlow.Table(new string[] { "EstateName"}); - table6.AddRow(new string[] { + table7.AddRow(new string[] { "Test Estate 1"}); #line 5 - testRunner.Given("I have created the following estates", ((string)(null)), table6, "Given "); + testRunner.Given("I have created the following estates", ((string)(null)), table7, "Given "); #line hidden - TechTalk.SpecFlow.Table table7 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table8 = new TechTalk.SpecFlow.Table(new string[] { "EstateName", "OperatorName", "RequireCustomMerchantNumber", "RequireCustomTerminalNumber"}); - table7.AddRow(new string[] { + table8.AddRow(new string[] { "Test Estate 1", "Test Operator 1", "True", "True"}); -#line 8 - testRunner.Given("I have created the following operators", ((string)(null)), table7, "Given "); +#line 9 + testRunner.Given("I have created the following operators", ((string)(null)), table8, "Given "); +#line hidden + TechTalk.SpecFlow.Table table9 = new TechTalk.SpecFlow.Table(new string[] { + "RoleName"}); + table9.AddRow(new string[] { + "Estate"}); +#line 13 + testRunner.Given("the following security roles exist", ((string)(null)), table9, "Given "); #line hidden } @@ -119,7 +126,7 @@ public virtual void CreateMerchant() { string[] tagsOfScenario = ((string[])(null)); TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Create Merchant", null, ((string[])(null))); -#line 12 +#line 17 this.ScenarioInitialize(scenarioInfo); #line hidden bool isScenarioIgnored = default(bool); @@ -142,7 +149,7 @@ public virtual void CreateMerchant() #line 4 this.FeatureBackground(); #line hidden - TechTalk.SpecFlow.Table table8 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table10 = new TechTalk.SpecFlow.Table(new string[] { "MerchantName", "AddressLine1", "Town", @@ -151,7 +158,7 @@ public virtual void CreateMerchant() "ContactName", "EmailAddress", "EstateName"}); - table8.AddRow(new string[] { + table10.AddRow(new string[] { "Test Merchant 1", "Address Line 1", "TestTown", @@ -160,8 +167,8 @@ public virtual void CreateMerchant() "Test Contact 1", "testcontact1@merchant1.co.uk", "Test Estate 1"}); -#line 13 - testRunner.When("I create the following merchants", ((string)(null)), table8, "When "); +#line 18 + testRunner.When("I create the following merchants", ((string)(null)), table10, "When "); #line hidden } this.ScenarioCleanup(); @@ -177,7 +184,7 @@ public virtual void AssignOperatorToMerchant() "PRTest"}; TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Assign Operator To Merchant", null, new string[] { "PRTest"}); -#line 18 +#line 23 this.ScenarioInitialize(scenarioInfo); #line hidden bool isScenarioIgnored = default(bool); @@ -200,7 +207,7 @@ public virtual void AssignOperatorToMerchant() #line 4 this.FeatureBackground(); #line hidden - TechTalk.SpecFlow.Table table9 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table11 = new TechTalk.SpecFlow.Table(new string[] { "MerchantName", "AddressLine1", "Town", @@ -209,7 +216,7 @@ public virtual void AssignOperatorToMerchant() "ContactName", "EmailAddress", "EstateName"}); - table9.AddRow(new string[] { + table11.AddRow(new string[] { "Test Merchant 1", "Address Line 1", "TestTown", @@ -218,21 +225,21 @@ public virtual void AssignOperatorToMerchant() "Test Contact 1", "testcontact1@merchant1.co.uk", "Test Estate 1"}); -#line 19 - testRunner.Given("I create the following merchants", ((string)(null)), table9, "Given "); +#line 24 + testRunner.Given("I create the following merchants", ((string)(null)), table11, "Given "); #line hidden - TechTalk.SpecFlow.Table table10 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table12 = new TechTalk.SpecFlow.Table(new string[] { "OperatorName", "MerchantName", "MerchantNumber", "TerminalNumber"}); - table10.AddRow(new string[] { + table12.AddRow(new string[] { "Test Operator 1", "Test Merchant 1", "00000001", "10000001"}); -#line 22 - testRunner.When("I assign the following operator to the merchants", ((string)(null)), table10, "When "); +#line 28 + testRunner.When("I assign the following operator to the merchants", ((string)(null)), table12, "When "); #line hidden } this.ScenarioCleanup(); @@ -248,7 +255,7 @@ public virtual void CreateSecurityUser() "PRTest"}; TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Create Security User", null, new string[] { "PRTest"}); -#line 27 +#line 33 this.ScenarioInitialize(scenarioInfo); #line hidden bool isScenarioIgnored = default(bool); @@ -271,7 +278,7 @@ public virtual void CreateSecurityUser() #line 4 this.FeatureBackground(); #line hidden - TechTalk.SpecFlow.Table table11 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table13 = new TechTalk.SpecFlow.Table(new string[] { "MerchantName", "AddressLine1", "Town", @@ -280,7 +287,7 @@ public virtual void CreateSecurityUser() "ContactName", "EmailAddress", "EstateName"}); - table11.AddRow(new string[] { + table13.AddRow(new string[] { "Test Merchant 1", "Address Line 1", "TestTown", @@ -289,23 +296,23 @@ public virtual void CreateSecurityUser() "Test Contact 1", "testcontact1@merchant1.co.uk", "Test Estate 1"}); -#line 28 - testRunner.Given("I create the following merchants", ((string)(null)), table11, "Given "); +#line 34 + testRunner.Given("I create the following merchants", ((string)(null)), table13, "Given "); #line hidden - TechTalk.SpecFlow.Table table12 = new TechTalk.SpecFlow.Table(new string[] { + TechTalk.SpecFlow.Table table14 = new TechTalk.SpecFlow.Table(new string[] { "EmailAddress", "Password", "GivenName", "FamilyName", "MerchantName"}); - table12.AddRow(new string[] { + table14.AddRow(new string[] { "merchantuser1@testmerchant1.co.uk", "123456", "TestMerchant", "User1", "Test Merchant 1"}); -#line 31 - testRunner.When("I create the following security users", ((string)(null)), table12, "When "); +#line 38 + testRunner.When("I create the following security users", ((string)(null)), table14, "When "); #line hidden } this.ScenarioCleanup(); diff --git a/EstateManagement.IntegrationTests/Shared/SharedSteps.cs b/EstateManagement.IntegrationTests/Shared/SharedSteps.cs index e6c6fde9..2449c29d 100644 --- a/EstateManagement.IntegrationTests/Shared/SharedSteps.cs +++ b/EstateManagement.IntegrationTests/Shared/SharedSteps.cs @@ -12,6 +12,8 @@ namespace EstateManagement.IntegrationTests.Shared using DataTransferObjects.Requests; using DataTransferObjects.Responses; using EstateManagement.DataTransferObjects.Requests; + using SecurityService.DataTransferObjects.Requests; + using SecurityService.DataTransferObjects.Responses; using Shouldly; using TechTalk.SpecFlow; @@ -271,5 +273,24 @@ public async Task WhenICreateTheFollowingSecurityUsers(Table table) } } + [Given(@"the following security roles exist")] + public async Task GivenTheFollowingSecurityRolesExist(Table table) + { + foreach (TableRow tableRow in table.Rows) + { + String roleName = SpecflowTableHelper.GetStringRowValue(tableRow,"RoleName"); + + CreateRoleRequest createRoleRequest = new CreateRoleRequest + { + RoleName = roleName + }; + + CreateRoleResponse createRoleResponse = await this.TestingContext.DockerHelper.SecurityServiceClient.CreateRole(createRoleRequest, CancellationToken.None).ConfigureAwait(false); + + createRoleResponse.RoleId.ShouldNotBe(Guid.Empty); + } + } + + } }