Skip to content

Commit

Permalink
test(engine): adjust auth query test cases to check additionally ids
Browse files Browse the repository at this point in the history
related to CAM-11796
  • Loading branch information
tasso94 committed Apr 24, 2020
1 parent e4727d7 commit fee1d17
Show file tree
Hide file tree
Showing 10 changed files with 314 additions and 204 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.camunda.bpm.engine.authorization.HistoricProcessInstancePermissions;
import org.camunda.bpm.engine.authorization.ProcessDefinitionPermissions;
import org.camunda.bpm.engine.authorization.Resources;
import org.camunda.bpm.engine.history.HistoricActivityInstance;
import org.camunda.bpm.engine.history.HistoricActivityInstanceQuery;
import org.camunda.bpm.engine.history.HistoricProcessInstance;
import org.camunda.bpm.engine.impl.AbstractQuery;
Expand Down Expand Up @@ -216,13 +215,11 @@ public void testCheckNonePermissionOnHistoricProcessInstance() {
HistoricProcessInstancePermissions.NONE);

// when
List<HistoricActivityInstance> result =
historyService.createHistoricActivityInstanceQuery()
.processInstanceId(processInstanceId)
.list();
HistoricActivityInstanceQuery query = historyService.createHistoricActivityInstanceQuery()
.processInstanceId(processInstanceId);

// then
assertThat(result.size()).isEqualTo(0);
assertThat(query.list()).isEmpty();
}

public void testCheckReadPermissionOnHistoricProcessInstance() {
Expand All @@ -235,12 +232,13 @@ public void testCheckReadPermissionOnHistoricProcessInstance() {
HistoricProcessInstancePermissions.READ);

// when
List<HistoricActivityInstance> result = historyService.createHistoricActivityInstanceQuery()
.processInstanceId(processInstanceId)
.list();
HistoricActivityInstanceQuery query = historyService.createHistoricActivityInstanceQuery()
.processInstanceId(processInstanceId);

// then
assertThat(result.size()).isEqualTo(2);
assertThat(query.list())
.extracting("processInstanceId")
.containsExactly(processInstanceId, processInstanceId);
}

public void testCheckReadPermissionOnCompletedHistoricProcessInstance() {
Expand All @@ -257,12 +255,13 @@ public void testCheckReadPermissionOnCompletedHistoricProcessInstance() {
HistoricProcessInstancePermissions.READ);

// when
List<HistoricActivityInstance> result = historyService.createHistoricActivityInstanceQuery()
.processInstanceId(processInstanceId)
.list();
HistoricActivityInstanceQuery query = historyService.createHistoricActivityInstanceQuery()
.processInstanceId(processInstanceId);

// then
assertThat(result.size()).isEqualTo(3);
assertThat(query.list())
.extracting("processInstanceId")
.containsExactly(processInstanceId, processInstanceId, processInstanceId);
}

public void testCheckNoneOnHistoricProcessInstanceAndReadHistoryPermissionOnProcessDefinition() {
Expand All @@ -280,12 +279,13 @@ public void testCheckNoneOnHistoricProcessInstanceAndReadHistoryPermissionOnProc
createGrantAuthorization(PROCESS_DEFINITION, PROCESS_KEY, userId, READ_HISTORY);

// when
List<HistoricActivityInstance> result = historyService.createHistoricActivityInstanceQuery()
.processInstanceId(processInstanceId)
.list();
HistoricActivityInstanceQuery query = historyService.createHistoricActivityInstanceQuery()
.processInstanceId(processInstanceId);

// then
assertThat(result.size()).isEqualTo(3);
assertThat(query.list())
.extracting("processInstanceId")
.containsExactly(processInstanceId, processInstanceId, processInstanceId);
}

public void testCheckReadOnHistoricProcessInstanceAndNonePermissionOnProcessDefinition() {
Expand All @@ -304,12 +304,13 @@ public void testCheckReadOnHistoricProcessInstanceAndNonePermissionOnProcessDefi
ProcessDefinitionPermissions.NONE);

