vinyldns / go-vinyldns

Go client package for VinylDNS
Apache License 2.0
7 stars 25 forks source link

ensure User-Agent header is actually set #68

Closed mdb closed 4 years ago

mdb commented 4 years ago

This seeks to address issue #67.

However, it appears to me that, when tested against a local VinylDNS API, VinylDNS still does not log the go-vinyldns-set User-Agent header, despite that...

  1. The local VinylDNS API will log a custom User-Agent header set by other clients, such as vinyldns-js
  2. When I use a modified version of go-vinyldns that issues a Zones() request to http://httpbin.org/user-agent rather than the VinylDNS API (using a technique similar to that outlined here, I do see the expected { "user-agent": "go-vinyldns/0.9.10" } response body, thus suggesting the User-Agent header is being sent correctly.

Am I confused or is it possible that VinylDNS dislikes some aspect of the go-vinyldns request and/or its User-Agent header?

nmische commented 4 years ago

I'd suggest adding the following test to util_test.go:

func TestResourceRequest(t *testing.T) {

    ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
        if r.UserAgent() != defaultUA() {
            t.Error("default user agent not set")
        }
    }))
    defer ts.Close()

    c := NewClient(ClientConfiguration{Host: ts.URL})

    resourceRequest(c, ts.URL, http.MethodGet, nil, nil)

}
nmische commented 4 years ago

69 adds the above test.

mdb commented 4 years ago

Thanks @nmische ! Also, @pauljamescleary was able to confirm that go-vinyldns is behaving as expected and the VinylDNS API behavior outlined above is a bug fixed via VinylDNS PR 894.