Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,9 @@ private void addPolicy(ResourcesApi resourcesApi, String resourceId, String poli

@Override
public boolean canDoAction(User user, Workflow workflow, Role.Action action) {
if (user == null) {
return false;
}
if (hasGoogleToken(user)) {
try {
final ResourcesApi resourcesApi = getResourcesApi(user);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,10 @@ void testCanRead() throws ApiException {
Workflow fooWorkflow = Mockito.mock(Workflow.class);
when(fooWorkflow.getWorkflowPath()).thenReturn(FOO_WORKFLOW_NAME, GOO_WORKFLOW_NAME);
assertTrue(samPermissionsImpl.canDoAction(janeDoeUserMock, fooWorkflow, Action.READ));
assertFalse(samPermissionsImpl.canDoAction(null, fooWorkflow, Action.READ));
Workflow gooWorkflow = Mockito.mock(Workflow.class);
assertFalse(samPermissionsImpl.canDoAction(janeDoeUserMock, gooWorkflow, Action.READ));
assertFalse(samPermissionsImpl.canDoAction(null, gooWorkflow, Action.READ));
}

@Test
Expand All @@ -252,9 +254,11 @@ void testCanWrite() throws ApiException {

when(workflowInstance.getWorkflowPath()).thenReturn(FOO_WORKFLOW_NAME);
assertTrue(samPermissionsImpl.canDoAction(janeDoeUserMock, workflowInstance, Action.WRITE));
assertFalse(samPermissionsImpl.canDoAction(null, workflowInstance, Action.WRITE));
Workflow gooWorkflow = Mockito.mock(Workflow.class);
when(gooWorkflow.getWorkflowPath()).thenReturn(GOO_WORKFLOW_NAME);
assertFalse(samPermissionsImpl.canDoAction(janeDoeUserMock, gooWorkflow, Action.WRITE));
assertFalse(samPermissionsImpl.canDoAction(null, gooWorkflow, Action.WRITE));
}

@Test
Expand Down
Loading