// when
List<HistoricActivityInstance> result = historyService.createHistoricActivityInstanceQuery()
.processInstanceId(processInstanceId)
.list();
HistoricActivityInstanceQuery query = historyService.createHistoricActivityInstanceQuery()
.processInstanceId(processInstanceId);

// then
assertThat(result.size()).isEqualTo(3);
assertThat(query.list())
.extracting("processInstanceId")
.containsExactly(processInstanceId, processInstanceId, processInstanceId);
}

public void testHistoricProcessInstancePermissionsAuthorizationDisabled() {
Expand All @@ -321,15 +322,15 @@ public void testHistoricProcessInstancePermissionsAuthorizationDisabled() {
disableAuthorization();

// when
List<HistoricActivityInstance> result = historyService.createHistoricActivityInstanceQuery()
.processInstanceId(processInstanceId)
.list();
HistoricActivityInstanceQuery query = historyService.createHistoricActivityInstanceQuery()
.processInstanceId(processInstanceId);

// then
assertThat(result.size()).isEqualTo(2);
assertThat(query.list())
.extracting("processInstanceId")
.containsExactly(processInstanceId, processInstanceId);
}


// helper ////////////////////////////////////////////////////////

protected void verifyQueryResults(HistoricActivityInstanceQuery query, int countExpected) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1015,11 +1015,10 @@ public void testCheckNonePermissionOnHistoricProcessInstance() {
HistoricProcessInstancePermissions.NONE);

// when
List<HistoricDetail> result = historyService.createHistoricDetailQuery()
.list();
HistoricDetailQuery query = historyService.createHistoricDetailQuery();

// then
assertThat(result.size()).isEqualTo(0);
assertThat(query.list()).isEmpty();
}

public void testCheckReadPermissionOnHistoricProcessInstance_GlobalVariable() {
Expand All @@ -1035,11 +1034,12 @@ public void testCheckReadPermissionOnHistoricProcessInstance_GlobalVariable() {
HistoricProcessInstancePermissions.READ);

// when
List<HistoricDetail> result = historyService.createHistoricDetailQuery()
.list();
HistoricDetailQuery query = historyService.createHistoricDetailQuery();

// then
assertThat(result.size()).isEqualTo(1);
assertThat(query.list())
.extracting("processInstanceId")
.containsExactly(processInstanceId);
}

public void testCheckReadPermissionOnHistoricProcessInstance_LocalVariable() {
Expand All @@ -1056,11 +1056,12 @@ public void testCheckReadPermissionOnHistoricProcessInstance_LocalVariable() {
HistoricProcessInstancePermissions.READ);

// when
List<HistoricDetail> result = historyService.createHistoricDetailQuery()
.list();
HistoricDetailQuery query = historyService.createHistoricDetailQuery();

// then
assertThat(result.size()).isEqualTo(1);
assertThat(query.list())
.extracting("processInstanceId")
.containsExactly(processInstanceId);
}

public void testCheckReadPermissionOnCompletedHistoricProcessInstance() {
Expand All @@ -1078,11 +1079,12 @@ public void testCheckReadPermissionOnCompletedHistoricProcessInstance() {
HistoricProcessInstancePermissions.READ);

// when
List<HistoricDetail> result = historyService.createHistoricDetailQuery()
.list();
HistoricDetailQuery query = historyService.createHistoricDetailQuery();

// then
assertThat(result.size()).isEqualTo(1);
assertThat(query.list())
.extracting("processInstanceId")
.containsExactly(processInstanceId);
}

public void testCheckNoneOnHistoricProcessInstanceAndReadHistoryPermissionOnProcessDefinition() {
Expand All @@ -1101,11 +1103,12 @@ public void testCheckNoneOnHistoricProcessInstanceAndReadHistoryPermissionOnProc
createGrantAuthorization(PROCESS_DEFINITION, PROCESS_KEY, userId, READ_HISTORY);

// when
List<HistoricDetail> result = historyService.createHistoricDetailQuery()
.list();
HistoricDetailQuery query = historyService.createHistoricDetailQuery();

// then
assertThat(result.size()).isEqualTo(1);
assertThat(query.list())
.extracting("processInstanceId")
.containsExactly(processInstanceId);
}

