public void GetResourcesOfAuthorizedUserSucceeds() { const string updateAction = "Alterar ficheiros", insertAction = "Criar ficheiros e pastas", executeAction = "Executar ficheiros"; var pdp = new PDP(); // Admin Assert.That( pdp.getResourcesOfAuthorizedUser("Ricardo", updateAction).Select(resource => resource.ResourceName), Is.EquivalentTo(new[] {"/folder", "/folder/file1.txt", "/folder/file2.txt"})); Assert.That( pdp.getResourcesOfAuthorizedUser("Ricardo", executeAction).Select(resource => resource.ResourceName), Is.EquivalentTo(new[] { "/folder", "/program.exe" })); // Director Assert.That( pdp.getResourcesOfAuthorizedUser("Luís", executeAction).Select(resource => resource.ResourceName), Is.EquivalentTo(new[] { "/folder", "/program.exe" })); // Guest Assert.That( pdp.getResourcesOfAuthorizedUser("Maria", executeAction).Select(resource => resource.ResourceName), Is.EquivalentTo(new[] { "/program.exe" })); }
public void GetResourcesForUnknownThrowsActionNotFoundException() { var pdp = new PDP(); Assert.That(() => pdp.getResourcesOfAuthorizedUser("Unknown user", "Unknown action"), Throws.TypeOf<ActionNotFoundException>()); }
public void GetResourcesOfUnknownUserReturnsEmptyList() { var pdp = new PDP(); Assert.That(pdp.getResourcesOfAuthorizedUser("Unknown", "Executar ficheiros").Select(resource => resource.ResourceName), Is.EquivalentTo(new string[] { })); }