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 |
|
package info.magnolia.integrationtests.rest.delivery.jcr.v2; |
35 |
|
|
36 |
|
import static io.restassured.RestAssured.given; |
37 |
|
import static org.hamcrest.Matchers.*; |
38 |
|
|
39 |
|
import org.junit.Test; |
40 |
|
|
41 |
|
import io.restassured.http.ContentType; |
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
@see |
47 |
|
|
|
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 9 |
Complexity Density: 1 |
|
48 |
|
public class ExceptionHandlingTest extends AbstractJcrDeliveryEndpointTest { |
49 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
4-
|
|
50 |
0 |
@Test... |
51 |
|
public void invalidRequestParamReturns404() { |
52 |
0 |
given().param("limit", "notANumber") |
53 |
|
.when() |
54 |
|
.get("default/v1") |
55 |
|
.then() |
56 |
|
.statusCode(404) |
57 |
|
.body( |
58 |
|
"", hasKey("error"), |
59 |
|
"error.code", equalTo("notFound"), |
60 |
|
"error.message", containsString("Unable to extract parameter from http request") |
61 |
|
); |
62 |
|
} |
63 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
4-
|
|
64 |
0 |
@Test... |
65 |
|
public void noMatchForAcceptHeaderReturns406() { |
66 |
0 |
given().accept(ContentType.XML) |
67 |
|
.when() |
68 |
|
.get("default/v1") |
69 |
|
.then() |
70 |
|
.statusCode(406) |
71 |
|
.body( |
72 |
|
"", hasKey("error"), |
73 |
|
"error.code", equalTo("notAcceptable"), |
74 |
|
"error.message", containsString("No match for accept header") |
75 |
|
); |
76 |
|
} |
77 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
4-
|
|
78 |
0 |
@Test... |
79 |
|
public void methodNotAllowedReturns405() { |
80 |
0 |
given().auth() |
81 |
|
.preemptive() |
82 |
|
.basic("superuser", "superuser") |
83 |
|
.when() |
84 |
|
.post("withoutBypassAcls/v1") |
85 |
|
.then() |
86 |
|
.statusCode(405) |
87 |
|
.body( |
88 |
|
"", hasKey("error"), |
89 |
|
"error.code", equalTo("methodNotAllowed"), |
90 |
|
"error.message", containsString("No resource method found for POST, return 405 with Allow header") |
91 |
|
); |
92 |
|
} |
93 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
4-
|
|
94 |
0 |
@Test... |
95 |
|
public void pathNotFoundReturns404() { |
96 |
0 |
given().when() |
97 |
|
.get("default/v1/pathNotFound") |
98 |
|
.then() |
99 |
|
.statusCode(404) |
100 |
|
.body( |
101 |
|
"", hasKey("error"), |
102 |
|
"error.code", equalTo("pathNotFound"), |
103 |
|
"error.message", equalTo("/pathNotFound") |
104 |
|
); |
105 |
|
} |
106 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
4-
|
|
107 |
0 |
@Test... |
108 |
|
public void invalidQueryReturns400() { |
109 |
0 |
given().param("orderBy", "invalid orderBy clause") |
110 |
|
.when() |
111 |
|
.get("default/v1") |
112 |
|
.then() |
113 |
|
.statusCode(400) |
114 |
|
.body( |
115 |
|
"", hasKey("error"), |
116 |
|
"error.code", equalTo("invalidQuery"), |
117 |
|
"error.message", equalTo("Invalid query") |
118 |
|
); |
119 |
|
} |
120 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
4-
|
|
121 |
0 |
@Test... |
122 |
|
public void noSuchWorkspaceReturns500() { |
123 |
0 |
given().when() |
124 |
|
.get("nonexistentNodeTypeConfigured/v1") |
125 |
|
.then() |
126 |
|
.statusCode(500) |
127 |
|
.body( |
128 |
|
"", hasKey("error"), |
129 |
|
"error.code", equalTo("noSuchNodeType"), |
130 |
|
"error.message", containsString("notFound") |
131 |
|
); |
132 |
|
} |
133 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
4-
|
|
134 |
0 |
@Test... |
135 |
|
public void noResourceMethodMatchedReturns404() { |
136 |
0 |
given().when() |
137 |
|
.get("default/noResourchMethodMatched") |
138 |
|
.then() |
139 |
|
.statusCode(404) |
140 |
|
.body( |
141 |
|
"", hasKey("error"), |
142 |
|
"error.code", equalTo("notFound"), |
143 |
|
"error.message", containsString("Could not find resource for full path") |
144 |
|
); |
145 |
|
} |
146 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
4-
|
|
147 |
0 |
@Test... |
148 |
|
public void readingNodeWithNullNodeTypesReturns404() { |
149 |
0 |
given().when() |
150 |
|
.get("nullNodeTypes/v1/travel/about") |
151 |
|
.then() |
152 |
|
.statusCode(404) |
153 |
|
.body( |
154 |
|
"", hasKey("error"), |
155 |
|
"error.code", equalTo("notFound"), |
156 |
|
"error.message", containsString("nodeTypes are configured as null, not serving any content") |
157 |
|
); |
158 |
|
} |
159 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
4-
|
|
160 |
0 |
@Test... |
161 |
|
public void queryingNodesWithNullNodeTypesReturns404() { |
162 |
0 |
given().when() |
163 |
|
.get("nullNodeTypes/v1") |
164 |
|
.then() |
165 |
|
.statusCode(404) |
166 |
|
.body( |
167 |
|
"", hasKey("error"), |
168 |
|
"error.code", equalTo("notFound"), |
169 |
|
"error.message", containsString("nodeTypes are configured as null, not serving any content") |
170 |
|
); |
171 |
|
} |
172 |
|
} |