public void testCheckReadOnHistoricProcessInstanceAndNonePermissionOnProcessDefinition() {
Expand All @@ -1125,11 +1128,12 @@ public void testCheckReadOnHistoricProcessInstanceAndNonePermissionOnProcessDefi
ProcessDefinitionPermissions.NONE);

// when
List<HistoricDetail> result = historyService.createHistoricDetailQuery()
.list();
HistoricDetailQuery query = historyService.createHistoricDetailQuery();

// then
assertThat(result.size()).isEqualTo(1);
assertThat(query.list())
.extracting("processInstanceId")
.containsExactly(processInstanceId);
}

// helper ////////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,11 +368,10 @@ public void testCheckNonePermissionOnHistoricProcessInstance() {
HistoricProcessInstancePermissions.NONE);

// when
List<HistoricIdentityLinkLog> result = historyService.createHistoricIdentityLinkLogQuery()
.list();
HistoricIdentityLinkLogQuery query = historyService.createHistoricIdentityLinkLogQuery();

// then
assertThat(result.size()).isEqualTo(0);
assertThat(query.list()).isEmpty();
}

public void testCheckReadPermissionOnHistoricProcessInstance() {
Expand All @@ -385,11 +384,12 @@ public void testCheckReadPermissionOnHistoricProcessInstance() {
HistoricProcessInstancePermissions.READ);

// when
List<HistoricIdentityLinkLog> result = historyService.createHistoricIdentityLinkLogQuery()
.list();
HistoricIdentityLinkLogQuery query = historyService.createHistoricIdentityLinkLogQuery();

// then
assertThat(result.size()).isEqualTo(1);
assertThat(query.list())
.extracting("rootProcessInstanceId")
.containsExactly(processInstanceId);
}

public void testCheckReadPermissionOnCompletedHistoricProcessInstance() {
Expand All @@ -406,11 +406,12 @@ public void testCheckReadPermissionOnCompletedHistoricProcessInstance() {
HistoricProcessInstancePermissions.READ);

// when
List<HistoricIdentityLinkLog> result = historyService.createHistoricIdentityLinkLogQuery()
.list();
HistoricIdentityLinkLogQuery query = historyService.createHistoricIdentityLinkLogQuery();

// then
assertThat(result.size()).isEqualTo(1);
assertThat(query.list())
.extracting("rootProcessInstanceId")
.containsExactly(processInstanceId);
}

public void testCheckNoneOnHistoricProcessInstanceAndReadHistoryPermissionOnProcessDefinition() {
Expand All @@ -428,11 +429,12 @@ public void testCheckNoneOnHistoricProcessInstanceAndReadHistoryPermissionOnProc
createGrantAuthorization(PROCESS_DEFINITION, ONE_PROCESS_KEY, userId, READ_HISTORY);

// when
List<HistoricIdentityLinkLog> result = historyService.createHistoricIdentityLinkLogQuery()
.list();
HistoricIdentityLinkLogQuery query = historyService.createHistoricIdentityLinkLogQuery();

// then
assertThat(result.size()).isEqualTo(1);
assertThat(query.list())
.extracting("rootProcessInstanceId")
.containsExactly(processInstanceId);
}

public void testCheckReadOnHistoricProcessInstanceAndNonePermissionOnProcessDefinition() {
Expand All @@ -451,11 +453,12 @@ public void testCheckReadOnHistoricProcessInstanceAndNonePermissionOnProcessDefi
ProcessDefinitionPermissions.NONE);

// when
List<HistoricIdentityLinkLog> result = historyService.createHistoricIdentityLinkLogQuery()
.list();
HistoricIdentityLinkLogQuery query = historyService.createHistoricIdentityLinkLogQuery();

// then
assertThat(result.size()).isEqualTo(1);
assertThat(query.list())
.extracting("rootProcessInstanceId")
.containsExactly(processInstanceId);
}

public void createTaskAndAssignUser(String taskId) {
Expand Down
Loading

0 comments on commit fee1d17

Please sign in to comment.