+
Skip to content

Omit OpenID Connect customization template claims when none are set #2620

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

Merged
merged 2 commits into from
Jan 10, 2023
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
2 changes: 1 addition & 1 deletion github/actions_oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
// OIDCSubjectClaimCustomTemplate represents an OIDC subject claim customization template.
type OIDCSubjectClaimCustomTemplate struct {
UseDefault *bool `json:"use_default,omitempty"`
IncludeClaimKeys []string `json:"include_claim_keys"`
IncludeClaimKeys []string `json:"include_claim_keys,omitempty"`
}

// GetOrgOIDCSubjectClaimCustomTemplate gets the subject claim customization template for an organization.
Expand Down
31 changes: 31 additions & 0 deletions github/actions_oidc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,34 @@ func TestActionsService_SetRepoOIDCSubjectClaimCustomTemplate(t *testing.T) {
return client.Actions.SetRepoOIDCSubjectClaimCustomTemplate(ctx, "o", "r", input)
})
}

func TestActionService_SetRepoOIDCSubjectClaimCustomTemplateToDefault(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()

mux.HandleFunc("/repos/o/r/actions/oidc/customization/sub", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "PUT")
testHeader(t, r, "Content-Type", "application/json")
testBody(t, r, `{"use_default":true}`+"\n")
w.WriteHeader(http.StatusCreated)
})

input := &OIDCSubjectClaimCustomTemplate{
UseDefault: Bool(true),
}
ctx := context.Background()
_, err := client.Actions.SetRepoOIDCSubjectClaimCustomTemplate(ctx, "o", "r", input)
if err != nil {
t.Errorf("Actions.SetRepoOIDCSubjectClaimCustomTemplate returned error: %v", err)
}

const methodName = "SetRepoOIDCSubjectClaimCustomTemplate"
testBadOptions(t, methodName, func() (err error) {
_, err = client.Actions.SetRepoOIDCSubjectClaimCustomTemplate(ctx, "\n", "\n", input)
return err
})

testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
return client.Actions.SetRepoOIDCSubjectClaimCustomTemplate(ctx, "o", "r", input)
})
}
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载