Skip to content

Commit

Permalink
Add API and Web to meta api endpoint (#2435)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamian committed Aug 18, 2022
1 parent acca0b6 commit 903be14
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
8 changes: 8 additions & 0 deletions github/misc.go
Expand Up @@ -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
Expand Down
10 changes: 8 additions & 2 deletions github/misc_test.go
Expand Up @@ -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"],
Expand All @@ -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)
Expand All @@ -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()
Expand All @@ -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),
}
Expand Down

0 comments on commit 903be14

Please sign in to comment.