diff options
author | 2024-08-06 18:53:22 -0700 | |
---|---|---|
committer | 2024-08-06 18:53:22 -0700 | |
commit | 825ba9d21d15e1f9b34c60bac68e42ee1fb125f9 (patch) | |
tree | c466380d15d672a4619a7e1c15f058d52123dbb4 /backend/internal/ibd/auth_test.go | |
parent | 961f9e0a76c3cfe9ae92ca8da0531790e0610b69 (diff) | |
download | ibd-trader-825ba9d21d15e1f9b34c60bac68e42ee1fb125f9.tar.gz ibd-trader-825ba9d21d15e1f9b34c60bac68e42ee1fb125f9.tar.zst ibd-trader-825ba9d21d15e1f9b34c60bac68e42ee1fb125f9.zip |
Improve selection of IBD transports
Diffstat (limited to 'backend/internal/ibd/auth_test.go')
-rw-r--r-- | backend/internal/ibd/auth_test.go | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/backend/internal/ibd/auth_test.go b/backend/internal/ibd/auth_test.go index 8a00d42..54ea98a 100644 --- a/backend/internal/ibd/auth_test.go +++ b/backend/internal/ibd/auth_test.go @@ -163,9 +163,7 @@ func TestClient_Authenticate(t *testing.T) { return resp, nil }) - client := NewClient([]transport.Transport{ - &http.Client{Transport: tp}, - }, nil) + client := NewClient(nil, newTransport(tp)) cookie, err := client.Authenticate(context.Background(), "abc", "xyz") require.NoError(t, err) @@ -191,11 +189,27 @@ func TestClient_Authenticate_401(t *testing.T) { return httpmock.NewStringResponse(http.StatusUnauthorized, `{"name":"ValidationError","code":"ERR016","message":"Wrong username or password","description":"Wrong username or password"}`), nil }) - client := NewClient([]transport.Transport{ - &http.Client{Transport: tp}, - }, nil) + client := NewClient(nil, newTransport(tp)) cookie, err := client.Authenticate(context.Background(), "abc", "xyz") assert.Nil(t, cookie) assert.ErrorIs(t, err, ErrBadCredentials) } + +type testReliableTransport http.Client + +func newTransport(tp *httpmock.MockTransport) *testReliableTransport { + return (*testReliableTransport)(&http.Client{Transport: tp}) +} + +func (t *testReliableTransport) String() string { + return "testReliableTransport" +} + +func (t *testReliableTransport) Do(req *http.Request) (*http.Response, error) { + return (*http.Client)(t).Do(req) +} + +func (t *testReliableTransport) Properties() transport.Properties { + return transport.PropertiesFree | transport.PropertiesReliable +} |