public void User_Admin_Read_All_Files() { string fileName = "ContentJsonRoleBasedEmployee.json"; //this file has role Employee string[] pauloUserRoles = new string[] { "Admin" }; ConfigureMocks(pauloUserRoles); var jsonFileReaderRoleBased = new JsonFileReaderRoleBased(filePath, fileName, _mockUserAuthorizationService.Object, _mockFileRoleValidationService.Object); string contentFile = jsonFileReaderRoleBased.Read("Admin"); Assert.Equal("{\"Role\": \"Employee\",\"title\": \"Person\",\"type\": \"object\",\"lastName\": {\"type\": \"string\"}}", contentFile); }
public void A_User_Should_Be_Able_To_Read_JsonFile_In_RoleBased_Security() { string fileName = "ContentJsonRoleBasedVisitor.json"; string[] pauloUserRoles = new string[] { "Visitor" }; ConfigureMocks(pauloUserRoles); var jsonFileReaderRoleBased = new JsonFileReaderRoleBased(filePath, fileName, _mockUserAuthorizationService.Object, _mockFileRoleValidationService.Object); string contentFile = jsonFileReaderRoleBased.Read("Visitor"); Assert.Equal("{\"Role\": \"Visitor\",\"title\": \"Person\",\"type\": \"object\",\"lastName\": {\"type\": \"string\"}}", contentFile); }
public void User_Cannot_Read_JsonFile_DoesNot_Have_Is_Employee_Role() { var exception = Assert.Throws <FileSecurityException>(() => { string fileName = "ContentJsonRoleBasedEmployee.json"; //this file has role Employee string[] pauloUserRoles = new string[] { "Visitor" }; ConfigureMocks(pauloUserRoles); var jsonFileReaderRoleBased = new JsonFileReaderRoleBased(filePath, fileName, _mockUserAuthorizationService.Object, _mockFileRoleValidationService.Object); string contentFile = jsonFileReaderRoleBased.Read("Employee"); }); Assert.Contains("User can't read this file", exception.Message); }