2018-08-03 09:38:13 +02:00
|
|
|
package sonia.scm.it;
|
|
|
|
|
|
|
|
|
|
import io.restassured.RestAssured;
|
|
|
|
|
import io.restassured.specification.RequestSpecification;
|
|
|
|
|
|
|
|
|
|
import java.net.URI;
|
|
|
|
|
|
2018-08-06 11:53:45 +02:00
|
|
|
import static java.net.URI.create;
|
2018-08-03 09:38:13 +02:00
|
|
|
|
|
|
|
|
public class RestUtil {
|
|
|
|
|
|
2018-08-06 11:53:45 +02:00
|
|
|
public static final URI BASE_URL = create("http://localhost:8081/scm/");
|
|
|
|
|
public static final URI REST_BASE_URL = BASE_URL.resolve("api/rest/v2/");
|
2018-08-03 09:38:13 +02:00
|
|
|
|
2018-08-06 11:53:45 +02:00
|
|
|
public static URI createResourceUrl(String path) {
|
|
|
|
|
return REST_BASE_URL.resolve(path);
|
2018-08-03 09:38:13 +02:00
|
|
|
}
|
|
|
|
|
|
2018-08-15 11:44:20 +02:00
|
|
|
public static final String ADMIN_USERNAME = "scmadmin";
|
|
|
|
|
public static final String ADMIN_PASSWORD = "scmadmin";
|
|
|
|
|
|
2018-08-22 09:18:17 +02:00
|
|
|
public static RequestSpecification given() {
|
2018-08-06 11:53:45 +02:00
|
|
|
return RestAssured.given()
|
2018-08-15 11:44:20 +02:00
|
|
|
.auth().preemptive().basic(ADMIN_USERNAME, ADMIN_PASSWORD);
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-22 09:18:17 +02:00
|
|
|
public static RequestSpecification given(String mediaType) {
|
|
|
|
|
return given(mediaType, ADMIN_USERNAME, ADMIN_PASSWORD);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static RequestSpecification given(String mediaType, String username, String password) {
|
2018-08-15 11:44:20 +02:00
|
|
|
return RestAssured.given()
|
2018-08-22 09:18:17 +02:00
|
|
|
.contentType(mediaType)
|
|
|
|
|
.accept(mediaType)
|
|
|
|
|
.auth().preemptive().basic(username, password);
|
2018-08-03 09:38:13 +02:00
|
|
|
}
|
|
|
|
|
}
|