Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: adding api and web to meta api endpoint. #2435

Merged
merged 3 commits into from
Aug 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions github/misc.go
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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