From cf6cb3d5911666def959d404efb5368b646c9717 Mon Sep 17 00:00:00 2001 From: Jamie West Date: Wed, 17 Aug 2022 14:49:27 +0100 Subject: [PATCH 1/3] feature: adding api and web to meta api endpoint. --- github/misc.go | 8 ++++++++ github/misc_test.go | 10 ++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/github/misc.go b/github/misc.go index 412d1e2b95d..8a274c90f0e 100644 --- a/github/misc.go +++ b/github/misc.go @@ -176,6 +176,14 @@ type APIMeta struct { // An array of SSH keys. SSHKeys []string `json:"ssh_keys,omitempty"` + + // An array of IP addresses in CIDR format specifying the addresses + // which serve GitHub websites. + Web []string `json:"web,omitempty"` + + // An array of IP addresses in CIDR format specifying the addresses + // which serve GitHub apis. + Api []string `json:"api,omitempty"` } // APIMeta returns information about GitHub.com, the service. Or, if you access diff --git a/github/misc_test.go b/github/misc_test.go index fc91d712948..adc7e765eba 100644 --- a/github/misc_test.go +++ b/github/misc_test.go @@ -190,6 +190,8 @@ func TestAPIMeta_Marshal(t *testing.T) { Dependabot: []string{"d"}, SSHKeyFingerprints: map[string]string{"a": "f"}, SSHKeys: []string{"k"}, + Api: []string{"a"}, + Web: []string{"w"}, } want := `{ "hooks":["h"], @@ -200,7 +202,9 @@ func TestAPIMeta_Marshal(t *testing.T) { "actions":["a"], "dependabot":["d"], "ssh_key_fingerprints":{"a":"f"}, - "ssh_keys":["k"] + "ssh_keys":["k"], + "api":["a"], + "web":["w"] }` testJSONMarshal(t, a, want) @@ -212,7 +216,7 @@ func TestAPIMeta(t *testing.T) { mux.HandleFunc("/meta", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprint(w, `{"hooks":["h"], "git":["g"], "pages":["p"], "importer":["i"], "actions":["a"], "dependabot":["d"], "verifiable_password_authentication": true}`) + fmt.Fprint(w, `{"web":["w"],"api":["a"],"hooks":["h"], "git":["g"], "pages":["p"], "importer":["i"], "actions":["a"], "dependabot":["d"], "verifiable_password_authentication": true}`) }) ctx := context.Background() @@ -228,6 +232,8 @@ func TestAPIMeta(t *testing.T) { Importer: []string{"i"}, Actions: []string{"a"}, Dependabot: []string{"d"}, + Api: []string{"a"}, + Web: []string{"w"}, VerifiablePasswordAuthentication: Bool(true), } From 88e840d30c5c5ea8642d9be76d97bedfc6f96943 Mon Sep 17 00:00:00 2001 From: Jamie West Date: Wed, 17 Aug 2022 15:53:49 +0100 Subject: [PATCH 2/3] fix: minor refactor of api to API for consistency. --- github/misc.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/github/misc.go b/github/misc.go index 8a274c90f0e..89615241570 100644 --- a/github/misc.go +++ b/github/misc.go @@ -182,8 +182,8 @@ type APIMeta struct { Web []string `json:"web,omitempty"` // An array of IP addresses in CIDR format specifying the addresses - // which serve GitHub apis. - Api []string `json:"api,omitempty"` + // which serve GitHub APIs. + API []string `json:"api,omitempty"` } // APIMeta returns information about GitHub.com, the service. Or, if you access From 05d67f40752a24c2bcc558ed4134f25c6f74409d Mon Sep 17 00:00:00 2001 From: Jamie West Date: Thu, 18 Aug 2022 09:18:54 +0100 Subject: [PATCH 3/3] fix: refactoring Api -> API naming in tests as well. Woops! --- github/misc_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/github/misc_test.go b/github/misc_test.go index adc7e765eba..4e88ec54529 100644 --- a/github/misc_test.go +++ b/github/misc_test.go @@ -190,7 +190,7 @@ func TestAPIMeta_Marshal(t *testing.T) { Dependabot: []string{"d"}, SSHKeyFingerprints: map[string]string{"a": "f"}, SSHKeys: []string{"k"}, - Api: []string{"a"}, + API: []string{"a"}, Web: []string{"w"}, } want := `{ @@ -232,7 +232,7 @@ func TestAPIMeta(t *testing.T) { Importer: []string{"i"}, Actions: []string{"a"}, Dependabot: []string{"d"}, - Api: []string{"a"}, + API: []string{"a"}, Web: []string{"w"}, VerifiablePasswordAuthentication: Bool(true),