Skip to content

Commit

Permalink
Merge pull request zanata#404 from zanata/rhbz1077439
Browse files Browse the repository at this point in the history
rhbz1077439 Rename SecurityService.checkPermission to checkWorkspaceAction
  • Loading branch information
seanf committed Mar 28, 2014
2 parents 469fb24 + 4347931 commit a8fc512
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ else if (Objects.equal(hProject.getStatus(), READONLY)) {

hProject.addIteration(hProjectIteration);
// pre-emptive entity permission check
// identity.checkPermission(hProject, "add-iteration");
// identity.checkWorkspaceAction(hProject, "add-iteration");
identity.checkPermission(hProjectIteration, "insert");

response = Response.created(uri.getAbsolutePath());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public interface SecurityService {
* , org.jboss.seam.security.NotLoggedInException
* org.zanata.webtrans.shared.NoSuchWorkspaceException
*/
SecurityCheckResult checkPermission(AbstractWorkspaceAction action,
TranslationAction translationAction)
SecurityCheckResult checkWorkspaceAction(AbstractWorkspaceAction action,
TranslationAction translationAction)
throws NoSuchWorkspaceException;

HProject checkWorkspaceStatus(WorkspaceId workspaceId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ public class SecurityServiceImpl implements SecurityService {
private TranslationWorkspaceManager translationWorkspaceManager;

@Override
public SecurityCheckResult checkPermission(AbstractWorkspaceAction action,
TranslationAction translationAction)
public SecurityCheckResult checkWorkspaceAction(
AbstractWorkspaceAction action,
TranslationAction translationAction)
throws NoSuchWorkspaceException {
WorkspaceId workspaceId = action.getWorkspaceId();
HProject project = checkWorkspaceStatus(workspaceId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ public class ReplaceTextHandler extends
@Override
public UpdateTransUnitResult execute(ReplaceText action,
ExecutionContext context) throws ActionException {
securityServiceImpl.checkPermission(action,
SecurityService.TranslationAction.MODIFY);
securityServiceImpl.checkWorkspaceAction(action,
SecurityService.TranslationAction.MODIFY);

replaceTextInUpdateRequests(action);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ public class RevertTransUnitUpdatesHandler extends
public UpdateTransUnitResult execute(RevertTransUnitUpdates action,
ExecutionContext context) throws ActionException {
SecurityService.SecurityCheckResult securityCheckResult =
securityServiceImpl.checkPermission(action,
SecurityService.TranslationAction.MODIFY);
securityServiceImpl.checkWorkspaceAction(action,
SecurityService.TranslationAction.MODIFY);
HLocale hLocale = securityCheckResult.getLocale();
TranslationWorkspace workspace = securityCheckResult.getWorkspace();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public class TransMemoryMergeHandler extends
public UpdateTransUnitResult execute(TransMemoryMerge action,
ExecutionContext context) throws ActionException {
SecurityService.SecurityCheckResult securityCheckResult =
securityServiceImpl.checkPermission(action, MODIFY);
securityServiceImpl.checkWorkspaceAction(action, MODIFY);
HLocale hLocale = securityCheckResult.getLocale();
TranslationWorkspace workspace = securityCheckResult.getWorkspace();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ public boolean apply(TransUnitUpdateRequest input) {
}
});
if (hasReviewUpdate.isPresent()) {
securityServiceImpl.checkPermission(action,
SecurityService.TranslationAction.REVIEW);
securityServiceImpl.checkWorkspaceAction(action,
SecurityService.TranslationAction.REVIEW);
} else {
securityServiceImpl.checkPermission(action,
SecurityService.TranslationAction.MODIFY);
securityServiceImpl.checkWorkspaceAction(action,
SecurityService.TranslationAction.MODIFY);
}

return doTranslation(action.getWorkspaceId().getLocaleId(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public void putGlossary() {

// TODO SeamAutowire needs to handle @Restrict. See
// org.jboss.seam.security.SecurityInterceptor.Restriction.check(Object[])
// verify(mockIdentity).checkPermission(anyString(),
// verify(mockIdentity).checkWorkspaceAction(anyString(),
// eq("glossary-insert"));
}

Expand All @@ -178,7 +178,7 @@ public void deleteAllGlossaries() {

// TODO SeamAutowire needs to handle @Restrict. See
// org.jboss.seam.security.SecurityInterceptor.Restriction.check(Object[])
// verify(mockIdentity).checkPermission(anyString(),
// verify(mockIdentity).checkWorkspaceAction(anyString(),
// eq("glossary-delete"));
}

Expand All @@ -196,7 +196,7 @@ public void deleteGlossaryTermWithLocale() {

// TODO SeamAutowire needs to handle @Restrict. See
// org.jboss.seam.security.SecurityInterceptor.Restriction.check(Object[])
// verify(mockIdentity).checkPermission(anyString(),
// verify(mockIdentity).checkWorkspaceAction(anyString(),
// eq("glossary-delete"));
}

Expand Down Expand Up @@ -224,7 +224,7 @@ public void testPutGlossaries() {

// TODO SeamAutowire needs to handle @Restrict. See
// org.jboss.seam.security.SecurityInterceptor.Restriction.check(Object[])
// verify(mockIdentity).checkPermission(anyString(),
// verify(mockIdentity).checkWorkspaceAction(anyString(),
// eq("glossary-insert"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import java.util.List;

import org.hamcrest.Matchers;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.testng.annotations.BeforeMethod;
Expand All @@ -30,7 +28,6 @@
import org.zanata.webtrans.shared.model.DocumentId;
import org.zanata.webtrans.shared.model.TransUnitUpdateInfo;
import org.zanata.webtrans.shared.rpc.RevertTransUnitUpdates;
import org.zanata.webtrans.shared.rpc.TransUnitUpdated;
import org.zanata.webtrans.shared.rpc.UpdateTransUnitResult;

import com.google.common.collect.Lists;
Expand Down Expand Up @@ -78,8 +75,8 @@ public void testExecute() throws Exception {
RevertTransUnitUpdates action =
new RevertTransUnitUpdates(updatesToRevert);
when(
securityServiceImpl.checkPermission(action,
SecurityService.TranslationAction.MODIFY)).thenReturn(
securityServiceImpl.checkWorkspaceAction(action,
SecurityService.TranslationAction.MODIFY)).thenReturn(
checkResult);
when(checkResult.getLocale()).thenReturn(new HLocale(LocaleId.EN_US));
when(checkResult.getWorkspace()).thenReturn(translationWorkspace);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ private TransMemoryMerge prepareActionAndMockSecurityService(int threshold,
private void mockSecurityService(TransMemoryMerge action)
throws NoSuchWorkspaceException {
when(
securityService.checkPermission(action,
SecurityService.TranslationAction.MODIFY)).thenReturn(
securityService.checkWorkspaceAction(action,
SecurityService.TranslationAction.MODIFY)).thenReturn(
securityResult);
when(securityResult.getLocale()).thenReturn(hLocale);
when(securityResult.getWorkspace()).thenReturn(workspace);
Expand Down

0 comments on commit a8fc512

Please sign in to comment.