-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
Copy pathKmsResourcesTest.java
48 lines (41 loc) · 1.51 KB
/
KmsResourcesTest.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
package org.acme.kms;
import static io.restassured.RestAssured.given;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.notNullValue;
import io.quarkus.test.junit.QuarkusTest;
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;
@QuarkusTest
public class KmsResourcesTest {
private final static String TEST_TEXT = "Quarkus is awsome";
@ParameterizedTest
@ValueSource(strings = {"sync", "async"})
void testResource(final String testedResource) {
//Encrypt text
String encryptedText = given()
.pathParam("resource", testedResource)
.header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN)
.body(TEST_TEXT)
.when()
.post("/{resource}/encrypt")
.then()
.statusCode(Status.OK.getStatusCode())
.extract()
.asString();
assertThat(encryptedText, notNullValue());
//Decrypt
given()
.pathParam("resource", testedResource)
.header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN)
.body(encryptedText)
.when()
.post("/{resource}/decrypt")
.then()
.statusCode(Status.OK.getStatusCode())
.body(containsString(TEST_TEXT));
}
}