-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat: Add private repo workflows permission API support #3679
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
Changes from 7 commits
155da37
8ec23fb
7e85478
053462c
a864e95
af079dc
9e8e913
0c11edd
c4d4fea
160ae72
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -523,3 +523,84 @@ func TestActionsService_EditSelfHostedRunnerPermissionsInEnterprise(t *testing.T | |||||
return client.Actions.EditSelfHostedRunnerPermissionsInEnterprise(ctx, "e", *input) | ||||||
}) | ||||||
} | ||||||
|
||||||
func TestActionsService_GetPrivateRepoForkPRWorkflowSettingsInEnterprise(t *testing.T) { | ||||||
t.Parallel() | ||||||
client, mux, _ := setup(t) | ||||||
|
||||||
mux.HandleFunc("/enterprises/e/actions/permissions/fork-pr-workflows-private-repos", func(w http.ResponseWriter, r *http.Request) { | ||||||
testMethod(t, r, "GET") | ||||||
fmt.Fprint(w, `{"run_workflows_from_fork_pull_requests": true, "send_write_tokens_to_workflows": false, "send_secrets_and_variables": true, "require_approval_for_fork_pr_workflows": false}`) | ||||||
}) | ||||||
|
||||||
ctx := context.Background() | ||||||
permissions, _, err := client.Actions.GetPrivateRepoForkPRWorkflowSettingsInEnterprise(ctx, "e") | ||||||
if err != nil { | ||||||
t.Errorf("Actions.GetPrivateRepoForkPRWorkflowSettingsInEnterprise returned error: %v", err) | ||||||
} | ||||||
want := &WorkflowsPermissions{ | ||||||
RunWorkflowsFromForkPullRequests: Ptr(true), | ||||||
SendWriteTokensToWorkflows: Ptr(false), | ||||||
SendSecretsAndVariables: Ptr(true), | ||||||
RequireApprovalForForkPRWorkflows: Ptr(false), | ||||||
} | ||||||
if !cmp.Equal(permissions, want) { | ||||||
t.Errorf("Actions.GetPrivateRepoForkPRWorkflowSettingsInEnterprise returned %+v, want %+v", permissions, want) | ||||||
} | ||||||
|
||||||
const methodName = "GetPrivateRepoForkPRWorkflowSettingsInEnterprise" | ||||||
testBadOptions(t, methodName, func() (err error) { | ||||||
_, _, err = client.Actions.GetPrivateRepoForkPRWorkflowSettingsInEnterprise(ctx, "\n") | ||||||
return err | ||||||
}) | ||||||
|
||||||
testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { | ||||||
got, resp, err := client.Actions.GetPrivateRepoForkPRWorkflowSettingsInEnterprise(ctx, "e") | ||||||
if got != nil { | ||||||
t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) | ||||||
} | ||||||
return resp, err | ||||||
}) | ||||||
} | ||||||
|
||||||
func TestActionsService_EditPrivateRepoForkPRWorkflowSettingsInEnterprise(t *testing.T) { | ||||||
|
func TestActionsService_EditPrivateRepoForkPRWorkflowSettingsInEnterprise(t *testing.T) { | |
func TestActionsService_UpdatePrivateRepoForkPRWorkflowSettingsInEnterprise(t *testing.T) { |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -693,3 +693,84 @@ func TestActionsService_RemoveRepositorySelfHostedRunnersAllowedInOrganization(t | |||||
return client.Actions.RemoveRepositorySelfHostedRunnersAllowedInOrganization(ctx, "o", 123) | ||||||
}) | ||||||
} | ||||||
|
||||||
func TestActionsService_GetPrivateRepoForkPRWorkflowSettingsInOrganization(t *testing.T) { | ||||||
t.Parallel() | ||||||
client, mux, _ := setup(t) | ||||||
|
||||||
mux.HandleFunc("/orgs/o/actions/permissions/fork-pr-workflows-private-repos", func(w http.ResponseWriter, r *http.Request) { | ||||||
testMethod(t, r, "GET") | ||||||
fmt.Fprint(w, `{"run_workflows_from_fork_pull_requests": true, "send_write_tokens_to_workflows": false, "send_secrets_and_variables": true, "require_approval_for_fork_pr_workflows": false}`) | ||||||
}) | ||||||
|
||||||
ctx := context.Background() | ||||||
permissions, _, err := client.Actions.GetPrivateRepoForkPRWorkflowSettingsInOrganization(ctx, "o") | ||||||
if err != nil { | ||||||
t.Errorf("Actions.GetPrivateRepoForkPRWorkflowSettingsInOrganization returned error: %v", err) | ||||||
} | ||||||
want := &WorkflowsPermissions{ | ||||||
RunWorkflowsFromForkPullRequests: Ptr(true), | ||||||
SendWriteTokensToWorkflows: Ptr(false), | ||||||
SendSecretsAndVariables: Ptr(true), | ||||||
RequireApprovalForForkPRWorkflows: Ptr(false), | ||||||
} | ||||||
if !cmp.Equal(permissions, want) { | ||||||
t.Errorf("Actions.GetPrivateRepoForkPRWorkflowSettingsInOrganization returned %+v, want %+v", permissions, want) | ||||||
} | ||||||
|
||||||
const methodName = "GetPrivateRepoForkPRWorkflowSettingsInOrganization" | ||||||
testBadOptions(t, methodName, func() (err error) { | ||||||
_, _, err = client.Actions.GetPrivateRepoForkPRWorkflowSettingsInOrganization(ctx, "\n") | ||||||
return err | ||||||
}) | ||||||
|
||||||
testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { | ||||||
got, resp, err := client.Actions.GetPrivateRepoForkPRWorkflowSettingsInOrganization(ctx, "o") | ||||||
if got != nil { | ||||||
t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) | ||||||
} | ||||||
return resp, err | ||||||
}) | ||||||
} | ||||||
|
||||||
func TestActionsService_EditPrivateRepoForkPRWorkflowSettingsInOrganization(t *testing.T) { | ||||||
|
func TestActionsService_EditPrivateRepoForkPRWorkflowSettingsInOrganization(t *testing.T) { | |
func TestActionsService_UpdatePrivateRepoForkPRWorkflowSettingsInOrganization(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I fix it. Thank you!
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think update makes more sense than edit both here and in the wider context of the package API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you are right, @stevehipwell, thank you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's OK, I'll rename it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or may I open another pr to do that? For the permissons APIs above, methods have been named
GetXXX
andEditXXX
where both GET and PUT methods are used for the same path. I think we better rename it all at once to keep consistency.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine either way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I renamed the methods implemented in this pr for now.