tor-commits
Threads by month
- ----- 2025 -----
- December
- November
- October
- September
- August
- 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
January 2017
- 22 participants
- 1797 discussions
31 Jan '17
commit c3079ae2ecbed0994273b7986e3cf19160f55153
Author: Karsten Loesing <karsten.loesing(a)gmx.net>
Date: Wed Jan 25 11:27:09 2017 +0100
Remove 604 checkstyle complaints.
Resolves #21144.
---
.../descriptor/DescriptorSourceFactory.java | 3 +-
.../descriptor/impl/DescriptorReaderImpl.java | 3 +-
.../descriptor/DescriptorSourceFactoryTest.java | 82 ++---
.../descriptor/DummyCollectorImplementation.java | 15 +
.../descriptor/DummyDownloaderImplementation.java | 15 +
.../descriptor/DummyParserImplementation.java | 15 +
.../descriptor/DummyReaderImplementation.java | 15 +
.../descriptor/benchmark/MeasurePerformance.java | 22 +-
.../descriptor/impl/BridgeNetworkStatusTest.java | 24 +-
.../descriptor/impl/ConsensusBuilder.java | 55 +++-
.../impl/DescriptorCollectorImplTest.java | 5 +-
.../descriptor/impl/DescriptorReaderImplTest.java | 1 +
.../descriptor/impl/ExitListImplTest.java | 10 +-
.../impl/ExtraInfoDescriptorImplTest.java | 231 ++++++++++----
.../descriptor/impl/MicrodescriptorImplTest.java | 16 +-
.../impl/RelayNetworkStatusConsensusImplTest.java | 97 ++++--
.../impl/RelayNetworkStatusImplTest.java | 47 ++-
.../impl/RelayNetworkStatusVoteImplTest.java | 111 +++++--
.../descriptor/impl/ServerDescriptorImplTest.java | 338 ++++++++++++---------
.../descriptor/impl/TorperfResultImplTest.java | 10 +-
20 files changed, 772 insertions(+), 343 deletions(-)
diff --git a/src/main/java/org/torproject/descriptor/DescriptorSourceFactory.java b/src/main/java/org/torproject/descriptor/DescriptorSourceFactory.java
index efdc5cf..77d8740 100644
--- a/src/main/java/org/torproject/descriptor/DescriptorSourceFactory.java
+++ b/src/main/java/org/torproject/descriptor/DescriptorSourceFactory.java
@@ -34,7 +34,8 @@ import org.slf4j.LoggerFactory;
* descriptor downloader:</p>
*
* <p><code>
- * java -Ddescriptor.downloader=my.special.descriptorimpl.Downloader my.app.Mainclass
+ * java -Ddescriptor.downloader=my.special.descriptorimpl.Downloader \
+ * my.app.Mainclass
* </code></p>
*
* @since 1.0.0
diff --git a/src/main/java/org/torproject/descriptor/impl/DescriptorReaderImpl.java b/src/main/java/org/torproject/descriptor/impl/DescriptorReaderImpl.java
index 2cbb6c8..cb14588 100644
--- a/src/main/java/org/torproject/descriptor/impl/DescriptorReaderImpl.java
+++ b/src/main/java/org/torproject/descriptor/impl/DescriptorReaderImpl.java
@@ -36,7 +36,8 @@ import java.util.TreeMap;
public class DescriptorReaderImpl implements DescriptorReader {
- private static Logger log = LoggerFactory.getLogger(DescriptorReaderImpl.class);
+ private static Logger log = LoggerFactory.getLogger(
+ DescriptorReaderImpl.class);
private boolean hasStartedReading = false;
private List<File> directories = new ArrayList<>();
diff --git a/src/test/java/org/torproject/descriptor/DescriptorSourceFactoryTest.java b/src/test/java/org/torproject/descriptor/DescriptorSourceFactoryTest.java
index d8990ac..9e0b5ff 100644
--- a/src/test/java/org/torproject/descriptor/DescriptorSourceFactoryTest.java
+++ b/src/test/java/org/torproject/descriptor/DescriptorSourceFactoryTest.java
@@ -1,42 +1,46 @@
/* Copyright 2016--2017 The Tor Project
* See LICENSE for licensing information */
+
package org.torproject.descriptor;
-import static org.torproject.descriptor.DescriptorSourceFactory.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.torproject.descriptor.DescriptorSourceFactory.COLLECTOR_DEFAULT;
+import static org.torproject.descriptor.DescriptorSourceFactory.COLLECTOR_PROPERTY;
+import static org.torproject.descriptor.DescriptorSourceFactory.DOWNLOADER_DEFAULT;
+import static org.torproject.descriptor.DescriptorSourceFactory.DOWNLOADER_PROPERTY;
+import static org.torproject.descriptor.DescriptorSourceFactory.PARSER_DEFAULT;
+import static org.torproject.descriptor.DescriptorSourceFactory.PARSER_PROPERTY;
+import static org.torproject.descriptor.DescriptorSourceFactory.READER_DEFAULT;
+import static org.torproject.descriptor.DescriptorSourceFactory.READER_PROPERTY;
-import org.torproject.descriptor.DescriptorCollector;
-import org.torproject.descriptor.DescriptorDownloader;
-import org.torproject.descriptor.DescriptorParser;
-import org.torproject.descriptor.DescriptorReader;
-import org.torproject.descriptor.ImplementationNotAccessibleException;
import org.torproject.descriptor.impl.DescriptorDownloaderImpl;
import org.torproject.descriptor.impl.DescriptorParserImpl;
import org.torproject.descriptor.impl.DescriptorReaderImpl;
import org.torproject.descriptor.index.DescriptorIndexCollector;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
import org.junit.Test;
-import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
public class DescriptorSourceFactoryTest {
- private final static String[] properties = new String[]{
- COLLECTOR_PROPERTY, DOWNLOADER_PROPERTY, PARSER_PROPERTY, READER_PROPERTY};
- private final static String[] defaults = new String[]{
- COLLECTOR_DEFAULT, DOWNLOADER_DEFAULT, PARSER_DEFAULT, READER_DEFAULT};
+ private static final String[] properties = new String[] { COLLECTOR_PROPERTY,
+ DOWNLOADER_PROPERTY, PARSER_PROPERTY, READER_PROPERTY };
+
+ private static final String[] defaults = new String[] { COLLECTOR_DEFAULT,
+ DOWNLOADER_DEFAULT, PARSER_DEFAULT, READER_DEFAULT };
@Test()
public void testDefaults() {
setProperties(defaults);
- DescriptorCollector dc = DescriptorSourceFactory.createDescriptorCollector();
+ DescriptorCollector dc =
+ DescriptorSourceFactory.createDescriptorCollector();
assertTrue(dc instanceof DescriptorIndexCollector);
- DescriptorDownloader dd = DescriptorSourceFactory.createDescriptorDownloader();
+ DescriptorDownloader dd =
+ DescriptorSourceFactory.createDescriptorDownloader();
assertTrue(dd instanceof DescriptorDownloaderImpl);
DescriptorParser dp = DescriptorSourceFactory.createDescriptorParser();
assertTrue(dp instanceof DescriptorParserImpl);
@@ -66,7 +70,7 @@ public class DescriptorSourceFactoryTest {
retrieve.setAccessible(true);
retrieve.invoke(null, "unknown.property");
} catch (InvocationTargetException ite) {
- if(ite.getCause() instanceof ImplementationNotAccessibleException) {
+ if (ite.getCause() instanceof ImplementationNotAccessibleException) {
return;
} else {
fail("Cause was " + ite.getCause()
@@ -79,16 +83,17 @@ public class DescriptorSourceFactoryTest {
@Test()
public void testProperties() {
- setProperties(new String[]{
+ setProperties(new String[] {
"org.torproject.descriptor.DummyCollectorImplementation",
"org.torproject.descriptor.DummyDownloaderImplementation",
"org.torproject.descriptor.DummyParserImplementation",
- "org.torproject.descriptor.DummyReaderImplementation",
- });
- DescriptorCollector dc = DescriptorSourceFactory.createDescriptorCollector();
+ "org.torproject.descriptor.DummyReaderImplementation" });
+ DescriptorCollector dc =
+ DescriptorSourceFactory.createDescriptorCollector();
assertTrue(dc instanceof DummyCollectorImplementation);
assertEquals(1, DummyCollectorImplementation.count);
- DescriptorDownloader dd = DescriptorSourceFactory.createDescriptorDownloader();
+ DescriptorDownloader dd =
+ DescriptorSourceFactory.createDescriptorDownloader();
assertTrue(dd instanceof DummyDownloaderImplementation);
assertEquals(1, DummyDownloaderImplementation.count);
DescriptorParser dp = DescriptorSourceFactory.createDescriptorParser();
@@ -98,33 +103,4 @@ public class DescriptorSourceFactoryTest {
assertTrue(dr instanceof DummyReaderImplementation);
assertEquals(1, DummyReaderImplementation.count);
}
-
-}
-
-class DummyCollectorImplementation extends DescriptorIndexCollector {
- static int count;
- public DummyCollectorImplementation() {
- count++;
- }
-}
-
-class DummyDownloaderImplementation extends DescriptorDownloaderImpl {
- static int count;
- public DummyDownloaderImplementation() {
- count++;
- }
-}
-
-class DummyParserImplementation extends DescriptorParserImpl {
- static int count;
- public DummyParserImplementation() {
- count++;
- }
-}
-
-class DummyReaderImplementation extends DescriptorReaderImpl {
- static int count;
- public DummyReaderImplementation() {
- count++;
- }
}
diff --git a/src/test/java/org/torproject/descriptor/DummyCollectorImplementation.java b/src/test/java/org/torproject/descriptor/DummyCollectorImplementation.java
new file mode 100644
index 0000000..130a718
--- /dev/null
+++ b/src/test/java/org/torproject/descriptor/DummyCollectorImplementation.java
@@ -0,0 +1,15 @@
+/* Copyright 2016--2017 The Tor Project
+ * See LICENSE for licensing information */
+
+package org.torproject.descriptor;
+
+import org.torproject.descriptor.index.DescriptorIndexCollector;
+
+class DummyCollectorImplementation extends DescriptorIndexCollector {
+
+ static int count;
+
+ public DummyCollectorImplementation() {
+ count++;
+ }
+}
diff --git a/src/test/java/org/torproject/descriptor/DummyDownloaderImplementation.java b/src/test/java/org/torproject/descriptor/DummyDownloaderImplementation.java
new file mode 100644
index 0000000..dce3372
--- /dev/null
+++ b/src/test/java/org/torproject/descriptor/DummyDownloaderImplementation.java
@@ -0,0 +1,15 @@
+/* Copyright 2016--2017 The Tor Project
+ * See LICENSE for licensing information */
+
+package org.torproject.descriptor;
+
+import org.torproject.descriptor.impl.DescriptorDownloaderImpl;
+
+class DummyDownloaderImplementation extends DescriptorDownloaderImpl {
+
+ static int count;
+
+ public DummyDownloaderImplementation() {
+ count++;
+ }
+}
diff --git a/src/test/java/org/torproject/descriptor/DummyParserImplementation.java b/src/test/java/org/torproject/descriptor/DummyParserImplementation.java
new file mode 100644
index 0000000..42e67c9
--- /dev/null
+++ b/src/test/java/org/torproject/descriptor/DummyParserImplementation.java
@@ -0,0 +1,15 @@
+/* Copyright 2016--2017 The Tor Project
+ * See LICENSE for licensing information */
+
+package org.torproject.descriptor;
+
+import org.torproject.descriptor.impl.DescriptorParserImpl;
+
+class DummyParserImplementation extends DescriptorParserImpl {
+
+ static int count;
+
+ public DummyParserImplementation() {
+ count++;
+ }
+}
diff --git a/src/test/java/org/torproject/descriptor/DummyReaderImplementation.java b/src/test/java/org/torproject/descriptor/DummyReaderImplementation.java
new file mode 100644
index 0000000..8f74337
--- /dev/null
+++ b/src/test/java/org/torproject/descriptor/DummyReaderImplementation.java
@@ -0,0 +1,15 @@
+/* Copyright 2016--2017 The Tor Project
+ * See LICENSE for licensing information */
+
+package org.torproject.descriptor;
+
+import org.torproject.descriptor.impl.DescriptorReaderImpl;
+
+class DummyReaderImplementation extends DescriptorReaderImpl {
+
+ static int count;
+
+ public DummyReaderImplementation() {
+ count++;
+ }
+}
diff --git a/src/test/java/org/torproject/descriptor/benchmark/MeasurePerformance.java b/src/test/java/org/torproject/descriptor/benchmark/MeasurePerformance.java
index 4c36ae4..a0c923c 100644
--- a/src/test/java/org/torproject/descriptor/benchmark/MeasurePerformance.java
+++ b/src/test/java/org/torproject/descriptor/benchmark/MeasurePerformance.java
@@ -1,5 +1,6 @@
/* Copyright 2016--2017 The Tor Project
* See LICENSE for licensing information */
+
package org.torproject.descriptor.benchmark;
import org.torproject.descriptor.Descriptor;
@@ -20,7 +21,7 @@ import java.util.SortedMap;
public class MeasurePerformance {
- /* Check if all necessary files are available and then measure
+ /** Check if all necessary files are available and then measure
* performance of some more or less common use cases. */
public static void main(String[] args) {
if (!filesAvailable()) {
@@ -88,8 +89,9 @@ public class MeasurePerformance {
private static void measureAverageAdvertisedBandwidth(
File tarballFileOrDirectory) {
System.out.println("Starting measureAverageAdvertisedBandwidth");
- long startedMillis = System.currentTimeMillis();
- long sumAdvertisedBandwidth = 0, countedServerDescriptors = 0;
+ final long startedMillis = System.currentTimeMillis();
+ long sumAdvertisedBandwidth = 0;
+ long countedServerDescriptors = 0;
DescriptorReader descriptorReader =
DescriptorSourceFactory.createDescriptorReader();
descriptorReader.addTarball(tarballFileOrDirectory);
@@ -125,7 +127,7 @@ public class MeasurePerformance {
private static void measureCountriesV3Requests(File tarballFile) {
System.out.println("Starting measureCountriesV3Requests");
- long startedMillis = System.currentTimeMillis();
+ final long startedMillis = System.currentTimeMillis();
Set<String> countries = new HashSet<>();
long countedExtraInfoDescriptors = 0;
DescriptorReader descriptorReader =
@@ -165,9 +167,10 @@ public class MeasurePerformance {
private static void measureAverageRelaysExit(
File tarballFileOrDirectory) {
System.out.println("Starting measureAverageRelaysExit");
- long startedMillis = System.currentTimeMillis();
- long totalRelaysWithExitFlag = 0L, totalRelays = 0L,
- countedConsensuses = 0L;
+ final long startedMillis = System.currentTimeMillis();
+ long totalRelaysWithExitFlag = 0L;
+ long totalRelays = 0L;
+ long countedConsensuses = 0L;
DescriptorReader descriptorReader =
DescriptorSourceFactory.createDescriptorReader();
descriptorReader.addTarball(tarballFileOrDirectory);
@@ -212,8 +215,9 @@ public class MeasurePerformance {
File tarballFile) {
System.out.println("Starting "
+ "measureFractionRelaysExit80Microdescriptors");
- long startedMillis = System.currentTimeMillis();
- long totalRelaysWithExitFlag = 0L, countedMicrodescriptors = 0L;
+ final long startedMillis = System.currentTimeMillis();
+ long totalRelaysWithExitFlag = 0L;
+ long countedMicrodescriptors = 0L;
DescriptorReader descriptorReader =
DescriptorSourceFactory.createDescriptorReader();
descriptorReader.addTarball(tarballFile);
diff --git a/src/test/java/org/torproject/descriptor/impl/BridgeNetworkStatusTest.java b/src/test/java/org/torproject/descriptor/impl/BridgeNetworkStatusTest.java
index d1a083e..8720d7b 100644
--- a/src/test/java/org/torproject/descriptor/impl/BridgeNetworkStatusTest.java
+++ b/src/test/java/org/torproject/descriptor/impl/BridgeNetworkStatusTest.java
@@ -1,17 +1,19 @@
/* Copyright 2015--2017 The Tor Project
* See LICENSE for licensing information */
+
package org.torproject.descriptor.impl;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.junit.Test;
import org.torproject.descriptor.BridgeNetworkStatus;
import org.torproject.descriptor.DescriptorParseException;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+
/* Test parsing of bridge network statuses. Some of the parsing code is
* already tested in the consensus/vote-parsing tests. */
public class BridgeNetworkStatusTest {
@@ -19,8 +21,10 @@ public class BridgeNetworkStatusTest {
/* Helper class to build a bridge network status based on default data
* and modifications requested by test methods. */
private static class StatusBuilder {
+
private String fileName = "20151121-173936-"
+ "4A0CCD2DDC7995083D73F5D667100C8A5831F16D";
+
private static BridgeNetworkStatus
createWithFileName(String fileName)
throws DescriptorParseException {
@@ -29,7 +33,9 @@ public class BridgeNetworkStatusTest {
return new BridgeNetworkStatusImpl(sb.buildStatus(), sb.fileName,
true);
}
+
private String publishedLine = "published 2015-11-21 17:39:36";
+
private static BridgeNetworkStatus
createWithPublishedLine(String line)
throws DescriptorParseException {
@@ -38,11 +44,13 @@ public class BridgeNetworkStatusTest {
return new BridgeNetworkStatusImpl(sb.buildStatus(), sb.fileName,
true);
}
+
private String flagThresholdsLine = "flag-thresholds "
+ "stable-uptime=3105080 stable-mtbf=2450615 fast-speed=55000 "
+ "guard-wfu=98.000% guard-tk=691200 guard-bw-inc-exits=337000 "
+ "guard-bw-exc-exits=339000 enough-mtbf=1 "
+ "ignoring-advertised-bws=0";
+
private static BridgeNetworkStatus
createWithFlagThresholdsLine(String line)
throws DescriptorParseException {
@@ -51,8 +59,11 @@ public class BridgeNetworkStatusTest {
return new BridgeNetworkStatusImpl(sb.buildStatus(), sb.fileName,
true);
}
+
private List<String> statusEntries = new ArrayList<>();
+
private String unrecognizedHeaderLine = null;
+
protected static BridgeNetworkStatus
createWithUnrecognizedHeaderLine(String line,
boolean failUnrecognizedDescriptorLines)
@@ -62,7 +73,9 @@ public class BridgeNetworkStatusTest {
return new BridgeNetworkStatusImpl(sb.buildStatus(), sb.fileName,
failUnrecognizedDescriptorLines);
}
+
private String unrecognizedStatusEntryLine = null;
+
protected static BridgeNetworkStatus
createWithUnrecognizedStatusEntryLine(String line,
boolean failUnrecognizedDescriptorLines)
@@ -79,12 +92,14 @@ public class BridgeNetworkStatusTest {
+ "10.153.163.200 443 0\ns Fast Running Stable Valid\n"
+ "w Bandwidth=264\np reject 1-65535");
}
+
private byte[] buildStatus() {
StringBuilder sb = new StringBuilder();
this.appendHeader(sb);
this.appendStatusEntries(sb);
return sb.toString().getBytes();
}
+
private void appendHeader(StringBuilder sb) {
if (this.publishedLine != null) {
sb.append(this.publishedLine).append("\n");
@@ -96,6 +111,7 @@ public class BridgeNetworkStatusTest {
sb.append(this.unrecognizedHeaderLine).append("\n");
}
}
+
private void appendStatusEntries(StringBuilder sb) {
for (String statusEntry : this.statusEntries) {
sb.append(statusEntry).append("\n");
diff --git a/src/test/java/org/torproject/descriptor/impl/ConsensusBuilder.java b/src/test/java/org/torproject/descriptor/impl/ConsensusBuilder.java
index fccd33b..b765be6 100644
--- a/src/test/java/org/torproject/descriptor/impl/ConsensusBuilder.java
+++ b/src/test/java/org/torproject/descriptor/impl/ConsensusBuilder.java
@@ -1,17 +1,20 @@
/* Copyright 2012--2017 The Tor Project
* See LICENSE for licensing information */
+
package org.torproject.descriptor.impl;
import org.torproject.descriptor.DescriptorParseException;
+import org.torproject.descriptor.RelayNetworkStatusConsensus;
+
import java.util.ArrayList;
import java.util.List;
-import org.torproject.descriptor.RelayNetworkStatusConsensus;
-
/* Helper class to build a consensus based on default data and
* modifications requested by test methods. */
public class ConsensusBuilder {
+
String networkStatusVersionLine = "network-status-version 3";
+
protected static RelayNetworkStatusConsensus
createWithNetworkStatusVersionLine(String line)
throws DescriptorParseException {
@@ -19,7 +22,9 @@ public class ConsensusBuilder {
cb.networkStatusVersionLine = line;
return new RelayNetworkStatusConsensusImpl(cb.buildConsensus(), true);
}
+
private String voteStatusLine = "vote-status consensus";
+
protected static RelayNetworkStatusConsensus
createWithVoteStatusLine(String line)
throws DescriptorParseException {
@@ -27,7 +32,9 @@ public class ConsensusBuilder {
cb.voteStatusLine = line;
return new RelayNetworkStatusConsensusImpl(cb.buildConsensus(), true);
}
+
private String consensusMethodLine = "consensus-method 11";
+
protected static RelayNetworkStatusConsensus
createWithConsensusMethodLine(String line)
throws DescriptorParseException {
@@ -35,7 +42,9 @@ public class ConsensusBuilder {
cb.consensusMethodLine = line;
return new RelayNetworkStatusConsensusImpl(cb.buildConsensus(), true);
}
+
private String validAfterLine = "valid-after 2011-11-30 09:00:00";
+
protected static RelayNetworkStatusConsensus
createWithValidAfterLine(String line)
throws DescriptorParseException {
@@ -43,7 +52,9 @@ public class ConsensusBuilder {
cb.validAfterLine = line;
return new RelayNetworkStatusConsensusImpl(cb.buildConsensus(), true);
}
+
private String freshUntilLine = "fresh-until 2011-11-30 10:00:00";
+
protected static RelayNetworkStatusConsensus
createWithFreshUntilLine(String line)
throws DescriptorParseException {
@@ -51,7 +62,9 @@ public class ConsensusBuilder {
cb.freshUntilLine = line;
return new RelayNetworkStatusConsensusImpl(cb.buildConsensus(), true);
}
+
private String validUntilLine = "valid-until 2011-11-30 12:00:00";
+
protected static RelayNetworkStatusConsensus
createWithValidUntilLine(String line)
throws DescriptorParseException {
@@ -59,7 +72,9 @@ public class ConsensusBuilder {
cb.validUntilLine = line;
return new RelayNetworkStatusConsensusImpl(cb.buildConsensus(), true);
}
+
private String votingDelayLine = "voting-delay 300 300";
+
protected static RelayNetworkStatusConsensus
createWithVotingDelayLine(String line)
throws DescriptorParseException {
@@ -67,8 +82,10 @@ public class ConsensusBuilder {
cb.votingDelayLine = line;
return new RelayNetworkStatusConsensusImpl(cb.buildConsensus(), true);
}
+
String clientVersionsLine = "client-versions 0.2.1.31,"
+ "0.2.2.34,0.2.3.6-alpha,0.2.3.7-alpha,0.2.3.8-alpha";
+
protected static RelayNetworkStatusConsensus
createWithClientVersionsLine(String line)
throws DescriptorParseException {
@@ -76,8 +93,10 @@ public class ConsensusBuilder {
cb.clientVersionsLine = line;
return new RelayNetworkStatusConsensusImpl(cb.buildConsensus(), true);
}
+
String serverVersionsLine = "server-versions 0.2.1.31,"
+ "0.2.2.34,0.2.3.6-alpha,0.2.3.7-alpha,0.2.3.8-alpha";
+
protected static RelayNetworkStatusConsensus
createWithServerVersionsLine(String line)
throws DescriptorParseException {
@@ -85,7 +104,9 @@ public class ConsensusBuilder {
cb.serverVersionsLine = line;
return new RelayNetworkStatusConsensusImpl(cb.buildConsensus(), true);
}
+
private String packageLines = null;
+
protected static RelayNetworkStatusConsensus
createWithPackageLines(String lines)
throws DescriptorParseException {
@@ -93,8 +114,10 @@ public class ConsensusBuilder {
cb.packageLines = lines;
return new RelayNetworkStatusConsensusImpl(cb.buildConsensus(), true);
}
+
private String knownFlagsLine = "known-flags Authority BadExit Exit "
+ "Fast Guard HSDir Named Running Stable Unnamed V2Dir Valid";
+
protected static RelayNetworkStatusConsensus
createWithKnownFlagsLine(String line)
throws DescriptorParseException {
@@ -102,11 +125,13 @@ public class ConsensusBuilder {
cb.knownFlagsLine = line;
return new RelayNetworkStatusConsensusImpl(cb.buildConsensus(), true);
}
+
private String paramsLine = "params "
+ "CircuitPriorityHalflifeMsec=30000 bwauthbestratio=1 "
+ "bwauthcircs=1 bwauthdescbw=0 bwauthkp=10000 bwauthpid=1 "
+ "bwauthtd=5000 bwauthti=50000 bwauthtidecay=5000 cbtnummodes=3 "
+ "cbtquantile=80 circwindow=1000 refuseunknownexits=1";
+
protected static RelayNetworkStatusConsensus
createWithParamsLine(String line)
throws DescriptorParseException {
@@ -114,12 +139,17 @@ public class ConsensusBuilder {
cb.paramsLine = line;
return new RelayNetworkStatusConsensusImpl(cb.buildConsensus(), true);
}
+
List<String> dirSources = new ArrayList<>();
+
List<String> statusEntries = new ArrayList<>();
+
private String directoryFooterLine = "directory-footer";
+
protected void setDirectoryFooterLine(String line) {
this.directoryFooterLine = line;
}
+
protected static RelayNetworkStatusConsensus
createWithDirectoryFooterLine(String line)
throws DescriptorParseException {
@@ -127,13 +157,16 @@ public class ConsensusBuilder {
cb.directoryFooterLine = line;
return new RelayNetworkStatusConsensusImpl(cb.buildConsensus(), true);
}
+
private String bandwidthWeightsLine = "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";
+
protected void setBandwidthWeightsLine(String line) {
this.bandwidthWeightsLine = line;
}
+
protected static RelayNetworkStatusConsensus
createWithBandwidthWeightsLine(String line)
throws DescriptorParseException {
@@ -141,11 +174,15 @@ public class ConsensusBuilder {
cb.bandwidthWeightsLine = line;
return new RelayNetworkStatusConsensusImpl(cb.buildConsensus(), true);
}
+
private List<String> directorySignatures = new ArrayList<>();
+
protected void addDirectorySignature(String directorySignatureString) {
this.directorySignatures.add(directorySignatureString);
}
+
private String unrecognizedHeaderLine = null;
+
protected static RelayNetworkStatusConsensus
createWithUnrecognizedHeaderLine(String line,
boolean failUnrecognizedDescriptorLines)
@@ -155,7 +192,9 @@ public class ConsensusBuilder {
return new RelayNetworkStatusConsensusImpl(cb.buildConsensus(),
failUnrecognizedDescriptorLines);
}
+
private String unrecognizedDirSourceLine = null;
+
protected static RelayNetworkStatusConsensus
createWithUnrecognizedDirSourceLine(String line,
boolean failUnrecognizedDescriptorLines)
@@ -165,7 +204,9 @@ public class ConsensusBuilder {
return new RelayNetworkStatusConsensusImpl(cb.buildConsensus(),
failUnrecognizedDescriptorLines);
}
+
private String unrecognizedStatusEntryLine = null;
+
protected static RelayNetworkStatusConsensus
createWithUnrecognizedStatusEntryLine(String line,
boolean failUnrecognizedDescriptorLines)
@@ -175,7 +216,9 @@ public class ConsensusBuilder {
return new RelayNetworkStatusConsensusImpl(cb.buildConsensus(),
failUnrecognizedDescriptorLines);
}
+
private String unrecognizedFooterLine = null;
+
protected static RelayNetworkStatusConsensus
createWithUnrecognizedFooterLine(String line,
boolean failUnrecognizedDescriptorLines)
@@ -185,7 +228,9 @@ public class ConsensusBuilder {
return new RelayNetworkStatusConsensusImpl(cb.buildConsensus(),
failUnrecognizedDescriptorLines);
}
+
private String unrecognizedDirectorySignatureLine = null;
+
protected static RelayNetworkStatusConsensus
createWithUnrecognizedDirectorySignatureLine(String line,
boolean failUnrecognizedDescriptorLines)
@@ -232,6 +277,7 @@ public class ConsensusBuilder {
+ "oQA/qeby7E\n5374pPPL6WwCLJHkKtk21S9oHDmFBdlZq7JWQelWlVM=\n"
+ "-----END SIGNATURE-----");
}
+
protected byte[] buildConsensus() {
StringBuilder sb = new StringBuilder();
this.appendHeader(sb);
@@ -241,6 +287,7 @@ public class ConsensusBuilder {
this.appendDirectorySignatures(sb);
return sb.toString().getBytes();
}
+
private void appendHeader(StringBuilder sb) {
if (this.networkStatusVersionLine != null) {
sb.append(this.networkStatusVersionLine).append("\n");
@@ -282,6 +329,7 @@ public class ConsensusBuilder {
sb.append(this.unrecognizedHeaderLine).append("\n");
}
}
+
private void appendDirSources(StringBuilder sb) {
for (String dirSource : this.dirSources) {
sb.append(dirSource).append("\n");
@@ -290,6 +338,7 @@ public class ConsensusBuilder {
sb.append(this.unrecognizedDirSourceLine).append("\n");
}
}
+
private void appendStatusEntries(StringBuilder sb) {
for (String statusEntry : this.statusEntries) {
sb.append(statusEntry).append("\n");
@@ -298,6 +347,7 @@ public class ConsensusBuilder {
sb.append(this.unrecognizedStatusEntryLine).append("\n");
}
}
+
private void appendFooter(StringBuilder sb) {
if (this.directoryFooterLine != null) {
sb.append(this.directoryFooterLine).append("\n");
@@ -309,6 +359,7 @@ public class ConsensusBuilder {
sb.append(this.unrecognizedFooterLine).append("\n");
}
}
+
private void appendDirectorySignatures(StringBuilder sb) {
for (String directorySignature : this.directorySignatures) {
sb.append(directorySignature).append("\n");
diff --git a/src/test/java/org/torproject/descriptor/impl/DescriptorCollectorImplTest.java b/src/test/java/org/torproject/descriptor/impl/DescriptorCollectorImplTest.java
index ad34528..45752b2 100644
--- a/src/test/java/org/torproject/descriptor/impl/DescriptorCollectorImplTest.java
+++ b/src/test/java/org/torproject/descriptor/impl/DescriptorCollectorImplTest.java
@@ -1,5 +1,6 @@
/* Copyright 2015--2017 The Tor Project
* See LICENSE for licensing information */
+
package org.torproject.descriptor.impl;
import static org.junit.Assert.assertEquals;
@@ -8,10 +9,10 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
-import java.util.SortedMap;
-
import org.junit.Test;
+import java.util.SortedMap;
+
public class DescriptorCollectorImplTest {
private static final String REMOTE_DIRECTORY_CONSENSUSES =
diff --git a/src/test/java/org/torproject/descriptor/impl/DescriptorReaderImplTest.java b/src/test/java/org/torproject/descriptor/impl/DescriptorReaderImplTest.java
index 5a418b9..0d3bdcf 100644
--- a/src/test/java/org/torproject/descriptor/impl/DescriptorReaderImplTest.java
+++ b/src/test/java/org/torproject/descriptor/impl/DescriptorReaderImplTest.java
@@ -1,5 +1,6 @@
/* Copyright 2016--2017 The Tor Project
* See LICENSE for licensing information */
+
package org.torproject.descriptor.impl;
import static org.junit.Assert.assertEquals;
diff --git a/src/test/java/org/torproject/descriptor/impl/ExitListImplTest.java b/src/test/java/org/torproject/descriptor/impl/ExitListImplTest.java
index 8bc81f9..916c4df 100644
--- a/src/test/java/org/torproject/descriptor/impl/ExitListImplTest.java
+++ b/src/test/java/org/torproject/descriptor/impl/ExitListImplTest.java
@@ -1,17 +1,19 @@
/* Copyright 2015--2017 The Tor Project
* See LICENSE for licensing information */
+
package org.torproject.descriptor.impl;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.junit.Test;
import org.torproject.descriptor.DescriptorParseException;
import org.torproject.descriptor.ExitListEntry;
+import org.junit.Test;
+
+import java.util.HashMap;
+import java.util.Map;
+
public class ExitListImplTest {
@Test()
diff --git a/src/test/java/org/torproject/descriptor/impl/ExtraInfoDescriptorImplTest.java b/src/test/java/org/torproject/descriptor/impl/ExtraInfoDescriptorImplTest.java
index fb38c86..096314e 100644
--- a/src/test/java/org/torproject/descriptor/impl/ExtraInfoDescriptorImplTest.java
+++ b/src/test/java/org/torproject/descriptor/impl/ExtraInfoDescriptorImplTest.java
@@ -1,5 +1,6 @@
/* Copyright 2012--2017 The Tor Project
* See LICENSE for licensing information */
+
package org.torproject.descriptor.impl;
import static org.junit.Assert.assertEquals;
@@ -7,6 +8,13 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import org.torproject.descriptor.BridgeExtraInfoDescriptor;
+import org.torproject.descriptor.DescriptorParseException;
+import org.torproject.descriptor.ExtraInfoDescriptor;
+import org.torproject.descriptor.RelayExtraInfoDescriptor;
+
+import org.junit.Test;
+
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
@@ -14,138 +22,166 @@ import java.util.List;
import java.util.Map;
import java.util.SortedMap;
-import org.junit.Test;
-import org.torproject.descriptor.BridgeExtraInfoDescriptor;
-import org.torproject.descriptor.DescriptorParseException;
-import org.torproject.descriptor.ExtraInfoDescriptor;
-import org.torproject.descriptor.RelayExtraInfoDescriptor;
-
/* Test parsing of extra-info descriptors. */
public class ExtraInfoDescriptorImplTest {
/* Helper class to build a descriptor based on default data and
* modifications requested by test methods. */
private static class DescriptorBuilder {
+
private String extraInfoLine = "extra-info chaoscomputerclub5 "
+ "A9C039A5FD02FCA06303DCFAABE25C5912C63B26";
+
private static ExtraInfoDescriptor createWithExtraInfoLine(
String line) throws DescriptorParseException {
DescriptorBuilder db = new DescriptorBuilder();
db.extraInfoLine = line;
return new RelayExtraInfoDescriptorImpl(db.buildDescriptor(), true);
}
+
private String publishedLine = "published 2012-02-11 09:08:36";
+
private static ExtraInfoDescriptor createWithPublishedLine(
String line) throws DescriptorParseException {
DescriptorBuilder db = new DescriptorBuilder();
db.publishedLine = line;
return new RelayExtraInfoDescriptorImpl(db.buildDescriptor(), true);
}
+
private String writeHistoryLine = "write-history 2012-02-11 09:03:39 "
+ "(900 s) 4713350144,4723824640,4710717440,4572675072";
+
private static ExtraInfoDescriptor createWithWriteHistoryLine(
String line) throws DescriptorParseException {
DescriptorBuilder db = new DescriptorBuilder();
db.writeHistoryLine = line;
return new RelayExtraInfoDescriptorImpl(db.buildDescriptor(), true);
}
+
private String readHistoryLine = "read-history 2012-02-11 09:03:39 "
+ "(900 s) 4707695616,4699666432,4650004480,4489718784";
+
private static ExtraInfoDescriptor createWithReadHistoryLine(
String line) throws DescriptorParseException {
DescriptorBuilder db = new DescriptorBuilder();
db.readHistoryLine = line;
return new RelayExtraInfoDescriptorImpl(db.buildDescriptor(), true);
}
+
private String dirreqWriteHistoryLine = "dirreq-write-history "
+ "2012-02-11 09:03:39 (900 s) 81281024,64996352,60625920,"
+ "67922944";
+
private static ExtraInfoDescriptor createWithDirreqWriteHistoryLine(
String line) throws DescriptorParseException {
DescriptorBuilder db = new DescriptorBuilder();
db.dirreqWriteHistoryLine = line;
return new RelayExtraInfoDescriptorImpl(db.buildDescriptor(), true);
}
+
private String dirreqReadHistoryLine = "dirreq-read-history "
+ "2012-02-11 09:03:39 (900 s) 17074176,16235520,16005120,"
+ "16209920";
+
private static ExtraInfoDescriptor createWithDirreqReadHistoryLine(
String line) throws DescriptorParseException {
DescriptorBuilder db = new DescriptorBuilder();
db.dirreqReadHistoryLine = line;
return new RelayExtraInfoDescriptorImpl(db.buildDescriptor(), true);
}
+
private String geoipDbDigestLine = null;
+
private static ExtraInfoDescriptor createWithGeoipDbDigestLine(
String line) throws DescriptorParseException {
DescriptorBuilder db = new DescriptorBuilder();
db.geoipDbDigestLine = line;
return new RelayExtraInfoDescriptorImpl(db.buildDescriptor(), true);
}
+
private String geoip6DbDigestLine = null;
+
private static ExtraInfoDescriptor createWithGeoip6DbDigestLine(
String line) throws DescriptorParseException {
DescriptorBuilder db = new DescriptorBuilder();
db.geoip6DbDigestLine = line;
return new RelayExtraInfoDescriptorImpl(db.buildDescriptor(), true);
}
+
private String geoipStatsLines = null;
+
private static ExtraInfoDescriptor createWithGeoipStatsLines(
String lines) throws DescriptorParseException {
DescriptorBuilder db = new DescriptorBuilder();
db.geoipStatsLines = lines;
return new RelayExtraInfoDescriptorImpl(db.buildDescriptor(), true);
}
+
private String dirreqStatsLines = null;
+
private static ExtraInfoDescriptor createWithDirreqStatsLines(
String lines) throws DescriptorParseException {
DescriptorBuilder db = new DescriptorBuilder();
db.dirreqStatsLines = lines;
return new RelayExtraInfoDescriptorImpl(db.buildDescriptor(), true);
}
+
private String entryStatsLines = null;
+
private static ExtraInfoDescriptor createWithEntryStatsLines(
String lines) throws DescriptorParseException {
DescriptorBuilder db = new DescriptorBuilder();
db.entryStatsLines = lines;
return new RelayExtraInfoDescriptorImpl(db.buildDescriptor(), true);
}
+
private String cellStatsLines = null;
+
private static ExtraInfoDescriptor createWithCellStatsLines(
String lines) throws DescriptorParseException {
DescriptorBuilder db = new DescriptorBuilder();
db.cellStatsLines = lines;
return new RelayExtraInfoDescriptorImpl(db.buildDescriptor(), true);
}
+
private String connBiDirectLine = null;
+
private static ExtraInfoDescriptor createWithConnBiDirectLine(
String line) throws DescriptorParseException {
DescriptorBuilder db = new DescriptorBuilder();
db.connBiDirectLine = line;
return new RelayExtraInfoDescriptorImpl(db.buildDescriptor(), true);
}
+
private String exitStatsLines = null;
+
private static ExtraInfoDescriptor createWithExitStatsLines(
String lines) throws DescriptorParseException {
DescriptorBuilder db = new DescriptorBuilder();
db.exitStatsLines = lines;
return new RelayExtraInfoDescriptorImpl(db.buildDescriptor(), true);
}
+
private String bridgeStatsLines = null;
+
private static ExtraInfoDescriptor createWithBridgeStatsLines(
String lines) throws DescriptorParseException {
DescriptorBuilder db = new DescriptorBuilder();
db.bridgeStatsLines = lines;
return new RelayExtraInfoDescriptorImpl(db.buildDescriptor(), true);
}
+
private String hidservStatsLines = null;
+
private static ExtraInfoDescriptor createWithHidservStatsLines(
String lines) throws DescriptorParseException {
DescriptorBuilder db = new DescriptorBuilder();
db.hidservStatsLines = lines;
return new RelayExtraInfoDescriptorImpl(db.buildDescriptor(), true);
}
+
private String unrecognizedLine = null;
+
private static ExtraInfoDescriptor createWithUnrecognizedLine(
String line, boolean failUnrecognizedDescriptorLines)
throws DescriptorParseException {
@@ -154,7 +190,9 @@ public class ExtraInfoDescriptorImplTest {
return new RelayExtraInfoDescriptorImpl(db.buildDescriptor(),
failUnrecognizedDescriptorLines);
}
+
private byte[] nonAsciiLineBytes = null;
+
private static ExtraInfoDescriptor createWithNonAsciiLineBytes(
byte[] lineBytes, boolean failUnrecognizedDescriptorLines)
throws DescriptorParseException {
@@ -163,20 +201,27 @@ public class ExtraInfoDescriptorImplTest {
return new RelayExtraInfoDescriptorImpl(db.buildDescriptor(),
failUnrecognizedDescriptorLines);
}
+
private String routerSignatureLines = "router-signature\n"
+ "-----BEGIN SIGNATURE-----\n"
+ "o4j+kH8UQfjBwepUnr99v0ebN8RpzHJ/lqYsTojXHy9kMr1RNI9IDeSzA7PSqT"
+ "uV\n4PL8QsGtlfwthtIoZpB2srZeyN/mcpA9fa1JXUrt/UN9K/+32Cyaad7h0n"
+ "HE6Xfb\njqpXDpnBpvk4zjmzjjKYnIsUWTnADmu0fo3xTRqXi7g=\n"
+ "-----END SIGNATURE-----";
+
private static ExtraInfoDescriptor createWithRouterSignatureLines(
String line) throws DescriptorParseException {
DescriptorBuilder db = new DescriptorBuilder();
db.routerSignatureLines = line;
return new RelayExtraInfoDescriptorImpl(db.buildDescriptor(), true);
}
- private String identityEd25519Lines = null,
- masterKeyEd25519Line = null, routerSigEd25519Line = null;
+
+ private String identityEd25519Lines = null;
+
+ private String masterKeyEd25519Line = null;
+
+ private String routerSigEd25519Line = null;
+
private static ExtraInfoDescriptor createWithEd25519Lines(
String identityEd25519Lines, String masterKeyEd25519Line,
String routerSigEd25519Line) throws DescriptorParseException {
@@ -186,6 +231,7 @@ public class ExtraInfoDescriptorImplTest {
db.routerSigEd25519Line = routerSigEd25519Line;
return new RelayExtraInfoDescriptorImpl(db.buildDescriptor(), true);
}
+
private byte[] buildDescriptor() {
StringBuilder sb = new StringBuilder();
if (this.extraInfoLine != null) {
@@ -272,8 +318,10 @@ public class ExtraInfoDescriptorImplTest {
/* Helper class to build a set of geoip-stats lines based on default
* data and modifications requested by test methods. */
private static class GeoipStatsBuilder {
+
private String geoipStartTimeLine = "geoip-start-time 2012-02-10 "
+ "18:32:51";
+
private static ExtraInfoDescriptor createWithGeoipStartTimeLine(
String line) throws DescriptorParseException {
GeoipStatsBuilder gsb = new GeoipStatsBuilder();
@@ -281,8 +329,10 @@ public class ExtraInfoDescriptorImplTest {
return DescriptorBuilder.createWithGeoipStatsLines(
gsb.buildGeoipStatsLines());
}
+
private String geoipClientOriginsLine = "geoip-client-origins "
+ "de=1152,cn=896,us=712,it=504,ru=352,fr=208,gb=208,ir=200";
+
private static ExtraInfoDescriptor createWithGeoipClientOriginsLine(
String line) throws DescriptorParseException {
GeoipStatsBuilder gsb = new GeoipStatsBuilder();
@@ -290,11 +340,13 @@ public class ExtraInfoDescriptorImplTest {
return DescriptorBuilder.createWithGeoipStatsLines(
gsb.buildGeoipStatsLines());
}
+
private static ExtraInfoDescriptor createWithDefaultLines()
throws DescriptorParseException {
return DescriptorBuilder.createWithGeoipStatsLines(
new GeoipStatsBuilder().buildGeoipStatsLines());
}
+
private String buildGeoipStatsLines() {
StringBuilder sb = new StringBuilder();
if (this.geoipStartTimeLine != null) {
@@ -314,8 +366,10 @@ public class ExtraInfoDescriptorImplTest {
/* Helper class to build a set of dirreq-stats lines based on default
* data and modifications requested by test methods. */
private static class DirreqStatsBuilder {
+
private String dirreqStatsEndLine = "dirreq-stats-end 2012-02-11 "
+ "00:59:53 (86400 s)";
+
private static ExtraInfoDescriptor createWithDirreqStatsEndLine(
String line) throws DescriptorParseException {
DirreqStatsBuilder dsb = new DirreqStatsBuilder();
@@ -323,8 +377,10 @@ public class ExtraInfoDescriptorImplTest {
return DescriptorBuilder.createWithDirreqStatsLines(
dsb.buildDirreqStatsLines());
}
+
private String dirreqV3IpsLine = "dirreq-v3-ips us=1544,de=1056,"
+ "it=1032,fr=784,es=640,ru=440,br=312,gb=272,kr=224,sy=192";
+
private static ExtraInfoDescriptor createWithDirreqV3IpsLine(
String line) throws DescriptorParseException {
DirreqStatsBuilder dsb = new DirreqStatsBuilder();
@@ -332,7 +388,9 @@ public class ExtraInfoDescriptorImplTest {
return DescriptorBuilder.createWithDirreqStatsLines(
dsb.buildDirreqStatsLines());
}
+
private String dirreqV2IpsLine = "dirreq-v2-ips ";
+
private static ExtraInfoDescriptor createWithDirreqV2IpsLine(
String line) throws DescriptorParseException {
DirreqStatsBuilder dsb = new DirreqStatsBuilder();
@@ -340,8 +398,10 @@ public class ExtraInfoDescriptorImplTest {
return DescriptorBuilder.createWithDirreqStatsLines(
dsb.buildDirreqStatsLines());
}
+
private String dirreqV3ReqsLine = "dirreq-v3-reqs us=1744,de=1224,"
+ "it=1080,fr=832,es=664,ru=536,br=344,gb=296,kr=272,in=216";
+
private static ExtraInfoDescriptor createWithDirreqV3ReqsLine(
String line) throws DescriptorParseException {
DirreqStatsBuilder dsb = new DirreqStatsBuilder();
@@ -349,7 +409,9 @@ public class ExtraInfoDescriptorImplTest {
return DescriptorBuilder.createWithDirreqStatsLines(
dsb.buildDirreqStatsLines());
}
+
private String dirreqV2ReqsLine = "dirreq-v2-reqs ";
+
private static ExtraInfoDescriptor createWithDirreqV2ReqsLine(
String line) throws DescriptorParseException {
DirreqStatsBuilder dsb = new DirreqStatsBuilder();
@@ -357,9 +419,11 @@ public class ExtraInfoDescriptorImplTest {
return DescriptorBuilder.createWithDirreqStatsLines(
dsb.buildDirreqStatsLines());
}
+
private String dirreqV3RespLine = "dirreq-v3-resp ok=10848,"
+ "not-enough-sigs=8,unavailable=0,not-found=0,not-modified=0,"
+ "busy=80";
+
private static ExtraInfoDescriptor createWithDirreqV3RespLine(
String line) throws DescriptorParseException {
DirreqStatsBuilder dsb = new DirreqStatsBuilder();
@@ -367,8 +431,10 @@ public class ExtraInfoDescriptorImplTest {
return DescriptorBuilder.createWithDirreqStatsLines(
dsb.buildDirreqStatsLines());
}
+
private String dirreqV2RespLine = "dirreq-v2-resp ok=0,unavailable=0,"
+ "not-found=1576,not-modified=0,busy=0";
+
private static ExtraInfoDescriptor createWithDirreqV2RespLine(
String line) throws DescriptorParseException {
DirreqStatsBuilder dsb = new DirreqStatsBuilder();
@@ -376,7 +442,9 @@ public class ExtraInfoDescriptorImplTest {
return DescriptorBuilder.createWithDirreqStatsLines(
dsb.buildDirreqStatsLines());
}
+
private String dirreqV2ShareLine = "dirreq-v2-share 0.37%";
+
private static ExtraInfoDescriptor createWithDirreqV2ShareLine(
String line) throws DescriptorParseException {
DirreqStatsBuilder dsb = new DirreqStatsBuilder();
@@ -384,7 +452,9 @@ public class ExtraInfoDescriptorImplTest {
return DescriptorBuilder.createWithDirreqStatsLines(
dsb.buildDirreqStatsLines());
}
+
private String dirreqV3ShareLine = "dirreq-v3-share 0.37%";
+
private static ExtraInfoDescriptor createWithDirreqV3ShareLine(
String line) throws DescriptorParseException {
DirreqStatsBuilder dsb = new DirreqStatsBuilder();
@@ -392,10 +462,12 @@ public class ExtraInfoDescriptorImplTest {
return DescriptorBuilder.createWithDirreqStatsLines(
dsb.buildDirreqStatsLines());
}
+
private String dirreqV3DirectDlLine = "dirreq-v3-direct-dl "
+ "complete=36,timeout=4,running=0,min=7538,d1=20224,d2=28950,"
+ "q1=40969,d3=55786,d4=145813,md=199164,d6=267230,d7=480900,"
+ "q3=481049,d8=531276,d9=778086,max=15079428";
+
private static ExtraInfoDescriptor createWithDirreqV3DirectDlLine(
String line) throws DescriptorParseException {
DirreqStatsBuilder dsb = new DirreqStatsBuilder();
@@ -403,8 +475,10 @@ public class ExtraInfoDescriptorImplTest {
return DescriptorBuilder.createWithDirreqStatsLines(
dsb.buildDirreqStatsLines());
}
+
private String dirreqV2DirectDlLine = "dirreq-v2-direct-dl "
+ "complete=0,timeout=0,running=0";
+
private static ExtraInfoDescriptor createWithDirreqV2DirectDlLine(
String line) throws DescriptorParseException {
DirreqStatsBuilder dsb = new DirreqStatsBuilder();
@@ -412,10 +486,12 @@ public class ExtraInfoDescriptorImplTest {
return DescriptorBuilder.createWithDirreqStatsLines(
dsb.buildDirreqStatsLines());
}
+
private String dirreqV3TunneledDlLine = "dirreq-v3-tunneled-dl "
+ "complete=10608,timeout=204,running=4,min=507,d1=20399,"
+ "d2=27588,q1=29292,d3=30889,d4=40624,md=59967,d6=103333,"
+ "d7=161170,q3=209415,d8=256711,d9=452503,max=23417777";
+
private static ExtraInfoDescriptor createWithDirreqV3TunneledDlLine(
String line) throws DescriptorParseException {
DirreqStatsBuilder dsb = new DirreqStatsBuilder();
@@ -423,8 +499,10 @@ public class ExtraInfoDescriptorImplTest {
return DescriptorBuilder.createWithDirreqStatsLines(
dsb.buildDirreqStatsLines());
}
+
private String dirreqV2TunneledDlLine = "dirreq-v2-tunneled-dl "
+ "complete=0,timeout=0,running=0";
+
private static ExtraInfoDescriptor createWithDirreqV2TunneledDlLine(
String line) throws DescriptorParseException {
DirreqStatsBuilder dsb = new DirreqStatsBuilder();
@@ -432,11 +510,13 @@ public class ExtraInfoDescriptorImplTest {
return DescriptorBuilder.createWithDirreqStatsLines(
dsb.buildDirreqStatsLines());
}
+
private static ExtraInfoDescriptor createWithDefaultLines()
throws DescriptorParseException {
return DescriptorBuilder.createWithDirreqStatsLines(
new DirreqStatsBuilder().buildDirreqStatsLines());
}
+
private String buildDirreqStatsLines() {
StringBuilder sb = new StringBuilder();
if (this.dirreqStatsEndLine != null) {
@@ -489,8 +569,10 @@ public class ExtraInfoDescriptorImplTest {
/* Helper class to build a set of entry-stats lines based on default
* data and modifications requested by test methods. */
private static class EntryStatsBuilder {
+
private String entryStatsEndLine = "entry-stats-end 2012-02-11 "
+ "01:59:39 (86400 s)";
+
private static ExtraInfoDescriptor createWithEntryStatsEndLine(
String line) throws DescriptorParseException {
EntryStatsBuilder esb = new EntryStatsBuilder();
@@ -498,9 +580,11 @@ public class ExtraInfoDescriptorImplTest {
return DescriptorBuilder.createWithEntryStatsLines(
esb.buildEntryStatsLines());
}
+
private String entryIpsLine = "entry-ips ir=25368,us=15744,it=14816,"
+ "de=13256,es=8280,fr=8120,br=5176,sy=4760,ru=4504,sa=4216,"
+ "gb=3152,pl=2928,nl=2208,kr=1856,ca=1792,ua=1272,in=1192";
+
private static ExtraInfoDescriptor createWithEntryIpsLine(
String line) throws DescriptorParseException {
EntryStatsBuilder esb = new EntryStatsBuilder();
@@ -508,11 +592,13 @@ public class ExtraInfoDescriptorImplTest {
return DescriptorBuilder.createWithEntryStatsLines(
esb.buildEntryStatsLines());
}
+
private static ExtraInfoDescriptor createWithDefaultLines()
throws DescriptorParseException {
return DescriptorBuilder.createWithEntryStatsLines(
new EntryStatsBuilder().buildEntryStatsLines());
}
+
private String buildEntryStatsLines() {
StringBuilder sb = new StringBuilder();
if (this.entryStatsEndLine != null) {
@@ -532,8 +618,10 @@ public class ExtraInfoDescriptorImplTest {
/* Helper class to build a set of cell-stats lines based on default
* data and modifications requested by test methods. */
private static class CellStatsBuilder {
+
private String cellStatsEndLine = "cell-stats-end 2012-02-11 "
+ "01:59:39 (86400 s)";
+
private static ExtraInfoDescriptor createWithCellStatsEndLine(
String line) throws DescriptorParseException {
CellStatsBuilder csb = new CellStatsBuilder();
@@ -541,8 +629,10 @@ public class ExtraInfoDescriptorImplTest {
return DescriptorBuilder.createWithCellStatsLines(
csb.buildCellStatsLines());
}
+
private String cellProcessedCellsLine = "cell-processed-cells "
+ "1441,11,6,4,2,1,1,1,1,1";
+
private static ExtraInfoDescriptor createWithCellProcessedCellsLine(
String line) throws DescriptorParseException {
CellStatsBuilder csb = new CellStatsBuilder();
@@ -550,8 +640,10 @@ public class ExtraInfoDescriptorImplTest {
return DescriptorBuilder.createWithCellStatsLines(
csb.buildCellStatsLines());
}
+
private String cellQueuedCellsLine = "cell-queued-cells "
+ "3.29,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00";
+
private static ExtraInfoDescriptor createWithCellQueuedCellsLine(
String line) throws DescriptorParseException {
CellStatsBuilder csb = new CellStatsBuilder();
@@ -559,8 +651,10 @@ public class ExtraInfoDescriptorImplTest {
return DescriptorBuilder.createWithCellStatsLines(
csb.buildCellStatsLines());
}
+
private String cellTimeInQueueLine = "cell-time-in-queue "
+ "524,1,1,0,0,25,0,0,0,0";
+
private static ExtraInfoDescriptor createWithCellTimeInQueueLine(
String line) throws DescriptorParseException {
CellStatsBuilder csb = new CellStatsBuilder();
@@ -568,8 +662,10 @@ public class ExtraInfoDescriptorImplTest {
return DescriptorBuilder.createWithCellStatsLines(
csb.buildCellStatsLines());
}
+
private String cellCircuitsPerDecileLine = "cell-circuits-per-decile "
+ "866";
+
private static ExtraInfoDescriptor
createWithCellCircuitsPerDecileLine(String line)
throws DescriptorParseException {
@@ -578,11 +674,13 @@ public class ExtraInfoDescriptorImplTest {
return DescriptorBuilder.createWithCellStatsLines(
csb.buildCellStatsLines());
}
+
private static ExtraInfoDescriptor createWithDefaultLines()
throws DescriptorParseException {
return DescriptorBuilder.createWithCellStatsLines(
new CellStatsBuilder().buildCellStatsLines());
}
+
private String buildCellStatsLines() {
StringBuilder sb = new StringBuilder();
if (this.cellStatsEndLine != null) {
@@ -611,8 +709,10 @@ public class ExtraInfoDescriptorImplTest {
/* Helper class to build a set of exit-stats lines based on default
* data and modifications requested by test methods. */
private static class ExitStatsBuilder {
+
private String exitStatsEndLine = "exit-stats-end 2012-02-11 "
+ "01:59:39 (86400 s)";
+
private static ExtraInfoDescriptor createWithExitStatsEndLine(
String line) throws DescriptorParseException {
ExitStatsBuilder esb = new ExitStatsBuilder();
@@ -620,9 +720,11 @@ public class ExtraInfoDescriptorImplTest {
return DescriptorBuilder.createWithExitStatsLines(
esb.buildExitStatsLines());
}
+
private String exitKibibytesWrittenLine = "exit-kibibytes-written "
+ "25=74647,80=31370,443=20577,49755=23,52563=12,52596=1111,"
+ "57528=4,60912=11,61351=6,64811=3365,other=2592";
+
private static ExtraInfoDescriptor createWithExitKibibytesWrittenLine(
String line) throws DescriptorParseException {
ExitStatsBuilder esb = new ExitStatsBuilder();
@@ -630,10 +732,12 @@ public class ExtraInfoDescriptorImplTest {
return DescriptorBuilder.createWithExitStatsLines(
esb.buildExitStatsLines());
}
+
private String exitKibibytesReadLine = "exit-kibibytes-read "
+ "25=35562,80=1254256,443=110279,49755=9396,52563=1911,"
+ "52596=648,57528=1188,60912=1427,61351=1824,64811=14,"
+ "other=3054";
+
private static ExtraInfoDescriptor createWithExitKibibytesReadLine(
String line) throws DescriptorParseException {
ExitStatsBuilder esb = new ExitStatsBuilder();
@@ -641,9 +745,11 @@ public class ExtraInfoDescriptorImplTest {
return DescriptorBuilder.createWithExitStatsLines(
esb.buildExitStatsLines());
}
+
private String exitStreamsOpenedLine = "exit-streams-opened "
+ "25=369748,80=64212,443=151660,49755=4,52563=4,52596=4,57528=4,"
+ "60912=4,61351=4,64811=4,other=1212";
+
private static ExtraInfoDescriptor createWithExitStreamsOpenedLine(
String line) throws DescriptorParseException {
ExitStatsBuilder esb = new ExitStatsBuilder();
@@ -651,11 +757,13 @@ public class ExtraInfoDescriptorImplTest {
return DescriptorBuilder.createWithExitStatsLines(
esb.buildExitStatsLines());
}
+
private static ExtraInfoDescriptor createWithDefaultLines()
throws DescriptorParseException {
return DescriptorBuilder.createWithExitStatsLines(
new ExitStatsBuilder().buildExitStatsLines());
}
+
private String buildExitStatsLines() {
StringBuilder sb = new StringBuilder();
if (this.exitStatsEndLine != null) {
@@ -681,8 +789,10 @@ public class ExtraInfoDescriptorImplTest {
/* Helper class to build a set of bridge-stats lines based on default
* data and modifications requested by test methods. */
private static class BridgeStatsBuilder {
+
private String bridgeStatsEndLine = "bridge-stats-end 2012-02-11 "
+ "01:59:39 (86400 s)";
+
private static ExtraInfoDescriptor createWithBridgeStatsEndLine(
String line) throws DescriptorParseException {
BridgeStatsBuilder bsb = new BridgeStatsBuilder();
@@ -690,8 +800,10 @@ public class ExtraInfoDescriptorImplTest {
return DescriptorBuilder.createWithBridgeStatsLines(
bsb.buildBridgeStatsLines());
}
+
private String bridgeIpsLine = "bridge-ips ir=24,sy=16,??=8,cn=8,"
+ "de=8,es=8,fr=8,gb=8,in=8,jp=8,kz=8,nl=8,ua=8,us=8,vn=8,za=8";
+
private static ExtraInfoDescriptor createWithBridgeIpsLine(
String line) throws DescriptorParseException {
BridgeStatsBuilder bsb = new BridgeStatsBuilder();
@@ -699,7 +811,9 @@ public class ExtraInfoDescriptorImplTest {
return DescriptorBuilder.createWithBridgeStatsLines(
bsb.buildBridgeStatsLines());
}
+
private String bridgeIpVersionsLine = "bridge-ip-versions v4=8,v6=16";
+
private static ExtraInfoDescriptor createWithBridgeIpVersionsLine(
String line) throws DescriptorParseException {
BridgeStatsBuilder bsb = new BridgeStatsBuilder();
@@ -707,8 +821,10 @@ public class ExtraInfoDescriptorImplTest {
return DescriptorBuilder.createWithBridgeStatsLines(
bsb.buildBridgeStatsLines());
}
+
private String bridgeIpTransportsLine = "bridge-ip-transports "
+ "<OR>=8,obfs2=792,obfs3=1728";
+
private static ExtraInfoDescriptor createWithBridgeIpTransportsLine(
String line) throws DescriptorParseException {
BridgeStatsBuilder bsb = new BridgeStatsBuilder();
@@ -716,11 +832,13 @@ public class ExtraInfoDescriptorImplTest {
return DescriptorBuilder.createWithBridgeStatsLines(
bsb.buildBridgeStatsLines());
}
+
private static ExtraInfoDescriptor createWithDefaultLines()
throws DescriptorParseException {
return DescriptorBuilder.createWithBridgeStatsLines(
new BridgeStatsBuilder().buildBridgeStatsLines());
}
+
private String buildBridgeStatsLines() {
StringBuilder sb = new StringBuilder();
if (this.bridgeStatsEndLine != null) {
@@ -746,8 +864,10 @@ public class ExtraInfoDescriptorImplTest {
/* Helper class to build a set of hidserv-stats lines based on default
* data and modifications requested by test methods. */
private static class HidservStatsBuilder {
+
private String hidservStatsEndLine = "hidserv-stats-end 2015-12-03 "
+ "14:26:56 (86400 s)";
+
private static ExtraInfoDescriptor createWithHidservStatsEndLine(
String line) throws DescriptorParseException {
HidservStatsBuilder hsb = new HidservStatsBuilder();
@@ -755,9 +875,11 @@ public class ExtraInfoDescriptorImplTest {
return DescriptorBuilder.createWithHidservStatsLines(
hsb.buildHidservStatsLines());
}
+
private String hidservRendRelayedCellsLine =
"hidserv-rend-relayed-cells 36474281 delta_f=2048 epsilon=0.30 "
+ "bin_size=1024";
+
private static ExtraInfoDescriptor
createWithHidservRendRelayedCellsLine(String line)
throws DescriptorParseException {
@@ -766,8 +888,10 @@ public class ExtraInfoDescriptorImplTest {
return DescriptorBuilder.createWithHidservStatsLines(
hsb.buildHidservStatsLines());
}
+
private String hidservDirOnionsSeenLine = "hidserv-dir-onions-seen "
+ "-3 delta_f=8 epsilon=0.30 bin_size=8";
+
private static ExtraInfoDescriptor createWithHidservDirOnionsSeenLine(
String line) throws DescriptorParseException {
HidservStatsBuilder hsb = new HidservStatsBuilder();
@@ -775,11 +899,13 @@ public class ExtraInfoDescriptorImplTest {
return DescriptorBuilder.createWithHidservStatsLines(
hsb.buildHidservStatsLines());
}
+
private static ExtraInfoDescriptor createWithDefaultLines()
throws DescriptorParseException {
return DescriptorBuilder.createWithHidservStatsLines(
new HidservStatsBuilder().buildHidservStatsLines());
}
+
private String buildHidservStatsLines() {
StringBuilder sb = new StringBuilder();
if (this.hidservStatsEndLine != null) {
@@ -809,11 +935,11 @@ public class ExtraInfoDescriptorImplTest {
descriptor.getFingerprint());
assertEquals(1328951316000L, descriptor.getPublishedMillis());
assertNotNull(descriptor.getWriteHistory());
- assertEquals(1328951019000L, descriptor.getWriteHistory().
- getHistoryEndMillis());
+ assertEquals(1328951019000L, descriptor.getWriteHistory()
+ .getHistoryEndMillis());
assertEquals(900L, descriptor.getWriteHistory().getIntervalLength());
- assertEquals(4572675072L, (long) descriptor.getWriteHistory().
- getBandwidthValues().get(1328951019000L));
+ assertEquals(4572675072L, (long) descriptor.getWriteHistory()
+ .getBandwidthValues().get(1328951019000L));
assertNotNull(descriptor.getReadHistory());
assertNotNull(descriptor.getDirreqWriteHistory());
assertNotNull(descriptor.getDirreqReadHistory());
@@ -826,8 +952,8 @@ public class ExtraInfoDescriptorImplTest {
@Test()
public void testExtraInfoOpt() throws DescriptorParseException {
- ExtraInfoDescriptor descriptor = DescriptorBuilder.
- createWithExtraInfoLine("opt extra-info chaoscomputerclub5 "
+ ExtraInfoDescriptor descriptor = DescriptorBuilder
+ .createWithExtraInfoLine("opt extra-info chaoscomputerclub5 "
+ "A9C039A5FD02FCA06303DCFAABE25C5912C63B26");
assertEquals("chaoscomputerclub5", descriptor.getNickname());
assertEquals("A9C039A5FD02FCA06303DCFAABE25C5912C63B26",
@@ -837,8 +963,8 @@ public class ExtraInfoDescriptorImplTest {
@Test()
public void testExtraInfoNicknameTwoSpaces()
throws DescriptorParseException {
- ExtraInfoDescriptor descriptor = DescriptorBuilder.
- createWithExtraInfoLine("opt extra-info chaoscomputerclub5 "
+ ExtraInfoDescriptor descriptor = DescriptorBuilder
+ .createWithExtraInfoLine("opt extra-info chaoscomputerclub5 "
+ "A9C039A5FD02FCA06303DCFAABE25C5912C63B26");
assertEquals("chaoscomputerclub5", descriptor.getNickname());
assertEquals("A9C039A5FD02FCA06303DCFAABE25C5912C63B26",
@@ -899,15 +1025,15 @@ public class ExtraInfoDescriptorImplTest {
@Test()
public void testPublishedOpt() throws DescriptorParseException {
- ExtraInfoDescriptor descriptor = DescriptorBuilder.
- createWithPublishedLine("opt published 2012-02-11 09:08:36");
+ ExtraInfoDescriptor descriptor = DescriptorBuilder
+ .createWithPublishedLine("opt published 2012-02-11 09:08:36");
assertEquals(1328951316000L, descriptor.getPublishedMillis());
}
@Test()
public void testPublishedMillis() throws DescriptorParseException {
- ExtraInfoDescriptor descriptor = DescriptorBuilder.
- createWithPublishedLine("opt published 2012-02-11 09:08:36.123");
+ ExtraInfoDescriptor descriptor = DescriptorBuilder
+ .createWithPublishedLine("opt published 2012-02-11 09:08:36.123");
assertEquals(1328951316000L, descriptor.getPublishedMillis());
}
@@ -977,8 +1103,8 @@ public class ExtraInfoDescriptorImplTest {
@Test()
public void testGeoipDbDigestValid() throws DescriptorParseException {
- ExtraInfoDescriptor descriptor = DescriptorBuilder.
- createWithGeoipDbDigestLine("geoip-db-digest "
+ ExtraInfoDescriptor descriptor = DescriptorBuilder
+ .createWithGeoipDbDigestLine("geoip-db-digest "
+ "916A3CA8B7DF61473D5AE5B21711F35F301CE9E8");
assertEquals("916A3CA8B7DF61473D5AE5B21711F35F301CE9E8",
descriptor.getGeoipDbDigest());
@@ -1006,8 +1132,8 @@ public class ExtraInfoDescriptorImplTest {
@Test()
public void testGeoip6DbDigestValid() throws DescriptorParseException {
- ExtraInfoDescriptor descriptor = DescriptorBuilder.
- createWithGeoip6DbDigestLine("geoip6-db-digest "
+ ExtraInfoDescriptor descriptor = DescriptorBuilder
+ .createWithGeoip6DbDigestLine("geoip6-db-digest "
+ "916A3CA8B7DF61473D5AE5B21711F35F301CE9E8");
assertEquals("916A3CA8B7DF61473D5AE5B21711F35F301CE9E8",
descriptor.getGeoip6DbDigest());
@@ -1015,8 +1141,8 @@ public class ExtraInfoDescriptorImplTest {
@Test()
public void testGeoipStatsValid() throws DescriptorParseException {
- ExtraInfoDescriptor descriptor = GeoipStatsBuilder.
- createWithDefaultLines();
+ ExtraInfoDescriptor descriptor = GeoipStatsBuilder
+ .createWithDefaultLines();
assertEquals(1328898771000L, descriptor.getGeoipStartTimeMillis());
SortedMap<String, Integer> ips = descriptor.getGeoipClientOrigins();
assertNotNull(ips);
@@ -1117,8 +1243,8 @@ public class ExtraInfoDescriptorImplTest {
@Test()
public void testDirreqStatsValid() throws DescriptorParseException {
- ExtraInfoDescriptor descriptor = DirreqStatsBuilder.
- createWithDefaultLines();
+ ExtraInfoDescriptor descriptor = DirreqStatsBuilder
+ .createWithDefaultLines();
assertEquals(1328921993000L, descriptor.getDirreqStatsEndMillis());
assertEquals(86400L, descriptor.getDirreqStatsIntervalLength());
SortedMap<String, Integer> ips = descriptor.getDirreqV3Ips();
@@ -1237,8 +1363,8 @@ public class ExtraInfoDescriptorImplTest {
@Test()
public void testEntryStatsValid() throws DescriptorParseException {
- ExtraInfoDescriptor descriptor = EntryStatsBuilder.
- createWithDefaultLines();
+ ExtraInfoDescriptor descriptor = EntryStatsBuilder
+ .createWithDefaultLines();
assertEquals(1328925579000L, descriptor.getEntryStatsEndMillis());
assertEquals(86400L, descriptor.getEntryStatsIntervalLength());
SortedMap<String, Integer> ips = descriptor.getEntryIps();
@@ -1262,8 +1388,8 @@ public class ExtraInfoDescriptorImplTest {
@Test()
public void testCellStatsValid() throws DescriptorParseException {
- ExtraInfoDescriptor descriptor = CellStatsBuilder.
- createWithDefaultLines();
+ ExtraInfoDescriptor descriptor = CellStatsBuilder
+ .createWithDefaultLines();
assertEquals(1328925579000L, descriptor.getCellStatsEndMillis());
assertEquals(86400L, descriptor.getCellStatsIntervalLength());
List<Integer> processedCells = descriptor.getCellProcessedCells();
@@ -1319,8 +1445,8 @@ public class ExtraInfoDescriptorImplTest {
@Test()
public void testConnBiDirectValid()
throws DescriptorParseException {
- ExtraInfoDescriptor descriptor = DescriptorBuilder.
- createWithConnBiDirectLine("conn-bi-direct 2012-02-11 01:59:39 "
+ ExtraInfoDescriptor descriptor = DescriptorBuilder
+ .createWithConnBiDirectLine("conn-bi-direct 2012-02-11 01:59:39 "
+ "(86400 s) 42173,1591,1310,1744");
assertEquals(1328925579000L,
descriptor.getConnBiDirectStatsEndMillis());
@@ -1340,35 +1466,35 @@ public class ExtraInfoDescriptorImplTest {
@Test()
public void testExitStatsValid() throws DescriptorParseException {
- ExtraInfoDescriptor descriptor = ExitStatsBuilder.
- createWithDefaultLines();
+ ExtraInfoDescriptor descriptor = ExitStatsBuilder
+ .createWithDefaultLines();
assertEquals(1328925579000L, descriptor.getExitStatsEndMillis());
assertEquals(86400L, descriptor.getExitStatsIntervalLength());
String[] ports = new String[] { "25", "80", "443", "49755",
"52563", "52596", "57528", "60912", "61351", "64811", "other" };
int[] writtenValues = new int[] { 74647, 31370, 20577, 23, 12, 1111,
4, 11, 6, 3365, 2592 };
- int i = 0;
+ int index = 0;
for (Map.Entry<String, Long> e :
descriptor.getExitKibibytesWritten().entrySet()) {
- assertEquals(ports[i], e.getKey());
- assertEquals(writtenValues[i++], e.getValue().intValue());
+ assertEquals(ports[index], e.getKey());
+ assertEquals(writtenValues[index++], e.getValue().intValue());
}
int[] readValues = new int[] { 35562, 1254256, 110279, 9396, 1911,
648, 1188, 1427, 1824, 14, 3054 };
- i = 0;
+ index = 0;
for (Map.Entry<String, Long> e :
descriptor.getExitKibibytesRead().entrySet()) {
- assertEquals(ports[i], e.getKey());
- assertEquals(readValues[i++], e.getValue().intValue());
+ assertEquals(ports[index], e.getKey());
+ assertEquals(readValues[index++], e.getValue().intValue());
}
int[] streamsValues = new int[] { 369748, 64212, 151660, 4, 4, 4, 4,
4, 4, 4, 1212 };
- i = 0;
+ index = 0;
for (Map.Entry<String, Long> e :
descriptor.getExitStreamsOpened().entrySet()) {
- assertEquals(ports[i], e.getKey());
- assertEquals(streamsValues[i++], e.getValue().intValue());
+ assertEquals(ports[index], e.getKey());
+ assertEquals(streamsValues[index++], e.getValue().intValue());
}
}
@@ -1416,8 +1542,8 @@ public class ExtraInfoDescriptorImplTest {
@Test()
public void testBridgeStatsValid() throws DescriptorParseException {
- ExtraInfoDescriptor descriptor = BridgeStatsBuilder.
- createWithDefaultLines();
+ ExtraInfoDescriptor descriptor = BridgeStatsBuilder
+ .createWithDefaultLines();
assertEquals(1328925579000L, descriptor.getBridgeStatsEndMillis());
assertEquals(86400L, descriptor.getBridgeStatsIntervalLength());
SortedMap<String, Integer> ips = descriptor.getBridgeIps();
@@ -1482,8 +1608,8 @@ public class ExtraInfoDescriptorImplTest {
@Test()
public void testHidservStatsValid() throws DescriptorParseException {
- ExtraInfoDescriptor descriptor = HidservStatsBuilder.
- createWithDefaultLines();
+ ExtraInfoDescriptor descriptor = HidservStatsBuilder
+ .createWithDefaultLines();
assertEquals(1449152816000L, descriptor.getHidservStatsEndMillis());
assertEquals(86400L, descriptor.getHidservStatsIntervalLength());
assertEquals(36474281.0, descriptor.getHidservRendRelayedCells(),
@@ -1575,8 +1701,8 @@ public class ExtraInfoDescriptorImplTest {
public void testUnrecognizedLineIgnore()
throws DescriptorParseException {
String unrecognizedLine = "unrecognized-line 1";
- ExtraInfoDescriptor descriptor = DescriptorBuilder.
- createWithUnrecognizedLine(unrecognizedLine, false);
+ ExtraInfoDescriptor descriptor = DescriptorBuilder
+ .createWithUnrecognizedLine(unrecognizedLine, false);
List<String> unrecognizedLines = new ArrayList<>();
unrecognizedLines.add(unrecognizedLine);
assertEquals(unrecognizedLines, descriptor.getUnrecognizedLines());
@@ -1727,7 +1853,8 @@ public class ExtraInfoDescriptorImplTest {
+ "geoip6-db-digest 212DE17D5A368DCAFA19B95F168BFFA101145A93\n"
+ "router-digest-sha256 "
+ "TvrqpjI7OmCtwGwair/NHUxg5ROVVQYz6/EDyXsDHR4\n"
- + "router-digest 00B98F076B586272C3172B7F3DA29ADEE75F2ED8\n").getBytes();
+ + "router-digest 00B98F076B586272C3172B7F3DA29ADEE75F2ED8\n")
+ .getBytes();
BridgeExtraInfoDescriptor descriptor =
new BridgeExtraInfoDescriptorImpl(descriptorBytes, true);
assertEquals("TvrqpjI7OmCtwGwair/NHUxg5ROVVQYz6/EDyXsDHR4",
diff --git a/src/test/java/org/torproject/descriptor/impl/MicrodescriptorImplTest.java b/src/test/java/org/torproject/descriptor/impl/MicrodescriptorImplTest.java
index abb51db..20b0849 100644
--- a/src/test/java/org/torproject/descriptor/impl/MicrodescriptorImplTest.java
+++ b/src/test/java/org/torproject/descriptor/impl/MicrodescriptorImplTest.java
@@ -1,20 +1,19 @@
+/* Copyright 2015--2017 The Tor Project
+ * See LICENSE for licensing information */
+
package org.torproject.descriptor.impl;
-import org.junit.Test;
import org.torproject.descriptor.DescriptorParseException;
import org.torproject.descriptor.Microdescriptor;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import org.junit.Test;
public class MicrodescriptorImplTest {
/* Helper class to build a microdescriptor based on default data and
* modifications requested by test methods. */
private static class DescriptorBuilder {
+
private String onionKeyLines = "onion-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBALNZ4pNsHHkl7a+kFWbBmPHNAepjjvuhjTr1TaMB3UKuCRaXJmS2Qr"
@@ -22,20 +21,25 @@ public class MicrodescriptorImplTest {
+ "UutXaZ\nfkyty5XOgV4Qucx9wokzTMCHlO0V0x9y0FwFsK5Nb6ugqfQLLQ6XAg"
+ "MBAAE=\n"
+ "-----END RSA PUBLIC KEY-----";
+
private static Microdescriptor createWithDefaultLines()
throws DescriptorParseException {
DescriptorBuilder db = new DescriptorBuilder();
return new MicrodescriptorImpl(db.buildDescriptor(), true);
}
+
private String ntorOnionKeyLine =
"ntor-onion-key PXLa7IGE+TzPDMsM5j9rFnDa37rd6kfZa5QuzqqJukw=";
+
private String idLine = "id rsa1024 bvegfGxp8k7T9QFpjPTrPaJTa/8";
+
private static Microdescriptor createWithIdLine(String line)
throws DescriptorParseException {
DescriptorBuilder db = new DescriptorBuilder();
db.idLine = line;
return new MicrodescriptorImpl(db.buildDescriptor(), true);
}
+
private byte[] buildDescriptor() {
StringBuilder sb = new StringBuilder();
if (this.onionKeyLines != null) {
diff --git a/src/test/java/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImplTest.java b/src/test/java/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImplTest.java
index 57a2d89..ebcbd83 100644
--- a/src/test/java/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImplTest.java
+++ b/src/test/java/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImplTest.java
@@ -1,9 +1,7 @@
/* Copyright 2011--2017 The Tor Project
* See LICENSE for licensing information */
-package org.torproject.descriptor.impl;
-import org.torproject.descriptor.DescriptorParseException;
-import org.torproject.descriptor.DirectorySignature;
+package org.torproject.descriptor.impl;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -11,15 +9,17 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+import org.torproject.descriptor.DescriptorParseException;
+import org.torproject.descriptor.DirectorySignature;
+import org.torproject.descriptor.NetworkStatusEntry;
+import org.torproject.descriptor.RelayNetworkStatusConsensus;
+
+import org.junit.Test;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-
-import org.junit.Test;
-import org.torproject.descriptor.NetworkStatusEntry;
-import org.torproject.descriptor.RelayNetworkStatusConsensus;
-
/* TODO Add test cases for all lines starting with "opt ". */
/* Test parsing of network status consensuses. The main focus is on
@@ -31,6 +31,7 @@ public class RelayNetworkStatusConsensusImplTest {
/* Helper class to build a directory source based on default data and
* modifications requested by test methods. */
private static class DirSourceBuilder {
+
private static RelayNetworkStatusConsensus
createWithDirSource(String dirSourceString)
throws DescriptorParseException {
@@ -39,7 +40,9 @@ public class RelayNetworkStatusConsensusImplTest {
return new RelayNetworkStatusConsensusImpl(cb.buildConsensus(),
true);
}
+
private String nickname = "gabelmoo";
+
private static RelayNetworkStatusConsensus
createWithNickname(String string)
throws DescriptorParseException {
@@ -47,7 +50,9 @@ public class RelayNetworkStatusConsensusImplTest {
dsb.nickname = string;
return createWithDirSource(dsb.buildDirSource());
}
+
private String identity = "ED03BB616EB2F60BEC80151114BB25CEF515B226";
+
private static RelayNetworkStatusConsensus
createWithIdentity(String string)
throws DescriptorParseException {
@@ -55,7 +60,9 @@ public class RelayNetworkStatusConsensusImplTest {
dsb.identity = string;
return createWithDirSource(dsb.buildDirSource());
}
+
private String hostName = "212.112.245.170";
+
private static RelayNetworkStatusConsensus
createWithHostName(String string)
throws DescriptorParseException {
@@ -63,7 +70,9 @@ public class RelayNetworkStatusConsensusImplTest {
dsb.hostName = string;
return createWithDirSource(dsb.buildDirSource());
}
+
private String address = "212.112.245.170";
+
private static RelayNetworkStatusConsensus
createWithAddress(String string)
throws DescriptorParseException {
@@ -71,7 +80,9 @@ public class RelayNetworkStatusConsensusImplTest {
dsb.address = string;
return createWithDirSource(dsb.buildDirSource());
}
+
private String dirPort = "80";
+
private static RelayNetworkStatusConsensus
createWithDirPort(String string)
throws DescriptorParseException {
@@ -79,7 +90,9 @@ public class RelayNetworkStatusConsensusImplTest {
dsb.dirPort = string;
return createWithDirSource(dsb.buildDirSource());
}
+
private String orPort = "443";
+
private static RelayNetworkStatusConsensus
createWithOrPort(String string)
throws DescriptorParseException {
@@ -87,8 +100,10 @@ public class RelayNetworkStatusConsensusImplTest {
dsb.orPort = string;
return createWithDirSource(dsb.buildDirSource());
}
+
private String contactLine = "contact 4096R/C5AA446D Sebastian Hahn "
+ "<tor(a)sebastianhahn.net>";
+
private static RelayNetworkStatusConsensus
createWithContactLine(String line)
throws DescriptorParseException {
@@ -96,8 +111,10 @@ public class RelayNetworkStatusConsensusImplTest {
dsb.contactLine = line;
return createWithDirSource(dsb.buildDirSource());
}
+
private String voteDigestLine =
"vote-digest 0F398A5834D2C139E1D92310B09F814F243354D1";
+
private static RelayNetworkStatusConsensus
createWithVoteDigestLine(String line)
throws DescriptorParseException {
@@ -105,6 +122,7 @@ public class RelayNetworkStatusConsensusImplTest {
dsb.voteDigestLine = line;
return createWithDirSource(dsb.buildDirSource());
}
+
private String buildDirSource() {
StringBuilder sb = new StringBuilder();
String dirSourceLine = "dir-source " + this.nickname + " "
@@ -127,6 +145,7 @@ public class RelayNetworkStatusConsensusImplTest {
/* Helper class to build a status entry based on default data and
* modifications requested by test methods. */
private static class StatusEntryBuilder {
+
private static RelayNetworkStatusConsensus
createWithStatusEntry(String statusEntryString)
throws DescriptorParseException {
@@ -135,7 +154,9 @@ public class RelayNetworkStatusConsensusImplTest {
return new RelayNetworkStatusConsensusImpl(cb.buildConsensus(),
true);
}
+
private String nickname = "right2privassy3";
+
private static RelayNetworkStatusConsensus
createWithNickname(String string)
throws DescriptorParseException {
@@ -143,7 +164,9 @@ public class RelayNetworkStatusConsensusImplTest {
seb.nickname = string;
return createWithStatusEntry(seb.buildStatusEntry());
}
+
private String fingerprintBase64 = "ADQ6gCT3DiFHKPDFr3rODBUI8HM";
+
private static RelayNetworkStatusConsensus
createWithFingerprintBase64(String string)
throws DescriptorParseException {
@@ -151,7 +174,9 @@ public class RelayNetworkStatusConsensusImplTest {
seb.fingerprintBase64 = string;
return createWithStatusEntry(seb.buildStatusEntry());
}
+
private String descriptorBase64 = "Yiti+nayuT2Efe2X1+M4nslwVuU";
+
private static RelayNetworkStatusConsensus
createWithDescriptorBase64(String string)
throws DescriptorParseException {
@@ -159,7 +184,9 @@ public class RelayNetworkStatusConsensusImplTest {
seb.descriptorBase64 = string;
return createWithStatusEntry(seb.buildStatusEntry());
}
+
private String publishedString = "2011-11-29 21:34:27";
+
private static RelayNetworkStatusConsensus
createWithPublishedString(String string)
throws DescriptorParseException {
@@ -167,55 +194,75 @@ public class RelayNetworkStatusConsensusImplTest {
seb.publishedString = string;
return createWithStatusEntry(seb.buildStatusEntry());
}
+
private String address = "50.63.8.215";
+
private static RelayNetworkStatusConsensus
createWithAddress(String string) throws DescriptorParseException {
StatusEntryBuilder seb = new StatusEntryBuilder();
seb.address = string;
return createWithStatusEntry(seb.buildStatusEntry());
}
+
private String orPort = "9023";
+
private static RelayNetworkStatusConsensus
createWithOrPort(String string) throws DescriptorParseException {
StatusEntryBuilder seb = new StatusEntryBuilder();
seb.orPort = string;
return createWithStatusEntry(seb.buildStatusEntry());
}
+
private String dirPort = "0";
+
private static RelayNetworkStatusConsensus
createWithDirPort(String string) throws DescriptorParseException {
StatusEntryBuilder seb = new StatusEntryBuilder();
seb.dirPort = string;
return createWithStatusEntry(seb.buildStatusEntry());
}
+
+ @SuppressWarnings("checkstyle:membername")
private String sLine = "s Exit Fast Named Running Stable Valid";
+
private static RelayNetworkStatusConsensus
createWithSLine(String line) throws DescriptorParseException {
StatusEntryBuilder seb = new StatusEntryBuilder();
seb.sLine = line;
return createWithStatusEntry(seb.buildStatusEntry());
}
+
+ @SuppressWarnings("checkstyle:membername")
private String vLine = "v Tor 0.2.1.29 (r8e9b25e6c7a2e70c)";
+
private static RelayNetworkStatusConsensus
createWithVLine(String line) throws DescriptorParseException {
StatusEntryBuilder seb = new StatusEntryBuilder();
seb.vLine = line;
return createWithStatusEntry(seb.buildStatusEntry());
}
+
+ @SuppressWarnings("checkstyle:membername")
private String wLine = "w Bandwidth=1";
+
private static RelayNetworkStatusConsensus
createWithWLine(String line) throws DescriptorParseException {
StatusEntryBuilder seb = new StatusEntryBuilder();
seb.wLine = line;
return createWithStatusEntry(seb.buildStatusEntry());
}
+
+ @SuppressWarnings("checkstyle:membername")
private String pLine = "p accept 80,1194,1220,1293";
+
private static RelayNetworkStatusConsensus
createWithPLine(String line) throws DescriptorParseException {
StatusEntryBuilder seb = new StatusEntryBuilder();
seb.pLine = line;
return createWithStatusEntry(seb.buildStatusEntry());
}
+
+ @SuppressWarnings("checkstyle:localvariablename")
private String buildStatusEntry() {
StringBuilder sb = new StringBuilder();
String rLine = "r " + nickname + " " + fingerprintBase64 + " "
@@ -244,6 +291,7 @@ public class RelayNetworkStatusConsensusImplTest {
/* Helper class to build a directory signature based on default data and
* modifications requested by test methods. */
private static class DirectorySignatureBuilder {
+
private static RelayNetworkStatusConsensus
createWithDirectorySignature(String directorySignatureString)
throws DescriptorParseException {
@@ -252,7 +300,9 @@ public class RelayNetworkStatusConsensusImplTest {
return new RelayNetworkStatusConsensusImpl(cb.buildConsensus(),
true);
}
+
private String identity = "ED03BB616EB2F60BEC80151114BB25CEF515B226";
+
private static RelayNetworkStatusConsensus
createWithIdentity(String string)
throws DescriptorParseException {
@@ -260,8 +310,10 @@ public class RelayNetworkStatusConsensusImplTest {
dsb.identity = string;
return createWithDirectorySignature(dsb.buildDirectorySignature());
}
+
private String signingKey =
"845CF1D0B370CA443A8579D18E7987E7E532F639";
+
private static RelayNetworkStatusConsensus
createWithSigningKey(String string)
throws DescriptorParseException {
@@ -269,6 +321,7 @@ public class RelayNetworkStatusConsensusImplTest {
dsb.signingKey = string;
return createWithDirectorySignature(dsb.buildDirectorySignature());
}
+
private String buildDirectorySignature() {
String directorySignature = "directory-signature " + identity + " "
+ signingKey + "\n"
@@ -1093,16 +1146,16 @@ public class RelayNetworkStatusConsensusImplTest {
@Test()
public void testBandwidthWeightsLineNoSpace()
throws DescriptorParseException {
- RelayNetworkStatusConsensus consensus = ConsensusBuilder.
- createWithBandwidthWeightsLine("bandwidth-weights");
+ RelayNetworkStatusConsensus consensus = ConsensusBuilder
+ .createWithBandwidthWeightsLine("bandwidth-weights");
assertNotNull(consensus.getBandwidthWeights());
}
@Test()
public void testBandwidthWeightsLineOneSpace()
throws DescriptorParseException {
- RelayNetworkStatusConsensus consensus = ConsensusBuilder.
- createWithBandwidthWeightsLine("bandwidth-weights ");
+ RelayNetworkStatusConsensus consensus = ConsensusBuilder
+ .createWithBandwidthWeightsLine("bandwidth-weights ");
assertNotNull(consensus.getBandwidthWeights());
}
@@ -1185,8 +1238,8 @@ public class RelayNetworkStatusConsensusImplTest {
public void testUnrecognizedHeaderLineIgnore()
throws DescriptorParseException {
String unrecognizedLine = "unrecognized-line 1";
- RelayNetworkStatusConsensus consensus = ConsensusBuilder.
- createWithUnrecognizedHeaderLine(unrecognizedLine, false);
+ RelayNetworkStatusConsensus consensus = ConsensusBuilder
+ .createWithUnrecognizedHeaderLine(unrecognizedLine, false);
List<String> unrecognizedLines = new ArrayList<>();
unrecognizedLines.add(unrecognizedLine);
assertEquals(unrecognizedLines, consensus.getUnrecognizedLines());
@@ -1204,8 +1257,8 @@ public class RelayNetworkStatusConsensusImplTest {
public void testUnrecognizedDirSourceLineIgnore()
throws DescriptorParseException {
String unrecognizedLine = "unrecognized-line 1";
- RelayNetworkStatusConsensus consensus = ConsensusBuilder.
- createWithUnrecognizedDirSourceLine(unrecognizedLine, false);
+ RelayNetworkStatusConsensus consensus = ConsensusBuilder
+ .createWithUnrecognizedDirSourceLine(unrecognizedLine, false);
List<String> unrecognizedLines = new ArrayList<>();
unrecognizedLines.add(unrecognizedLine);
assertEquals(unrecognizedLines, consensus.getUnrecognizedLines());
@@ -1223,8 +1276,8 @@ public class RelayNetworkStatusConsensusImplTest {
public void testUnrecognizedStatusEntryLineIgnore()
throws DescriptorParseException {
String unrecognizedLine = "unrecognized-line 1";
- RelayNetworkStatusConsensus consensus = ConsensusBuilder.
- createWithUnrecognizedStatusEntryLine(unrecognizedLine, false);
+ RelayNetworkStatusConsensus consensus = ConsensusBuilder
+ .createWithUnrecognizedStatusEntryLine(unrecognizedLine, false);
List<String> unrecognizedLines = new ArrayList<>();
unrecognizedLines.add(unrecognizedLine);
assertEquals(unrecognizedLines, consensus.getUnrecognizedLines());
@@ -1242,8 +1295,8 @@ public class RelayNetworkStatusConsensusImplTest {
public void testUnrecognizedDirectoryFooterLineIgnore()
throws DescriptorParseException {
String unrecognizedLine = "unrecognized-line 1";
- RelayNetworkStatusConsensus consensus = ConsensusBuilder.
- createWithUnrecognizedFooterLine(unrecognizedLine, false);
+ RelayNetworkStatusConsensus consensus = ConsensusBuilder
+ .createWithUnrecognizedFooterLine(unrecognizedLine, false);
List<String> unrecognizedLines = new ArrayList<>();
unrecognizedLines.add(unrecognizedLine);
assertEquals(unrecognizedLines, consensus.getUnrecognizedLines());
@@ -1261,8 +1314,8 @@ public class RelayNetworkStatusConsensusImplTest {
public void testUnrecognizedDirectorySignatureLineIgnore()
throws DescriptorParseException {
String unrecognizedLine = "unrecognized-line 1";
- RelayNetworkStatusConsensus consensus = ConsensusBuilder.
- createWithUnrecognizedDirectorySignatureLine(unrecognizedLine,
+ RelayNetworkStatusConsensus consensus = ConsensusBuilder
+ .createWithUnrecognizedDirectorySignatureLine(unrecognizedLine,
false);
List<String> unrecognizedLines = new ArrayList<>();
unrecognizedLines.add(unrecognizedLine);
diff --git a/src/test/java/org/torproject/descriptor/impl/RelayNetworkStatusImplTest.java b/src/test/java/org/torproject/descriptor/impl/RelayNetworkStatusImplTest.java
index 8f4ece2..d550d26 100644
--- a/src/test/java/org/torproject/descriptor/impl/RelayNetworkStatusImplTest.java
+++ b/src/test/java/org/torproject/descriptor/impl/RelayNetworkStatusImplTest.java
@@ -1,37 +1,31 @@
/* Copyright 2016--2017 The Tor Project
* See LICENSE for licensing information */
-package org.torproject.descriptor.impl;
-import org.torproject.descriptor.DescriptorParseException;
+package org.torproject.descriptor.impl;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
+import org.torproject.descriptor.DescriptorParseException;
import org.junit.Test;
-import org.torproject.descriptor.RelayNetworkStatus;
public class RelayNetworkStatusImplTest {
- private final static String validHeader = "network-status-version 2\n"
- + "dir-source 194.109.206.212 194.109.206.212 80\n"
- + "fingerprint 7EA6EAD6FD83083C538F44038BBFA077587DD755\n"
- + "contact 1024R/8D56913D Alex de Joode <adejoode(a)sabotage.org>\n"
- + "published 2012-03-01 00:10:43\n"
- + "dir-options\n"
- + "dir-signing-key\n"
- + "-----BEGIN RSA PUBLIC KEY-----\n"
- + "MIGJAoGBAL7QJ6cmXhMlexV97ehnV5hn5ePOeo0sbDYXhlfw52CheEycoUqSD9Y/\n"
- + "3qEo0Rm7XTEol0dRW34ca1LMIXGM4B4whXxBKCRRYe1RY6nF70zb2EUuaHWEWc+f\n"
- + "c6JWYUWZSPpW1uyjyLPUI/ikyyH7zmtR4MfhSeNdt2zSakojYNaPAgMBAAE=\n"
- + "-----END RSA PUBLIC KEY-----\n";
-
- private final static String validStatus =
- "@type network-status-2 1.0\n" + validHeader;
+ private static final String validHeader = "network-status-version 2\n"
+ + "dir-source 194.109.206.212 194.109.206.212 80\n"
+ + "fingerprint 7EA6EAD6FD83083C538F44038BBFA077587DD755\n"
+ + "contact 1024R/8D56913D Alex de Joode <adejoode(a)sabotage.org>\n"
+ + "published 2012-03-01 00:10:43\n"
+ + "dir-options\n"
+ + "dir-signing-key\n"
+ + "-----BEGIN RSA PUBLIC KEY-----\n"
+ + "MIGJAoGBAL7QJ6cmXhMlexV97ehnV5hn5ePOeo0sbDYXhlfw52CheEycoUqSD9Y/\n"
+ + "3qEo0Rm7XTEol0dRW34ca1LMIXGM4B4whXxBKCRRYe1RY6nF70zb2EUuaHWEWc+f\n"
+ + "c6JWYUWZSPpW1uyjyLPUI/ikyyH7zmtR4MfhSeNdt2zSakojYNaPAgMBAAE=\n"
+ + "-----END RSA PUBLIC KEY-----\n";
+
+ private static final String validStatus =
+ "@type network-status-2 1.0\n" + validHeader;
@Test(expected = DescriptorParseException.class)
public void testParseBrokenHeader() throws DescriptorParseException {
@@ -42,12 +36,11 @@ public class RelayNetworkStatusImplTest {
@Test()
public void testValidHeader() throws DescriptorParseException {
- RelayNetworkStatusImpl rnsi
- = new RelayNetworkStatusImpl(validStatus.getBytes(), true);
+ RelayNetworkStatusImpl rnsi =
+ new RelayNetworkStatusImpl(validStatus.getBytes(), true);
rnsi.parseHeader(validHeader.getBytes());
assertEquals(rnsi.getContactLine(),
- "1024R/8D56913D Alex de Joode <adejoode(a)sabotage.org>");
+ "1024R/8D56913D Alex de Joode <adejoode(a)sabotage.org>");
}
-
}
diff --git a/src/test/java/org/torproject/descriptor/impl/RelayNetworkStatusVoteImplTest.java b/src/test/java/org/torproject/descriptor/impl/RelayNetworkStatusVoteImplTest.java
index 79cb78c..847c538 100644
--- a/src/test/java/org/torproject/descriptor/impl/RelayNetworkStatusVoteImplTest.java
+++ b/src/test/java/org/torproject/descriptor/impl/RelayNetworkStatusVoteImplTest.java
@@ -1,21 +1,22 @@
/* Copyright 2011--2017 The Tor Project
* See LICENSE for licensing information */
-package org.torproject.descriptor.impl;
-import org.torproject.descriptor.DescriptorParseException;
-import org.torproject.descriptor.DirectorySignature;
+package org.torproject.descriptor.impl;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+import org.torproject.descriptor.DescriptorParseException;
+import org.torproject.descriptor.DirectorySignature;
+import org.torproject.descriptor.RelayNetworkStatusVote;
+
+import org.junit.Test;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import org.junit.Test;
-import org.torproject.descriptor.RelayNetworkStatusVote;
-
/* TODO Add test cases for all lines starting with "opt ". */
/* Test parsing of network status votes. Some of the vote-parsing code is
@@ -27,7 +28,9 @@ public class RelayNetworkStatusVoteImplTest {
/* Helper class to build a vote based on default data and modifications
* requested by test methods. */
private static class VoteBuilder {
+
private String networkStatusVersionLine = "network-status-version 3";
+
private static RelayNetworkStatusVote
createWithNetworkStatusVersionLine(String line)
throws DescriptorParseException {
@@ -35,7 +38,9 @@ public class RelayNetworkStatusVoteImplTest {
vb.networkStatusVersionLine = line;
return new RelayNetworkStatusVoteImpl(vb.buildVote(), true);
}
+
private String voteStatusLine = "vote-status vote";
+
private static RelayNetworkStatusVote
createWithVoteStatusLine(String line)
throws DescriptorParseException {
@@ -43,8 +48,10 @@ public class RelayNetworkStatusVoteImplTest {
vb.voteStatusLine = line;
return new RelayNetworkStatusVoteImpl(vb.buildVote(), true);
}
+
private String consensusMethodsLine =
"consensus-methods 1 2 3 4 5 6 7 8 9 10 11";
+
private static RelayNetworkStatusVote
createWithConsensusMethodsLine(String line)
throws DescriptorParseException {
@@ -52,7 +59,9 @@ public class RelayNetworkStatusVoteImplTest {
vb.consensusMethodsLine = line;
return new RelayNetworkStatusVoteImpl(vb.buildVote(), true);
}
+
private String publishedLine = "published 2011-11-30 08:50:01";
+
private static RelayNetworkStatusVote
createWithPublishedLine(String line)
throws DescriptorParseException {
@@ -60,7 +69,9 @@ public class RelayNetworkStatusVoteImplTest {
vb.publishedLine = line;
return new RelayNetworkStatusVoteImpl(vb.buildVote(), true);
}
+
private String validAfterLine = "valid-after 2011-11-30 09:00:00";
+
private static RelayNetworkStatusVote
createWithValidAfterLine(String line)
throws DescriptorParseException {
@@ -68,7 +79,9 @@ public class RelayNetworkStatusVoteImplTest {
vb.validAfterLine = line;
return new RelayNetworkStatusVoteImpl(vb.buildVote(), true);
}
+
private String freshUntilLine = "fresh-until 2011-11-30 10:00:00";
+
private static RelayNetworkStatusVote
createWithFreshUntilLine(String line)
throws DescriptorParseException {
@@ -76,7 +89,9 @@ public class RelayNetworkStatusVoteImplTest {
vb.freshUntilLine = line;
return new RelayNetworkStatusVoteImpl(vb.buildVote(), true);
}
+
private String validUntilLine = "valid-until 2011-11-30 12:00:00";
+
private static RelayNetworkStatusVote
createWithValidUntilLine(String line)
throws DescriptorParseException {
@@ -84,7 +99,9 @@ public class RelayNetworkStatusVoteImplTest {
vb.validUntilLine = line;
return new RelayNetworkStatusVoteImpl(vb.buildVote(), true);
}
+
private String votingDelayLine = "voting-delay 300 300";
+
private static RelayNetworkStatusVote
createWithVotingDelayLine(String line)
throws DescriptorParseException {
@@ -92,8 +109,10 @@ public class RelayNetworkStatusVoteImplTest {
vb.votingDelayLine = line;
return new RelayNetworkStatusVoteImpl(vb.buildVote(), true);
}
+
private String clientVersionsLine = "client-versions 0.2.1.31,"
+ "0.2.2.34,0.2.3.6-alpha,0.2.3.7-alpha,0.2.3.8-alpha";
+
private static RelayNetworkStatusVote
createWithClientVersionsLine(String line)
throws DescriptorParseException {
@@ -101,8 +120,10 @@ public class RelayNetworkStatusVoteImplTest {
vb.clientVersionsLine = line;
return new RelayNetworkStatusVoteImpl(vb.buildVote(), true);
}
+
private String serverVersionsLine = "server-versions 0.2.1.31,"
+ "0.2.2.34,0.2.3.6-alpha,0.2.3.7-alpha,0.2.3.8-alpha";
+
private static RelayNetworkStatusVote
createWithServerVersionsLine(String line)
throws DescriptorParseException {
@@ -110,7 +131,9 @@ public class RelayNetworkStatusVoteImplTest {
vb.serverVersionsLine = line;
return new RelayNetworkStatusVoteImpl(vb.buildVote(), true);
}
+
private String packageLines = null;
+
protected static RelayNetworkStatusVote
createWithPackageLines(String lines)
throws DescriptorParseException {
@@ -118,8 +141,10 @@ public class RelayNetworkStatusVoteImplTest {
vb.packageLines = lines;
return new RelayNetworkStatusVoteImpl(vb.buildVote(), true);
}
+
private String knownFlagsLine = "known-flags Authority BadExit Exit "
+ "Fast Guard HSDir Named Running Stable Unnamed V2Dir Valid";
+
private static RelayNetworkStatusVote
createWithKnownFlagsLine(String line)
throws DescriptorParseException {
@@ -127,10 +152,12 @@ public class RelayNetworkStatusVoteImplTest {
vb.knownFlagsLine = line;
return new RelayNetworkStatusVoteImpl(vb.buildVote(), true);
}
+
private String flagThresholdsLine = "flag-thresholds "
+ "stable-uptime=693369 stable-mtbf=153249 fast-speed=40960 "
+ "guard-wfu=94.669% guard-tk=691200 guard-bw-inc-exits=174080 "
+ "guard-bw-exc-exits=184320 enough-mtbf=1";
+
private static RelayNetworkStatusVote
createWithFlagThresholdsLine(String line)
throws DescriptorParseException {
@@ -138,11 +165,13 @@ public class RelayNetworkStatusVoteImplTest {
vb.flagThresholdsLine = line;
return new RelayNetworkStatusVoteImpl(vb.buildVote(), true);
}
+
private String paramsLine = "params "
+ "CircuitPriorityHalflifeMsec=30000 bwauthbestratio=1 "
+ "bwauthcircs=1 bwauthdescbw=0 bwauthkp=10000 bwauthpid=1 "
+ "bwauthtd=5000 bwauthti=50000 bwauthtidecay=5000 cbtnummodes=3 "
+ "cbtquantile=80 circwindow=1000 refuseunknownexits=1";
+
private static RelayNetworkStatusVote
createWithParamsLine(String line)
throws DescriptorParseException {
@@ -150,9 +179,11 @@ public class RelayNetworkStatusVoteImplTest {
vb.paramsLine = line;
return new RelayNetworkStatusVoteImpl(vb.buildVote(), true);
}
+
private String dirSourceLine = "dir-source urras "
+ "80550987E1D626E3EBA5E5E75A458DE0626D088C 208.83.223.34 "
+ "208.83.223.34 443 80";
+
private static RelayNetworkStatusVote
createWithDirSourceLine(String line)
throws DescriptorParseException {
@@ -160,8 +191,10 @@ public class RelayNetworkStatusVoteImplTest {
vb.dirSourceLine = line;
return new RelayNetworkStatusVoteImpl(vb.buildVote(), true);
}
+
private String contactLine = "contact 4096R/E012B42D Jacob Appelbaum "
+ "<jacob(a)appelbaum.net>";
+
private static RelayNetworkStatusVote
createWithContactLine(String line)
throws DescriptorParseException {
@@ -169,7 +202,9 @@ public class RelayNetworkStatusVoteImplTest {
vb.contactLine = line;
return new RelayNetworkStatusVoteImpl(vb.buildVote(), true);
}
+
private String legacyDirKeyLine = null;
+
private static RelayNetworkStatusVote
createWithLegacyDirKeyLine(String line)
throws DescriptorParseException {
@@ -177,8 +212,10 @@ public class RelayNetworkStatusVoteImplTest {
vb.legacyDirKeyLine = line;
return new RelayNetworkStatusVoteImpl(vb.buildVote(), true);
}
+
private String dirKeyCertificateVersionLine =
"dir-key-certificate-version 3";
+
private static RelayNetworkStatusVote
createWithDirKeyCertificateVersionLine(String line)
throws DescriptorParseException {
@@ -186,8 +223,10 @@ public class RelayNetworkStatusVoteImplTest {
vb.dirKeyCertificateVersionLine = line;
return new RelayNetworkStatusVoteImpl(vb.buildVote(), true);
}
+
private String fingerprintLine = "fingerprint "
+ "80550987E1D626E3EBA5E5E75A458DE0626D088C";
+
private static RelayNetworkStatusVote
createWithFingerprintLine(String line)
throws DescriptorParseException {
@@ -195,8 +234,10 @@ public class RelayNetworkStatusVoteImplTest {
vb.fingerprintLine = line;
return new RelayNetworkStatusVoteImpl(vb.buildVote(), true);
}
+
private String dirKeyPublishedLine = "dir-key-published 2011-04-27 "
+ "05:34:37";
+
private static RelayNetworkStatusVote
createWithDirKeyPublishedLine(String line)
throws DescriptorParseException {
@@ -204,8 +245,10 @@ public class RelayNetworkStatusVoteImplTest {
vb.dirKeyPublishedLine = line;
return new RelayNetworkStatusVoteImpl(vb.buildVote(), true);
}
+
private String dirKeyExpiresLine = "dir-key-expires 2012-04-27 "
+ "05:34:37";
+
private static RelayNetworkStatusVote
createWithDirKeyExpiresLine(String line)
throws DescriptorParseException {
@@ -213,6 +256,7 @@ public class RelayNetworkStatusVoteImplTest {
vb.dirKeyExpiresLine = line;
return new RelayNetworkStatusVoteImpl(vb.buildVote(), true);
}
+
private String dirIdentityKeyLines = "dir-identity-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIIBigKCAYEAtKpuLgVK25sfScjsxfVU1ljofrDygt9GP7bNJl/rghX42KUT97"
@@ -225,6 +269,7 @@ public class RelayNetworkStatusVoteImplTest {
+ "TvcaKz9CEj4XcKm+kOmzejYmIa\nkbWNcRpXPiUZ+xmwGtsq30xrzqiONmERkx"
+ "qlmf7bVQPFvh3Kz6hGcmTBhTbHSe9h\nzDgmdaTNn3EHAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----";
+
private static RelayNetworkStatusVote
createWithDirIdentityKeyLines(String lines)
throws DescriptorParseException {
@@ -232,6 +277,7 @@ public class RelayNetworkStatusVoteImplTest {
vb.dirIdentityKeyLines = lines;
return new RelayNetworkStatusVoteImpl(vb.buildVote(), true);
}
+
private String dirSigningKeyLines = "dir-signing-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBAN05qyHFQlTqykMP8yLuD4G2UuYulD4Xs8iSX5uqF+WGsUA1E4zZh4"
@@ -239,6 +285,7 @@ public class RelayNetworkStatusVoteImplTest {
+ "mBGsN7\nPUXyMNjwRKL6UvrcbYk1d2mRBLO7SAP/sFW5fHhIBVeLIWrzQ19rAg"
+ "MBAAE=\n"
+ "-----END RSA PUBLIC KEY-----";
+
private static RelayNetworkStatusVote
createWithDirSigningKeyLines(String lines)
throws DescriptorParseException {
@@ -246,12 +293,14 @@ public class RelayNetworkStatusVoteImplTest {
vb.dirSigningKeyLines = lines;
return new RelayNetworkStatusVoteImpl(vb.buildVote(), true);
}
+
private String dirKeyCrosscertLines = "dir-key-crosscert\n"
+ "-----BEGIN ID SIGNATURE-----\n"
+ "rPBFn6IJ6TvAHj4pSwlg+RTn1fP89JGSVa08wuyJr5dAvZsdakQXvRjamT9oJU"
+ "aZ\nnY5Rl/tRlGuSQ0BglTPPKoXdKERK0FUr9f0EKrQy7NDUgE2j9losiRuyKz"
+ "hA3neZ\nK4yF8bhqAwM51u7fzAhIjNeRif9c04rhFJJCseco84w=\n"
+ "-----END ID SIGNATURE-----";
+
private static RelayNetworkStatusVote
createWithDirKeyCrosscertLines(String lines)
throws DescriptorParseException {
@@ -259,6 +308,7 @@ public class RelayNetworkStatusVoteImplTest {
vb.dirKeyCrosscertLines = lines;
return new RelayNetworkStatusVoteImpl(vb.buildVote(), true);
}
+
private String dirKeyCertificationLines = "dir-key-certification\n"
+ "-----BEGIN SIGNATURE-----\n"
+ "hPSh6FuohNF5ccjiMbkvr8cZJwGFuL11cNtwN9k0X3pUdFZVATIEkqBe7z+rE2"
@@ -271,6 +321,7 @@ public class RelayNetworkStatusVoteImplTest {
+ "bEGbvY/P8mzVAZxp3Yz+sRtNel\nC1SWz/Fx+Saex5oI7DJ3xtSD4XqKb/wYwZ"
+ "FT8IxDYq1t2tFXdHxd4QPRVcvc0zYC\n"
+ "-----END SIGNATURE-----";
+
private static RelayNetworkStatusVote
createWithDirKeyCertificationLines(String lines)
throws DescriptorParseException {
@@ -278,14 +329,18 @@ public class RelayNetworkStatusVoteImplTest {
vb.dirKeyCertificationLines = lines;
return new RelayNetworkStatusVoteImpl(vb.buildVote(), true);
}
+
private List<String> statusEntries = null;
+
private static RelayNetworkStatusVote createWithStatusEntries(
List<String> statusEntries) throws DescriptorParseException {
VoteBuilder vb = new VoteBuilder();
vb.statusEntries = statusEntries;
return new RelayNetworkStatusVoteImpl(vb.buildVote(), true);
}
+
private String directoryFooterLine = "directory-footer";
+
private static RelayNetworkStatusVote
createWithDirectoryFooterLine(String line)
throws DescriptorParseException {
@@ -293,6 +348,7 @@ public class RelayNetworkStatusVoteImplTest {
vb.directoryFooterLine = line;
return new RelayNetworkStatusVoteImpl(vb.buildVote(), true);
}
+
private String directorySignatureLines = "directory-signature "
+ "80550987E1D626E3EBA5E5E75A458DE0626D088C "
+ "EEB9299D295C1C815E289FBF2F2BBEA5F52FDD19\n"
@@ -301,6 +357,7 @@ public class RelayNetworkStatusVoteImplTest {
+ "F3Yh\nrXVaaoP07r6Ta+s0g1Zijm3lms50Nk/4tV2p8Y63c3F4Q3DAnK40Oi"
+ "kfOIwEj+Ny\n+zBRQssP3hPhTPOj/A7o3mZZwtL6x1sxpeu/nME1l5E=\n"
+ "-----END SIGNATURE-----";
+
private static RelayNetworkStatusVote
createWithDirectorySignatureLines(String lines)
throws DescriptorParseException {
@@ -308,7 +365,9 @@ public class RelayNetworkStatusVoteImplTest {
vb.directorySignatureLines = lines;
return new RelayNetworkStatusVoteImpl(vb.buildVote(), true);
}
+
private String unrecognizedHeaderLine = null;
+
protected static RelayNetworkStatusVote
createWithUnrecognizedHeaderLine(String line,
boolean failUnrecognizedDescriptorLines)
@@ -318,7 +377,9 @@ public class RelayNetworkStatusVoteImplTest {
return new RelayNetworkStatusVoteImpl(vb.buildVote(),
failUnrecognizedDescriptorLines);
}
+
private String unrecognizedDirSourceLine = null;
+
protected static RelayNetworkStatusVote
createWithUnrecognizedDirSourceLine(String line,
boolean failUnrecognizedDescriptorLines)
@@ -328,7 +389,9 @@ public class RelayNetworkStatusVoteImplTest {
return new RelayNetworkStatusVoteImpl(vb.buildVote(),
failUnrecognizedDescriptorLines);
}
+
private String unrecognizedStatusEntryLine = null;
+
protected static RelayNetworkStatusVote
createWithUnrecognizedStatusEntryLine(String line,
boolean failUnrecognizedDescriptorLines)
@@ -338,7 +401,9 @@ public class RelayNetworkStatusVoteImplTest {
return new RelayNetworkStatusVoteImpl(vb.buildVote(),
failUnrecognizedDescriptorLines);
}
+
private String unrecognizedFooterLine = null;
+
protected static RelayNetworkStatusVote
createWithUnrecognizedFooterLine(String line,
boolean failUnrecognizedDescriptorLines)
@@ -348,7 +413,9 @@ public class RelayNetworkStatusVoteImplTest {
return new RelayNetworkStatusVoteImpl(vb.buildVote(),
failUnrecognizedDescriptorLines);
}
+
private String unrecognizedDirectorySignatureLine = null;
+
protected static RelayNetworkStatusVote
createWithUnrecognizedDirectorySignatureLine(String line,
boolean failUnrecognizedDescriptorLines)
@@ -378,6 +445,7 @@ public class RelayNetworkStatusVoteImplTest {
+ "m 8,9,10,11 "
+ "sha256=9ciEx9t0McXk9A06I7qwN7pxuNOdpCP64RV/6cx2Zkc");
}
+
private byte[] buildVote() {
StringBuilder sb = new StringBuilder();
this.appendHeader(sb);
@@ -387,6 +455,7 @@ public class RelayNetworkStatusVoteImplTest {
this.appendDirectorySignature(sb);
return sb.toString().getBytes();
}
+
private void appendHeader(StringBuilder sb) {
if (this.networkStatusVersionLine != null) {
sb.append(this.networkStatusVersionLine).append("\n");
@@ -434,6 +503,7 @@ public class RelayNetworkStatusVoteImplTest {
sb.append(this.unrecognizedHeaderLine).append("\n");
}
}
+
private void appendDirSource(StringBuilder sb) {
if (this.dirSourceLine != null) {
sb.append(this.dirSourceLine).append("\n");
@@ -472,6 +542,7 @@ public class RelayNetworkStatusVoteImplTest {
sb.append(this.unrecognizedDirSourceLine).append("\n");
}
}
+
private void appendStatusEntries(StringBuilder sb) {
for (String statusEntry : this.statusEntries) {
sb.append(statusEntry).append("\n");
@@ -480,6 +551,7 @@ public class RelayNetworkStatusVoteImplTest {
sb.append(this.unrecognizedStatusEntryLine).append("\n");
}
}
+
private void appendFooter(StringBuilder sb) {
if (this.directoryFooterLine != null) {
sb.append(this.directoryFooterLine).append("\n");
@@ -488,6 +560,7 @@ public class RelayNetworkStatusVoteImplTest {
sb.append(this.unrecognizedFooterLine).append("\n");
}
}
+
private void appendDirectorySignature(StringBuilder sb) {
if (this.directorySignatureLines != null) {
sb.append(directorySignatureLines).append("\n");
@@ -517,8 +590,8 @@ public class RelayNetworkStatusVoteImplTest {
assertEquals(30000, (int) vote.getConsensusParams().get(
"CircuitPriorityHalflifeMsec"));
assertEquals("Tor 0.2.1.29 (r8e9b25e6c7a2e70c)",
- vote.getStatusEntry("00343A8024F70E214728F0C5AF7ACE0C1508F073").
- getVersion());
+ vote.getStatusEntry("00343A8024F70E214728F0C5AF7ACE0C1508F073")
+ .getVersion());
assertEquals(3, vote.getDirKeyCertificateVersion());
assertEquals("80550987E1D626E3EBA5E5E75A458DE0626D088C",
vote.getIdentity());
@@ -832,11 +905,11 @@ public class RelayNetworkStatusVoteImplTest {
}
}
- @Test(expected = DescriptorParseException.class)
- public void testPackageIncomplete() throws DescriptorParseException {
- String packageLine = "package shouldbesecond 0 http";
- ConsensusBuilder.createWithPackageLines(packageLine);
- }
+ @Test(expected = DescriptorParseException.class)
+ public void testPackageIncomplete() throws DescriptorParseException {
+ String packageLine = "package shouldbesecond 0 http";
+ ConsensusBuilder.createWithPackageLines(packageLine);
+ }
@Test(expected = DescriptorParseException.class)
public void testKnownFlagsNoLine() throws DescriptorParseException {
@@ -1284,8 +1357,8 @@ public class RelayNetworkStatusVoteImplTest {
public void testUnrecognizedHeaderLineIgnore()
throws DescriptorParseException {
String unrecognizedLine = "unrecognized-line 1";
- RelayNetworkStatusVote vote = VoteBuilder.
- createWithUnrecognizedHeaderLine(unrecognizedLine, false);
+ RelayNetworkStatusVote vote = VoteBuilder
+ .createWithUnrecognizedHeaderLine(unrecognizedLine, false);
List<String> unrecognizedLines = new ArrayList<>();
unrecognizedLines.add(unrecognizedLine);
assertEquals(unrecognizedLines, vote.getUnrecognizedLines());
@@ -1303,8 +1376,8 @@ public class RelayNetworkStatusVoteImplTest {
public void testUnrecognizedDirSourceLineIgnore()
throws DescriptorParseException {
String unrecognizedLine = "unrecognized-line 1";
- RelayNetworkStatusVote vote = VoteBuilder.
- createWithUnrecognizedDirSourceLine(unrecognizedLine, false);
+ RelayNetworkStatusVote vote = VoteBuilder
+ .createWithUnrecognizedDirSourceLine(unrecognizedLine, false);
List<String> unrecognizedLines = new ArrayList<>();
unrecognizedLines.add(unrecognizedLine);
assertEquals(unrecognizedLines, vote.getUnrecognizedLines());
@@ -1321,8 +1394,8 @@ public class RelayNetworkStatusVoteImplTest {
public void testUnrecognizedFooterLineIgnore()
throws DescriptorParseException {
String unrecognizedLine = "unrecognized-line 1";
- RelayNetworkStatusVote vote = VoteBuilder.
- createWithUnrecognizedFooterLine(unrecognizedLine, false);
+ RelayNetworkStatusVote vote = VoteBuilder
+ .createWithUnrecognizedFooterLine(unrecognizedLine, false);
List<String> unrecognizedLines = new ArrayList<>();
unrecognizedLines.add(unrecognizedLine);
assertEquals(unrecognizedLines, vote.getUnrecognizedLines());
diff --git a/src/test/java/org/torproject/descriptor/impl/ServerDescriptorImplTest.java b/src/test/java/org/torproject/descriptor/impl/ServerDescriptorImplTest.java
index 0daa83b..3769ead 100644
--- a/src/test/java/org/torproject/descriptor/impl/ServerDescriptorImplTest.java
+++ b/src/test/java/org/torproject/descriptor/impl/ServerDescriptorImplTest.java
@@ -1,14 +1,20 @@
/* Copyright 2012--2017 The Tor Project
* See LICENSE for licensing information */
+
package org.torproject.descriptor.impl;
-import org.torproject.descriptor.DescriptorParseException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+import org.torproject.descriptor.BandwidthHistory;
+import org.torproject.descriptor.DescriptorParseException;
+import org.torproject.descriptor.ServerDescriptor;
+
+import org.junit.Test;
+
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
@@ -16,68 +22,79 @@ import java.util.Arrays;
import java.util.List;
import java.util.SortedMap;
-import org.junit.Test;
-import org.torproject.descriptor.BandwidthHistory;
-import org.torproject.descriptor.ServerDescriptor;
-
/* Test parsing of relay server descriptors. */
public class ServerDescriptorImplTest {
/* Helper class to build a descriptor based on default data and
* modifications requested by test methods. */
private static class DescriptorBuilder {
+
private String routerLine = "router saberrider2008 94.134.192.243 "
+ "9001 0 0";
+
private static ServerDescriptor createWithRouterLine(
String line) throws DescriptorParseException {
DescriptorBuilder db = new DescriptorBuilder();
db.routerLine = line;
return new RelayServerDescriptorImpl(db.buildDescriptor(), true);
}
+
private String bandwidthLine = "bandwidth 51200 51200 53470";
+
private static ServerDescriptor createWithBandwidthLine(
String line) throws DescriptorParseException {
DescriptorBuilder db = new DescriptorBuilder();
db.bandwidthLine = line;
return new RelayServerDescriptorImpl(db.buildDescriptor(), true);
}
+
private String platformLine = "platform Tor 0.2.2.35 "
+ "(git-b04388f9e7546a9f) on Linux i686";
+
private static ServerDescriptor createWithPlatformLine(
String line) throws DescriptorParseException {
DescriptorBuilder db = new DescriptorBuilder();
db.platformLine = line;
return new RelayServerDescriptorImpl(db.buildDescriptor(), true);
}
+
private String publishedLine = "published 2012-01-01 04:03:19";
+
private static ServerDescriptor createWithPublishedLine(
String line) throws DescriptorParseException {
DescriptorBuilder db = new DescriptorBuilder();
db.publishedLine = line;
return new RelayServerDescriptorImpl(db.buildDescriptor(), true);
}
+
private String fingerprintLine = "opt fingerprint D873 3048 FC8E "
+ "C910 2466 AD8F 3098 622B F1BF 71FD";
+
private static ServerDescriptor createWithFingerprintLine(
String line) throws DescriptorParseException {
DescriptorBuilder db = new DescriptorBuilder();
db.fingerprintLine = line;
return new RelayServerDescriptorImpl(db.buildDescriptor(), true);
}
+
private String hibernatingLine = null;
+
private static ServerDescriptor createWithHibernatingLine(
String line) throws DescriptorParseException {
DescriptorBuilder db = new DescriptorBuilder();
db.hibernatingLine = line;
return new RelayServerDescriptorImpl(db.buildDescriptor(), true);
}
+
private String uptimeLine = "uptime 48";
+
private static ServerDescriptor createWithUptimeLine(
String line) throws DescriptorParseException {
DescriptorBuilder db = new DescriptorBuilder();
db.uptimeLine = line;
return new RelayServerDescriptorImpl(db.buildDescriptor(), true);
}
+
private String onionKeyLines = "onion-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBAKM+iiHhO6eHsvd6Xjws9z9EQB1V/Bpuy5ciGJ1U4V9SeiKooSo5Bp"
@@ -85,12 +102,14 @@ public class ServerDescriptorImplTest {
+ "uC3cTF\n9wE4WXY4nX7w0RTN18UVLxrt1A9PP0cobFNiPs9rzJCbKFfacOkpAg"
+ "MBAAE=\n"
+ "-----END RSA PUBLIC KEY-----";
+
private static ServerDescriptor createWithOnionKeyLines(
String lines) throws DescriptorParseException {
DescriptorBuilder db = new DescriptorBuilder();
db.onionKeyLines = lines;
return new RelayServerDescriptorImpl(db.buildDescriptor(), true);
}
+
private String signingKeyLines = "signing-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBALMm3r3QDh482Ewe6Ub9wvRIfmEkoNX6q5cEAtQRNHSDcNx41gjELb"
@@ -98,99 +117,126 @@ public class ServerDescriptorImplTest {
+ "DhUROG\n8URDIhQoixcUeyyrVB8sxliSstKimulGnB7xpjYOlO8JKaHLNL4TAg"
+ "MBAAE=\n"
+ "-----END RSA PUBLIC KEY-----";
+
private static ServerDescriptor createWithSigningKeyLines(
String lines) throws DescriptorParseException {
DescriptorBuilder db = new DescriptorBuilder();
db.signingKeyLines = lines;
return new RelayServerDescriptorImpl(db.buildDescriptor(), true);
}
+
private String onionKeyCrosscertLines = null;
+
private static ServerDescriptor createWithOnionKeyCrosscertLines(
String lines) throws DescriptorParseException {
DescriptorBuilder db = new DescriptorBuilder();
db.onionKeyCrosscertLines = lines;
return new RelayServerDescriptorImpl(db.buildDescriptor(), true);
}
+
private String ntorOnionKeyCrosscertLines = null;
+
private static ServerDescriptor createWithNtorOnionKeyCrosscertLines(
String lines) throws DescriptorParseException {
DescriptorBuilder db = new DescriptorBuilder();
db.ntorOnionKeyCrosscertLines = lines;
return new RelayServerDescriptorImpl(db.buildDescriptor(), true);
}
+
private String exitPolicyLines = "reject *:*";
+
private static ServerDescriptor createWithExitPolicyLines(
String lines) throws DescriptorParseException {
DescriptorBuilder db = new DescriptorBuilder();
db.exitPolicyLines = lines;
return new RelayServerDescriptorImpl(db.buildDescriptor(), true);
}
+
private String contactLine = "contact Random Person <nobody AT "
+ "example dot com>";
+
private static ServerDescriptor createWithContactLine(
String line) throws DescriptorParseException {
DescriptorBuilder db = new DescriptorBuilder();
db.contactLine = line;
return new RelayServerDescriptorImpl(db.buildDescriptor(), true);
}
+
private String familyLine = null;
+
private static ServerDescriptor createWithFamilyLine(
String line) throws DescriptorParseException {
DescriptorBuilder db = new DescriptorBuilder();
db.familyLine = line;
return new RelayServerDescriptorImpl(db.buildDescriptor(), true);
}
+
private String readHistoryLine = null;
+
private static ServerDescriptor createWithReadHistoryLine(
String line) throws DescriptorParseException {
DescriptorBuilder db = new DescriptorBuilder();
db.readHistoryLine = line;
return new RelayServerDescriptorImpl(db.buildDescriptor(), true);
}
+
private String writeHistoryLine = null;
+
private static ServerDescriptor createWithWriteHistoryLine(
String line) throws DescriptorParseException {
DescriptorBuilder db = new DescriptorBuilder();
db.writeHistoryLine = line;
return new RelayServerDescriptorImpl(db.buildDescriptor(), true);
}
+
private String eventdnsLine = null;
+
private static ServerDescriptor createWithEventdnsLine(
String line) throws DescriptorParseException {
DescriptorBuilder db = new DescriptorBuilder();
db.eventdnsLine = line;
return new RelayServerDescriptorImpl(db.buildDescriptor(), true);
}
+
private String cachesExtraInfoLine = null;
+
private static ServerDescriptor createWithCachesExtraInfoLine(
String line) throws DescriptorParseException {
DescriptorBuilder db = new DescriptorBuilder();
db.cachesExtraInfoLine = line;
return new RelayServerDescriptorImpl(db.buildDescriptor(), true);
}
+
private String extraInfoDigestLine = "opt extra-info-digest "
+ "1469D1550738A25B1E7B47CDDBCD7B2899F51B74";
+
private static ServerDescriptor createWithExtraInfoDigestLine(
String line) throws DescriptorParseException {
DescriptorBuilder db = new DescriptorBuilder();
db.extraInfoDigestLine = line;
return new RelayServerDescriptorImpl(db.buildDescriptor(), true);
}
+
private String hiddenServiceDirLine = "opt hidden-service-dir";
+
private static ServerDescriptor createWithHiddenServiceDirLine(
String line) throws DescriptorParseException {
DescriptorBuilder db = new DescriptorBuilder();
db.hiddenServiceDirLine = line;
return new RelayServerDescriptorImpl(db.buildDescriptor(), true);
}
+
private String protocolsLine = "opt protocols Link 1 2 Circuit 1";
+
private static ServerDescriptor createWithProtocolsLine(
String line) throws DescriptorParseException {
DescriptorBuilder db = new DescriptorBuilder();
db.protocolsLine = line;
return new RelayServerDescriptorImpl(db.buildDescriptor(), true);
}
+
private String allowSingleHopExitsLine = null;
+
private static ServerDescriptor
createWithAllowSingleHopExitsLine(String line)
throws DescriptorParseException {
@@ -198,40 +244,50 @@ public class ServerDescriptorImplTest {
db.allowSingleHopExitsLine = line;
return new RelayServerDescriptorImpl(db.buildDescriptor(), true);
}
+
private String ipv6PolicyLine = null;
+
private static ServerDescriptor createWithIpv6PolicyLine(
String line) throws DescriptorParseException {
DescriptorBuilder db = new DescriptorBuilder();
db.ipv6PolicyLine = line;
return new RelayServerDescriptorImpl(db.buildDescriptor(), true);
}
+
private String ntorOnionKeyLine = null;
+
private static ServerDescriptor createWithNtorOnionKeyLine(
String line) throws DescriptorParseException {
DescriptorBuilder db = new DescriptorBuilder();
db.ntorOnionKeyLine = line;
return new RelayServerDescriptorImpl(db.buildDescriptor(), true);
}
+
private String tunnelledDirServerLine = null;
+
private static ServerDescriptor createWithTunnelledDirServerLine(
String line) throws DescriptorParseException {
DescriptorBuilder db = new DescriptorBuilder();
db.tunnelledDirServerLine = line;
return new RelayServerDescriptorImpl(db.buildDescriptor(), true);
}
+
private String routerSignatureLines = "router-signature\n"
+ "-----BEGIN SIGNATURE-----\n"
+ "o4j+kH8UQfjBwepUnr99v0ebN8RpzHJ/lqYsTojXHy9kMr1RNI9IDeSzA7PSqT"
+ "uV\n4PL8QsGtlfwthtIoZpB2srZeyN/mcpA9fa1JXUrt/UN9K/+32Cyaad7h0n"
+ "HE6Xfb\njqpXDpnBpvk4zjmzjjKYnIsUWTnADmu0fo3xTRqXi7g=\n"
+ "-----END SIGNATURE-----";
+
private static ServerDescriptor createWithRouterSignatureLines(
String line) throws DescriptorParseException {
DescriptorBuilder db = new DescriptorBuilder();
db.routerSignatureLines = line;
return new RelayServerDescriptorImpl(db.buildDescriptor(), true);
}
+
private String unrecognizedLine = null;
+
private static ServerDescriptor createWithUnrecognizedLine(
String line, boolean failUnrecognizedDescriptorLines)
throws DescriptorParseException {
@@ -240,7 +296,9 @@ public class ServerDescriptorImplTest {
return new RelayServerDescriptorImpl(db.buildDescriptor(),
failUnrecognizedDescriptorLines);
}
+
private byte[] nonAsciiLineBytes = null;
+
private static ServerDescriptor createWithNonAsciiLineBytes(
byte[] lineBytes, boolean failUnrecognizedDescriptorLines)
throws DescriptorParseException {
@@ -249,8 +307,13 @@ public class ServerDescriptorImplTest {
return new RelayServerDescriptorImpl(db.buildDescriptor(),
failUnrecognizedDescriptorLines);
}
- private String identityEd25519Lines = null,
- masterKeyEd25519Line = null, routerSigEd25519Line = null;
+
+ private String identityEd25519Lines = null;
+
+ private String masterKeyEd25519Line = null;
+
+ private String routerSigEd25519Line = null;
+
private static ServerDescriptor createWithEd25519Lines(
String identityEd25519Lines, String masterKeyEd25519Line,
String routerSigEd25519Line) throws DescriptorParseException {
@@ -260,6 +323,7 @@ public class ServerDescriptorImplTest {
db.routerSigEd25519Line = routerSigEd25519Line;
return new RelayServerDescriptorImpl(db.buildDescriptor(), true);
}
+
private byte[] buildDescriptor() {
StringBuilder sb = new StringBuilder();
if (this.routerLine != null) {
@@ -418,8 +482,8 @@ public class ServerDescriptorImplTest {
@Test()
public void testRouterOpt() throws DescriptorParseException {
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithRouterLine("opt router saberrider2008 "
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithRouterLine("opt router saberrider2008 "
+ "94.134.192.243 9001 0 0");
assertEquals("saberrider2008", descriptor.getNickname());
assertEquals("94.134.192.243", descriptor.getAddress());
@@ -455,8 +519,8 @@ public class ServerDescriptorImplTest {
@Test()
public void testNicknameTwoSpaces() throws DescriptorParseException {
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithRouterLine("router saberrider2008 "
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithRouterLine("router saberrider2008 "
+ "94.134.192.243 9001 0 0");
assertEquals("saberrider2008", descriptor.getNickname());
assertEquals("94.134.192.243", descriptor.getAddress());
@@ -512,15 +576,15 @@ public class ServerDescriptorImplTest {
@Test()
public void testPlatformMissing() throws DescriptorParseException {
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithPlatformLine(null);
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithPlatformLine(null);
assertNull(descriptor.getPlatform());
}
@Test()
public void testPlatformOpt() throws DescriptorParseException {
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithPlatformLine("opt platform Tor 0.2.2.35 "
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithPlatformLine("opt platform Tor 0.2.2.35 "
+ "(git-b04388f9e7546a9f) on Linux i686");
assertEquals("Tor 0.2.2.35 (git-b04388f9e7546a9f) on Linux i686",
descriptor.getPlatform());
@@ -528,22 +592,22 @@ public class ServerDescriptorImplTest {
@Test()
public void testPlatformNoSpace() throws DescriptorParseException {
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithPlatformLine("platform");
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithPlatformLine("platform");
assertEquals("", descriptor.getPlatform());
}
@Test()
public void testPlatformSpace() throws DescriptorParseException {
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithPlatformLine("platform ");
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithPlatformLine("platform ");
assertEquals("", descriptor.getPlatform());
}
@Test()
public void testProtocolsNoOpt() throws DescriptorParseException {
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithProtocolsLine("protocols Link 1 2 Circuit 1");
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithProtocolsLine("protocols Link 1 2 Circuit 1");
assertEquals(Arrays.asList(new Integer[] {1, 2}),
descriptor.getLinkProtocolVersions());
assertEquals(Arrays.asList(new Integer[] {1}),
@@ -551,7 +615,7 @@ public class ServerDescriptorImplTest {
}
@Test(expected = DescriptorParseException.class)
- public void testProtocolsAB() throws DescriptorParseException {
+ public void testProtocolsAb() throws DescriptorParseException {
DescriptorBuilder.createWithProtocolsLine("opt protocols Link A B "
+ "Circuit 1");
}
@@ -569,8 +633,8 @@ public class ServerDescriptorImplTest {
@Test()
public void testPublishedOpt() throws DescriptorParseException {
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithPublishedLine("opt published 2012-01-01 04:03:19");
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithPublishedLine("opt published 2012-01-01 04:03:19");
assertEquals(1325390599000L, descriptor.getPublishedMillis());
}
@@ -599,15 +663,15 @@ public class ServerDescriptorImplTest {
@Test()
public void testPublishedMillis() throws DescriptorParseException {
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithPublishedLine("opt published 2012-01-01 04:03:19.123");
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithPublishedLine("opt published 2012-01-01 04:03:19.123");
assertEquals(1325390599000L, descriptor.getPublishedMillis());
}
@Test()
public void testFingerprintNoOpt() throws DescriptorParseException {
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithFingerprintLine("fingerprint D873 3048 FC8E C910 2466 "
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithFingerprintLine("fingerprint D873 3048 FC8E C910 2466 "
+ "AD8F 3098 622B F1BF 71FD");
assertEquals("D8733048FC8EC9102466AD8F3098622BF1BF71FD",
descriptor.getFingerprint());
@@ -639,15 +703,15 @@ public class ServerDescriptorImplTest {
@Test()
public void testUptimeMissing() throws DescriptorParseException {
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithUptimeLine(null);
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithUptimeLine(null);
assertNull(descriptor.getUptime());
}
@Test()
public void testUptimeOpt() throws DescriptorParseException {
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithUptimeLine("opt uptime 48");
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithUptimeLine("opt uptime 48");
assertEquals(48, descriptor.getUptime().longValue());
}
@@ -678,8 +742,8 @@ public class ServerDescriptorImplTest {
@Test()
public void testBandwidthOpt() throws DescriptorParseException {
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithBandwidthLine("opt bandwidth 51200 51200 53470");
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithBandwidthLine("opt bandwidth 51200 51200 53470");
assertEquals(51200, (int) descriptor.getBandwidthRate());
assertEquals(51200, (int) descriptor.getBandwidthBurst());
assertEquals(53470, (int) descriptor.getBandwidthObserved());
@@ -700,8 +764,8 @@ public class ServerDescriptorImplTest {
/* This is allowed, because Tor versions 0.0.8 and older only wrote
* bandwidth lines with rate and burst values, but no observed
* value. */
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithBandwidthLine("bandwidth 51200 51200");
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithBandwidthLine("bandwidth 51200 51200");
assertEquals(51200, (int) descriptor.getBandwidthRate());
assertEquals(51200, (int) descriptor.getBandwidthBurst());
assertEquals(-1, (int) descriptor.getBandwidthObserved());
@@ -721,8 +785,8 @@ public class ServerDescriptorImplTest {
@Test()
public void testExtraInfoDigestNoOpt() throws DescriptorParseException {
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithExtraInfoDigestLine("extra-info-digest "
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithExtraInfoDigestLine("extra-info-digest "
+ "1469D1550738A25B1E7B47CDDBCD7B2899F51B74");
assertEquals("1469D1550738A25B1E7B47CDDBCD7B2899F51B74",
descriptor.getExtraInfoDigest());
@@ -753,8 +817,8 @@ public class ServerDescriptorImplTest {
@Test()
public void testExtraInfoDigestMissing()
throws DescriptorParseException {
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithExtraInfoDigestLine(null);
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithExtraInfoDigestLine(null);
assertNull(descriptor.getExtraInfoDigest());
}
@@ -766,8 +830,8 @@ public class ServerDescriptorImplTest {
"V609l+N6ActBveebfNbH5lQ6wHDNstDkFgyqEhBHwtA";
String extraInfoDigestLine = String.format("extra-info-digest %s %s",
extraInfoDigest, additionalExtraInfoDigest);
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithExtraInfoDigestLine(extraInfoDigestLine);
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithExtraInfoDigestLine(extraInfoDigestLine);
assertEquals(extraInfoDigest, descriptor.getExtraInfoDigest());
}
@@ -796,16 +860,16 @@ public class ServerDescriptorImplTest {
@Test()
public void testHiddenServiceDirMissing()
throws DescriptorParseException {
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithHiddenServiceDirLine(null);
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithHiddenServiceDirLine(null);
assertNull(descriptor.getHiddenServiceDirVersions());
}
@Test()
public void testHiddenServiceDirNoOpt()
throws DescriptorParseException {
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithHiddenServiceDirLine("hidden-service-dir");
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithHiddenServiceDirLine("hidden-service-dir");
assertEquals(Arrays.asList(new Integer[] {2}),
descriptor.getHiddenServiceDirVersions());
}
@@ -813,23 +877,23 @@ public class ServerDescriptorImplTest {
@Test()
public void testHiddenServiceDirVersions2And3()
throws DescriptorParseException {
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithHiddenServiceDirLine("hidden-service-dir 2 3");
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithHiddenServiceDirLine("hidden-service-dir 2 3");
assertEquals(Arrays.asList(new Integer[] {2, 3}),
descriptor.getHiddenServiceDirVersions());
}
@Test()
public void testContactMissing() throws DescriptorParseException {
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithContactLine(null);
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithContactLine(null);
assertNull(descriptor.getContact());
}
@Test()
public void testContactOpt() throws DescriptorParseException {
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithContactLine("opt contact Random Person");
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithContactLine("opt contact Random Person");
assertEquals("Random Person", descriptor.getContact());
}
@@ -841,8 +905,8 @@ public class ServerDescriptorImplTest {
@Test()
public void testContactNoSpace() throws DescriptorParseException {
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithContactLine("contact");
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithContactLine("contact");
assertEquals("", descriptor.getContact());
}
@@ -856,24 +920,24 @@ public class ServerDescriptorImplTest {
+ "07\rmTQoP40G4zqOrVEOOcXpdSiRnHWJYfgTnkibNZrOZEZLn3H1ywpovEgESm"
+ "oGEdAX\roid3XuIYRpRnqoafbFg9sg+OofX/mGrO+5ACfagQ9rlfx2oxCWijYw"
+ "pYFRk3NhCY=\r=Xaw3\r-----END PGP PUBLIC KEY BLOCK-----";
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithContactLine("contact " + contactString);
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithContactLine("contact " + contactString);
assertEquals(contactString, descriptor.getContact());
}
@Test()
public void testExitPolicyRejectAllAcceptAll()
throws DescriptorParseException {
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithExitPolicyLines("reject *:*\naccept *:*");
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithExitPolicyLines("reject *:*\naccept *:*");
assertEquals(Arrays.asList(new String[] {"reject *:*", "accept *:*"}),
descriptor.getExitPolicyLines());
}
@Test()
public void testExitPolicyOpt() throws DescriptorParseException {
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithExitPolicyLines("opt reject *:*");
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithExitPolicyLines("opt reject *:*");
assertEquals(Arrays.asList(new String[] {"reject *:*"}),
descriptor.getExitPolicyLines());
}
@@ -886,8 +950,8 @@ public class ServerDescriptorImplTest {
@Test()
public void testExitPolicyAccept80RejectAll()
throws DescriptorParseException {
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithExitPolicyLines("accept *:80\nreject *:*");
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithExitPolicyLines("accept *:80\nreject *:*");
assertEquals(Arrays.asList(new String[] {"accept *:80",
"reject *:*"}), descriptor.getExitPolicyLines());
}
@@ -916,8 +980,8 @@ public class ServerDescriptorImplTest {
@Test()
public void testExitPolicyMaskTypes() throws DescriptorParseException {
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithExitPolicyLines("reject 192.168.0.0/16:*\n"
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithExitPolicyLines("reject 192.168.0.0/16:*\n"
+ "reject 94.134.192.243/255.255.255.0:*");
assertEquals(Arrays.asList(new String[] { "reject 192.168.0.0/16:*",
"reject 94.134.192.243/255.255.255.0:*"}),
@@ -947,22 +1011,22 @@ public class ServerDescriptorImplTest {
@Test()
public void testHibernatingOpt() throws DescriptorParseException {
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithHibernatingLine("opt hibernating 1");
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithHibernatingLine("opt hibernating 1");
assertTrue(descriptor.isHibernating());
}
@Test()
public void testHibernatingFalse() throws DescriptorParseException {
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithHibernatingLine("hibernating 0");
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithHibernatingLine("hibernating 0");
assertFalse(descriptor.isHibernating());
}
@Test()
public void testHibernatingTrue() throws DescriptorParseException {
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithHibernatingLine("hibernating 1");
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithHibernatingLine("hibernating 1");
assertTrue(descriptor.isHibernating());
}
@@ -978,16 +1042,16 @@ public class ServerDescriptorImplTest {
@Test()
public void testFamilyOpt() throws DescriptorParseException {
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithFamilyLine("opt family saberrider2008");
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithFamilyLine("opt family saberrider2008");
assertEquals(Arrays.asList(new String[] {"saberrider2008"}),
descriptor.getFamilyEntries());
}
@Test()
public void testFamilyFingerprint() throws DescriptorParseException {
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithFamilyLine("family "
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithFamilyLine("family "
+ "$D8733048FC8EC9102466AD8F3098622BF1BF71FD");
assertEquals(Arrays.asList(new String[] {
"$D8733048FC8EC9102466AD8F3098622BF1BF71FD"}),
@@ -996,8 +1060,8 @@ public class ServerDescriptorImplTest {
@Test()
public void testFamilyNickname() throws DescriptorParseException {
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithFamilyLine("family saberrider2008");
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithFamilyLine("family saberrider2008");
assertEquals(Arrays.asList(new String[] {"saberrider2008"}),
descriptor.getFamilyEntries());
}
@@ -1023,8 +1087,8 @@ public class ServerDescriptorImplTest {
@Test()
public void testFamilyFingerprintNicknameNamed()
throws DescriptorParseException {
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithFamilyLine("family "
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithFamilyLine("family "
+ "$D8733048FC8EC9102466AD8F3098622BF1BF71FD=saberrider2008");
assertEquals(Arrays.asList(new String[]
{ "$D8733048FC8EC9102466AD8F3098622BF1BF71FD=saberrider2008" }),
@@ -1034,8 +1098,8 @@ public class ServerDescriptorImplTest {
@Test()
public void testFamilyFingerprintNicknameUnnamed()
throws DescriptorParseException {
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithFamilyLine("family "
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithFamilyLine("family "
+ "$D8733048FC8EC9102466AD8F3098622BF1BF71FD~saberrider2008");
assertEquals(Arrays.asList(new String[]
{ "$D8733048FC8EC9102466AD8F3098622BF1BF71FD~saberrider2008" }),
@@ -1046,16 +1110,16 @@ public class ServerDescriptorImplTest {
public void testWriteHistory() throws DescriptorParseException {
String writeHistoryLine = "write-history 2012-01-01 03:51:44 (900 s) "
+ "4345856,261120,7591936,1748992";
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithWriteHistoryLine(writeHistoryLine);
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithWriteHistoryLine(writeHistoryLine);
assertNotNull(descriptor.getWriteHistory());
BandwidthHistory parsedWriteHistory = descriptor.getWriteHistory();
assertEquals(writeHistoryLine, parsedWriteHistory.getLine());
- assertEquals(1325389904000L, (long) parsedWriteHistory.
- getHistoryEndMillis());
+ assertEquals(1325389904000L, (long) parsedWriteHistory
+ .getHistoryEndMillis());
assertEquals(900L, (long) parsedWriteHistory.getIntervalLength());
- SortedMap<Long, Long> bandwidthValues = parsedWriteHistory.
- getBandwidthValues();
+ SortedMap<Long, Long> bandwidthValues = parsedWriteHistory
+ .getBandwidthValues();
assertEquals(4345856L, (long) bandwidthValues.remove(1325387204000L));
assertEquals(261120L, (long) bandwidthValues.remove(1325388104000L));
assertEquals(7591936L, (long) bandwidthValues.remove(1325389004000L));
@@ -1065,8 +1129,8 @@ public class ServerDescriptorImplTest {
@Test()
public void testWriteHistoryOpt() throws DescriptorParseException {
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithWriteHistoryLine("opt write-history 2012-01-01 "
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithWriteHistoryLine("opt write-history 2012-01-01 "
+ "03:51:44 (900 s) 4345856,261120,7591936,1748992");
assertNotNull(descriptor.getWriteHistory());
}
@@ -1115,25 +1179,25 @@ public class ServerDescriptorImplTest {
@Test()
public void testWriteHistoryNoValuesSpace()
throws DescriptorParseException {
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithWriteHistoryLine("write-history 2012-01-01 03:51:44 "
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithWriteHistoryLine("write-history 2012-01-01 03:51:44 "
+ "(900 s) ");
- assertEquals(900, (long) descriptor.getWriteHistory().
- getIntervalLength());
- assertTrue(descriptor.getWriteHistory().getBandwidthValues().
- isEmpty());
+ assertEquals(900, (long) descriptor.getWriteHistory()
+ .getIntervalLength());
+ assertTrue(descriptor.getWriteHistory().getBandwidthValues()
+ .isEmpty());
}
@Test()
public void testWriteHistoryNoValuesNoSpace()
throws DescriptorParseException {
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithWriteHistoryLine("write-history 2012-01-01 03:51:44 "
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithWriteHistoryLine("write-history 2012-01-01 03:51:44 "
+ "(900 s)");
- assertEquals(900, (long) descriptor.getWriteHistory().
- getIntervalLength());
- assertTrue(descriptor.getWriteHistory().getBandwidthValues().
- isEmpty());
+ assertEquals(900, (long) descriptor.getWriteHistory()
+ .getIntervalLength());
+ assertTrue(descriptor.getWriteHistory().getBandwidthValues()
+ .isEmpty());
}
@Test(expected = DescriptorParseException.class)
@@ -1152,27 +1216,27 @@ public class ServerDescriptorImplTest {
@Test()
public void testWriteHistory1800Seconds()
throws DescriptorParseException {
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithWriteHistoryLine("write-history 2012-01-01 03:51:44 "
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithWriteHistoryLine("write-history 2012-01-01 03:51:44 "
+ "(1800 s) 4345856");
- assertEquals(1800L, (long) descriptor.getWriteHistory().
- getIntervalLength());
+ assertEquals(1800L, (long) descriptor.getWriteHistory()
+ .getIntervalLength());
}
@Test()
public void testReadHistory() throws DescriptorParseException {
String readHistoryLine = "read-history 2012-01-01 03:51:44 (900 s) "
+ "4268032,139264,7797760,1415168";
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithReadHistoryLine(readHistoryLine);
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithReadHistoryLine(readHistoryLine);
assertNotNull(descriptor.getReadHistory());
BandwidthHistory parsedReadHistory = descriptor.getReadHistory();
assertEquals(readHistoryLine, parsedReadHistory.getLine());
- assertEquals(1325389904000L, (long) parsedReadHistory.
- getHistoryEndMillis());
+ assertEquals(1325389904000L, (long) parsedReadHistory
+ .getHistoryEndMillis());
assertEquals(900L, (long) parsedReadHistory.getIntervalLength());
- SortedMap<Long, Long> bandwidthValues = parsedReadHistory.
- getBandwidthValues();
+ SortedMap<Long, Long> bandwidthValues = parsedReadHistory
+ .getBandwidthValues();
assertEquals(4268032L, (long) bandwidthValues.remove(1325387204000L));
assertEquals(139264L, (long) bandwidthValues.remove(1325388104000L));
assertEquals(7797760L, (long) bandwidthValues.remove(1325389004000L));
@@ -1191,22 +1255,22 @@ public class ServerDescriptorImplTest {
@Test()
public void testEventdnsOpt() throws DescriptorParseException {
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithEventdnsLine("opt eventdns 1");
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithEventdnsLine("opt eventdns 1");
assertTrue(descriptor.getUsesEnhancedDnsLogic());
}
@Test()
public void testEventdns1() throws DescriptorParseException {
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithEventdnsLine("eventdns 1");
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithEventdnsLine("eventdns 1");
assertTrue(descriptor.getUsesEnhancedDnsLogic());
}
@Test()
public void testEventdns0() throws DescriptorParseException {
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithEventdnsLine("eventdns 0");
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithEventdnsLine("eventdns 0");
assertFalse(descriptor.getUsesEnhancedDnsLogic());
}
@@ -1222,16 +1286,16 @@ public class ServerDescriptorImplTest {
@Test()
public void testCachesExtraInfoOpt() throws DescriptorParseException {
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithCachesExtraInfoLine("opt caches-extra-info");
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithCachesExtraInfoLine("opt caches-extra-info");
assertTrue(descriptor.getCachesExtraInfo());
}
@Test()
public void testCachesExtraInfoNoSpace()
throws DescriptorParseException {
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithCachesExtraInfoLine("caches-extra-info");
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithCachesExtraInfoLine("caches-extra-info");
assertTrue(descriptor.getCachesExtraInfo());
}
@@ -1244,16 +1308,16 @@ public class ServerDescriptorImplTest {
@Test()
public void testAllowSingleHopExitsOpt()
throws DescriptorParseException {
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithAllowSingleHopExitsLine("opt allow-single-hop-exits");
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithAllowSingleHopExitsLine("opt allow-single-hop-exits");
assertTrue(descriptor.getAllowSingleHopExits());
}
@Test()
public void testAllowSingleHopExitsNoSpace()
throws DescriptorParseException {
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithAllowSingleHopExitsLine("allow-single-hop-exits");
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithAllowSingleHopExitsLine("allow-single-hop-exits");
assertTrue(descriptor.getAllowSingleHopExits());
}
@@ -1278,8 +1342,8 @@ public class ServerDescriptorImplTest {
@Test()
public void testIpv6PolicyLine() throws DescriptorParseException {
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithIpv6PolicyLine("ipv6-policy accept 80,1194,1220,1293");
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithIpv6PolicyLine("ipv6-policy accept 80,1194,1220,1293");
assertEquals("accept", descriptor.getIpv6DefaultPolicy());
assertEquals("80,1194,1220,1293", descriptor.getIpv6PortList());
}
@@ -1317,8 +1381,8 @@ public class ServerDescriptorImplTest {
@Test()
public void testNtorOnionKeyLine() throws DescriptorParseException {
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithNtorOnionKeyLine("ntor-onion-key "
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithNtorOnionKeyLine("ntor-onion-key "
+ "Y/XgaHcPIJVa4D55kir9QLH8rEYAaLXuv3c3sm8jYhY=");
assertEquals("Y/XgaHcPIJVa4D55kir9QLH8rEYAaLXuv3c3sm8jYhY",
descriptor.getNtorOnionKey());
@@ -1327,8 +1391,8 @@ public class ServerDescriptorImplTest {
@Test()
public void testNtorOnionKeyLineNoPadding()
throws DescriptorParseException {
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithNtorOnionKeyLine("ntor-onion-key "
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithNtorOnionKeyLine("ntor-onion-key "
+ "Y/XgaHcPIJVa4D55kir9QLH8rEYAaLXuv3c3sm8jYhY");
assertEquals("Y/XgaHcPIJVa4D55kir9QLH8rEYAaLXuv3c3sm8jYhY",
descriptor.getNtorOnionKey());
@@ -1403,8 +1467,8 @@ public class ServerDescriptorImplTest {
public void testUnrecognizedLineIgnore()
throws DescriptorParseException {
String unrecognizedLine = "unrecognized-line 1";
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithUnrecognizedLine(unrecognizedLine, false);
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithUnrecognizedLine(unrecognizedLine, false);
List<String> unrecognizedLines = new ArrayList<>();
unrecognizedLines.add(unrecognizedLine);
assertEquals(unrecognizedLines, descriptor.getUnrecognizedLines());
@@ -1426,8 +1490,8 @@ public class ServerDescriptorImplTest {
for (String line : unrecognizedLines) {
sb.append("\n").append(line);
}
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithUnrecognizedLine(sb.toString().substring(1), false);
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithUnrecognizedLine(sb.toString().substring(1), false);
assertEquals(unrecognizedLines, descriptor.getUnrecognizedLines());
}
@@ -1447,8 +1511,8 @@ public class ServerDescriptorImplTest {
for (String line : unrecognizedLines) {
sb.append("\n").append(line);
}
- ServerDescriptor descriptor = DescriptorBuilder.
- createWithUnrecognizedLine(sb.toString().substring(1), false);
+ ServerDescriptor descriptor = DescriptorBuilder
+ .createWithUnrecognizedLine(sb.toString().substring(1), false);
assertEquals(unrecognizedLines, descriptor.getUnrecognizedLines());
}
@@ -1579,7 +1643,7 @@ public class ServerDescriptorImplTest {
public void testOnionKeyCrosscertDuplicate()
throws DescriptorParseException {
DescriptorBuilder.createWithOnionKeyCrosscertLines(
- ONION_KEY_CROSSCERT_LINES + "\n" + ONION_KEY_CROSSCERT_LINES);
+ ONION_KEY_CROSSCERT_LINES + "\n" + ONION_KEY_CROSSCERT_LINES);
}
@Test()
diff --git a/src/test/java/org/torproject/descriptor/impl/TorperfResultImplTest.java b/src/test/java/org/torproject/descriptor/impl/TorperfResultImplTest.java
index 62d0875..080d16d 100644
--- a/src/test/java/org/torproject/descriptor/impl/TorperfResultImplTest.java
+++ b/src/test/java/org/torproject/descriptor/impl/TorperfResultImplTest.java
@@ -1,19 +1,21 @@
/* Copyright 2015--2017 The Tor Project
* See LICENSE for licensing information */
+
package org.torproject.descriptor.impl;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import java.util.List;
+import org.torproject.descriptor.Descriptor;
import org.junit.Test;
-import org.torproject.descriptor.Descriptor;
+
+import java.util.List;
public class TorperfResultImplTest {
@Test()
- public void testAnnotatedInput() throws Exception{
+ public void testAnnotatedInput() throws Exception {
TorperfResultImpl result = (TorperfResultImpl)
(TorperfResultImpl.parseTorperfResults((torperfAnnotation + input)
.getBytes("US-ASCII"), false).get(0));
@@ -29,7 +31,7 @@ public class TorperfResultImplTest {
}
@Test()
- public void testPartiallyAnnotatedInput() throws Exception{
+ public void testPartiallyAnnotatedInput() throws Exception {
byte[] asciiBytes = (torperfAnnotation
+ input + input + input).getBytes("US-ASCII");
List<Descriptor> result = TorperfResultImpl.parseTorperfResults(
1
0
commit 7e807c15aee409b68930a616d0e37b10a6f6f147
Author: David Goulet <dgoulet(a)torproject.org>
Date: Tue Jan 31 09:39:34 2017 -0500
prop224: Fix tabs issue
Signed-off-by: David Goulet <dgoulet(a)torproject.org>
---
proposals/224-rend-spec-ng.txt | 102 ++++++++++++++++++++---------------------
1 file changed, 51 insertions(+), 51 deletions(-)
diff --git a/proposals/224-rend-spec-ng.txt b/proposals/224-rend-spec-ng.txt
index 4a685e5..6f71b32 100644
--- a/proposals/224-rend-spec-ng.txt
+++ b/proposals/224-rend-spec-ng.txt
@@ -2137,80 +2137,80 @@ Appendix E. Managing authorized client data [CLIENT-AUTH-MGMT]
E.1.1. Hidden Service side
- A hidden service that wants to perform client authorization, adds a new
- option HiddenServiceAuthorizeClient to its torrc file:
+ A hidden service that wants to perform client authorization, adds a new
+ option HiddenServiceAuthorizeClient to its torrc file:
- HiddenServiceAuthorizeClient auth-type client-name,client-name,...
+ HiddenServiceAuthorizeClient auth-type client-name,client-name,...
- The only recognized auth-type value is "basic" which describes the scheme in
- section [CLIENT-AUTH]. The rest of the line is a comma-separated list of
- human-readable authorized client names.
+ The only recognized auth-type value is "basic" which describes the scheme in
+ section [CLIENT-AUTH]. The rest of the line is a comma-separated list of
+ human-readable authorized client names.
- Let's consider that one of the listed client names is "alice". In this
- case, Tor checks the "client_authorized_pubkeys" file for any entries
- with client_name being "alice". If an "alice" entry is found, we use the
- relevant pubkeys to authenticate Alice.
+ Let's consider that one of the listed client names is "alice". In this
+ case, Tor checks the "client_authorized_pubkeys" file for any entries
+ with client_name being "alice". If an "alice" entry is found, we use the
+ relevant pubkeys to authenticate Alice.
- If no "alice" entry is found in the "client_authorized_pubkeys" file, Tor
- is tasked with generating public/private keys for Alice. To do so, Tor
- generates x25519 and ed25519 keypairs for Alice, then makes a
- "client_authorized_privkeys/alice.privkey" file and writes the private
- keys inside; it also adds an entry for alice to the
- "client_authorized_pubkeys" file.
+ If no "alice" entry is found in the "client_authorized_pubkeys" file, Tor
+ is tasked with generating public/private keys for Alice. To do so, Tor
+ generates x25519 and ed25519 keypairs for Alice, then makes a
+ "client_authorized_privkeys/alice.privkey" file and writes the private
+ keys inside; it also adds an entry for alice to the
+ "client_authorized_pubkeys" file.
- In this last case, the hidden service operator has the responsibility to
- pass the .key file to Alice in a secure out-of-band way. After the file
- is passed to Alice, it can be shredded from the filesystem, as only the
- public keys are required for the hidden service to function.
+ In this last case, the hidden service operator has the responsibility to
+ pass the .key file to Alice in a secure out-of-band way. After the file
+ is passed to Alice, it can be shredded from the filesystem, as only the
+ public keys are required for the hidden service to function.
E.1.2. Client side
- A client who wants to register client authorization data for a hidden service
- needs to add the following line to their torrc:
+ A client who wants to register client authorization data for a hidden service
+ needs to add the following line to their torrc:
- HidServAuth onion-address x25519-private-key ed25519-private-key
+ HidServAuth onion-address x25519-private-key ed25519-private-key
- The keys above are either generated by Alice using a key generation utility,
- or they are extracted from a .key file provided by the hidden service.
+ The keys above are either generated by Alice using a key generation utility,
+ or they are extracted from a .key file provided by the hidden service.
- In the former case, the client is also tasked with transfering the public
- keys to the hidden service in a secure out-of-band way.
+ In the former case, the client is also tasked with transfering the public
+ keys to the hidden service in a secure out-of-band way.
E.2. Configuring client authorization using the control port
E.2.1. Service side
- A hidden service also has the option to configure authorized clients
- using the control port. The idea is that hidden service operators can use
- controller utilities that manage their access control instead of using
- the filesystem to register client keys.
+ A hidden service also has the option to configure authorized clients
+ using the control port. The idea is that hidden service operators can use
+ controller utilities that manage their access control instead of using
+ the filesystem to register client keys.
- Specifically, we require a new control port command ADD_ONION_CLIENT_AUTH
- which is able to register x25519/ed25519 public keys tied to a specific
- authorized client.
+ Specifically, we require a new control port command ADD_ONION_CLIENT_AUTH
+ which is able to register x25519/ed25519 public keys tied to a specific
+ authorized client.
[XXX figure out control port command format]
- Hidden services who use the control port interface for client auth need
- to perform their own key management.
+ Hidden services who use the control port interface for client auth need
+ to perform their own key management.
E.2.2. Client side
- There should also be a control port interface for clients to register
- authorization data for hidden services without having to use the
- torrc. It should allow both generation of client authorization private
- keys, and also to import client authorization data provided by a hidden
- service
+ There should also be a control port interface for clients to register
+ authorization data for hidden services without having to use the
+ torrc. It should allow both generation of client authorization private
+ keys, and also to import client authorization data provided by a hidden
+ service
- This way, Tor Browser can present "Generate client auth keys" and "Import
- client auth keys" dialogs to users when they try to visit a hidden service
- that is protected by client authorization.
+ This way, Tor Browser can present "Generate client auth keys" and "Import
+ client auth keys" dialogs to users when they try to visit a hidden service
+ that is protected by client authorization.
- Specifically, we require two new control port commands:
- IMPORT_ONION_CLIENT_AUTH_DATA
- GENERATE_ONION_CLIENT_AUTH_DATA
- which import and generate client authorization data respectively.
+ Specifically, we require two new control port commands:
+ IMPORT_ONION_CLIENT_AUTH_DATA
+ GENERATE_ONION_CLIENT_AUTH_DATA
+ which import and generate client authorization data respectively.
- [XXX how does key management work here?]
- [XXX what happens when people use both the control port interface and the
- filesystem interface?]
+ [XXX how does key management work here?]
+ [XXX what happens when people use both the control port interface and the
+ filesystem interface?]
1
0
[torspec/master] prop224: Specify rough directory format of hidden services.
by asn@torproject.org 31 Jan '17
by asn@torproject.org 31 Jan '17
31 Jan '17
commit 009fd7195a0a302d04b4d7d98b213c69a3d76a7f
Author: George Kadianakis <desnacked(a)riseup.net>
Date: Tue Jan 31 14:57:14 2017 +0200
prop224: Specify rough directory format of hidden services.
---
proposals/224-rend-spec-ng.txt | 80 ++++++++++++++++++++++++++++--------------
1 file changed, 53 insertions(+), 27 deletions(-)
diff --git a/proposals/224-rend-spec-ng.txt b/proposals/224-rend-spec-ng.txt
index 814fd74..4a685e5 100644
--- a/proposals/224-rend-spec-ng.txt
+++ b/proposals/224-rend-spec-ng.txt
@@ -2096,15 +2096,46 @@ Appendix E. Reserved numbers
Note: The value "0A" is skipped because it's reserved for the onion key
cross-certifying ntor identity key from proposal 228.
-Appendix F. Managing authorized client data [CLIENT-AUTH-MGMT]
+Appendix F. Hidden service directory format [HIDSERVDIR-FORMAT]
+
+ This appendix section specifies the contents of the HiddenServiceDir directory:
+
+ - "hostname" [FILE]
+
+ This file contains the onion address of the onion service.
+
+ - "private_key_ed25519" [FILE]
+
+ This file contains the private master ed25519 key of the onion service.
+ [TODO: Offline keys]
+
+ - "client_authorized_pubkeys" [FILE]
+
+ If client authorization is _enabled_, this is a newline-separated file of
+ "<client name> <pubkeys> entries for authorized clients. You can think of it
+ as the ~/.ssh/authorized_keys of onion services. See [CLIENT-AUTH-MGMT] for
+ more details.
+
+ - "./client_authorized_privkeys/" [DIRECTORY]
+ "./client_authorized_privkeys/alice.privkey" [FILE]
+ "./client_authorized_privkeys/bob.privkey" [FILE]
+ "./client_authorized_privkeys/charlie.privkey" [FILE]
+
+ If client authorization is _enabled_ _AND_ if the hidden service is
+ responsible for generating and distributing private keys for its clients,
+ then this directory contains files with client's private keys. See
+ [CLIENT-AUTH-MGMT] for more details.
+
+Appendix E. Managing authorized client data [CLIENT-AUTH-MGMT]
Hidden services and clients can configure their authorized client data either
using the torrc, or using the control port. This section presents a suggested
- scheme for configuring client authorization.
+ scheme for configuring client authorization. Please see appendix
+ [HIDSERVDIR-FORMAT] for more information about relevant hidden service files.
- F.1. Configuring client authorization using torrc
+ E.1. Configuring client authorization using torrc
- F.1.1. Hidden Service side
+ E.1.1. Hidden Service side
A hidden service that wants to perform client authorization, adds a new
option HiddenServiceAuthorizeClient to its torrc file:
@@ -2115,29 +2146,24 @@ Appendix F. Managing authorized client data [CLIENT-AUTH-MGMT]
section [CLIENT-AUTH]. The rest of the line is a comma-separated list of
human-readable authorized client names.
- Let's consider that one of the listed client names is "alice". In this case,
- Tor checks the directory at "DataDirectory/hidden_service/client_auth/" for
- any files with filename alice.key or alice.pub .
-
- Files ending in .key contain private keys for authorized clients, whereas
- .pub files contain public keys for authorized clients. In general, authorized
- clients should send their public keys to the hidden service operator, and the
- operator should place them in the filesystem as .pub files. Only .pub files
- are useful to the hidden service, whereas .key files are there only if the
- hidden service had to generate its client's keypairs as described below.
+ Let's consider that one of the listed client names is "alice". In this
+ case, Tor checks the "client_authorized_pubkeys" file for any entries
+ with client_name being "alice". If an "alice" entry is found, we use the
+ relevant pubkeys to authenticate Alice.
- If no alice.key or alice.pub files exist, Tor is tasked with generating
- client keys for Alice. To do so, Tor generates x25519 and ed25519 keypairs
- for Alice, then makes an alice.key file and writes the private keys inside;
- it also makes an alice.pub file and writes the public keys inside.
- [XXX what format? it should be convenient so that client can just copy-paste]
+ If no "alice" entry is found in the "client_authorized_pubkeys" file, Tor
+ is tasked with generating public/private keys for Alice. To do so, Tor
+ generates x25519 and ed25519 keypairs for Alice, then makes a
+ "client_authorized_privkeys/alice.privkey" file and writes the private
+ keys inside; it also adds an entry for alice to the
+ "client_authorized_pubkeys" file.
- In this case, the hidden service operator has the responsibility to pass the
- .key file to Alice in a secure out-of-band way. After the file is passed to
- Alice, it can be shredded from the filesystem, as only the public keys are
- required for the hidden service to function.
+ In this last case, the hidden service operator has the responsibility to
+ pass the .key file to Alice in a secure out-of-band way. After the file
+ is passed to Alice, it can be shredded from the filesystem, as only the
+ public keys are required for the hidden service to function.
- F.1.2. Client side
+ E.1.2. Client side
A client who wants to register client authorization data for a hidden service
needs to add the following line to their torrc:
@@ -2150,9 +2176,9 @@ Appendix F. Managing authorized client data [CLIENT-AUTH-MGMT]
In the former case, the client is also tasked with transfering the public
keys to the hidden service in a secure out-of-band way.
- F.2. Configuring client authorization using the control port
+ E.2. Configuring client authorization using the control port
- F.2.1. Service side
+ E.2.1. Service side
A hidden service also has the option to configure authorized clients
using the control port. The idea is that hidden service operators can use
@@ -2167,7 +2193,7 @@ Appendix F. Managing authorized client data [CLIENT-AUTH-MGMT]
Hidden services who use the control port interface for client auth need
to perform their own key management.
- F.2.2. Client side
+ E.2.2. Client side
There should also be a control port interface for clients to register
authorization data for hidden services without having to use the
1
0
31 Jan '17
commit 80e443aac029a454c1737e309569674b8eb0e2f3
Author: George Kadianakis <desnacked(a)riseup.net>
Date: Tue Jan 31 14:52:32 2017 +0200
prop224: Specify onion address encoding
---
proposals/224-rend-spec-ng.txt | 52 ++++++++++++++++++++++++++++++------------
1 file changed, 37 insertions(+), 15 deletions(-)
diff --git a/proposals/224-rend-spec-ng.txt b/proposals/224-rend-spec-ng.txt
index 4ef1ae3..814fd74 100644
--- a/proposals/224-rend-spec-ng.txt
+++ b/proposals/224-rend-spec-ng.txt
@@ -67,7 +67,8 @@ Table of contents:
4.2.1. Key expansion
4.3. Using legacy hosts as rendezvous points
5. Encrypting data between client and host
- 6. Open Questions:
+ 6. Encoding onion addresses [ONIONADDRESS]
+ 7. Open Questions:
-1. Draft notes
@@ -404,9 +405,10 @@ Table of contents:
1.2. In more detail: naming hidden services [NAMING]
- A hidden service's name is its long term master identity key. This
- is encoded as a hostname by encoding the entire key in Base 32, and
- adding the string ".onion" at the end.
+ A hidden service's name is its long term master identity key. This is
+ encoded as a hostname by encoding the entire key in Base 32, including a
+ version byte and a checksum, and then appending the string ".onion" at the
+ end. The result is a 56-character domain name.
(This is a change from older versions of the hidden service protocol,
where we used an 80-bit truncated SHA1 hash of a 1024 bit RSA key.)
@@ -419,17 +421,9 @@ Table of contents:
And a new name following this specification might look like:
- a1uik0w1gmfq3i5ievxdm9ceu27e88g6o7pe0rffdw9jmntwkdsd.onion
+ l5satjgud6gucryazcyvyvhuxhr74u6ygigiuyixe3a6ysis67ororad.onion
- Note that since master keys are 32 bytes long, and 52 bytes of base
- 32 encoding can hold 260 bits of information, we have four unused
- bits in each of these names.
-
- [TODO: Alternatively, we could require that the first bit of the
- master key always be zero, and use a 51-byte encoding. Or we could
- require that the first two bits be zero, and use a 51-byte encoding
- and reserve the first bit. Or we could require that the first nine
- bits, or ten bits be zero, etc.]
+ Please see section [ONIONADDRESS] for the encoding specification.
1.3. In more detail: Access control [IMD:AC]
@@ -1874,7 +1868,31 @@ Table of contents:
decryption. The client encrypts with Kf and decrypts with Kb; the
service host does the opposite.
-6. Open Questions:
+6. Encoding onion addresses [ONIONADDRESS]
+
+ The onion address of a hidden service includes its identity public key, a
+ version field and a basic checksum. All this information is then base32
+ encoded as shown below:
+
+ onion_address = base32(PUBKEY || CHECKSUM || VERSION) + ".onion"
+ CHECKSUM = H(".onion checksum" || PUBKEY || VERSION)
+
+ where:
+ - PUBKEY is the 32 bytes ed25519 master pubkey of the hidden service.
+ - VERSION is an one byte version field (default value '\x03')
+ - ".onion checksum" is a constant string
+ - CHECKSUM is truncated to two bytes before inserting it in onion_address
+
+ Here are a few example addresses (with broken checksum):
+
+ l5satjgud6gucryazcyvyvhuxhr74u6ygigiuyixe3a6ysis67ororad.onion
+ btojiu7nu5y5iwut64eufevogqdw4wmqzugnoluw232r4t3ecsfv37ad.onion
+ vckjr6bpchiahzhmtzslnl477hdfvwhzw7dmymz3s5lp64mwf6wfeqad.onion
+
+ For more information about this encoding, please see our discussion thread
+ at [ONIONADDRESS-REFS].
+
+7. Open Questions:
Scaling hidden services is hard. There are on-going discussions that
you might be able to help with. See [SCALING-REFS].
@@ -1941,6 +1959,9 @@ References:
[VANITY-REFS]:
https://github.com/Yawning/horse25519
+[ONIONADDRESS-REFS]:
+ https://lists.torproject.org/pipermail/tor-dev/2017-January/011816.html
+
Appendix A. Signature scheme with key blinding [KEYBLIND]
As described in [IMD:DIST] and [SUBCRED] above, we require a "key
@@ -2166,3 +2187,4 @@ Appendix F. Managing authorized client data [CLIENT-AUTH-MGMT]
[XXX how does key management work here?]
[XXX what happens when people use both the control port interface and the
filesystem interface?]
+
1
0
[tor-browser-bundle/master] Bug 21343: Remove unused FTE related parts for macOS
by gk@torproject.org 31 Jan '17
by gk@torproject.org 31 Jan '17
31 Jan '17
commit fc71d02f70b8bd05fbd4cd09650b175ea29fe186
Author: Georg Koppen <gk(a)torproject.org>
Date: Mon Jan 30 12:46:01 2017 +0000
Bug 21343: Remove unused FTE related parts for macOS
---
Bundle-Data/PTConfigs/mac/torrc-defaults-appendix | 3 -
.../mac/gitian-pluggable-transports.yml | 148 ---------------------
gitian/descriptors/mac/gitian-utils.yml | 21 ---
gitian/mkbundle-mac.sh | 18 +--
4 files changed, 4 insertions(+), 186 deletions(-)
diff --git a/Bundle-Data/PTConfigs/mac/torrc-defaults-appendix b/Bundle-Data/PTConfigs/mac/torrc-defaults-appendix
index f5eb5e4..271b36c 100644
--- a/Bundle-Data/PTConfigs/mac/torrc-defaults-appendix
+++ b/Bundle-Data/PTConfigs/mac/torrc-defaults-appendix
@@ -1,6 +1,3 @@
-## fteproxy configuration
-ClientTransportPlugin fte exec PluggableTransports/fteproxy.bin --managed
-
## obfs4proxy configuration
ClientTransportPlugin obfs2,obfs3,obfs4,scramblesuit exec PluggableTransports/obfs4proxy
diff --git a/gitian/descriptors/mac/gitian-pluggable-transports.yml b/gitian/descriptors/mac/gitian-pluggable-transports.yml
index 8fc4df7..5f47b47 100644
--- a/gitian/descriptors/mac/gitian-pluggable-transports.yml
+++ b/gitian/descriptors/mac/gitian-pluggable-transports.yml
@@ -7,21 +7,9 @@ architectures:
- "i386"
packages:
- "unzip"
-- "python-setuptools"
-- "python-dev"
- "zip"
reference_datetime: "2000-01-01 00:00:00"
remotes:
-- "url": "https://git.torproject.org/pluggable-transports/pyptlib.git"
- "dir": "pyptlib"
-- "url": "https://git.torproject.org/pluggable-transports/obfsproxy.git"
- "dir": "obfsproxy"
-- "url": "https://github.com/kpdyer/libfte.git"
- "dir": "libfte"
-- "url": "https://github.com/kpdyer/fteproxy.git"
- "dir": "fteproxy"
-- "url": "https://github.com/habnabit/txsocksx.git"
- "dir": "txsocksx"
- "url": "https://git.torproject.org/pluggable-transports/goptlib.git"
"dir": "goptlib"
- "url": "https://git.torproject.org/pluggable-transports/meek.git"
@@ -38,20 +26,11 @@ remotes:
"dir": "obfs4"
files:
- "versions"
-- "pycrypto.tar.gz"
-- "argparse.tar.gz"
-- "pyyaml.tar.gz"
-- "zope.interface.zip"
-- "twisted.tar.bz2"
-- "parsley.tar.gz"
- "go14.tar.gz"
- "go.tar.gz"
-- "apple-uni-sdk-10.6_20110407-0.flosoft1_i386.deb"
- "MacOSX10.7.sdk.tar.gz"
- "multiarch-darwin11-cctools127.2-gcc42-5666.3-llvmgcc42-2336.1-Linux-120724.tar.xz"
- "dzip.sh"
-- "gmp-mac64-utils.zip"
-- "openssl-mac64-utils.zip"
script: |
INSTDIR="$HOME/install"
source versions
@@ -60,13 +39,10 @@ script: |
PTDIR="$TBDIR/Contents/MacOS/Tor/PluggableTransports"
DOCSDIR="$TBDIR/Contents/Resources/TorBrowser/Docs"
TORBINDIR="$TBDIR/Contents/MacOS/Tor"
- # TODO: Fix packaging of fte so it can be included. See bug 18495.
- INCLUDE_FTE=0
else
PTDIR="$TBDIR/TorBrowser/Tor/PluggableTransports"
DOCSDIR="$TBDIR/TorBrowser/Docs"
TORBINDIR="$TBDIR/TorBrowser/Tor"
- INCLUDE_FTE=1
fi
export LIBRARY_PATH="$INSTDIR/lib"
export REFERENCE_DATETIME
@@ -77,29 +53,14 @@ script: |
mkdir -p $PTDIR/
mkdir -p $OUTDIR/
#
- # dpkg requires sbin directories in the PATH
- export PATH="/usr/sbin:/sbin:$PATH"
- sudo dpkg -i *.deb
tar xaf multiarch-darwin*tar.xz
# The 10.7 SDK is needed for Go: https://bugs.torproject.org/20023#comment:6
tar xaf MacOSX10.7.sdk.tar.gz
export PATH="$PATH:$HOME/build/apple-osx/bin/"
- if [ "z$INCLUDE_FTE" = "z1" ]; then
- unzip -d $INSTDIR gmp-mac64-utils.zip
- unzip -d $INSTDIR openssl-mac64-utils.zip
- # FTE only needs libgmp.10.dylib and no libgmpxx anymore.
- cp $INSTDIR/gmp/lib/libgmp.10.dylib $TORBINDIR/
- FTE_EXTRA_CFLAGS=" -I$INSTDIR/gmp/include -L$INSTDIR/gmp/lib"
- else
- FTE_EXTRA_CFLAGS=""
- fi
-
#
export AR=$HOME/build/apple-osx/bin/i686-apple-darwin11-ar
export CC=$HOME/build/apple-osx/bin/i686-apple-darwin11-gcc
export CXX=$HOME/build/apple-osx/bin/i686-apple-darwin11-g++
- # http://bugs.python.org/issue9437
- export LDSHARED="$CC -pthread -shared"
# Building go 1.4.x
# This is needed to bootstrap the go that we actually use
@@ -134,115 +95,6 @@ script: |
cd ../..
export PATH="$PATH:$PWD/go/bin"
- if [ "z$INCLUDE_FTE" = "z1" ]; then
-
- # Building pyptlib
- cd pyptlib
- find -type f -print0 | xargs -0 touch --date="$REFERENCE_DATETIME"
- python setup.py build --build-lib build
- cp -a build/pyptlib $PTDIR/
- cd ..
-
- # Building PyCrypto
- tar xzf pycrypto.tar.gz
- cd pycrypto-*
- find -type f -print0 | xargs -0 touch --date="$REFERENCE_DATETIME"
- # https://bugs.launchpad.net/pycrypto/+bug/1096207 for ac_cv_func_malloc_0_nonnull.
- ac_cv_func_malloc_0_nonnull=yes sh configure --host=i686-apple-darwin11
- LDSHARED="$LDSHARED -framework Python" python setup.py build_ext --build-lib build -I/usr/lib/apple/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/Python.framework/Headers
- python setup.py build --build-lib build
- cp -a build/Crypto $PTDIR/
- cd ..
-
- # Building argparse
- tar xzf argparse.tar.gz
- cd argparse-*
- find -type f -print0 | xargs -0 touch --date="$REFERENCE_DATETIME"
- python setup.py build --build-lib build
- cp -a build/argparse.py $PTDIR/
- cd ..
-
- # Building Zope interfaces
- unzip zope.interface.zip
- cd zope.interface-*
- find -type f -print0 | xargs -0 touch --date="$REFERENCE_DATETIME"
- python setup.py build --build-lib build
- cp -a build/zope $PTDIR/
- cd ..
-
- # Building PyYAML
- tar xzf pyyaml.tar.gz
- cd PyYAML-*
- find -type f -print0 | xargs -0 touch --date="$REFERENCE_DATETIME"
- python setup.py build --build-lib build
- cp -a build/yaml $PTDIR/
- cd ..
-
- # Building Twisted
- tar xjf twisted.tar.bz2
- cd Twisted-*
- find -type f -print0 | xargs -0 touch --date="$REFERENCE_DATETIME"
- LDSHARED="$LDSHARED -framework Python" python setup.py build_ext --build-lib build -I/usr/lib/apple/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/Python.framework/Headers
- python setup.py build --build-lib build
- cp -a build/twisted $PTDIR/
- cd ..
-
- # Building Parsley
- tar xzf parsley.tar.gz
- cd Parsley-*
- find -type f -print0 | xargs -0 touch --date="$REFERENCE_DATETIME"
- python setup.py build --build-lib build
- cp -a build/parsley.py $PTDIR/
- cp -a build/ometa $PTDIR/
- cp -a build/terml $PTDIR/
- cd ..
-
- # Building txsocksx
- cd txsocksx
- find -type f -print0 | xargs -0 touch --date="$REFERENCE_DATETIME"
- # Let's pretend we have the setup dependency already as we don't want to get
- # it downloaded during building. Just pretending and thus avoiding another
- # dependency should be fine here as txsocksx catches the exception due to
- # missing __version__ and __sha__ .
- mkdir vcversioner-1.14.1.1-py2.7.egg
- python setup.py build --build-lib build
- cp -a build/txsocksx $PTDIR/
- cd ..
-
- # Building obfsproxy
- cd obfsproxy
- find -type f -print0 | xargs -0 touch --date="$REFERENCE_DATETIME"
- python setup.py build --build-lib build
- cp -a build/obfsproxy $PTDIR/
- cp -a bin/obfsproxy $PTDIR/obfsproxy.bin
- mkdir -p $DOCSDIR/Obfsproxy
- cp -a {LICENSE,README} $DOCSDIR/Obfsproxy
- # XXX: Workaround for bug 11190
- sed 's/python2/python/' -i $PTDIR/obfsproxy.bin
- cd ..
-
- # Building libfte
- cd libfte
- find -type f -print0 | xargs -0 touch --date="$REFERENCE_DATETIME"
- CFLAGS="-L$INSTDIR/Tor -I$INSTDIR/gmp/include $CFLAGS" CXXFLAGS="-L$INSTDIR/Tor -I$INSTDIR/gmp/include $CXXFLAGS" make
- cp -ra fte $PTDIR/
- mkdir -p $DOCSDIR/libfte
- cp -a {LICENSE,README.md} $DOCSDIR/libfte
- cp -an thirdparty/re2/LICENSE $DOCSDIR/libfte/LICENSE.re2
- cd ..
-
- # Building fteproxy
- cd fteproxy
- find -type f -print0 | xargs -0 touch --date="$REFERENCE_DATETIME"
- cp -a bin/fteproxy $PTDIR/fteproxy.bin
- cp -ra fteproxy $PTDIR/
- mkdir -p $DOCSDIR/fteproxy
- cp -a {COPYING,README.md} $DOCSDIR/fteproxy
- cd ..
-
- fi
- # end of 'INCLUDE_FTE' section
-
# Building goptlib
cd goptlib
find -type f -print0 | xargs -0 touch --date="$REFERENCE_DATETIME"
diff --git a/gitian/descriptors/mac/gitian-utils.yml b/gitian/descriptors/mac/gitian-utils.yml
index f54d5cb..55d6c7f 100644
--- a/gitian/descriptors/mac/gitian-utils.yml
+++ b/gitian/descriptors/mac/gitian-utils.yml
@@ -27,7 +27,6 @@ files:
- "apple-uni-sdk-10.6_20110407-0.flosoft1_i386.deb"
- "multiarch-darwin11-cctools127.2-gcc42-5666.3-llvmgcc42-2336.1-Linux-120724.tar.xz"
- "openssl.tar.gz"
-- "gmp.tar.bz2"
- "versions"
- "dzip.sh"
- "libfaketime.patch"
@@ -78,8 +77,6 @@ script: |
export PATH="$PATH:$HOME/build/apple-osx/bin/"
# For OpenSSL
ln -s ~/build/apple-osx/bin/apple-osx-gcc ~/build/apple-osx/bin/i686-apple-darwin11-cc
- #For gmp, need to trick it so it knows we're doing a 64 bit build
- for i in ~/build/apple-osx/bin/i686-apple-darwin11-*; do j=`echo $i | sed 's/i686/x86_64/'`; ln -s $i $j; done;
# XXX Clean up these flags?
export CFLAGS="-m64 -I/usr/lib/apple/SDKs/MacOSX10.6.sdk/usr/include/ -I/usr/lib/gcc/i686-apple-darwin10/4.2.1/include/ -I. -L/usr/lib/apple/SDKs/MacOSX10.6.sdk/usr/lib/ -L/usr/lib/apple/SDKs/MacOSX10.6.sdk/usr/lib/system/ -mmacosx-version-min=10.5"
@@ -109,27 +106,9 @@ script: |
make install
cd ..
- # Building GMP
- tar xjf gmp.tar.bz2
- cd gmp-*
- # |configure| can't cope with nano seconds faked. And even if we would revert
- # that feature it would hang sometimes for unknown but to libfaketime related
- # reasons.
- export LD_PRELOAD=""
- find -type f -print0 | xargs -0 touch --date="$REFERENCE_DATETIME"
- # Even if we are not shipping libgmpxx anymore we still need --enable-xcc
- # during compile time.
- ./configure --host=x86_64-apple-darwin11 --prefix=$INSTDIR/gmp --disable-static --enable-shared --enable-cxx
- export LD_PRELOAD="$INSTDIR/faketime/usr/local/lib/faketime/libfaketime.so.1"
- make
- make install
- cd ..
-
# Grabbing the results
cd $INSTDIR
~/build/dzip.sh openssl-$OPENSSL_VER-mac64-utils.zip openssl
~/build/dzip.sh libevent-${LIBEVENT_TAG#release-}-mac64-utils.zip libevent
- ~/build/dzip.sh gmp-$GMP_VER-mac64-utils.zip gmp
-
cp *utils.zip $OUTDIR/
fi
diff --git a/gitian/mkbundle-mac.sh b/gitian/mkbundle-mac.sh
index 3536553..789cc80 100755
--- a/gitian/mkbundle-mac.sh
+++ b/gitian/mkbundle-mac.sh
@@ -55,17 +55,10 @@ rm -f $GITIAN_DIR/inputs/tbb-docs.zip
$WRAPPER_DIR/build-helpers/dzip.sh $GITIAN_DIR/inputs/tbb-docs.zip ./Docs/
rm -f $GITIAN_DIR/inputs/TorBrowser.app.meek-http-helper.zip
(cd PTConfigs/mac && $WRAPPER_DIR/build-helpers/dzip.sh $GITIAN_DIR/inputs/TorBrowser.app.meek-http-helper.zip TorBrowser.app.meek-http-helper)
-if [ "z$DATA_OUTSIDE_APP_DIR" = "z1" ]; then
-# FTE is temporarily disabled due to bug 18495 and snowflake is Linux-only for
+cp PTConfigs/mac/torrc-defaults-appendix $GITIAN_DIR/inputs/torrc-defaults-appendix-mac
+# FTE is temporarily removed due to bug 18495 and snowflake is Linux-only for
# now.
- grep -v 'fteproxy' PTConfigs/mac/torrc-defaults-appendix > $GITIAN_DIR/inputs/torrc-defaults-appendix-mac
grep -Ev 'default_bridge\.fte|default_bridge\.snowflake' PTConfigs/bridge_prefs.js > $GITIAN_DIR/inputs/bridge_prefs.js
-else
- cp PTConfigs/mac/torrc-defaults-appendix $GITIAN_DIR/inputs/torrc-defaults-appendix-mac
- # We don't have snowflake available on macOS yet.
- grep -v 'default_bridge\.snowflake' PTConfigs/bridge_prefs.js > $GITIAN_DIR/inputs/bridge_prefs.js
-
-fi
cp PTConfigs/meek-http-helper-user.js $GITIAN_DIR/inputs/
cp mac-tor.sh $GITIAN_DIR/inputs/
@@ -144,8 +137,7 @@ cd $GITIAN_DIR
if [ ! -f inputs/clang-$CLANG_VER-linux64-wheezy-utils.zip -o \
! -f inputs/openssl-$OPENSSL_VER-mac64-utils.zip -o \
- ! -f inputs/libevent-${LIBEVENT_TAG_ORIG#release-}-mac64-utils.zip -o \
- ! -f inputs/gmp-$GMP_VER-mac64-utils.zip ];
+ ! -f inputs/libevent-${LIBEVENT_TAG_ORIG#release-}-mac64-utils.zip ];
then
echo
echo "****** Starting Utilities Component of Mac Bundle (1/5 for Mac) ******"
@@ -162,7 +154,6 @@ then
ln -sf clang-$CLANG_VER-linux64-wheezy-utils.zip clang-linux64-wheezy-utils.zip
ln -sf openssl-$OPENSSL_VER-mac64-utils.zip openssl-mac64-utils.zip
ln -sf libevent-${LIBEVENT_TAG_ORIG#release-}-mac64-utils.zip libevent-mac64-utils.zip
- ln -sf gmp-$GMP_VER-mac64-utils.zip gmp-mac64-utils.zip
cd ..
#cp -a result/utils-mac-res.yml inputs/
else
@@ -176,7 +167,6 @@ else
ln -sf clang-$CLANG_VER-linux64-wheezy-utils.zip clang-linux64-wheezy-utils.zip
ln -sf openssl-$OPENSSL_VER-mac64-utils.zip openssl-mac64-utils.zip
ln -sf libevent-${LIBEVENT_TAG_ORIG#release-}-mac64-utils.zip libevent-mac64-utils.zip
- ln -sf gmp-$GMP_VER-mac64-utils.zip gmp-mac64-utils.zip
cd ..
fi
@@ -229,7 +219,7 @@ then
echo "****** Starting Pluggable Transports Component of Mac Bundle (4/5 for Mac) ******"
echo
- ./bin/gbuild -j $NUM_PROCS -m $VM_MEMORY --commit pyptlib=$PYPTLIB_TAG,obfsproxy=$OBFSPROXY_TAG,libfte=$LIBFTE_TAG,fteproxy=$FTEPROXY_TAG,txsocksx=$TXSOCKSX_TAG,goptlib=$GOPTLIB_TAG,meek=$MEEK_TAG,ed25519=$GOED25519_TAG,siphash=$GOSIPHASH_TAG,goxcrypto=$GO_X_CRYPTO_TAG,goxnet=$GO_X_NET_TAG,obfs4=$OBFS4_TAG $DESCRIPTOR_DIR/mac/gitian-pluggable-transports.yml
+ ./bin/gbuild -j $NUM_PROCS -m $VM_MEMORY --commit goptlib=$GOPTLIB_TAG,meek=$MEEK_TAG,ed25519=$GOED25519_TAG,siphash=$GOSIPHASH_TAG,goxcrypto=$GO_X_CRYPTO_TAG,goxnet=$GO_X_NET_TAG,obfs4=$OBFS4_TAG $DESCRIPTOR_DIR/mac/gitian-pluggable-transports.yml
if [ $? -ne 0 ];
then
#mv var/build.log ./firefox-fail-mac.log.`date +%Y%m%d%H%M%S`
1
0
[tor-browser-bundle/master] Bug 21348: Make snowflake only available on Linux for now
by gk@torproject.org 31 Jan '17
by gk@torproject.org 31 Jan '17
31 Jan '17
commit ff0756e4778736cb2e05f260bf277c20bcd2d31a
Author: Georg Koppen <gk(a)torproject.org>
Date: Mon Jan 30 14:25:18 2017 +0000
Bug 21348: Make snowflake only available on Linux for now
---
gitian/mkbundle-mac.sh | 9 ++++++---
gitian/mkbundle-windows.sh | 3 ++-
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/gitian/mkbundle-mac.sh b/gitian/mkbundle-mac.sh
index 16140b1..3536553 100755
--- a/gitian/mkbundle-mac.sh
+++ b/gitian/mkbundle-mac.sh
@@ -56,12 +56,15 @@ $WRAPPER_DIR/build-helpers/dzip.sh $GITIAN_DIR/inputs/tbb-docs.zip ./Docs/
rm -f $GITIAN_DIR/inputs/TorBrowser.app.meek-http-helper.zip
(cd PTConfigs/mac && $WRAPPER_DIR/build-helpers/dzip.sh $GITIAN_DIR/inputs/TorBrowser.app.meek-http-helper.zip TorBrowser.app.meek-http-helper)
if [ "z$DATA_OUTSIDE_APP_DIR" = "z1" ]; then
-# FTE is temporarily disabled due to bug 18495.
+# FTE is temporarily disabled due to bug 18495 and snowflake is Linux-only for
+# now.
grep -v 'fteproxy' PTConfigs/mac/torrc-defaults-appendix > $GITIAN_DIR/inputs/torrc-defaults-appendix-mac
- grep -v 'default_bridge\.fte' PTConfigs/bridge_prefs.js > $GITIAN_DIR/inputs/bridge_prefs.js
+ grep -Ev 'default_bridge\.fte|default_bridge\.snowflake' PTConfigs/bridge_prefs.js > $GITIAN_DIR/inputs/bridge_prefs.js
else
cp PTConfigs/mac/torrc-defaults-appendix $GITIAN_DIR/inputs/torrc-defaults-appendix-mac
- cp PTConfigs/bridge_prefs.js $GITIAN_DIR/inputs/
+ # We don't have snowflake available on macOS yet.
+ grep -v 'default_bridge\.snowflake' PTConfigs/bridge_prefs.js > $GITIAN_DIR/inputs/bridge_prefs.js
+
fi
cp PTConfigs/meek-http-helper-user.js $GITIAN_DIR/inputs/
cp mac-tor.sh $GITIAN_DIR/inputs/
diff --git a/gitian/mkbundle-windows.sh b/gitian/mkbundle-windows.sh
index 1afa840..6254937 100755
--- a/gitian/mkbundle-windows.sh
+++ b/gitian/mkbundle-windows.sh
@@ -55,7 +55,8 @@ cd $WRAPPER_DIR/../Bundle-Data/
rm -f $GITIAN_DIR/inputs/tbb-docs.zip
$WRAPPER_DIR/build-helpers/dzip.sh $GITIAN_DIR/inputs/tbb-docs.zip ./Docs/
cp PTConfigs/windows/torrc-defaults-appendix $GITIAN_DIR/inputs/torrc-defaults-appendix-windows
-cp PTConfigs/bridge_prefs.js $GITIAN_DIR/inputs/
+# We don't have snowflake available on Windows yet.
+grep -v 'default_bridge\.snowflake' PTConfigs/bridge_prefs.js > $GITIAN_DIR/inputs/bridge_prefs.js
cp PTConfigs/meek-http-helper-user.js $GITIAN_DIR/inputs/
cd windows
1
0
[atlas/master] Uses pre elements for fingerprints in details view, not tt (Fixes: #21350)
by irl@torproject.org 31 Jan '17
by irl@torproject.org 31 Jan '17
31 Jan '17
commit 4627254904953d0ba9c02d0cf767472d10b78acc
Author: Iain R. Learmonth <irl(a)fsfe.org>
Date: Tue Jan 31 00:21:47 2017 +0000
Uses pre elements for fingerprints in details view, not tt (Fixes: #21350)
Comment from cypherpunks: "It reverts the solution from #12685 because <pre>
tags wrap their content automatically. However, using the <pre> tag changes the
fingerprint to look like the fingerprints of the family members (except with
black text instead of blue or orange). IMO this is preferable because it makes
displaying fingerprints consistent but thought I'd mention it anyway."
In testing, I found this to actually be a better solution for responsiveness as
instead of wrapping at a fixed location, everything can still be viewable even
with a 160px wide screen. This does lead to having different length lines when
wrapping, and I guess user feedback will let us know if this was a dreadful
idea, but I don't see it causing disasterous breakage for anyone.
---
templates/details/router.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/templates/details/router.html b/templates/details/router.html
index d94f5cf..f87001f 100644
--- a/templates/details/router.html
+++ b/templates/details/router.html
@@ -72,7 +72,7 @@
<% } %>
<dt><span class="tip" data-content="20-byte unique identifier of the relay." data-original-title="Fingerprint">Fingerprint</span></dt>
- <dd><tt><%= relay.get('fingerprint').replace(/(.{20})/g,"$1​") %></tt></dd>
+ <dd><pre><%= relay.get('fingerprint') %></pre></dd>
<dt><span class="tip" data-content="Flags that the directory authorities assigned to this relay." data-original-title="Relay flags">Flags</span></dt>
<dd><% _.each(relay.get('flags'), function(flag) { %>
1
0
[atlas/master] Removes duplicate id attributes on SVG graphs (Fixes: #21351)
by irl@torproject.org 31 Jan '17
by irl@torproject.org 31 Jan '17
31 Jan '17
commit 849712efdf623af8cfcde73bc0a44ad2b70a4e96
Author: Iain R. Learmonth <irl(a)fsfe.org>
Date: Tue Jan 31 00:16:43 2017 +0000
Removes duplicate id attributes on SVG graphs (Fixes: #21351)
Comment from cypherpunks: "A quick grep shows there is no CSS that uses the
bw_month id. The id is only used by the JS code that generates the SVG graphs
to know where to inject the graphs. This code also injects the duplicate id for
some unknown reason. The inline patch fixes the issue by simply removing the
injection of the duplicate id."
I would agree with this comment.
---
js/views/details/main.js | 1 -
1 file changed, 1 deletion(-)
diff --git a/js/views/details/main.js b/js/views/details/main.js
index e73ac4a..97846be 100644
--- a/js/views/details/main.js
+++ b/js/views/details/main.js
@@ -32,7 +32,6 @@ define([
width = 550 - margin.left - margin.right,
height = 342 - margin.top - margin.bottom;
var svg = d3.select("#" + g).append("svg:svg")
- .attr("id", g)
.attr("version", 1.1)
.attr("xmlns", "http://www.w3.org/2000/svg")
.attr("width", width + margin.left + margin.right)
1
0
30 Jan '17
commit 9fa91542525e021ea11f7889293fae35d85a7f8c
Author: Damian Johnson <atagar(a)torproject.org>
Date: Thu Jan 5 10:43:01 2017 -0800
Speed up auth's test_all_use_cases unit test
This test isn't overly burdensome and it's neat that it tests all combinations,
but this one unit test alone takes around as much as every other test put
together.
We can speed it up without losing coverage by having it raise some parent
exceptions rather than each child exception individually. On my 'lil netbook
this drops the test runtime from 5s to 1s (80% faster).
---
test/unit/connection/authentication.py | 28 +++++++++-------------------
1 file changed, 9 insertions(+), 19 deletions(-)
diff --git a/test/unit/connection/authentication.py b/test/unit/connection/authentication.py
index b12efeb..70de6d7 100644
--- a/test/unit/connection/authentication.py
+++ b/test/unit/connection/authentication.py
@@ -65,35 +65,25 @@ class TestAuthenticate(unittest.TestCase):
# exceptions that the authentication functions are documented to raise
- all_auth_none_exc = (None, stem.connection.OpenAuthRejected(None))
+ all_auth_none_exc = (
+ None,
+ stem.connection.OpenAuthRejected(None),
+ stem.ControllerError(None))
all_auth_password_exc = (
None,
stem.connection.PasswordAuthRejected(None),
- stem.connection.IncorrectPassword(None))
+ stem.connection.IncorrectPassword(None),
+ stem.ControllerError(None))
all_auth_cookie_exc = (
None,
- stem.connection.IncorrectCookieSize(None, False, None),
- stem.connection.UnreadableCookieFile(None, False, None),
stem.connection.CookieAuthRejected(None, False, None),
stem.connection.IncorrectCookieValue(None, False, None),
- stem.connection.UnrecognizedAuthChallengeMethod(None, None, None),
+ stem.connection.IncorrectCookieSize(None, False, None),
+ stem.connection.UnreadableCookieFile(None, False, None),
stem.connection.AuthChallengeFailed(None, None),
- stem.connection.AuthSecurityFailure(None, None),
- stem.connection.InvalidClientNonce(None, None))
-
- # authentication functions might raise a controller error when
- # 'suppress_ctl_errors' is False, so including those
-
- control_exc = (
- stem.ProtocolError(None),
- stem.SocketError(None),
- stem.SocketClosed(None))
-
- all_auth_none_exc += control_exc
- all_auth_password_exc += control_exc
- all_auth_cookie_exc += control_exc
+ stem.ControllerError(None))
auth_method_combinations = mocking.get_all_combinations([
stem.connection.AuthMethod.NONE,
1
0
[stem/master] Speed up base controller's test_asynchronous_event_handling
by atagar@torproject.org 30 Jan '17
by atagar@torproject.org 30 Jan '17
30 Jan '17
commit 921955e540cb9ca6018129ab7eea1f3747ff677e
Author: Damian Johnson <atagar(a)torproject.org>
Date: Thu Jan 19 10:41:51 2017 -0800
Speed up base controller's test_asynchronous_event_handling
Replacing BW events with triggered events so we can speed this up by three
seconds.
---
test/integ/control/base_controller.py | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/test/integ/control/base_controller.py b/test/integ/control/base_controller.py
index 48dd3df..5beffc2 100644
--- a/test/integ/control/base_controller.py
+++ b/test/integ/control/base_controller.py
@@ -2,6 +2,8 @@
Integration tests for the stem.control.BaseController class.
"""
+import hashlib
+import os
import re
import threading
import time
@@ -150,15 +152,11 @@ class TestBaseController(unittest.TestCase):
with test.runner.get_runner().get_tor_socket() as control_socket:
controller = ControlledListener(control_socket)
- controller.msg('SETEVENTS BW')
+ controller.msg('SETEVENTS CONF_CHANGED')
- # Wait for a couple events for events to be enqueued. Doing a bunch of
- # GETINFO queries while waiting to better exercise the asynchronous event
- # handling.
-
- start_time = time.time()
-
- while (time.time() - start_time) < 3:
+ for i in range(10):
+ random_fingerprint = hashlib.sha1(os.urandom(20)).hexdigest().upper()
+ controller.msg('SETCONF NodeFamily=%s' % random_fingerprint)
test.runner.exercise_controller(self, controller)
# Concurrently shut down the controller. We need to do this in another
@@ -177,10 +175,10 @@ class TestBaseController(unittest.TestCase):
self.assertTrue(len(controller.received_events) >= 2)
- for bw_event in controller.received_events:
- self.assertTrue(re.match('BW [0-9]+ [0-9]+', str(bw_event)))
- self.assertTrue(re.match('650 BW [0-9]+ [0-9]+\r\n', bw_event.raw_content()))
- self.assertEqual(('650', ' '), bw_event.content()[0][:2])
+ for conf_changed_event in controller.received_events:
+ self.assertTrue(re.match('CONF_CHANGED\nNodeFamily=*', str(conf_changed_event)))
+ self.assertTrue(conf_changed_event.raw_content().startswith('650-CONF_CHANGED\r\n650-NodeFamily='))
+ self.assertEqual(('650', '-'), conf_changed_event.content()[0][:2])
@require_controller
def test_get_latest_heartbeat(self):
1
0