TSK-1664: fixed some code smells and redesigned RestHelper
This commit is contained in:
parent
1eb3ccec78
commit
358e699f9f
|
@ -102,6 +102,8 @@ public class SampleDataGenerator {
|
|||
|
||||
if (LOGGER.isTraceEnabled()) {
|
||||
LOGGER.trace(outWriter.toString());
|
||||
}
|
||||
if (LOGGER.isErrorEnabled()) {
|
||||
String trimmedErrorString = errorWriter.toString().trim();
|
||||
if (!trimmedErrorString.isEmpty()) {
|
||||
LOGGER.error(trimmedErrorString);
|
||||
|
|
|
@ -22,7 +22,7 @@ public class CurrentUserContextImpl implements CurrentUserContext {
|
|||
private static final String GET_CALLER_SUBJECT_METHOD = "getCallerSubject";
|
||||
private static final String WSSUBJECT_CLASSNAME = "com.ibm.websphere.security.auth.WSSubject";
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(CurrentUserContext.class);
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(CurrentUserContextImpl.class);
|
||||
private final boolean shouldUseLowerCaseForAccessIds;
|
||||
private boolean runningOnWebSphere;
|
||||
|
||||
|
|
|
@ -100,7 +100,8 @@ public class BaseRestDocTest {
|
|||
public RequestPostProcessor beforeMockMvcCreated(
|
||||
@NonNull ConfigurableMockMvcBuilder<?> builder, @NonNull WebApplicationContext cxt) {
|
||||
builder.defaultRequest(
|
||||
MockMvcRequestBuilders.post("/test").headers(restHelper.getHeadersAdmin()));
|
||||
MockMvcRequestBuilders.post("/test")
|
||||
.headers(RestHelper.generateHeadersForUser("admin")));
|
||||
return super.beforeMockMvcCreated(builder, cxt);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -6,7 +6,10 @@ import com.fasterxml.jackson.databind.SerializationFeature;
|
|||
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
import com.fasterxml.jackson.module.paramnames.ParameterNamesModule;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Base64;
|
||||
import java.util.Collections;
|
||||
import java.util.Optional;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.hateoas.MediaTypes;
|
||||
|
@ -21,15 +24,6 @@ import org.springframework.web.util.UriComponentsBuilder;
|
|||
@Component
|
||||
public class RestHelper {
|
||||
|
||||
public static final String AUTHORIZATION_TEAMLEAD_1 = "Basic dGVhbWxlYWQtMTp0ZWFtbGVhZC0x";
|
||||
public static final String AUTHORIZATION_ADMIN = "Basic YWRtaW46YWRtaW4=";
|
||||
public static final String AUTHORIZATION_BUSINESSADMIN =
|
||||
"Basic YnVzaW5lc3NhZG1pbjpidXNpbmVzc2FkbWlu";
|
||||
public static final String AUTHORIZATION_USER_1_1 = "Basic dXNlci0xLTE6dXNlci0xLTE=";
|
||||
public static final String AUTHORIZATION_USER_1_2 = "Basic dXNlci0xLTI6dXNlci0xLTI=";
|
||||
public static final String AUTHORIZATION_USER_2_1 = "Basic dXNlci0yLTE6dXNlci0yLTE=";
|
||||
public static final String AUTHORIZATION_USER_B_1 = "Basic dXNlci1iLTE6dXNlci1iLTE=";
|
||||
|
||||
public static final RestTemplate TEMPLATE = getRestTemplate();
|
||||
|
||||
private Environment environment;
|
||||
|
@ -54,60 +48,22 @@ public class RestHelper {
|
|||
.toString();
|
||||
}
|
||||
|
||||
public HttpHeaders getHeadersTeamlead_1() {
|
||||
public static HttpHeaders generateHeadersForUser(String user) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.add("Authorization", AUTHORIZATION_TEAMLEAD_1);
|
||||
headers.add("Content-Type", "application/json");
|
||||
headers.add("Authorization", encodeUserAndPasswordAsBasicAuth(user));
|
||||
headers.add("Content-Type", MediaTypes.HAL_JSON_VALUE);
|
||||
return headers;
|
||||
}
|
||||
|
||||
public HttpHeaders getHeadersAdmin() {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.add("Authorization", AUTHORIZATION_ADMIN);
|
||||
headers.add("Content-Type", "application/hal+json");
|
||||
return headers;
|
||||
}
|
||||
|
||||
public HttpHeaders getHeadersBusinessAdmin() {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.add("Authorization", AUTHORIZATION_BUSINESSADMIN);
|
||||
headers.add("Content-Type", "application/hal+json");
|
||||
return headers;
|
||||
}
|
||||
|
||||
public HttpHeaders getHeadersUser_1_2() {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.add("Authorization", AUTHORIZATION_USER_1_2);
|
||||
headers.add("Content-Type", "application/json");
|
||||
return headers;
|
||||
}
|
||||
|
||||
public HttpHeaders getHeadersUser_1_1() {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.add("Authorization", AUTHORIZATION_USER_1_1);
|
||||
headers.add("Content-Type", "application/json");
|
||||
return headers;
|
||||
}
|
||||
|
||||
public HttpHeaders getHeadersUser_2_1() {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.add("Authorization", AUTHORIZATION_USER_2_1);
|
||||
headers.add("Content-Type", "application/json");
|
||||
return headers;
|
||||
}
|
||||
|
||||
public HttpHeaders getHeadersUser_b_1() {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.add("Authorization", AUTHORIZATION_USER_B_1);
|
||||
headers.add("Content-Type", "application/json");
|
||||
return headers;
|
||||
public static String encodeUserAndPasswordAsBasicAuth(String user) {
|
||||
String toEncode = user + ":" + user;
|
||||
return "Basic " + Base64.getEncoder().encodeToString(toEncode.getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
private int getPort() {
|
||||
if (environment != null) {
|
||||
return environment.getRequiredProperty("local.server.port", int.class);
|
||||
}
|
||||
return port;
|
||||
return Optional.ofNullable(environment)
|
||||
.map(e -> e.getRequiredProperty("local.server.port", int.class))
|
||||
.orElse(port);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -116,11 +72,11 @@ public class RestHelper {
|
|||
* @return RestTemplate
|
||||
*/
|
||||
private static RestTemplate getRestTemplate() {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
|
||||
mapper.registerModule(new Jackson2HalModule());
|
||||
mapper
|
||||
ObjectMapper mapper =
|
||||
new ObjectMapper()
|
||||
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
|
||||
.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false)
|
||||
.registerModule(new Jackson2HalModule())
|
||||
.registerModule(new ParameterNamesModule())
|
||||
.registerModule(new Jdk8Module())
|
||||
.registerModule(new JavaTimeModule());
|
||||
|
|
|
@ -56,7 +56,7 @@ class TaskHistoryEventControllerIntTest {
|
|||
TEMPLATE.exchange(
|
||||
restHelper.toUrl(HistoryRestEndpoints.URL_HISTORY_EVENTS),
|
||||
HttpMethod.GET,
|
||||
new HttpEntity<>(restHelper.getHeadersTeamlead_1()),
|
||||
new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1")),
|
||||
TASK_HISTORY_EVENT_PAGED_REPRESENTATION_MODEL_TYPE);
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
assertThat(response.getBody().getContent()).hasSize(45);
|
||||
|
@ -68,7 +68,7 @@ class TaskHistoryEventControllerIntTest {
|
|||
TEMPLATE.exchange(
|
||||
restHelper.toUrl(HistoryRestEndpoints.URL_HISTORY_EVENTS),
|
||||
HttpMethod.GET,
|
||||
new HttpEntity<>(restHelper.getHeadersTeamlead_1()),
|
||||
new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1")),
|
||||
TASK_HISTORY_EVENT_PAGED_REPRESENTATION_MODEL_TYPE);
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF))
|
||||
|
@ -86,7 +86,7 @@ class TaskHistoryEventControllerIntTest {
|
|||
TEMPLATE.exchange(
|
||||
restHelper.toUrl(HistoryRestEndpoints.URL_HISTORY_EVENTS + parameters),
|
||||
HttpMethod.GET,
|
||||
new HttpEntity<>(restHelper.getHeadersTeamlead_1()),
|
||||
new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1")),
|
||||
TASK_HISTORY_EVENT_PAGED_REPRESENTATION_MODEL_TYPE);
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF))
|
||||
|
@ -104,7 +104,7 @@ class TaskHistoryEventControllerIntTest {
|
|||
TEMPLATE.exchange(
|
||||
restHelper.toUrl(HistoryRestEndpoints.URL_HISTORY_EVENTS + parameters),
|
||||
HttpMethod.GET,
|
||||
new HttpEntity<>(restHelper.getHeadersTeamlead_1()),
|
||||
new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1")),
|
||||
TASK_HISTORY_EVENT_PAGED_REPRESENTATION_MODEL_TYPE);
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
assertThat(response.getBody().getContent())
|
||||
|
@ -119,7 +119,7 @@ class TaskHistoryEventControllerIntTest {
|
|||
TEMPLATE.exchange(
|
||||
restHelper.toUrl(HistoryRestEndpoints.URL_HISTORY_EVENTS + parameters),
|
||||
HttpMethod.GET,
|
||||
new HttpEntity<>(restHelper.getHeadersTeamlead_1()),
|
||||
new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1")),
|
||||
TASK_HISTORY_EVENT_PAGED_REPRESENTATION_MODEL_TYPE);
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
assertThat(response.getBody().getContent())
|
||||
|
@ -137,7 +137,7 @@ class TaskHistoryEventControllerIntTest {
|
|||
restHelper.toUrl(
|
||||
HistoryRestEndpoints.URL_HISTORY_EVENTS + "?created=" + currentTime),
|
||||
HttpMethod.GET,
|
||||
new HttpEntity<>(restHelper.getHeadersTeamlead_1()),
|
||||
new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1")),
|
||||
TASK_HISTORY_EVENT_PAGED_REPRESENTATION_MODEL_TYPE);
|
||||
assertThatThrownBy(httpCall)
|
||||
.isInstanceOf(HttpClientErrorException.class)
|
||||
|
@ -154,7 +154,7 @@ class TaskHistoryEventControllerIntTest {
|
|||
restHelper.toUrl(
|
||||
HistoryRestEndpoints.URL_HISTORY_EVENTS + "?created=" + now + "&created="),
|
||||
HttpMethod.GET,
|
||||
new HttpEntity<>(restHelper.getHeadersTeamlead_1()),
|
||||
new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1")),
|
||||
TASK_HISTORY_EVENT_PAGED_REPRESENTATION_MODEL_TYPE);
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF)).isNotNull();
|
||||
|
@ -174,7 +174,7 @@ class TaskHistoryEventControllerIntTest {
|
|||
TEMPLATE.exchange(
|
||||
restHelper.toUrl(HistoryRestEndpoints.URL_HISTORY_EVENTS + parameters),
|
||||
HttpMethod.GET,
|
||||
new HttpEntity<>(restHelper.getHeadersTeamlead_1()),
|
||||
new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1")),
|
||||
TASK_HISTORY_EVENT_PAGED_REPRESENTATION_MODEL_TYPE);
|
||||
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
|
@ -229,7 +229,7 @@ class TaskHistoryEventControllerIntTest {
|
|||
TEMPLATE.exchange(
|
||||
restHelper.toUrl(HistoryRestEndpoints.URL_HISTORY_EVENTS_ID, id),
|
||||
HttpMethod.GET,
|
||||
new HttpEntity<>(restHelper.getHeadersTeamlead_1()),
|
||||
new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1")),
|
||||
TASK_HISTORY_EVENT_PAGED_REPRESENTATION_MODEL_TYPE);
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
assertThat(response.getBody().getLink(IanaLinkRelations.SELF))
|
||||
|
@ -248,7 +248,7 @@ class TaskHistoryEventControllerIntTest {
|
|||
HistoryRestEndpoints.URL_HISTORY_EVENTS_ID,
|
||||
"THI:000000000000000000000000000000000000"),
|
||||
HttpMethod.GET,
|
||||
new HttpEntity<>(restHelper.getHeadersTeamlead_1()),
|
||||
new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1")),
|
||||
TASK_HISTORY_EVENT_REPRESENTATION_MODEL_TYPE);
|
||||
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
|
@ -267,7 +267,7 @@ class TaskHistoryEventControllerIntTest {
|
|||
+ "&anotherIllegalParam=stillIllegal"
|
||||
+ "&sort-by=TASK_ID&order=DESCENDING&page-size=5&page=2",
|
||||
HttpMethod.GET,
|
||||
new HttpEntity<>(restHelper.getHeadersTeamlead_1()),
|
||||
new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1")),
|
||||
TASK_HISTORY_EVENT_PAGED_REPRESENTATION_MODEL_TYPE);
|
||||
|
||||
assertThatThrownBy(httpCall)
|
||||
|
|
|
@ -29,7 +29,7 @@ public class ObjectReference {
|
|||
if (objectReference == null) {
|
||||
throw new InvalidArgumentException(
|
||||
String.format("%s of %s must not be null.", objRefType, objName));
|
||||
} else if (objectReference.getCompany() == null || objectReference.getCompany().length() == 0) {
|
||||
} else if (objectReference.getCompany() == null || objectReference.getCompany().isEmpty()) {
|
||||
throw new InvalidArgumentException(
|
||||
String.format("Company of %s of %s must not be empty", objRefType, objName));
|
||||
} else if (objectReference.getType() == null || objectReference.getType().length() == 0) {
|
||||
|
|
|
@ -62,6 +62,7 @@ import pro.taskana.task.api.exceptions.TaskAlreadyExistException;
|
|||
import pro.taskana.task.api.exceptions.TaskCommentNotFoundException;
|
||||
import pro.taskana.task.api.exceptions.TaskNotFoundException;
|
||||
import pro.taskana.task.api.models.Attachment;
|
||||
import pro.taskana.task.api.models.AttachmentSummary;
|
||||
import pro.taskana.task.api.models.ObjectReference;
|
||||
import pro.taskana.task.api.models.Task;
|
||||
import pro.taskana.task.api.models.TaskComment;
|
||||
|
@ -1029,12 +1030,12 @@ public class TaskServiceImpl implements TaskService {
|
|||
.map(id -> Pair.of(id, taskSummaryMap.get(id)))
|
||||
.filter(
|
||||
pair -> {
|
||||
if (pair.getRight() == null) {
|
||||
if (pair.getRight() != null) {
|
||||
return true;
|
||||
}
|
||||
String taskId = pair.getLeft();
|
||||
bulkLog.addError(taskId, new TaskNotFoundException(taskId));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
})
|
||||
.map(Pair::getRight);
|
||||
}
|
||||
|
@ -1541,34 +1542,26 @@ public class TaskServiceImpl implements TaskService {
|
|||
}
|
||||
|
||||
private List<ClassificationSummary> findClassificationsForTasksAndAttachments(
|
||||
List<TaskSummaryImpl> taskSummaries, List<AttachmentSummaryImpl> attachmentSummaries) {
|
||||
List<? extends TaskSummaryImpl> taskSummaries,
|
||||
List<? extends AttachmentSummaryImpl> attachmentSummaries) {
|
||||
if (taskSummaries == null || taskSummaries.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
Set<String> classificationIdSet =
|
||||
taskSummaries.stream()
|
||||
.map(t -> t.getClassificationSummary().getId())
|
||||
Stream.concat(
|
||||
taskSummaries.stream().map(TaskSummary::getClassificationSummary),
|
||||
attachmentSummaries.stream().map(AttachmentSummary::getClassificationSummary))
|
||||
.map(ClassificationSummary::getId)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
if (attachmentSummaries != null && !attachmentSummaries.isEmpty()) {
|
||||
for (AttachmentSummaryImpl att : attachmentSummaries) {
|
||||
classificationIdSet.add(att.getClassificationSummary().getId());
|
||||
}
|
||||
}
|
||||
return queryClassificationsForTasksAndAttachments(classificationIdSet);
|
||||
}
|
||||
|
||||
private List<ClassificationSummary> findClassificationForTaskImplAndAttachments(
|
||||
TaskImpl task, List<AttachmentImpl> attachmentImpls) {
|
||||
Set<String> classificationIdSet =
|
||||
new HashSet<>(Collections.singletonList(task.getClassificationSummary().getId()));
|
||||
if (attachmentImpls != null && !attachmentImpls.isEmpty()) {
|
||||
for (AttachmentImpl att : attachmentImpls) {
|
||||
classificationIdSet.add(att.getClassificationSummary().getId());
|
||||
}
|
||||
}
|
||||
return queryClassificationsForTasksAndAttachments(classificationIdSet);
|
||||
return findClassificationsForTasksAndAttachments(
|
||||
Collections.singletonList(task), attachmentImpls);
|
||||
}
|
||||
|
||||
private List<ClassificationSummary> queryClassificationsForTasksAndAttachments(
|
||||
|
|
|
@ -276,24 +276,16 @@ class CreateTaskAccTest extends AbstractAccTest {
|
|||
engineProxy.openConnection();
|
||||
String customProperties =
|
||||
mapper.getCustomAttributesAsString(createdTask.getAttachments().get(0).getId());
|
||||
assertThat(customProperties.contains("\"Property_26\":\"Property Value of Property_26\""))
|
||||
.isTrue();
|
||||
assertThat(customProperties.contains("\"Property_25\":\"Property Value of Property_25\""))
|
||||
.isTrue();
|
||||
assertThat(customProperties.contains("\"Property_21\":\"Property Value of Property_21\""))
|
||||
.isTrue();
|
||||
assertThat(customProperties.contains("\"Property_19\":\"Property Value of Property_19\""))
|
||||
.isTrue();
|
||||
assertThat(customProperties.contains("\"Property_16\":\"Property Value of Property_16\""))
|
||||
.isTrue();
|
||||
assertThat(customProperties.contains("\"Property_12\":\"Property Value of Property_12\""))
|
||||
.isTrue();
|
||||
assertThat(customProperties.contains("\"Property_11\":\"Property Value of Property_11\""))
|
||||
.isTrue();
|
||||
assertThat(customProperties.contains("\"Property_7\":\"Property Value of Property_7\""))
|
||||
.isTrue();
|
||||
assertThat(customProperties.contains("\"Property_6\":\"Property Value of Property_6\""))
|
||||
.isTrue();
|
||||
assertThat(customProperties)
|
||||
.contains("\"Property_26\":\"Property Value of Property_26\"")
|
||||
.contains("\"Property_25\":\"Property Value of Property_25\"")
|
||||
.contains("\"Property_21\":\"Property Value of Property_21\"")
|
||||
.contains("\"Property_19\":\"Property Value of Property_19\"")
|
||||
.contains("\"Property_16\":\"Property Value of Property_16\"")
|
||||
.contains("\"Property_12\":\"Property Value of Property_12\"")
|
||||
.contains("\"Property_11\":\"Property Value of Property_11\"")
|
||||
.contains("\"Property_7\":\"Property Value of Property_7\"")
|
||||
.contains("\"Property_6\":\"Property Value of Property_6\"");
|
||||
} finally {
|
||||
engineProxy.returnConnection();
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ class AsyncUpdateJobIntTest {
|
|||
TEMPLATE.exchange(
|
||||
restHelper.toUrl(RestEndpoints.URL_CLASSIFICATIONS_ID, CLASSIFICATION_ID),
|
||||
HttpMethod.GET,
|
||||
new HttpEntity<>(restHelper.getHeadersTeamlead_1()),
|
||||
new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1")),
|
||||
ParameterizedTypeReference.forType(ClassificationRepresentationModel.class));
|
||||
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
|
@ -73,7 +73,7 @@ class AsyncUpdateJobIntTest {
|
|||
TEMPLATE.exchange(
|
||||
restHelper.toUrl(RestEndpoints.URL_CLASSIFICATIONS_ID, CLASSIFICATION_ID),
|
||||
HttpMethod.PUT,
|
||||
new HttpEntity<>(classification, restHelper.getHeadersTeamlead_1()),
|
||||
new HttpEntity<>(classification, RestHelper.generateHeadersForUser("teamlead-1")),
|
||||
ParameterizedTypeReference.forType(ClassificationRepresentationModel.class));
|
||||
|
||||
// trigger jobs twice to refresh all entries. first entry on the first call and follow up on the
|
||||
|
@ -86,7 +86,7 @@ class AsyncUpdateJobIntTest {
|
|||
TEMPLATE.exchange(
|
||||
restHelper.toUrl(RestEndpoints.URL_CLASSIFICATIONS_ID, CLASSIFICATION_ID),
|
||||
HttpMethod.GET,
|
||||
new HttpEntity<>(restHelper.getHeadersTeamlead_1()),
|
||||
new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1")),
|
||||
ParameterizedTypeReference.forType(ClassificationRepresentationModel.class));
|
||||
|
||||
assertThat(repeatedResponse.getBody()).isNotNull();
|
||||
|
@ -150,7 +150,7 @@ class AsyncUpdateJobIntTest {
|
|||
TEMPLATE.exchange(
|
||||
restHelper.toUrl(RestEndpoints.URL_TASKS_ID, taskId),
|
||||
HttpMethod.GET,
|
||||
new HttpEntity<>(restHelper.getHeadersAdmin()),
|
||||
new HttpEntity<>(RestHelper.generateHeadersForUser("admin")),
|
||||
ParameterizedTypeReference.forType(TaskRepresentationModel.class));
|
||||
|
||||
TaskRepresentationModel taskRepresentationModel = taskResponse.getBody();
|
||||
|
|
|
@ -50,7 +50,7 @@ public class AbstractAccTest {
|
|||
return RestHelper.TEMPLATE.exchange(
|
||||
restHelper.toUrl("/taskana" + HistoryRestEndpoints.URL_HISTORY_EVENTS),
|
||||
HttpMethod.GET,
|
||||
new HttpEntity<>(restHelper.getHeadersTeamlead_1()),
|
||||
new HttpEntity<>(restHelper.generateHeadersForUser("teamlead-1")),
|
||||
ParameterizedTypeReference.forType(TaskHistoryEventPagedRepresentationModel.class));
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ public class AbstractAccTest {
|
|||
return RestHelper.TEMPLATE.exchange(
|
||||
restHelper.toUrl("/taskana" + RestEndpoints.URL_TASKS),
|
||||
HttpMethod.POST,
|
||||
new HttpEntity<>(taskRepresentationModel, restHelper.getHeadersTeamlead_1()),
|
||||
new HttpEntity<>(taskRepresentationModel, restHelper.generateHeadersForUser("teamlead-1")),
|
||||
ParameterizedTypeReference.forType(TaskRepresentationModel.class));
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ public class TaskanaWildflyTest extends AbstractAccTest {
|
|||
TEMPLATE.exchange(
|
||||
restHelper.toUrl("/taskana" + RestEndpoints.URL_CURRENT_USER),
|
||||
HttpMethod.GET,
|
||||
new HttpEntity<>(restHelper.getHeadersTeamlead_1()),
|
||||
new HttpEntity<>(restHelper.generateHeadersForUser("teamlead-1")),
|
||||
ParameterizedTypeReference.forType(TaskanaUserInfoRepresentationModel.class));
|
||||
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
TaskanaUserInfoRepresentationModel currentUser = response.getBody();
|
||||
|
@ -90,7 +90,7 @@ public class TaskanaWildflyTest extends AbstractAccTest {
|
|||
TEMPLATE.exchange(
|
||||
restHelper.toUrl("/taskana" + RestEndpoints.URL_ACCESS_ID + "?search-for=rig"),
|
||||
HttpMethod.GET,
|
||||
new HttpEntity<>(restHelper.getHeadersTeamlead_1()),
|
||||
new HttpEntity<>(restHelper.generateHeadersForUser("teamlead-1")),
|
||||
new ParameterizedTypeReference<List<AccessIdRepresentationModel>>() {});
|
||||
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(response.getBody()).hasSize(2);
|
||||
|
@ -105,7 +105,7 @@ public class TaskanaWildflyTest extends AbstractAccTest {
|
|||
"/taskana" + RestEndpoints.URL_TASKS_ID,
|
||||
"TKI:000000000000000000000000000000000001"),
|
||||
HttpMethod.GET,
|
||||
new HttpEntity<>(restHelper.getHeadersTeamlead_1()),
|
||||
new HttpEntity<>(restHelper.generateHeadersForUser("teamlead-1")),
|
||||
ParameterizedTypeReference.forType(TaskRepresentationModel.class));
|
||||
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
|
|
|
@ -17,6 +17,7 @@ import org.springframework.http.ResponseEntity;
|
|||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.web.client.HttpClientErrorException;
|
||||
import org.springframework.web.client.HttpServerErrorException;
|
||||
import org.springframework.web.client.HttpStatusCodeException;
|
||||
|
||||
import pro.taskana.classification.rest.models.ClassificationRepresentationModel;
|
||||
import pro.taskana.classification.rest.models.ClassificationSummaryPagedRepresentationModel;
|
||||
|
@ -48,7 +49,7 @@ class ClassificationControllerIntTest {
|
|||
String url =
|
||||
restHelper.toUrl(
|
||||
RestEndpoints.URL_CLASSIFICATIONS_ID, "CLI:100000000000000000000000000000000002");
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ResponseEntity<ClassificationRepresentationModel> response =
|
||||
TEMPLATE.exchange(url, HttpMethod.GET, auth, CLASSIFICATION_REPRESENTATION_MODEL_TYPE);
|
||||
|
@ -61,7 +62,7 @@ class ClassificationControllerIntTest {
|
|||
@Test
|
||||
void testGetAllClassifications() {
|
||||
String url = restHelper.toUrl(RestEndpoints.URL_CLASSIFICATIONS);
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ResponseEntity<ClassificationSummaryPagedRepresentationModel> response =
|
||||
TEMPLATE.exchange(url, HttpMethod.GET, auth, CLASSIFICATION_SUMMARY_PAGE_MODEL_TYPE);
|
||||
|
@ -74,7 +75,7 @@ class ClassificationControllerIntTest {
|
|||
void testGetAllClassificationsFilterByCustomAttribute() {
|
||||
String url =
|
||||
restHelper.toUrl(RestEndpoints.URL_CLASSIFICATIONS) + "?domain=DOMAIN_A&custom-1-like=RVNR";
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ResponseEntity<ClassificationSummaryPagedRepresentationModel> response =
|
||||
TEMPLATE.exchange(url, HttpMethod.GET, auth, CLASSIFICATION_SUMMARY_PAGE_MODEL_TYPE);
|
||||
|
@ -89,7 +90,7 @@ class ClassificationControllerIntTest {
|
|||
String url =
|
||||
restHelper.toUrl(RestEndpoints.URL_CLASSIFICATIONS)
|
||||
+ "?domain=DOMAIN_A&sort-by=KEY&order=ASCENDING";
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ResponseEntity<ClassificationSummaryPagedRepresentationModel> response =
|
||||
TEMPLATE.exchange(url, HttpMethod.GET, auth, CLASSIFICATION_SUMMARY_PAGE_MODEL_TYPE);
|
||||
|
@ -107,7 +108,7 @@ class ClassificationControllerIntTest {
|
|||
String url =
|
||||
restHelper.toUrl(RestEndpoints.URL_CLASSIFICATIONS)
|
||||
+ "?domain=DOMAIN_A&sort-by=KEY&order=ASCENDING&page-size=5&page=2";
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ResponseEntity<ClassificationSummaryPagedRepresentationModel> response =
|
||||
TEMPLATE.exchange(url, HttpMethod.GET, auth, CLASSIFICATION_SUMMARY_PAGE_MODEL_TYPE);
|
||||
|
@ -129,25 +130,25 @@ class ClassificationControllerIntTest {
|
|||
@Test
|
||||
@DirtiesContext
|
||||
void testCreateClassification() {
|
||||
String newClassification =
|
||||
"{\"classificationId\":\"\",\"category\":\"MANUAL\","
|
||||
+ "\"domain\":\"DOMAIN_A\",\"key\":\"NEW_CLASS\","
|
||||
+ "\"name\":\"new classification\",\"type\":\"TASK\", \"serviceLevel\":\"P1D\"}";
|
||||
ClassificationRepresentationModel newClassification = new ClassificationRepresentationModel();
|
||||
newClassification.setType("TASK");
|
||||
newClassification.setCategory("MANUAL");
|
||||
newClassification.setDomain("DOMAIN_A");
|
||||
newClassification.setKey("NEW_CLASS");
|
||||
newClassification.setServiceLevel("P1D");
|
||||
newClassification.setName("new classification");
|
||||
String url = restHelper.toUrl(RestEndpoints.URL_CLASSIFICATIONS);
|
||||
HttpEntity<String> auth =
|
||||
new HttpEntity<>(newClassification, restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<?> auth =
|
||||
new HttpEntity<>(newClassification, RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ResponseEntity<ClassificationRepresentationModel> responseEntity =
|
||||
TEMPLATE.exchange(url, HttpMethod.POST, auth, CLASSIFICATION_REPRESENTATION_MODEL_TYPE);
|
||||
assertThat(responseEntity).isNotNull();
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.CREATED);
|
||||
|
||||
newClassification =
|
||||
"{\"classificationId\":\"\",\"category\":\"MANUAL\","
|
||||
+ "\"domain\":\"DOMAIN_A\",\"key\":\"NEW_CLASS_2\","
|
||||
+ "\"name\":\"new classification\",\"type\":\"TASK\", \"serviceLevel\":\"P1D\"}";
|
||||
HttpEntity<String> auth2 =
|
||||
new HttpEntity<>(newClassification, restHelper.getHeadersTeamlead_1());
|
||||
newClassification.setKey("NEW_CLASS_2");
|
||||
HttpEntity<?> auth2 =
|
||||
new HttpEntity<>(newClassification, RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
responseEntity =
|
||||
TEMPLATE.exchange(url, HttpMethod.POST, auth2, CLASSIFICATION_REPRESENTATION_MODEL_TYPE);
|
||||
|
@ -157,35 +158,42 @@ class ClassificationControllerIntTest {
|
|||
@Test
|
||||
@DirtiesContext
|
||||
void should_ThrowNotAuthorized_WhenUserIsNotInRoleAdminOrBusinessAdmin_whileCreating() {
|
||||
String newClassification =
|
||||
"{\"classificationId\":\"\",\"category\":\"MANUAL\","
|
||||
+ "\"domain\":\"DOMAIN_A\",\"key\":\"NEW_CLASS\","
|
||||
+ "\"name\":\"new classification\",\"type\":\"TASK\"}";
|
||||
ClassificationRepresentationModel newClassification = new ClassificationRepresentationModel();
|
||||
newClassification.setType("TASK");
|
||||
newClassification.setCategory("MANUAL");
|
||||
newClassification.setDomain("DOMAIN_A");
|
||||
newClassification.setKey("NEW_CLASS");
|
||||
newClassification.setName("new classification");
|
||||
|
||||
String url = restHelper.toUrl(RestEndpoints.URL_CLASSIFICATIONS);
|
||||
HttpEntity<String> auth = new HttpEntity<>(newClassification, restHelper.getHeadersUser_1_1());
|
||||
HttpEntity<?> auth =
|
||||
new HttpEntity<>(newClassification, RestHelper.generateHeadersForUser("user-1-1"));
|
||||
|
||||
ThrowingCallable httpCall =
|
||||
() -> {
|
||||
() ->
|
||||
TEMPLATE.exchange(url, HttpMethod.POST, auth, CLASSIFICATION_REPRESENTATION_MODEL_TYPE);
|
||||
};
|
||||
|
||||
assertThatThrownBy(httpCall)
|
||||
.isInstanceOf(HttpClientErrorException.class)
|
||||
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
|
||||
.extracting(HttpClientErrorException.class::cast)
|
||||
.extracting(HttpStatusCodeException::getStatusCode)
|
||||
.isEqualTo(HttpStatus.FORBIDDEN);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DirtiesContext
|
||||
void testCreateClassificationWithParentId() {
|
||||
String newClassification =
|
||||
"{\"classificationId\":\"\",\"category\":\"MANUAL\","
|
||||
+ "\"domain\":\"DOMAIN_B\",\"key\":\"NEW_CLASS_P1\","
|
||||
+ "\"name\":\"new classification\",\"type\":\"TASK\",\"serviceLevel\":\"P1D\","
|
||||
+ "\"parentId\":\"CLI:200000000000000000000000000000000015\"}";
|
||||
ClassificationRepresentationModel newClassification = new ClassificationRepresentationModel();
|
||||
newClassification.setType("TASK");
|
||||
newClassification.setCategory("MANUAL");
|
||||
newClassification.setDomain("DOMAIN_B");
|
||||
newClassification.setKey("NEW_CLASS_P1");
|
||||
newClassification.setName("new classification");
|
||||
newClassification.setServiceLevel("P1D");
|
||||
newClassification.setParentId("CLI:200000000000000000000000000000000015");
|
||||
String url = restHelper.toUrl(RestEndpoints.URL_CLASSIFICATIONS);
|
||||
HttpEntity<String> auth =
|
||||
new HttpEntity<>(newClassification, restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<?> auth =
|
||||
new HttpEntity<>(newClassification, RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ResponseEntity<ClassificationRepresentationModel> responseEntity =
|
||||
TEMPLATE.exchange(url, HttpMethod.POST, auth, CLASSIFICATION_REPRESENTATION_MODEL_TYPE);
|
||||
|
@ -196,15 +204,18 @@ class ClassificationControllerIntTest {
|
|||
|
||||
@Test
|
||||
@DirtiesContext
|
||||
@SuppressWarnings("checkstyle:LineLength")
|
||||
void testCreateClassificationWithParentKey() {
|
||||
String newClassification =
|
||||
"{\"classificationId\":\"\",\"category\":\"MANUAL\",\"domain\":\"DOMAIN_B\","
|
||||
+ "\"key\":\"NEW_CLASS_P2\",\"name\":\"new classification\","
|
||||
+ "\"type\":\"TASK\",\"parentKey\":\"T2100\",\"serviceLevel\":\"P1D\"}";
|
||||
ClassificationRepresentationModel newClassification = new ClassificationRepresentationModel();
|
||||
newClassification.setType("TASK");
|
||||
newClassification.setCategory("MANUAL");
|
||||
newClassification.setDomain("DOMAIN_B");
|
||||
newClassification.setKey("NEW_CLASS_P1");
|
||||
newClassification.setName("new classification");
|
||||
newClassification.setParentKey("T2100");
|
||||
newClassification.setServiceLevel("P1D");
|
||||
String url = restHelper.toUrl(RestEndpoints.URL_CLASSIFICATIONS);
|
||||
HttpEntity<String> auth =
|
||||
new HttpEntity<>(newClassification, restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<?> auth =
|
||||
new HttpEntity<>(newClassification, RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ResponseEntity<ClassificationRepresentationModel> responseEntity =
|
||||
TEMPLATE.exchange(url, HttpMethod.POST, auth, CLASSIFICATION_REPRESENTATION_MODEL_TYPE);
|
||||
|
@ -216,20 +227,24 @@ class ClassificationControllerIntTest {
|
|||
@Test
|
||||
@DirtiesContext
|
||||
void testCreateClassificationWithParentKeyInDomain_aShouldCreateAClassificationInRootDomain() {
|
||||
String newClassification =
|
||||
"{\"classificationId\":\"\",\"category\":\"MANUAL\",\"domain\":\"DOMAIN_A\","
|
||||
+ "\"key\":\"NEW_CLASS_P2\",\"name\":\"new classification\","
|
||||
+ "\"type\":\"TASK\",\"parentKey\":\"T2100\",\"serviceLevel\":\"P1D\"}";
|
||||
ClassificationRepresentationModel newClassification = new ClassificationRepresentationModel();
|
||||
newClassification.setType("TASK");
|
||||
newClassification.setCategory("MANUAL");
|
||||
newClassification.setDomain("DOMAIN_A");
|
||||
newClassification.setKey("NEW_CLASS_P2");
|
||||
newClassification.setName("new classification");
|
||||
newClassification.setParentKey("T2100");
|
||||
newClassification.setServiceLevel("P1D");
|
||||
String url = restHelper.toUrl(RestEndpoints.URL_CLASSIFICATIONS);
|
||||
HttpEntity<String> auth =
|
||||
new HttpEntity<>(newClassification, restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<?> auth =
|
||||
new HttpEntity<>(newClassification, RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ResponseEntity<ClassificationRepresentationModel> responseEntity =
|
||||
TEMPLATE.exchange(url, HttpMethod.POST, auth, CLASSIFICATION_REPRESENTATION_MODEL_TYPE);
|
||||
assertThat(responseEntity).isNotNull();
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.CREATED);
|
||||
|
||||
HttpEntity<Object> auth2 = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<?> auth2 = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
ResponseEntity<ClassificationSummaryPagedRepresentationModel> response =
|
||||
TEMPLATE.exchange(url, HttpMethod.GET, auth2, CLASSIFICATION_SUMMARY_PAGE_MODEL_TYPE);
|
||||
|
||||
|
@ -259,7 +274,7 @@ class ClassificationControllerIntTest {
|
|||
+ "\"parentKey\":\"T2000\",\"serviceLevel\":\"P1D\"}";
|
||||
String url = restHelper.toUrl(RestEndpoints.URL_CLASSIFICATIONS);
|
||||
HttpEntity<String> auth =
|
||||
new HttpEntity<>(newClassification, restHelper.getHeadersBusinessAdmin());
|
||||
new HttpEntity<>(newClassification, RestHelper.generateHeadersForUser("businessadmin"));
|
||||
|
||||
ThrowingCallable httpCall =
|
||||
() -> {
|
||||
|
@ -281,7 +296,7 @@ class ClassificationControllerIntTest {
|
|||
+ "\"name\":\"new classification\",\"type\":\"TASK\",\"serviceLevel\":\"P1D\"}";
|
||||
String url = restHelper.toUrl(RestEndpoints.URL_CLASSIFICATIONS);
|
||||
HttpEntity<String> auth =
|
||||
new HttpEntity<>(newClassification, restHelper.getHeadersBusinessAdmin());
|
||||
new HttpEntity<>(newClassification, RestHelper.generateHeadersForUser("businessadmin"));
|
||||
|
||||
ThrowingCallable httpCall =
|
||||
() -> {
|
||||
|
@ -299,7 +314,7 @@ class ClassificationControllerIntTest {
|
|||
String url =
|
||||
restHelper.toUrl(
|
||||
RestEndpoints.URL_CLASSIFICATIONS_ID, "CLI:100000000000000000000000000000000009");
|
||||
HttpEntity<String> auth = new HttpEntity<>(restHelper.getHeadersAdmin());
|
||||
HttpEntity<String> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("admin"));
|
||||
|
||||
ResponseEntity<ClassificationSummaryRepresentationModel> response =
|
||||
TEMPLATE.exchange(
|
||||
|
@ -315,7 +330,7 @@ class ClassificationControllerIntTest {
|
|||
String url =
|
||||
restHelper.toUrl(
|
||||
RestEndpoints.URL_CLASSIFICATIONS_ID, "CLI:200000000000000000000000000000000004");
|
||||
HttpEntity<String> auth = new HttpEntity<>(restHelper.getHeadersBusinessAdmin());
|
||||
HttpEntity<String> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("businessadmin"));
|
||||
|
||||
ResponseEntity<ClassificationSummaryRepresentationModel> response =
|
||||
TEMPLATE.exchange(
|
||||
|
@ -337,7 +352,7 @@ class ClassificationControllerIntTest {
|
|||
+ "&illegalParam=illegal"
|
||||
+ "&anotherIllegalParam=stillIllegal"
|
||||
+ "&sort-by=NAME&order=DESCENDING&page-size=5&page=2";
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ThrowingCallable httpCall =
|
||||
() -> {
|
||||
|
|
|
@ -80,7 +80,7 @@ class ClassificationDefinitionControllerIntTest {
|
|||
void should_ExportAllClassifications_When_ExportIsRequested() {
|
||||
String url =
|
||||
restHelper.toUrl(RestEndpoints.URL_CLASSIFICATION_DEFINITIONS) + "?domain=DOMAIN_B";
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
ResponseEntity<ClassificationDefinitionCollectionRepresentationModel> response =
|
||||
TEMPLATE.exchange(url, HttpMethod.GET, auth, CLASSIFICATION_DEFINITION_COLLECTION);
|
||||
|
||||
|
@ -101,7 +101,7 @@ class ClassificationDefinitionControllerIntTest {
|
|||
void should_NotContainAnyLinks_When_ExportIsRequested() {
|
||||
String url =
|
||||
restHelper.toUrl(RestEndpoints.URL_CLASSIFICATION_DEFINITIONS) + "?domain=DOMAIN_B";
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ResponseEntity<ClassificationDefinitionCollectionRepresentationModel> response =
|
||||
TEMPLATE.exchange(url, HttpMethod.GET, auth, CLASSIFICATION_DEFINITION_COLLECTION);
|
||||
|
@ -119,7 +119,7 @@ class ClassificationDefinitionControllerIntTest {
|
|||
@Test
|
||||
void should_ExportNothing_When_DomainIsUnknown() {
|
||||
String url = restHelper.toUrl(RestEndpoints.URL_CLASSIFICATION_DEFINITIONS) + "?domain=ADdfe";
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ResponseEntity<ClassificationDefinitionCollectionRepresentationModel> response =
|
||||
TEMPLATE.exchange(url, HttpMethod.GET, auth, CLASSIFICATION_DEFINITION_COLLECTION);
|
||||
|
@ -428,7 +428,7 @@ class ClassificationDefinitionControllerIntTest {
|
|||
MultiValueMap<String, FileSystemResource> body = new LinkedMultiValueMap<>();
|
||||
body.add("file", new FileSystemResource(tmpFile));
|
||||
|
||||
HttpHeaders headers = restHelper.getHeadersBusinessAdmin();
|
||||
HttpHeaders headers = RestHelper.generateHeadersForUser("businessadmin");
|
||||
headers.setContentType(MediaType.MULTIPART_FORM_DATA);
|
||||
|
||||
HttpEntity<?> requestEntity = new HttpEntity<>(body, headers);
|
||||
|
|
|
@ -51,7 +51,8 @@ class AccessIdControllerIntTest {
|
|||
pair -> {
|
||||
String url =
|
||||
restHelper.toUrl(RestEndpoints.URL_ACCESS_ID) + "?search-for=" + pair.getLeft();
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth =
|
||||
new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ResponseEntity<List<AccessIdRepresentationModel>> response =
|
||||
TEMPLATE.exchange(url, HttpMethod.GET, auth, ACCESS_ID_LIST_TYPE);
|
||||
|
@ -70,7 +71,7 @@ class AccessIdControllerIntTest {
|
|||
void should_ReturnEmptyResults_ifInvalidCharacterIsUsedInCondition() {
|
||||
String url =
|
||||
restHelper.toUrl(RestEndpoints.URL_ACCESS_ID) + "?search-for=ksc-teamleads,cn=groups";
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ResponseEntity<List<AccessIdRepresentationModel>> response =
|
||||
TEMPLATE.exchange(url, HttpMethod.GET, auth, ACCESS_ID_LIST_TYPE);
|
||||
|
@ -81,7 +82,7 @@ class AccessIdControllerIntTest {
|
|||
@Test
|
||||
void testGetMatches() {
|
||||
String url = restHelper.toUrl(RestEndpoints.URL_ACCESS_ID) + "?search-for=rig";
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ResponseEntity<List<AccessIdRepresentationModel>> response =
|
||||
TEMPLATE.exchange(url, HttpMethod.GET, auth, ACCESS_ID_LIST_TYPE);
|
||||
|
@ -95,7 +96,7 @@ class AccessIdControllerIntTest {
|
|||
@Test
|
||||
void should_ReturnAccessIdWithUmlauten_ifBased64EncodedUserIsLookedUp() {
|
||||
String url = restHelper.toUrl(RestEndpoints.URL_ACCESS_ID) + "?search-for=läf";
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ResponseEntity<List<AccessIdRepresentationModel>> response =
|
||||
TEMPLATE.exchange(url, HttpMethod.GET, auth, ACCESS_ID_LIST_TYPE);
|
||||
|
@ -109,7 +110,7 @@ class AccessIdControllerIntTest {
|
|||
@Test
|
||||
void should_ThrowException_When_SearchForIsTooShort() {
|
||||
String url = restHelper.toUrl(RestEndpoints.URL_ACCESS_ID) + "?search-for=al";
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ThrowingCallable httpCall =
|
||||
() -> {
|
||||
|
@ -127,7 +128,7 @@ class AccessIdControllerIntTest {
|
|||
@Test
|
||||
void should_ReturnAccessIdsOfGroupsTheAccessIdIsMemberOf_ifAccessIdOfUserIsGiven() {
|
||||
String url = restHelper.toUrl(RestEndpoints.URL_ACCESS_ID_GROUPS) + "?access-id=teamlead-2";
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ResponseEntity<List<AccessIdRepresentationModel>> response =
|
||||
TEMPLATE.exchange(url, HttpMethod.GET, auth, ACCESS_ID_LIST_TYPE);
|
||||
|
@ -147,7 +148,7 @@ class AccessIdControllerIntTest {
|
|||
@Test
|
||||
void should_ValidateAccessIdWithEqualsFilterAndReturnAccessIdsOfGroupsTheAccessIdIsMemberOf() {
|
||||
String url = restHelper.toUrl(RestEndpoints.URL_ACCESS_ID_GROUPS) + "?access-id=user-2-1";
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ResponseEntity<List<AccessIdRepresentationModel>> response =
|
||||
TEMPLATE.exchange(url, HttpMethod.GET, auth, ACCESS_ID_LIST_TYPE);
|
||||
|
@ -166,7 +167,7 @@ class AccessIdControllerIntTest {
|
|||
void should_ReturnBadRequest_ifAccessIdOfUserContainsInvalidCharacter() {
|
||||
String url =
|
||||
restHelper.toUrl(RestEndpoints.URL_ACCESS_ID_GROUPS) + "?access-id=teamlead-2,cn=users";
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ThrowingCallable call = () -> TEMPLATE.exchange(url, HttpMethod.GET, auth, ACCESS_ID_LIST_TYPE);
|
||||
|
||||
|
@ -183,7 +184,7 @@ class AccessIdControllerIntTest {
|
|||
restHelper.toUrl(RestEndpoints.URL_ACCESS_ID_GROUPS)
|
||||
+ "?access-id=cn=Organisationseinheit KSC 1,"
|
||||
+ "cn=Organisationseinheit KSC,cn=organisation,OU=Test,O=TASKANA";
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ResponseEntity<List<AccessIdRepresentationModel>> response =
|
||||
TEMPLATE.exchange(url, HttpMethod.GET, auth, ACCESS_ID_LIST_TYPE);
|
||||
|
@ -198,7 +199,7 @@ class AccessIdControllerIntTest {
|
|||
@Test
|
||||
void should_ThrowNotAuthorizedException_ifCallerOfGroupRetrievalIsNotAdminOrBusinessAdmin() {
|
||||
String url = restHelper.toUrl(RestEndpoints.URL_ACCESS_ID_GROUPS) + "?access-id=teamlead-2";
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersUser_1_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("user-1-1"));
|
||||
|
||||
ThrowingCallable call = () -> TEMPLATE.exchange(url, HttpMethod.GET, auth, ACCESS_ID_LIST_TYPE);
|
||||
|
||||
|
@ -211,7 +212,7 @@ class AccessIdControllerIntTest {
|
|||
@Test
|
||||
void should_ThrowNotAuthorizedException_ifCallerOfValidationIsNotAdminOrBusinessAdmin() {
|
||||
String url = restHelper.toUrl(RestEndpoints.URL_ACCESS_ID) + "?search-for=al";
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersUser_1_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("user-1-1"));
|
||||
|
||||
ThrowingCallable call = () -> TEMPLATE.exchange(url, HttpMethod.GET, auth, ACCESS_ID_LIST_TYPE);
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ class GeneralExceptionHandlingTest {
|
|||
@Test
|
||||
void testDeleteNonExisitingClassificationExceptionIsLogged() {
|
||||
String url = restHelper.toUrl(RestEndpoints.URL_CLASSIFICATIONS_ID, "non-existing-id");
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ThrowingCallable httpCall =
|
||||
() ->
|
||||
|
@ -61,7 +61,7 @@ class GeneralExceptionHandlingTest {
|
|||
@Test
|
||||
void should_ThrowExpressiveError_When_AQueryParameterIsInvalid() throws Exception {
|
||||
String url = restHelper.toUrl(RestEndpoints.URL_WORKBASKET) + "?required-permission=GROU";
|
||||
HttpEntity<String> auth = new HttpEntity<>(restHelper.getHeadersAdmin());
|
||||
HttpEntity<String> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("admin"));
|
||||
|
||||
ThrowingCallable httpCall =
|
||||
() ->
|
||||
|
@ -96,7 +96,7 @@ class GeneralExceptionHandlingTest {
|
|||
void should_CombineErrors_When_SameQueryParameterDeclarationsAreInvalidMultipleTimes()
|
||||
throws Exception {
|
||||
String url = restHelper.toUrl(RestEndpoints.URL_WORKBASKET) + "?type=GROU&type=invalid";
|
||||
HttpEntity<String> auth = new HttpEntity<>(restHelper.getHeadersAdmin());
|
||||
HttpEntity<String> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("admin"));
|
||||
|
||||
ThrowingCallable httpCall =
|
||||
() ->
|
||||
|
@ -133,7 +133,7 @@ class GeneralExceptionHandlingTest {
|
|||
void should_FilterOutValidQueryParameters_When_OnlySomeQueryParametersDeclarationsAreInvalid()
|
||||
throws Exception {
|
||||
String url = restHelper.toUrl(RestEndpoints.URL_WORKBASKET) + "?type=GROUP&type=invalid";
|
||||
HttpEntity<String> auth = new HttpEntity<>(restHelper.getHeadersAdmin());
|
||||
HttpEntity<String> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("admin"));
|
||||
|
||||
ThrowingCallable httpCall =
|
||||
() ->
|
||||
|
@ -168,7 +168,7 @@ class GeneralExceptionHandlingTest {
|
|||
void should_CombineErrors_When_DifferentQueryParametersAreInvalid() throws Exception {
|
||||
String url =
|
||||
restHelper.toUrl(RestEndpoints.URL_WORKBASKET) + "?type=GROU&required-permission=invalid";
|
||||
HttpEntity<String> auth = new HttpEntity<>(restHelper.getHeadersAdmin());
|
||||
HttpEntity<String> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("admin"));
|
||||
|
||||
ThrowingCallable httpCall =
|
||||
() ->
|
||||
|
|
|
@ -32,7 +32,7 @@ class TaskanaEngineControllerIntTest {
|
|||
@Test
|
||||
void testDomains() {
|
||||
String url = restHelper.toUrl(RestEndpoints.URL_DOMAIN);
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ResponseEntity<List<String>> response =
|
||||
TEMPLATE.exchange(
|
||||
|
@ -43,7 +43,7 @@ class TaskanaEngineControllerIntTest {
|
|||
@Test
|
||||
void testClassificationTypes() {
|
||||
String url = restHelper.toUrl(RestEndpoints.URL_CLASSIFICATION_TYPES);
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ResponseEntity<List<String>> response =
|
||||
TEMPLATE.exchange(
|
||||
|
@ -54,7 +54,7 @@ class TaskanaEngineControllerIntTest {
|
|||
@Test
|
||||
void testClassificationCategories() {
|
||||
String url = restHelper.toUrl(RestEndpoints.URL_CLASSIFICATION_CATEGORIES);
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ResponseEntity<List<String>> response =
|
||||
TEMPLATE.exchange(
|
||||
|
@ -66,7 +66,7 @@ class TaskanaEngineControllerIntTest {
|
|||
@Test
|
||||
void testGetCurrentUserInfo() {
|
||||
String url = restHelper.toUrl(RestEndpoints.URL_CURRENT_USER);
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ResponseEntity<TaskanaUserInfoRepresentationModel> response =
|
||||
TEMPLATE.exchange(
|
||||
|
|
|
@ -31,7 +31,7 @@ class MonitorControllerIntTest {
|
|||
restHelper.toUrl(RestEndpoints.URL_MONITOR_TASKS_STATUS_REPORT)
|
||||
+ "?workbasket-ids=WBI:100000000000000000000000000000000007"
|
||||
+ "&states=READY&states=CLAIMED";
|
||||
HttpEntity<String> auth = new HttpEntity<>(restHelper.getHeadersAdmin());
|
||||
HttpEntity<String> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("admin"));
|
||||
|
||||
ResponseEntity<ReportRepresentationModel> response =
|
||||
TEMPLATE.exchange(url, HttpMethod.GET, auth, REPORT_MODEL);
|
||||
|
@ -49,7 +49,7 @@ class MonitorControllerIntTest {
|
|||
@Test
|
||||
void should_ReturnAllOpenTasksByState_When_QueryingForSpecificWbAndStateReadyAndMinimumPrio() {
|
||||
String url = restHelper.toUrl(RestEndpoints.URL_MONITOR_TASKS_STATUS_REPORT);
|
||||
HttpEntity<String> auth = new HttpEntity<>(restHelper.getHeadersAdmin());
|
||||
HttpEntity<String> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("admin"));
|
||||
|
||||
ResponseEntity<ReportRepresentationModel> response =
|
||||
TEMPLATE.exchange(
|
||||
|
|
|
@ -43,7 +43,7 @@ class TaskCommentControllerIntTest {
|
|||
@Test
|
||||
void should_FailToReturnTaskComment_When_TaskCommentIsNotExisting() {
|
||||
String url = restHelper.toUrl(RestEndpoints.URL_TASK_COMMENT, "Non existing task comment Id");
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersAdmin());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("admin"));
|
||||
|
||||
ThrowingCallable httpCall =
|
||||
() -> {
|
||||
|
@ -60,7 +60,7 @@ class TaskCommentControllerIntTest {
|
|||
String url =
|
||||
restHelper.toUrl(
|
||||
RestEndpoints.URL_TASK_COMMENTS, "TKI:000000000000000000000000000000000004");
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersUser_1_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("user-1-1"));
|
||||
|
||||
ThrowingCallable httpCall =
|
||||
() -> {
|
||||
|
@ -77,7 +77,7 @@ class TaskCommentControllerIntTest {
|
|||
String url =
|
||||
restHelper.toUrl(
|
||||
RestEndpoints.URL_TASK_COMMENTS, "TKI:000000000000000000000000000000000000");
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersAdmin());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("admin"));
|
||||
|
||||
String url1 = url + "?sort-by=MODIFIED&order=DESCENDING";
|
||||
ResponseEntity<TaskCommentCollectionRepresentationModel>
|
||||
|
@ -125,7 +125,7 @@ class TaskCommentControllerIntTest {
|
|||
String url =
|
||||
restHelper.toUrl(
|
||||
RestEndpoints.URL_TASK_COMMENTS, "TKI:000000000000000000000000000000000000");
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersUser_1_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("user-1-1"));
|
||||
|
||||
ThrowingCallable httpCall =
|
||||
() -> {
|
||||
|
@ -146,7 +146,7 @@ class TaskCommentControllerIntTest {
|
|||
String url =
|
||||
restHelper.toUrl(
|
||||
RestEndpoints.URL_TASK_COMMENT, "TCI:000000000000000000000000000000000012");
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersUser_1_2());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("user-1-2"));
|
||||
|
||||
ThrowingCallable httpCall =
|
||||
() -> {
|
||||
|
@ -168,7 +168,8 @@ class TaskCommentControllerIntTest {
|
|||
restHelper.toUrl(
|
||||
RestEndpoints.URL_TASK_COMMENTS, "TKI:000000000000000000000000000000000000");
|
||||
HttpEntity<TaskCommentRepresentationModel> auth =
|
||||
new HttpEntity<>(taskCommentRepresentationModelToCreate, restHelper.getHeadersUser_b_1());
|
||||
new HttpEntity<>(
|
||||
taskCommentRepresentationModelToCreate, RestHelper.generateHeadersForUser("user-b-1"));
|
||||
|
||||
ThrowingCallable httpCall =
|
||||
() -> {
|
||||
|
@ -188,7 +189,8 @@ class TaskCommentControllerIntTest {
|
|||
taskCommentRepresentationModelToCreate.setTextField("newly created task comment");
|
||||
String url = restHelper.toUrl(RestEndpoints.URL_TASK_COMMENTS, "DefinatelyNotExistingId");
|
||||
HttpEntity<TaskCommentRepresentationModel> auth =
|
||||
new HttpEntity<>(taskCommentRepresentationModelToCreate, restHelper.getHeadersAdmin());
|
||||
new HttpEntity<>(
|
||||
taskCommentRepresentationModelToCreate, RestHelper.generateHeadersForUser("admin"));
|
||||
|
||||
ThrowingCallable httpCall =
|
||||
() -> {
|
||||
|
@ -205,7 +207,7 @@ class TaskCommentControllerIntTest {
|
|||
String url =
|
||||
restHelper.toUrl(
|
||||
RestEndpoints.URL_TASK_COMMENT, "TCI:000000000000000000000000000000000000");
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersAdmin());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("admin"));
|
||||
|
||||
ResponseEntity<TaskCommentRepresentationModel> getTaskCommentResponse =
|
||||
TEMPLATE.exchange(url, HttpMethod.GET, auth, TASK_COMMENT_TYPE);
|
||||
|
@ -217,7 +219,7 @@ class TaskCommentControllerIntTest {
|
|||
|
||||
taskCommentToUpdate.setModified(Instant.now());
|
||||
HttpEntity<TaskCommentRepresentationModel> auth2 =
|
||||
new HttpEntity<>(taskCommentToUpdate, restHelper.getHeadersUser_1_1());
|
||||
new HttpEntity<>(taskCommentToUpdate, RestHelper.generateHeadersForUser("user-1-1"));
|
||||
|
||||
ThrowingCallable httpCall =
|
||||
() -> {
|
||||
|
@ -233,7 +235,7 @@ class TaskCommentControllerIntTest {
|
|||
String url =
|
||||
restHelper.toUrl(
|
||||
RestEndpoints.URL_TASK_COMMENT, "TCI:000000000000000000000000000000000000");
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersUser_1_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("user-1-1"));
|
||||
|
||||
ResponseEntity<TaskCommentRepresentationModel> getTaskCommentResponse =
|
||||
TEMPLATE.exchange(url, HttpMethod.GET, auth, TASK_COMMENT_TYPE);
|
||||
|
@ -245,7 +247,7 @@ class TaskCommentControllerIntTest {
|
|||
|
||||
taskComment.setTextField("updated textfield");
|
||||
HttpEntity<TaskCommentRepresentationModel> auth2 =
|
||||
new HttpEntity<>(taskComment, restHelper.getHeadersUser_1_2());
|
||||
new HttpEntity<>(taskComment, RestHelper.generateHeadersForUser("user-1-2"));
|
||||
|
||||
ThrowingCallable httpCall =
|
||||
() -> {
|
||||
|
@ -261,7 +263,7 @@ class TaskCommentControllerIntTest {
|
|||
String url =
|
||||
restHelper.toUrl(
|
||||
RestEndpoints.URL_TASK_COMMENT, "TCI:000000000000000000000000000000000000");
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersAdmin());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("admin"));
|
||||
|
||||
ResponseEntity<TaskCommentRepresentationModel> getTaskCommentResponse =
|
||||
TEMPLATE.exchange(url, HttpMethod.GET, auth, TASK_COMMENT_TYPE);
|
||||
|
@ -275,7 +277,8 @@ class TaskCommentControllerIntTest {
|
|||
taskCommentRepresentationModelToUpdate.setTextField("updated text");
|
||||
taskCommentRepresentationModelToUpdate.setTaskCommentId("DifferentTaskCommentId");
|
||||
HttpEntity<TaskCommentRepresentationModel> auth2 =
|
||||
new HttpEntity<>(taskCommentRepresentationModelToUpdate, restHelper.getHeadersUser_1_1());
|
||||
new HttpEntity<>(
|
||||
taskCommentRepresentationModelToUpdate, RestHelper.generateHeadersForUser("user-1-1"));
|
||||
|
||||
ThrowingCallable httpCall =
|
||||
() -> {
|
||||
|
@ -291,7 +294,7 @@ class TaskCommentControllerIntTest {
|
|||
String url =
|
||||
restHelper.toUrl(
|
||||
RestEndpoints.URL_TASK_COMMENTS, "TKI:000000000000000000000000000000000001");
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersUser_1_2());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("user-1-2"));
|
||||
|
||||
ResponseEntity<TaskCommentCollectionRepresentationModel>
|
||||
getTaskCommentsBeforeDeleteionResponse =
|
||||
|
@ -316,7 +319,7 @@ class TaskCommentControllerIntTest {
|
|||
void should_FailToDeleteTaskComment_When_TaskCommentIsNotExisting() {
|
||||
|
||||
String url = restHelper.toUrl(RestEndpoints.URL_TASK_COMMENT, "NotExistingTaskComment");
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersAdmin());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("admin"));
|
||||
|
||||
ThrowingCallable httpCall =
|
||||
() -> {
|
||||
|
|
|
@ -84,7 +84,7 @@ class TaskControllerIntTest {
|
|||
@Test
|
||||
void testGetAllTasks() {
|
||||
String url = restHelper.toUrl(RestEndpoints.URL_TASKS);
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ResponseEntity<TaskSummaryPagedRepresentationModel> response =
|
||||
TEMPLATE.exchange(url, HttpMethod.GET, auth, TASK_SUMMARY_PAGE_MODEL_TYPE);
|
||||
|
@ -99,7 +99,7 @@ class TaskControllerIntTest {
|
|||
String url =
|
||||
restHelper.toUrl(RestEndpoints.URL_TASKS)
|
||||
+ "?workbasket-id=WBI:100000000000000000000000000000000001";
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ResponseEntity<TaskSummaryPagedRepresentationModel> response =
|
||||
TEMPLATE.exchange(url, HttpMethod.GET, auth, TASK_SUMMARY_PAGE_MODEL_TYPE);
|
||||
|
@ -124,7 +124,7 @@ class TaskControllerIntTest {
|
|||
+ "&planned=&planned=%s"
|
||||
+ "&sort-by=PLANNED",
|
||||
firstInstant, secondInstant, thirdInstant, fourthInstant);
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ResponseEntity<TaskSummaryPagedRepresentationModel> response =
|
||||
TEMPLATE.exchange(url, HttpMethod.GET, auth, TASK_SUMMARY_PAGE_MODEL_TYPE);
|
||||
|
@ -146,7 +146,7 @@ class TaskControllerIntTest {
|
|||
+ "&planned-until="
|
||||
+ plannedToInstant
|
||||
+ "&sort-by=PLANNED";
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ResponseEntity<TaskSummaryPagedRepresentationModel> response =
|
||||
TEMPLATE.exchange(url, HttpMethod.GET, auth, TASK_SUMMARY_PAGE_MODEL_TYPE);
|
||||
|
@ -165,7 +165,7 @@ class TaskControllerIntTest {
|
|||
+ "&planned-from="
|
||||
+ plannedFromInstant
|
||||
+ "&sort-by=PLANNED";
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ResponseEntity<TaskSummaryPagedRepresentationModel> response =
|
||||
TEMPLATE.exchange(url, HttpMethod.GET, auth, TASK_SUMMARY_PAGE_MODEL_TYPE);
|
||||
|
@ -185,7 +185,7 @@ class TaskControllerIntTest {
|
|||
+ ",2020-01-18T09:44:47.453Z"
|
||||
+ "&planned-from=2020-01-19T07:44:47.453Z"
|
||||
+ "&sort-by=planned";
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ThrowingCallable httpCall =
|
||||
() -> {
|
||||
|
@ -212,7 +212,7 @@ class TaskControllerIntTest {
|
|||
+ "&due=&due=%s"
|
||||
+ "&sort-by=DUE",
|
||||
firstInstant, secondInstant, thirdInstant, fourthInstant);
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ResponseEntity<TaskSummaryPagedRepresentationModel> response =
|
||||
TEMPLATE.exchange(url, HttpMethod.GET, auth, TASK_SUMMARY_PAGE_MODEL_TYPE);
|
||||
|
@ -230,7 +230,7 @@ class TaskControllerIntTest {
|
|||
+ "&wildcard-search-fields=NAME"
|
||||
+ "&wildcard-search-fields=CUSTOM_3"
|
||||
+ "&wildcard-search-fields=CUSTOM_4";
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersAdmin());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("admin"));
|
||||
|
||||
ResponseEntity<TaskSummaryPagedRepresentationModel> response =
|
||||
TEMPLATE.exchange(url, HttpMethod.GET, auth, TASK_SUMMARY_PAGE_MODEL_TYPE);
|
||||
|
@ -255,7 +255,8 @@ class TaskControllerIntTest {
|
|||
taskRepresentationModel.setCustomAttributes(List.of(customAttribute));
|
||||
String url = restHelper.toUrl(RestEndpoints.URL_TASKS);
|
||||
HttpEntity<TaskRepresentationModel> auth =
|
||||
new HttpEntity<>(taskRepresentationModel, restHelper.getHeadersTeamlead_1());
|
||||
new HttpEntity<>(
|
||||
taskRepresentationModel, RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ThrowingCallable httpCall =
|
||||
() -> {
|
||||
|
@ -279,7 +280,7 @@ class TaskControllerIntTest {
|
|||
+ "&task-id=TKI:000000000000000000000000000000000037"
|
||||
+ "&task-id=TKI:000000000000000000000000000000000038"
|
||||
+ "&custom14=abc";
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersAdmin());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("admin"));
|
||||
|
||||
ResponseEntity<TaskSummaryCollectionRepresentationModel> response =
|
||||
TEMPLATE.exchange(url, HttpMethod.DELETE, auth, TASK_SUMMARY_COLLECTION_MODEL_TYPE);
|
||||
|
@ -292,7 +293,7 @@ class TaskControllerIntTest {
|
|||
@Test
|
||||
void should_ThrowException_When_ProvidingInvalidWildcardSearchParameters() {
|
||||
String url = restHelper.toUrl(RestEndpoints.URL_TASKS) + "?wildcard-search-value=%rt%";
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ThrowingCallable httpCall =
|
||||
() -> {
|
||||
|
@ -330,7 +331,7 @@ class TaskControllerIntTest {
|
|||
+ "&due-until="
|
||||
+ dueToInstant
|
||||
+ "&sort-by=DUE";
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ResponseEntity<TaskSummaryPagedRepresentationModel> response =
|
||||
TEMPLATE.exchange(url, HttpMethod.GET, auth, TASK_SUMMARY_PAGE_MODEL_TYPE);
|
||||
|
@ -349,7 +350,7 @@ class TaskControllerIntTest {
|
|||
+ "&due-until="
|
||||
+ dueToInstant
|
||||
+ "&sort-by=DUE";
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ResponseEntity<TaskSummaryPagedRepresentationModel> response =
|
||||
TEMPLATE.exchange(url, HttpMethod.GET, auth, TASK_SUMMARY_PAGE_MODEL_TYPE);
|
||||
|
@ -369,7 +370,7 @@ class TaskControllerIntTest {
|
|||
+ ",2020-01-18T09:44:47.453Z"
|
||||
+ "&due-from=2020-01-19T07:44:47.453Z"
|
||||
+ "&sort-by=planned";
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ThrowingCallable httpCall =
|
||||
() -> {
|
||||
|
@ -386,7 +387,7 @@ class TaskControllerIntTest {
|
|||
void testGetAllTasksByWorkbasketKeyAndDomain() {
|
||||
String url =
|
||||
restHelper.toUrl(RestEndpoints.URL_TASKS) + "?workbasket-key=USER-1-2&domain=DOMAIN_A";
|
||||
HttpEntity<String> auth = new HttpEntity<>(restHelper.getHeadersUser_1_2());
|
||||
HttpEntity<String> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("user-1-2"));
|
||||
|
||||
ResponseEntity<TaskSummaryPagedRepresentationModel> response =
|
||||
TEMPLATE.exchange(url, HttpMethod.GET, auth, TASK_SUMMARY_PAGE_MODEL_TYPE);
|
||||
|
@ -402,7 +403,7 @@ class TaskControllerIntTest {
|
|||
restHelper.toUrl(RestEndpoints.URL_TASKS)
|
||||
+ "?external-id=ETI:000000000000000000000000000000000003"
|
||||
+ "&external-id=ETI:000000000000000000000000000000000004";
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ResponseEntity<TaskSummaryPagedRepresentationModel> response =
|
||||
TEMPLATE.exchange(url, HttpMethod.GET, auth, TASK_SUMMARY_PAGE_MODEL_TYPE);
|
||||
|
@ -415,7 +416,7 @@ class TaskControllerIntTest {
|
|||
@Test
|
||||
void testExceptionIfKeyIsSetButDomainIsMissing() {
|
||||
String url = restHelper.toUrl(RestEndpoints.URL_TASKS) + "?workbasket-key=USER-1-2";
|
||||
HttpEntity<String> auth = new HttpEntity<>(restHelper.getHeadersUser_1_2());
|
||||
HttpEntity<String> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("user-1-2"));
|
||||
|
||||
ThrowingCallable httpCall =
|
||||
() -> {
|
||||
|
@ -430,7 +431,7 @@ class TaskControllerIntTest {
|
|||
@Test
|
||||
void testGetAllTasksWithAdminRole() {
|
||||
String url = restHelper.toUrl(RestEndpoints.URL_TASKS);
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersAdmin());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("admin"));
|
||||
|
||||
ResponseEntity<TaskSummaryPagedRepresentationModel> response =
|
||||
TEMPLATE.exchange(url, HttpMethod.GET, auth, TASK_SUMMARY_PAGE_MODEL_TYPE);
|
||||
|
@ -445,7 +446,7 @@ class TaskControllerIntTest {
|
|||
String url =
|
||||
restHelper.toUrl(RestEndpoints.URL_TASKS)
|
||||
+ "?por.type=VNR&por.value=22334455&sort-by=POR_VALUE&order=DESCENDING";
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ResponseEntity<TaskSummaryPagedRepresentationModel> response =
|
||||
TEMPLATE.exchange(url, HttpMethod.GET, auth, TASK_SUMMARY_PAGE_MODEL_TYPE);
|
||||
|
@ -464,7 +465,7 @@ class TaskControllerIntTest {
|
|||
restHelper.toUrl(RestEndpoints.URL_TASKS)
|
||||
+ "?state=READY&state=CLAIMED&sort-by=POR_VALUE"
|
||||
+ "&order=DESCENDING&page-size=5&page=16";
|
||||
HttpEntity<String> auth = new HttpEntity<>(restHelper.getHeadersAdmin());
|
||||
HttpEntity<String> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("admin"));
|
||||
|
||||
ResponseEntity<TaskSummaryPagedRepresentationModel> response =
|
||||
TEMPLATE.exchange(url, HttpMethod.GET, auth, TASK_SUMMARY_PAGE_MODEL_TYPE);
|
||||
|
@ -492,7 +493,7 @@ class TaskControllerIntTest {
|
|||
// ClassificationControllerIntTest.testGetQueryByPorSecondPageSortedByType changes
|
||||
// tasks and this test depends on the tasks as they are in sampledata
|
||||
String url = restHelper.toUrl(RestEndpoints.URL_TASKS) + "?sort-by=DUE&order=DESCENDING";
|
||||
HttpEntity<String> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<String> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ResponseEntity<TaskSummaryPagedRepresentationModel> response =
|
||||
TEMPLATE.exchange(url, HttpMethod.GET, auth, TASK_SUMMARY_PAGE_MODEL_TYPE);
|
||||
|
@ -529,7 +530,7 @@ class TaskControllerIntTest {
|
|||
+ "?por.company=00&por.system=PASystem&por.instance=00&"
|
||||
+ "por.type=VNR&por.value=22334455&sort-by=POR_TYPE&"
|
||||
+ "order=ASCENDING&page-size=5&page=2";
|
||||
HttpEntity<String> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<String> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ResponseEntity<TaskSummaryPagedRepresentationModel> response =
|
||||
TEMPLATE.exchange(url, HttpMethod.GET, auth, TASK_SUMMARY_PAGE_MODEL_TYPE);
|
||||
|
@ -553,7 +554,7 @@ class TaskControllerIntTest {
|
|||
void should_NotGetEmptyAttachmentList_When_GettingTaskWithAttachment() {
|
||||
String url =
|
||||
restHelper.toUrl(RestEndpoints.URL_TASKS_ID, "TKI:000000000000000000000000000000000002");
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersAdmin());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("admin"));
|
||||
|
||||
ResponseEntity<TaskRepresentationModel> response =
|
||||
TEMPLATE.exchange(url, HttpMethod.GET, auth, TASK_MODEL_TYPE);
|
||||
|
@ -568,14 +569,14 @@ class TaskControllerIntTest {
|
|||
void should_ChangeValueOfModified_When_UpdatingTask() {
|
||||
String url =
|
||||
restHelper.toUrl(RestEndpoints.URL_TASKS_ID, "TKI:100000000000000000000000000000000000");
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ResponseEntity<TaskRepresentationModel> responseGet =
|
||||
TEMPLATE.exchange(url, HttpMethod.GET, auth, TASK_MODEL_TYPE);
|
||||
|
||||
final TaskRepresentationModel originalTask = responseGet.getBody();
|
||||
HttpEntity<TaskRepresentationModel> auth2 =
|
||||
new HttpEntity<>(originalTask, restHelper.getHeadersTeamlead_1());
|
||||
new HttpEntity<>(originalTask, RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ResponseEntity<TaskRepresentationModel> responseUpdate =
|
||||
TEMPLATE.exchange(url, HttpMethod.PUT, auth2, TASK_MODEL_TYPE);
|
||||
|
@ -591,7 +592,7 @@ class TaskControllerIntTest {
|
|||
TaskRepresentationModel taskRepresentationModel = getTaskResourceSample();
|
||||
String url = restHelper.toUrl(RestEndpoints.URL_TASKS);
|
||||
HttpEntity<TaskRepresentationModel> auth =
|
||||
new HttpEntity<>(taskRepresentationModel, restHelper.getHeadersTeamlead_1());
|
||||
new HttpEntity<>(taskRepresentationModel, RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ResponseEntity<TaskRepresentationModel> responseCreate =
|
||||
TEMPLATE.exchange(url, HttpMethod.POST, auth, TASK_MODEL_TYPE);
|
||||
|
@ -603,7 +604,7 @@ class TaskControllerIntTest {
|
|||
assertThat(taskIdOfCreatedTask).startsWith("TKI:");
|
||||
|
||||
String url2 = restHelper.toUrl(RestEndpoints.URL_TASKS_ID, taskIdOfCreatedTask);
|
||||
HttpEntity<Object> auth2 = new HttpEntity<>(restHelper.getHeadersAdmin());
|
||||
HttpEntity<Object> auth2 = new HttpEntity<>(RestHelper.generateHeadersForUser("admin"));
|
||||
|
||||
ResponseEntity<TaskRepresentationModel> responseDeleted =
|
||||
TEMPLATE.exchange(
|
||||
|
@ -623,7 +624,7 @@ class TaskControllerIntTest {
|
|||
taskRepresentationModel.setDue(now);
|
||||
String url = restHelper.toUrl(RestEndpoints.URL_TASKS);
|
||||
HttpEntity<TaskRepresentationModel> auth =
|
||||
new HttpEntity<>(taskRepresentationModel, restHelper.getHeadersUser_1_1());
|
||||
new HttpEntity<>(taskRepresentationModel, RestHelper.generateHeadersForUser("user-1-1"));
|
||||
|
||||
ThrowingCallable httpCall =
|
||||
() -> {
|
||||
|
@ -646,7 +647,7 @@ class TaskControllerIntTest {
|
|||
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
||||
con.setRequestMethod("POST");
|
||||
con.setDoOutput(true);
|
||||
con.setRequestProperty("Authorization", RestHelper.AUTHORIZATION_TEAMLEAD_1);
|
||||
con.setRequestProperty("Authorization", RestHelper.encodeUserAndPasswordAsBasicAuth("admin"));
|
||||
con.setRequestProperty("Content-Type", "application/json");
|
||||
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(con.getOutputStream(), UTF_8));
|
||||
out.write(taskToCreateJson);
|
||||
|
@ -666,7 +667,7 @@ class TaskControllerIntTest {
|
|||
con = (HttpURLConnection) url.openConnection();
|
||||
con.setRequestMethod("POST");
|
||||
con.setDoOutput(true);
|
||||
con.setRequestProperty("Authorization", RestHelper.AUTHORIZATION_TEAMLEAD_1);
|
||||
con.setRequestProperty("Authorization", RestHelper.encodeUserAndPasswordAsBasicAuth("admin"));
|
||||
con.setRequestProperty("Content-Type", "application/json");
|
||||
out = new BufferedWriter(new OutputStreamWriter(con.getOutputStream(), UTF_8));
|
||||
out.write(taskToCreateJson2);
|
||||
|
@ -681,7 +682,7 @@ class TaskControllerIntTest {
|
|||
void should_CancelTask_when_CallingCancelEndpoint() {
|
||||
String url =
|
||||
restHelper.toUrl(RestEndpoints.URL_TASKS_ID, "TKI:000000000000000000000000000000000026");
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersUser_1_2());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("user-1-2"));
|
||||
|
||||
// retrieve task from Rest Api
|
||||
ResponseEntity<TaskRepresentationModel> responseGet =
|
||||
|
@ -705,7 +706,7 @@ class TaskControllerIntTest {
|
|||
void testCancelClaimTask() {
|
||||
String url =
|
||||
restHelper.toUrl(RestEndpoints.URL_TASKS_ID, "TKI:000000000000000000000000000000000027");
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersUser_1_2());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("user-1-2"));
|
||||
|
||||
// retrieve task from Rest Api
|
||||
ResponseEntity<TaskRepresentationModel> getTaskResponse =
|
||||
|
@ -734,7 +735,7 @@ class TaskControllerIntTest {
|
|||
void should_ForceCancelClaim_When_TaskIsClaimedByDifferentOwner() {
|
||||
String url =
|
||||
restHelper.toUrl(RestEndpoints.URL_TASKS_ID, "TKI:000000000000000000000000000000000027");
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersUser_1_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("user-1-1"));
|
||||
|
||||
// retrieve task from Rest Api
|
||||
ResponseEntity<TaskRepresentationModel> getTaskResponse =
|
||||
|
@ -763,7 +764,7 @@ class TaskControllerIntTest {
|
|||
void testCancelClaimOfClaimedTaskByAnotherUserShouldThrowException() {
|
||||
String url =
|
||||
restHelper.toUrl(RestEndpoints.URL_TASKS_ID, "TKI:000000000000000000000000000000000026");
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersUser_1_2());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("user-1-2"));
|
||||
|
||||
// retrieve task from Rest Api
|
||||
ResponseEntity<TaskRepresentationModel> responseGet =
|
||||
|
@ -791,7 +792,7 @@ class TaskControllerIntTest {
|
|||
@Test
|
||||
void testUpdateTaskOwnerOfReadyTaskSucceeds() {
|
||||
final String url = restHelper.toUrl("/api/v1/tasks/TKI:000000000000000000000000000000000025");
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersUser_1_2());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("user-1-2"));
|
||||
|
||||
// retrieve task from Rest Api
|
||||
ResponseEntity<TaskRepresentationModel> responseGet =
|
||||
|
@ -805,7 +806,7 @@ class TaskControllerIntTest {
|
|||
// set Owner and update Task
|
||||
theTaskRepresentationModel.setOwner("dummyUser");
|
||||
HttpEntity<TaskRepresentationModel> auth2 =
|
||||
new HttpEntity<>(theTaskRepresentationModel, restHelper.getHeadersUser_1_2());
|
||||
new HttpEntity<>(theTaskRepresentationModel, RestHelper.generateHeadersForUser("user-1-2"));
|
||||
|
||||
ResponseEntity<TaskRepresentationModel> responseUpdate =
|
||||
TEMPLATE.exchange(url, HttpMethod.PUT, auth2, TASK_MODEL_TYPE);
|
||||
|
@ -819,7 +820,7 @@ class TaskControllerIntTest {
|
|||
@Test
|
||||
void testUpdateTaskOwnerOfClaimedTaskFails() {
|
||||
final String url = restHelper.toUrl("/api/v1/tasks/TKI:000000000000000000000000000000000026");
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersUser_1_2());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("user-1-2"));
|
||||
|
||||
// retrieve task from Rest Api
|
||||
ResponseEntity<TaskRepresentationModel> responseGet =
|
||||
|
@ -833,7 +834,7 @@ class TaskControllerIntTest {
|
|||
// set Owner and update Task
|
||||
theTaskRepresentationModel.setOwner("dummyuser");
|
||||
HttpEntity<TaskRepresentationModel> auth2 =
|
||||
new HttpEntity<>(theTaskRepresentationModel, restHelper.getHeadersUser_1_2());
|
||||
new HttpEntity<>(theTaskRepresentationModel, RestHelper.generateHeadersForUser("user-1-2"));
|
||||
|
||||
ThrowingCallable httpCall =
|
||||
() -> {
|
||||
|
@ -849,7 +850,7 @@ class TaskControllerIntTest {
|
|||
void should_ThrowNotAuthorized_When_UserHasNoAuthorizationOnTask() {
|
||||
String url =
|
||||
restHelper.toUrl(RestEndpoints.URL_TASKS_ID, "TKI:000000000000000000000000000000000000");
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersUser_b_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("user-b-1"));
|
||||
|
||||
ThrowingCallable httpCall =
|
||||
() -> {
|
||||
|
@ -873,7 +874,7 @@ class TaskControllerIntTest {
|
|||
+ "&illegalParam=illegal"
|
||||
+ "&anotherIllegalParam=stillIllegal"
|
||||
+ "&sort-by=NAME&order=DESCENDING&page-size=5&page=2";
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ThrowingCallable httpCall =
|
||||
() -> {
|
||||
|
@ -900,7 +901,8 @@ class TaskControllerIntTest {
|
|||
ThrowingConsumer<Boolean> test =
|
||||
setTransferFlag -> {
|
||||
HttpEntity<String> auth =
|
||||
new HttpEntity<>(setTransferFlag.toString(), restHelper.getHeadersAdmin());
|
||||
new HttpEntity<>(
|
||||
setTransferFlag.toString(), RestHelper.generateHeadersForUser("admin"));
|
||||
ResponseEntity<TaskRepresentationModel> response =
|
||||
TEMPLATE.exchange(url, HttpMethod.POST, auth, TASK_MODEL_TYPE);
|
||||
|
||||
|
@ -920,7 +922,7 @@ class TaskControllerIntTest {
|
|||
RestEndpoints.URL_TASKS_ID_TRANSFER_WORKBASKET_ID,
|
||||
"TKI:000000000000000000000000000000000003",
|
||||
"WBI:100000000000000000000000000000000006");
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersAdmin());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("admin"));
|
||||
|
||||
ResponseEntity<TaskRepresentationModel> response =
|
||||
TEMPLATE.exchange(url, HttpMethod.POST, auth, TASK_MODEL_TYPE);
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
|
|||
|
||||
import pro.taskana.common.rest.RestEndpoints;
|
||||
import pro.taskana.common.test.BaseRestDocTest;
|
||||
import pro.taskana.common.test.rest.RestHelper;
|
||||
import pro.taskana.common.test.security.JaasExtension;
|
||||
import pro.taskana.common.test.security.WithAccessId;
|
||||
import pro.taskana.task.api.TaskService;
|
||||
|
@ -64,7 +65,7 @@ class TaskControllerRestDocTest extends BaseRestDocTest {
|
|||
mockMvc
|
||||
.perform(
|
||||
delete(RestEndpoints.URL_TASKS_ID_CLAIM, "TKI:000000000000000000000000000000000002")
|
||||
.headers(restHelper.getHeadersUser_1_1()))
|
||||
.headers(RestHelper.generateHeadersForUser("user-1-1")))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk());
|
||||
}
|
||||
|
||||
|
@ -75,7 +76,7 @@ class TaskControllerRestDocTest extends BaseRestDocTest {
|
|||
delete(
|
||||
RestEndpoints.URL_TASKS_ID_CLAIM_FORCE,
|
||||
"TKI:000000000000000000000000000000000035")
|
||||
.headers(restHelper.getHeadersUser_1_2()))
|
||||
.headers(RestHelper.generateHeadersForUser("user-1-2")))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk());
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ class WorkbasketAccessItemControllerIntTest {
|
|||
@Test
|
||||
void testGetAllWorkbasketAccessItems() {
|
||||
String url = restHelper.toUrl(RestEndpoints.URL_WORKBASKET_ACCESS_ITEMS);
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ResponseEntity<WorkbasketAccessItemPagedRepresentationModel> response =
|
||||
TEMPLATE.exchange(
|
||||
|
@ -61,7 +61,7 @@ class WorkbasketAccessItemControllerIntTest {
|
|||
String parameters =
|
||||
"?sort-by=WORKBASKET_KEY&order=ASCENDING&page-size=9&access-id=user-1-1&page=1";
|
||||
String url = restHelper.toUrl(RestEndpoints.URL_WORKBASKET_ACCESS_ITEMS) + parameters;
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ResponseEntity<WorkbasketAccessItemPagedRepresentationModel> response =
|
||||
TEMPLATE.exchange(
|
||||
|
@ -82,7 +82,7 @@ class WorkbasketAccessItemControllerIntTest {
|
|||
String parameters =
|
||||
"?sort-by=WORKBASKET_KEY&order=ASCENDING&page=2&page-size=9&access-id=user-1-1";
|
||||
String url = restHelper.toUrl(RestEndpoints.URL_WORKBASKET_ACCESS_ITEMS) + parameters;
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ResponseEntity<WorkbasketAccessItemPagedRepresentationModel> response =
|
||||
TEMPLATE.exchange(
|
||||
|
@ -111,7 +111,7 @@ class WorkbasketAccessItemControllerIntTest {
|
|||
void should_DeleteAllAccessItemForUser_ifValidAccessIdOfUserIsSupplied() {
|
||||
String url =
|
||||
restHelper.toUrl(RestEndpoints.URL_WORKBASKET_ACCESS_ITEMS) + "?access-id=teamlead-2";
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ResponseEntity<Void> response =
|
||||
TEMPLATE.exchange(
|
||||
|
@ -128,7 +128,7 @@ class WorkbasketAccessItemControllerIntTest {
|
|||
+ "&illegalParam=illegal"
|
||||
+ "&anotherIllegalParam=stillIllegal"
|
||||
+ "&sort-by=WORKBASKET_KEY&order=DESCENDING&page-size=5&page=2";
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ThrowingCallable httpCall =
|
||||
() -> {
|
||||
|
@ -157,7 +157,8 @@ class WorkbasketAccessItemControllerIntTest {
|
|||
restHelper.toUrl(RestEndpoints.URL_WORKBASKET_ACCESS_ITEMS)
|
||||
+ "?access-id="
|
||||
+ accessId;
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth =
|
||||
new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ThrowingCallable httpCall =
|
||||
() -> {
|
||||
|
|
|
@ -62,7 +62,7 @@ class WorkbasketControllerIntTest {
|
|||
final String url =
|
||||
restHelper.toUrl(
|
||||
RestEndpoints.URL_WORKBASKET_ID, "WBI:100000000000000000000000000000000006");
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ResponseEntity<WorkbasketRepresentationModel> response =
|
||||
TEMPLATE.exchange(url, HttpMethod.GET, auth, WORKBASKET_REPRESENTATION_MODEL_TYPE);
|
||||
|
@ -77,7 +77,7 @@ class WorkbasketControllerIntTest {
|
|||
@Test
|
||||
void testGetAllWorkbaskets() {
|
||||
String url = restHelper.toUrl(RestEndpoints.URL_WORKBASKET);
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ResponseEntity<WorkbasketSummaryPagedRepresentationModel> response =
|
||||
TEMPLATE.exchange(url, HttpMethod.GET, auth, WORKBASKET_SUMMARY_PAGE_MODEL_TYPE);
|
||||
|
@ -89,7 +89,7 @@ class WorkbasketControllerIntTest {
|
|||
@Test
|
||||
void testGetAllWorkbasketsBusinessAdminHasOpenPermission() {
|
||||
String url = restHelper.toUrl(RestEndpoints.URL_WORKBASKET) + "?required-permission=OPEN";
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ResponseEntity<WorkbasketSummaryPagedRepresentationModel> response =
|
||||
TEMPLATE.exchange(url, HttpMethod.GET, auth, WORKBASKET_SUMMARY_PAGE_MODEL_TYPE);
|
||||
|
@ -103,7 +103,7 @@ class WorkbasketControllerIntTest {
|
|||
void testGetAllWorkbasketsKeepingFilters() {
|
||||
String parameters = "?type=PERSONAL&sort-by=KEY&order=DESCENDING";
|
||||
String url = restHelper.toUrl(RestEndpoints.URL_WORKBASKET) + parameters;
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ResponseEntity<WorkbasketSummaryPagedRepresentationModel> response =
|
||||
TEMPLATE.exchange(url, HttpMethod.GET, auth, WORKBASKET_SUMMARY_PAGE_MODEL_TYPE);
|
||||
|
@ -124,7 +124,7 @@ class WorkbasketControllerIntTest {
|
|||
String url =
|
||||
restHelper.toUrl(
|
||||
RestEndpoints.URL_WORKBASKET_ID, "WBI:100000000000000000000000000000000001");
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ResponseEntity<WorkbasketRepresentationModel> initialWorkbasketResourceRequestResponse =
|
||||
TEMPLATE.exchange(url, HttpMethod.GET, auth, WORKBASKET_REPRESENTATION_MODEL_TYPE);
|
||||
|
@ -139,7 +139,8 @@ class WorkbasketControllerIntTest {
|
|||
workbasketRepresentationModel.setOwner("Joerg");
|
||||
workbasketRepresentationModel.setModified(Instant.now());
|
||||
HttpEntity<WorkbasketRepresentationModel> auth2 =
|
||||
new HttpEntity<>(workbasketRepresentationModel, restHelper.getHeadersTeamlead_1());
|
||||
new HttpEntity<>(
|
||||
workbasketRepresentationModel, RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ThrowingCallable httpCall =
|
||||
() -> {
|
||||
|
@ -155,7 +156,7 @@ class WorkbasketControllerIntTest {
|
|||
String url =
|
||||
restHelper.toUrl(
|
||||
RestEndpoints.URL_WORKBASKET_ID, "WBI:100004857400039500000999999999999999");
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersBusinessAdmin());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("businessadmin"));
|
||||
|
||||
ThrowingCallable httpCall =
|
||||
() -> {
|
||||
|
@ -172,7 +173,7 @@ class WorkbasketControllerIntTest {
|
|||
void testGetSecondPageSortedByKey() {
|
||||
String parameters = "?sort-by=KEY&order=DESCENDING&page-size=5&page=2";
|
||||
String url = restHelper.toUrl(RestEndpoints.URL_WORKBASKET) + parameters;
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ResponseEntity<WorkbasketSummaryPagedRepresentationModel> response =
|
||||
TEMPLATE.exchange(url, HttpMethod.GET, auth, WORKBASKET_SUMMARY_PAGE_MODEL_TYPE);
|
||||
|
@ -199,7 +200,7 @@ class WorkbasketControllerIntTest {
|
|||
String url =
|
||||
restHelper.toUrl(
|
||||
RestEndpoints.URL_WORKBASKET_ID, "WBI:100000000000000000000000000000000005");
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersBusinessAdmin());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("businessadmin"));
|
||||
|
||||
ResponseEntity<?> response = TEMPLATE.exchange(url, HttpMethod.DELETE, auth, Void.class);
|
||||
|
||||
|
@ -211,7 +212,7 @@ class WorkbasketControllerIntTest {
|
|||
String url =
|
||||
restHelper.toUrl(
|
||||
RestEndpoints.URL_WORKBASKET_ID, "WBI:100000000000000000000000000000000004");
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersBusinessAdmin());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("businessadmin"));
|
||||
|
||||
ThrowingCallable call =
|
||||
() -> {
|
||||
|
@ -230,7 +231,7 @@ class WorkbasketControllerIntTest {
|
|||
restHelper.toUrl(
|
||||
RestEndpoints.URL_WORKBASKET_ID_DISTRIBUTION,
|
||||
"WBI:100000000000000000000000000000000007");
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ResponseEntity<?> response = TEMPLATE.exchange(url, HttpMethod.DELETE, auth, Void.class);
|
||||
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
|
||||
|
@ -256,7 +257,7 @@ class WorkbasketControllerIntTest {
|
|||
restHelper.toUrl(
|
||||
RestEndpoints.URL_WORKBASKET_ID_ACCESS_ITEMS,
|
||||
"WBI:100000000000000000000000000000000005");
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ResponseEntity<WorkbasketAccessItemCollectionRepresentationModel> response =
|
||||
TEMPLATE.exchange(
|
||||
|
@ -274,7 +275,7 @@ class WorkbasketControllerIntTest {
|
|||
restHelper.toUrl(
|
||||
RestEndpoints.URL_WORKBASKET_ID_DISTRIBUTION,
|
||||
"WBI:100000000000000000000000000000000001");
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ResponseEntity<DistributionTargetsCollectionRepresentationModel> response =
|
||||
TEMPLATE.exchange(
|
||||
|
@ -294,7 +295,7 @@ class WorkbasketControllerIntTest {
|
|||
+ "&illegalParam=illegal"
|
||||
+ "&anotherIllegalParam=stillIllegal"
|
||||
+ "&sort-by=KEY&order=DESCENDING&page-size=5&page=2";
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
ThrowingCallable httpCall =
|
||||
() -> {
|
||||
|
|
|
@ -272,7 +272,7 @@ class WorkbasketDefinitionControllerIntTest {
|
|||
private ResponseEntity<WorkbasketDefinitionCollectionRepresentationModel>
|
||||
executeExportRequestForDomain(String domain) {
|
||||
String url = restHelper.toUrl(RestEndpoints.URL_WORKBASKET_DEFINITIONS) + "?domain=" + domain;
|
||||
HttpEntity<Object> auth = new HttpEntity<>(restHelper.getHeadersTeamlead_1());
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
|
||||
|
||||
return TEMPLATE.exchange(
|
||||
url,
|
||||
|
@ -302,7 +302,7 @@ class WorkbasketDefinitionControllerIntTest {
|
|||
MultiValueMap<String, FileSystemResource> body = new LinkedMultiValueMap<>();
|
||||
body.add("file", new FileSystemResource(tmpFile));
|
||||
|
||||
HttpHeaders headers = restHelper.getHeadersBusinessAdmin();
|
||||
HttpHeaders headers = RestHelper.generateHeadersForUser("businessadmin");
|
||||
headers.setContentType(MediaType.MULTIPART_FORM_DATA);
|
||||
|
||||
HttpEntity<?> requestEntity = new HttpEntity<>(body, headers);
|
||||
|
|
Loading…
Reference in New Issue