Beispiel #1
0
        public void ShouldGetSingleResourceByClaimSetIdAndResourceId()
        {
            var testApplication = new Application
            {
                ApplicationName = "TestApplicationName"
            };

            Save(testApplication);
            var testClaimSets      = SetupApplicationWithClaimSets(testApplication).ToList();
            var testResourceClaims = SetupParentResourceClaims(testClaimSets, testApplication);

            Transaction <SqlServerSecurityContext>(securityContext =>
            {
                var query = new GetResourcesByClaimSetIdQuery(securityContext, GetMapper());

                foreach (var testClaimSet in testClaimSets)
                {
                    var testResourceClaim =
                        testResourceClaims.Single(x => x.ClaimSet.ClaimSetId == testClaimSet.ClaimSetId && x.ResourceClaim.ResourceName == "TestResourceClaim3.00").ResourceClaim;
                    var result = query.SingleResource(testClaimSet.ClaimSetId, testResourceClaim.ResourceClaimId);

                    result.Name.ShouldBe(testResourceClaim.ResourceName);
                    result.Id.ShouldBe(testResourceClaim.ResourceClaimId);
                    result.Create.ShouldBe(true);
                    result.Read.ShouldBe(false);
                    result.Update.ShouldBe(false);
                    result.Delete.ShouldBe(false);
                }
            });
        }
Beispiel #2
0
        public void ShouldGetDefaultAuthorizationStrategiesForSingleResourcesByClaimSetIdAndResourceId()
        {
            var testApplication = new Application
            {
                ApplicationName = "TestApplicationName"
            };

            Save(testApplication);

            var testClaimSet = new ClaimSet
            {
                ClaimSetName = "TestClaimSet",
                Application  = testApplication
            };

            Save(testClaimSet);

            var appAuthorizationStrategies = SetupApplicationAuthorizationStrategies(testApplication).ToList();
            var testResourceClaims         = SetupParentResourceClaims(new List <ClaimSet> {
                testClaimSet
            }, testApplication);
            var testAuthStrategies = SetupResourcesWithDefaultAuthorizationStrategies(appAuthorizationStrategies, testResourceClaims.ToList());

            Transaction <SqlServerSecurityContext>(securityContext =>
            {
                var query             = new GetResourcesByClaimSetIdQuery(securityContext, GetMapper());
                var testResourceClaim =
                    testResourceClaims.Single(x => x.ClaimSet.ClaimSetId == testClaimSet.ClaimSetId && x.ResourceClaim.ResourceName == "TestResourceClaim3.00").ResourceClaim;
                var testAuthStrategy = testAuthStrategies.Single(x =>
                                                                 x.ResourceClaim.ResourceClaimId == testResourceClaim.ResourceClaimId && x.Action.ActionName == ActionName.Create.Value).AuthorizationStrategy;

                var result = query.SingleResource(testClaimSet.ClaimSetId, testResourceClaim.ResourceClaimId);

                result.Name.ShouldBe(testResourceClaim.ResourceName);
                result.Id.ShouldBe(testResourceClaim.ResourceClaimId);
                result.Create.ShouldBe(true);
                result.Read.ShouldBe(false);
                result.Update.ShouldBe(false);
                result.Delete.ShouldBe(false);
                result.DefaultAuthStrategiesForCRUD[0].AuthStrategyName.ShouldBe(testAuthStrategy.DisplayName);
            });
        }