コード例 #1
0
        public async Task UpdateAccessPolicyPairing_AccessPolicyPairingsExist_AccessPolicyPairingIdAccurate(int id, int expectedScopeId, int expectedClaimId, int expectedAccessPolicyId)
        {
            // Arrange

            IAccessPolicyPairingRepository accessPolicyPairingRepository = new AccessPolicyPairingRepository(new SQLServerGateway(), new ConnectionStringData());

            AccessPolicyPairingModel accessPolicyPairingModel = new AccessPolicyPairingModel();

            accessPolicyPairingModel.Id             = id;
            accessPolicyPairingModel.ScopeId        = expectedScopeId;
            accessPolicyPairingModel.ClaimId        = expectedClaimId;
            accessPolicyPairingModel.AccessPolicyId = expectedAccessPolicyId;

            // Act
            await accessPolicyPairingRepository.UpdateAccessPolicyPairing(accessPolicyPairingModel);

            var actual = await accessPolicyPairingRepository.GetAccessPolicyPairingById(id);

            var actualScopeId        = actual.ScopeId;
            var actualClaimId        = actual.ClaimId;
            var actualAccessPolicyId = actual.AccessPolicyId;


            // Assert
            Assert.IsTrue(actualScopeId == expectedScopeId &&
                          actualClaimId == expectedClaimId &&
                          actualAccessPolicyId == expectedAccessPolicyId);
        }
コード例 #2
0
        public async Task Init()
        {
            await TestCleaner.CleanDatabase();

            var numTestRows = 20;

            IDataGateway                   dataGateway                   = new SQLServerGateway();
            IConnectionStringData          connectionString              = new ConnectionStringData();
            IScopeRepository               scopeRepository               = new ScopeRepository(dataGateway, connectionString);
            IResourceRepository            resourceRepository            = new ResourceRepository(dataGateway, connectionString);
            IClaimRepository               claimRepository               = new ClaimRepository(dataGateway, connectionString);
            IAccessPolicyRepository        accessPolicyRepository        = new AccessPolicyRepository(dataGateway, connectionString);
            IAccessPolicyPairingRepository accessPolicyPairingRepository = new AccessPolicyPairingRepository(dataGateway, connectionString);


            for (int i = 1; i <= numTestRows; ++i)
            {
                ResourceModel resourceModel = new ResourceModel();
                resourceModel.Id   = i;
                resourceModel.Name = "TestResource" + i;

                ScopeModel scopeModel = new ScopeModel();
                scopeModel.Id          = i;
                scopeModel.Type        = "TestScope" + i;
                scopeModel.Description = "TestDescription" + i;

                ClaimModel claimModel = new ClaimModel();
                claimModel.Id        = i;
                claimModel.Type      = "TestClaim" + i;
                claimModel.Value     = "TestDescription" + i;
                claimModel.IsDefault = true;

                var resourceId = await resourceRepository.CreateResource(resourceModel);

                var claimId = await claimRepository.CreateClaim(claimModel);

                var scopeId = await scopeRepository.CreateScope(scopeModel);

                AccessPolicyModel accessPolicyModel = new AccessPolicyModel();
                accessPolicyModel.Id         = i;
                accessPolicyModel.Name       = "TestAccessPolicy" + i;
                accessPolicyModel.ResourceId = resourceId;
                accessPolicyModel.Priority   = i % 4;

                var accessPolicyId = await accessPolicyRepository.CreateAccessPolicy(accessPolicyModel);

                AccessPolicyPairingModel accessPolicyPairingModel = new AccessPolicyPairingModel();
                accessPolicyPairingModel.Id             = i;
                accessPolicyPairingModel.ScopeId        = scopeId;
                accessPolicyPairingModel.ClaimId        = claimId;
                accessPolicyPairingModel.AccessPolicyId = accessPolicyId;

                await accessPolicyPairingRepository.CreateAccessPolicyPairing(accessPolicyPairingModel);
            }
        }
