-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
Copy pathSsmResourcesTest.java
59 lines (49 loc) · 1.87 KB
/
SsmResourcesTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package org.acme.ssm;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.equalTo;
import java.util.LinkedHashMap;
import java.util.Map;
import jakarta.ws.rs.core.HttpHeaders;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response.Status;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import io.quarkus.test.junit.QuarkusTest;
@QuarkusTest
public class SsmResourcesTest {
@ParameterizedTest
@ValueSource(strings = { "sync", "async" })
void testResource(final String testedResource) {
Map<String, String> data = new LinkedHashMap<>();
data.put("secure", "stored as cipher text");
data.put("plain", "stored as plain text");
//Add params
data.forEach((name, value) -> given()
.pathParam("resource", testedResource)
.pathParam("name", name)
.queryParam("secure", "secure".equals(name))
.header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN)
.body(value)
.when()
.put("/{resource}/{name}")
.then()
.statusCode(Status.NO_CONTENT.getStatusCode()));
//List params
given()
.pathParam("resource", testedResource)
.when()
.get("/{resource}")
.then()
.statusCode(200)
.body("secure", equalTo(data.get("secure")))
.body("plain", equalTo(data.get("plain")));
//Get each param
data.forEach((name, value) -> given()
.pathParam("resource", testedResource)
.pathParam("name", name)
.when().get("/{resource}/{name}")
.then()
.statusCode(200)
.body(equalTo(value)));
}
}