Skip to content

Commit f190a0a

Browse files
authored
Merge pull request #43 from APNIC-net/feature/RST-25
Feature/RST-25
2 parents 2bc7a91 + 8decac4 commit f190a0a

File tree

5 files changed

+447
-5
lines changed

5 files changed

+447
-5
lines changed

pom.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<groupId>net.apnic.rdap</groupId>
77
<artifactId>rdap-conformance</artifactId>
88
<packaging>jar</packaging>
9-
<version>0.5</version>
9+
<version>0.6</version>
1010
<name>rdap-conformance</name>
1111
<description>RDAP conformance</description>
1212
<inceptionYear>2014</inceptionYear>
@@ -153,7 +153,7 @@
153153
<dependency>
154154
<groupId>org.apache.httpcomponents</groupId>
155155
<artifactId>httpclient</artifactId>
156-
<version>4.3.1</version>
156+
<version>4.3.6</version>
157157
</dependency>
158158

159159
<dependency>
@@ -183,7 +183,7 @@
183183
<dependency>
184184
<groupId>commons-validator</groupId>
185185
<artifactId>commons-validator</artifactId>
186-
<version>1.4.0</version>
186+
<version>1.4.1</version>
187187
</dependency>
188188

189189
<dependency>

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

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ private static HttpRequestBase httpRequest(
4848
? new HttpGet(path)
4949
: new HttpHead(path);
5050
request.setHeader("Accept", context.getContentType());
51+
request.setHeader("Origin", "http://127.0.0.1");
5152
RequestConfig config =
5253
RequestConfig.custom()
5354
.setConnectionRequestTimeout(TIMEOUT_MS)

src/main/java/net/apnic/rdap/conformance/attributetest/Entity.java

+89-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.util.Arrays;
44
import java.util.ArrayList;
5+
import java.util.Collection;
56
import java.util.List;
67
import java.util.Map;
78
import java.util.Set;
@@ -12,6 +13,12 @@
1213
import ezvcard.Ezvcard;
1314
import ezvcard.Ezvcard.ParserChainJsonString;
1415
import ezvcard.ValidationWarnings;
16+
import ezvcard.property.VCardProperty;
17+
import ezvcard.property.RawProperty;
18+
import ezvcard.property.Address;
19+
import ezvcard.property.Email;
20+
import ezvcard.property.Kind;
21+
import org.apache.commons.validator.routines.EmailValidator;
1522

1623
import net.apnic.rdap.conformance.Result;
1724
import net.apnic.rdap.conformance.Result.Status;
@@ -33,6 +40,7 @@ public final class Entity implements SearchTest {
3340
private String handle = null;
3441
private String fn = null;
3542
private Set<String> knownAttributes = null;
43+
private Set<String> standardKinds = null;
3644

3745
/**
3846
* <p>Constructor for Entity.</p>
@@ -70,6 +78,8 @@ public void setSearchDetails(final String key, final String pattern) {
7078
public boolean run(final Context context, final Result proto,
7179
final Map<String, Object> data) {
7280
knownAttributes = Sets.newHashSet("handle", "roles", "vcardArray");
81+
standardKinds = Sets.newHashSet("individual", "org", "group",
82+
"location", "application", "device");
7383

7484
Result nr = new Result(proto);
7585
nr.setCode("content");
@@ -122,6 +132,7 @@ public boolean run(final Context context, final Result proto,
122132
}
123133
Result nrv = new Result(nr);
124134
Result nrv2 = null;
135+
List<Result> nrvAdditionals = new ArrayList<Result>();
125136
nrv.addNode("vcardArray");
126137
if (error != null) {
127138
nrv.setStatus(Status.Failure);
@@ -141,21 +152,97 @@ public boolean run(final Context context, final Result proto,
141152
if (warnings.size() > 0) {
142153
List<String> vcardWarnings = warnings.get(0);
143154
for (String s : vcardWarnings) {
144-
System.err.println(s);
155+
Result nrvAdditional = new Result(nrv);
156+
nrvAdditional.setStatus(Status.Failure);
157+
nrvAdditional.setInfo(s);
158+
nrvAdditionals.add(nrvAdditional);
145159
}
146160
}
147161
vcard = vcards.get(0);
148162
ValidationWarnings vws =
149163
vcard.validate(vcard.getVersion());
150-
String validationWarnings = vws.toString();
164+
String validationWarnings = vws.toString().trim();
151165
nrv2 = new Result(nrv);
152166
nrv2.setDetails((validationWarnings.length() == 0),
153167
"valid", "invalid: " + validationWarnings);
168+
169+
Collection<VCardProperty> properties =
170+
vcard.getProperties();
171+
for (VCardProperty property : properties) {
172+
if (property instanceof ezvcard.property.Email) {
173+
Email emailProperty =
174+
(ezvcard.property.Email) property;
175+
String email = emailProperty.getValue();
176+
boolean valid =
177+
EmailValidator.getInstance().isValid(email);
178+
Result nrvAdditional = new Result(nrv);
179+
nrvAdditional.setDetails(
180+
valid,
181+
"email address is valid",
182+
"email address is invalid"
183+
);
184+
nrvAdditionals.add(nrvAdditional);
185+
}
186+
if (property instanceof ezvcard.property.Address) {
187+
Address addressProperty =
188+
(ezvcard.property.Address) property;
189+
190+
String poBox = addressProperty.getPoBox();
191+
Result nrvAdditionalPoBox = new Result(nrv);
192+
nrvAdditionalPoBox.setDocument("rfc6350");
193+
nrvAdditionalPoBox.setReference("6.3.1");
194+
nrvAdditionalPoBox.setInfo("PO box should not be set");
195+
nrvAdditionalPoBox.setStatus(
196+
(poBox == null)
197+
? Status.Success
198+
: Status.Warning
199+
);
200+
nrvAdditionals.add(nrvAdditionalPoBox);
201+
202+
String extendedAddress =
203+
addressProperty.getExtendedAddress();
204+
Result nrvAdditionalEA = new Result(nrv);
205+
nrvAdditionalEA.setDocument("rfc6350");
206+
nrvAdditionalEA.setReference("6.3.1");
207+
nrvAdditionalEA.setInfo("extended address should not be set");
208+
nrvAdditionalEA.setStatus(
209+
(extendedAddress == null)
210+
? Status.Success
211+
: Status.Warning
212+
);
213+
nrvAdditionals.add(nrvAdditionalEA);
214+
}
215+
if (property instanceof ezvcard.property.Kind) {
216+
Kind kindProperty =
217+
(ezvcard.property.Kind) property;
218+
String value = kindProperty.getValue();
219+
if (!standardKinds.contains(value)) {
220+
Result nrvAdditional = new Result(nrv);
221+
nrvAdditional.setStatus(Status.Warning);
222+
nrvAdditional.setInfo("found non-standard kind " +
223+
"'" + value + "'");
224+
nrvAdditionals.add(nrvAdditional);
225+
}
226+
}
227+
}
228+
List<RawProperty> extendedProperties =
229+
vcard.getExtendedProperties();
230+
for (RawProperty property : extendedProperties) {
231+
Result nrvAdditional = new Result(nrv);
232+
nrvAdditional.setStatus(Status.Warning);
233+
nrvAdditional.setInfo("found non-standard property " +
234+
"'" + property.getPropertyName()
235+
+ "'");
236+
nrvAdditionals.add(nrvAdditional);
237+
}
154238
}
155239
context.addResult(nrv);
156240
if (nrv2 != null) {
157241
context.addResult(nrv2);
158242
}
243+
for (Result nrvAdditional : nrvAdditionals) {
244+
context.addResult(nrvAdditional);
245+
}
159246
}
160247

161248
if ((fn != null) && searchContext) {

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

+4
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ public boolean run(final Context context, final Result proto,
4545
nr.setStatus(Status.Success);
4646
results.add(nr);
4747
return true;
48+
} else if (ct.equals("http://127.0.0.1")) {
49+
nr.setStatus(Status.Success);
50+
results.add(nr);
51+
return true;
4852
} else {
4953
nr.setStatus(Status.Failure);
5054
nr.setInfo("got '" + ct + "' instead of '*'");

0 commit comments

Comments
 (0)