[tor-commits] [snowflake/master] Clean up proxy-go tests
cohosh at torproject.org
cohosh at torproject.org
Wed Nov 13 19:34:25 UTC 2019
commit 742070a7fbeef8e8dc0c68060a12266fe60e0ba0
Author: Cecylia Bocovich <cohosh at torproject.org>
Date: Wed Nov 13 14:31:55 2019 -0500
Clean up proxy-go tests
---
proxy-go/proxy-go_test.go | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/proxy-go/proxy-go_test.go b/proxy-go/proxy-go_test.go
index a09dcc3..ebe4381 100644
--- a/proxy-go/proxy-go_test.go
+++ b/proxy-go/proxy-go_test.go
@@ -8,6 +8,7 @@ import (
"net"
"net/http"
"net/url"
+ "strconv"
"strings"
"testing"
@@ -43,14 +44,6 @@ func (f *FaultyTransport) RoundTrip(req *http.Request) (*http.Response, error) {
return nil, fmt.Errorf("TransportFailed")
}
-const SDP = "v=0\r\no=- 4358805017720277108 2 IN IP4 8.8.8.8\r\ns=-\r\nt=0 0\r\na=group:BUNDLE data\r\na=msid-semantic: WMS\r\nm=application 56688 DTLS/SCTP 5000\r\nc=IN IP4 8.8.8.8\r\na=candidate:3769337065 1 udp 2122260223 8.8.8.8 56688 typ host generation 0 network-id 1 network-cost 50\r\na=candidate:2921887769 1 tcp 1518280447 8.8.8.8 35441 typ host tcptype passive generation 0 network-id 1 network-cost 50\r\na=ice-ufrag:aMAZ\r\na=ice-pwd:jcHb08Jjgrazp2dzjdrvPPvV\r\na=ice-options:trickle\r\na=fingerprint:sha-256 C8:88:EE:B9:E7:02:2E:21:37:ED:7A:D1:EB:2B:A3:15:A2:3B:5B:1C:3D:D4:D5:1F:06:CF:52:40:03:F8:DD:66\r\na=setup:actpass\r\na=mid:data\r\na=sctpmap:5000 webrtc-datachannel 1024\r\n"
-
-const sampleSDP = `"v=0\r\no=- 4358805017720277108 2 IN IP4 8.8.8.8\r\ns=-\r\nt=0 0\r\na=group:BUNDLE data\r\na=msid-semantic: WMS\r\nm=application 56688 DTLS/SCTP 5000\r\nc=IN IP4 8.8.8.8\r\na=candidate:3769337065 1 udp 2122260223 8.8.8.8 56688 typ host generation 0 network-id 1 network-cost 50\r\na=candidate:2921887769 1 tcp 1518280447 8.8.8.8 35441 typ host tcptype passive generation 0 network-id 1 network-cost 50\r\na=ice-ufrag:aMAZ\r\na=ice-pwd:jcHb08Jjgrazp2dzjdrvPPvV\r\na=ice-options:trickle\r\na=fingerprint:sha-256 C8:88:EE:B9:E7:02:2E:21:37:ED:7A:D1:EB:2B:A3:15:A2:3B:5B:1C:3D:D4:D5:1F:06:CF:52:40:03:F8:DD:66\r\na=setup:actpass\r\na=mid:data\r\na=sctpmap:5000 webrtc-datachannel 1024\r\n"`
-
-var sampleOffer = `{"type":"offer","sdp":` + sampleSDP + `}`
-
-const sampleAnswer = `{"type":"answer","sdp":` + sampleSDP + `}`
-
func TestRemoteIPFromSDP(t *testing.T) {
tests := []struct {
sdp string
@@ -228,6 +221,11 @@ func TestSessionDescriptions(t *testing.T) {
}
func TestBrokerInteractions(t *testing.T) {
+ const sampleSDP = `"v=0\r\no=- 4358805017720277108 2 IN IP4 8.8.8.8\r\ns=-\r\nt=0 0\r\na=group:BUNDLE data\r\na=msid-semantic: WMS\r\nm=application 56688 DTLS/SCTP 5000\r\nc=IN IP4 8.8.8.8\r\na=candidate:3769337065 1 udp 2122260223 8.8.8.8 56688 typ host generation 0 network-id 1 network-cost 50\r\na=candidate:2921887769 1 tcp 1518280447 8.8.8.8 35441 typ host tcptype passive generation 0 network-id 1 network-cost 50\r\na=ice-ufrag:aMAZ\r\na=ice-pwd:jcHb08Jjgrazp2dzjdrvPPvV\r\na=ice-options:trickle\r\na=fingerprint:sha-256 C8:88:EE:B9:E7:02:2E:21:37:ED:7A:D1:EB:2B:A3:15:A2:3B:5B:1C:3D:D4:D5:1F:06:CF:52:40:03:F8:DD:66\r\na=setup:actpass\r\na=mid:data\r\na=sctpmap:5000 webrtc-datachannel 1024\r\n"`
+
+ const sampleOffer = `{"type":"offer","sdp":` + sampleSDP + `}`
+ const sampleAnswer = `{"type":"answer","sdp":` + sampleSDP + `}`
+
Convey("Proxy connections to broker", t, func() {
broker := new(Broker)
broker.url, _ = url.Parse("localhost")
@@ -257,7 +255,8 @@ func TestBrokerInteractions(t *testing.T) {
}
sdp := broker.pollOffer(sampleOffer)
- So(sdp.SDP, ShouldEqual, SDP)
+ expectedSDP, _ := strconv.Unquote(sampleSDP)
+ So(sdp.SDP, ShouldResemble, expectedSDP)
})
Convey("handles poll error", func() {
var err error
More information about the tor-commits
mailing list