Skip to content

Commit cf3568e

Browse files
committed
fix unsupported query type tests
1 parent 662c801 commit cf3568e

File tree

2 files changed

+29
-12
lines changed

2 files changed

+29
-12
lines changed

src/main/java/net/apnic/rdap/conformance/Application.java

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -150,16 +150,6 @@ public X509Certificate[] getAcceptedIssuers() {
150150

151151
List<Test> tests = new ArrayList();
152152

153-
for (String objectType : objectTypes) {
154-
ObjectClass oc = s.getObjectClass(objectType);
155-
if ((oc != null)
156-
&& (!s.getObjectClass(objectType).isSupported())) {
157-
tests.add(new net.apnic.rdap.conformance.test.common.NotFound(
158-
"/" + objectType)
159-
);
160-
}
161-
}
162-
163153
/* Relative URI in the HTTP request. */
164154
Result relative = new Result();
165155
relative.setTestName("common.bad-uri-relative");
@@ -195,6 +185,9 @@ public X509Certificate[] getAcceptedIssuers() {
195185
)
196186
);
197187

188+
/* From here onwards, the tests are RDAP-specific, except for
189+
* the unescaped-URI IP test. */
190+
198191
/* application/json content-type. This is deliberately using
199192
* an invalid status code with inverted sense, because so long
200193
* as the request is 'successful', it's fine. */
@@ -212,6 +205,26 @@ public X509Certificate[] getAcceptedIssuers() {
212205
));
213206
c.setContentType(null);
214207

208+
/* Unsupported query types. */
209+
for (String objectType : objectTypes) {
210+
Result unsupported = new Result();
211+
unsupported.setTestName("common.unsupported");
212+
unsupported.setDocument("draft-ietf-weirds-using-http-08");
213+
unsupported.setReference("5.4");
214+
ObjectClass oc = s.getObjectClass(objectType);
215+
if ((oc == null)
216+
|| (!s.getObjectClass(objectType).isSupported())) {
217+
tests.add(
218+
new net.apnic.rdap.conformance.test.common.BasicRequest(
219+
HttpStatus.SC_BAD_REQUEST,
220+
"/" + objectType + "/1.2.3.4",
221+
"common.unsupported",
222+
false,
223+
unsupported
224+
));
225+
}
226+
}
227+
215228
ObjectClass ocIp = s.getObjectClass("ip");
216229
if ((ocIp != null) && (ocIp.isSupported())) {
217230
tests.add(new net.apnic.rdap.conformance.test.ip.BadRequest());

src/main/java/net/apnic/rdap/conformance/responsetest/NotStatusCode.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,12 @@ public boolean run(final Context context, final Result proto,
3939

4040
if (code != notExpectedCode) {
4141
nr.setStatus(Status.Success);
42-
nr.setInfo("got " + code + " instead of unexpected code ("
43-
+ notExpectedCode + ")");
42+
if (notExpectedCode != 0) {
43+
nr.setInfo("got " + code + " instead of unexpected code ("
44+
+ notExpectedCode + ")");
45+
} else {
46+
nr.setInfo("got valid code (" + code + ")");
47+
}
4448
results.add(nr);
4549
return true;
4650
} else {

0 commit comments

Comments
 (0)