From 8c933dda3847bfc249d37995497093d194a57dbc Mon Sep 17 00:00:00 2001 From: Eric Wollesen Date: Fri, 3 Nov 2023 12:35:02 -0600 Subject: [PATCH] make client config's UserAgent property optional The value is useful for debugging, but it's not being set shouldn't stop a test or any other process from running. Also fixed a few calls to Go stdlib deprecated functions. --- alerts/client_test.go | 3 +- client/client.go | 4 +- client/client_test.go | 85 ++++++++++++++++++------------------ client/config.go | 14 ++++-- client/config_test.go | 5 --- data/client/client_test.go | 7 --- metric/client/client_test.go | 7 --- platform/config_test.go | 5 --- 8 files changed, 56 insertions(+), 74 deletions(-) diff --git a/alerts/client_test.go b/alerts/client_test.go index 9d8e90611d..a200217823 100644 --- a/alerts/client_test.go +++ b/alerts/client_test.go @@ -80,8 +80,7 @@ var _ = Describe("Client", func() { func buildTestClient(s *httptest.Server) *Client { pCfg := &platform.Config{ Config: &client.Config{ - Address: s.URL, - UserAgent: "foo", + Address: s.URL, }, } token := mockTokenProvider(testToken) diff --git a/client/client.go b/client/client.go index c8709b09b2..7468948ba5 100644 --- a/client/client.go +++ b/client/client.go @@ -117,7 +117,9 @@ func (c *Client) createRequest(ctx context.Context, method string, url string, m return nil, errors.New("url is missing") } - mutators = append(mutators, request.NewHeaderMutator("User-Agent", c.userAgent)) + if c.userAgent != "" { + mutators = append(mutators, request.NewHeaderMutator("User-Agent", c.userAgent)) + } var body io.Reader if requestBody != nil { diff --git a/client/client_test.go b/client/client_test.go index 240d4f43ef..f19c110b64 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "io" - "io/ioutil" "net/http" "net/url" "strings" @@ -34,13 +33,10 @@ type ResponseBody struct { } var _ = Describe("Client", func() { - var userAgent string var config *client.Config BeforeEach(func() { - userAgent = testHttp.NewUserAgent() config = client.NewConfig() - config.UserAgent = userAgent }) Context("New", func() { @@ -226,6 +222,45 @@ var _ = Describe("Client", func() { } }) + Context("with a user agent", func() { + var userAgent = testHttp.NewUserAgent() + JustBeforeEach(func() { + config.UserAgent = userAgent + clnt, err = client.New(config) + Expect(err).ToNot(HaveOccurred()) + }) + + It("sets the User-Agent header in requests", func() { + server.AppendHandlers(CombineHandlers( + VerifyHeaderKV("User-Agent", userAgent), + RespondWith(http.StatusNoContent, nil))) + + _, err = clnt.RequestStreamWithHTTPClient(ctx, method, url, mutators, nil, inspectors, httpClient) + + Expect(err).ToNot(HaveOccurred()) + Expect(server.ReceivedRequests()).To(HaveLen(1)) + }) + }) + + Context("without a user agent", func() { + JustBeforeEach(func() { + config.UserAgent = "" + clnt, err = client.New(config) + Expect(err).ToNot(HaveOccurred()) + }) + + It("doesn't set one (and the Go default is used)", func() { + server.AppendHandlers(CombineHandlers( + VerifyHeaderKV("User-Agent", "Go-http-client/1.1"), + RespondWith(http.StatusNoContent, nil))) + + _, err = clnt.RequestStreamWithHTTPClient(ctx, method, url, mutators, nil, inspectors, httpClient) + + Expect(err).ToNot(HaveOccurred()) + Expect(server.ReceivedRequests()).To(HaveLen(1)) + }) + }) + It("returns error if http client is missing", func() { reader, err = clnt.RequestStreamWithHTTPClient(ctx, method, url, mutators, requestBody, inspectors, nil) Expect(err).To(MatchError("http client is missing")) @@ -287,7 +322,6 @@ var _ = Describe("Client", func() { server.AppendHandlers( CombineHandlers( VerifyRequest(method, path, fmt.Sprintf("%s=%s", parameterMutator.Key, parameterMutator.Value)), - VerifyHeaderKV("User-Agent", userAgent), VerifyHeaderKV(headerMutator.Key, headerMutator.Value), VerifyBody(nil), RespondWith(http.StatusOK, []byte(responseString), responseHeaders), @@ -315,7 +349,6 @@ var _ = Describe("Client", func() { server.AppendHandlers( CombineHandlers( VerifyRequest(method, path, fmt.Sprintf("%s=%s", parameterMutator.Key, parameterMutator.Value)), - VerifyHeaderKV("User-Agent", userAgent), VerifyHeaderKV("Content-Type", "application/json; charset=utf-8"), VerifyHeaderKV(headerMutator.Key, headerMutator.Value), VerifyBody(test.MarshalRequestBody(requestBody)), @@ -340,7 +373,6 @@ var _ = Describe("Client", func() { server.AppendHandlers( CombineHandlers( VerifyRequest(method, path, fmt.Sprintf("%s=%s", parameterMutator.Key, parameterMutator.Value)), - VerifyHeaderKV("User-Agent", userAgent), VerifyHeaderKV("Content-Type", "application/json; charset=utf-8"), VerifyHeaderKV(headerMutator.Key, headerMutator.Value), VerifyBody(test.MarshalRequestBody(requestBody)), @@ -362,7 +394,6 @@ var _ = Describe("Client", func() { server.AppendHandlers( CombineHandlers( VerifyRequest(method, path, fmt.Sprintf("%s=%s", parameterMutator.Key, parameterMutator.Value)), - VerifyHeaderKV("User-Agent", userAgent), VerifyHeaderKV("Content-Type", "application/json; charset=utf-8"), VerifyHeaderKV(headerMutator.Key, headerMutator.Value), VerifyBody(test.MarshalRequestBody(requestBody)), @@ -384,7 +415,6 @@ var _ = Describe("Client", func() { server.AppendHandlers( CombineHandlers( VerifyRequest(method, path, fmt.Sprintf("%s=%s", parameterMutator.Key, parameterMutator.Value)), - VerifyHeaderKV("User-Agent", userAgent), VerifyHeaderKV("Content-Type", "application/json; charset=utf-8"), VerifyHeaderKV(headerMutator.Key, headerMutator.Value), VerifyBody(test.MarshalRequestBody(requestBody)), @@ -406,7 +436,6 @@ var _ = Describe("Client", func() { server.AppendHandlers( CombineHandlers( VerifyRequest(method, path, fmt.Sprintf("%s=%s", parameterMutator.Key, parameterMutator.Value)), - VerifyHeaderKV("User-Agent", userAgent), VerifyHeaderKV("Content-Type", "application/json; charset=utf-8"), VerifyHeaderKV(headerMutator.Key, headerMutator.Value), VerifyBody(test.MarshalRequestBody(requestBody)), @@ -431,7 +460,6 @@ var _ = Describe("Client", func() { server.AppendHandlers( CombineHandlers( VerifyRequest(method, path, fmt.Sprintf("%s=%s", parameterMutator.Key, parameterMutator.Value)), - VerifyHeaderKV("User-Agent", userAgent), VerifyHeaderKV("Content-Type", "application/json; charset=utf-8"), VerifyHeaderKV(headerMutator.Key, headerMutator.Value), VerifyBody(test.MarshalRequestBody(requestBody)), @@ -453,7 +481,6 @@ var _ = Describe("Client", func() { server.AppendHandlers( CombineHandlers( VerifyRequest(method, path, fmt.Sprintf("%s=%s", parameterMutator.Key, parameterMutator.Value)), - VerifyHeaderKV("User-Agent", userAgent), VerifyHeaderKV("Content-Type", "application/json; charset=utf-8"), VerifyHeaderKV(headerMutator.Key, headerMutator.Value), VerifyBody(test.MarshalRequestBody(requestBody)), @@ -475,7 +502,6 @@ var _ = Describe("Client", func() { server.AppendHandlers( CombineHandlers( VerifyRequest(method, path, fmt.Sprintf("%s=%s", parameterMutator.Key, parameterMutator.Value)), - VerifyHeaderKV("User-Agent", userAgent), VerifyHeaderKV("Content-Type", "application/json; charset=utf-8"), VerifyHeaderKV(headerMutator.Key, headerMutator.Value), VerifyBody(test.MarshalRequestBody(requestBody)), @@ -497,7 +523,6 @@ var _ = Describe("Client", func() { server.AppendHandlers( CombineHandlers( VerifyRequest(method, path, fmt.Sprintf("%s=%s", parameterMutator.Key, parameterMutator.Value)), - VerifyHeaderKV("User-Agent", userAgent), VerifyHeaderKV("Content-Type", "application/json; charset=utf-8"), VerifyHeaderKV(headerMutator.Key, headerMutator.Value), VerifyBody(test.MarshalRequestBody(requestBody)), @@ -522,7 +547,6 @@ var _ = Describe("Client", func() { server.AppendHandlers( CombineHandlers( VerifyRequest(method, path, fmt.Sprintf("%s=%s", parameterMutator.Key, parameterMutator.Value)), - VerifyHeaderKV("User-Agent", userAgent), VerifyHeaderKV("Content-Type", "application/json; charset=utf-8"), VerifyHeaderKV(headerMutator.Key, headerMutator.Value), VerifyBody(test.MarshalRequestBody(requestBody)), @@ -544,7 +568,6 @@ var _ = Describe("Client", func() { server.AppendHandlers( CombineHandlers( VerifyRequest(method, path, fmt.Sprintf("%s=%s", parameterMutator.Key, parameterMutator.Value)), - VerifyHeaderKV("User-Agent", userAgent), VerifyHeaderKV("Content-Type", "application/json; charset=utf-8"), VerifyHeaderKV(headerMutator.Key, headerMutator.Value), VerifyBody(test.MarshalRequestBody(requestBody)), @@ -566,7 +589,6 @@ var _ = Describe("Client", func() { server.AppendHandlers( CombineHandlers( VerifyRequest(method, path, fmt.Sprintf("%s=%s", parameterMutator.Key, parameterMutator.Value)), - VerifyHeaderKV("User-Agent", userAgent), VerifyHeaderKV("Content-Type", "application/json; charset=utf-8"), VerifyHeaderKV(headerMutator.Key, headerMutator.Value), VerifyBody(test.MarshalRequestBody(requestBody)), @@ -588,7 +610,6 @@ var _ = Describe("Client", func() { server.AppendHandlers( CombineHandlers( VerifyRequest(method, path, fmt.Sprintf("%s=%s", parameterMutator.Key, parameterMutator.Value)), - VerifyHeaderKV("User-Agent", userAgent), VerifyHeaderKV(headerMutator.Key, headerMutator.Value), VerifyBody(nil), RespondWith(http.StatusOK, []byte(responseString)), @@ -600,7 +621,7 @@ var _ = Describe("Client", func() { reader, err = clnt.RequestStreamWithHTTPClient(ctx, method, url, mutators, nil, inspectors, httpClient) Expect(err).ToNot(HaveOccurred()) Expect(reader).ToNot(BeNil()) - Expect(ioutil.ReadAll(reader)).To(Equal([]byte(responseString))) + Expect(io.ReadAll(reader)).To(Equal([]byte(responseString))) Expect(server.ReceivedRequests()).To(HaveLen(1)) }) }) @@ -610,7 +631,6 @@ var _ = Describe("Client", func() { server.AppendHandlers( CombineHandlers( VerifyRequest(method, path, fmt.Sprintf("%s=%s", parameterMutator.Key, parameterMutator.Value)), - VerifyHeaderKV("User-Agent", userAgent), VerifyHeaderKV(headerMutator.Key, headerMutator.Value), VerifyBody([]byte(requestString)), RespondWith(http.StatusOK, []byte(responseString)), @@ -622,7 +642,7 @@ var _ = Describe("Client", func() { reader, err = clnt.RequestStreamWithHTTPClient(ctx, method, url, mutators, strings.NewReader(requestString), inspectors, httpClient) Expect(err).ToNot(HaveOccurred()) Expect(reader).ToNot(BeNil()) - Expect(ioutil.ReadAll(reader)).To(Equal([]byte(responseString))) + Expect(io.ReadAll(reader)).To(Equal([]byte(responseString))) Expect(server.ReceivedRequests()).To(HaveLen(1)) }) }) @@ -632,7 +652,6 @@ var _ = Describe("Client", func() { server.AppendHandlers( CombineHandlers( VerifyRequest(method, path, fmt.Sprintf("%s=%s", parameterMutator.Key, parameterMutator.Value)), - VerifyHeaderKV("User-Agent", userAgent), VerifyHeaderKV("Content-Type", "application/json; charset=utf-8"), VerifyHeaderKV(headerMutator.Key, headerMutator.Value), VerifyBody(test.MarshalRequestBody(requestBody)), @@ -645,7 +664,7 @@ var _ = Describe("Client", func() { reader, err = clnt.RequestStreamWithHTTPClient(ctx, method, url, mutators, requestBody, inspectors, httpClient) Expect(err).ToNot(HaveOccurred()) Expect(reader).ToNot(BeNil()) - Expect(ioutil.ReadAll(reader)).To(Equal([]byte(responseString))) + Expect(io.ReadAll(reader)).To(Equal([]byte(responseString))) Expect(server.ReceivedRequests()).To(HaveLen(1)) }) }) @@ -705,7 +724,6 @@ var _ = Describe("Client", func() { server.AppendHandlers( CombineHandlers( VerifyRequest(method, path, fmt.Sprintf("%s=%s", parameterMutator.Key, parameterMutator.Value)), - VerifyHeaderKV("User-Agent", userAgent), VerifyHeaderKV(headerMutator.Key, headerMutator.Value), VerifyBody(nil), RespondWith(http.StatusOK, test.MarshalResponseBody(&ResponseBody{Response: responseString}), responseHeaders), @@ -733,7 +751,6 @@ var _ = Describe("Client", func() { server.AppendHandlers( CombineHandlers( VerifyRequest(method, path, fmt.Sprintf("%s=%s", parameterMutator.Key, parameterMutator.Value)), - VerifyHeaderKV("User-Agent", userAgent), VerifyHeaderKV(headerMutator.Key, headerMutator.Value), VerifyBody(nil), RespondWith(http.StatusOK, test.MarshalResponseBody(&ResponseBody{Response: responseString}), responseHeaders), @@ -754,7 +771,6 @@ var _ = Describe("Client", func() { server.AppendHandlers( CombineHandlers( VerifyRequest(method, path, fmt.Sprintf("%s=%s", parameterMutator.Key, parameterMutator.Value)), - VerifyHeaderKV("User-Agent", userAgent), VerifyHeaderKV("Content-Type", "application/json; charset=utf-8"), VerifyHeaderKV(headerMutator.Key, headerMutator.Value), VerifyBody(test.MarshalRequestBody(requestBody)), @@ -778,7 +794,6 @@ var _ = Describe("Client", func() { server.AppendHandlers( CombineHandlers( VerifyRequest(method, path, fmt.Sprintf("%s=%s", parameterMutator.Key, parameterMutator.Value)), - VerifyHeaderKV("User-Agent", userAgent), VerifyHeaderKV("Content-Type", "application/json; charset=utf-8"), VerifyHeaderKV(headerMutator.Key, headerMutator.Value), VerifyBody(test.MarshalRequestBody(requestBody)), @@ -799,7 +814,6 @@ var _ = Describe("Client", func() { server.AppendHandlers( CombineHandlers( VerifyRequest(method, path, fmt.Sprintf("%s=%s", parameterMutator.Key, parameterMutator.Value)), - VerifyHeaderKV("User-Agent", userAgent), VerifyHeaderKV("Content-Type", "application/json; charset=utf-8"), VerifyHeaderKV(headerMutator.Key, headerMutator.Value), VerifyBody(test.MarshalRequestBody(requestBody)), @@ -820,7 +834,6 @@ var _ = Describe("Client", func() { server.AppendHandlers( CombineHandlers( VerifyRequest(method, path, fmt.Sprintf("%s=%s", parameterMutator.Key, parameterMutator.Value)), - VerifyHeaderKV("User-Agent", userAgent), VerifyHeaderKV("Content-Type", "application/json; charset=utf-8"), VerifyHeaderKV(headerMutator.Key, headerMutator.Value), VerifyBody(test.MarshalRequestBody(requestBody)), @@ -841,7 +854,6 @@ var _ = Describe("Client", func() { server.AppendHandlers( CombineHandlers( VerifyRequest(method, path, fmt.Sprintf("%s=%s", parameterMutator.Key, parameterMutator.Value)), - VerifyHeaderKV("User-Agent", userAgent), VerifyHeaderKV("Content-Type", "application/json; charset=utf-8"), VerifyHeaderKV(headerMutator.Key, headerMutator.Value), VerifyBody(test.MarshalRequestBody(requestBody)), @@ -865,7 +877,6 @@ var _ = Describe("Client", func() { server.AppendHandlers( CombineHandlers( VerifyRequest(method, path, fmt.Sprintf("%s=%s", parameterMutator.Key, parameterMutator.Value)), - VerifyHeaderKV("User-Agent", userAgent), VerifyHeaderKV("Content-Type", "application/json; charset=utf-8"), VerifyHeaderKV(headerMutator.Key, headerMutator.Value), VerifyBody(test.MarshalRequestBody(requestBody)), @@ -886,7 +897,6 @@ var _ = Describe("Client", func() { server.AppendHandlers( CombineHandlers( VerifyRequest(method, path, fmt.Sprintf("%s=%s", parameterMutator.Key, parameterMutator.Value)), - VerifyHeaderKV("User-Agent", userAgent), VerifyHeaderKV("Content-Type", "application/json; charset=utf-8"), VerifyHeaderKV(headerMutator.Key, headerMutator.Value), VerifyBody(test.MarshalRequestBody(requestBody)), @@ -907,7 +917,6 @@ var _ = Describe("Client", func() { server.AppendHandlers( CombineHandlers( VerifyRequest(method, path, fmt.Sprintf("%s=%s", parameterMutator.Key, parameterMutator.Value)), - VerifyHeaderKV("User-Agent", userAgent), VerifyHeaderKV("Content-Type", "application/json; charset=utf-8"), VerifyHeaderKV(headerMutator.Key, headerMutator.Value), VerifyBody(test.MarshalRequestBody(requestBody)), @@ -928,7 +937,6 @@ var _ = Describe("Client", func() { server.AppendHandlers( CombineHandlers( VerifyRequest(method, path, fmt.Sprintf("%s=%s", parameterMutator.Key, parameterMutator.Value)), - VerifyHeaderKV("User-Agent", userAgent), VerifyHeaderKV("Content-Type", "application/json; charset=utf-8"), VerifyHeaderKV(headerMutator.Key, headerMutator.Value), VerifyBody(test.MarshalRequestBody(requestBody)), @@ -946,13 +954,11 @@ var _ = Describe("Client", func() { Context("with an unexpected response 500 with deserializable error body", func() { var responseErr error - BeforeEach(func() { responseErr = errorsTest.RandomError() server.AppendHandlers( CombineHandlers( VerifyRequest(method, path, fmt.Sprintf("%s=%s", parameterMutator.Key, parameterMutator.Value)), - VerifyHeaderKV("User-Agent", userAgent), VerifyHeaderKV("Content-Type", "application/json; charset=utf-8"), VerifyHeaderKV(headerMutator.Key, headerMutator.Value), VerifyBody(test.MarshalRequestBody(requestBody)), @@ -973,7 +979,6 @@ var _ = Describe("Client", func() { server.AppendHandlers( CombineHandlers( VerifyRequest(method, path, fmt.Sprintf("%s=%s", parameterMutator.Key, parameterMutator.Value)), - VerifyHeaderKV("User-Agent", userAgent), VerifyHeaderKV("Content-Type", "application/json; charset=utf-8"), VerifyHeaderKV(headerMutator.Key, headerMutator.Value), VerifyBody(test.MarshalRequestBody(requestBody)), @@ -994,7 +999,6 @@ var _ = Describe("Client", func() { server.AppendHandlers( CombineHandlers( VerifyRequest(method, path, fmt.Sprintf("%s=%s", parameterMutator.Key, parameterMutator.Value)), - VerifyHeaderKV("User-Agent", userAgent), VerifyHeaderKV("Content-Type", "application/json; charset=utf-8"), VerifyHeaderKV(headerMutator.Key, headerMutator.Value), VerifyBody(test.MarshalRequestBody(requestBody)), @@ -1016,7 +1020,6 @@ var _ = Describe("Client", func() { server.AppendHandlers( CombineHandlers( VerifyRequest(method, path, fmt.Sprintf("%s=%s", parameterMutator.Key, parameterMutator.Value)), - VerifyHeaderKV("User-Agent", userAgent), VerifyHeaderKV("Content-Type", "application/json; charset=utf-8"), VerifyHeaderKV(headerMutator.Key, headerMutator.Value), VerifyBody(test.MarshalRequestBody(requestBody)), @@ -1038,7 +1041,6 @@ var _ = Describe("Client", func() { server.AppendHandlers( CombineHandlers( VerifyRequest(method, path, fmt.Sprintf("%s=%s", parameterMutator.Key, parameterMutator.Value)), - VerifyHeaderKV("User-Agent", userAgent), VerifyHeaderKV(headerMutator.Key, headerMutator.Value), VerifyBody(nil), RespondWith(http.StatusOK, test.MarshalResponseBody(&ResponseBody{Response: responseString}), responseHeaders), @@ -1059,7 +1061,6 @@ var _ = Describe("Client", func() { server.AppendHandlers( CombineHandlers( VerifyRequest(method, path, fmt.Sprintf("%s=%s", parameterMutator.Key, parameterMutator.Value)), - VerifyHeaderKV("User-Agent", userAgent), VerifyHeaderKV(headerMutator.Key, headerMutator.Value), VerifyBody([]byte(requestString)), RespondWith(http.StatusOK, test.MarshalResponseBody(&ResponseBody{Response: responseString}), responseHeaders), @@ -1080,7 +1081,6 @@ var _ = Describe("Client", func() { server.AppendHandlers( CombineHandlers( VerifyRequest(method, path, fmt.Sprintf("%s=%s", parameterMutator.Key, parameterMutator.Value)), - VerifyHeaderKV("User-Agent", userAgent), VerifyHeaderKV("Content-Type", "application/json; charset=utf-8"), VerifyHeaderKV(headerMutator.Key, headerMutator.Value), VerifyBody(test.MarshalRequestBody(requestBody)), @@ -1102,7 +1102,6 @@ var _ = Describe("Client", func() { server.AppendHandlers( CombineHandlers( VerifyRequest(method, path, fmt.Sprintf("%s=%s", parameterMutator.Key, parameterMutator.Value)), - VerifyHeaderKV("User-Agent", userAgent), VerifyHeaderKV("Content-Type", "application/json; charset=utf-8"), VerifyHeaderKV(headerMutator.Key, headerMutator.Value), VerifyBody(test.MarshalRequestBody(requestBody)), diff --git a/client/config.go b/client/config.go index f5e237dc7c..b74720633f 100644 --- a/client/config.go +++ b/client/config.go @@ -10,7 +10,16 @@ import ( ) type Config struct { - Address string // this should be overridden for loaders using envconfig + Address string // this should be overridden for loaders using envconfig + // UserAgent is an optional way for a client to identify itself. + // + // This is usually set to the name of the service that's using the + // client. If left empty, the default Go http.Client value should be used. + // + // This value can be helpful when debugging. But remember that these + // values can be spoofed, so when in doubt, verify the client's source IP. + // + // More info: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent UserAgent string `envconfig:"TIDEPOOL_USER_AGENT"` } @@ -28,9 +37,6 @@ func (c *Config) Validate() error { } else if _, err := url.Parse(c.Address); err != nil { return errors.New("address is invalid") } - if c.UserAgent == "" { - return errors.New("user agent is missing") - } return nil } diff --git a/client/config_test.go b/client/config_test.go index fa0e4c3ff7..1a84ff6064 100644 --- a/client/config_test.go +++ b/client/config_test.go @@ -89,11 +89,6 @@ var _ = Describe("Config", func() { Expect(cfg.Validate()).To(MatchError("address is invalid")) }) - It("returns an error if the user agent is missing", func() { - cfg.UserAgent = "" - Expect(cfg.Validate()).To(MatchError("user agent is missing")) - }) - It("returns success", func() { Expect(cfg.Validate()).To(Succeed()) Expect(cfg.Address).To(Equal(address)) diff --git a/data/client/client_test.go b/data/client/client_test.go index 77357a8b37..1cd9d2e0db 100644 --- a/data/client/client_test.go +++ b/data/client/client_test.go @@ -43,13 +43,6 @@ var _ = Describe("Client", func() { Expect(clnt).To(BeNil()) }) - It("returns an error if config user agent is missing", func() { - config.UserAgent = "" - clnt, err := dataClient.New(config, platform.AuthorizeAsService) - Expect(err).To(MatchError("config is invalid; user agent is missing")) - Expect(clnt).To(BeNil()) - }) - It("returns success", func() { clnt, err := dataClient.New(config, platform.AuthorizeAsService) Expect(err).ToNot(HaveOccurred()) diff --git a/metric/client/client_test.go b/metric/client/client_test.go index fa744d6e7f..761b514dd3 100644 --- a/metric/client/client_test.go +++ b/metric/client/client_test.go @@ -66,13 +66,6 @@ var _ = Describe("Client", func() { Expect(clnt).To(BeNil()) }) - It("returns an error if config user agent is missing", func() { - config.UserAgent = "" - clnt, err := metricClient.New(config, platform.AuthorizeAsUser, name, versionReporter) - Expect(err).To(MatchError("config is invalid; user agent is missing")) - Expect(clnt).To(BeNil()) - }) - It("returns success", func() { clnt, err := metricClient.New(config, platform.AuthorizeAsUser, name, versionReporter) Expect(err).ToNot(HaveOccurred()) diff --git a/platform/config_test.go b/platform/config_test.go index 49b625f149..00b006e239 100644 --- a/platform/config_test.go +++ b/platform/config_test.go @@ -113,11 +113,6 @@ var _ = Describe("Config", func() { Expect(cfg.Validate()).To(MatchError("address is invalid")) }) - It("returns an error if the user agent is missing", func() { - cfg.UserAgent = "" - Expect(cfg.Validate()).To(MatchError("user agent is missing")) - }) - It("returns success", func() { Expect(cfg.Validate()).To(Succeed()) Expect(cfg.Config).ToNot(BeNil())