コード例 #3
0
        public static async Task CleanDatabase()
        {
            IDataGateway                        dataGateway                        = new SQLServerGateway();
            IConnectionStringData               connectionString                   = new ConnectionStringData();
            IUserAccountRepository              userAccountRepository              = new UserAccountRepository(dataGateway, connectionString);
            IUserProfileRepository              userProfileRepository              = new UserProfileRepository(dataGateway, connectionString);
            IUserAccountCodeRepository          userAccountCodeRepository          = new UserAccountCodeRepository(dataGateway, connectionString);
            IUserAccountSettingsRepository      userAccountSettingsRepository      = new UserAccountSettingRepository(dataGateway, connectionString);
            ILoginAttemptsRepository            loginAttemptsRepository            = new LoginAttemptsRepository(dataGateway, connectionString);
            IResourceRepository                 resourceRepository                 = new ResourceRepository(dataGateway, connectionString);
            IClaimRepository                    claimRepository                    = new ClaimRepository(dataGateway, connectionString);
            IScopeRepository                    scopeRepository                    = new ScopeRepository(dataGateway, connectionString);
            IScopeClaimRepository               scopeClaimRepository               = new ScopeClaimRepository(dataGateway, connectionString);
            IUserScopeRepository                userScopeRepository                = new UserScopeRepository(dataGateway, connectionString);
            IUserClaimRepository                userClaimRepository                = new UserClaimRepository(dataGateway, connectionString);
            IAssignmentPolicyRepository         assignmentPolicyRepository         = new AssignmentPolicyRepository(dataGateway, connectionString);
            IAssignmentPolicyPairingRepository  assignmentPolicyPairingRepository  = new AssignmentPolicyPairingRepository(dataGateway, connectionString);
            IUserScopeClaimRepository           userScopeClaimRepository           = new UserScopeClaimRepository(dataGateway, connectionString);
            IAccessPolicyRepository             accessPolicyRepository             = new AccessPolicyRepository(dataGateway, connectionString);
            IAccessPolicyPairingRepository      accessPolicyPairingRepository      = new AccessPolicyPairingRepository(dataGateway, connectionString);
            ITraditionalListingSearchRepository traditionalListingSearchRepository = new TraditionalListingSearchRepository(dataGateway, connectionString);


            var accounts = await userAccountRepository.GetAllAccounts();

            var profiles = await userProfileRepository.GetAllUserProfiles();

            var accountCodes = await userAccountCodeRepository.GetAllUserAccountCodes();

            var accountSettings = await userAccountSettingsRepository.GetAllSettings();

            var loginAttempts = await loginAttemptsRepository.GetAllLoginAttempts();

            var resources = await resourceRepository.GetAllResources();

            var claims = await claimRepository.GetAllClaims();

            var scopes = await scopeRepository.GetAllScopes();

            var scopeClaims = await scopeClaimRepository.GetAllScopeClaims();

            var userClaims = await userClaimRepository.GetAllUserClaims();

            var userScopes = await userScopeRepository.GetAllUserScopes();

            var assignmentPolicies = await assignmentPolicyRepository.GetAllAssignmentPolicies();

            var assignmentPolicyPairings = await assignmentPolicyPairingRepository.GetAllAssignmentPolicyPairings();

            var userScopeClaims = await userScopeClaimRepository.GetAllUserScopeClaims();

            var accessPolicies = await accessPolicyRepository.GetAllAccessPolicies();

            var accesssPolicyPairings = await accessPolicyPairingRepository.GetAllAccessPoliciesPairings();

            var listings = await traditionalListingSearchRepository.GetAllListings();

            var collaborationListings = await traditionalListingSearchRepository.GetAllCollaborationListings();

            var relationshipListings = await traditionalListingSearchRepository.GetAllRelationshipListings();

            var teamListings = await traditionalListingSearchRepository.GetAllTeamListings();

            if (resources != null)
            {
                await DeleteAllFromTable("Resource");
                await ReseedAsync("Resource", 0, connectionString, dataGateway);
            }

            if (claimRepository != null)
            {
                await DeleteAllFromTable("Claim");
                await ReseedAsync("Claim", 0, connectionString, dataGateway);
            }

            if (scopeRepository != null)
            {
                await DeleteAllFromTable("Scope");
                await ReseedAsync("Scope", 0, connectionString, dataGateway);
            }

            if (scopeClaims != null)
            {
                await DeleteAllFromTable("ScopeClaim");
                await ReseedAsync("ScopeClaim", 0, connectionString, dataGateway);
            }
            if (assignmentPolicies != null)
            {
                await DeleteAllFromTable("AssignmentPolicy");
                await ReseedAsync("AssignmentPolicy", 0, connectionString, dataGateway);
            }

            if (assignmentPolicyPairings != null)
            {
                await DeleteAllFromTable("AssignmentPolicyPairing");
            }

            if (userScopeClaims != null)
            {
                await DeleteAllFromTable("UserScopeClaim");
                await ReseedAsync("UserScopeClaim", 0, connectionString, dataGateway);
            }

            if (userScopes != null)
            {
                await DeleteAllFromTable("UserScope");
                await ReseedAsync("UserScope", 0, connectionString, dataGateway);
            }

            if (userClaims != null)
            {
                await DeleteAllFromTable("UserClaim");
                await ReseedAsync("UserClaim", 0, connectionString, dataGateway);
            }

            if (accessPolicies != null)
            {
                await DeleteAllFromTable("AccessPolicy");
                await ReseedAsync("AccessPolicy", 0, connectionString, dataGateway);
            }

            if (accesssPolicyPairings != null)
            {
                await DeleteAllFromTable("AccessPolicyPairing");
                await ReseedAsync("AssignmentPolicyPairing", 0, connectionString, dataGateway);
                await ReseedAsync("AccessPolicyPairing", 0, connectionString, dataGateway);
            }

            if (loginAttempts != null)
            {
                await DeleteAllFromTable("LoginAttempts");
                await ReseedAsync("LoginAttempts", 0, connectionString, dataGateway);
            }

            if (accounts != null)
            {
                await DeleteAllFromTable("UserProfile");
                await DeleteAllFromTable("UserAccountSettings");
                await DeleteAllFromTable("UserAccountCode");
                await DeleteAllFromTable("UserAccount");

                await ReseedAsync("UserAccount", 0, connectionString, dataGateway);
                await ReseedAsync("UserProfile", 0, connectionString, dataGateway);
                await ReseedAsync("UserAccountCode", 0, connectionString, dataGateway);
                await ReseedAsync("UserAccountSettings", 0, connectionString, dataGateway);
            }
            if (listings != null)
            {
                await DeleteAllFromTable("Listing");
                await ReseedAsync("Listing", 0, connectionString, dataGateway);
            }
            if (collaborationListings != null)
            {
                await DeleteAllFromTable("Collaboration");
                await ReseedAsync("Collaboration", 0, connectionString, dataGateway);
            }
            if (relationshipListings != null)
            {
                await DeleteAllFromTable("Relationship");
                await ReseedAsync("Relationship", 0, connectionString, dataGateway);
            }
            if (teamListings != null)
            {
                await DeleteAllFromTable("TeamModel");
                await ReseedAsync("TeamModel", 0, connectionString, dataGateway);
            }
        }