Skip to content

Commit

Permalink
feat!: Add login query param support to ListCredentialAuthorizations (#…
Browse files Browse the repository at this point in the history
…3270)

BREAKING CHANGE: `ListCredentialAuthorizations` now takes `opts *CredentialAuthorizationsListOptions` instead of `ListOptions`.
  • Loading branch information
zeusdeux authored Sep 19, 2024
1 parent 057ff1b commit ef170a3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
12 changes: 11 additions & 1 deletion github/orgs_credential_authorizations.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,23 @@ type CredentialAuthorization struct {
AuthorizedCredentialExpiresAt *Timestamp `json:"authorized_credential_expires_at,omitempty"`
}

// CredentialAuthorizationsListOptions adds the Login option as supported by the
// list SAML SSO authorizations for organizations endpoint alongside paging options
// such as Page and PerPage.
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/orgs/orgs#list-saml-sso-authorizations-for-an-organization
type CredentialAuthorizationsListOptions struct {
ListOptions
// For credentials authorizations for an organization, limit the list of authorizations to a specific login (aka github username)
Login string `url:"login,omitempty"`
}

// ListCredentialAuthorizations lists credentials authorized through SAML SSO
// for a given organization. Only available with GitHub Enterprise Cloud.
//
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/orgs/orgs#list-saml-sso-authorizations-for-an-organization
//
//meta:operation GET /orgs/{org}/credential-authorizations
func (s *OrganizationsService) ListCredentialAuthorizations(ctx context.Context, org string, opts *ListOptions) ([]*CredentialAuthorization, *Response, error) {
func (s *OrganizationsService) ListCredentialAuthorizations(ctx context.Context, org string, opts *CredentialAuthorizationsListOptions) ([]*CredentialAuthorization, *Response, error) {
u := fmt.Sprintf("orgs/%v/credential-authorizations", org)
u, err := addOptions(u, opts)
if err != nil {
Expand Down
8 changes: 6 additions & 2 deletions github/orgs_credential_authorizations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestOrganizationsService_ListCredentialAuthorizations(t *testing.T) {

mux.HandleFunc("/orgs/o/credential-authorizations", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, http.MethodGet)
testFormValues(t, r, values{"per_page": "2", "page": "2"})
testFormValues(t, r, values{"per_page": "2", "page": "2", "login": "l"})
fmt.Fprint(w, `[
{
"login": "l",
Expand All @@ -34,7 +34,11 @@ func TestOrganizationsService_ListCredentialAuthorizations(t *testing.T) {
]`)
})

opts := &ListOptions{Page: 2, PerPage: 2}
opts := &CredentialAuthorizationsListOptions{
ListOptions: ListOptions{Page: 2, PerPage: 2},
Login: "l",
}

ctx := context.Background()
creds, _, err := client.Organizations.ListCredentialAuthorizations(ctx, "o", opts)
if err != nil {
Expand Down

0 comments on commit ef170a3

Please sign in to comment.