public void User_Admin_Read_All_Files() { string fileName = "ContentXMLRoleBasedEmployee.xml"; //this file has role Employee string[] pauloUserRoles = new string[] { "Admin" }; ConfigureMocks(pauloUserRoles); var xmlFileReaderRoleBased = new XmlFileReaderRoleBased(filePath, fileName, _mockUserAuthorizationService.Object, _mockFileRoleValidationService.Object); string contentFile = xmlFileReaderRoleBased.Read("Admin"); Assert.Equal("<note role=\"Employee\"><to>Tove</to><from>Jani</from></note>", contentFile); }
public void A_User_Should_Be_Able_To_Read_XmlFile_In_RoleBased_Security() { string fileName = "ContentXMLRoleBasedVisitor.xml"; string[] pauloUserRoles = new string[] { "Visitor" }; ConfigureMocks(pauloUserRoles); var xmlFileReaderRoleBased = new XmlFileReaderRoleBased(filePath, fileName, _mockUserAuthorizationService.Object, _mockFileRoleValidationService.Object); string contentFile = xmlFileReaderRoleBased.Read("Visitor"); Assert.Equal("<note role=\"Visitor\"><to>Tove</to><from>Jani</from></note>", contentFile); }
public void User_Cannot_Read_XmlFile_DoesNot_Have_Employee_Role() { var exception = Assert.Throws <FileSecurityException>(() => { string fileName = "ContentXMLRoleBasedEmployee.xml"; //this file has role Employee string[] pauloUserRoles = new string[] { "Visitor" }; ConfigureMocks(pauloUserRoles); var xmlFileReaderRoleBased = new XmlFileReaderRoleBased(filePath, fileName, _mockUserAuthorizationService.Object, _mockFileRoleValidationService.Object); string contentFile = xmlFileReaderRoleBased.Read("Employee"); }); Assert.Contains("User can't read this file", exception.Message); }