Skip to content

Commit 9bf8eaa

Browse files
committed
Further User API tests
1 parent 3202f09 commit 9bf8eaa

File tree

3 files changed

+61
-2
lines changed

3 files changed

+61
-2
lines changed

src/test/java/com/fusiondb/studio/api/UserIT.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import static com.fusiondb.studio.api.API.*;
2828
import static io.restassured.RestAssured.given;
2929
import static io.restassured.http.ContentType.JSON;
30+
import static io.restassured.module.jsv.JsonSchemaValidator.matchesJsonSchemaInClasspath;
3031
import static org.apache.http.HttpStatus.*;
3132
import static org.junit.jupiter.api.Assertions.assertFalse;
3233
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -95,8 +96,10 @@ private ExtractableResponse<Response> getUser(final String userId) {
9596
when().
9697
get(getApiBaseUri() + "/user/user" + userId).
9798
then().
98-
statusCode(SC_OK)
99-
.extract();
99+
statusCode(SC_OK).
100+
assertThat().
101+
body(matchesJsonSchemaInClasspath("user-schema.json")).
102+
extract();
100103
}
101104

102105
private void createUser(final String userId) {
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"title": "Collection",
4+
"type": "object",
5+
"required": [
6+
"key"
7+
],
8+
"properties": {
9+
"key": {
10+
"type": "string"
11+
},
12+
"value": {
13+
"type": "string"
14+
}
15+
}
16+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"title": "User",
4+
"type": "object",
5+
"required": [
6+
"userName"
7+
],
8+
"properties": {
9+
"userName": {
10+
"type": "string"
11+
},
12+
"password": {
13+
"type": "string"
14+
},
15+
"umask": {
16+
"type": "integer"
17+
},
18+
"enabled": {
19+
"type": "boolean"
20+
},
21+
"expired": {
22+
"type": "boolean"
23+
},
24+
"primaryGroup": {
25+
"type": "string"
26+
},
27+
"groups": {
28+
"type": "array",
29+
"items": {
30+
"type": "string"
31+
}
32+
},
33+
"metadata": {
34+
"type": "array",
35+
"items": {
36+
"$ref": "attribute-schema.json"
37+
}
38+
}
39+
}
40+
}

0 commit comments

Comments
 (0)