Skip to content

Commit 39047bc

Browse files
committed
test: transport encryption
Old tests were no longer working because go-libp2p 0.19 removed the undocumented 'ls' pseudoprotocol. This replaces these tests with handshake attempt (name is echoed back on OK or 'na' is returned when protocol is not available) for tls and noise variants + adds explicit test that safeguards us against enabling plaintext by default by a mistake.
1 parent e49e30d commit 39047bc

File tree

6 files changed

+27
-7
lines changed

6 files changed

+27
-7
lines changed

Diff for: test/sharness/t0060-daemon.sh

+19-4
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,26 @@ test_expect_success "ipfs help output looks good" '
125125
test_fsh cat help.txt
126126
'
127127

128-
# check transport is encrypted
129-
test_expect_success SOCAT "transport should be encrypted ( needs socat )" '
130-
socat - tcp:localhost:$SWARM_PORT,connect-timeout=1 > swarmnc < ../t0060-data/mss-ls &&
128+
# check transport is encrypted by default and no plaintext is allowed
129+
130+
test_expect_success SOCAT "default transport should support encryption (TLS, needs socat )" '
131+
socat - tcp:localhost:$SWARM_PORT,connect-timeout=1 > swarmnc < ../t0060-data/mss-tls &&
131132
grep -q "/tls" swarmnc &&
132-
test_must_fail grep -q "/plaintext/1.0.0" swarmnc ||
133+
test_must_fail grep -q "na" swarmnc ||
134+
test_fsh cat swarmnc
135+
'
136+
137+
test_expect_success SOCAT "default transport should support encryption (Noise, needs socat )" '
138+
socat - tcp:localhost:$SWARM_PORT,connect-timeout=1 > swarmnc < ../t0060-data/mss-noise &&
139+
grep -q "/noise" swarmnc &&
140+
test_must_fail grep -q "na" swarmnc ||
141+
test_fsh cat swarmnc
142+
'
143+
144+
test_expect_success SOCAT "default transport should not support plaintext (needs socat )" '
145+
socat - tcp:localhost:$SWARM_PORT,connect-timeout=1 > swarmnc < ../t0060-data/mss-plaintext &&
146+
grep -q "na" swarmnc &&
147+
test_must_fail grep -q "/plaintext" swarmnc ||
133148
test_fsh cat swarmnc
134149
'
135150

Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
/multistream/1.0.0
2-
ls
2+
/noise

Diff for: test/sharness/t0060-data/mss-plaintext

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/multistream/1.0.0
2+
/plaintext/2.0.0

Diff for: test/sharness/t0060-data/mss-tls

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/multistream/1.0.0
2+
/tls/1.0.0

Diff for: test/sharness/t0061-daemon-opts.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ apiaddr=$API_ADDR
1818

1919
# Odd. this fails here, but the inverse works on t0060-daemon.
2020
test_expect_success SOCAT 'transport should be unencrypted ( needs socat )' '
21-
socat - tcp:localhost:$SWARM_PORT,connect-timeout=1 > swarmnc < ../t0060-data/mss-ls &&
22-
grep -q "/plaintext" swarmnc ||
21+
socat - tcp:localhost:$SWARM_PORT,connect-timeout=1 > swarmnc < ../t0060-data/mss-plaintext &&
22+
grep -q "/plaintext" swarmnc &&
23+
test_must_fail grep -q "na" swarmnc ||
2324
test_fsh cat swarmnc
2425
'
2526

Diff for: test/sharness/t0280-plugin-dag-jose.sh

100644100755
File mode changed.

0 commit comments

Comments
 (0)