mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
Update client tests for NewBrokerChannel errors
We changed NewBrokerChannel to return an error value on failure. This updates the tests to check that value.
This commit is contained in:
parent
57d4b0b5bd
commit
7682986a45
1 changed files with 14 additions and 7 deletions
|
@ -294,22 +294,25 @@ func TestSnowflakeClient(t *testing.T) {
|
||||||
fakeOffer := deserializeSessionDescription(`{"type":"offer","sdp":"test"}`)
|
fakeOffer := deserializeSessionDescription(`{"type":"offer","sdp":"test"}`)
|
||||||
|
|
||||||
Convey("Construct BrokerChannel with no front domain", func() {
|
Convey("Construct BrokerChannel with no front domain", func() {
|
||||||
b := NewBrokerChannel("test.broker", "", transport)
|
b, err := NewBrokerChannel("test.broker", "", transport)
|
||||||
So(b.url, ShouldNotBeNil)
|
So(b.url, ShouldNotBeNil)
|
||||||
|
So(err, ShouldBeNil)
|
||||||
So(b.url.Path, ShouldResemble, "test.broker")
|
So(b.url.Path, 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 := NewBrokerChannel("test.broker", "front", transport)
|
b, err := NewBrokerChannel("test.broker", "front", transport)
|
||||||
So(b.url, ShouldNotBeNil)
|
So(b.url, ShouldNotBeNil)
|
||||||
|
So(err, ShouldBeNil)
|
||||||
So(b.url.Path, ShouldResemble, "test.broker")
|
So(b.url.Path, 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 := NewBrokerChannel("test.broker", "", transport)
|
b, err := NewBrokerChannel("test.broker", "", transport)
|
||||||
|
So(err, ShouldBeNil)
|
||||||
answer, err := b.Negotiate(fakeOffer)
|
answer, err := b.Negotiate(fakeOffer)
|
||||||
So(err, ShouldBeNil)
|
So(err, ShouldBeNil)
|
||||||
So(answer, ShouldNotBeNil)
|
So(answer, ShouldNotBeNil)
|
||||||
|
@ -317,8 +320,9 @@ func TestSnowflakeClient(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
Convey("BrokerChannel.Negotiate fails with 503", func() {
|
Convey("BrokerChannel.Negotiate fails with 503", func() {
|
||||||
b := NewBrokerChannel("test.broker", "",
|
b, err := NewBrokerChannel("test.broker", "",
|
||||||
&MockTransport{http.StatusServiceUnavailable, []byte("\n")})
|
&MockTransport{http.StatusServiceUnavailable, []byte("\n")})
|
||||||
|
So(err, ShouldBeNil)
|
||||||
answer, err := b.Negotiate(fakeOffer)
|
answer, err := b.Negotiate(fakeOffer)
|
||||||
So(err, ShouldNotBeNil)
|
So(err, ShouldNotBeNil)
|
||||||
So(answer, ShouldBeNil)
|
So(answer, ShouldBeNil)
|
||||||
|
@ -326,8 +330,9 @@ func TestSnowflakeClient(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
Convey("BrokerChannel.Negotiate fails with 400", func() {
|
Convey("BrokerChannel.Negotiate fails with 400", func() {
|
||||||
b := NewBrokerChannel("test.broker", "",
|
b, err := NewBrokerChannel("test.broker", "",
|
||||||
&MockTransport{http.StatusBadRequest, []byte("\n")})
|
&MockTransport{http.StatusBadRequest, []byte("\n")})
|
||||||
|
So(err, ShouldBeNil)
|
||||||
answer, err := b.Negotiate(fakeOffer)
|
answer, err := b.Negotiate(fakeOffer)
|
||||||
So(err, ShouldNotBeNil)
|
So(err, ShouldNotBeNil)
|
||||||
So(answer, ShouldBeNil)
|
So(answer, ShouldBeNil)
|
||||||
|
@ -335,8 +340,9 @@ func TestSnowflakeClient(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
Convey("BrokerChannel.Negotiate fails with large read", func() {
|
Convey("BrokerChannel.Negotiate fails with large read", func() {
|
||||||
b := NewBrokerChannel("test.broker", "",
|
b, err := NewBrokerChannel("test.broker", "",
|
||||||
&MockTransport{http.StatusOK, make([]byte, 100001, 100001)})
|
&MockTransport{http.StatusOK, make([]byte, 100001, 100001)})
|
||||||
|
So(err, ShouldBeNil)
|
||||||
answer, err := b.Negotiate(fakeOffer)
|
answer, err := b.Negotiate(fakeOffer)
|
||||||
So(err, ShouldNotBeNil)
|
So(err, ShouldNotBeNil)
|
||||||
So(answer, ShouldBeNil)
|
So(answer, ShouldBeNil)
|
||||||
|
@ -344,8 +350,9 @@ func TestSnowflakeClient(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
Convey("BrokerChannel.Negotiate fails with unexpected error", func() {
|
Convey("BrokerChannel.Negotiate fails with unexpected error", func() {
|
||||||
b := NewBrokerChannel("test.broker", "",
|
b, err := NewBrokerChannel("test.broker", "",
|
||||||
&MockTransport{123, []byte("")})
|
&MockTransport{123, []byte("")})
|
||||||
|
So(err, ShouldBeNil)
|
||||||
answer, err := b.Negotiate(fakeOffer)
|
answer, err := b.Negotiate(fakeOffer)
|
||||||
So(err, ShouldNotBeNil)
|
So(err, ShouldNotBeNil)
|
||||||
So(answer, ShouldBeNil)
|
So(answer, ShouldBeNil)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue