-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 574382 - Change Role for Server Admin
* update SA _and_ other roles * add test case Change-Id: I79740da4861dcff3a972de844c834b6a4a1a5d08 Signed-off-by: Johannes Faltermeier <jfaltermeier@eclipsesource.com>
- Loading branch information
1 parent
67e0b2e
commit e823d2e
Showing
4 changed files
with
112 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
...re.server.test/src/org/eclipse/emf/emfstore/server/accesscontrol/test/ChangeRoleTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2011-2021 EclipseSource Muenchen GmbH and others. | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Johannes Faltermeier - initial API and implementation | ||
******************************************************************************/ | ||
package org.eclipse.emf.emfstore.server.accesscontrol.test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import org.eclipse.core.runtime.NullProgressMonitor; | ||
import org.eclipse.emf.emfstore.client.test.common.util.ServerUtil; | ||
import org.eclipse.emf.emfstore.internal.server.model.accesscontrol.ACUser; | ||
import org.eclipse.emf.emfstore.internal.server.model.accesscontrol.roles.RolesPackage; | ||
import org.eclipse.emf.emfstore.server.auth.ESProjectAdminPrivileges; | ||
import org.eclipse.emf.emfstore.server.exceptions.ESException; | ||
import org.junit.BeforeClass; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.ExpectedException; | ||
|
||
public class ChangeRoleTest extends ProjectAdminTest { | ||
|
||
// BEGIN COMPLEX CODE | ||
// Checkstyle complains about public modifier.. | ||
@Rule | ||
public final ExpectedException expectedException = ExpectedException.none(); | ||
|
||
// END COMPLEX CODE | ||
|
||
@BeforeClass | ||
public static void beforeClass() { | ||
startEMFStoreWithPAProperties( | ||
ESProjectAdminPrivileges.ShareProject, | ||
ESProjectAdminPrivileges.AssignRoleToOrgUnit // needed for share | ||
); | ||
} | ||
|
||
@Test | ||
public void changeSAPAtoWriter() throws ESException { | ||
// setup | ||
makeUserPA(); | ||
getLocalProject().shareProject(getUsersession(), new NullProgressMonitor()); | ||
makeUserSA(); | ||
ACUser user = ServerUtil.getUser(getSuperUsersession(), getUser()); | ||
assertTrue(ProjectAdminTest.hasServerAdminRole(user.getId())); | ||
assertTrue(ProjectAdminTest.hasProjectAdminRole(user, getProjectSpace().getProjectId())); | ||
assertEquals(2, user.getRoles().size()); | ||
|
||
// act | ||
getSuperAdminBroker().changeRole(getProjectSpace().getProjectId(), user.getId(), | ||
RolesPackage.eINSTANCE.getWriterRole()); | ||
|
||
// assert | ||
user = ServerUtil.getUser(getSuperUsersession(), getUser()); | ||
assertFalse(ProjectAdminTest.hasServerAdminRole(user.getId())); | ||
assertFalse(ProjectAdminTest.hasProjectAdminRole(user, getProjectSpace().getProjectId())); | ||
assertTrue(ProjectAdminTest.hasWriterRole(user.getId())); | ||
assertEquals(1, user.getRoles().size()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters