Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
briar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Julian Dehm
briar
Commits
5656dc8d
Commit
5656dc8d
authored
13 years ago
by
akwizgran
Browse files
Options
Downloads
Patches
Plain Diff
Another unit test for the Tor plugin.
parent
fbf5c78f
Branches
implement-chunking
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
components/net/sf/briar/plugins/tor/TorPlugin.java
+2
-3
2 additions, 3 deletions
components/net/sf/briar/plugins/tor/TorPlugin.java
test/net/sf/briar/plugins/tor/TorPluginTest.java
+31
-0
31 additions, 0 deletions
test/net/sf/briar/plugins/tor/TorPluginTest.java
with
33 additions
and
3 deletions
components/net/sf/briar/plugins/tor/TorPlugin.java
+
2
−
3
View file @
5656dc8d
...
@@ -26,7 +26,6 @@ import org.silvertunnel.netlib.api.util.TcpipNetAddress;
...
@@ -26,7 +26,6 @@ import org.silvertunnel.netlib.api.util.TcpipNetAddress;
import
org.silvertunnel.netlib.layer.tor.TorHiddenServicePortPrivateNetAddress
;
import
org.silvertunnel.netlib.layer.tor.TorHiddenServicePortPrivateNetAddress
;
import
org.silvertunnel.netlib.layer.tor.TorHiddenServicePrivateNetAddress
;
import
org.silvertunnel.netlib.layer.tor.TorHiddenServicePrivateNetAddress
;
import
org.silvertunnel.netlib.layer.tor.TorNetLayerUtil
;
import
org.silvertunnel.netlib.layer.tor.TorNetLayerUtil
;
import
org.silvertunnel.netlib.layer.tor.TorNetServerSocket
;
import
org.silvertunnel.netlib.layer.tor.util.Encryption
;
import
org.silvertunnel.netlib.layer.tor.util.Encryption
;
import
org.silvertunnel.netlib.layer.tor.util.RSAKeyPair
;
import
org.silvertunnel.netlib.layer.tor.util.RSAKeyPair
;
...
@@ -94,9 +93,9 @@ class TorPlugin implements DuplexPlugin {
...
@@ -94,9 +93,9 @@ class TorPlugin implements DuplexPlugin {
NetLayer
nl
=
netFactory
.
getNetLayerById
(
NetLayerIDs
.
TOR
);
NetLayer
nl
=
netFactory
.
getNetLayerById
(
NetLayerIDs
.
TOR
);
nl
.
waitUntilReady
();
nl
.
waitUntilReady
();
// Publish the hidden service
// Publish the hidden service
Tor
NetServerSocket
ss
;
NetServerSocket
ss
;
try
{
try
{
ss
=
(
TorNetServerSocket
)
nl
.
createNetServerSocket
(
null
,
addrPort
);
ss
=
nl
.
createNetServerSocket
(
null
,
addrPort
);
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
if
(
LOG
.
isLoggable
(
Level
.
WARNING
))
LOG
.
warning
(
e
.
toString
());
if
(
LOG
.
isLoggable
(
Level
.
WARNING
))
LOG
.
warning
(
e
.
toString
());
return
;
return
;
...
...
This diff is collapsed.
Click to expand it.
test/net/sf/briar/plugins/tor/TorPluginTest.java
+
31
−
0
View file @
5656dc8d
...
@@ -49,6 +49,37 @@ public class TorPluginTest extends BriarTestCase {
...
@@ -49,6 +49,37 @@ public class TorPluginTest extends BriarTestCase {
clientPlugin
.
stop
();
clientPlugin
.
stop
();
}
}
@Test
public
void
testStoreAndRetrievePrivateKey
()
throws
Exception
{
Executor
e
=
Executors
.
newCachedThreadPool
();
// Start a plugin instance with no private key
Callback
callback
=
new
Callback
();
TorPlugin
plugin
=
new
TorPlugin
(
e
,
callback
,
0L
);
plugin
.
start
();
// The plugin should create a hidden service... eventually
callback
.
latch
.
await
(
5
,
TimeUnit
.
MINUTES
);
String
onion
=
callback
.
local
.
get
(
"onion"
);
assertNotNull
(
onion
);
assertTrue
(
onion
.
endsWith
(
".onion"
));
// Get the PEM-encoded private key and stop the plugin
String
privateKey
=
callback
.
config
.
get
(
"privateKey"
);
assertNotNull
(
privateKey
);
plugin
.
stop
();
// Start another instance, reusing the private key
callback
=
new
Callback
();
callback
.
config
.
put
(
"privateKey"
,
privateKey
);
plugin
=
new
TorPlugin
(
e
,
callback
,
0L
);
plugin
.
start
();
// The plugin should create a hidden service... eventually
callback
.
latch
.
await
(
5
,
TimeUnit
.
MINUTES
);
// The onion URL should be the same
assertEquals
(
onion
,
callback
.
local
.
get
(
"onion"
));
// The private key should be the same
assertEquals
(
privateKey
,
callback
.
config
.
get
(
"privateKey"
));
// Stop the plugin
plugin
.
stop
();
}
private
static
class
Callback
implements
DuplexPluginCallback
{
private
static
class
Callback
implements
DuplexPluginCallback
{
private
final
Map
<
ContactId
,
TransportProperties
>
remote
=
private
final
Map
<
ContactId
,
TransportProperties
>
remote
=
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment