public void RevokePrivilege_AllOK_RevokePrivilege() { //Prefase IDatabaseContainer databaseContainer = ObjectConstructor.CreateDatabaseContainer(); IDatabase database = databaseContainer.GetDatabase(SystemeConstants.DefaultDatabaseName); Table table = new Table("table"); database.AddTable(table); string profileName = SystemeConstants.DefaultProfile; string privilegeName = SystemeConstants.InsertPrivilegeName; GrantPrivilege grantPrivilege = TestGrantPrivilege.CreateGrantPrivilege(databaseContainer, SystemeConstants.SystemDatabaseName, SystemeConstants.PrivilegesOfProfilesOnTablesTableName); grantPrivilege.SetData(privilegeName, profileName, database.databaseName, table.tableName); grantPrivilege.ValidateParameters(); grantPrivilege.Execute(); ITable profilesPrivilegesTable = databaseContainer.GetDatabase(SystemeConstants.SystemDatabaseName).GetTable(SystemeConstants.PrivilegesOfProfilesOnTablesTableName); int rowCounts = profilesPrivilegesTable.GetRowCount(); //Test RevoquePrivilege revoquePrivilege = CreateRevokePrivilege(databaseContainer, SystemeConstants.SystemDatabaseName, SystemeConstants.PrivilegesOfProfilesOnTablesTableName); revoquePrivilege.SetData(profileName, database.databaseName, table.tableName, privilegeName); Assert.IsTrue(revoquePrivilege.ValidateParameters()); revoquePrivilege.Execute(); Assert.AreEqual(rowCounts - 1, profilesPrivilegesTable.GetRowCount()); }
public static RevoquePrivilege CreateRevokePrivilege(IDatabaseContainer container, string databaseName, string tableName) { RevoquePrivilege revoquePrivilege = new RevoquePrivilege(container); revoquePrivilege.targetDatabase = databaseName; revoquePrivilege.targetTableName = tableName; return(revoquePrivilege); }
public void RevokePrivilege_PrivilegeDoesntExist_NoticeInValidate() { IDatabaseContainer databaseContainer = ObjectConstructor.CreateDatabaseContainer(); string privilegeName = ShittyUtilities.GetDoesntExistPrivilegeName(databaseContainer); RevoquePrivilege revoquePrivilege = CreateRevokePrivilege(databaseContainer, SystemeConstants.SystemDatabaseName, SystemeConstants.PrivilegesOfProfilesOnTablesTableName); revoquePrivilege.SetData(SystemeConstants.DefaultProfile, SystemeConstants.SystemDatabaseName, SystemeConstants.ProfilesTableName, privilegeName); Assert.IsFalse(revoquePrivilege.ValidateParameters()); }
public void RevokePrivilege_AllParamsExistsButTheCombinationIsNotValid_NoticeInValidate() { //Prefase IDatabaseContainer databaseContainer = ObjectConstructor.CreateDatabaseContainer(); CreateSecurityProfile createSecurityProfile = TestCreateSecurityProfile.CreateCreateSecurityProfile(databaseContainer); Column profileNamesColumn = databaseContainer.GetDatabase(SystemeConstants.SystemDatabaseName).GetTable(SystemeConstants.ProfilesTableName).GetColumn(SystemeConstants.ProfileNameColumn); string profileName = VariousFunctions.GenerateRandomString(8); while (profileNamesColumn.ExistCells(profileName)) { profileName = VariousFunctions.GenerateRandomString(8); } createSecurityProfile.SetProfileName(profileName); createSecurityProfile.ValidateParameters(); createSecurityProfile.Execute(); //TEST RevoquePrivilege revoquePrivilege = CreateRevokePrivilege(databaseContainer, SystemeConstants.SystemDatabaseName, SystemeConstants.PrivilegesOfProfilesOnTablesTableName); revoquePrivilege.SetData(profileName, SystemeConstants.SystemDatabaseName, SystemeConstants.ProfilesTableName, SystemeConstants.InsertPrivilegeName); Assert.IsFalse(revoquePrivilege.ValidateParameters()); }