public ClaimSetsController(IGetClaimSetByIdQuery getClaimSetByIdQuery , IGetApplicationsByClaimSetIdQuery getApplicationsByClaimSetIdQuery , IGetResourcesByClaimSetIdQuery getResourcesByClaimSetIdQuery , IGetClaimSetsByApplicationNameQuery getClaimSetsByApplicationNameQuery , IGetAuthStrategiesByApplicationNameQuery getAuthStrategiesByApplicationNameQuery , ITabDisplayService tabDisplayService , CopyClaimSetCommand copyClaimSetCommand , AddClaimSetCommand addClaimSetCommand , EditClaimSetCommand editClaimSetCommand , GetResourceClaimsQuery getResourceClaimsQuery , GetChildResourceClaimsForParentQuery getChildResourceClaimsForParentQuery , DeleteClaimSetCommand deleteClaimSetCommand , EditResourceOnClaimSetCommand editResourceOnClaimSetCommand , DeleteResourceOnClaimSetCommand deleteResourceOnClaimSetCommand , ClaimSetFileExportCommand claimSetFileExportCommand , ClaimSetFileImportCommand claimSetFileImportCommand , OverrideDefaultAuthorizationStrategyCommand overrideDefaultAuthorizationStrategyCommand , ResetToDefaultAuthStrategyCommand resetToDefaultAuthStrategyCommand) { _getClaimSetByIdQuery = getClaimSetByIdQuery; _getApplicationsByClaimSetIdQuery = getApplicationsByClaimSetIdQuery; _getResourcesByClaimSetIdQuery = getResourcesByClaimSetIdQuery; _getClaimSetsByApplicationNameQuery = getClaimSetsByApplicationNameQuery; _getAuthStrategiesByApplicationNameQuery = getAuthStrategiesByApplicationNameQuery; _tabDisplayService = tabDisplayService; _copyClaimSetCommand = copyClaimSetCommand; _addClaimSetCommand = addClaimSetCommand; _editClaimSetCommand = editClaimSetCommand; _getClaimSetByIdQuery = getClaimSetByIdQuery; _getResourceClaimsQuery = getResourceClaimsQuery; _getChildResourceClaimsForParentQuery = getChildResourceClaimsForParentQuery; _deleteClaimSetCommand = deleteClaimSetCommand; _editResourceOnClaimSetCommand = editResourceOnClaimSetCommand; _deleteResourceOnClaimSetCommand = deleteResourceOnClaimSetCommand; _claimSetFileExportCommand = claimSetFileExportCommand; _claimSetFileImportCommand = claimSetFileImportCommand; _overrideDefaultAuthorizationStrategyCommand = overrideDefaultAuthorizationStrategyCommand; _resetToDefaultAuthStrategyCommand = resetToDefaultAuthStrategyCommand; }
public void ShouldImportClaimSet() { var testApplication = new Application { ApplicationName = $"Test Application {DateTime.Now:O}" }; Save(testApplication); SetupResourceClaims(testApplication); var testJSON = @"{ ""title"": ""testfile"", ""template"": { ""claimSets"": [ { ""name"": ""Test Claimset"", ""resourceClaims"": [ { ""Name"": ""TestParentResourceClaim1"", ""Read"": true, ""Create"": false, ""Update"": false, ""Delete"": false, ""Children"": [] }, { ""Name"": ""TestParentResourceClaim2"", ""Read"": true, ""Create"": false, ""Update"": false, ""Delete"": false, ""Children"": [] }, { ""Name"": ""TestParentResourceClaim3"", ""Read"": true, ""Create"": true, ""Update"": true, ""Delete"": true, ""Children"": [] } ] } ] } }"; var importModel = GetImportModel(testJSON); var getResourceByClaimSetIdQuery = new GetResourcesByClaimSetIdQuery(TestContext, GetMapper()); var addClaimSetCommand = new AddClaimSetCommand(TestContext); var getResourceClaimsQuery = new GetResourceClaimsQuery(TestContext); var editResourceOnClaimSetCommand = new EditResourceOnClaimSetCommand(TestContext); var command = new ClaimSetFileImportCommand(addClaimSetCommand, editResourceOnClaimSetCommand, getResourceClaimsQuery); command.Execute(importModel); var testClaimSet = TestContext.ClaimSets.SingleOrDefault(x => x.ClaimSetName == "Test Claimset"); testClaimSet.ShouldNotBeNull(); var resourcesForClaimSet = getResourceByClaimSetIdQuery.AllResources(testClaimSet.ClaimSetId).ToList(); resourcesForClaimSet.Count.ShouldBeGreaterThan(0); var testResources = resourcesForClaimSet.Where(x => x.ParentId == 0).ToArray(); testResources.Count().ShouldBe(3); var testResource1 = testResources[0]; MatchActions(testResource1, "TestParentResourceClaim1", new bool[] { false, true, false, false }); var testResource2 = testResources[1]; MatchActions(testResource2, "TestParentResourceClaim2", new bool[] { false, true, false, false }); var testResource3 = testResources[2]; MatchActions(testResource3, "TestParentResourceClaim3", new bool[] { true, true, true, true }); }