QuellCode/CentronERP war nur als Gitlink (Submodul-Referenz auf 79c1142) getrackt, ohne .gitmodules und ohne erreichbares Remote. Der Untersuchungsgegenstand der Versuchsreihe war damit nicht reproduzierbar gesichert: Ein Klon haette ein leeres Verzeichnis erhalten, und die Belege der 3.287 Anforderungen waeren nicht ueberpruefbar gewesen. Umstellung: - Historie nach c:\DEV\CentronERP_git_snapshot_79c1142 ausgelagert (vollstaendig lesbar, enthaelt 79c1142 und Vorgaenger 89ccfd6) - Gitlink aus dem Index entfernt - Dateiinhalt aufgenommen: 24.557 Dateien, rund 333 MB Die verschachtelte .gitignore der Codebasis gilt weiter, Build-Artefakte bleiben ausgeschlossen. Details in Versuche/Versuch_01/_Codebasis-Nachweis.md
331 lines
12 KiB
C#
331 lines
12 KiB
C#
using System.Collections.Generic;
|
|
using Centron.BusinessLogic.Administration.Rights;
|
|
using Centron.BusinessLogic.WebServices.CheckListArea;
|
|
using Centron.Data.Entities.Administration;
|
|
using Centron.Data.Entities.Administration.Logins;
|
|
using Centron.Data.Entities.ChecklistArea;
|
|
using Centron.Data.Entities.EmployeeArea;
|
|
using Centron.Data.WebServices.Administration.Employees;
|
|
using Centron.Interfaces.ChecklistArea;
|
|
using CentronSoftware.Centron.WebServices.Entities.CentronChecklist;
|
|
using Xunit;
|
|
|
|
namespace Centron.Tests.EndToEnd.Tests.Checklists;
|
|
|
|
public class ChecklistItemEditAccessTest
|
|
{
|
|
[Fact]
|
|
public void IsChecklistItemEditAllowed_ShouldReturnFalse_ForNullUser()
|
|
{
|
|
// Act
|
|
var result = CentronChecklistWebserviceBL.IsChecklistItemEditAllowed(null, null, null);
|
|
|
|
// Assert
|
|
Assert.False(result.Item1);
|
|
}
|
|
|
|
[Fact]
|
|
public void IsChecklistItemEditAllowed_ShouldReturnTrue_ForAdminUser()
|
|
{
|
|
// Arrange
|
|
var appUser = new AppUser{ Groups = new List<AppGroup>()};
|
|
appUser.Groups.Add(new AppGroup{ Name = UserRightsConst.ADMIN_ACCOUNT });
|
|
var loggedInUser = new LoggedInUser(appUser);
|
|
var checklistItemDTO = new CentronChecklistItemDTO();
|
|
|
|
// Act
|
|
var result = CentronChecklistWebserviceBL.IsChecklistItemEditAllowed(checklistItemDTO, null, loggedInUser);
|
|
|
|
// Assert
|
|
Assert.True(result.Item1);
|
|
}
|
|
|
|
[Fact]
|
|
public void IsChecklistItemEditAllowed_ShouldReturnFalse_ForNonAdminUserWithDifferentEditor()
|
|
{
|
|
// Arrange
|
|
var appUser = new AppUser{ Employee = new EmployeeCompact { I3D = 1 } };
|
|
var loggedInUser = new LoggedInUser(appUser);
|
|
var checklistItemDTO = new CentronChecklistItemDTO { Editor = new EmployeePreviewDTO { I3D = 2 } };
|
|
var checklistItemEntity = new CentronChecklistItem { Editor = new Employee { I3D = 2 } };
|
|
|
|
// Act
|
|
var result = CentronChecklistWebserviceBL.IsChecklistItemEditAllowed(checklistItemDTO, checklistItemEntity, loggedInUser);
|
|
|
|
// Assert
|
|
Assert.False(result.Item1);
|
|
}
|
|
|
|
[Fact]
|
|
public void IsChecklistItemEditAllowed_ShouldReturnTrue_ForNonAdminUserWithSameEditor()
|
|
{
|
|
// Arrange
|
|
var appUser = new AppUser{ Employee = new EmployeeCompact { I3D = 2 } };
|
|
var loggedInUser = new LoggedInUser(appUser);
|
|
var checklistItemDTO = new CentronChecklistItemDTO { Editor = new EmployeePreviewDTO { I3D = 2 } };
|
|
var checklistItemEntity = new CentronChecklistItem { Editor = new Employee { I3D = 2 } };
|
|
|
|
// Act
|
|
var result = CentronChecklistWebserviceBL.IsChecklistItemEditAllowed(checklistItemDTO, checklistItemEntity, loggedInUser);
|
|
|
|
// Assert
|
|
Assert.True(result.Item1);
|
|
}
|
|
|
|
[Fact]
|
|
public void IsChecklistItemEditAllowed_ShouldReturnTrue_ForNullChecklistItemEntity()
|
|
{
|
|
// Arrange
|
|
var appUser = new AppUser { Groups = new List<AppGroup>() };
|
|
var loggedInUser = new LoggedInUser(appUser);
|
|
var checklistItemDTO = new CentronChecklistItemDTO();
|
|
|
|
// Act
|
|
var result = CentronChecklistWebserviceBL.IsChecklistItemEditAllowed(checklistItemDTO, null, loggedInUser);
|
|
|
|
// Assert
|
|
Assert.True(result.Item1);
|
|
}
|
|
|
|
[Fact]
|
|
public void IsChecklistItemEditAllowed_ShouldReturnTrue_ForAdHocItemCreatedByLoggedInUser()
|
|
{
|
|
// Arrange
|
|
var appUser = new AppUser { Employee = new EmployeeCompact { I3D = 1 } };
|
|
var loggedInUser = new LoggedInUser(appUser);
|
|
var checklistItemDTO = new CentronChecklistItemDTO { AdHocCreatedBy = new EmployeePreviewDTO { I3D = 1 } };
|
|
var checklistItemEntity = new CentronChecklistItem { AdHocCreatedBy = new Employee { I3D = 1 } };
|
|
|
|
// Act
|
|
var result = CentronChecklistWebserviceBL.IsChecklistItemEditAllowed(checklistItemDTO, checklistItemEntity, loggedInUser);
|
|
|
|
// Assert
|
|
Assert.True(result.Item1);
|
|
}
|
|
|
|
[Fact]
|
|
public void IsChecklistItemEditAllowed_ShouldReturnFalse_ForAdHocItemNotCreatedByLoggedInUser()
|
|
{
|
|
// Arrange
|
|
var appUser = new AppUser { Employee = new EmployeeCompact { I3D = 1 } };
|
|
var loggedInUser = new LoggedInUser(appUser);
|
|
var checklistItemDTO = new CentronChecklistItemDTO { AdHocCreatedBy = new EmployeePreviewDTO { I3D = 2 } };
|
|
var checklistItemEntity = new CentronChecklistItem { AdHocCreatedBy = new Employee { I3D = 2 } };
|
|
|
|
// Act
|
|
var result = CentronChecklistWebserviceBL.IsChecklistItemEditAllowed(checklistItemDTO, checklistItemEntity, loggedInUser);
|
|
|
|
// Assert
|
|
Assert.False(result.Item1);
|
|
}
|
|
|
|
[Fact]
|
|
public void IsChecklistItemEditAllowed_ShouldReturnFalse_ForTemplateItemWithDifferentEditor()
|
|
{
|
|
// Arrange
|
|
var appUser = new AppUser { Employee = new EmployeeCompact { I3D = 1 } };
|
|
var loggedInUser = new LoggedInUser(appUser);
|
|
var checklistItemDTO = new CentronChecklistItemDTO { Editor = new EmployeePreviewDTO { I3D = 2 } };
|
|
var checklistItemEntity = new CentronChecklistItem { Editor = new Employee { I3D = 2 } };
|
|
|
|
// Act
|
|
var result = CentronChecklistWebserviceBL.IsChecklistItemEditAllowed(checklistItemDTO, checklistItemEntity, loggedInUser);
|
|
|
|
// Assert
|
|
Assert.False(result.Item1);
|
|
}
|
|
|
|
[Fact]
|
|
public void IsChecklistItemEditAllowed_ShouldReturnTrue_ForTemplateItemWithSameEditorStateChange()
|
|
{
|
|
// Arrange
|
|
var appUser = new AppUser { Employee = new EmployeeCompact { I3D = 1 } };
|
|
var loggedInUser = new LoggedInUser(appUser);
|
|
var checklistItemDTO = new CentronChecklistItemDTO
|
|
{
|
|
Editor = new EmployeePreviewDTO { I3D = 1 },
|
|
State = CentronChecklistItemState.Finished
|
|
};
|
|
var checklistItemEntity = new CentronChecklistItem
|
|
{
|
|
Editor = new Employee { I3D = 1 },
|
|
State = CentronChecklistItemState.Open
|
|
|
|
};
|
|
|
|
// Act
|
|
var result = CentronChecklistWebserviceBL.IsChecklistItemEditAllowed(checklistItemDTO, checklistItemEntity, loggedInUser);
|
|
|
|
// Assert
|
|
Assert.True(result.Item1);
|
|
}
|
|
|
|
[Fact]
|
|
public void IsChecklistItemEditAllowed_ShouldReturnFalse_ForTemplateItemWithSameEditorCaptionChange()
|
|
{
|
|
// Arrange
|
|
var appUser = new AppUser { Employee = new EmployeeCompact { I3D = 1 } };
|
|
var loggedInUser = new LoggedInUser(appUser);
|
|
var checklistItemDTO = new CentronChecklistItemDTO
|
|
{
|
|
Editor = new EmployeePreviewDTO { I3D = 1 },
|
|
Caption = "Test"
|
|
};
|
|
var checklistItemEntity = new CentronChecklistItem
|
|
{
|
|
Editor = new Employee { I3D = 1 },
|
|
Caption = "Changed"
|
|
};
|
|
|
|
// Act
|
|
var result = CentronChecklistWebserviceBL.IsChecklistItemEditAllowed(checklistItemDTO, checklistItemEntity, loggedInUser);
|
|
|
|
// Assert
|
|
Assert.False(result.Item1);
|
|
}
|
|
|
|
[Fact]
|
|
public void IsChecklistItemEditAllowed_ShouldReturnFalse_ForTemplateItemWithSameEditorDescriptionChange()
|
|
{
|
|
// Arrange
|
|
var appUser = new AppUser { Employee = new EmployeeCompact { I3D = 1 } };
|
|
var loggedInUser = new LoggedInUser(appUser);
|
|
var checklistItemDTO = new CentronChecklistItemDTO
|
|
{
|
|
Editor = new EmployeePreviewDTO { I3D = 1 },
|
|
Description = "Test"
|
|
};
|
|
var checklistItemEntity = new CentronChecklistItem
|
|
{
|
|
Editor = new Employee { I3D = 1 },
|
|
Description = "Changed"
|
|
};
|
|
|
|
// Act
|
|
var result = CentronChecklistWebserviceBL.IsChecklistItemEditAllowed(checklistItemDTO, checklistItemEntity, loggedInUser);
|
|
|
|
// Assert
|
|
Assert.False(result.Item1);
|
|
}
|
|
|
|
[Fact]
|
|
public void IsChecklistItemEditAllowed_ShouldReturnFalse_ForTemplateItemWithSameEditorDurationChange()
|
|
{
|
|
// Arrange
|
|
var appUser = new AppUser { Employee = new EmployeeCompact { I3D = 1 } };
|
|
var loggedInUser = new LoggedInUser(appUser);
|
|
var checklistItemDTO = new CentronChecklistItemDTO
|
|
{
|
|
Editor = new EmployeePreviewDTO { I3D = 1 },
|
|
DurationTime = 10
|
|
};
|
|
var checklistItemEntity = new CentronChecklistItem
|
|
{
|
|
Editor = new Employee { I3D = 1 },
|
|
DurationTime = 0
|
|
};
|
|
|
|
// Act
|
|
var result = CentronChecklistWebserviceBL.IsChecklistItemEditAllowed(checklistItemDTO, checklistItemEntity, loggedInUser);
|
|
|
|
// Assert
|
|
Assert.False(result.Item1);
|
|
}
|
|
|
|
[Fact]
|
|
public void IsChecklistItemEditAllowed_ShouldReturnTrue_ForTemplateItemWithNullEditorStateChange()
|
|
{
|
|
// Arrange
|
|
var appUser = new AppUser { Employee = new EmployeeCompact { I3D = 1 } };
|
|
var loggedInUser = new LoggedInUser(appUser);
|
|
var checklistItemDTO = new CentronChecklistItemDTO
|
|
{
|
|
Editor = null,
|
|
State = CentronChecklistItemState.Finished
|
|
};
|
|
var checklistItemEntity = new CentronChecklistItem
|
|
{
|
|
Editor = null,
|
|
State = CentronChecklistItemState.Open
|
|
|
|
};
|
|
|
|
// Act
|
|
var result = CentronChecklistWebserviceBL.IsChecklistItemEditAllowed(checklistItemDTO, checklistItemEntity, loggedInUser);
|
|
|
|
// Assert
|
|
Assert.True(result.Item1);
|
|
}
|
|
|
|
[Fact]
|
|
public void IsChecklistItemEditAllowed_ShouldReturnFalse_ForTemplateItemWithNullEditorCaptionChange()
|
|
{
|
|
// Arrange
|
|
var appUser = new AppUser { Employee = new EmployeeCompact { I3D = 1 } };
|
|
var loggedInUser = new LoggedInUser(appUser);
|
|
var checklistItemDTO = new CentronChecklistItemDTO
|
|
{
|
|
Editor = null,
|
|
Caption = "Test"
|
|
};
|
|
var checklistItemEntity = new CentronChecklistItem
|
|
{
|
|
Editor = null,
|
|
Caption = "Changed"
|
|
};
|
|
|
|
// Act
|
|
var result = CentronChecklistWebserviceBL.IsChecklistItemEditAllowed(checklistItemDTO, checklistItemEntity, loggedInUser);
|
|
|
|
// Assert
|
|
Assert.False(result.Item1);
|
|
}
|
|
|
|
[Fact]
|
|
public void IsChecklistItemEditAllowed_ShouldReturnFalse_ForTemplateItemWithNullEditorDescriptionChange()
|
|
{
|
|
// Arrange
|
|
var appUser = new AppUser { Employee = new EmployeeCompact { I3D = 1 } };
|
|
var loggedInUser = new LoggedInUser(appUser);
|
|
var checklistItemDTO = new CentronChecklistItemDTO
|
|
{
|
|
Editor = null,
|
|
Description = "Test"
|
|
};
|
|
var checklistItemEntity = new CentronChecklistItem
|
|
{
|
|
Editor = null,
|
|
Description = "Changed"
|
|
};
|
|
|
|
// Act
|
|
var result = CentronChecklistWebserviceBL.IsChecklistItemEditAllowed(checklistItemDTO, checklistItemEntity, loggedInUser);
|
|
|
|
// Assert
|
|
Assert.False(result.Item1);
|
|
}
|
|
|
|
[Fact]
|
|
public void IsChecklistItemEditAllowed_ShouldReturnFalse_ForTemplateItemWithNullEditorDurationChange()
|
|
{
|
|
// Arrange
|
|
var appUser = new AppUser { Employee = new EmployeeCompact { I3D = 1 } };
|
|
var loggedInUser = new LoggedInUser(appUser);
|
|
var checklistItemDTO = new CentronChecklistItemDTO
|
|
{
|
|
Editor = null,
|
|
DurationTime = 10
|
|
};
|
|
var checklistItemEntity = new CentronChecklistItem
|
|
{
|
|
Editor = null,
|
|
DurationTime = 0
|
|
};
|
|
|
|
// Act
|
|
var result = CentronChecklistWebserviceBL.IsChecklistItemEditAllowed(checklistItemDTO, checklistItemEntity, loggedInUser);
|
|
|
|
// Assert
|
|
Assert.False(result.Item1);
|
|
}
|
|
} |