[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [snowflake/main] Use a URL with a Host component in BrokerChannel tests.
commit 191510c416db6b0229e62cc2b869aaf3cee907fa
Author: David Fifield <david@xxxxxxxxxxxxxxx>
Date: Sun Jul 18 11:44:43 2021 -0600
Use a URL with a Host component in BrokerChannel tests.
The tests were using a broker URL of "test.broker" (i.e., a schema-less,
host-less, relative path), and running assertions on the value of
b.url.Path. This is strange, especially in tests regarding domain
fronting, where we care about b.url.Host, not b.url.Path. This commit
changes the broker URL to "http://test.broker" and changes tests to
check b.url.Host. I also added an additional assertion for an empty
b.Host in the non-domain-fronted case.
---
client/lib/lib_test.go | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/client/lib/lib_test.go b/client/lib/lib_test.go
index c31a1a6..03c53dd 100644
--- a/client/lib/lib_test.go
+++ b/client/lib/lib_test.go
@@ -198,24 +198,25 @@ func TestSnowflakeClient(t *testing.T) {
}
Convey("Construct BrokerChannel with no front domain", func() {
- b, err := NewBrokerChannel("test.broker", "", transport, false)
+ b, err := NewBrokerChannel("http://test.broker", "", transport, false)
So(b.url, ShouldNotBeNil)
So(err, ShouldBeNil)
- So(b.url.Path, ShouldResemble, "test.broker")
+ So(b.Host, ShouldResemble, "")
+ So(b.url.Host, ShouldResemble, "test.broker")
So(b.transport, ShouldNotBeNil)
})
Convey("Construct BrokerChannel *with* front domain", func() {
- b, err := NewBrokerChannel("test.broker", "front", transport, false)
+ b, err := NewBrokerChannel("http://test.broker", "front", transport, false)
So(b.url, ShouldNotBeNil)
So(err, ShouldBeNil)
- So(b.url.Path, ShouldResemble, "test.broker")
+ So(b.Host, ShouldResemble, "test.broker")
So(b.url.Host, ShouldResemble, "front")
So(b.transport, ShouldNotBeNil)
})
Convey("BrokerChannel.Negotiate responds with answer", func() {
- b, err := NewBrokerChannel("test.broker", "", transport, false)
+ b, err := NewBrokerChannel("http://test.broker", "", transport, false)
So(err, ShouldBeNil)
answer, err := b.Negotiate(fakeOffer)
So(err, ShouldBeNil)
@@ -224,7 +225,7 @@ func TestSnowflakeClient(t *testing.T) {
})
Convey("BrokerChannel.Negotiate fails", func() {
- b, err := NewBrokerChannel("test.broker", "",
+ b, err := NewBrokerChannel("http://test.broker", "",
&MockTransport{http.StatusOK, []byte(`{"error": "no snowflake proxies currently available"}`)},
false)
So(err, ShouldBeNil)
@@ -234,7 +235,7 @@ func TestSnowflakeClient(t *testing.T) {
})
Convey("BrokerChannel.Negotiate fails with unexpected error", func() {
- b, err := NewBrokerChannel("test.broker", "",
+ b, err := NewBrokerChannel("http://test.broker", "",
&MockTransport{http.StatusInternalServerError, []byte("\n")},
false)
So(err, ShouldBeNil)
@@ -245,7 +246,7 @@ func TestSnowflakeClient(t *testing.T) {
})
Convey("BrokerChannel.Negotiate fails with large read", func() {
- b, err := NewBrokerChannel("test.broker", "",
+ b, err := NewBrokerChannel("http://test.broker", "",
&MockTransport{http.StatusOK, make([]byte, readLimit+1)},
false)
So(err, ShouldBeNil)
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits