summaryrefslogtreecommitdiff
path: root/client/httpclient_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'client/httpclient_test.go')
-rw-r--r--client/httpclient_test.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/client/httpclient_test.go b/client/httpclient_test.go
index 97e1384..59dabc4 100644
--- a/client/httpclient_test.go
+++ b/client/httpclient_test.go
@@ -94,6 +94,35 @@ func TestEmptyBasicAuthSettings(t *testing.T) {
require.NoError(t, err)
}
+func TestRequestWithUserAgent(t *testing.T) {
+ const gitalyUserAgent = "gitaly/13.5.0"
+ requests := []testserver.TestRequestHandler{
+ {
+ Path: "/api/v4/internal/default_user_agent",
+ Handler: func(w http.ResponseWriter, r *http.Request) {
+ assert.Equal(t, defaultUserAgent, r.UserAgent())
+ },
+ },
+ {
+ Path: "/api/v4/internal/override_user_agent",
+ Handler: func(w http.ResponseWriter, r *http.Request) {
+ assert.Equal(t, gitalyUserAgent, r.UserAgent())
+ },
+ },
+ }
+
+ client, cleanup := setup(t, "", "", requests)
+ defer cleanup()
+
+ _, err := client.Get(context.Background(), "/default_user_agent")
+ require.NoError(t, err)
+
+ client.SetUserAgent(gitalyUserAgent)
+ _, err = client.Get(context.Background(), "/override_user_agent")
+ require.NoError(t, err)
+
+}
+
func setup(t *testing.T, username, password string, requests []testserver.TestRequestHandler) (*GitlabNetClient, func()) {
url, cleanup := testserver.StartHttpServer(t, requests)