mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-14 05:11:19 -04:00
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.
This commit is contained in:
parent
e3d376ca43
commit
191510c416
1 changed files with 9 additions and 8 deletions
|
@ -198,24 +198,25 @@ func TestSnowflakeClient(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Convey("Construct BrokerChannel with no front domain", func() {
|
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(b.url, ShouldNotBeNil)
|
||||||
So(err, ShouldBeNil)
|
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)
|
So(b.transport, ShouldNotBeNil)
|
||||||
})
|
})
|
||||||
|
|
||||||
Convey("Construct BrokerChannel *with* front domain", func() {
|
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(b.url, ShouldNotBeNil)
|
||||||
So(err, ShouldBeNil)
|
So(err, ShouldBeNil)
|
||||||
So(b.url.Path, ShouldResemble, "test.broker")
|
So(b.Host, ShouldResemble, "test.broker")
|
||||||
So(b.url.Host, ShouldResemble, "front")
|
So(b.url.Host, ShouldResemble, "front")
|
||||||
So(b.transport, ShouldNotBeNil)
|
So(b.transport, ShouldNotBeNil)
|
||||||
})
|
})
|
||||||
|
|
||||||
Convey("BrokerChannel.Negotiate responds with answer", func() {
|
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)
|
So(err, ShouldBeNil)
|
||||||
answer, err := b.Negotiate(fakeOffer)
|
answer, err := b.Negotiate(fakeOffer)
|
||||||
So(err, ShouldBeNil)
|
So(err, ShouldBeNil)
|
||||||
|
@ -224,7 +225,7 @@ func TestSnowflakeClient(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
Convey("BrokerChannel.Negotiate fails", func() {
|
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"}`)},
|
&MockTransport{http.StatusOK, []byte(`{"error": "no snowflake proxies currently available"}`)},
|
||||||
false)
|
false)
|
||||||
So(err, ShouldBeNil)
|
So(err, ShouldBeNil)
|
||||||
|
@ -234,7 +235,7 @@ func TestSnowflakeClient(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
Convey("BrokerChannel.Negotiate fails with unexpected error", func() {
|
Convey("BrokerChannel.Negotiate fails with unexpected error", func() {
|
||||||
b, err := NewBrokerChannel("test.broker", "",
|
b, err := NewBrokerChannel("http://test.broker", "",
|
||||||
&MockTransport{http.StatusInternalServerError, []byte("\n")},
|
&MockTransport{http.StatusInternalServerError, []byte("\n")},
|
||||||
false)
|
false)
|
||||||
So(err, ShouldBeNil)
|
So(err, ShouldBeNil)
|
||||||
|
@ -245,7 +246,7 @@ func TestSnowflakeClient(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
Convey("BrokerChannel.Negotiate fails with large read", func() {
|
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)},
|
&MockTransport{http.StatusOK, make([]byte, readLimit+1)},
|
||||||
false)
|
false)
|
||||||
So(err, ShouldBeNil)
|
So(err, ShouldBeNil)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue