Commit 118e0068 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch '778-access-denied' into 'devel_12.2.x'

Resolve ""Access denied" is thrown"

See merge request !728
parents 29851a1b d9cc78db
Pipeline #9644 passed with stage
in 10 minutes and 39 seconds
......@@ -7,6 +7,9 @@ minerva (12.2.2) stable; urgency=medium
disease id from project upload was used instead (#779)
* Bug fix: user login with special characters (like '@') could cause
problems in admin panel (#780)
* Bug fix: removing project without full control in the system (but with
enough privileges to remove project) caused "Not enough privileges" error
(#778)
minerva (12.2.1) stable; urgency=medium
* Bug fix: export of reaction colorsi in SBML is properly encoded (COPASI can
......
......@@ -33,6 +33,8 @@ import lcsb.mapviewer.converter.zip.ZipEntryFile;
import lcsb.mapviewer.model.Project;
import lcsb.mapviewer.model.map.MiriamType;
import lcsb.mapviewer.model.map.model.Model;
import lcsb.mapviewer.model.user.PrivilegeType;
import lcsb.mapviewer.model.user.User;
import lcsb.mapviewer.persist.dao.ProjectDao;
import lcsb.mapviewer.services.interfaces.IModelService;
import lcsb.mapviewer.services.interfaces.IProjectService;
......@@ -81,6 +83,24 @@ public class ProjectRestImplTest extends RestTestFunctions {
}
}
@Test
public void testRemoveProject() throws Exception {
try {
String projectId = "test";
Project project = new Project();
project.setProjectId(projectId);
projectDao.add(project);
User user = userService.getUserByToken(token);
userService.setUserPrivilege(user, PrivilegeType.VIEW_PROJECT,1, project.getId(), adminToken);
userService.setUserPrivilege(user, PrivilegeType.PROJECT_MANAGEMENT, 1);
// userService.setUserPrivilege(user, PrivilegeType.VIEW_PROJECT, 1);
_projectRestImpl.removeProject(token, projectId, null);
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
@Test(expected = ObjectNotFoundException.class)
public void testGetInvalidMetaData() throws Exception {
ProjectRestImpl projectRest = createMockProjectRest(null);
......
package lcsb.mapviewer.api.projects.mirnas;
import static org.junit.Assert.assertFalse;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
import java.util.HashSet;
import java.util.List;
......@@ -14,12 +12,10 @@ import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
import lcsb.mapviewer.api.RestTestFunctions;
import lcsb.mapviewer.model.map.model.Model;
import lcsb.mapviewer.services.interfaces.IModelService;
public class MiRnaRestImplTest extends RestTestFunctions {
Logger logger = Logger.getLogger(MiRnaRestImplTest.class);
......
......@@ -303,7 +303,6 @@ public class ProjectService implements IProjectService {
homeDir = null;
}
}
removePrivilegesForProject(p);
updateProjectStatus(p, ProjectStatus.REMOVING, 0, new CreateProjectParams());
Thread computations = new Thread(new Runnable() {
......@@ -355,6 +354,7 @@ public class ProjectService implements IProjectService {
}
}
}
removePrivilegesForProject(project);
projectDao.delete(project);
if (async) {
projectDao.commit();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment