tor-commits
Threads by month
- ----- 2025 -----
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
June 2017
- 13 participants
- 1918 discussions

16 Jun '17
commit 83cf2bb101beac95fefaabc58e5f8e0f3bbd258d
Author: iwakeh <iwakeh(a)torproject.org>
Date: Thu Jun 1 08:44:35 2017 +0000
Minor readability and space changes.
Removed check that cannot evaluate as true.
---
src/main/java/org/torproject/descriptor/impl/KeyValueMap.java | 10 +++++-----
src/main/java/org/torproject/descriptor/impl/ParseHelper.java | 6 ++----
2 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/src/main/java/org/torproject/descriptor/impl/KeyValueMap.java b/src/main/java/org/torproject/descriptor/impl/KeyValueMap.java
index 7b918dc..a1eab05 100644
--- a/src/main/java/org/torproject/descriptor/impl/KeyValueMap.java
+++ b/src/main/java/org/torproject/descriptor/impl/KeyValueMap.java
@@ -24,8 +24,7 @@ public class KeyValueMap<T> extends TreeMap<String, T> {
throw new DescriptorParseException("Line '" + line + "' contains "
+ "duplicate key '" + key + "'.");
}
- if (null == key || key.isEmpty()
- || (keyLength > 0 && key.length() != keyLength)) {
+ if (key.isEmpty() || (keyLength > 0 && key.length() != keyLength)) {
throw new DescriptorParseException("Line '" + line + "' contains an "
+ "illegal key in list element '" + listElement + "'.");
}
@@ -43,10 +42,11 @@ public class KeyValueMap<T> extends TreeMap<String, T> {
if (startIndex >= partsNoOpt.length) {
return this;
}
- String[] keysAndValues = " ".equals(separatorPattern) ? partsNoOpt
+ boolean usingSpacePattern = " ".equals(separatorPattern);
+ String[] keysAndValues = usingSpacePattern ? partsNoOpt
: partsNoOpt[startIndex].split(separatorPattern, -1);
- for (int i = " ".equals(separatorPattern) ? startIndex : 0;
- i < keysAndValues.length; i++) {
+ for (int i = usingSpacePattern ? startIndex : 0; i < keysAndValues.length;
+ i++) {
String listElement = keysAndValues[i];
String[] keyAndValue = listElement.split("=");
String key = keyAndValue[0];
diff --git a/src/main/java/org/torproject/descriptor/impl/ParseHelper.java b/src/main/java/org/torproject/descriptor/impl/ParseHelper.java
index e89b59e..31454e5 100644
--- a/src/main/java/org/torproject/descriptor/impl/ParseHelper.java
+++ b/src/main/java/org/torproject/descriptor/impl/ParseHelper.java
@@ -23,8 +23,7 @@ import javax.xml.bind.DatatypeConverter;
public class ParseHelper {
- private static Pattern keywordPattern =
- Pattern.compile("^[A-Za-z0-9-]+$");
+ private static Pattern keywordPattern = Pattern.compile("^[A-Za-z0-9-]+$");
protected static String parseKeyword(String line, String keyword)
throws DescriptorParseException {
@@ -35,8 +34,7 @@ public class ParseHelper {
return keyword;
}
- private static Pattern ipv4Pattern =
- Pattern.compile("^[0-9\\.]{7,15}$");
+ private static Pattern ipv4Pattern = Pattern.compile("^[0-9\\.]{7,15}$");
protected static String parseIpv4Address(String line, String address)
throws DescriptorParseException {
1
0

[metrics-lib/release] Also check exception message in tests. Part of task-22280.
by karsten@torproject.org 16 Jun '17
by karsten@torproject.org 16 Jun '17
16 Jun '17
commit c39a15a2ffb929ffd844d79bf2b8d0d5bdc15620
Author: iwakeh <iwakeh(a)torproject.org>
Date: Thu Jun 1 08:44:28 2017 +0000
Also check exception message in tests. Part of task-22280.
---
.../descriptor/impl/ExitListImplTest.java | 13 +-
.../impl/ExtraInfoDescriptorImplTest.java | 379 +++++++++++----
.../descriptor/impl/MicrodescriptorImplTest.java | 27 +-
.../impl/RelayNetworkStatusConsensusImplTest.java | 517 +++++++++++++++++----
.../impl/RelayNetworkStatusImplTest.java | 9 +-
.../impl/RelayNetworkStatusVoteImplTest.java | 450 ++++++++++++++----
.../descriptor/impl/ServerDescriptorImplTest.java | 389 ++++++++++++----
7 files changed, 1415 insertions(+), 369 deletions(-)
diff --git a/src/test/java/org/torproject/descriptor/impl/ExitListImplTest.java b/src/test/java/org/torproject/descriptor/impl/ExitListImplTest.java
index 916c4df..5a67d53 100644
--- a/src/test/java/org/torproject/descriptor/impl/ExitListImplTest.java
+++ b/src/test/java/org/torproject/descriptor/impl/ExitListImplTest.java
@@ -9,13 +9,18 @@ import static org.junit.Assert.assertTrue;
import org.torproject.descriptor.DescriptorParseException;
import org.torproject.descriptor.ExitListEntry;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
import java.util.HashMap;
import java.util.Map;
public class ExitListImplTest {
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
@Test()
public void testAnnotatedInput() throws Exception {
ExitListImpl result = new ExitListImpl((tordnselAnnotation + input)
@@ -74,14 +79,18 @@ public class ExitListImplTest {
assertTrue("Map: " + map, map.containsKey("81.7.17.173"));
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testInsufficientInput0() throws Exception {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Missing 'ExitAddress' line in exit list entry.");
new ExitListImpl((tordnselAnnotation + insufficientInput[0])
.getBytes("US-ASCII"), fileName, false);
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testInsufficientInput1() throws Exception {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Missing 'Published' line in exit list entry.");
new ExitListImpl((tordnselAnnotation + insufficientInput[1])
.getBytes("US-ASCII"), fileName, false);
}
diff --git a/src/test/java/org/torproject/descriptor/impl/ExtraInfoDescriptorImplTest.java b/src/test/java/org/torproject/descriptor/impl/ExtraInfoDescriptorImplTest.java
index b745b07..e10fa7b 100644
--- a/src/test/java/org/torproject/descriptor/impl/ExtraInfoDescriptorImplTest.java
+++ b/src/test/java/org/torproject/descriptor/impl/ExtraInfoDescriptorImplTest.java
@@ -970,8 +970,11 @@ public class ExtraInfoDescriptorImplTest {
assertNotNull(descriptor.getDirreqReadHistory());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testExtraInfoLineMissing() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'extra-info' is contained 0 times, but "
+ + "must be contained exactly once.");
DescriptorBuilder.createWithExtraInfoLine(null);
}
@@ -996,55 +999,81 @@ public class ExtraInfoDescriptorImplTest {
descriptor.getFingerprint());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testExtraInfoLineNotFirst()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage(
+ "Keyword 'extra-info' must be contained in the first line.");
DescriptorBuilder.createWithExtraInfoLine("geoip-db-digest "
+ "916A3CA8B7DF61473D5AE5B21711F35F301CE9E8\n"
+ "extra-info chaoscomputerclub5 "
+ "A9C039A5FD02FCA06303DCFAABE25C5912C63B26");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testNicknameMissing() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal line 'extra-info "
+ + "A9C039A5FD02FCA06303DCFAABE25C5912C63B26' "
+ + "in extra-info descriptor.");
DescriptorBuilder.createWithExtraInfoLine("extra-info "
+ "A9C039A5FD02FCA06303DCFAABE25C5912C63B26");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testNicknameInvalidChar() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal nickname in line 'extra-info "
+ + "chaoscomputerclub% A9C039A5FD02FCA06303DCFAABE25C5912C63B26'.");
DescriptorBuilder.createWithExtraInfoLine("extra-info "
+ "chaoscomputerclub% A9C039A5FD02FCA06303DCFAABE25C5912C63B26");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testNicknameTooLong() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal nickname in line 'extra-info "
+ + "chaoscomputerclub5ReallyLongNickname "
+ + "A9C039A5FD02FCA06303DCFAABE25C5912C63B26'.");
DescriptorBuilder.createWithExtraInfoLine("extra-info "
+ "chaoscomputerclub5ReallyLongNickname "
+ "A9C039A5FD02FCA06303DCFAABE25C5912C63B26");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testFingerprintG() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal hex string in line 'extra-info "
+ + "chaoscomputerclub5 G9C039A5FD02FCA06303DCFAABE25C5912C63B26'.");
DescriptorBuilder.createWithExtraInfoLine("extra-info "
+ "chaoscomputerclub5 G9C039A5FD02FCA06303DCFAABE25C5912C63B26");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testFingerprintTooShort() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal hex string in line 'extra-info "
+ + "chaoscomputerclub5 A9C039A5FD02FCA06303DCFAABE25C5912C6'.");
DescriptorBuilder.createWithExtraInfoLine("extra-info "
+ "chaoscomputerclub5 A9C039A5FD02FCA06303DCFAABE25C5912C6");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testFingerprintTooLong() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal hex string in line 'extra-info "
+ + "chaoscomputerclub5 A9C039A5FD02FCA06303DCFAABE25C5912C63B26A9C0'.");
DescriptorBuilder.createWithExtraInfoLine("extra-info "
+ "chaoscomputerclub5 A9C039A5FD02FCA06303DCFAABE25C5912C63B26"
+ "A9C0");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testPublishedMissing() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'published' is contained 0 times, "
+ + "but must be contained exactly once.");
DescriptorBuilder.createWithPublishedLine(null);
}
@@ -1062,9 +1091,13 @@ public class ExtraInfoDescriptorImplTest {
assertEquals(1328951316000L, descriptor.getPublishedMillis());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testWriteHistoryNegativeBytes()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Negative bandwidth values are not allowed in "
+ + "line 'write-history 2012-02-11 09:03:39 (900 s) -4713350144,"
+ + "-4723824640,-4710717440,-4572675072'.");
DescriptorBuilder.createWithWriteHistoryLine("write-history "
+ "2012-02-11 09:03:39 (900 s) "
+ "-4713350144,-4723824640,-4710717440,-4572675072");
@@ -1086,9 +1119,13 @@ public class ExtraInfoDescriptorImplTest {
+ "4707695616,4699666432,4650004480,4489718784");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testReadHistoryNegativeInterval()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Only positive interval lengths are allowed in "
+ + "line 'read-history 2012-02-11 09:03:39 (-900 s) 4707695616,"
+ + "4699666432,4650004480,4489718784'.");
DescriptorBuilder.createWithReadHistoryLine("read-history "
+ "2012-02-11 09:03:39 (-900 s) "
+ "4707695616,4699666432,4650004480,4489718784");
@@ -1102,17 +1139,25 @@ public class ExtraInfoDescriptorImplTest {
+ "4707695616,4699666432,4650004480,4489718784");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testDirreqWriteHistoryMissingBytesBegin()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Invalid bandwidth-history line "
+ + "'dirreq-write-history 2012-02-11 09:03:39 (900 s) "
+ + ",64996352,60625920,67922944'.");
DescriptorBuilder.createWithDirreqWriteHistoryLine(
"dirreq-write-history 2012-02-11 09:03:39 (900 s) "
+ ",64996352,60625920,67922944");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testDirreqWriteHistoryMissingBytesMiddle()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Invalid bandwidth-history line "
+ + "'dirreq-write-history 2012-02-11 09:03:39 (900 s) 81281024,,"
+ + "60625920,67922944'.");
DescriptorBuilder.createWithDirreqWriteHistoryLine(
"dirreq-write-history 2012-02-11 09:03:39 (900 s) "
+ "81281024,,60625920,67922944");
@@ -1126,9 +1171,13 @@ public class ExtraInfoDescriptorImplTest {
+ "67922944 bin_size=1024");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testDirreqReadHistoryMissingBytesEnd()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Invalid bandwidth-history line "
+ + "'dirreq-read-history 2012-02-11 09:03:39 (900 s) "
+ + "17074176,16235520,16005120,'.");
DescriptorBuilder.createWithDirreqReadHistoryLine(
"dirreq-read-history 2012-02-11 09:03:39 (900 s) "
+ "17074176,16235520,16005120,");
@@ -1143,23 +1192,32 @@ public class ExtraInfoDescriptorImplTest {
descriptor.getGeoipDbDigestSha1Hex());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testGeoipDbDigestTooShort()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal hex string in line 'geoip-db-digest "
+ + "916A3CA8B7DF61473D5AE5B21711F35F301C'.");
DescriptorBuilder.createWithGeoipDbDigestLine("geoip-db-digest "
+ "916A3CA8B7DF61473D5AE5B21711F35F301C");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testGeoipDbDigestIllegalChars()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal hex string in line 'geoip-db-digest "
+ + "&%6A3CA8B7DF61473D5AE5B21711F35F301CE9E8'.");
DescriptorBuilder.createWithGeoipDbDigestLine("geoip-db-digest "
+ "&%6A3CA8B7DF61473D5AE5B21711F35F301CE9E8");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testGeoipDbDigestMissing()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal line 'geoip-db-digest' in extra-info "
+ + "descriptor.");
DescriptorBuilder.createWithGeoipDbDigestLine("geoip-db-digest");
}
@@ -1206,40 +1264,59 @@ public class ExtraInfoDescriptorImplTest {
assertFalse(ips.containsKey("pl"));
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testGeoipStartTimeDateOnly()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal line 'geoip-start-time 2012-02-10' in "
+ + "extra-info descriptor.");
GeoipStatsBuilder.createWithGeoipStartTimeLine("geoip-start-time "
+ "2012-02-10");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testGeoipClientOriginsDash()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Line 'geoip-client-origins de-1152,cn=896,us=712"
+ + ",it=504,ru=352,fr=208,gb=208,ir=200' contains an illegal key in "
+ + "list element 'de-1152'.");
GeoipStatsBuilder.createWithGeoipClientOriginsLine(
"geoip-client-origins de-1152,cn=896,us=712,it=504,ru=352,fr=208,"
+ "gb=208,ir=200");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testGeoipClientOriginsZero()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Line 'geoip-client-origins de=zero,cn=896,us=712"
+ + ",it=504,ru=352,fr=208,gb=208,ir=200' contains an illegal value in "
+ + "list element 'de=zero'.");
GeoipStatsBuilder.createWithGeoipClientOriginsLine(
"geoip-client-origins de=zero,cn=896,us=712,it=504,ru=352,fr=208,"
+ "gb=208,ir=200");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testGeoipClientOriginsNone()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Line 'geoip-client-origins de=none,cn=896,us=712"
+ + ",it=504,ru=352,fr=208,gb=208,ir=200' contains an illegal value in "
+ + "list element 'de=none'.");
GeoipStatsBuilder.createWithGeoipClientOriginsLine(
"geoip-client-origins de=none,cn=896,us=712,it=504,ru=352,fr=208,"
+ "gb=208,ir=200");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testGeoipClientOriginsOther()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Line 'geoip-client-origins de=1152,cn=896,"
+ + "us=712,it=504,ru=352,fr=208,gb=208,other=200' contains an "
+ + "illegal key in list element 'other=200'.");
GeoipStatsBuilder.createWithGeoipClientOriginsLine(
"geoip-client-origins de=1152,cn=896,us=712,it=504,ru=352,fr=208,"
+ "gb=208,other=200");
@@ -1261,33 +1338,49 @@ public class ExtraInfoDescriptorImplTest {
+ "GB=208,IR=200");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testGeoipClientOriginsMissingBegin()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Line 'geoip-client-origins ,cn=896,us=712,"
+ + "it=504,ru=352,fr=208,gb=208,ir=200' "
+ + "contains an illegal key in list element ''.");
GeoipStatsBuilder.createWithGeoipClientOriginsLine(
"geoip-client-origins ,cn=896,us=712,it=504,ru=352,fr=208,gb=208,"
+ "ir=200");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testGeoipClientOriginsMissingMiddle()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Line 'geoip-client-origins de=1152,,us=712,"
+ + "it=504,ru=352,fr=208,gb=208,ir=200' contains an illegal key in "
+ + "list element ''.");
GeoipStatsBuilder.createWithGeoipClientOriginsLine(
"geoip-client-origins de=1152,,us=712,it=504,ru=352,fr=208,"
+ "gb=208,ir=200");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testGeoipClientOriginsMissingEnd()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Line 'geoip-client-origins de=1152,cn=896,"
+ + "us=712,it=504,ru=352,fr=208,gb=208,' contains an illegal key in "
+ + "list element ''.");
GeoipStatsBuilder.createWithGeoipClientOriginsLine(
"geoip-client-origins de=1152,cn=896,us=712,it=504,ru=352,fr=208,"
+ "gb=208,");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testGeoipClientOriginsDuplicate()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Line 'geoip-client-origins de=1152,de=952,"
+ + "cn=896,us=712,it=504,ru=352,fr=208,gb=208,ir=200' contains "
+ + "duplicate key 'de'.");
GeoipStatsBuilder.createWithGeoipClientOriginsLine(
"geoip-client-origins de=1152,de=952,cn=896,us=712,it=504,"
+ "ru=352,fr=208,gb=208,ir=200");
@@ -1346,9 +1439,12 @@ public class ExtraInfoDescriptorImplTest {
+ "2012-02-11 00:59:53 (172800 s) XXXXXXXXXXXXXXXXXXXXXXXXXXX");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testDirreqV3IpsThreeLetterCountry()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Line 'dirreq-v3-ips usa=1544' contains an "
+ + "illegal key in list element 'usa=1544'.");
DirreqStatsBuilder.createWithDirreqV3IpsLine("dirreq-v3-ips "
+ "usa=1544");
}
@@ -1366,9 +1462,12 @@ public class ExtraInfoDescriptorImplTest {
DirreqStatsBuilder.createWithDirreqV2IpsLine("dirreq-v2-ips 00=8");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testDirreqV3ReqsOneLetterCountry()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Line 'dirreq-v3-reqs u=1744' contains an "
+ + "illegal key in list element 'u=1744'.");
DirreqStatsBuilder.createWithDirreqV3ReqsLine("dirreq-v3-reqs "
+ "u=1744");
}
@@ -1380,15 +1479,21 @@ public class ExtraInfoDescriptorImplTest {
assertNull(eid.getDirreqV3Reqs());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testDirreqV2ReqsNoNumber()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Line 'dirreq-v2-reqs us=' contains an illegal "
+ + "value in list element 'us='.");
DirreqStatsBuilder.createWithDirreqV2ReqsLine("dirreq-v2-reqs us=");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testDirreqV3RespTwoEqualSigns()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Line 'dirreq-v3-resp ok==10848' contains an "
+ + "illegal value in list element 'ok==10848'.");
DirreqStatsBuilder.createWithDirreqV3RespLine("dirreq-v3-resp "
+ "ok==10848");
}
@@ -1410,23 +1515,28 @@ public class ExtraInfoDescriptorImplTest {
+ "ok=1084 4801=ko");
}
- @Test(expected = DescriptorParseException.class)
- public void testDirreqV2RespNull()
- throws DescriptorParseException {
+ @Test
+ public void testDirreqV2RespNull() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage(
+ "Line 'dirreq-v2-resp ok=null' contains an illegal value in "
+ + "list element 'ok=null'.");
DirreqStatsBuilder.createWithDirreqV2RespLine("dirreq-v2-resp "
+ "ok=null");
}
- @Test(expected = DescriptorParseException.class)
- public void testDirreqV2ShareComma()
- throws DescriptorParseException {
+ @Test
+ public void testDirreqV2ShareComma() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal line 'dirreq-v2-share 0,37%'.");
DirreqStatsBuilder.createWithDirreqV2ShareLine("dirreq-v2-share "
+ "0,37%");
}
- @Test(expected = DescriptorParseException.class)
- public void testDirreqV3ShareNoPercent()
- throws DescriptorParseException {
+ @Test
+ public void testDirreqV3ShareNoPercent() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal line 'dirreq-v3-share 0.37'.");
DirreqStatsBuilder.createWithDirreqV3ShareLine("dirreq-v3-share "
+ "0.37");
}
@@ -1438,9 +1548,11 @@ public class ExtraInfoDescriptorImplTest {
+ "0.37% 123456");
}
- @Test(expected = DescriptorParseException.class)
- public void testDirreqV3DirectDlSpace()
- throws DescriptorParseException {
+ @Test
+ public void testDirreqV3DirectDlSpace() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Line 'dirreq-v3-direct-dl complete 36' contains "
+ + "an illegal value in list element 'complete'.");
DirreqStatsBuilder.createWithDirreqV3DirectDlLine(
"dirreq-v3-direct-dl complete 36");
}
@@ -1452,16 +1564,20 @@ public class ExtraInfoDescriptorImplTest {
"dirreq-v2-direct-dl complete=-8");
}
- @Test(expected = DescriptorParseException.class)
- public void testDirreqV3TunneledDlTooLarge()
- throws DescriptorParseException {
+ @Test
+ public void testDirreqV3TunneledDlTooLarge() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Line 'dirreq-v3-tunneled-dl complete=2147483648'"
+ + " contains an illegal value in list element 'complete=2147483648'.");
DirreqStatsBuilder.createWithDirreqV3TunneledDlLine(
"dirreq-v3-tunneled-dl complete=2147483648");
}
- @Test(expected = DescriptorParseException.class)
- public void testDirreqV3TunneledDlDouble()
- throws DescriptorParseException {
+ @Test
+ public void testDirreqV3TunneledDlDouble() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Line 'dirreq-v2-tunneled-dl complete=0.001' "
+ + "contains an illegal value in list element 'complete=0.001'.");
DirreqStatsBuilder.createWithDirreqV2TunneledDlLine(
"dirreq-v2-tunneled-dl complete=0.001");
}
@@ -1485,15 +1601,20 @@ public class ExtraInfoDescriptorImplTest {
assertFalse(ips.containsKey("no"));
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testEntryStatsEndNoDate() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage(
+ "Illegal line 'entry-stats-end 01:59:39 (86400 s)'.");
EntryStatsBuilder.createWithEntryStatsEndLine("entry-stats-end "
+ "01:59:39 (86400 s)");
}
- @Test(expected = DescriptorParseException.class)
- public void testEntryStatsIpsSemicolon()
- throws DescriptorParseException {
+ @Test
+ public void testEntryStatsIpsSemicolon() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Line 'entry-ips ir=25368;us=15744' contains an "
+ + "illegal value in list element 'ir=25368;us=15744'.");
EntryStatsBuilder.createWithEntryIpsLine("entry-ips "
+ "ir=25368;us=15744");
}
@@ -1519,37 +1640,50 @@ public class ExtraInfoDescriptorImplTest {
assertEquals(866, descriptor.getCellCircuitsPerDecile());
}
- @Test(expected = DescriptorParseException.class)
- public void testCellStatsEndNoSeconds()
- throws DescriptorParseException {
+ @Test
+ public void testCellStatsEndNoSeconds() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage(
+ "Illegal line 'cell-stats-end 2012-02-11 01:59:39 (86400)'.");
CellStatsBuilder.createWithCellStatsEndLine("cell-stats-end "
+ "2012-02-11 01:59:39 (86400)");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testCellProcessedCellsNineComma()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Line 'cell-processed-cells 1441,11,6,4,2,"
+ + "1,1,1,1,' contains an illegal value in list element ''.");
CellStatsBuilder.createWithCellProcessedCellsLine(
"cell-processed-cells 1441,11,6,4,2,1,1,1,1,");
}
- @Test(expected = DescriptorParseException.class)
- public void testCellProcessedCellsEleven()
- throws DescriptorParseException {
+ @Test
+ public void testCellProcessedCellsEleven() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("There must be exact ten values in line "
+ + "'cell-queued-cells 3.29,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,"
+ + "0.00,0.00'.");
CellStatsBuilder.createWithCellQueuedCellsLine("cell-queued-cells "
+ "3.29,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00");
}
- @Test(expected = DescriptorParseException.class)
- public void testCellTimeInQueueDouble()
- throws DescriptorParseException {
+ @Test
+ public void testCellTimeInQueueDouble() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Line 'cell-time-in-queue 524.0,1.0,1.0,0.0,0.0,"
+ + "25.0,0.0,0.0,0.0,0.0' contains an illegal value in list element "
+ + "'524.0'.");
CellStatsBuilder.createWithCellTimeInQueueLine("cell-time-in-queue "
+ "524.0,1.0,1.0,0.0,0.0,25.0,0.0,0.0,0.0,0.0");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testCellCircuitsPerDecileNegative()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal line 'cell-circuits-per-decile -866'.");
CellStatsBuilder.createWithCellCircuitsPerDecileLine(
"cell-circuits-per-decile -866");
}
@@ -1576,9 +1710,11 @@ public class ExtraInfoDescriptorImplTest {
assertEquals(1744, descriptor.getConnBiDirectBoth());
}
- @Test(expected = DescriptorParseException.class)
- public void testConnBiDirectStatsFive()
- throws DescriptorParseException {
+ @Test
+ public void testConnBiDirectStatsFive() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal line 'conn-bi-direct 2012-02-11 01:59:39"
+ + " (86400 s) 42173,1591,1310,1744,42' in extra-info descriptor.");
DescriptorBuilder.createWithConnBiDirectLine("conn-bi-direct "
+ "2012-02-11 01:59:39 (86400 s) 42173,1591,1310,1744,42");
}
@@ -1624,23 +1760,30 @@ public class ExtraInfoDescriptorImplTest {
}
}
- @Test(expected = DescriptorParseException.class)
- public void testExitStatsEndNoSeconds()
- throws DescriptorParseException {
+ @Test
+ public void testExitStatsEndNoSeconds() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal timestamp format in line "
+ + "'exit-stats-end 2012-02-11 01:59 (86400 s)'.");
ExitStatsBuilder.createWithExitStatsEndLine("exit-stats-end "
+ "2012-02-11 01:59 (86400 s)");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testExitStatsWrittenNegativePort()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage(
+ "Invalid port in line 'exit-kibibytes-written -25=74647'.");
ExitStatsBuilder.createWithExitKibibytesWrittenLine(
"exit-kibibytes-written -25=74647");
}
- @Test(expected = DescriptorParseException.class)
- public void testExitStatsWrittenUnknown()
- throws DescriptorParseException {
+ @Test
+ public void testExitStatsWrittenUnknown() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage(
+ "Invalid port in line 'exit-kibibytes-written unknown=74647'.");
ExitStatsBuilder.createWithExitKibibytesWrittenLine(
"exit-kibibytes-written unknown=74647");
}
@@ -1655,9 +1798,12 @@ public class ExtraInfoDescriptorImplTest {
"exit-kibibytes-written =74647");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testExitStatsReadNegativeBytes()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage(
+ "Invalid value in line 'exit-kibibytes-read 25=-35562'.");
ExitStatsBuilder.createWithExitKibibytesReadLine(
"exit-kibibytes-read 25=-35562");
}
@@ -1705,9 +1851,12 @@ public class ExtraInfoDescriptorImplTest {
assertEquals(1728, trans.get("obfs3").intValue());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testBridgeStatsEndIntervalZero()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Interval length must be positive in line "
+ + "'bridge-stats-end 2012-02-11 01:59:39 (0 s)'.");
BridgeStatsBuilder.createWithBridgeStatsEndLine("bridge-stats-end "
+ "2012-02-11 01:59:39 (0 s)");
}
@@ -1719,15 +1868,21 @@ public class ExtraInfoDescriptorImplTest {
+ "2012-02-11 01:59:39 (86400 s) 99999999999999999999999999999999");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testBridgeIpsDouble()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Line 'bridge-ips ir=24.5' contains an illegal "
+ + "value in list element 'ir=24.5'.");
BridgeStatsBuilder.createWithBridgeIpsLine("bridge-ips ir=24.5");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testBridgeIpsNonAsciiKeyword()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Unrecognized character in keyword "
+ + "'�bridge-ips' in line '�bridge-ips'.");
DescriptorBuilder.createWithNonAsciiLineBytes(new byte[] {
0x14, (byte) 0xfe, 0x18, // non-ascii chars
0x62, 0x72, 0x69, 0x64, 0x67, 0x65, 0x2d, // "bridge-"
@@ -1740,9 +1895,12 @@ public class ExtraInfoDescriptorImplTest {
BridgeStatsBuilder.createWithBridgeIpsLine("bridge-ips ir=24 5");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testBridgeIpVersionsDouble()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Line 'bridge-ip-versions v4=24.5' "
+ + "contains an illegal value in list element 'v4=24.5'.");
BridgeStatsBuilder.createWithBridgeIpVersionsLine(
"bridge-ip-versions v4=24.5");
}
@@ -1754,9 +1912,12 @@ public class ExtraInfoDescriptorImplTest {
"bridge-ip-versions v4=24 5");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testBridgeIpTransportsDouble()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Line 'bridge-ip-transports obfs2=24.5' contains "
+ + "an illegal value in list element 'obfs2=24.5'.");
BridgeStatsBuilder.createWithBridgeIpTransportsLine(
"bridge-ip-transports obfs2=24.5");
}
@@ -1837,8 +1998,11 @@ public class ExtraInfoDescriptorImplTest {
0L, 0L, 0L, 0L, 0L, 42L});
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testPaddingCountsNoTime() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal line 'padding-counts 2017-05-10"
+ + " (86400 s) bin-size=10000 write-drop=10000'.");
DescriptorBuilder.createWithPaddingCountsLine("padding-counts 2017-05-10 "
+ "(86400 s) bin-size=10000 write-drop=10000");
}
@@ -1954,16 +2118,24 @@ public class ExtraInfoDescriptorImplTest {
descriptor.getHidservRendRelayedCellsParameters().isEmpty());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testHidservDirOnionsSeenCommaSeparatedParams()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Line 'hidserv-dir-onions-seen -3 delta_f=8,"
+ + "epsilon=0.30,bin_size=8' contains an illegal value in list element "
+ + "'delta_f=8,epsilon=0.30,bin_size=8'.");
HidservStatsBuilder.createWithHidservDirOnionsSeenLine(
"hidserv-dir-onions-seen -3 delta_f=8,epsilon=0.30,bin_size=8");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testHidservDirOnionsSeenNoDoubleParams()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Line 'hidserv-dir-onions-seen -3 delta_f=A "
+ + "epsilon=B bin_size=C' contains an illegal value in list element "
+ + "'delta_f=A'.");
HidservStatsBuilder.createWithHidservDirOnionsSeenLine(
"hidserv-dir-onions-seen -3 delta_f=A epsilon=B bin_size=C");
}
@@ -1975,9 +2147,12 @@ public class ExtraInfoDescriptorImplTest {
"hidserv-dir-onions-seen -3 delta_f=8 epsilon=0.30 bin_size=8 pi=3");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testRouterSignatureNotLastLine()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'published' is contained 2 times, "
+ + "but must be contained exactly once.");
DescriptorBuilder.createWithRouterSignatureLines("router-signature\n"
+ "-----BEGIN SIGNATURE-----\n"
+ "o4j+kH8UQfjBwepUnr99v0ebN8RpzHJ/lqYsTojXHy9kMr1RNI9IDeSzA7PSqT"
@@ -1986,9 +2161,11 @@ public class ExtraInfoDescriptorImplTest {
+ "-----END SIGNATURE-----\npublished 2012-02-11 09:08:36");
}
- @Test(expected = DescriptorParseException.class)
- public void testUnrecognizedLineFail()
- throws DescriptorParseException {
+ @Test
+ public void testUnrecognizedLineFail() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Unrecognized line 'unrecognized-line 1' in "
+ + "extra-info descriptor.");
String unrecognizedLine = "unrecognized-line 1";
DescriptorBuilder.createWithUnrecognizedLine(unrecognizedLine, true);
}
@@ -2036,9 +2213,12 @@ public class ExtraInfoDescriptorImplTest {
descriptor.getRouterSignatureEd25519());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testEd25519IdentityMasterKeyMismatch()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage(
+ "Mismatch between identity-ed25519 and master-key-ed25519.");
DescriptorBuilder.createWithEd25519Lines(IDENTITY_ED25519_LINES,
"master-key-ed25519 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
ROUTER_SIG_ED25519_LINE);
@@ -2051,17 +2231,23 @@ public class ExtraInfoDescriptorImplTest {
MASTER_KEY_ED25519_LINE, ROUTER_SIG_ED25519_LINE);
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testEd25519IdentityDuplicate()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'identity-ed25519' is contained 2 times,"
+ + " but must be contained at most once.");
DescriptorBuilder.createWithEd25519Lines(IDENTITY_ED25519_LINES + "\n"
+ IDENTITY_ED25519_LINES, MASTER_KEY_ED25519_LINE,
ROUTER_SIG_ED25519_LINE);
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testEd25519IdentityEmptyCrypto()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage(
+ "Invalid length of identity-ed25519 (in bytes): 0");
DescriptorBuilder.createWithEd25519Lines("identity-ed25519\n"
+ "-----BEGIN ED25519 CERT-----\n-----END ED25519 CERT-----",
MASTER_KEY_ED25519_LINE, ROUTER_SIG_ED25519_LINE);
@@ -2078,9 +2264,12 @@ public class ExtraInfoDescriptorImplTest {
descriptor.getMasterKeyEd25519());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testEd25519MasterKeyDuplicate()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'master-key-ed25519' is contained 2 "
+ + "times, but must be contained at most once.");
DescriptorBuilder.createWithEd25519Lines(IDENTITY_ED25519_LINES,
MASTER_KEY_ED25519_LINE + "\n" + MASTER_KEY_ED25519_LINE,
ROUTER_SIG_ED25519_LINE);
@@ -2093,17 +2282,23 @@ public class ExtraInfoDescriptorImplTest {
MASTER_KEY_ED25519_LINE, null);
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testEd25519RouterSigDuplicate()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'router-sig-ed25519' is contained "
+ + "2 times, but must be contained at most once.");
DescriptorBuilder.createWithEd25519Lines(IDENTITY_ED25519_LINES,
MASTER_KEY_ED25519_LINE, ROUTER_SIG_ED25519_LINE + "\n"
+ ROUTER_SIG_ED25519_LINE);
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testEd25519FollowedbyUnrecognizedLine()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage(
+ "Unrecognized line 'unrecognized-line 1' in extra-info descriptor.");
DescriptorBuilder.createWithEd25519Lines(IDENTITY_ED25519_LINES,
MASTER_KEY_ED25519_LINE, ROUTER_SIG_ED25519_LINE
+ "\nunrecognized-line 1");
diff --git a/src/test/java/org/torproject/descriptor/impl/MicrodescriptorImplTest.java b/src/test/java/org/torproject/descriptor/impl/MicrodescriptorImplTest.java
index 140974c..7167de9 100644
--- a/src/test/java/org/torproject/descriptor/impl/MicrodescriptorImplTest.java
+++ b/src/test/java/org/torproject/descriptor/impl/MicrodescriptorImplTest.java
@@ -8,10 +8,15 @@ import static org.junit.Assert.assertEquals;
import org.torproject.descriptor.DescriptorParseException;
import org.torproject.descriptor.Microdescriptor;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
public class MicrodescriptorImplTest {
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
/* Helper class to build a microdescriptor based on default data and
* modifications requested by test methods. */
private static class DescriptorBuilder {
@@ -73,25 +78,39 @@ public class MicrodescriptorImplTest {
micro.getDigestSha256Base64());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testIdRsa1024TooShort() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("'AAAA' in line 'id rsa1024 AAAA' is not a "
+ + "valid base64-encoded 20-byte value.");
DescriptorBuilder.createWithIdLine("id rsa1024 AAAA");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testIdRsa1024TooLong() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
+ + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' in line 'id ed25519 "
+ + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
+ + "AAAAAAAAAAAAAAAAAAA' is not a valid base64-encoded 32-byte value.");
DescriptorBuilder.createWithIdLine("id ed25519 AAAAAAAAAAAAAAAAAAAAAA"
+ "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testIdRsa512() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage(
+ "Illegal line 'id rsa512 bvegfGxp8k7T9QFpjPTrPaJTa/8'.");
DescriptorBuilder.createWithIdLine("id rsa512 "
+ "bvegfGxp8k7T9QFpjPTrPaJTa/8");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testIdEd25519Duplicate() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'id' is contained 2 times, but must be"
+ + " contained at most once.");
DescriptorBuilder.createWithIdLine(
"id rsa1024 bvegfGxp8k7T9QFpjPTrPaJTa/8\n"
+ "id rsa1024 bvegfGxp8k7T9QFpjPTrPaJTa/8");
diff --git a/src/test/java/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImplTest.java b/src/test/java/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImplTest.java
index d6bf4cf..dcd3663 100644
--- a/src/test/java/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImplTest.java
+++ b/src/test/java/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImplTest.java
@@ -14,7 +14,9 @@ import org.torproject.descriptor.DirectorySignature;
import org.torproject.descriptor.NetworkStatusEntry;
import org.torproject.descriptor.RelayNetworkStatusConsensus;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
import java.util.ArrayList;
import java.util.Arrays;
@@ -29,6 +31,9 @@ import java.util.TreeSet;
* a parsed consensus is fully compatible to dir-spec.txt. */
public class RelayNetworkStatusConsensusImplTest {
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
/* Helper class to build a directory source based on default data and
* modifications requested by test methods. */
private static class DirSourceBuilder {
@@ -392,22 +397,29 @@ public class RelayNetworkStatusConsensusImplTest {
assertTrue(consensus.getUnrecognizedLines().isEmpty());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testNetworkStatusVersionNoLine()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'network-status-version' must be "
+ + "contained in the first line.");
ConsensusBuilder.createWithNetworkStatusVersionLine(null);
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testNetworkStatusVersionNewLine()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Blank lines are not allowed.");
ConsensusBuilder.createWithNetworkStatusVersionLine(
"network-status-version 3\n");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testNetworkStatusVersionNewLineSpace()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal keyword in line ' '.");
ConsensusBuilder.createWithNetworkStatusVersionLine(
"network-status-version 3\n ");
}
@@ -419,72 +431,104 @@ public class RelayNetworkStatusConsensusImplTest {
"@consensus\nnetwork-status-version 3");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testNetworkStatusVersionPrefixLine()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage(
+ "Unrecognized line 'directory-footer' in consensus.");
ConsensusBuilder.createWithNetworkStatusVersionLine(
"directory-footer\nnetwork-status-version 3");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testNetworkStatusVersionPrefixLinePoundChar()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Unrecognized line '#consensus' in consensus.");
ConsensusBuilder.createWithNetworkStatusVersionLine(
"#consensus\nnetwork-status-version 3");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testNetworkStatusVersionNoSpace()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal network status version number in line "
+ + "'network-status-version'.");
ConsensusBuilder.createWithNetworkStatusVersionLine(
"network-status-version");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testNetworkStatusVersionOneSpace()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal network status version number in line "
+ + "'network-status-version '.");
ConsensusBuilder.createWithNetworkStatusVersionLine(
"network-status-version ");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testNetworkStatusVersion42()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal network status version number in line "
+ + "'network-status-version 42'.");
ConsensusBuilder.createWithNetworkStatusVersionLine(
"network-status-version 42");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testNetworkStatusVersionFourtyTwo()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal network status version number in line "
+ + "'network-status-version FourtyTwo'.");
ConsensusBuilder.createWithNetworkStatusVersionLine(
"network-status-version FourtyTwo");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testVoteStatusNoLine() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'vote-status' is contained 0 times, "
+ + "but must be contained exactly once.");
ConsensusBuilder.createWithVoteStatusLine(null);
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testNetworkStatusVersionSpaceBefore()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage(
+ "Illegal keyword in line ' network-status-version 3'.");
ConsensusBuilder.createWithNetworkStatusVersionLine(
" network-status-version 3");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testVoteStatusSpaceBefore() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage(
+ "Illegal keyword in line ' vote-status consensus'.");
ConsensusBuilder.createWithVoteStatusLine(" vote-status consensus");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testVoteStatusNoSpace() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage(
+ "Line 'vote-status' indicates that this is not a consensus.");
ConsensusBuilder.createWithVoteStatusLine("vote-status");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testVoteStatusOneSpace() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage(
+ "Line 'vote-status ' indicates that this is not a consensus.");
ConsensusBuilder.createWithVoteStatusLine("vote-status ");
}
@@ -494,135 +538,201 @@ public class RelayNetworkStatusConsensusImplTest {
ConsensusBuilder.createWithVoteStatusLine("vote-status consensus ");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testVoteStatusVote() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage(
+ "Line 'vote-status vote' indicates that this is not a consensus.");
ConsensusBuilder.createWithVoteStatusLine("vote-status vote");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testVoteStatusTheMagicVoteStatus()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Line 'vote-status TheMagicVoteStatus' indicates "
+ + "that this is not a consensus.");
ConsensusBuilder.createWithVoteStatusLine(
"vote-status TheMagicVoteStatus");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testConsensusMethodNoLine()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'consensus-method' is contained 0 "
+ + "times, but must be contained exactly once.");
ConsensusBuilder.createWithConsensusMethodLine(null);
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testConsensusMethodNoSpace()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal line 'consensus-method' in consensus.");
ConsensusBuilder.createWithConsensusMethodLine("consensus-method");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testConsensusMethodOneSpace()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal line 'consensus-method ' in consensus.");
ConsensusBuilder.createWithConsensusMethodLine("consensus-method ");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testConsensusMethodEleven()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage(
+ "Illegal consensus method number in line 'consensus-method eleven'.");
ConsensusBuilder.createWithConsensusMethodLine(
"consensus-method eleven");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testConsensusMethodMinusOne()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal consensus method number in line "
+ + "'consensus-method -1'.");
ConsensusBuilder.createWithConsensusMethodLine("consensus-method -1");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testConsensusMethodNinePeriod()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal consensus method number in line "
+ + "'consensus-method 99999999999999999999999999999999999999999999"
+ + "9999999999999999'.");
ConsensusBuilder.createWithConsensusMethodLine("consensus-method "
+ "999999999999999999999999999999999999999999999999999999999999");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testConsensusMethodTwoLines()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'consensus-method' is contained 2 times,"
+ + " but must be contained exactly once.");
ConsensusBuilder.createWithConsensusMethodLine(
"consensus-method 1\nconsensus-method 1");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testValidAfterNoLine() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'valid-after' is contained 0 times, "
+ + "but must be contained exactly once.");
ConsensusBuilder.createWithValidAfterLine(null);
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testValidAfterNoSpace() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Line 'valid-after' does not contain a "
+ + "timestamp at the expected position.");
ConsensusBuilder.createWithValidAfterLine("valid-after");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testValidAfterOneSpace() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Line 'valid-after ' does not contain a timestamp"
+ + " at the expected position.");
ConsensusBuilder.createWithValidAfterLine("valid-after ");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testValidAfterLongAgo() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage(
+ "Illegal timestamp format in line 'valid-after long ago'.");
ConsensusBuilder.createWithValidAfterLine("valid-after long ago");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testValidAfterFeb30() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal timestamp format in line "
+ + "'valid-after 2011-02-30 09:00:00'.");
ConsensusBuilder.createWithValidAfterLine(
"valid-after 2011-02-30 09:00:00");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testFreshUntilNoLine() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'fresh-until' is contained 0 times, "
+ + "but must be contained exactly once.");
ConsensusBuilder.createWithFreshUntilLine(null);
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testFreshUntilAroundTen() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal timestamp format in line "
+ + "'fresh-until 2011-11-30 around ten'.");
ConsensusBuilder.createWithFreshUntilLine(
"fresh-until 2011-11-30 around ten");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testValidUntilTomorrowMorning()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage(
+ "Illegal timestamp format in line 'valid-until tomorrow morning'.");
ConsensusBuilder.createWithValidUntilLine(
"valid-until tomorrow morning");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testVotingDelayNoLine() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'voting-delay' is contained 0 times, "
+ + "but must be contained exactly once.");
ConsensusBuilder.createWithVotingDelayLine(null);
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testVotingDelayNoSpace() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Wrong number of values in line 'voting-delay'.");
ConsensusBuilder.createWithVotingDelayLine("voting-delay");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testVotingDelayOneSpace() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage(
+ "Wrong number of values in line 'voting-delay '.");
ConsensusBuilder.createWithVotingDelayLine("voting-delay ");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testVotingDelayTriple() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage(
+ "Wrong number of values in line 'voting-delay 300 300 300'.");
ConsensusBuilder.createWithVotingDelayLine(
"voting-delay 300 300 300");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testVotingDelaySingle() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage(
+ "Wrong number of values in line 'voting-delay 300'.");
ConsensusBuilder.createWithVotingDelayLine("voting-delay 300");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testVotingDelayOneTwo() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal values in line 'voting-delay one two'.");
ConsensusBuilder.createWithVotingDelayLine("voting-delay one two");
}
@@ -671,14 +781,19 @@ public class RelayNetworkStatusConsensusImplTest {
assertTrue(consensus.getRecommendedClientVersions().isEmpty());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testClientVersionsComma() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal versions line 'client-versions ,'.");
ConsensusBuilder.createWithClientVersionsLine("client-versions ,");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testClientVersionsCommaVersion()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage(
+ "Illegal versions line 'client-versions ,0.2.2.34'.");
ConsensusBuilder.createWithClientVersionsLine(
"client-versions ,0.2.2.34");
}
@@ -724,9 +839,12 @@ public class RelayNetworkStatusConsensusImplTest {
consensus.getRequiredRelayProtocols().get("Cons"));
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testRequiredRelayProtocolsTwice()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'required-relay-protocols' is contained "
+ + "2 times, but must be contained at most once.");
ConsensusBuilder.createWithRequiredRelayProtocolsLine(
"required-relay-protocols Cons=1\nrequired-relay-protocols Cons=1");
}
@@ -761,24 +879,34 @@ public class RelayNetworkStatusConsensusImplTest {
}
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testPackageIncomplete() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage(
+ "Wrong number of values in line 'package shouldbesecond 0 http'.");
String packageLine = "package shouldbesecond 0 http";
ConsensusBuilder.createWithPackageLines(packageLine);
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testKnownFlagsNoLine() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'known-flags' is contained 0 times, "
+ + "but must be contained exactly once.");
ConsensusBuilder.createWithKnownFlagsLine(null);
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testKnownFlagsNoSpace() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("No known flags in line 'known-flags'.");
ConsensusBuilder.createWithKnownFlagsLine("known-flags");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testKnownFlagsOneSpace() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("No known flags in line 'known-flags '.");
ConsensusBuilder.createWithKnownFlagsLine("known-flags ");
}
@@ -813,14 +941,20 @@ public class RelayNetworkStatusConsensusImplTest {
assertTrue(consensus.getConsensusParams().isEmpty());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testParamsNoEqualSign() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Line 'params key-value' contains an illegal "
+ + "value in list element 'key-value'.");
ConsensusBuilder.createWithParamsLine("params key-value");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testParamsOneTooLargeNegative()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Line 'params min=-2147483649' contains an "
+ + "illegal value in list element 'min=-2147483649'.");
ConsensusBuilder.createWithParamsLine("params min=-2147483649");
}
@@ -844,22 +978,31 @@ public class RelayNetworkStatusConsensusImplTest {
(int) consensus.getConsensusParams().get("max"));
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testParamsOneTooLargePositive()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Line 'params max=2147483648' contains an illegal"
+ + " value in list element 'max=2147483648'.");
ConsensusBuilder.createWithParamsLine("params max=2147483648");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testSharedRandPreviousNumRevealsOnly()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage(
+ "Illegal line 'shared-rand-previous-value 8' in vote.");
ConsensusBuilder.createWithSharedRandPreviousValueLine(
"shared-rand-previous-value 8");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testSharedRandPreviousExtraArg()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal line 'shared-rand-current-value 8 "
+ + "D88plxd8YeLfCIVAR9gjiFlWB1WqpC53kWr350o1pzw= -1.0' in vote.");
ConsensusBuilder.createWithSharedRandCurrentValueLine(
"shared-rand-current-value 8 "
+ "D88plxd8YeLfCIVAR9gjiFlWB1WqpC53kWr350o1pzw= -1.0");
@@ -880,62 +1023,101 @@ public class RelayNetworkStatusConsensusImplTest {
"81349FC1F2DBA2C2C11B45CB9706637D480AB913").isLegacy());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testDirSourceNicknameTooLong()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal nickname in line 'dir-source "
+ + "gabelmooisfinebutthisistoolong ED03BB616EB2F60BEC80151114BB25CEF5"
+ + "15B226 212.112.245.170 212.112.245.170 80 443'.");
DirSourceBuilder.createWithNickname("gabelmooisfinebutthisistoolong");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testDirSourceIdentityTooShort()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal hex string in line 'dir-source gabelmoo "
+ + "ED03BB616EB2F60BEC8015111 212.112.245.170 212.112.245.170 80 443'.");
DirSourceBuilder.createWithIdentity("ED03BB616EB2F60BEC8015111");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testDirSourceIdentityTooLong()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal hex string in line 'dir-source gabelmoo "
+ + "ED03BB616EB2F60BEC80151114BB25CEF515B226ED03BB616EB2F60BEC8 "
+ + "212.112.245.170 212.112.245.170 80 443'.");
DirSourceBuilder.createWithIdentity("ED03BB616EB2F60BEC8015111"
+ "4BB25CEF515B226ED03BB616EB2F60BEC8");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testDirSourceHostnameMissing()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Invalid line 'dir-source gabelmoo "
+ + "ED03BB616EB2F60BEC80151114BB25CEF515B226 212.112.245.170 80 443'.");
DirSourceBuilder.createWithHostName("");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testDirSourceAddress24() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("'212.112.245' in line 'dir-source "
+ + "gabelmoo ED03BB616EB2F60BEC80151114BB25CEF515B226 212.112.245.170 "
+ + "212.112.245 80 443' is not a valid IPv4 address.");
DirSourceBuilder.createWithAddress("212.112.245");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testDirSourceAddress40() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage(
+ "'212.112.245.170.123' in line 'dir-source gabelmoo "
+ + "ED03BB616EB2F60BEC80151114BB25CEF515B226 212.112.245.170 212.112.245"
+ + ".170.123 80 443' is not a valid IPv4 address.");
DirSourceBuilder.createWithAddress("212.112.245.170.123");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testDirSourceDirPortMinusOne()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("'-1' in line 'dir-source gabelmoo "
+ + "ED03BB616EB2F60BEC80151114BB25CEF515B226 212.112.245.170 "
+ + "212.112.245.170 -1 443' is not a valid port number.");
DirSourceBuilder.createWithDirPort("-1");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testDirSourceDirPort66666()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("'66666' in line 'dir-source gabelmoo "
+ + "ED03BB616EB2F60BEC80151114BB25CEF515B226 212.112.245.170 "
+ + "212.112.245.170 66666 443' is not a valid port number.");
DirSourceBuilder.createWithDirPort("66666");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testDirSourceDirPortOnions()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("'onions' in line 'dir-source gabelmoo "
+ + "ED03BB616EB2F60BEC80151114BB25CEF515B226 212.112.245.170 "
+ + "212.112.245.170 onions 443' is not a valid port number.");
DirSourceBuilder.createWithDirPort("onions");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testDirSourceOrPortOnions()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("'onions' in line 'dir-source gabelmoo "
+ + "ED03BB616EB2F60BEC80151114BB25CEF515B226 212.112.245.170 "
+ + "212.112.245.170 80 onions' is not a valid port number.");
DirSourceBuilder.createWithOrPort("onions");
}
@@ -966,113 +1148,193 @@ public class RelayNetworkStatusConsensusImplTest {
"ED03BB616EB2F60BEC80151114BB25CEF515B226").getContactLine());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testDirSourceVoteDigestNoLine()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage(
+ "dir-source does not contain a 'vote-digest' line.");
DirSourceBuilder.createWithVoteDigestLine(null);
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testDirSourceVoteDigestLineNoSpace()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Invalid line 'vote-digest'.");
DirSourceBuilder.createWithVoteDigestLine("vote-digest");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testDirSourceVoteDigestLineOneSpace()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Invalid line 'vote-digest '.");
DirSourceBuilder.createWithVoteDigestLine("vote-digest ");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testNicknameNotAllowedChars()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal nickname in line 'r notAll()wed "
+ + "ADQ6gCT3DiFHKPDFr3rODBUI8HM Yiti+nayuT2Efe2X1+M4nslwVuU 2011-11-29 "
+ + "21:34:27 50.63.8.215 9023 0'.");
StatusEntryBuilder.createWithNickname("notAll()wed");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testNicknameTooLong() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal nickname in line "
+ + "'r 1234567890123456789tooLong ADQ6gCT3DiFHKPDFr3rODBUI8HM "
+ + "Yiti+nayuT2Efe2X1+M4nslwVuU 2011-11-29 21:34:27 50.63.8.215 "
+ + "9023 0'.");
StatusEntryBuilder.createWithNickname("1234567890123456789tooLong");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testFingerprintTooShort() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("'TooShort' in line 'r right2privassy3 TooShort "
+ + "Yiti+nayuT2Efe2X1+M4nslwVuU 2011-11-29 21:34:27 50.63.8.215 9023 0' "
+ + "is not a valid base64-encoded 20-byte value.");
StatusEntryBuilder.createWithFingerprintBase64("TooShort");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testFingerprintEndsWithEqualSign()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("'ADQ6gCT3DiFHKPDFr3rODBUI8H=' in line 'r "
+ + "right2privassy3 ADQ6gCT3DiFHKPDFr3rODBUI8H= Yiti+nayuT2Efe2X1+M4"
+ + "nslwVuU 2011-11-29 21:34:27 50.63.8.215 9023 0' is not a valid "
+ + "base64-encoded 20-byte value.");
StatusEntryBuilder.createWithFingerprintBase64(
"ADQ6gCT3DiFHKPDFr3rODBUI8H=");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testFingerprintTooLong() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("'ADQ6gCT3DiFHKPDFr3rODBUI8HMAAAA' in line "
+ + "'r right2privassy3 ADQ6gCT3DiFHKPDFr3rODBUI8HMAAAA Yiti+nayuT2Efe2X1"
+ + "+M4nslwVuU 2011-11-29 21:34:27 50.63.8.215 9023 0' is not a valid "
+ + "base64-encoded 20-byte value.");
StatusEntryBuilder.createWithFingerprintBase64(
"ADQ6gCT3DiFHKPDFr3rODBUI8HMAAAA");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testDescriptorTooShort() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("'TooShort' in line 'r right2privassy3 "
+ + "ADQ6gCT3DiFHKPDFr3rODBUI8HM TooShort 2011-11-29 21:34:27 50.63.8.215"
+ + " 9023 0' is not a valid base64-encoded 20-byte value.");
StatusEntryBuilder.createWithDescriptorBase64("TooShort");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testDescriptorEndsWithEqualSign()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("'ADQ6gCT3DiFHKPDFr3rODBUI8H=' in line "
+ + "'r right2privassy3 ADQ6gCT3DiFHKPDFr3rODBUI8HM "
+ + "ADQ6gCT3DiFHKPDFr3rODBUI8H= 2011-11-29 21:34:27 50.63.8.215 9023 0' "
+ + "is not a valid base64-encoded 20-byte value.");
StatusEntryBuilder.createWithDescriptorBase64(
"ADQ6gCT3DiFHKPDFr3rODBUI8H=");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testDescriptorTooLong() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("'Yiti+nayuT2Efe2X1+M4nslwVuUAAAA' in line "
+ + "'r right2privassy3 ADQ6gCT3DiFHKPDFr3rODBUI8HM Yiti+nayuT2Efe2X1+M4n"
+ + "slwVuUAAAA 2011-11-29 21:34:27 50.63.8.215 9023 0' is not a valid "
+ + "base64-encoded 20-byte value.");
StatusEntryBuilder.createWithDescriptorBase64(
"Yiti+nayuT2Efe2X1+M4nslwVuUAAAA");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testPublished1960() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal timestamp format in line 'r "
+ + "right2privassy3 ADQ6gCT3DiFHKPDFr3rODBUI8HM Yiti+nayuT2Efe2X1+M4ns"
+ + "lwVuU 1960-11-29 21:34:27 50.63.8.215 9023 0'.");
StatusEntryBuilder.createWithPublishedString("1960-11-29 21:34:27");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testPublished9999() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal timestamp format in line 'r "
+ + "right2privassy3 ADQ6gCT3DiFHKPDFr3rODBUI8HM Yiti+nayuT2Efe2X1+"
+ + "M4nslwVuU 9999-11-29 21:34:27 50.63.8.215 9023 0'.");
StatusEntryBuilder.createWithPublishedString("9999-11-29 21:34:27");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testAddress256() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("'256.63.8.215' in line 'r right2privassy3 "
+ + "ADQ6gCT3DiFHKPDFr3rODBUI8HM Yiti+nayuT2Efe2X1+M4nslwVuU 2011-11-29 "
+ + "21:34:27 256.63.8.215 9023 0' is not a valid IPv4 address.");
StatusEntryBuilder.createWithAddress("256.63.8.215");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testAddress24() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("'50.63.8/24' in line 'r right2privassy3 "
+ + "ADQ6gCT3DiFHKPDFr3rODBUI8HM Yiti+nayuT2Efe2X1+M4nslwVuU 2011-11-29 "
+ + "21:34:27 50.63.8/24 9023 0' is not a valid IPv4 address.");
StatusEntryBuilder.createWithAddress("50.63.8/24");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testAddressV6() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("'::1' in line 'r right2privassy3 "
+ + "ADQ6gCT3DiFHKPDFr3rODBUI8HM Yiti+nayuT2Efe2X1+M4nslwVuU 2011-11-29 "
+ + "21:34:27 ::1 9023 0' is not a valid IPv4 address.");
StatusEntryBuilder.createWithAddress("::1");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testOrPort66666() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("'66666' in line 'r right2privassy3 "
+ + "ADQ6gCT3DiFHKPDFr3rODBUI8HM Yiti+nayuT2Efe2X1+M4nslwVuU 2011-11-29 "
+ + "21:34:27 50.63.8.215 66666 0' is not a valid port number.");
StatusEntryBuilder.createWithOrPort("66666");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testOrPortEighty() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("'eighty' in line 'r right2privassy3 "
+ + "ADQ6gCT3DiFHKPDFr3rODBUI8HM Yiti+nayuT2Efe2X1+M4nslwVuU 2011-11-29 "
+ + "21:34:27 50.63.8.215 eighty 0' is not a valid port number.");
StatusEntryBuilder.createWithOrPort("eighty");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testDirPortMinusOne() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("'-1' in line 'r right2privassy3 ADQ6gCT3DiFHKP"
+ + "DFr3rODBUI8HM Yiti+nayuT2Efe2X1+M4nslwVuU 2011-11-29 21:34:27 "
+ + "50.63.8.215 9023 -1' is not a valid port number.");
StatusEntryBuilder.createWithDirPort("-1");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testDirPortZero() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("'zero' in line 'r right2privassy3 "
+ + "ADQ6gCT3DiFHKPDFr3rODBUI8HM Yiti+nayuT2Efe2X1+M4nslwVuU 2011-11-29 "
+ + "21:34:27 50.63.8.215 9023 zero' is not a valid port number.");
StatusEntryBuilder.createWithDirPort("zero");
}
@@ -1092,8 +1354,10 @@ public class RelayNetworkStatusConsensusImplTest {
"00343A8024F70E214728F0C5AF7ACE0C1508F073").getFlags().isEmpty());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testTwoSLines() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Duplicate 's' line in status entry.");
StatusEntryBuilder sb = new StatusEntryBuilder();
sb.sLine = sb.sLine + "\n" + sb.sLine;
ConsensusBuilder cb = new ConsensusBuilder();
@@ -1101,8 +1365,10 @@ public class RelayNetworkStatusConsensusImplTest {
cb.buildConsensus(true);
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testTwoPrLines() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Duplicate 'pr' line in status entry.");
StatusEntryBuilder sb = new StatusEntryBuilder();
sb.prLine = sb.prLine + "\n" + sb.prLine;
ConsensusBuilder cb = new ConsensusBuilder();
@@ -1110,13 +1376,17 @@ public class RelayNetworkStatusConsensusImplTest {
cb.buildConsensus(true);
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testWLineNoSpace() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal line 'w'.");
StatusEntryBuilder.createWithWLine("w");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testWLineOneSpace() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal line 'w '.");
StatusEntryBuilder.createWithWLine("w ");
}
@@ -1125,8 +1395,10 @@ public class RelayNetworkStatusConsensusImplTest {
StatusEntryBuilder.createWithWLine("w Warp=7");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testTwoWLines() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Duplicate 'w' line in status entry.");
StatusEntryBuilder sb = new StatusEntryBuilder();
sb.wLine = sb.wLine + "\n" + sb.wLine;
ConsensusBuilder cb = new ConsensusBuilder();
@@ -1157,28 +1429,38 @@ public class RelayNetworkStatusConsensusImplTest {
}
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testPLineNoPolicy() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal line 'p 80'.");
StatusEntryBuilder.createWithPLine("p 80");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testPLineNoPorts() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal line 'p accept'.");
StatusEntryBuilder.createWithPLine("p accept");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testPLineNoPolicyNoPorts() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal line 'p '.");
StatusEntryBuilder.createWithPLine("p ");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testPLineProject() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal line 'p project 80'.");
StatusEntryBuilder.createWithPLine("p project 80");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testTwoPLines() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Duplicate 'p' line in status entry.");
StatusEntryBuilder sb = new StatusEntryBuilder();
sb.pLine = sb.pLine + "\n" + sb.pLine;
ConsensusBuilder cb = new ConsensusBuilder();
@@ -1195,9 +1477,14 @@ public class RelayNetworkStatusConsensusImplTest {
"00795A6E8D91C270FC23B30F388A495553E01894"));
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testDirectoryFooterNoLine()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Unrecognized line 'bandwidth-weights Wbd=285 "
+ + "Wbe=0 Wbg=0 Wbm=10000 Wdb=10000 Web=10000 Wed=1021 Wee=10000 "
+ + "Weg=1021 Wem=10000 Wgb=10000 Wgd=8694 Wgg=10000 Wgm=10000 Wmb=10000 "
+ + "Wmd=285 Wme=0 Wmg=0 Wmm=10000' in status entry.");
/* This breaks, because a bandwidth-weights line without a preceding
* directory-footer line is not allowed. */
ConsensusBuilder.createWithDirectoryFooterLine(null);
@@ -1245,16 +1532,22 @@ public class RelayNetworkStatusConsensusImplTest {
assertNotNull(consensus.getBandwidthWeights());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testBandwidthWeightsLineNoEqualSign()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Line 'bandwidth-weights Wbd-285' contains an "
+ + "illegal value in list element 'Wbd-285'.");
ConsensusBuilder.createWithBandwidthWeightsLine(
"bandwidth-weights Wbd-285");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testDirectorySignatureIdentityTooShort()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal hex string in line 'directory-signature "
+ + "ED03BB616EB2F60 845CF1D0B370CA443A8579D18E7987E7E532F639'.");
DirectorySignatureBuilder.createWithIdentity("ED03BB616EB2F60");
}
@@ -1277,9 +1570,12 @@ public class RelayNetworkStatusConsensusImplTest {
DirectorySignatureBuilder.createWithSigningKey("845CF1D0B370CA");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testDirectorySignatureSigningKeyTooShortOddNumber()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal hex string in line 'directory-signature "
+ + "ED03BB616EB2F60BEC80151114BB25CEF515B226 845'.");
/* We don't accept this hex string, because it contains an odd number
* of hex characters. */
DirectorySignatureBuilder.createWithSigningKey("845");
@@ -1294,8 +1590,11 @@ public class RelayNetworkStatusConsensusImplTest {
"845CF1D0B370CA443A8579D18E7987E7E532F639845CF1D0B370CA443A");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testNonAsciiByte20() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Unrecognized line 'network-status-versi�n 3' in "
+ + "consensus.");
ConsensusBuilder cb = new ConsensusBuilder();
byte[] consensusBytes = cb.buildConsensusBytes();
consensusBytes[20] = (byte) 200;
@@ -1303,9 +1602,12 @@ public class RelayNetworkStatusConsensusImplTest {
new int[] { 0, consensusBytes.length }, true);
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testNonAsciiByteMinusOne()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage(
+ "Unrecognized line '�network-status-version 3' in consensus.");
ConsensusBuilder cb = new ConsensusBuilder();
cb.networkStatusVersionLine = "Xnetwork-status-version 3";
byte[] consensusBytes = cb.buildConsensusBytes();
@@ -1314,9 +1616,12 @@ public class RelayNetworkStatusConsensusImplTest {
new int[] { 0, consensusBytes.length }, true);
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testUnrecognizedHeaderLineFail()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage(
+ "Unrecognized line 'unrecognized-line 1' in consensus.");
String unrecognizedLine = "unrecognized-line 1";
ConsensusBuilder.createWithUnrecognizedHeaderLine(unrecognizedLine,
true);
@@ -1333,9 +1638,12 @@ public class RelayNetworkStatusConsensusImplTest {
assertEquals(unrecognizedLines, consensus.getUnrecognizedLines());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testUnrecognizedDirSourceLineFail()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage(
+ "Unrecognized line 'unrecognized-line 1' in dir-source entry.");
String unrecognizedLine = "unrecognized-line 1";
ConsensusBuilder.createWithUnrecognizedDirSourceLine(unrecognizedLine,
true);
@@ -1352,9 +1660,12 @@ public class RelayNetworkStatusConsensusImplTest {
assertEquals(unrecognizedLines, consensus.getUnrecognizedLines());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testUnrecognizedStatusEntryLineFail()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Unrecognized line 'unrecognized-line 1' in "
+ + "status entry.");
String unrecognizedLine = "unrecognized-line 1";
ConsensusBuilder.createWithUnrecognizedStatusEntryLine(
unrecognizedLine, true);
@@ -1371,9 +1682,12 @@ public class RelayNetworkStatusConsensusImplTest {
assertEquals(unrecognizedLines, consensus.getUnrecognizedLines());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testUnrecognizedDirectoryFooterLineFail()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage(
+ "Unrecognized line 'unrecognized-line 1' in consensus.");
String unrecognizedLine = "unrecognized-line 1";
ConsensusBuilder.createWithUnrecognizedFooterLine(unrecognizedLine,
true);
@@ -1390,9 +1704,12 @@ public class RelayNetworkStatusConsensusImplTest {
assertEquals(unrecognizedLines, consensus.getUnrecognizedLines());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testUnrecognizedDirectorySignatureLineFail()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage(
+ "Unrecognized line 'unrecognized-line 1' in dir-source entry.");
String unrecognizedLine = "unrecognized-line 1";
ConsensusBuilder.createWithUnrecognizedDirectorySignatureLine(
unrecognizedLine, true);
diff --git a/src/test/java/org/torproject/descriptor/impl/RelayNetworkStatusImplTest.java b/src/test/java/org/torproject/descriptor/impl/RelayNetworkStatusImplTest.java
index d0ff7fb..efca978 100644
--- a/src/test/java/org/torproject/descriptor/impl/RelayNetworkStatusImplTest.java
+++ b/src/test/java/org/torproject/descriptor/impl/RelayNetworkStatusImplTest.java
@@ -7,10 +7,15 @@ import static org.junit.Assert.assertEquals;
import org.torproject.descriptor.DescriptorParseException;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
public class RelayNetworkStatusImplTest {
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
private static final String validAnnotation = "@type network-status-2 1.0\n";
private static final String validHeader = "network-status-version 2\n"
@@ -36,8 +41,10 @@ public class RelayNetworkStatusImplTest {
private static final String validStatus =
validAnnotation + validHeader + validFooter;
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testParseBrokenHeader() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Unrecognized line 'xyx' in v2 network status.");
String invalidHeader = "network-status-version 2\nxyx\nabc";
byte[] statusBytes = (validAnnotation + invalidHeader + validFooter)
.getBytes();
diff --git a/src/test/java/org/torproject/descriptor/impl/RelayNetworkStatusVoteImplTest.java b/src/test/java/org/torproject/descriptor/impl/RelayNetworkStatusVoteImplTest.java
index aa7ff4a..1997c46 100644
--- a/src/test/java/org/torproject/descriptor/impl/RelayNetworkStatusVoteImplTest.java
+++ b/src/test/java/org/torproject/descriptor/impl/RelayNetworkStatusVoteImplTest.java
@@ -11,7 +11,9 @@ import org.torproject.descriptor.DescriptorParseException;
import org.torproject.descriptor.DirectorySignature;
import org.torproject.descriptor.RelayNetworkStatusVote;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
import java.util.ArrayList;
import java.util.Arrays;
@@ -26,6 +28,9 @@ import java.util.TreeSet;
* in the directory header. */
public class RelayNetworkStatusVoteImplTest {
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
/* Helper class to build a vote based on default data and modifications
* requested by test methods. */
private static class VoteBuilder {
@@ -745,22 +750,29 @@ public class RelayNetworkStatusVoteImplTest {
assertTrue(vote.getUnrecognizedLines().isEmpty());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testNetworkStatusVersionNoLine()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'network-status-version' must be "
+ + "contained in the first line.");
VoteBuilder.createWithNetworkStatusVersionLine(null);
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testNetworkStatusVersionNewLine()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Blank lines are not allowed.");
VoteBuilder.createWithNetworkStatusVersionLine(
"network-status-version 3\n");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testNetworkStatusVersionNewLineSpace()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal keyword in line ' '.");
VoteBuilder.createWithNetworkStatusVersionLine(
"network-status-version 3\n ");
}
@@ -772,72 +784,102 @@ public class RelayNetworkStatusVoteImplTest {
"@vote\nnetwork-status-version 3");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testNetworkStatusVersionPrefixLine()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Unrecognized line 'directory-footer' in vote.");
VoteBuilder.createWithNetworkStatusVersionLine(
"directory-footer\nnetwork-status-version 3");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testNetworkStatusVersionPrefixLinePoundChar()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Unrecognized line '#vote' in vote.");
VoteBuilder.createWithNetworkStatusVersionLine(
"#vote\nnetwork-status-version 3");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testNetworkStatusVersionNoSpace()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal network status version number "
+ + "in line 'network-status-version'.");
VoteBuilder.createWithNetworkStatusVersionLine(
"network-status-version");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testNetworkStatusVersionOneSpace()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal network status version number in "
+ + "line 'network-status-version '.");
VoteBuilder.createWithNetworkStatusVersionLine(
"network-status-version ");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testNetworkStatusVersion42()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal network status version number in line "
+ + "'network-status-version 42'.");
VoteBuilder.createWithNetworkStatusVersionLine(
"network-status-version 42");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testNetworkStatusVersionFourtyTwo()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal network status version number in line "
+ + "'network-status-version FourtyTwo'.");
VoteBuilder.createWithNetworkStatusVersionLine(
"network-status-version FourtyTwo");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testVoteStatusNoLine() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'vote-status' is contained 0 times, "
+ + "but must be contained exactly once.");
VoteBuilder.createWithVoteStatusLine(null);
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testNetworkStatusVersionSpaceBefore()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage(
+ "Illegal keyword in line ' network-status-version 3'.");
VoteBuilder.createWithNetworkStatusVersionLine(
" network-status-version 3");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testVoteStatusSpaceBefore() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal keyword in line ' vote-status vote'.");
VoteBuilder.createWithVoteStatusLine(" vote-status vote");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testVoteStatusNoSpace() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown
+ .expectMessage("Line 'vote-status' indicates that this is not a vote.");
VoteBuilder.createWithVoteStatusLine("vote-status");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testVoteStatusOneSpace() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage(
+ "Line 'vote-status ' indicates that this is not a vote.");
VoteBuilder.createWithVoteStatusLine("vote-status ");
}
@@ -847,14 +889,20 @@ public class RelayNetworkStatusVoteImplTest {
VoteBuilder.createWithVoteStatusLine("vote-status vote ");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testVoteStatusConsensus() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Line 'vote-status consensus' indicates that "
+ + "this is not a vote.");
VoteBuilder.createWithVoteStatusLine("vote-status consensus");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testVoteStatusTheMagicVoteStatus()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Line 'vote-status TheMagicVoteStatus' "
+ + "indicates that this is not a vote.");
VoteBuilder.createWithVoteStatusLine(
"vote-status TheMagicVoteStatus");
}
@@ -867,140 +915,208 @@ public class RelayNetworkStatusVoteImplTest {
assertNull(vote.getConsensusMethods());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testConsensusMethodNoSpace()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal line 'consensus-methods' in vote.");
VoteBuilder.createWithConsensusMethodsLine("consensus-methods");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testConsensusMethodOneSpace()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal line 'consensus-methods ' in vote.");
VoteBuilder.createWithConsensusMethodsLine("consensus-methods ");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testConsensusMethodEleven()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal consensus method number in line "
+ + "'consensus-methods eleven'.");
VoteBuilder.createWithConsensusMethodsLine(
"consensus-methods eleven");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testConsensusMethodMinusOne()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal consensus method number in line "
+ + "'consensus-methods -1'.");
VoteBuilder.createWithConsensusMethodsLine("consensus-methods -1");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testConsensusMethodNinePeriod()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal consensus method number in line "
+ + "'consensus-methods 99999999999999999999999999999999999999999"
+ + "9999999999999999999'.");
VoteBuilder.createWithConsensusMethodsLine("consensus-methods "
+ "999999999999999999999999999999999999999999999999999999999999");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testConsensusMethodTwoLines()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage(
+ "Unrecognized line 'consensus-method 1' in vote.");
VoteBuilder.createWithConsensusMethodsLine(
"consensus-method 1\nconsensus-method 1");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testPublishedNoLine() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'published' is contained 0 times, "
+ + "but must be contained exactly once.");
VoteBuilder.createWithPublishedLine(null);
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testValidAfterNoLine() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'valid-after' is contained 0 times, "
+ + "but must be contained exactly once.");
VoteBuilder.createWithValidAfterLine(null);
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testValidAfterNoSpace() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Line 'valid-after' does not contain a "
+ + "timestamp at the expected position.");
VoteBuilder.createWithValidAfterLine("valid-after");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testValidAfterOneSpace() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Line 'valid-after ' does not contain a "
+ + "timestamp at the expected position.");
VoteBuilder.createWithValidAfterLine("valid-after ");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testValidAfterLongAgo() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal timestamp format in line 'valid-after "
+ + "long ago'.");
VoteBuilder.createWithValidAfterLine("valid-after long ago");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testValidAfterFeb30() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal timestamp format in line "
+ + "'valid-after 2011-02-30 09:00:00'.");
VoteBuilder.createWithValidAfterLine(
"valid-after 2011-02-30 09:00:00");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testFreshUntilNoLine() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'fresh-until' is contained 0 times, "
+ + "but must be contained exactly once.");
VoteBuilder.createWithFreshUntilLine(null);
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testFreshUntilAroundTen() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal timestamp format in line "
+ + "'fresh-until 2011-11-30 around ten'.");
VoteBuilder.createWithFreshUntilLine(
"fresh-until 2011-11-30 around ten");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testValidUntilTomorrowMorning()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal timestamp format in line 'valid-until "
+ + "tomorrow morning'.");
VoteBuilder.createWithValidUntilLine(
"valid-until tomorrow morning");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testVotingDelayNoLine() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'voting-delay' is contained 0 times, "
+ + "but must be contained exactly once.");
VoteBuilder.createWithVotingDelayLine(null);
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testVotingDelayNoSpace() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Wrong number of values in line 'voting-delay'.");
VoteBuilder.createWithVotingDelayLine("voting-delay");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testVotingDelayOneSpace() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown
+ .expectMessage("Wrong number of values in line 'voting-delay '.");
VoteBuilder.createWithVotingDelayLine("voting-delay ");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testVotingDelayTriple() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage(
+ "Wrong number of values in line 'voting-delay 300 300 300'.");
VoteBuilder.createWithVotingDelayLine(
"voting-delay 300 300 300");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testVotingDelaySingle() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage(
+ "Wrong number of values in line 'voting-delay 300'.");
VoteBuilder.createWithVotingDelayLine("voting-delay 300");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testVotingDelayOneTwo() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal values in line 'voting-delay one two'.");
VoteBuilder.createWithVotingDelayLine("voting-delay one two");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testClientVersionsComma() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal versions line 'client-versions ,'.");
VoteBuilder.createWithClientVersionsLine("client-versions ,");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testClientVersionsCommaVersion()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage(
+ "Illegal versions line 'client-versions ,0.2.2.34'.");
VoteBuilder.createWithClientVersionsLine(
"client-versions ,0.2.2.34");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testRecommendedClientProtocols21()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage(
+ "Invalid line 'recommended-client-protocols Cons=2-1'.");
VoteBuilder.createWithRecommendedClientProtocolsLine(
"recommended-client-protocols Cons=2-1");
}
@@ -1015,16 +1131,22 @@ public class RelayNetworkStatusVoteImplTest {
vote.getRecommendedRelayProtocols().get("Cons"));
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testRequiredClientProtocols1Max()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage(
+ "Invalid line 'recommended-client-protocols Cons=1-4294967296'.");
VoteBuilder.createWithRequiredClientProtocolsLine(
"recommended-client-protocols Cons=1-4294967296");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testRequiredRelayProtocolsMinus1()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown
+ .expectMessage("Invalid line 'recommended-client-protocols Cons=-1'.");
VoteBuilder.createWithRequiredRelayProtocolsLine(
"recommended-client-protocols Cons=-1");
}
@@ -1059,24 +1181,34 @@ public class RelayNetworkStatusVoteImplTest {
}
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testPackageIncomplete() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Wrong number of values in line "
+ + "'package shouldbesecond 0 http'.");
String packageLine = "package shouldbesecond 0 http";
ConsensusBuilder.createWithPackageLines(packageLine);
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testKnownFlagsNoLine() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'known-flags' is contained 0 times, "
+ + "but must be contained exactly once.");
VoteBuilder.createWithKnownFlagsLine(null);
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testKnownFlagsNoSpace() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("No known flags in line 'known-flags'.");
VoteBuilder.createWithKnownFlagsLine("known-flags");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testKnownFlagsOneSpace() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("No known flags in line 'known-flags '.");
VoteBuilder.createWithKnownFlagsLine("known-flags ");
}
@@ -1126,45 +1258,63 @@ public class RelayNetworkStatusVoteImplTest {
assertEquals(0, vote.getEnoughMtbfInfo());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testFlagThresholdsNoSpace()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("No flag thresholds in line 'flag-thresholds'.");
VoteBuilder.createWithFlagThresholdsLine("flag-thresholds");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testFlagThresholdsOneSpace()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("No flag thresholds in line 'flag-thresholds '.");
VoteBuilder.createWithFlagThresholdsLine("flag-thresholds ");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testFlagThresholdDuplicate()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'flag-thresholds' is contained 2 "
+ + "times, but must be contained at most once.");
VoteBuilder vb = new VoteBuilder();
vb.flagThresholdsLine = vb.flagThresholdsLine + "\n"
+ vb.flagThresholdsLine;
vb.buildVote(true);
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testNicknameMissing() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal line 'dir-source 80550987E1D626E3EBA5E"
+ + "5E75A458DE0626D088C 208.83.223.34 208.83.223.34 443 80' in vote.");
VoteBuilder.createWithDirSourceLine("dir-source "
+ "80550987E1D626E3EBA5E5E75A458DE0626D088C 208.83.223.34 "
+ "208.83.223.34 443 80");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testNicknameTooLong() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal nickname in line 'dir-source "
+ + "urrassssssssssssssssssssssssssssssssssssssssssssssss 80550987E1D626"
+ + "E3EBA5E5E75A458DE0626D088C 208.83.223.34 208.83.223.34 443 80'.");
VoteBuilder.createWithDirSourceLine("dir-source "
+ "urrassssssssssssssssssssssssssssssssssssssssssssssss "
+ "80550987E1D626E3EBA5E5E75A458DE0626D088C 208.83.223.34 "
+ "208.83.223.34 443 80");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testNicknameIllegalCharacters()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal nickname in line 'dir-source urra$ "
+ + "80550987E1D626E3EBA5E5E75A458DE0626D088C 208.83.223.34 "
+ + "208.83.223.34 443 80'.");
VoteBuilder.createWithDirSourceLine("dir-source urra$ "
+ "80550987E1D626E3EBA5E5E75A458DE0626D088C 208.83.223.34 "
+ "208.83.223.34 443 80");
@@ -1177,31 +1327,46 @@ public class RelayNetworkStatusVoteImplTest {
+ "208.83.223.34 443 80");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testFingerprintTooShort() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal hex string in line 'dir-source urras "
+ + "80550987E1D626E3EBA5E5E75A458DE0626D 208.83.223.34 208.83.223.34 "
+ + "443 80'.");
VoteBuilder.createWithDirSourceLine("dir-source urras "
+ "80550987E1D626E3EBA5E5E75A458DE0626D 208.83.223.34 "
+ "208.83.223.34 443 80");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testFingerprintTooLong() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal hex string in line 'dir-source urras "
+ + "80550987E1D626E3EBA5E5E75A458DE0626D088C8055 208.83.223.34 "
+ + "208.83.223.34 443 80'.");
VoteBuilder.createWithDirSourceLine("dir-source urras "
+ "80550987E1D626E3EBA5E5E75A458DE0626D088C8055 208.83.223.34 "
+ "208.83.223.34 443 80");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testFingerprintIllegalCharacters()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal hex string in line 'dir-source urras "
+ + "ABCDEFGHIJKLM6E3EBA5E5E75A458DE0626D088C 208.83.223.34 208.83.223.34"
+ + " 443 80'.");
VoteBuilder.createWithDirSourceLine("dir-source urras "
+ "ABCDEFGHIJKLM6E3EBA5E5E75A458DE0626D088C 208.83.223.34 "
+ "208.83.223.34 443 80");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testFingerprintMissing()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal line 'dir-source urras "
+ + "208.83.223.34 208.83.223.34 443 80' in vote.");
VoteBuilder.createWithDirSourceLine("dir-source urras "
+ " 208.83.223.34 208.83.223.34 443 80");
}
@@ -1217,41 +1382,61 @@ public class RelayNetworkStatusVoteImplTest {
assertEquals("256.256.256.256", vote.getHostname());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testHostnameMissing()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal line 'dir-source urras "
+ + "80550987E1D626E3EBA5E5E75A458DE0626D088C 208.83.223.34 443 80' "
+ + "in vote.");
VoteBuilder.createWithDirSourceLine("dir-source urras "
+ "80550987E1D626E3EBA5E5E75A458DE0626D088C 208.83.223.34 443 "
+ "80");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testAddress256()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("'256.256.256.256' in line 'dir-source urras "
+ + "80550987E1D626E3EBA5E5E75A458DE0626D088C 208.83.223.34 256.256.256."
+ + "256 443 80' is not a valid IPv4 address.");
VoteBuilder.createWithDirSourceLine("dir-source urras "
+ "80550987E1D626E3EBA5E5E75A458DE0626D088C 208.83.223.34 "
+ "256.256.256.256 443 80");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testAddressMissing()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal line 'dir-source urras "
+ + "80550987E1D626E3EBA5E5E75A458DE0626D088C 208.83.223.34 "
+ + "443 80' in vote.");
VoteBuilder.createWithDirSourceLine("dir-source urras "
+ "80550987E1D626E3EBA5E5E75A458DE0626D088C 208.83.223.34 443 "
+ "80");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testDirPortMinus443()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("'-443' in line 'dir-source urras "
+ + "80550987E1D626E3EBA5E5E75A458DE0626D088C 208.83.223.34 "
+ + "208.83.223.34 -443 80' is not a valid port number.");
VoteBuilder.createWithDirSourceLine("dir-source urras "
+ "80550987E1D626E3EBA5E5E75A458DE0626D088C 208.83.223.34 "
+ "208.83.223.34 -443 80");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testDirPortFourFourThree()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("'four-four-three' in line 'dir-source urras "
+ + "80550987E1D626E3EBA5E5E75A458DE0626D088C 208.83.223.34 208.83.223.34"
+ + " four-four-three 80' is not a valid port number.");
VoteBuilder.createWithDirSourceLine("dir-source urras "
+ "80550987E1D626E3EBA5E5E75A458DE0626D088C 208.83.223.34 "
+ "208.83.223.34 four-four-three 80");
@@ -1266,8 +1451,11 @@ public class RelayNetworkStatusVoteImplTest {
+ "208.83.223.34 0 80");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testOrPortMissing() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal line 'dir-source urras 80550987E1D626E3E"
+ + "BA5E5E75A458DE0626D088C 208.83.223.34 208.83.223.34 443 ' in vote.");
VoteBuilder.createWithDirSourceLine("dir-source urras "
+ "80550987E1D626E3EBA5E5E75A458DE0626D088C 208.83.223.34 "
+ "208.83.223.34 443 ");
@@ -1283,15 +1471,21 @@ public class RelayNetworkStatusVoteImplTest {
+ "208.83.223.34 80 80");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testDirSourceLineMissing()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'dir-source' is contained 0 times, "
+ + "but must be contained exactly once.");
VoteBuilder.createWithDirSourceLine(null);
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testDirSourceLineDuplicate()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'dir-source' is contained 2 times, "
+ + "but must be contained exactly once.");
VoteBuilder.createWithDirSourceLine("dir-source urras "
+ "80550987E1D626E3EBA5E5E75A458DE0626D088C 208.83.223.34 "
+ "208.83.223.34 443 80\ndir-source urras "
@@ -1305,24 +1499,33 @@ public class RelayNetworkStatusVoteImplTest {
VoteBuilder.createWithContactLine(null);
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testContactLineDuplicate()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'contact' is contained 2 times, "
+ + "but must be contained at most once.");
VoteBuilder.createWithContactLine("contact 4096R/E012B42D Jacob "
+ "Appelbaum <jacob(a)appelbaum.net>\ncontact 4096R/E012B42D Jacob "
+ "Appelbaum <jacob(a)appelbaum.net>");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testSharedRandParticipateLineDuplicate()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'shared-rand-participate' is contained "
+ + "2 times, but must be contained at most once.");
VoteBuilder.createWithSharedRandParticipateLine("shared-rand-participate\n"
+ "shared-rand-participate");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testSharedRandParticipateLineArg()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown
+ .expectMessage("Illegal line 'shared-rand-participate 1' in vote.");
VoteBuilder.createWithSharedRandParticipateLine(
"shared-rand-participate 1");
}
@@ -1334,17 +1537,23 @@ public class RelayNetworkStatusVoteImplTest {
assertNull(vote.getSharedRandCommitLines());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testSharedRandPreviousValueBeforeNumReveals()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal line 'shared-rand-previous-value "
+ + "grwbnD6I40odtsdtWYxqs0DvPweCur6qG2Fo5p5ivS4= 8' in vote.");
VoteBuilder.createWithSharedRandPreviousValueLine(
"shared-rand-previous-value "
+ "grwbnD6I40odtsdtWYxqs0DvPweCur6qG2Fo5p5ivS4= 8");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testSharedRandCurrentNoNumReveals()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal line 'shared-rand-current-value "
+ + "D88plxd8YeLfCIVAR9gjiFlWB1WqpC53kWr350o1pzw=' in vote.");
VoteBuilder.createWithSharedRandCurrentValueLine(
"shared-rand-current-value "
+ "D88plxd8YeLfCIVAR9gjiFlWB1WqpC53kWr350o1pzw=");
@@ -1358,102 +1567,146 @@ public class RelayNetworkStatusVoteImplTest {
vote.getLegacyDirKey());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testLegacyDirKeyLineNoId() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal line 'legacy-dir-key '.");
VoteBuilder.createWithLegacyDirKeyLine("legacy-dir-key ");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testDirKeyCertificateVersionLineMissing()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'dir-key-certificate-version' is "
+ + "contained 0 times, but must be contained exactly once.");
VoteBuilder.createWithDirKeyCertificateVersionLine(null);
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testDirKeyCertificateVersionLineDuplicate()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'dir-key-certificate-version' is "
+ + "contained 2 times, but must be contained exactly once.");
VoteBuilder.createWithDirKeyCertificateVersionLine(
"dir-key-certificate-version 3\ndir-key-certificate-version 3");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testFingerprintLineMissing()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'fingerprint' is contained 0 times, "
+ + "but must be contained exactly once.");
VoteBuilder.createWithFingerprintLine(null);
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testFingerprintLineDuplicate()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'fingerprint' is contained 2 times, "
+ + "but must be contained exactly once.");
VoteBuilder.createWithFingerprintLine("fingerprint "
+ "80550987E1D626E3EBA5E5E75A458DE0626D088C\nfingerprint "
+ "80550987E1D626E3EBA5E5E75A458DE0626D088C");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testFingerprintLineTooLong()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal hex string in line 'fingerprint "
+ + "80550987E1D626E3EBA5E5E75A458DE0626D088C8055'.");
VoteBuilder.createWithFingerprintLine("fingerprint "
+ "80550987E1D626E3EBA5E5E75A458DE0626D088C8055");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testFingerprintLineTooShort()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal hex string in line 'fingerprint "
+ + "80550987E1D626E3EBA5E5E75A458DE0626D'.");
VoteBuilder.createWithFingerprintLine("fingerprint "
+ "80550987E1D626E3EBA5E5E75A458DE0626D");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testDirKeyPublished3011()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal timestamp format in line "
+ + "'dir-key-published 3011-04-27 05:34:37'.");
VoteBuilder.createWithDirKeyPublishedLine("dir-key-published "
+ "3011-04-27 05:34:37");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testDirKeyPublishedRecentlyAtNoon()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal timestamp format in line "
+ + "'dir-key-published recently 12:00:00'.");
VoteBuilder.createWithDirKeyPublishedLine("dir-key-published "
+ "recently 12:00:00");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testDirKeyPublishedRecentlyNoTime()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Line 'dir-key-published recently' does not "
+ + "contain a timestamp at the expected position.");
VoteBuilder.createWithDirKeyPublishedLine("dir-key-published "
+ "recently");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testDirKeyExpiresSoonAtNoon()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage(
+ "Illegal timestamp format in line 'dir-key-expires soon 12:00:00'.");
VoteBuilder.createWithDirKeyExpiresLine("dir-key-expires "
+ "soon 12:00:00");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testDirKeyExpiresLineMissing()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'dir-key-expires' is contained 0 times,"
+ + " but must be contained exactly once.");
VoteBuilder.createWithDirKeyExpiresLine(null);
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testDirKeyExpiresLineDuplicate()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'dir-key-expires' is contained 2 times, "
+ + "but must be contained exactly once.");
VoteBuilder.createWithDirKeyExpiresLine("dir-key-expires 2012-04-27 "
+ "05:34:37\ndir-key-expires 2012-04-27 05:34:37");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testDirIdentityKeyLinesMissing()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'dir-identity-key' is contained 0 times,"
+ + " but must be contained exactly once.");
VoteBuilder.createWithDirIdentityKeyLines(null);
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testDirSigningKeyLinesMissing()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'dir-signing-key' is contained 0"
+ + " times, but must be contained exactly once.");
VoteBuilder.createWithDirSigningKeyLines(null);
}
@@ -1463,9 +1716,12 @@ public class RelayNetworkStatusVoteImplTest {
VoteBuilder.createWithDirKeyCrosscertLines(null);
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testDirKeyCertificationLinesMissing()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'dir-key-certification' is contained "
+ + "0 times, but must be contained exactly once.");
VoteBuilder.createWithDirKeyCertificationLines(null);
}
@@ -1475,9 +1731,12 @@ public class RelayNetworkStatusVoteImplTest {
VoteBuilder.createWithDirectoryFooterLine(null);
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testDirectorySignaturesLinesMissing()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'directory-signature' is contained 0 "
+ + "times, but must be contained at least once.");
VoteBuilder.createWithDirectorySignatureLines(null);
}
@@ -1538,9 +1797,12 @@ public class RelayNetworkStatusVoteImplTest {
assertEquals(2, vote.getSignatures().size());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testUnrecognizedHeaderLineFail()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage(
+ "Unrecognized line 'unrecognized-line 1' in vote.");
String unrecognizedLine = "unrecognized-line 1";
VoteBuilder.createWithUnrecognizedHeaderLine(unrecognizedLine, true);
}
@@ -1556,9 +1818,12 @@ public class RelayNetworkStatusVoteImplTest {
assertEquals(unrecognizedLines, vote.getUnrecognizedLines());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testUnrecognizedDirSourceLineFail()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage(
+ "Unrecognized line 'unrecognized-line 1' in vote.");
String unrecognizedLine = "unrecognized-line 1";
VoteBuilder.createWithUnrecognizedDirSourceLine(unrecognizedLine,
true);
@@ -1575,9 +1840,12 @@ public class RelayNetworkStatusVoteImplTest {
assertEquals(unrecognizedLines, vote.getUnrecognizedLines());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testUnrecognizedFooterLineFail()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown
+ .expectMessage("Unrecognized line 'unrecognized-line 1' in vote.");
String unrecognizedLine = "unrecognized-line 1";
VoteBuilder.createWithUnrecognizedFooterLine(unrecognizedLine, true);
}
@@ -1624,9 +1892,11 @@ public class RelayNetworkStatusVoteImplTest {
vote.getStatusEntry(fingerprint).getMasterKeyEd25519());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testIdRsa1024None()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal line 'id rsa1024 none'.");
List<String> statusEntries = new ArrayList<>();
statusEntries.add("r MathematicalApology AAPJIrV9nhfgTYQs0vsTghFaP2A "
+ "uA7p0m68O8ILXsf3aLZUj0EvDNE 2015-12-01 18:01:49 172.99.69.177 "
diff --git a/src/test/java/org/torproject/descriptor/impl/ServerDescriptorImplTest.java b/src/test/java/org/torproject/descriptor/impl/ServerDescriptorImplTest.java
index 7a765d4..70a25a0 100644
--- a/src/test/java/org/torproject/descriptor/impl/ServerDescriptorImplTest.java
+++ b/src/test/java/org/torproject/descriptor/impl/ServerDescriptorImplTest.java
@@ -14,7 +14,9 @@ import org.torproject.descriptor.BridgeServerDescriptor;
import org.torproject.descriptor.DescriptorParseException;
import org.torproject.descriptor.ServerDescriptor;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -27,6 +29,9 @@ import java.util.TreeSet;
/* Test parsing of relay server descriptors. */
public class ServerDescriptorImplTest {
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
/* Helper class to build a descriptor based on default data and
* modifications requested by test methods. */
private static class DescriptorBuilder {
@@ -500,8 +505,11 @@ public class ServerDescriptorImplTest {
descriptor.getDigestSha256Base64());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testRouterLineMissing() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'router' is contained 0 times, but "
+ + "must be contained exactly once.");
DescriptorBuilder.createWithRouterLine(null);
}
@@ -517,27 +525,39 @@ public class ServerDescriptorImplTest {
assertEquals(0, (int) descriptor.getDirPort());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testRouterLinePrecedingHibernatingLine()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'router' must be contained in "
+ + "the first line.");
DescriptorBuilder.createWithRouterLine("hibernating 1\nrouter "
+ "saberrider2008 94.134.192.243 9001 0 0");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testNicknameMissing() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal line 'router 94.134.192.243 9001 0 0' "
+ + "in server descriptor.");
DescriptorBuilder.createWithRouterLine("router 94.134.192.243 9001 "
+ "0 0");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testNicknameInvalidChar() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal nickname in line "
+ + "'router $aberrider2008 94.134.192.243 9001 0 0'.");
DescriptorBuilder.createWithRouterLine("router $aberrider2008 "
+ "94.134.192.243 9001 0 0");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testNicknameTooLong() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal nickname in line 'router "
+ + "saberrider2008ReallyLongNickname 94.134.192.243 9001 0 0'.");
DescriptorBuilder.createWithRouterLine("router "
+ "saberrider2008ReallyLongNickname 94.134.192.243 9001 0 0");
}
@@ -551,50 +571,74 @@ public class ServerDescriptorImplTest {
assertEquals("94.134.192.243", descriptor.getAddress());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testAddress24() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("'94.134.192/24' in line 'router saberrider2008 "
+ + "94.134.192/24 9001 0 0' is not a valid IPv4 address.");
DescriptorBuilder.createWithRouterLine("router saberrider2008 "
+ "94.134.192/24 9001 0 0");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testAddress294() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("'294.134.192.243' in line 'router "
+ + "saberrider2008 294.134.192.243 9001 0 0' is not a valid "
+ + "IPv4 address.");
DescriptorBuilder.createWithRouterLine("router saberrider2008 "
+ "294.134.192.243 9001 0 0");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testAddressMissing() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage(
+ "Illegal line 'router saberrider2008 9001 0 0' in server descriptor.");
DescriptorBuilder.createWithRouterLine("router saberrider2008 9001 "
+ "0 0");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testOrPort99001() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("'99001' in line 'router saberrider2008 "
+ + "94.134.192.243 99001 0 0' is not a valid port number.");
DescriptorBuilder.createWithRouterLine("router saberrider2008 "
+ "94.134.192.243 99001 0 0");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testOrPortMissing() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal line 'router saberrider2008 "
+ + "94.134.192.243 0 0' in server descriptor.");
DescriptorBuilder.createWithRouterLine("router saberrider2008 "
+ "94.134.192.243 0 0");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testOrPortOne() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("'one' in line 'router saberrider2008 "
+ + "94.134.192.243 one 0 0' is not a valid port number.");
DescriptorBuilder.createWithRouterLine("router saberrider2008 "
+ "94.134.192.243 one 0 0");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testOrPortNewline() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal keyword in line ' 0 0'.");
DescriptorBuilder.createWithRouterLine("router saberrider2008 "
+ "94.134.192.243 0\n 0 0");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testDirPortMissing() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal line 'router saberrider2008 "
+ + "94.134.192.243 9001 0 ' in server descriptor.");
DescriptorBuilder.createWithRouterLine("router saberrider2008 "
+ "94.134.192.243 9001 0 ");
}
@@ -649,15 +693,20 @@ public class ServerDescriptorImplTest {
descriptor.getCircuitProtocolVersions());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testProtocolsAb() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown
+ .expectMessage("Illegal line 'opt protocols Link A B Circuit 1'.");
DescriptorBuilder.createWithProtocolsLine("opt protocols Link A B "
+ "Circuit 1");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testProtocolsNoCircuitVersions()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal line 'opt protocols Link 1 2'.");
DescriptorBuilder.createWithProtocolsLine("opt protocols Link 1 2");
}
@@ -671,13 +720,18 @@ public class ServerDescriptorImplTest {
descriptor.getProtocols().get("Purple"));
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testProtoInvalid() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Invalid line 'proto Invalid=1+2+3'.");
DescriptorBuilder.createWithProtoLine("proto Invalid=1+2+3");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testPublishedMissing() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'published' is contained 0 times, "
+ + "but must be contained exactly once.");
DescriptorBuilder.createWithPublishedLine(null);
}
@@ -688,26 +742,38 @@ public class ServerDescriptorImplTest {
assertEquals(1325390599000L, descriptor.getPublishedMillis());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testPublished2039() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage(
+ "Illegal timestamp format in line 'published 2039-01-01 04:03:19'.");
DescriptorBuilder.createWithPublishedLine("published 2039-01-01 "
+ "04:03:19");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testPublished1912() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal timestamp format in line "
+ + "'published 1912-01-01 04:03:19'.");
DescriptorBuilder.createWithPublishedLine("published 1912-01-01 "
+ "04:03:19");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testPublishedFeb31() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal timestamp format in line "
+ + "'published 2012-02-31 04:03:19'.");
DescriptorBuilder.createWithPublishedLine("published 2012-02-31 "
+ "04:03:19");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testPublishedNoTime() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Line 'published 2012-01-01' does not contain "
+ + "a timestamp at the expected position.");
DescriptorBuilder.createWithPublishedLine("published 2012-01-01");
}
@@ -727,26 +793,38 @@ public class ServerDescriptorImplTest {
descriptor.getFingerprint());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testFingerprintG() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal hex string in line 'opt fingerprint "
+ + "G873 3048 FC8E C910 2466 AD8F 3098 622B F1BF 71FD'.");
DescriptorBuilder.createWithFingerprintLine("opt fingerprint G873 "
+ "3048 FC8E C910 2466 AD8F 3098 622B F1BF 71FD");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testFingerprintTooShort() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal line 'opt fingerprint D873 3048 FC8E "
+ + "C910 2466 AD8F 3098 622B F1BF'.");
DescriptorBuilder.createWithFingerprintLine("opt fingerprint D873 "
+ "3048 FC8E C910 2466 AD8F 3098 622B F1BF");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testFingerprintTooLong() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal line 'opt fingerprint D873 3048 "
+ + "FC8E C910 2466 AD8F 3098 622B F1BF 71FD D873'.");
DescriptorBuilder.createWithFingerprintLine("opt fingerprint D873 "
+ "3048 FC8E C910 2466 AD8F 3098 622B F1BF 71FD D873");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testFingerprintNoSpaces() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal line 'opt fingerprint "
+ + "D8733048FC8EC9102466AD8F3098622BF1BF71FD'.");
DescriptorBuilder.createWithFingerprintLine("opt fingerprint "
+ "D8733048FC8EC9102466AD8F3098622BF1BF71FD");
}
@@ -765,8 +843,10 @@ public class ServerDescriptorImplTest {
assertEquals(48, descriptor.getUptime().longValue());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testUptimeFourtyEight() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal value in line 'uptime fourty-eight'.");
DescriptorBuilder.createWithUptimeLine("uptime fourty-eight");
}
@@ -775,18 +855,24 @@ public class ServerDescriptorImplTest {
DescriptorBuilder.createWithUptimeLine("uptime -1");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testUptimeSpace() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Wrong number of values in line 'uptime '.");
DescriptorBuilder.createWithUptimeLine("uptime ");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testUptimeNoSpace() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Wrong number of values in line 'uptime'.");
DescriptorBuilder.createWithUptimeLine("uptime");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testUptimeFourEight() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Wrong number of values in line 'uptime 4 8'.");
DescriptorBuilder.createWithUptimeLine("uptime 4 8");
}
@@ -799,13 +885,19 @@ public class ServerDescriptorImplTest {
assertEquals(53470, (int) descriptor.getBandwidthObserved());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testBandwidthMissing() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'bandwidth' is contained 0 times, "
+ + "but must be contained exactly once.");
DescriptorBuilder.createWithBandwidthLine(null);
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testBandwidthOneValue() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown
+ .expectMessage("Wrong number of values in line 'bandwidth 51200'.");
DescriptorBuilder.createWithBandwidthLine("bandwidth 51200");
}
@@ -821,15 +913,20 @@ public class ServerDescriptorImplTest {
assertEquals(-1, (int) descriptor.getBandwidthObserved());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testBandwidthFourValues() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Wrong number of values in line "
+ + "'bandwidth 51200 51200 53470 53470'.");
DescriptorBuilder.createWithBandwidthLine("bandwidth 51200 51200 "
+ "53470 53470");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testBandwidthMinusOneTwoThree()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal values in line 'bandwidth -1 -2 -3'.");
DescriptorBuilder.createWithBandwidthLine("bandwidth -1 -2 -3");
}
@@ -842,23 +939,31 @@ public class ServerDescriptorImplTest {
descriptor.getExtraInfoDigestSha1Hex());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testExtraInfoDigestNoSpace()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal line 'opt extra-info-digest'.");
DescriptorBuilder.createWithExtraInfoDigestLine("opt "
+ "extra-info-digest");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testExtraInfoDigestTooShort()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal hex string in line 'opt "
+ + "extra-info-digest 1469D1550738A25B1E7B47CDDBCD7B2899F5'.");
DescriptorBuilder.createWithExtraInfoDigestLine("opt "
+ "extra-info-digest 1469D1550738A25B1E7B47CDDBCD7B2899F5");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testExtraInfoDigestTooLong()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal hex string in line 'opt "
+ + "extra-info-digest 1469D1550738A25B1E7B47CDDBCD7B2899F51B741469'.");
DescriptorBuilder.createWithExtraInfoDigestLine("opt "
+ "extra-info-digest "
+ "1469D1550738A25B1E7B47CDDBCD7B2899F51B741469");
@@ -947,8 +1052,11 @@ public class ServerDescriptorImplTest {
assertEquals("Random Person", descriptor.getContact());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testContactDuplicate() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'contact' is contained 2 times, "
+ + "but must be contained at most once.");
DescriptorBuilder.createWithContactLine("contact Random "
+ "Person\ncontact Random Person");
}
@@ -992,8 +1100,11 @@ public class ServerDescriptorImplTest {
descriptor.getExitPolicyLines());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testExitPolicyNoPort() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("'*' in line 'reject *' must contain address "
+ + "and port.");
DescriptorBuilder.createWithExitPolicyLines("reject *");
}
@@ -1006,25 +1117,37 @@ public class ServerDescriptorImplTest {
"reject *:*"}), descriptor.getExitPolicyLines());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testExitPolicyReject321() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("'123.123.123.321' in line 'reject "
+ + "123.123.123.321:80' is not a valid IPv4 address.");
DescriptorBuilder.createWithExitPolicyLines("reject "
+ "123.123.123.321:80");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testExitPolicyRejectPort66666()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("'66666' in line 'reject *:66666' "
+ + "is not a valid port number.");
DescriptorBuilder.createWithExitPolicyLines("reject *:66666");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testExitPolicyProjectAll() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage(
+ "Unrecognized line 'project *:*' in server descriptor.");
DescriptorBuilder.createWithExitPolicyLines("project *:*");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testExitPolicyMissing() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Either keyword 'accept' or 'reject' must be "
+ + "contained at least once.");
DescriptorBuilder.createWithExitPolicyLines(null);
}
@@ -1048,9 +1171,12 @@ public class ServerDescriptorImplTest {
+ "-----END SIGNATURE----");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testRouterSignatureNotLastLine()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'contact' is contained 2 times, "
+ + "but must be contained at most once.");
DescriptorBuilder.createWithRouterSignatureLines("router-signature\n"
+ "-----BEGIN SIGNATURE-----\n"
+ "o4j+kH8UQfjBwepUnr99v0ebN8RpzHJ/lqYsTojXHy9kMr1RNI9IDeSzA7PSqT"
@@ -1080,13 +1206,17 @@ public class ServerDescriptorImplTest {
assertTrue(descriptor.isHibernating());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testHibernatingYep() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal line 'hibernating yep'.");
DescriptorBuilder.createWithHibernatingLine("hibernating yep");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testHibernatingNoSpace() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal line 'hibernating'.");
DescriptorBuilder.createWithHibernatingLine("hibernating");
}
@@ -1116,20 +1246,29 @@ public class ServerDescriptorImplTest {
descriptor.getFamilyEntries());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testFamilyDuplicate() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'family' is contained 2 times, "
+ + "but must be contained at most once.");
DescriptorBuilder.createWithFamilyLine("family "
+ "saberrider2008\nfamily saberrider2008");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testFamilyNicknamePrefix() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage(
+ "Illegal hex string in line 'family $saberrider2008'.");
DescriptorBuilder.createWithFamilyLine("family $saberrider2008");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testFamilyFingerprintNoPrefix()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal nickname in line 'family "
+ + "D8733048FC8EC9102466AD8F3098622BF1BF71FD'.");
DescriptorBuilder.createWithFamilyLine("family "
+ "D8733048FC8EC9102466AD8F3098622BF1BF71FD");
}
@@ -1185,43 +1324,64 @@ public class ServerDescriptorImplTest {
assertNotNull(descriptor.getWriteHistory());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testWriteHistory3012() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal timestamp format in line "
+ + "'write-history 3012-01-01 03:51:44 (900 s) "
+ + "4345856,261120,7591936,1748992'.");
DescriptorBuilder.createWithWriteHistoryLine("write-history "
+ "3012-01-01 03:51:44 (900 s) 4345856,261120,7591936,1748992");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testWriteHistoryNoSeconds()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal timestamp format in line "
+ + "'write-history 2012-01-01 03:51 (900 s) 4345856,261120,"
+ + "7591936,1748992'.");
DescriptorBuilder.createWithWriteHistoryLine("write-history "
+ "2012-01-01 03:51 (900 s) 4345856,261120,7591936,1748992");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testWriteHistoryNoParathenses()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Invalid bandwidth-history line 'write-history "
+ + "2012-01-01 03:51:44 900 s 4345856,261120,7591936,1748992'.");
DescriptorBuilder.createWithWriteHistoryLine("write-history "
+ "2012-01-01 03:51:44 900 s 4345856,261120,7591936,1748992");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testWriteHistoryNoSpaceSeconds()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Invalid bandwidth-history line "
+ + "'write-history 2012-01-01 03:51:44 (900s) "
+ + "4345856,261120,7591936,1748992'.");
DescriptorBuilder.createWithWriteHistoryLine("write-history "
+ "2012-01-01 03:51:44 (900s) 4345856,261120,7591936,1748992");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testWriteHistoryTrailingComma()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Invalid bandwidth-history line 'write-history "
+ + "2012-01-01 03:51:44 (900 s) 4345856,261120,7591936,'.");
DescriptorBuilder.createWithWriteHistoryLine("write-history "
+ "2012-01-01 03:51:44 (900 s) 4345856,261120,7591936,");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testWriteHistoryOneTwoThree()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Invalid bandwidth-history line 'write-history "
+ + "2012-01-01 03:51:44 (900 s) one,two,three'.");
DescriptorBuilder.createWithWriteHistoryLine("write-history "
+ "2012-01-01 03:51:44 (900 s) one,two,three");
}
@@ -1250,8 +1410,11 @@ public class ServerDescriptorImplTest {
.isEmpty());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testWriteHistoryNoS() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Invalid bandwidth-history line "
+ + "'write-history 2012-01-01 03:51:44 (900 '.");
DescriptorBuilder.createWithWriteHistoryLine(
"write-history 2012-01-01 03:51:44 (900 ");
}
@@ -1324,13 +1487,17 @@ public class ServerDescriptorImplTest {
assertFalse(descriptor.getUsesEnhancedDnsLogic());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testEventdnsTrue() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal line 'eventdns true'.");
DescriptorBuilder.createWithEventdnsLine("eventdns true");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testEventdnsNo() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal line 'eventdns no'.");
DescriptorBuilder.createWithEventdnsLine("eventdns no");
}
@@ -1349,8 +1516,10 @@ public class ServerDescriptorImplTest {
assertTrue(descriptor.getCachesExtraInfo());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testCachesExtraInfoTrue() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal line 'caches-extra-info true'.");
DescriptorBuilder.createWithCachesExtraInfoLine("caches-extra-info "
+ "true");
}
@@ -1371,16 +1540,22 @@ public class ServerDescriptorImplTest {
assertTrue(descriptor.getAllowSingleHopExits());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testAllowSingleHopExitsTrue()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal line 'allow-single-hop-exits true'.");
DescriptorBuilder.createWithAllowSingleHopExitsLine(
"allow-single-hop-exits true");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testAllowSingleHopExitsNonAsciiKeyword()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Unrecognized character in keyword "
+ + "'�allow-single-hop-exits' in line "
+ + "'�allow-single-hop-exits'.");
DescriptorBuilder.createWithNonAsciiLineBytes(new byte[] {
0x14, (byte) 0xfe, 0x18, // non-ascii chars
0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x2d, // "allow-"
@@ -1398,32 +1573,43 @@ public class ServerDescriptorImplTest {
assertEquals("80,1194,1220,1293", descriptor.getIpv6PortList());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testIpv6PolicyLineNoPolicy()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal line 'ipv6-policy 80'.");
DescriptorBuilder.createWithIpv6PolicyLine("ipv6-policy 80");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testIpv6PolicyLineNoPorts()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal line 'ipv6-policy accept'.");
DescriptorBuilder.createWithIpv6PolicyLine("ipv6-policy accept");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testIpv6PolicyLineNoPolicyNoPorts()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal line 'ipv6-policy '.");
DescriptorBuilder.createWithIpv6PolicyLine("ipv6-policy ");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testIpv6PolicyLineProject()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal line 'ipv6-policy project 80'.");
DescriptorBuilder.createWithIpv6PolicyLine("ipv6-policy project 80");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testTwoIpv6PolicyLines() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'ipv6-policy' is contained 2 times, "
+ + "but must be contained at most once.");
DescriptorBuilder.createWithIpv6PolicyLine(
"ipv6-policy accept 80,1194,1220,1293\n"
+ "ipv6-policy accept 80,1194,1220,1293");
@@ -1448,22 +1634,30 @@ public class ServerDescriptorImplTest {
descriptor.getNtorOnionKey());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testNtorOnionKeyLineNoKey()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal line 'ntor-onion-key '.");
DescriptorBuilder.createWithNtorOnionKeyLine("ntor-onion-key ");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testNtorOnionKeyLineTwoKeys()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal line 'ntor-onion-key Y/XgaHcPIJVa"
+ + "4D55kir9QLH8rEYAaLXuv3c3sm8jYhY Y/XgaHcPIJVa4D55kir9QLH8rEYAa"
+ + "LXuv3c3sm8jYhY'.");
DescriptorBuilder.createWithNtorOnionKeyLine("ntor-onion-key "
+ "Y/XgaHcPIJVa4D55kir9QLH8rEYAaLXuv3c3sm8jYhY "
+ "Y/XgaHcPIJVa4D55kir9QLH8rEYAaLXuv3c3sm8jYhY");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testTwoNtorOnionKeyLines() throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Blank lines are not allowed.");
DescriptorBuilder.createWithNtorOnionKeyLine("ntor-onion-key "
+ "Y/XgaHcPIJVa4D55kir9QLH8rEYAaLXuv3c3sm8jYhY\nntor-onion-key "
+ "Y/XgaHcPIJVa4D55kir9QLH8rEYAaLXuv3c3sm8jYhY\n");
@@ -1485,31 +1679,42 @@ public class ServerDescriptorImplTest {
assertFalse(descriptor.getTunnelledDirServer());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testTunnelledDirServerTypo()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Unrecognized line 'tunneled-dir-server' "
+ + "in server descriptor.");
DescriptorBuilder.createWithTunnelledDirServerLine(
"tunneled-dir-server");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testTunnelledDirServerTwice()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'tunnelled-dir-server' is contained "
+ + "2 times, but must be contained at most once.");
DescriptorBuilder.createWithTunnelledDirServerLine(
"tunnelled-dir-server\ntunnelled-dir-server");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testTunnelledDirServerArgs()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Illegal line 'tunnelled-dir-server 1'.");
DescriptorBuilder.createWithTunnelledDirServerLine(
"tunnelled-dir-server 1");
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testUnrecognizedLineFail()
throws DescriptorParseException {
String unrecognizedLine = "unrecognized-line 1";
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage(
+ "Unrecognized line 'unrecognized-line 1' in server descriptor.");
DescriptorBuilder.createWithUnrecognizedLine(unrecognizedLine, true);
}
@@ -1598,9 +1803,12 @@ public class ServerDescriptorImplTest {
descriptor.getRouterSignatureEd25519());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testEd25519IdentityMasterKeyMismatch()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Mismatch between identity-ed25519 and "
+ + "master-key-ed25519.");
DescriptorBuilder.createWithEd25519Lines(IDENTITY_ED25519_LINES,
"master-key-ed25519 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
ROUTER_SIG_ED25519_LINE);
@@ -1613,17 +1821,23 @@ public class ServerDescriptorImplTest {
MASTER_KEY_ED25519_LINE, ROUTER_SIG_ED25519_LINE);
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testEd25519IdentityDuplicate()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'identity-ed25519' is contained 2 "
+ + "times, but must be contained at most once.");
DescriptorBuilder.createWithEd25519Lines(IDENTITY_ED25519_LINES + "\n"
+ IDENTITY_ED25519_LINES, MASTER_KEY_ED25519_LINE,
ROUTER_SIG_ED25519_LINE);
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testEd25519IdentityEmptyCrypto()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown
+ .expectMessage("Invalid length of identity-ed25519 (in bytes): 0");
DescriptorBuilder.createWithEd25519Lines("identity-ed25519\n"
+ "-----BEGIN ED25519 CERT-----\n-----END ED25519 CERT-----",
MASTER_KEY_ED25519_LINE, ROUTER_SIG_ED25519_LINE);
@@ -1640,9 +1854,12 @@ public class ServerDescriptorImplTest {
descriptor.getMasterKeyEd25519());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testEd25519MasterKeyDuplicate()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'master-key-ed25519' is contained 2 "
+ + "times, but must be contained at most once.");
DescriptorBuilder.createWithEd25519Lines(IDENTITY_ED25519_LINES,
MASTER_KEY_ED25519_LINE + "\n" + MASTER_KEY_ED25519_LINE,
ROUTER_SIG_ED25519_LINE);
@@ -1655,17 +1872,23 @@ public class ServerDescriptorImplTest {
MASTER_KEY_ED25519_LINE, null);
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testEd25519RouterSigDuplicate()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'router-sig-ed25519' is contained 2 "
+ + "times, but must be contained at most once.");
DescriptorBuilder.createWithEd25519Lines(IDENTITY_ED25519_LINES,
MASTER_KEY_ED25519_LINE, ROUTER_SIG_ED25519_LINE + "\n"
+ ROUTER_SIG_ED25519_LINE);
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testEd25519FollowedbyUnrecognizedLine()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Unrecognized line 'unrecognized-line 1' "
+ + "in server descriptor.");
DescriptorBuilder.createWithEd25519Lines(IDENTITY_ED25519_LINES,
MASTER_KEY_ED25519_LINE, ROUTER_SIG_ED25519_LINE
+ "\nunrecognized-line 1");
@@ -1697,9 +1920,12 @@ public class ServerDescriptorImplTest {
descriptor.getOnionKeyCrosscert());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testOnionKeyCrosscertDuplicate()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'onion-key-crosscert' is contained 2 "
+ + "times, but must be contained at most once.");
DescriptorBuilder.createWithOnionKeyCrosscertLines(
ONION_KEY_CROSSCERT_LINES + "\n" + ONION_KEY_CROSSCERT_LINES);
}
@@ -1716,9 +1942,12 @@ public class ServerDescriptorImplTest {
assertEquals(1, descriptor.getNtorOnionKeyCrosscertSign());
}
- @Test(expected = DescriptorParseException.class)
+ @Test
public void testNtorOnionKeyCrosscertDuplicate()
throws DescriptorParseException {
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("Keyword 'ntor-onion-key-crosscert' is "
+ + "contained 2 times, but must be contained at most once.");
DescriptorBuilder.createWithOnionKeyCrosscertLines(
NTOR_ONION_KEY_CROSSCERT_LINES + "\n"
+ NTOR_ONION_KEY_CROSSCERT_LINES);
1
0

16 Jun '17
commit 1ac254697b21ac297a2e3ef151fcf0bc22c53354
Author: iwakeh <iwakeh(a)torproject.org>
Date: Thu Jun 8 08:54:06 2017 +0000
Escalate NoSuchAlgorithmExceptions.
---
.../torproject/descriptor/impl/DescriptorImpl.java | 30 ++++++++++------------
1 file changed, 14 insertions(+), 16 deletions(-)
diff --git a/src/main/java/org/torproject/descriptor/impl/DescriptorImpl.java b/src/main/java/org/torproject/descriptor/impl/DescriptorImpl.java
index 79905c0..52ff6d4 100644
--- a/src/main/java/org/torproject/descriptor/impl/DescriptorImpl.java
+++ b/src/main/java/org/torproject/descriptor/impl/DescriptorImpl.java
@@ -364,14 +364,8 @@ public abstract class DescriptorImpl implements Descriptor {
end = ascii.indexOf(endToken) + endToken.length();
}
if (start >= 0 && end >= 0 && end > start) {
- try {
- MessageDigest md = MessageDigest.getInstance("SHA-1");
- md.update(this.rawDescriptorBytes, this.offset + start, end - start);
- this.digestSha1Hex = DatatypeConverter.printHexBinary(md.digest())
- .toLowerCase();
- } catch (NoSuchAlgorithmException e) {
- /* Handle below. */
- }
+ this.digestSha1Hex = DatatypeConverter.printHexBinary(
+ messageDigest("SHA-1", start, end)).toLowerCase();
}
}
if (null == this.digestSha1Hex) {
@@ -380,6 +374,16 @@ public abstract class DescriptorImpl implements Descriptor {
}
}
+ private byte[] messageDigest(String alg, int start, int end) {
+ try {
+ MessageDigest md = MessageDigest.getInstance(alg);
+ md.update(this.rawDescriptorBytes, this.offset + start, end - start);
+ return md.digest();
+ } catch (NoSuchAlgorithmException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
public String getDigestSha1Hex() {
return this.digestSha1Hex;
}
@@ -403,14 +407,8 @@ public abstract class DescriptorImpl implements Descriptor {
end = ascii.indexOf(endToken) + endToken.length();
}
if (start >= 0 && end >= 0 && end > start) {
- try {
- MessageDigest md = MessageDigest.getInstance("SHA-256");
- md.update(this.rawDescriptorBytes, this.offset + start, end - start);
- this.digestSha256Base64 = DatatypeConverter.printBase64Binary(
- md.digest()).replaceAll("=", "");
- } catch (NoSuchAlgorithmException e) {
- /* Handle below. */
- }
+ this.digestSha256Base64 = DatatypeConverter.printBase64Binary(
+ messageDigest("SHA-256", start, end)).replaceAll("=", "");
}
}
if (null == this.digestSha256Base64) {
1
0

16 Jun '17
commit c7a4ffe6ccd1989ff1cd6eddd5beb141798600b5
Author: Karsten Loesing <karsten.loesing(a)gmx.net>
Date: Mon Jun 12 10:10:04 2017 +0200
Replace all @Test() with @Test.
---
.../descriptor/DescriptorSourceFactoryTest.java | 6 +-
.../descriptor/impl/BridgeNetworkStatusTest.java | 6 +-
.../impl/DescriptorCollectorImplTest.java | 12 +-
.../descriptor/impl/ExitListImplTest.java | 6 +-
.../impl/ExtraInfoDescriptorImplTest.java | 130 +++++++++---------
.../descriptor/impl/MicrodescriptorImplTest.java | 2 +-
.../impl/RelayNetworkStatusConsensusImplTest.java | 88 ++++++-------
.../impl/RelayNetworkStatusImplTest.java | 2 +-
.../impl/RelayNetworkStatusVoteImplTest.java | 54 ++++----
.../descriptor/impl/ServerDescriptorImplTest.java | 146 ++++++++++-----------
.../descriptor/impl/TorperfResultImplTest.java | 10 +-
.../index/DescriptorIndexCollectorTest.java | 14 +-
.../descriptor/index/DirectoryNodeTest.java | 4 +-
.../torproject/descriptor/index/FileNodeTest.java | 2 +-
.../torproject/descriptor/index/IndexNodeTest.java | 12 +-
15 files changed, 247 insertions(+), 247 deletions(-)
diff --git a/src/test/java/org/torproject/descriptor/DescriptorSourceFactoryTest.java b/src/test/java/org/torproject/descriptor/DescriptorSourceFactoryTest.java
index 9e0b5ff..8eee1ef 100644
--- a/src/test/java/org/torproject/descriptor/DescriptorSourceFactoryTest.java
+++ b/src/test/java/org/torproject/descriptor/DescriptorSourceFactoryTest.java
@@ -33,7 +33,7 @@ public class DescriptorSourceFactoryTest {
private static final String[] defaults = new String[] { COLLECTOR_DEFAULT,
DOWNLOADER_DEFAULT, PARSER_DEFAULT, READER_DEFAULT };
- @Test()
+ @Test
public void testDefaults() {
setProperties(defaults);
DescriptorCollector dc =
@@ -61,7 +61,7 @@ public class DescriptorSourceFactoryTest {
DescriptorSourceFactory.createDescriptorCollector();
}
- @Test()
+ @Test
public void testUnknownPropertyException() {
setProperties(defaults);
try {
@@ -81,7 +81,7 @@ public class DescriptorSourceFactoryTest {
}
}
- @Test()
+ @Test
public void testProperties() {
setProperties(new String[] {
"org.torproject.descriptor.DummyCollectorImplementation",
diff --git a/src/test/java/org/torproject/descriptor/impl/BridgeNetworkStatusTest.java b/src/test/java/org/torproject/descriptor/impl/BridgeNetworkStatusTest.java
index 25db3d0..3739e5d 100644
--- a/src/test/java/org/torproject/descriptor/impl/BridgeNetworkStatusTest.java
+++ b/src/test/java/org/torproject/descriptor/impl/BridgeNetworkStatusTest.java
@@ -126,7 +126,7 @@ public class BridgeNetworkStatusTest {
}
}
- @Test()
+ @Test
public void testSampleStatus() throws DescriptorParseException {
StatusBuilder sb = new StatusBuilder();
BridgeNetworkStatus status = sb.buildStatus(true);
@@ -145,14 +145,14 @@ public class BridgeNetworkStatusTest {
assertTrue(status.getUnrecognizedLines().isEmpty());
}
- @Test()
+ @Test
public void testPublishedNoLine() throws DescriptorParseException {
BridgeNetworkStatus status =
StatusBuilder.createWithPublishedLine(null);
assertEquals(1448127576000L, status.getPublishedMillis());
}
- @Test()
+ @Test
public void testFlagThresholdsNoLine() throws DescriptorParseException {
BridgeNetworkStatus status =
StatusBuilder.createWithFlagThresholdsLine(null);
diff --git a/src/test/java/org/torproject/descriptor/impl/DescriptorCollectorImplTest.java b/src/test/java/org/torproject/descriptor/impl/DescriptorCollectorImplTest.java
index 45752b2..c2f9674 100644
--- a/src/test/java/org/torproject/descriptor/impl/DescriptorCollectorImplTest.java
+++ b/src/test/java/org/torproject/descriptor/impl/DescriptorCollectorImplTest.java
@@ -18,7 +18,7 @@ public class DescriptorCollectorImplTest {
private static final String REMOTE_DIRECTORY_CONSENSUSES =
"/recent/relay-descriptors/consensuses/";
- @Test()
+ @Test
public void testOneFile() {
String remoteFilename = "2015-05-24-12-00-00-consensus";
String directoryListing = "<tr><td valign=\"top\">"
@@ -38,7 +38,7 @@ public class DescriptorCollectorImplTest {
remoteFiles.get(remoteFiles.firstKey()));
}
- @Test()
+ @Test
public void testSameFileTwoTimestampsLastWins() {
String remoteFilename = "2015-05-24-12-00-00-consensus";
String firstTimestamp = "2015-05-24 12:04";
@@ -61,7 +61,7 @@ public class DescriptorCollectorImplTest {
remoteFiles.get(remoteFiles.firstKey()));
}
- @Test()
+ @Test
public void testSubDirectoryOnly() {
String directoryListing = "<tr><td valign=\"top\">"
+ "<img src=\"/icons/folder.gif\" alt=\"[DIR]\"></td><td>"
@@ -75,7 +75,7 @@ public class DescriptorCollectorImplTest {
assertTrue(remoteFiles.isEmpty());
}
- @Test()
+ @Test
public void testParentDirectoryOnly() {
String directoryListing = "<tr><td valign=\"top\">"
+ "<img src=\"/icons/back.gif\" alt=\"[DIR]\"></td><td>"
@@ -89,7 +89,7 @@ public class DescriptorCollectorImplTest {
assertTrue(remoteFiles.isEmpty());
}
- @Test()
+ @Test
public void testUnexpectedDateFormat() {
String directoryListing = "<tr><td valign=\"top\">"
+ "<img src=\"/icons/unknown.gif\" alt=\"[ ]\"></td><td>"
@@ -104,7 +104,7 @@ public class DescriptorCollectorImplTest {
assertTrue(remoteFiles.isEmpty());
}
- @Test()
+ @Test
public void testInvalidDate() {
String directoryListing = "<tr><td valign=\"top\">"
+ "<img src=\"/icons/unknown.gif\" alt=\"[ ]\"></td><td>"
diff --git a/src/test/java/org/torproject/descriptor/impl/ExitListImplTest.java b/src/test/java/org/torproject/descriptor/impl/ExitListImplTest.java
index 5a67d53..74417d9 100644
--- a/src/test/java/org/torproject/descriptor/impl/ExitListImplTest.java
+++ b/src/test/java/org/torproject/descriptor/impl/ExitListImplTest.java
@@ -21,7 +21,7 @@ public class ExitListImplTest {
@Rule
public ExpectedException thrown = ExpectedException.none();
- @Test()
+ @Test
public void testAnnotatedInput() throws Exception {
ExitListImpl result = new ExitListImpl((tordnselAnnotation + input)
.getBytes("US-ASCII"), fileName, false);
@@ -38,7 +38,7 @@ public class ExitListImplTest {
result.getEntries().size());
}
- @Test()
+ @Test
public void testMultipleOldExitAddresses() throws Exception {
ExitListImpl result = new ExitListImpl(
(tordnselAnnotation + multiExitAddressInput)
@@ -64,7 +64,7 @@ public class ExitListImplTest {
assertTrue("Map: " + testMap, testMap.isEmpty());
}
- @Test()
+ @Test
public void testMultipleExitAddresses() throws Exception {
ExitListImpl result = new ExitListImpl(
(tordnselAnnotation + multiExitAddressInput)
diff --git a/src/test/java/org/torproject/descriptor/impl/ExtraInfoDescriptorImplTest.java b/src/test/java/org/torproject/descriptor/impl/ExtraInfoDescriptorImplTest.java
index e10fa7b..7b62393 100644
--- a/src/test/java/org/torproject/descriptor/impl/ExtraInfoDescriptorImplTest.java
+++ b/src/test/java/org/torproject/descriptor/impl/ExtraInfoDescriptorImplTest.java
@@ -951,7 +951,7 @@ public class ExtraInfoDescriptorImplTest {
}
}
- @Test()
+ @Test
public void testSampleDescriptor() throws DescriptorParseException {
DescriptorBuilder db = new DescriptorBuilder();
ExtraInfoDescriptor descriptor = db.buildDescriptor(true);
@@ -978,7 +978,7 @@ public class ExtraInfoDescriptorImplTest {
DescriptorBuilder.createWithExtraInfoLine(null);
}
- @Test()
+ @Test
public void testExtraInfoOpt() throws DescriptorParseException {
ExtraInfoDescriptor descriptor = DescriptorBuilder
.createWithExtraInfoLine("opt extra-info chaoscomputerclub5 "
@@ -988,7 +988,7 @@ public class ExtraInfoDescriptorImplTest {
descriptor.getFingerprint());
}
- @Test()
+ @Test
public void testExtraInfoNicknameTwoSpaces()
throws DescriptorParseException {
ExtraInfoDescriptor descriptor = DescriptorBuilder
@@ -1077,14 +1077,14 @@ public class ExtraInfoDescriptorImplTest {
DescriptorBuilder.createWithPublishedLine(null);
}
- @Test()
+ @Test
public void testPublishedOpt() throws DescriptorParseException {
ExtraInfoDescriptor descriptor = DescriptorBuilder
.createWithPublishedLine("opt published 2012-02-11 09:08:36");
assertEquals(1328951316000L, descriptor.getPublishedMillis());
}
- @Test()
+ @Test
public void testPublishedMillis() throws DescriptorParseException {
ExtraInfoDescriptor descriptor = DescriptorBuilder
.createWithPublishedLine("opt published 2012-02-11 09:08:36.123");
@@ -1103,7 +1103,7 @@ public class ExtraInfoDescriptorImplTest {
+ "-4713350144,-4723824640,-4710717440,-4572675072");
}
- @Test()
+ @Test
public void testReadHistoryTabInterval()
throws DescriptorParseException {
DescriptorBuilder.createWithReadHistoryLine("read-history "
@@ -1111,7 +1111,7 @@ public class ExtraInfoDescriptorImplTest {
+ "4707695616,4699666432,4650004480,4489718784");
}
- @Test()
+ @Test
public void testReadHistoryTabIntervalBytes()
throws DescriptorParseException {
DescriptorBuilder.createWithReadHistoryLine("read-history "
@@ -1131,7 +1131,7 @@ public class ExtraInfoDescriptorImplTest {
+ "4707695616,4699666432,4650004480,4489718784");
}
- @Test()
+ @Test
public void testReadHistoryNonStandardInterval()
throws DescriptorParseException {
DescriptorBuilder.createWithReadHistoryLine("read-history "
@@ -1163,7 +1163,7 @@ public class ExtraInfoDescriptorImplTest {
+ "81281024,,60625920,67922944");
}
- @Test()
+ @Test
public void testDirreqWriteHistoryExtraArg() throws DescriptorParseException {
DescriptorBuilder.createWithDirreqWriteHistoryLine(
"dirreq-write-history "
@@ -1183,7 +1183,7 @@ public class ExtraInfoDescriptorImplTest {
+ "17074176,16235520,16005120,");
}
- @Test()
+ @Test
public void testGeoipDbDigestValid() throws DescriptorParseException {
ExtraInfoDescriptor descriptor = DescriptorBuilder
.createWithGeoipDbDigestLine("geoip-db-digest "
@@ -1221,7 +1221,7 @@ public class ExtraInfoDescriptorImplTest {
DescriptorBuilder.createWithGeoipDbDigestLine("geoip-db-digest");
}
- @Test()
+ @Test
public void testGeoipDbDigestExtraArg() throws DescriptorParseException {
ExtraInfoDescriptor descriptor = DescriptorBuilder
.createWithGeoip6DbDigestLine("geoip-db-digest "
@@ -1232,7 +1232,7 @@ public class ExtraInfoDescriptorImplTest {
descriptor.getGeoipDbDigest());
}
- @Test()
+ @Test
public void testGeoip6DbDigestValid() throws DescriptorParseException {
ExtraInfoDescriptor descriptor = DescriptorBuilder
.createWithGeoip6DbDigestLine("geoip6-db-digest "
@@ -1241,7 +1241,7 @@ public class ExtraInfoDescriptorImplTest {
descriptor.getGeoip6DbDigestSha1Hex());
}
- @Test()
+ @Test
public void testGeoip6DbDigestExtraArg() throws DescriptorParseException {
ExtraInfoDescriptor descriptor = DescriptorBuilder
.createWithGeoip6DbDigestLine("geoip6-db-digest "
@@ -1252,7 +1252,7 @@ public class ExtraInfoDescriptorImplTest {
descriptor.getGeoip6DbDigest());
}
- @Test()
+ @Test
public void testGeoipStatsValid() throws DescriptorParseException {
ExtraInfoDescriptor descriptor = GeoipStatsBuilder
.createWithDefaultLines();
@@ -1322,7 +1322,7 @@ public class ExtraInfoDescriptorImplTest {
+ "gb=208,other=200");
}
- @Test()
+ @Test
public void testGeoipClientOriginsQuestionMarks()
throws DescriptorParseException {
GeoipStatsBuilder.createWithGeoipClientOriginsLine(
@@ -1330,7 +1330,7 @@ public class ExtraInfoDescriptorImplTest {
+ "gb=208,??=200");
}
- @Test()
+ @Test
public void testGeoipClientOriginsCapital()
throws DescriptorParseException {
GeoipStatsBuilder.createWithGeoipClientOriginsLine(
@@ -1386,7 +1386,7 @@ public class ExtraInfoDescriptorImplTest {
+ "ru=352,fr=208,gb=208,ir=200");
}
- @Test()
+ @Test
public void testGeoipClientOriginsExtraArg()
throws DescriptorParseException {
GeoipStatsBuilder.createWithGeoipClientOriginsLine(
@@ -1394,7 +1394,7 @@ public class ExtraInfoDescriptorImplTest {
+ "gb=208 ir=200");
}
- @Test()
+ @Test
public void testDirreqStatsValid() throws DescriptorParseException {
ExtraInfoDescriptor descriptor = DirreqStatsBuilder
.createWithDefaultLines();
@@ -1425,14 +1425,14 @@ public class ExtraInfoDescriptorImplTest {
assertEquals(0, dl.get("complete").intValue());
}
- @Test()
+ @Test
public void testDirreqStatsIntervalTwoDays()
throws DescriptorParseException {
DirreqStatsBuilder.createWithDirreqStatsEndLine("dirreq-stats-end "
+ "2012-02-11 00:59:53 (172800 s)");
}
- @Test()
+ @Test
public void testDirreqStatsExtraArg()
throws DescriptorParseException {
DirreqStatsBuilder.createWithDirreqStatsEndLine("dirreq-stats-end "
@@ -1449,14 +1449,14 @@ public class ExtraInfoDescriptorImplTest {
+ "usa=1544");
}
- @Test()
+ @Test
public void testDirreqV3IpsExtraArg()
throws DescriptorParseException {
DirreqStatsBuilder.createWithDirreqV3IpsLine("dirreq-v3-ips "
+ "ab=12,cd=34 ef=56");
}
- @Test()
+ @Test
public void testDirreqV2IpsDigitCountry()
throws DescriptorParseException {
DirreqStatsBuilder.createWithDirreqV2IpsLine("dirreq-v2-ips 00=8");
@@ -1472,7 +1472,7 @@ public class ExtraInfoDescriptorImplTest {
+ "u=1744");
}
- @Test()
+ @Test
public void testDirreqV3ReqsNull() throws DescriptorParseException {
ExtraInfoDescriptor eid =
DirreqStatsBuilder.createWithDirreqV3ReqsLine(null);
@@ -1498,7 +1498,7 @@ public class ExtraInfoDescriptorImplTest {
+ "ok==10848");
}
- @Test()
+ @Test
public void testDirreqV3RespEmptyString()
throws DescriptorParseException {
this.thrown.expect(DescriptorParseException.class);
@@ -1508,7 +1508,7 @@ public class ExtraInfoDescriptorImplTest {
DirreqStatsBuilder.createWithDirreqV3RespLine("dirreq-v3-resp =10848");
}
- @Test()
+ @Test
public void testDirreqV3RespExtraArg()
throws DescriptorParseException {
DirreqStatsBuilder.createWithDirreqV3RespLine("dirreq-v3-resp "
@@ -1541,7 +1541,7 @@ public class ExtraInfoDescriptorImplTest {
+ "0.37");
}
- @Test()
+ @Test
public void testDirreqV3ShareExtraArg()
throws DescriptorParseException {
DirreqStatsBuilder.createWithDirreqV3ShareLine("dirreq-v3-share "
@@ -1557,7 +1557,7 @@ public class ExtraInfoDescriptorImplTest {
"dirreq-v3-direct-dl complete 36");
}
- @Test()
+ @Test
public void testDirreqV2DirectDlNegative()
throws DescriptorParseException {
DirreqStatsBuilder.createWithDirreqV2DirectDlLine(
@@ -1582,14 +1582,14 @@ public class ExtraInfoDescriptorImplTest {
"dirreq-v2-tunneled-dl complete=0.001");
}
- @Test()
+ @Test
public void testDirreqV3TunneledDlExtraArg()
throws DescriptorParseException {
DirreqStatsBuilder.createWithDirreqV2TunneledDlLine(
"dirreq-v2-tunneled-dl complete=-8 incomplete=1/-8");
}
- @Test()
+ @Test
public void testEntryStatsValid() throws DescriptorParseException {
ExtraInfoDescriptor descriptor = EntryStatsBuilder
.createWithDefaultLines();
@@ -1619,7 +1619,7 @@ public class ExtraInfoDescriptorImplTest {
+ "ir=25368;us=15744");
}
- @Test()
+ @Test
public void testCellStatsValid() throws DescriptorParseException {
ExtraInfoDescriptor descriptor = CellStatsBuilder
.createWithDefaultLines();
@@ -1688,14 +1688,14 @@ public class ExtraInfoDescriptorImplTest {
"cell-circuits-per-decile -866");
}
- @Test()
+ @Test
public void testCellCircuitsPerDecileExtraArg()
throws DescriptorParseException {
CellStatsBuilder.createWithCellCircuitsPerDecileLine(
"cell-circuits-per-decile 866 866 866 866 866");
}
- @Test()
+ @Test
public void testConnBiDirectValid()
throws DescriptorParseException {
ExtraInfoDescriptor descriptor = DescriptorBuilder
@@ -1719,14 +1719,14 @@ public class ExtraInfoDescriptorImplTest {
+ "2012-02-11 01:59:39 (86400 s) 42173,1591,1310,1744,42");
}
- @Test()
+ @Test
public void testConnBiDirectStatsExtraArg()
throws DescriptorParseException {
DescriptorBuilder.createWithConnBiDirectLine("conn-bi-direct "
+ "2012-02-11 01:59:39 (86400 s) 42173,1591,1310,1744 +1");
}
- @Test()
+ @Test
public void testExitStatsValid() throws DescriptorParseException {
ExtraInfoDescriptor descriptor = ExitStatsBuilder
.createWithDefaultLines();
@@ -1788,7 +1788,7 @@ public class ExtraInfoDescriptorImplTest {
"exit-kibibytes-written unknown=74647");
}
- @Test()
+ @Test
public void testExitStatsWrittenEmptyString()
throws DescriptorParseException {
this.thrown.expect(DescriptorParseException.class);
@@ -1808,27 +1808,27 @@ public class ExtraInfoDescriptorImplTest {
"exit-kibibytes-read 25=-35562");
}
- @Test()
+ @Test
public void testExitStatsReadTooLarge()
throws DescriptorParseException {
ExitStatsBuilder.createWithExitKibibytesReadLine(
"exit-kibibytes-read other=2282907805");
}
- @Test()
+ @Test
public void testExitStatsStreamsTooLarge()
throws DescriptorParseException {
ExitStatsBuilder.createWithExitStreamsOpenedLine(
"exit-streams-opened 25=2147483648");
}
- @Test()
+ @Test
public void testExitStatsStreamsExtraArg() throws DescriptorParseException {
ExitStatsBuilder.createWithExitStreamsOpenedLine(
"exit-streams-opened 25=21474 3648");
}
- @Test()
+ @Test
public void testBridgeStatsValid() throws DescriptorParseException {
ExtraInfoDescriptor descriptor = BridgeStatsBuilder
.createWithDefaultLines();
@@ -1861,7 +1861,7 @@ public class ExtraInfoDescriptorImplTest {
+ "2012-02-11 01:59:39 (0 s)");
}
- @Test()
+ @Test
public void testBridgeStatsEndExtraArg()
throws DescriptorParseException {
BridgeStatsBuilder.createWithBridgeStatsEndLine("bridge-stats-end "
@@ -1889,7 +1889,7 @@ public class ExtraInfoDescriptorImplTest {
0x69, 0x70, 0x73 }, false); // "ips" (no newline)
}
- @Test()
+ @Test
public void testBridgeIpsExtraArg()
throws DescriptorParseException {
BridgeStatsBuilder.createWithBridgeIpsLine("bridge-ips ir=24 5");
@@ -1905,7 +1905,7 @@ public class ExtraInfoDescriptorImplTest {
"bridge-ip-versions v4=24.5");
}
- @Test()
+ @Test
public void testBridgeIpVersionsExtraArg()
throws DescriptorParseException {
BridgeStatsBuilder.createWithBridgeIpVersionsLine(
@@ -1922,21 +1922,21 @@ public class ExtraInfoDescriptorImplTest {
"bridge-ip-transports obfs2=24.5");
}
- @Test()
+ @Test
public void testBridgeIpTransportsUnderscore()
throws DescriptorParseException {
BridgeStatsBuilder.createWithBridgeIpTransportsLine(
"bridge-ip-transports meek=32,obfs3_websocket=8,websocket=64");
}
- @Test()
+ @Test
public void testBridgeIpTransportsExtraArg()
throws DescriptorParseException {
BridgeStatsBuilder.createWithBridgeIpTransportsLine(
"bridge-ip-transports obfs2=24 5");
}
- @Test()
+ @Test
public void testPaddingCountsValid()
throws DescriptorParseException {
ExtraInfoDescriptor descriptor = DescriptorBuilder
@@ -1953,7 +1953,7 @@ public class ExtraInfoDescriptorImplTest {
0L, 0L, 0L, 0L, 0L});
}
- @Test()
+ @Test
public void testPaddingOtherCountsValid()
throws DescriptorParseException {
ExtraInfoDescriptor descriptor = DescriptorBuilder
@@ -1981,7 +1981,7 @@ public class ExtraInfoDescriptorImplTest {
}
}
- @Test()
+ @Test
public void testPaddingCountsValidFutureProof()
throws DescriptorParseException {
ExtraInfoDescriptor descriptor = DescriptorBuilder
@@ -2007,7 +2007,7 @@ public class ExtraInfoDescriptorImplTest {
+ "(86400 s) bin-size=10000 write-drop=10000");
}
- @Test()
+ @Test
public void testPaddingCountsNoInterval() throws DescriptorParseException {
this.thrown.expect(DescriptorParseException.class);
this.thrown.expectMessage(Matchers
@@ -2018,7 +2018,7 @@ public class ExtraInfoDescriptorImplTest {
+ "01:48:43 bin-size=10000 write-drop=10000");
}
- @Test()
+ @Test
public void testPaddingCountsNoKey() throws DescriptorParseException {
this.thrown.expect(DescriptorParseException.class);
this.thrown.expectMessage(Matchers
@@ -2028,7 +2028,7 @@ public class ExtraInfoDescriptorImplTest {
+ "01:48:43 (86400 s) write-total=9 write-drop=10000 =7 x=8");
}
- @Test()
+ @Test
public void testPaddingCountsNoValue() throws DescriptorParseException {
this.thrown.expect(DescriptorParseException.class);
this.thrown.expectMessage(Matchers
@@ -2038,7 +2038,7 @@ public class ExtraInfoDescriptorImplTest {
+ "01:48:43 (86400 s) write-total=7 write-drop= bin-size=10000 ");
}
- @Test()
+ @Test
public void testPaddingCountsKeyRepeated() throws DescriptorParseException {
this.thrown.expect(DescriptorParseException.class);
this.thrown.expectMessage(Matchers
@@ -2048,7 +2048,7 @@ public class ExtraInfoDescriptorImplTest {
+ "01:48:43 (86400 s) a=1 b=2 a=3 b=4");
}
- @Test()
+ @Test
public void testPaddingCountsCommaSeparatedList()
throws DescriptorParseException {
this.thrown.expect(DescriptorParseException.class);
@@ -2059,7 +2059,7 @@ public class ExtraInfoDescriptorImplTest {
+ "01:48:43 (86400 s) bin-size=10000,write-drop=10000");
}
- @Test()
+ @Test
public void testPaddingCountsNoList() throws DescriptorParseException {
this.thrown.expect(DescriptorParseException.class);
this.thrown.expectMessage(Matchers
@@ -2069,7 +2069,7 @@ public class ExtraInfoDescriptorImplTest {
+ "(86400 s)");
}
- @Test()
+ @Test
public void testHidservStatsValid() throws DescriptorParseException {
ExtraInfoDescriptor descriptor = HidservStatsBuilder
.createWithDefaultLines();
@@ -2097,7 +2097,7 @@ public class ExtraInfoDescriptorImplTest {
assertTrue(params.isEmpty());
}
- @Test()
+ @Test
public void testHidservStatsEndLineMissing()
throws DescriptorParseException {
ExtraInfoDescriptor descriptor =
@@ -2106,7 +2106,7 @@ public class ExtraInfoDescriptorImplTest {
assertEquals(-1L, descriptor.getHidservStatsIntervalLength());
}
- @Test()
+ @Test
public void testHidservRendRelayedCellsNoParams()
throws DescriptorParseException {
ExtraInfoDescriptor descriptor =
@@ -2140,7 +2140,7 @@ public class ExtraInfoDescriptorImplTest {
"hidserv-dir-onions-seen -3 delta_f=A epsilon=B bin_size=C");
}
- @Test()
+ @Test
public void testHidservDirOnionsSeenExtraArg()
throws DescriptorParseException {
HidservStatsBuilder.createWithHidservDirOnionsSeenLine(
@@ -2170,7 +2170,7 @@ public class ExtraInfoDescriptorImplTest {
DescriptorBuilder.createWithUnrecognizedLine(unrecognizedLine, true);
}
- @Test()
+ @Test
public void testUnrecognizedLineIgnore()
throws DescriptorParseException {
String unrecognizedLine = "unrecognized-line 1";
@@ -2197,7 +2197,7 @@ public class ExtraInfoDescriptorImplTest {
"router-sig-ed25519 y7WF9T2GFwkSDPZEhB55HgquIFOl5uXUFMYJPq3CXXUTKeJ"
+ "kSrtaZUB5s34fWdHQNtl84mH4dVaFMunHnwgYAw";
- @Test()
+ @Test
public void testEd25519() throws DescriptorParseException {
ExtraInfoDescriptor descriptor =
DescriptorBuilder.createWithEd25519Lines(IDENTITY_ED25519_LINES,
@@ -2224,7 +2224,7 @@ public class ExtraInfoDescriptorImplTest {
ROUTER_SIG_ED25519_LINE);
}
- @Test()
+ @Test
public void testEd25519IdentityMissing()
throws DescriptorParseException {
DescriptorBuilder.createWithEd25519Lines(null,
@@ -2253,7 +2253,7 @@ public class ExtraInfoDescriptorImplTest {
MASTER_KEY_ED25519_LINE, ROUTER_SIG_ED25519_LINE);
}
- @Test()
+ @Test
public void testEd25519MasterKeyMissing()
throws DescriptorParseException {
ExtraInfoDescriptor descriptor =
@@ -2275,7 +2275,7 @@ public class ExtraInfoDescriptorImplTest {
ROUTER_SIG_ED25519_LINE);
}
- @Test()
+ @Test
public void testEd25519RouterSigMissing()
throws DescriptorParseException {
DescriptorBuilder.createWithEd25519Lines(IDENTITY_ED25519_LINES,
@@ -2304,7 +2304,7 @@ public class ExtraInfoDescriptorImplTest {
+ "\nunrecognized-line 1");
}
- @Test()
+ @Test
public void testExtraInfoDigestSha256Relay()
throws DescriptorParseException {
byte[] descriptorBytes = ("extra-info Unnamed "
@@ -2337,7 +2337,7 @@ public class ExtraInfoDescriptorImplTest {
descriptor.getDigestSha256Base64());
}
- @Test()
+ @Test
public void testExtraInfoDigestSha256Bridge()
throws DescriptorParseException {
byte[] descriptorBytes = ("extra-info idideditheconfig "
@@ -2362,7 +2362,7 @@ public class ExtraInfoDescriptorImplTest {
descriptor.getDigestSha256Base64());
}
- @Test()
+ @Test
public void testExtraInfoDigestsNoRouterDigestLines()
throws DescriptorParseException {
byte[] descriptorBytes = ("extra-info idideditheconfig "
diff --git a/src/test/java/org/torproject/descriptor/impl/MicrodescriptorImplTest.java b/src/test/java/org/torproject/descriptor/impl/MicrodescriptorImplTest.java
index 7167de9..b1d6474 100644
--- a/src/test/java/org/torproject/descriptor/impl/MicrodescriptorImplTest.java
+++ b/src/test/java/org/torproject/descriptor/impl/MicrodescriptorImplTest.java
@@ -71,7 +71,7 @@ public class MicrodescriptorImplTest {
}
}
- @Test()
+ @Test
public void testDefaults() throws DescriptorParseException {
Microdescriptor micro = DescriptorBuilder.createWithDefaultLines();
assertEquals("ER1AC4KqT//o3pJDrqlmej5G2qW1EQYEr/IrMQHNc6I",
diff --git a/src/test/java/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImplTest.java b/src/test/java/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImplTest.java
index dcd3663..90128c2 100644
--- a/src/test/java/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImplTest.java
+++ b/src/test/java/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImplTest.java
@@ -352,7 +352,7 @@ public class RelayNetworkStatusConsensusImplTest {
}
}
- @Test()
+ @Test
public void testSampleConsensus() throws DescriptorParseException {
ConsensusBuilder cb = new ConsensusBuilder();
RelayNetworkStatusConsensus consensus = cb.buildConsensus(true);
@@ -424,7 +424,7 @@ public class RelayNetworkStatusConsensusImplTest {
"network-status-version 3\n ");
}
- @Test()
+ @Test
public void testNetworkStatusVersionPrefixLineAtChar()
throws DescriptorParseException {
ConsensusBuilder.createWithNetworkStatusVersionLine(
@@ -532,7 +532,7 @@ public class RelayNetworkStatusConsensusImplTest {
ConsensusBuilder.createWithVoteStatusLine("vote-status ");
}
- @Test()
+ @Test
public void testVoteStatusConsensusOneSpace()
throws DescriptorParseException {
ConsensusBuilder.createWithVoteStatusLine("vote-status consensus ");
@@ -736,7 +736,7 @@ public class RelayNetworkStatusConsensusImplTest {
ConsensusBuilder.createWithVotingDelayLine("voting-delay one two");
}
- @Test()
+ @Test
public void testClientServerVersionsNoLine()
throws DescriptorParseException {
ConsensusBuilder cb = new ConsensusBuilder();
@@ -747,7 +747,7 @@ public class RelayNetworkStatusConsensusImplTest {
assertNull(consensus.getRecommendedServerVersions());
}
- @Test()
+ @Test
public void testServerVersionsNoLine() throws DescriptorParseException {
RelayNetworkStatusConsensus consensus =
ConsensusBuilder.createWithServerVersionsLine(null);
@@ -755,7 +755,7 @@ public class RelayNetworkStatusConsensusImplTest {
assertNull(consensus.getRecommendedServerVersions());
}
- @Test()
+ @Test
public void testClientVersionsNoLine() throws DescriptorParseException {
RelayNetworkStatusConsensus consensus =
ConsensusBuilder.createWithClientVersionsLine(null);
@@ -763,7 +763,7 @@ public class RelayNetworkStatusConsensusImplTest {
assertNotNull(consensus.getRecommendedServerVersions());
}
- @Test()
+ @Test
public void testClientVersionsNoSpace()
throws DescriptorParseException {
RelayNetworkStatusConsensus consensus =
@@ -772,7 +772,7 @@ public class RelayNetworkStatusConsensusImplTest {
assertTrue(consensus.getRecommendedClientVersions().isEmpty());
}
- @Test()
+ @Test
public void testClientVersionsOneSpace()
throws DescriptorParseException {
RelayNetworkStatusConsensus consensus =
@@ -798,7 +798,7 @@ public class RelayNetworkStatusConsensusImplTest {
"client-versions ,0.2.2.34");
}
- @Test()
+ @Test
public void testRecommendedClientProtocols123()
throws DescriptorParseException {
RelayNetworkStatusConsensus consensus = ConsensusBuilder
@@ -808,7 +808,7 @@ public class RelayNetworkStatusConsensusImplTest {
consensus.getRecommendedClientProtocols().get("Cons"));
}
- @Test()
+ @Test
public void testRecommendedRelayProtocols134()
throws DescriptorParseException {
RelayNetworkStatusConsensus consensus = ConsensusBuilder
@@ -818,7 +818,7 @@ public class RelayNetworkStatusConsensusImplTest {
consensus.getRecommendedRelayProtocols().get("Cons"));
}
- @Test()
+ @Test
public void testRequiredClientProtocols1425()
throws DescriptorParseException {
RelayNetworkStatusConsensus consensus = ConsensusBuilder
@@ -829,7 +829,7 @@ public class RelayNetworkStatusConsensusImplTest {
consensus.getRequiredClientProtocols().get("Cons"));
}
- @Test()
+ @Test
public void testRequiredRelayProtocols1111()
throws DescriptorParseException {
RelayNetworkStatusConsensus consensus = ConsensusBuilder
@@ -849,14 +849,14 @@ public class RelayNetworkStatusConsensusImplTest {
"required-relay-protocols Cons=1\nrequired-relay-protocols Cons=1");
}
- @Test()
+ @Test
public void testPackageNone() throws DescriptorParseException {
RelayNetworkStatusConsensus consensus =
ConsensusBuilder.createWithPackageLines(null);
assertNull(consensus.getPackageLines());
}
- @Test()
+ @Test
public void testPackageOne() throws DescriptorParseException {
String packageLine = "package shouldbesecond 0 http digest=digest";
RelayNetworkStatusConsensus consensus =
@@ -865,7 +865,7 @@ public class RelayNetworkStatusConsensusImplTest {
consensus.getPackageLines().get(0));
}
- @Test()
+ @Test
public void testPackageTwo() throws DescriptorParseException {
List<String> packageLines = Arrays.asList(
"package shouldbesecond 0 http digest=digest",
@@ -910,14 +910,14 @@ public class RelayNetworkStatusConsensusImplTest {
ConsensusBuilder.createWithKnownFlagsLine("known-flags ");
}
- @Test()
+ @Test
public void testParamsNoLine() throws DescriptorParseException {
RelayNetworkStatusConsensus consensus =
ConsensusBuilder.createWithParamsLine(null);
assertNull(consensus.getConsensusParams());
}
- @Test()
+ @Test
public void testParamsNoSpace() throws DescriptorParseException {
RelayNetworkStatusConsensus consensus =
ConsensusBuilder.createWithParamsLine("params");
@@ -925,7 +925,7 @@ public class RelayNetworkStatusConsensusImplTest {
assertTrue(consensus.getConsensusParams().isEmpty());
}
- @Test()
+ @Test
public void testParamsOneSpace() throws DescriptorParseException {
RelayNetworkStatusConsensus consensus =
ConsensusBuilder.createWithParamsLine("params ");
@@ -933,7 +933,7 @@ public class RelayNetworkStatusConsensusImplTest {
assertTrue(consensus.getConsensusParams().isEmpty());
}
- @Test()
+ @Test
public void testParamsThreeSpaces() throws DescriptorParseException {
RelayNetworkStatusConsensus consensus =
ConsensusBuilder.createWithParamsLine("params ");
@@ -958,7 +958,7 @@ public class RelayNetworkStatusConsensusImplTest {
ConsensusBuilder.createWithParamsLine("params min=-2147483649");
}
- @Test()
+ @Test
public void testParamsLargestNegative()
throws DescriptorParseException {
RelayNetworkStatusConsensus consensus =
@@ -968,7 +968,7 @@ public class RelayNetworkStatusConsensusImplTest {
(int) consensus.getConsensusParams().get("min"));
}
- @Test()
+ @Test
public void testParamsLargestPositive()
throws DescriptorParseException {
RelayNetworkStatusConsensus consensus =
@@ -1008,7 +1008,7 @@ public class RelayNetworkStatusConsensusImplTest {
+ "D88plxd8YeLfCIVAR9gjiFlWB1WqpC53kWr350o1pzw= -1.0");
}
- @Test()
+ @Test
public void testDirSourceLegacyNickname()
throws DescriptorParseException {
DirSourceBuilder dsb = new DirSourceBuilder();
@@ -1121,7 +1121,7 @@ public class RelayNetworkStatusConsensusImplTest {
DirSourceBuilder.createWithOrPort("onions");
}
- @Test()
+ @Test
public void testDirSourceContactNoLine()
throws DescriptorParseException {
RelayNetworkStatusConsensus consensus =
@@ -1130,7 +1130,7 @@ public class RelayNetworkStatusConsensusImplTest {
"ED03BB616EB2F60BEC80151114BB25CEF515B226").getContactLine());
}
- @Test()
+ @Test
public void testDirSourceContactLineNoSpace()
throws DescriptorParseException {
RelayNetworkStatusConsensus consensus =
@@ -1139,7 +1139,7 @@ public class RelayNetworkStatusConsensusImplTest {
"ED03BB616EB2F60BEC80151114BB25CEF515B226").getContactLine());
}
- @Test()
+ @Test
public void testDirSourceContactLineOneSpace()
throws DescriptorParseException {
RelayNetworkStatusConsensus consensus =
@@ -1338,7 +1338,7 @@ public class RelayNetworkStatusConsensusImplTest {
StatusEntryBuilder.createWithDirPort("zero");
}
- @Test()
+ @Test
public void testSLineNoSpace() throws DescriptorParseException {
RelayNetworkStatusConsensus consensus =
StatusEntryBuilder.createWithSLine("s");
@@ -1346,7 +1346,7 @@ public class RelayNetworkStatusConsensusImplTest {
"00343A8024F70E214728F0C5AF7ACE0C1508F073").getFlags().isEmpty());
}
- @Test()
+ @Test
public void testSLineOneSpace() throws DescriptorParseException {
RelayNetworkStatusConsensus consensus =
StatusEntryBuilder.createWithSLine("s ");
@@ -1390,7 +1390,7 @@ public class RelayNetworkStatusConsensusImplTest {
StatusEntryBuilder.createWithWLine("w ");
}
- @Test()
+ @Test
public void testWLineWarpSeven() throws DescriptorParseException {
StatusEntryBuilder.createWithWLine("w Warp=7");
}
@@ -1406,7 +1406,7 @@ public class RelayNetworkStatusConsensusImplTest {
cb.buildConsensus(true);
}
- @Test()
+ @Test
public void testWLineUnmeasured() throws DescriptorParseException {
StatusEntryBuilder sb = new StatusEntryBuilder();
sb.wLine = "w Bandwidth=42424242 Unmeasured=1";
@@ -1420,7 +1420,7 @@ public class RelayNetworkStatusConsensusImplTest {
}
}
- @Test()
+ @Test
public void testWLineNotUnmeasured() throws DescriptorParseException {
RelayNetworkStatusConsensus consensus =
StatusEntryBuilder.createWithWLine("w Bandwidth=20");
@@ -1468,7 +1468,7 @@ public class RelayNetworkStatusConsensusImplTest {
cb.buildConsensus(true);
}
- @Test()
+ @Test
public void testNoStatusEntries() throws DescriptorParseException {
ConsensusBuilder cb = new ConsensusBuilder();
cb.statusEntries.clear();
@@ -1490,7 +1490,7 @@ public class RelayNetworkStatusConsensusImplTest {
ConsensusBuilder.createWithDirectoryFooterLine(null);
}
- @Test()
+ @Test
public void testDirectoryFooterMissing()
throws DescriptorParseException {
ConsensusBuilder cb = new ConsensusBuilder();
@@ -1502,13 +1502,13 @@ public class RelayNetworkStatusConsensusImplTest {
assertNull(consensus.getBandwidthWeights());
}
- @Test()
+ @Test
public void testDirectoryFooterLineSpace()
throws DescriptorParseException {
ConsensusBuilder.createWithDirectoryFooterLine("directory-footer ");
}
- @Test()
+ @Test
public void testBandwidthWeightsNoLine()
throws DescriptorParseException {
RelayNetworkStatusConsensus consensus =
@@ -1516,7 +1516,7 @@ public class RelayNetworkStatusConsensusImplTest {
assertNull(consensus.getBandwidthWeights());
}
- @Test()
+ @Test
public void testBandwidthWeightsLineNoSpace()
throws DescriptorParseException {
RelayNetworkStatusConsensus consensus = ConsensusBuilder
@@ -1524,7 +1524,7 @@ public class RelayNetworkStatusConsensusImplTest {
assertNotNull(consensus.getBandwidthWeights());
}
- @Test()
+ @Test
public void testBandwidthWeightsLineOneSpace()
throws DescriptorParseException {
RelayNetworkStatusConsensus consensus = ConsensusBuilder
@@ -1551,7 +1551,7 @@ public class RelayNetworkStatusConsensusImplTest {
DirectorySignatureBuilder.createWithIdentity("ED03BB616EB2F60");
}
- @Test()
+ @Test
public void testDirectorySignatureIdentityTooLong()
throws DescriptorParseException {
/* This hex string has an unusual length of 58 hex characters, but
@@ -1562,7 +1562,7 @@ public class RelayNetworkStatusConsensusImplTest {
"ED03BB616EB2F60BEC80151114BB25CEF515B226ED03BB616EB2F60BEC");
}
- @Test()
+ @Test
public void testDirectorySignatureSigningKeyTooShort()
throws DescriptorParseException {
/* See above, we accept this hex string even though it's unusually
@@ -1581,7 +1581,7 @@ public class RelayNetworkStatusConsensusImplTest {
DirectorySignatureBuilder.createWithSigningKey("845");
}
- @Test()
+ @Test
public void testDirectorySignatureSigningKeyTooLong()
throws DescriptorParseException {
/* See above, we accept this hex string even though it's unusually
@@ -1627,7 +1627,7 @@ public class RelayNetworkStatusConsensusImplTest {
true);
}
- @Test()
+ @Test
public void testUnrecognizedHeaderLineIgnore()
throws DescriptorParseException {
String unrecognizedLine = "unrecognized-line 1";
@@ -1649,7 +1649,7 @@ public class RelayNetworkStatusConsensusImplTest {
true);
}
- @Test()
+ @Test
public void testUnrecognizedDirSourceLineIgnore()
throws DescriptorParseException {
String unrecognizedLine = "unrecognized-line 1";
@@ -1671,7 +1671,7 @@ public class RelayNetworkStatusConsensusImplTest {
unrecognizedLine, true);
}
- @Test()
+ @Test
public void testUnrecognizedStatusEntryLineIgnore()
throws DescriptorParseException {
String unrecognizedLine = "unrecognized-line 1";
@@ -1693,7 +1693,7 @@ public class RelayNetworkStatusConsensusImplTest {
true);
}
- @Test()
+ @Test
public void testUnrecognizedDirectoryFooterLineIgnore()
throws DescriptorParseException {
String unrecognizedLine = "unrecognized-line 1";
@@ -1715,7 +1715,7 @@ public class RelayNetworkStatusConsensusImplTest {
unrecognizedLine, true);
}
- @Test()
+ @Test
public void testUnrecognizedDirectorySignatureLineIgnore()
throws DescriptorParseException {
String unrecognizedLine = "unrecognized-line 1";
diff --git a/src/test/java/org/torproject/descriptor/impl/RelayNetworkStatusImplTest.java b/src/test/java/org/torproject/descriptor/impl/RelayNetworkStatusImplTest.java
index efca978..e69a26b 100644
--- a/src/test/java/org/torproject/descriptor/impl/RelayNetworkStatusImplTest.java
+++ b/src/test/java/org/torproject/descriptor/impl/RelayNetworkStatusImplTest.java
@@ -52,7 +52,7 @@ public class RelayNetworkStatusImplTest {
true);
}
- @Test()
+ @Test
public void testValidHeader() throws DescriptorParseException {
byte[] statusBytes = validStatus.getBytes();
RelayNetworkStatusImpl rnsi = new RelayNetworkStatusImpl(statusBytes,
diff --git a/src/test/java/org/torproject/descriptor/impl/RelayNetworkStatusVoteImplTest.java b/src/test/java/org/torproject/descriptor/impl/RelayNetworkStatusVoteImplTest.java
index 1997c46..1152626 100644
--- a/src/test/java/org/torproject/descriptor/impl/RelayNetworkStatusVoteImplTest.java
+++ b/src/test/java/org/torproject/descriptor/impl/RelayNetworkStatusVoteImplTest.java
@@ -700,7 +700,7 @@ public class RelayNetworkStatusVoteImplTest {
}
}
- @Test()
+ @Test
public void testSampleVote() throws DescriptorParseException {
VoteBuilder vb = new VoteBuilder();
RelayNetworkStatusVote vote = vb.buildVote(true);
@@ -777,7 +777,7 @@ public class RelayNetworkStatusVoteImplTest {
"network-status-version 3\n ");
}
- @Test()
+ @Test
public void testNetworkStatusVersionPrefixLineAtChar()
throws DescriptorParseException {
VoteBuilder.createWithNetworkStatusVersionLine(
@@ -883,7 +883,7 @@ public class RelayNetworkStatusVoteImplTest {
VoteBuilder.createWithVoteStatusLine("vote-status ");
}
- @Test()
+ @Test
public void testVoteStatusVoteOneSpace()
throws DescriptorParseException {
VoteBuilder.createWithVoteStatusLine("vote-status vote ");
@@ -907,7 +907,7 @@ public class RelayNetworkStatusVoteImplTest {
"vote-status TheMagicVoteStatus");
}
- @Test()
+ @Test
public void testConsensusMethodNoLine()
throws DescriptorParseException {
RelayNetworkStatusVote vote =
@@ -1121,7 +1121,7 @@ public class RelayNetworkStatusVoteImplTest {
"recommended-client-protocols Cons=2-1");
}
- @Test()
+ @Test
public void testRecommendedRelayProtocols0()
throws DescriptorParseException {
RelayNetworkStatusVote vote =
@@ -1151,14 +1151,14 @@ public class RelayNetworkStatusVoteImplTest {
"recommended-client-protocols Cons=-1");
}
- @Test()
+ @Test
public void testPackageNone() throws DescriptorParseException {
RelayNetworkStatusVote vote =
VoteBuilder.createWithPackageLines(null);
assertNull(vote.getPackageLines());
}
- @Test()
+ @Test
public void testPackageOne() throws DescriptorParseException {
String packageLine = "package shouldbesecond 0 http digest=digest";
RelayNetworkStatusVote vote =
@@ -1167,7 +1167,7 @@ public class RelayNetworkStatusVoteImplTest {
vote.getPackageLines().get(0));
}
- @Test()
+ @Test
public void testPackageTwo() throws DescriptorParseException {
List<String> packageLines = Arrays.asList(
"package shouldbesecond 0 http digest=digest",
@@ -1212,7 +1212,7 @@ public class RelayNetworkStatusVoteImplTest {
VoteBuilder.createWithKnownFlagsLine("known-flags ");
}
- @Test()
+ @Test
public void testFlagThresholdsLine() throws DescriptorParseException {
VoteBuilder vb = new VoteBuilder();
RelayNetworkStatusVote vote = vb.buildVote(true);
@@ -1226,7 +1226,7 @@ public class RelayNetworkStatusVoteImplTest {
assertEquals(1, vote.getEnoughMtbfInfo());
}
- @Test()
+ @Test
public void testFlagThresholdsNoLine() throws DescriptorParseException {
RelayNetworkStatusVote vote =
VoteBuilder.createWithFlagThresholdsLine(null);
@@ -1240,7 +1240,7 @@ public class RelayNetworkStatusVoteImplTest {
assertEquals(-1, vote.getEnoughMtbfInfo());
}
- @Test()
+ @Test
public void testFlagThresholdsAllZeroes()
throws DescriptorParseException {
RelayNetworkStatusVote vote =
@@ -1320,7 +1320,7 @@ public class RelayNetworkStatusVoteImplTest {
+ "208.83.223.34 443 80");
}
- @Test()
+ @Test
public void testFingerprintLowerCase() throws DescriptorParseException {
VoteBuilder.createWithDirSourceLine("dir-source urras "
+ "80550987e1d626e3eba5e5e75a458de0626d088c 208.83.223.34 "
@@ -1371,7 +1371,7 @@ public class RelayNetworkStatusVoteImplTest {
+ " 208.83.223.34 208.83.223.34 443 80");
}
- @Test()
+ @Test
public void testHostname256()
throws DescriptorParseException {
/* This test doesn't fail, because we're not parsing the hostname. */
@@ -1442,7 +1442,7 @@ public class RelayNetworkStatusVoteImplTest {
+ "208.83.223.34 four-four-three 80");
}
- @Test()
+ @Test
public void testDirPort0() throws DescriptorParseException {
/* This test doesn't fail, because we're accepting DirPort 0, even
* though it doesn't make sense from Tor's view. */
@@ -1461,7 +1461,7 @@ public class RelayNetworkStatusVoteImplTest {
+ "208.83.223.34 443 ");
}
- @Test()
+ @Test
public void testDirPortOrPortIdentical()
throws DescriptorParseException {
/* This test doesn't fail, even though identical OR and Dir port don't
@@ -1493,7 +1493,7 @@ public class RelayNetworkStatusVoteImplTest {
+ "208.83.223.34 443 80");
}
- @Test()
+ @Test
public void testContactLineMissing()
throws DescriptorParseException {
VoteBuilder.createWithContactLine(null);
@@ -1530,7 +1530,7 @@ public class RelayNetworkStatusVoteImplTest {
"shared-rand-participate 1");
}
- @Test()
+ @Test
public void testSharedRandCommitLinesEmpty() throws DescriptorParseException {
RelayNetworkStatusVote vote =
VoteBuilder.createWithSharedRandCommitLines(null);
@@ -1559,7 +1559,7 @@ public class RelayNetworkStatusVoteImplTest {
+ "D88plxd8YeLfCIVAR9gjiFlWB1WqpC53kWr350o1pzw=");
}
- @Test()
+ @Test
public void testLegacyDirKeyLine() throws DescriptorParseException {
RelayNetworkStatusVote vote = VoteBuilder.createWithLegacyDirKeyLine(
"legacy-dir-key 81349FC1F2DBA2C2C11B45CB9706637D480AB913");
@@ -1710,7 +1710,7 @@ public class RelayNetworkStatusVoteImplTest {
VoteBuilder.createWithDirSigningKeyLines(null);
}
- @Test()
+ @Test
public void testDirKeyCrosscertLinesMissing()
throws DescriptorParseException {
VoteBuilder.createWithDirKeyCrosscertLines(null);
@@ -1725,7 +1725,7 @@ public class RelayNetworkStatusVoteImplTest {
VoteBuilder.createWithDirKeyCertificationLines(null);
}
- @Test()
+ @Test
public void testDirectoryFooterLineMissing()
throws DescriptorParseException {
VoteBuilder.createWithDirectoryFooterLine(null);
@@ -1740,7 +1740,7 @@ public class RelayNetworkStatusVoteImplTest {
VoteBuilder.createWithDirectorySignatureLines(null);
}
- @Test()
+ @Test
public void testDirectorySignaturesLinesTwoAlgorithms()
throws DescriptorParseException {
String identitySha256 = "32519E5CB7254AB5A94CC9925EC7676E53D5D52EEAB7"
@@ -1785,7 +1785,7 @@ public class RelayNetworkStatusVoteImplTest {
vote.getDigestSha1Hex());
}
- @Test()
+ @Test
public void testDirectorySignaturesLinesTwoAlgorithmsSameDigests()
throws DescriptorParseException {
String signaturesLines = "directory-signature 00 00\n"
@@ -1807,7 +1807,7 @@ public class RelayNetworkStatusVoteImplTest {
VoteBuilder.createWithUnrecognizedHeaderLine(unrecognizedLine, true);
}
- @Test()
+ @Test
public void testUnrecognizedHeaderLineIgnore()
throws DescriptorParseException {
String unrecognizedLine = "unrecognized-line 1";
@@ -1829,7 +1829,7 @@ public class RelayNetworkStatusVoteImplTest {
true);
}
- @Test()
+ @Test
public void testUnrecognizedDirSourceLineIgnore()
throws DescriptorParseException {
String unrecognizedLine = "unrecognized-line 1";
@@ -1850,7 +1850,7 @@ public class RelayNetworkStatusVoteImplTest {
VoteBuilder.createWithUnrecognizedFooterLine(unrecognizedLine, true);
}
- @Test()
+ @Test
public void testUnrecognizedFooterLineIgnore()
throws DescriptorParseException {
String unrecognizedLine = "unrecognized-line 1";
@@ -1861,7 +1861,7 @@ public class RelayNetworkStatusVoteImplTest {
assertEquals(unrecognizedLines, vote.getUnrecognizedLines());
}
- @Test()
+ @Test
public void testIdEd25519MasterKey()
throws DescriptorParseException {
String masterKey25519 = "8RH34kO07Pp+XYwzdoATVyCibIvmbslUjRkAm7J4IA8";
@@ -1877,7 +1877,7 @@ public class RelayNetworkStatusVoteImplTest {
vote.getStatusEntry(fingerprint).getMasterKeyEd25519());
}
- @Test()
+ @Test
public void testIdEd25519None()
throws DescriptorParseException {
List<String> statusEntries = new ArrayList<>();
diff --git a/src/test/java/org/torproject/descriptor/impl/ServerDescriptorImplTest.java b/src/test/java/org/torproject/descriptor/impl/ServerDescriptorImplTest.java
index 70a25a0..9533de3 100644
--- a/src/test/java/org/torproject/descriptor/impl/ServerDescriptorImplTest.java
+++ b/src/test/java/org/torproject/descriptor/impl/ServerDescriptorImplTest.java
@@ -461,7 +461,7 @@ public class ServerDescriptorImplTest {
}
}
- @Test()
+ @Test
public void testSampleDescriptor() throws DescriptorParseException {
DescriptorBuilder db = new DescriptorBuilder();
ServerDescriptor descriptor = db.buildDescriptor(true);
@@ -513,7 +513,7 @@ public class ServerDescriptorImplTest {
DescriptorBuilder.createWithRouterLine(null);
}
- @Test()
+ @Test
public void testRouterOpt() throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder
.createWithRouterLine("opt router saberrider2008 "
@@ -562,7 +562,7 @@ public class ServerDescriptorImplTest {
+ "saberrider2008ReallyLongNickname 94.134.192.243 9001 0 0");
}
- @Test()
+ @Test
public void testNicknameTwoSpaces() throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder
.createWithRouterLine("router saberrider2008 "
@@ -643,14 +643,14 @@ public class ServerDescriptorImplTest {
+ "94.134.192.243 9001 0 ");
}
- @Test()
+ @Test
public void testPlatformMissing() throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder
.createWithPlatformLine(null);
assertNull(descriptor.getPlatform());
}
- @Test()
+ @Test
public void testPlatformOpt() throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder
.createWithPlatformLine("opt platform Tor 0.2.2.35 "
@@ -659,21 +659,21 @@ public class ServerDescriptorImplTest {
descriptor.getPlatform());
}
- @Test()
+ @Test
public void testPlatformNoSpace() throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder
.createWithPlatformLine("platform");
assertEquals("", descriptor.getPlatform());
}
- @Test()
+ @Test
public void testPlatformSpace() throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder
.createWithPlatformLine("platform ");
assertEquals("", descriptor.getPlatform());
}
- @Test()
+ @Test
public void testProtocolsOpt() throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder
.createWithProtocolsLine("opt protocols Link 1 2 Circuit 1");
@@ -683,7 +683,7 @@ public class ServerDescriptorImplTest {
descriptor.getCircuitProtocolVersions());
}
- @Test()
+ @Test
public void testProtocolsNoOpt() throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder
.createWithProtocolsLine("protocols Link 1 2 Circuit 1");
@@ -710,7 +710,7 @@ public class ServerDescriptorImplTest {
DescriptorBuilder.createWithProtocolsLine("opt protocols Link 1 2");
}
- @Test()
+ @Test
public void testProtoGreenPurple() throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder
.createWithProtoLine("proto Green=23 Purple=42");
@@ -735,7 +735,7 @@ public class ServerDescriptorImplTest {
DescriptorBuilder.createWithPublishedLine(null);
}
- @Test()
+ @Test
public void testPublishedOpt() throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder
.createWithPublishedLine("opt published 2012-01-01 04:03:19");
@@ -777,14 +777,14 @@ public class ServerDescriptorImplTest {
DescriptorBuilder.createWithPublishedLine("published 2012-01-01");
}
- @Test()
+ @Test
public void testPublishedMillis() throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder
.createWithPublishedLine("opt published 2012-01-01 04:03:19.123");
assertEquals(1325390599000L, descriptor.getPublishedMillis());
}
- @Test()
+ @Test
public void testFingerprintNoOpt() throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder
.createWithFingerprintLine("fingerprint D873 3048 FC8E C910 2466 "
@@ -829,14 +829,14 @@ public class ServerDescriptorImplTest {
+ "D8733048FC8EC9102466AD8F3098622BF1BF71FD");
}
- @Test()
+ @Test
public void testUptimeMissing() throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder
.createWithUptimeLine(null);
assertNull(descriptor.getUptime());
}
- @Test()
+ @Test
public void testUptimeOpt() throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder
.createWithUptimeLine("opt uptime 48");
@@ -850,7 +850,7 @@ public class ServerDescriptorImplTest {
DescriptorBuilder.createWithUptimeLine("uptime fourty-eight");
}
- @Test()
+ @Test
public void testUptimeMinusOne() throws DescriptorParseException {
DescriptorBuilder.createWithUptimeLine("uptime -1");
}
@@ -876,7 +876,7 @@ public class ServerDescriptorImplTest {
DescriptorBuilder.createWithUptimeLine("uptime 4 8");
}
- @Test()
+ @Test
public void testBandwidthOpt() throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder
.createWithBandwidthLine("opt bandwidth 51200 51200 53470");
@@ -901,7 +901,7 @@ public class ServerDescriptorImplTest {
DescriptorBuilder.createWithBandwidthLine("bandwidth 51200");
}
- @Test()
+ @Test
public void testBandwidthTwoValues() throws DescriptorParseException {
/* This is allowed, because Tor versions 0.0.8 and older only wrote
* bandwidth lines with rate and burst values, but no observed
@@ -930,7 +930,7 @@ public class ServerDescriptorImplTest {
DescriptorBuilder.createWithBandwidthLine("bandwidth -1 -2 -3");
}
- @Test()
+ @Test
public void testExtraInfoDigestNoOpt() throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder
.createWithExtraInfoDigestLine("extra-info-digest "
@@ -969,7 +969,7 @@ public class ServerDescriptorImplTest {
+ "1469D1550738A25B1E7B47CDDBCD7B2899F51B741469");
}
- @Test()
+ @Test
public void testExtraInfoDigestMissing()
throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder
@@ -977,7 +977,7 @@ public class ServerDescriptorImplTest {
assertNull(descriptor.getExtraInfoDigestSha1Hex());
}
- @Test()
+ @Test
public void testExtraInfoDigestAdditionalDigest()
throws DescriptorParseException {
String extraInfoDigest = "0879DB7B765218D7B3AE7557669D20307BB21CAA";
@@ -990,7 +990,7 @@ public class ServerDescriptorImplTest {
assertEquals(extraInfoDigest, descriptor.getExtraInfoDigestSha1Hex());
}
- @Test()
+ @Test
public void testOnionKeyOpt() throws DescriptorParseException {
DescriptorBuilder.createWithOnionKeyLines("opt onion-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
@@ -1001,7 +1001,7 @@ public class ServerDescriptorImplTest {
+ "-----END RSA PUBLIC KEY-----");
}
- @Test()
+ @Test
public void testSigningKeyOpt() throws DescriptorParseException {
DescriptorBuilder.createWithSigningKeyLines("opt signing-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
@@ -1012,7 +1012,7 @@ public class ServerDescriptorImplTest {
+ "-----END RSA PUBLIC KEY-----");
}
- @Test()
+ @Test
public void testHiddenServiceDirMissing()
throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder
@@ -1020,7 +1020,7 @@ public class ServerDescriptorImplTest {
assertNull(descriptor.getHiddenServiceDirVersions());
}
- @Test()
+ @Test
public void testHiddenServiceDirNoOpt()
throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder
@@ -1029,7 +1029,7 @@ public class ServerDescriptorImplTest {
descriptor.getHiddenServiceDirVersions());
}
- @Test()
+ @Test
public void testHiddenServiceDirVersions2And3()
throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder
@@ -1038,14 +1038,14 @@ public class ServerDescriptorImplTest {
descriptor.getHiddenServiceDirVersions());
}
- @Test()
+ @Test
public void testContactMissing() throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder
.createWithContactLine(null);
assertNull(descriptor.getContact());
}
- @Test()
+ @Test
public void testContactOpt() throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder
.createWithContactLine("opt contact Random Person");
@@ -1061,14 +1061,14 @@ public class ServerDescriptorImplTest {
+ "Person\ncontact Random Person");
}
- @Test()
+ @Test
public void testContactNoSpace() throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder
.createWithContactLine("contact");
assertEquals("", descriptor.getContact());
}
- @Test()
+ @Test
public void testContactCarriageReturn()
throws DescriptorParseException {
String contactString = "Random "
@@ -1083,7 +1083,7 @@ public class ServerDescriptorImplTest {
assertEquals(contactString, descriptor.getContact());
}
- @Test()
+ @Test
public void testExitPolicyRejectAllAcceptAll()
throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder
@@ -1092,7 +1092,7 @@ public class ServerDescriptorImplTest {
descriptor.getExitPolicyLines());
}
- @Test()
+ @Test
public void testExitPolicyOpt() throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder
.createWithExitPolicyLines("opt reject *:*");
@@ -1108,7 +1108,7 @@ public class ServerDescriptorImplTest {
DescriptorBuilder.createWithExitPolicyLines("reject *");
}
- @Test()
+ @Test
public void testExitPolicyAccept80RejectAll()
throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder
@@ -1151,7 +1151,7 @@ public class ServerDescriptorImplTest {
DescriptorBuilder.createWithExitPolicyLines(null);
}
- @Test()
+ @Test
public void testExitPolicyMaskTypes() throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder
.createWithExitPolicyLines("reject 192.168.0.0/16:*\n"
@@ -1185,21 +1185,21 @@ public class ServerDescriptorImplTest {
+ "-----END SIGNATURE-----\ncontact me");
}
- @Test()
+ @Test
public void testHibernatingOpt() throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder
.createWithHibernatingLine("opt hibernating 1");
assertTrue(descriptor.isHibernating());
}
- @Test()
+ @Test
public void testHibernatingFalse() throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder
.createWithHibernatingLine("hibernating 0");
assertFalse(descriptor.isHibernating());
}
- @Test()
+ @Test
public void testHibernatingTrue() throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder
.createWithHibernatingLine("hibernating 1");
@@ -1220,7 +1220,7 @@ public class ServerDescriptorImplTest {
DescriptorBuilder.createWithHibernatingLine("hibernating");
}
- @Test()
+ @Test
public void testFamilyOpt() throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder
.createWithFamilyLine("opt family saberrider2008");
@@ -1228,7 +1228,7 @@ public class ServerDescriptorImplTest {
descriptor.getFamilyEntries());
}
- @Test()
+ @Test
public void testFamilyFingerprint() throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder
.createWithFamilyLine("family "
@@ -1238,7 +1238,7 @@ public class ServerDescriptorImplTest {
descriptor.getFamilyEntries());
}
- @Test()
+ @Test
public void testFamilyNickname() throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder
.createWithFamilyLine("family saberrider2008");
@@ -1273,7 +1273,7 @@ public class ServerDescriptorImplTest {
+ "D8733048FC8EC9102466AD8F3098622BF1BF71FD");
}
- @Test()
+ @Test
public void testFamilyFingerprintNicknameNamed()
throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder
@@ -1284,7 +1284,7 @@ public class ServerDescriptorImplTest {
descriptor.getFamilyEntries());
}
- @Test()
+ @Test
public void testFamilyFingerprintNicknameUnnamed()
throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder
@@ -1295,7 +1295,7 @@ public class ServerDescriptorImplTest {
descriptor.getFamilyEntries());
}
- @Test()
+ @Test
public void testWriteHistory() throws DescriptorParseException {
String writeHistoryLine = "write-history 2012-01-01 03:51:44 (900 s) "
+ "4345856,261120,7591936,1748992";
@@ -1316,7 +1316,7 @@ public class ServerDescriptorImplTest {
assertTrue(bandwidthValues.isEmpty());
}
- @Test()
+ @Test
public void testWriteHistoryOpt() throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder
.createWithWriteHistoryLine("opt write-history 2012-01-01 "
@@ -1386,7 +1386,7 @@ public class ServerDescriptorImplTest {
+ "2012-01-01 03:51:44 (900 s) one,two,three");
}
- @Test()
+ @Test
public void testWriteHistoryNoValuesSpace()
throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder
@@ -1398,7 +1398,7 @@ public class ServerDescriptorImplTest {
.isEmpty());
}
- @Test()
+ @Test
public void testWriteHistoryNoValuesNoSpace()
throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder
@@ -1419,14 +1419,14 @@ public class ServerDescriptorImplTest {
"write-history 2012-01-01 03:51:44 (900 ");
}
- @Test()
+ @Test
public void testWriteHistoryExtraArg()
throws DescriptorParseException {
DescriptorBuilder.createWithWriteHistoryLine("write-history "
+ "2012-01-01 03:51:44 (900 s) 4345856 bin_size=1024");
}
- @Test()
+ @Test
public void testWriteHistory1800Seconds()
throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder
@@ -1436,7 +1436,7 @@ public class ServerDescriptorImplTest {
.getIntervalLength());
}
- @Test()
+ @Test
public void testReadHistory() throws DescriptorParseException {
String readHistoryLine = "read-history 2012-01-01 03:51:44 (900 s) "
+ "4268032,139264,7797760,1415168";
@@ -1457,7 +1457,7 @@ public class ServerDescriptorImplTest {
assertTrue(bandwidthValues.isEmpty());
}
- @Test()
+ @Test
public void testReadHistoryTwoSpaces() throws DescriptorParseException {
/* There are some server descriptors from older Tor versions that
* contain "opt read-history " lines. */
@@ -1466,21 +1466,21 @@ public class ServerDescriptorImplTest {
DescriptorBuilder.createWithReadHistoryLine(readHistoryLine);
}
- @Test()
+ @Test
public void testEventdnsOpt() throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder
.createWithEventdnsLine("opt eventdns 1");
assertTrue(descriptor.getUsesEnhancedDnsLogic());
}
- @Test()
+ @Test
public void testEventdns1() throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder
.createWithEventdnsLine("eventdns 1");
assertTrue(descriptor.getUsesEnhancedDnsLogic());
}
- @Test()
+ @Test
public void testEventdns0() throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder
.createWithEventdnsLine("eventdns 0");
@@ -1501,14 +1501,14 @@ public class ServerDescriptorImplTest {
DescriptorBuilder.createWithEventdnsLine("eventdns no");
}
- @Test()
+ @Test
public void testCachesExtraInfoOpt() throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder
.createWithCachesExtraInfoLine("opt caches-extra-info");
assertTrue(descriptor.getCachesExtraInfo());
}
- @Test()
+ @Test
public void testCachesExtraInfoNoSpace()
throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder
@@ -1524,7 +1524,7 @@ public class ServerDescriptorImplTest {
+ "true");
}
- @Test()
+ @Test
public void testAllowSingleHopExitsOpt()
throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder
@@ -1532,7 +1532,7 @@ public class ServerDescriptorImplTest {
assertTrue(descriptor.getAllowSingleHopExits());
}
- @Test()
+ @Test
public void testAllowSingleHopExitsNoSpace()
throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder
@@ -1565,7 +1565,7 @@ public class ServerDescriptorImplTest {
false);
}
- @Test()
+ @Test
public void testIpv6PolicyLine() throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder
.createWithIpv6PolicyLine("ipv6-policy accept 80,1194,1220,1293");
@@ -1615,7 +1615,7 @@ public class ServerDescriptorImplTest {
+ "ipv6-policy accept 80,1194,1220,1293");
}
- @Test()
+ @Test
public void testNtorOnionKeyLine() throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder
.createWithNtorOnionKeyLine("ntor-onion-key "
@@ -1624,7 +1624,7 @@ public class ServerDescriptorImplTest {
descriptor.getNtorOnionKey());
}
- @Test()
+ @Test
public void testNtorOnionKeyLineNoPadding()
throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder
@@ -1663,7 +1663,7 @@ public class ServerDescriptorImplTest {
+ "Y/XgaHcPIJVa4D55kir9QLH8rEYAaLXuv3c3sm8jYhY\n");
}
- @Test()
+ @Test
public void testTunnelledDirServerTrue()
throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder
@@ -1671,7 +1671,7 @@ public class ServerDescriptorImplTest {
assertTrue(descriptor.getTunnelledDirServer());
}
- @Test()
+ @Test
public void testTunnelledDirServerFalse()
throws DescriptorParseException {
ServerDescriptor descriptor = DescriptorBuilder
@@ -1718,7 +1718,7 @@ public class ServerDescriptorImplTest {
DescriptorBuilder.createWithUnrecognizedLine(unrecognizedLine, true);
}
- @Test()
+ @Test
public void testUnrecognizedLineIgnore()
throws DescriptorParseException {
String unrecognizedLine = "unrecognized-line 1";
@@ -1729,7 +1729,7 @@ public class ServerDescriptorImplTest {
assertEquals(unrecognizedLines, descriptor.getUnrecognizedLines());
}
- @Test()
+ @Test
public void testSomeOtherKey() throws DescriptorParseException {
List<String> unrecognizedLines = new ArrayList<>();
unrecognizedLines.add("some-other-key");
@@ -1750,7 +1750,7 @@ public class ServerDescriptorImplTest {
assertEquals(unrecognizedLines, descriptor.getUnrecognizedLines());
}
- @Test()
+ @Test
public void testUnrecognizedCryptoBlockNoKeyword()
throws DescriptorParseException {
List<String> unrecognizedLines = new ArrayList<>();
@@ -1787,7 +1787,7 @@ public class ServerDescriptorImplTest {
"router-sig-ed25519 y7WF9T2GFwkSDPZEhB55HgquIFOl5uXUFMYJPq3CXXUTKeJ"
+ "kSrtaZUB5s34fWdHQNtl84mH4dVaFMunHnwgYAw";
- @Test()
+ @Test
public void testEd25519() throws DescriptorParseException {
ServerDescriptor descriptor =
DescriptorBuilder.createWithEd25519Lines(IDENTITY_ED25519_LINES,
@@ -1814,7 +1814,7 @@ public class ServerDescriptorImplTest {
ROUTER_SIG_ED25519_LINE);
}
- @Test()
+ @Test
public void testEd25519IdentityMissing()
throws DescriptorParseException {
DescriptorBuilder.createWithEd25519Lines(null,
@@ -1843,7 +1843,7 @@ public class ServerDescriptorImplTest {
MASTER_KEY_ED25519_LINE, ROUTER_SIG_ED25519_LINE);
}
- @Test()
+ @Test
public void testEd25519MasterKeyMissing()
throws DescriptorParseException {
ServerDescriptor descriptor =
@@ -1865,7 +1865,7 @@ public class ServerDescriptorImplTest {
ROUTER_SIG_ED25519_LINE);
}
- @Test()
+ @Test
public void testEd25519RouterSigMissing()
throws DescriptorParseException {
DescriptorBuilder.createWithEd25519Lines(IDENTITY_ED25519_LINES,
@@ -1910,7 +1910,7 @@ public class ServerDescriptorImplTest {
+ "Ka\nErPtMuiEqAc=\n"
+ "-----END ED25519 CERT-----";
- @Test()
+ @Test
public void testOnionKeyCrosscert() throws DescriptorParseException {
ServerDescriptor descriptor =
DescriptorBuilder.createWithOnionKeyCrosscertLines(
@@ -1930,7 +1930,7 @@ public class ServerDescriptorImplTest {
ONION_KEY_CROSSCERT_LINES + "\n" + ONION_KEY_CROSSCERT_LINES);
}
- @Test()
+ @Test
public void testNtorOnionKeyCrosscert()
throws DescriptorParseException {
ServerDescriptor descriptor =
@@ -1953,7 +1953,7 @@ public class ServerDescriptorImplTest {
+ NTOR_ONION_KEY_CROSSCERT_LINES);
}
- @Test()
+ @Test
public void testBridgeDescriptorDigestsRouterDigestLines()
throws DescriptorParseException {
DescriptorBuilder db = new DescriptorBuilder();
@@ -1968,7 +1968,7 @@ public class ServerDescriptorImplTest {
assertEquals(digestSha256Base64, descriptor.getDigestSha256Base64());
}
- @Test()
+ @Test
public void testBridgeDescriptorDigestsNoRouterDigestLines()
throws DescriptorParseException {
DescriptorBuilder db = new DescriptorBuilder();
diff --git a/src/test/java/org/torproject/descriptor/impl/TorperfResultImplTest.java b/src/test/java/org/torproject/descriptor/impl/TorperfResultImplTest.java
index 640b8a3..122e301 100644
--- a/src/test/java/org/torproject/descriptor/impl/TorperfResultImplTest.java
+++ b/src/test/java/org/torproject/descriptor/impl/TorperfResultImplTest.java
@@ -16,7 +16,7 @@ import java.util.List;
public class TorperfResultImplTest {
- @Test()
+ @Test
public void testAnnotatedInput() throws Exception {
TorperfResultImpl result = (TorperfResultImpl)
(TorperfResultImpl.parseTorperfResults((torperfAnnotation + input)
@@ -32,7 +32,7 @@ public class TorperfResultImplTest {
}
}
- @Test()
+ @Test
public void testPartiallyAnnotatedInput() throws Exception {
byte[] asciiBytes = (torperfAnnotation
+ input + input + input).getBytes("US-ASCII");
@@ -47,7 +47,7 @@ public class TorperfResultImplTest {
((TorperfResultImpl)(result.get(2))).getAnnotations().size());
}
- @Test()
+ @Test
public void testAllAnnotatedInput() throws Exception {
byte[] asciiBytes = (torperfAnnotation + input
+ torperfAnnotation + input
@@ -87,7 +87,7 @@ public class TorperfResultImplTest {
+ "SOCKET=1441065601.86 SOURCE=moria START=1441065601.86 "
+ "TIMEOUT=1500 USED_AT=1441065603.40 USED_BY=2475 WRITEBYTES=75\n";
- @Test()
+ @Test
public void testDatapercNonNumeric() throws Exception {
List<Descriptor> result = TorperfResultImpl.parseTorperfResults(
("DATAPERMILLE=2.0 " + input).getBytes(), false);
@@ -121,7 +121,7 @@ public class TorperfResultImplTest {
+ "START=1493397365.14 TIMEOUT=1500 USED_AT=1493397368.14 "
+ "USED_BY=17429 WRITEBYTES=54";
- @Test()
+ @Test
public void testEndpointsHostnamesSourceAddress()
throws DescriptorParseException {
List<Descriptor> result = TorperfResultImpl.parseTorperfResults(
diff --git a/src/test/java/org/torproject/descriptor/index/DescriptorIndexCollectorTest.java b/src/test/java/org/torproject/descriptor/index/DescriptorIndexCollectorTest.java
index 142d883..d7f602f 100644
--- a/src/test/java/org/torproject/descriptor/index/DescriptorIndexCollectorTest.java
+++ b/src/test/java/org/torproject/descriptor/index/DescriptorIndexCollectorTest.java
@@ -32,7 +32,7 @@ public class DescriptorIndexCollectorTest {
@Rule
public TemporaryFolder tmpf = new TemporaryFolder();
- @Test()
+ @Test
public void testNormalCollecting() throws Exception {
// create local file structure
File localFolder = tmpf.newFolder();
@@ -135,7 +135,7 @@ public class DescriptorIndexCollectorTest {
return indexFile;
}
- @Test()
+ @Test
public void testNormalCollectingWithDeletion() throws Exception {
File localFolder = tmpf.newFolder();
makeStructure(localFolder, "1");
@@ -176,7 +176,7 @@ public class DescriptorIndexCollectorTest {
"a/b/x1", "a/b/y1", "a/b/c/w1", "a/b/c/z1", "a/b/c/u1");
}
- @Test()
+ @Test
public void testSlashesInCollectionWithDeletion() throws Exception {
File localFolder = tmpf.newFolder();
makeStructure(localFolder, "1");
@@ -218,7 +218,7 @@ public class DescriptorIndexCollectorTest {
"a/b/x1", "a/b/y1", "a/b/c/w1", "a/b/c/z1", "a/b/c/u1");
}
- @Test()
+ @Test
public void testNormalStatLocalDirectory() throws IOException {
// create local file structure
File dir = tmpf.newFolder();
@@ -243,7 +243,7 @@ public class DescriptorIndexCollectorTest {
assertEquals("found " + res, 1, res.size());
}
- @Test()
+ @Test
public void testWrongInputStatLocalDirectory() throws IOException {
File dir = makeDirs(tmpf.newFolder().toString(), "a", "b");
SortedMap<String, Long> res = DescriptorIndexCollector
@@ -254,7 +254,7 @@ public class DescriptorIndexCollectorTest {
assertTrue("found " + res, res.isEmpty());
}
- @Test()
+ @Test
public void testMinimalArgs() throws IOException {
File fakeDir = tmpf.newFolder("fantasy-dir");
new DescriptorIndexCollector()
@@ -281,7 +281,7 @@ public class DescriptorIndexCollectorTest {
null, new String[]{}, 100L, null, false);
}
- @Test()
+ @Test
public void testExistingDir() throws IOException {
File dir = tmpf.newFolder();
dir.setWritable(false);
diff --git a/src/test/java/org/torproject/descriptor/index/DirectoryNodeTest.java b/src/test/java/org/torproject/descriptor/index/DirectoryNodeTest.java
index 1fa5f83..c98abb8 100644
--- a/src/test/java/org/torproject/descriptor/index/DirectoryNodeTest.java
+++ b/src/test/java/org/torproject/descriptor/index/DirectoryNodeTest.java
@@ -13,7 +13,7 @@ import java.util.TreeSet;
public class DirectoryNodeTest {
- @Test()
+ @Test
public void testCompare() {
DirectoryNode dn1 = new DirectoryNode("a1", null, null);
DirectoryNode dn2 = new DirectoryNode("a2", null,
@@ -25,7 +25,7 @@ public class DirectoryNodeTest {
assertEquals(1, dn2.compareTo(dn3));
}
- @Test()
+ @Test
public void testFind() {
FileNode fnx = new FileNode("x", 0L, "2000-01-01 01:01");
SortedSet<FileNode> fm = new TreeSet<>();
diff --git a/src/test/java/org/torproject/descriptor/index/FileNodeTest.java b/src/test/java/org/torproject/descriptor/index/FileNodeTest.java
index 59b66a6..5af89ff 100644
--- a/src/test/java/org/torproject/descriptor/index/FileNodeTest.java
+++ b/src/test/java/org/torproject/descriptor/index/FileNodeTest.java
@@ -9,7 +9,7 @@ import org.junit.Test;
public class FileNodeTest {
- @Test()
+ @Test
public void testCompare() {
FileNode fn1 = new FileNode("a1", 1L, "2016-01-01 01:01");
FileNode fn2 = new FileNode("a2", 1L, "2016-01-01 02:02");
diff --git a/src/test/java/org/torproject/descriptor/index/IndexNodeTest.java b/src/test/java/org/torproject/descriptor/index/IndexNodeTest.java
index e1d36b2..f1e044c 100644
--- a/src/test/java/org/torproject/descriptor/index/IndexNodeTest.java
+++ b/src/test/java/org/torproject/descriptor/index/IndexNodeTest.java
@@ -24,7 +24,7 @@ public class IndexNodeTest {
@Rule
public TemporaryFolder tmpf = new TemporaryFolder();
- @Test()
+ @Test
public void testSimpleIndexRead() throws Exception {
URL indexUrl = getClass().getClassLoader().getResource("index1.json");
IndexNode index = IndexNode.fetchIndex(indexUrl.toString());
@@ -33,7 +33,7 @@ public class IndexNodeTest {
/* toString is only used for debugging. Simply ensure that paths,
* file names, and urls are readable. */
- @Test()
+ @Test
public void testToString() throws Exception {
URL indexUrl = getClass().getClassLoader().getResource("index1.json");
IndexNode index = IndexNode.fetchIndex(indexUrl.toString());
@@ -57,7 +57,7 @@ public class IndexNodeTest {
index.directories.first().directories.first().files.last().path);
}
- @Test()
+ @Test
public void testCompressedIndexRead() throws Exception {
for (String fileName : new String[] {"index1.json.xz", "index1.json.bz2",
"index1.json.gz"}) {
@@ -67,7 +67,7 @@ public class IndexNodeTest {
}
}
- @Test()
+ @Test
public void testIndexWrite() throws Exception {
for (String fileName : new String[] {
"test.json", "test.json.bz2", "test.json.gz", "test.json.xz"}) {
@@ -86,7 +86,7 @@ public class IndexNodeTest {
assertEquals("Comparing to " + oldPath, oldJson, newJson);
}
- @Test()
+ @Test
public void testRetrieveFiles() throws Exception {
URL indexUrl = getClass().getClassLoader().getResource("index2.json");
IndexNode index = IndexNode.fetchIndex(indexUrl.toString());
@@ -120,7 +120,7 @@ public class IndexNodeTest {
IndexNode.fetchIndex(indexUrl.openStream());
}
- @Test()
+ @Test
public void testRetrieveEmpty() throws Exception {
URL indexUrl = getClass().getClassLoader().getResource("index1.json");
IndexNode index = IndexNode.fetchIndex(indexUrl.toString());
1
0
commit 569795e282abe2ea33a20289b77033ab7f2a0068
Author: Karsten Loesing <karsten.loesing(a)gmx.net>
Date: Thu Jun 8 16:00:34 2017 +0200
Bump version to 1.8.1-dev.
---
CHANGELOG.md | 3 +++
build.xml | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 23259fc..44420bf 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,6 @@
+# Changes in version 1.9.0 - 2017-06-??
+
+
# Changes in version 1.8.1 - 2017-06-08
* Medium changes
diff --git a/build.xml b/build.xml
index cc58705..1ed53ec 100644
--- a/build.xml
+++ b/build.xml
@@ -6,7 +6,7 @@
<project default="usage" name="descriptor" basedir=".">
- <property name="release.version" value="1.8.1" />
+ <property name="release.version" value="1.8.1-dev" />
<property name="javadoc-title" value="DescripTor API Documentation"/>
<property name="javadoc-excludes" value="**/impl/** **/index/**" />
<property name="implementation-title" value="DescripTor" />
1
0

[metrics-lib/release] Make DescriptorParserImpl.parseDescriptor easily accessible for testing.
by karsten@torproject.org 16 Jun '17
by karsten@torproject.org 16 Jun '17
16 Jun '17
commit 5954b344628d628bab62e54f95fbd62ee3910f66
Author: iwakeh <iwakeh(a)torproject.org>
Date: Fri Jun 16 12:55:34 2017 +0000
Make DescriptorParserImpl.parseDescriptor easily accessible for testing.
---
src/main/java/org/torproject/descriptor/impl/DescriptorParserImpl.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/java/org/torproject/descriptor/impl/DescriptorParserImpl.java b/src/main/java/org/torproject/descriptor/impl/DescriptorParserImpl.java
index ad0d512..e416d93 100644
--- a/src/main/java/org/torproject/descriptor/impl/DescriptorParserImpl.java
+++ b/src/main/java/org/torproject/descriptor/impl/DescriptorParserImpl.java
@@ -188,7 +188,7 @@ public class DescriptorParserImpl implements DescriptorParser {
return parsedDescriptors;
}
- private static Descriptor parseDescriptor(byte[] rawDescriptorBytes,
+ static Descriptor parseDescriptor(byte[] rawDescriptorBytes,
int[] offsetAndLength, Constructor<? extends DescriptorImpl> constructor,
boolean failUnrecognizedDescriptorLines)
throws DescriptorParseException {
1
0
commit 3affad3f8877b1e907ba9e04b0020e4b7cc86023
Author: iwakeh <iwakeh(a)torproject.org>
Date: Fri Jun 16 12:55:35 2017 +0000
Add test for task-22634.
---
.../descriptor/impl/DescriptorParserImplTest.java | 75 ++++++++++++++++++++++
.../descriptor/impl/TestServerDescriptor.java | 17 +++++
2 files changed, 92 insertions(+)
diff --git a/src/test/java/org/torproject/descriptor/impl/DescriptorParserImplTest.java b/src/test/java/org/torproject/descriptor/impl/DescriptorParserImplTest.java
index ef21ce6..5a328ec 100644
--- a/src/test/java/org/torproject/descriptor/impl/DescriptorParserImplTest.java
+++ b/src/test/java/org/torproject/descriptor/impl/DescriptorParserImplTest.java
@@ -5,10 +5,14 @@ package org.torproject.descriptor.impl;
import static org.junit.Assert.assertEquals;
+import org.torproject.descriptor.DescriptorParseException;
+
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
+import java.lang.reflect.Constructor;
+
public class DescriptorParserImplTest {
@Rule
@@ -37,5 +41,76 @@ public class DescriptorParserImplTest {
dpi.parseDescriptors(des.getRawDescriptorBytes(), "dummy.file").size());
}
+ @Test
+ public void testParseDescriptor() throws DescriptorParseException {
+ Constructor<? extends DescriptorImpl> constructor;
+ try {
+ constructor = TestServerDescriptor.class
+ .getDeclaredConstructor(byte[].class, int[].class, boolean.class);
+ } catch (NoSuchMethodException e) {
+ throw new RuntimeException(e);
+ }
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("'176x.158.53.63' in line 'router UbuntuCore169 "
+ + "176x.158.53.63 44583 0 0' is not a valid IPv4 address.");
+ DescriptorParserImpl.parseDescriptor(DEFECT.getBytes(),
+ new int[]{0, DEFECT.getBytes().length}, constructor, false);
+ }
+
+ private static final String DEFECT =
+ "@type server-descriptor 1.0\n"
+ + "router UbuntuCore169 176x.158.53.63 44583 0 0\n"
+ + "identity-ed25519\n"
+ + "-----BEGIN ED25519 CERT-----\n"
+ + "AQQABleiAZ2Ce5QY1oSL0F79WeaPhL/zWomAVJG1vwTioPBkpeG7AQAgBABF3iK6\n"
+ + "clXuNv2ZbfNSbmrJkKRLKsC41BZAVs1BSWQndRMNDsZJ/s6GmOd5IiU6axR5z2Nn\n"
+ + "XTUR0TMGOc5KNJHqKi9Ht+iSIH02OeV1Gm/PNfos7KBKSJJROme1YQQsvwQ=\n"
+ + "-----END ED25519 CERT-----\n"
+ + "master-key-ed25x519 Rd4iunJV7jb9mW3zUm5qyZCkSyrAuNQWQFbNQUlkJ3U\n"
+ + "platform Tor 0.3.0.6 on Linux\n"
+ + "proto Cons=1-2 Desc=1-2 DirCache=1 HSDir=1-2 HSIntro=3-4 HSRend=1-2 Li"
+ + "nk=1-4 LinkAuth=1,3 Microdesc=1-2 Relay=1-2\n"
+ + "published 2017-05-02 17:25:22\n"
+ + "fingerprint 256F 183F 252D BBF0 80F2 E70E 5CB0 F523 A632 3D0F\n"
+ + "uptime 12\n"
+ + "bandwidth 4194304 6291456 0\n"
+ + "extra-info-digest 357F399E5A0FE2EEDEB7B3AD3D9328440EC17582 "
+ + "OgEu6BAQLUeTFjGofg0WTT9CYQsUGH9tiDENt/tiAD0\n"
+ + "onion-key\n"
+ + "-----BEGIN RSA PUBLIC KEY-----\n"
+ + "MIGJAoGBAMYpYIFcAGOcfZBWt+nUPDu1ovbG8uamDBN4A/XTla74p6A3Ozl8/06D\n"
+ + "1E/CcX6N2UahjDs+iM9EmND0k1CFgnkkkU7qBhm4aeOwfzSjDGXA52ab9vS0yEpa\n"
+ + "aFHORGn88LRqcSvm9zRtChde5Ez0QJpBOuhyh19qIsSwT4EVa6CXAgMBAAE=\n"
+ + "-----END RSA PUBLIC KEY-----\n"
+ + "signing-key\n"
+ + "-----BEGIN RSA PUBLIC KEY-----\n"
+ + "MIGJAoGBAL6touSlbyMx2frcjIrLXcUUhN9rydnQhZrREZEdpALondnaEZzu3LE8\n"
+ + "AeQI+VUTpZBlYbWR3Wh+wMDrdPzB3B07ATjAV3N07x6CtKk8YHE5RgShLlEr1k9c\n"
+ + "DhN1VZi3rEA63pVfGTC1n7jXpAkMgYMW4KSHk40kgueu+3JxNSe1AgMBAAE=\n"
+ + "-----END RSA PUBLIC KEY-----\n"
+ + "onion-key-crosscert\n"
+ + "-----BEGIN CROSSCERT-----\n"
+ + "ITr+XCRVFqFE5o/5utRst/j8cZjEj43Ucd6n4Xoo566rVS9VPvUszduvPAZJECVS\n"
+ + "QHPmshTsvXFH5+LEzCk0nN3cR5+iZX5zT15+1EoplE97doHQqtSTcA1CJSSFvoRj\n"
+ + "1iobnqDn1lHLFyTMBJ4VV38a1NeovFmy4YkodTrtztk=\n"
+ + "-----END CROSSCERT-----\n"
+ + "ntor-onion-key-crosscert 1\n"
+ + "-----BEGIN ED25519 CERT-----\n"
+ + "AQoABlV6AUXeIrpyVe42/Zlt81JuasmQpEsqwLjUFkBWzUFJZCd1ALsQt0Q8mBNP\n"
+ + "FcAXX6E+2oX2nGto910Sb1CBMPenMopKXaqArOPeqEQQx4+4x/waBLw7niBtEVjb\n"
+ + "+WZ5cSha6Aw=\n"
+ + "-----END ED25519 CERT-----\n"
+ + "hidden-service-dir\n"
+ + "ntor-onion-key fhiVUl9Ff0OlXd6zyqnfEA8u86KmewZISILHeU33Diw=\n"
+ + "reject *:*\n"
+ + "tunnelled-dir-server\n"
+ + "router-sig-ed25519 pyHeZ3dimbx4cBOAjlhLbnav2F9FLrmy+CqO+QIv01VI4"
+ + "qK5xihG6s75HLj3s6dpa52xGBE6HNRdx2rCk2r3Bg\n"
+ + "router-signature\n"
+ + "-----BEGIN SIGNATURE-----\n"
+ + "gJGxrxrbBVnO5x34450bKkBBBGZGJrgfYBLL6tfN6BhEYtENy9cWqt556boXsEuW\n"
+ + "cN8z+OdNYr+LGJqUJgGWTSb1am26lU9lyHHHzVIhp9I9K4CXYq93POHCSore0M0c\n"
+ + "PgAHPTkUN6WJvxachkEXwftzYaOLvJOqP+GFj+QvsVg=\n"
+ + "-----END SIGNATURE-----";
}
diff --git a/src/test/java/org/torproject/descriptor/impl/TestServerDescriptor.java b/src/test/java/org/torproject/descriptor/impl/TestServerDescriptor.java
new file mode 100644
index 0000000..194df82
--- /dev/null
+++ b/src/test/java/org/torproject/descriptor/impl/TestServerDescriptor.java
@@ -0,0 +1,17 @@
+/* Copyright 2017 The Tor Project
+ * See LICENSE for licensing information */
+
+package org.torproject.descriptor.impl;
+
+public class TestServerDescriptor extends ServerDescriptorImpl {
+
+ protected TestServerDescriptor(byte[] rawDescriptorBytes,
+ int[] offsetAndLength, boolean failUnrecognizedDescriptorLines)
+ throws DescriptorParseException {
+ super(rawDescriptorBytes, offsetAndLength, failUnrecognizedDescriptorLines);
+ }
+
+}
+
+
+
1
0

16 Jun '17
commit 0917016f6b2ac6e383fa6862a3a530b4dcf777bc
Author: Karsten Loesing <karsten.loesing(a)gmx.net>
Date: Fri Jun 16 14:43:20 2017 +0200
Fix a regression in parsing descriptors.
---
CHANGELOG.md | 7 ++++++-
.../org/torproject/descriptor/impl/DescriptorParserImpl.java | 12 +++++++++---
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 44420bf..409d0e8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,4 +1,9 @@
-# Changes in version 1.9.0 - 2017-06-??
+# Changes in version 1.8.2 - 2017-06-16
+
+ * Medium changes
+ - Fix a regression where any DescriptorParseException thrown while
+ parsing a descriptor is encapsulated and rethrown as
+ RuntimeException.
# Changes in version 1.8.1 - 2017-06-08
diff --git a/src/main/java/org/torproject/descriptor/impl/DescriptorParserImpl.java b/src/main/java/org/torproject/descriptor/impl/DescriptorParserImpl.java
index 6317597..ad0d512 100644
--- a/src/main/java/org/torproject/descriptor/impl/DescriptorParserImpl.java
+++ b/src/main/java/org/torproject/descriptor/impl/DescriptorParserImpl.java
@@ -195,9 +195,15 @@ public class DescriptorParserImpl implements DescriptorParser {
try {
return constructor.newInstance(rawDescriptorBytes,
offsetAndLength, failUnrecognizedDescriptorLines);
- } catch (InstantiationException | IllegalAccessException
- | InvocationTargetException e) {
- throw new RuntimeException();
+ } catch (InvocationTargetException e) {
+ if (null != e.getCause()
+ && e.getCause() instanceof DescriptorParseException) {
+ throw (DescriptorParseException) e.getCause();
+ } else {
+ throw new RuntimeException(e);
+ }
+ } catch (InstantiationException | IllegalAccessException e) {
+ throw new RuntimeException(e);
}
}
1
0
commit be96d96b830355b9f122072f0b02855282ae64a3
Author: Karsten Loesing <karsten.loesing(a)gmx.net>
Date: Fri Jun 16 16:54:50 2017 +0200
Prepare for 1.8.2 release.
---
build.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/build.xml b/build.xml
index 1ed53ec..d755932 100644
--- a/build.xml
+++ b/build.xml
@@ -6,7 +6,7 @@
<project default="usage" name="descriptor" basedir=".">
- <property name="release.version" value="1.8.1-dev" />
+ <property name="release.version" value="1.8.2" />
<property name="javadoc-title" value="DescripTor API Documentation"/>
<property name="javadoc-excludes" value="**/impl/** **/index/**" />
<property name="implementation-title" value="DescripTor" />
1
0
commit 3affad3f8877b1e907ba9e04b0020e4b7cc86023
Author: iwakeh <iwakeh(a)torproject.org>
Date: Fri Jun 16 12:55:35 2017 +0000
Add test for task-22634.
---
.../descriptor/impl/DescriptorParserImplTest.java | 75 ++++++++++++++++++++++
.../descriptor/impl/TestServerDescriptor.java | 17 +++++
2 files changed, 92 insertions(+)
diff --git a/src/test/java/org/torproject/descriptor/impl/DescriptorParserImplTest.java b/src/test/java/org/torproject/descriptor/impl/DescriptorParserImplTest.java
index ef21ce6..5a328ec 100644
--- a/src/test/java/org/torproject/descriptor/impl/DescriptorParserImplTest.java
+++ b/src/test/java/org/torproject/descriptor/impl/DescriptorParserImplTest.java
@@ -5,10 +5,14 @@ package org.torproject.descriptor.impl;
import static org.junit.Assert.assertEquals;
+import org.torproject.descriptor.DescriptorParseException;
+
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
+import java.lang.reflect.Constructor;
+
public class DescriptorParserImplTest {
@Rule
@@ -37,5 +41,76 @@ public class DescriptorParserImplTest {
dpi.parseDescriptors(des.getRawDescriptorBytes(), "dummy.file").size());
}
+ @Test
+ public void testParseDescriptor() throws DescriptorParseException {
+ Constructor<? extends DescriptorImpl> constructor;
+ try {
+ constructor = TestServerDescriptor.class
+ .getDeclaredConstructor(byte[].class, int[].class, boolean.class);
+ } catch (NoSuchMethodException e) {
+ throw new RuntimeException(e);
+ }
+ this.thrown.expect(DescriptorParseException.class);
+ this.thrown.expectMessage("'176x.158.53.63' in line 'router UbuntuCore169 "
+ + "176x.158.53.63 44583 0 0' is not a valid IPv4 address.");
+ DescriptorParserImpl.parseDescriptor(DEFECT.getBytes(),
+ new int[]{0, DEFECT.getBytes().length}, constructor, false);
+ }
+
+ private static final String DEFECT =
+ "@type server-descriptor 1.0\n"
+ + "router UbuntuCore169 176x.158.53.63 44583 0 0\n"
+ + "identity-ed25519\n"
+ + "-----BEGIN ED25519 CERT-----\n"
+ + "AQQABleiAZ2Ce5QY1oSL0F79WeaPhL/zWomAVJG1vwTioPBkpeG7AQAgBABF3iK6\n"
+ + "clXuNv2ZbfNSbmrJkKRLKsC41BZAVs1BSWQndRMNDsZJ/s6GmOd5IiU6axR5z2Nn\n"
+ + "XTUR0TMGOc5KNJHqKi9Ht+iSIH02OeV1Gm/PNfos7KBKSJJROme1YQQsvwQ=\n"
+ + "-----END ED25519 CERT-----\n"
+ + "master-key-ed25x519 Rd4iunJV7jb9mW3zUm5qyZCkSyrAuNQWQFbNQUlkJ3U\n"
+ + "platform Tor 0.3.0.6 on Linux\n"
+ + "proto Cons=1-2 Desc=1-2 DirCache=1 HSDir=1-2 HSIntro=3-4 HSRend=1-2 Li"
+ + "nk=1-4 LinkAuth=1,3 Microdesc=1-2 Relay=1-2\n"
+ + "published 2017-05-02 17:25:22\n"
+ + "fingerprint 256F 183F 252D BBF0 80F2 E70E 5CB0 F523 A632 3D0F\n"
+ + "uptime 12\n"
+ + "bandwidth 4194304 6291456 0\n"
+ + "extra-info-digest 357F399E5A0FE2EEDEB7B3AD3D9328440EC17582 "
+ + "OgEu6BAQLUeTFjGofg0WTT9CYQsUGH9tiDENt/tiAD0\n"
+ + "onion-key\n"
+ + "-----BEGIN RSA PUBLIC KEY-----\n"
+ + "MIGJAoGBAMYpYIFcAGOcfZBWt+nUPDu1ovbG8uamDBN4A/XTla74p6A3Ozl8/06D\n"
+ + "1E/CcX6N2UahjDs+iM9EmND0k1CFgnkkkU7qBhm4aeOwfzSjDGXA52ab9vS0yEpa\n"
+ + "aFHORGn88LRqcSvm9zRtChde5Ez0QJpBOuhyh19qIsSwT4EVa6CXAgMBAAE=\n"
+ + "-----END RSA PUBLIC KEY-----\n"
+ + "signing-key\n"
+ + "-----BEGIN RSA PUBLIC KEY-----\n"
+ + "MIGJAoGBAL6touSlbyMx2frcjIrLXcUUhN9rydnQhZrREZEdpALondnaEZzu3LE8\n"
+ + "AeQI+VUTpZBlYbWR3Wh+wMDrdPzB3B07ATjAV3N07x6CtKk8YHE5RgShLlEr1k9c\n"
+ + "DhN1VZi3rEA63pVfGTC1n7jXpAkMgYMW4KSHk40kgueu+3JxNSe1AgMBAAE=\n"
+ + "-----END RSA PUBLIC KEY-----\n"
+ + "onion-key-crosscert\n"
+ + "-----BEGIN CROSSCERT-----\n"
+ + "ITr+XCRVFqFE5o/5utRst/j8cZjEj43Ucd6n4Xoo566rVS9VPvUszduvPAZJECVS\n"
+ + "QHPmshTsvXFH5+LEzCk0nN3cR5+iZX5zT15+1EoplE97doHQqtSTcA1CJSSFvoRj\n"
+ + "1iobnqDn1lHLFyTMBJ4VV38a1NeovFmy4YkodTrtztk=\n"
+ + "-----END CROSSCERT-----\n"
+ + "ntor-onion-key-crosscert 1\n"
+ + "-----BEGIN ED25519 CERT-----\n"
+ + "AQoABlV6AUXeIrpyVe42/Zlt81JuasmQpEsqwLjUFkBWzUFJZCd1ALsQt0Q8mBNP\n"
+ + "FcAXX6E+2oX2nGto910Sb1CBMPenMopKXaqArOPeqEQQx4+4x/waBLw7niBtEVjb\n"
+ + "+WZ5cSha6Aw=\n"
+ + "-----END ED25519 CERT-----\n"
+ + "hidden-service-dir\n"
+ + "ntor-onion-key fhiVUl9Ff0OlXd6zyqnfEA8u86KmewZISILHeU33Diw=\n"
+ + "reject *:*\n"
+ + "tunnelled-dir-server\n"
+ + "router-sig-ed25519 pyHeZ3dimbx4cBOAjlhLbnav2F9FLrmy+CqO+QIv01VI4"
+ + "qK5xihG6s75HLj3s6dpa52xGBE6HNRdx2rCk2r3Bg\n"
+ + "router-signature\n"
+ + "-----BEGIN SIGNATURE-----\n"
+ + "gJGxrxrbBVnO5x34450bKkBBBGZGJrgfYBLL6tfN6BhEYtENy9cWqt556boXsEuW\n"
+ + "cN8z+OdNYr+LGJqUJgGWTSb1am26lU9lyHHHzVIhp9I9K4CXYq93POHCSore0M0c\n"
+ + "PgAHPTkUN6WJvxachkEXwftzYaOLvJOqP+GFj+QvsVg=\n"
+ + "-----END SIGNATURE-----";
}
diff --git a/src/test/java/org/torproject/descriptor/impl/TestServerDescriptor.java b/src/test/java/org/torproject/descriptor/impl/TestServerDescriptor.java
new file mode 100644
index 0000000..194df82
--- /dev/null
+++ b/src/test/java/org/torproject/descriptor/impl/TestServerDescriptor.java
@@ -0,0 +1,17 @@
+/* Copyright 2017 The Tor Project
+ * See LICENSE for licensing information */
+
+package org.torproject.descriptor.impl;
+
+public class TestServerDescriptor extends ServerDescriptorImpl {
+
+ protected TestServerDescriptor(byte[] rawDescriptorBytes,
+ int[] offsetAndLength, boolean failUnrecognizedDescriptorLines)
+ throws DescriptorParseException {
+ super(rawDescriptorBytes, offsetAndLength, failUnrecognizedDescriptorLines);
+ }
+
+}
+
+
+
1
0