forked from stellar/go
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request stellar#5170 from stellar/pass_user_agent_in_ledge…
…r_backend ingest/ledgerbackend - Pass user agent in ledger backend
- Loading branch information
Showing
2 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright 2016 Stellar Development Foundation and contributors. Licensed | ||
// under the Apache License, Version 2.0. See the COPYING file at the root | ||
// of this distribution or at http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
package historyarchive | ||
|
||
import ( | ||
"net/http" | ||
"net/http/httptest" | ||
"testing" | ||
|
||
"github.com/stellar/go/support/storage" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestConfiguresHttpUserAgentForArchivePool(t *testing.T) { | ||
var userAgent string | ||
var archiveURLs []string | ||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
userAgent = r.Header["User-Agent"][0] | ||
w.WriteHeader(http.StatusOK) | ||
})) | ||
defer server.Close() | ||
archiveURLs = append(archiveURLs, server.URL) | ||
|
||
archiveOptions := ArchiveOptions{ | ||
ConnectOptions: storage.ConnectOptions{ | ||
UserAgent: "uatest", | ||
}, | ||
} | ||
|
||
archivePool, err := NewArchivePool(archiveURLs, archiveOptions) | ||
assert.NoError(t, err) | ||
|
||
ok, err := archivePool.BucketExists(EmptyXdrArrayHash()) | ||
assert.True(t, ok) | ||
assert.NoError(t, err) | ||
assert.Equal(t, userAgent, "uatest") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters