Skip to content

Commit

Permalink
Add missing installation permissions (#1880)
Browse files Browse the repository at this point in the history
Fixes: #1879.
  • Loading branch information
xun-guo-anzx authored Jun 1, 2021
1 parent 8b2866e commit 8751f3d
Show file tree
Hide file tree
Showing 4 changed files with 203 additions and 56 deletions.
67 changes: 37 additions & 30 deletions github/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,37 +55,44 @@ type InstallationTokenOptions struct {
// InstallationPermissions lists the repository and organization permissions for an installation.
//
// Permission names taken from:
// https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/permissions/
// https://developer.github.com/enterprise/v3/apps/permissions/
// https://docs.github.com/en/[email protected]/rest/reference/apps#create-an-installation-access-token-for-an-app
// https://docs.github.com/en/rest/reference/apps#create-an-installation-access-token-for-an-app
type InstallationPermissions struct {
Actions *string `json:"actions,omitempty"`
Administration *string `json:"administration,omitempty"`
Blocking *string `json:"blocking,omitempty"`
Checks *string `json:"checks,omitempty"`
Contents *string `json:"contents,omitempty"`
ContentReferences *string `json:"content_references,omitempty"`
Deployments *string `json:"deployments,omitempty"`
Emails *string `json:"emails,omitempty"`
Followers *string `json:"followers,omitempty"`
Issues *string `json:"issues,omitempty"`
Metadata *string `json:"metadata,omitempty"`
Members *string `json:"members,omitempty"`
OrganizationAdministration *string `json:"organization_administration,omitempty"`
OrganizationHooks *string `json:"organization_hooks,omitempty"`
OrganizationPlan *string `json:"organization_plan,omitempty"`
OrganizationPreReceiveHooks *string `json:"organization_pre_receive_hooks,omitempty"`
OrganizationProjects *string `json:"organization_projects,omitempty"`
OrganizationUserBlocking *string `json:"organization_user_blocking,omitempty"`
Packages *string `json:"packages,omitempty"`
Pages *string `json:"pages,omitempty"`
PullRequests *string `json:"pull_requests,omitempty"`
RepositoryHooks *string `json:"repository_hooks,omitempty"`
RepositoryProjects *string `json:"repository_projects,omitempty"`
RepositoryPreReceiveHooks *string `json:"repository_pre_receive_hooks,omitempty"`
SingleFile *string `json:"single_file,omitempty"`
Statuses *string `json:"statuses,omitempty"`
TeamDiscussions *string `json:"team_discussions,omitempty"`
VulnerabilityAlerts *string `json:"vulnerability_alerts,omitempty"`
Actions *string `json:"actions,omitempty"`
Administration *string `json:"administration,omitempty"`
Blocking *string `json:"blocking,omitempty"`
Checks *string `json:"checks,omitempty"`
Contents *string `json:"contents,omitempty"`
ContentReferences *string `json:"content_references,omitempty"`
Deployments *string `json:"deployments,omitempty"`
Emails *string `json:"emails,omitempty"`
Environments *string `json:"environments,omitempty"`
Followers *string `json:"followers,omitempty"`
Issues *string `json:"issues,omitempty"`
Metadata *string `json:"metadata,omitempty"`
Members *string `json:"members,omitempty"`
OrganizationAdministration *string `json:"organization_administration,omitempty"`
OrganizationHooks *string `json:"organization_hooks,omitempty"`
OrganizationPlan *string `json:"organization_plan,omitempty"`
OrganizationPreReceiveHooks *string `json:"organization_pre_receive_hooks,omitempty"`
OrganizationProjects *string `json:"organization_projects,omitempty"`
OrganizationSecrets *string `json:"organization_secrets,omitempty"`
OrganizationSelfHostedRunners *string `json:"organization_self_hosted_runners,omitempty"`
OrganizationUserBlocking *string `json:"organization_user_blocking,omitempty"`
Packages *string `json:"packages,omitempty"`
Pages *string `json:"pages,omitempty"`
PullRequests *string `json:"pull_requests,omitempty"`
RepositoryHooks *string `json:"repository_hooks,omitempty"`
RepositoryProjects *string `json:"repository_projects,omitempty"`
RepositoryPreReceiveHooks *string `json:"repository_pre_receive_hooks,omitempty"`
Secrets *string `json:"secrets,omitempty"`
SecretScanningAlerts *string `json:"secret_scanning_alerts,omitempty"`
SecurityEvents *string `json:"security_events,omitempty"`
SingleFile *string `json:"single_file,omitempty"`
Statuses *string `json:"statuses,omitempty"`
TeamDiscussions *string `json:"team_discussions,omitempty"`
VulnerabilityAlerts *string `json:"vulnerability_alerts,omitempty"`
Workflows *string `json:"workflows,omitempty"`
}

// Installation represents a GitHub Apps installation.
Expand Down
66 changes: 40 additions & 26 deletions github/apps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ func TestAppsService_ListInstallations(t *testing.T) {
"contents": "read",
"content_references": "read",
"deployments": "read",
"environments": "read",
"issues": "write",
"metadata": "read",
"members": "read",
Expand All @@ -102,17 +103,23 @@ func TestAppsService_ListInstallations(t *testing.T) {
"organization_plan": "read",
"organization_pre_receive_hooks": "write",
"organization_projects": "read",
"organization_secrets": "read",
"organization_self_hosted_runners": "read",
"organization_user_blocking": "write",
"packages": "read",
"pages": "read",
"pull_requests": "write",
"repository_hooks": "write",
"repository_projects": "read",
"repository_pre_receive_hooks": "read",
"secrets": "read",
"secret_scanning_alerts": "read",
"security_events": "read",
"single_file": "write",
"statuses": "write",
"team_discussions": "read",
"vulnerability_alerts": "read"
"vulnerability_alerts": "read",
"workflows": "write"
},
"events": [
"push",
Expand Down Expand Up @@ -141,31 +148,38 @@ func TestAppsService_ListInstallations(t *testing.T) {
SingleFileName: String("config.yml"),
RepositorySelection: String("selected"),
Permissions: &InstallationPermissions{
Actions: String("read"),
Administration: String("read"),
Checks: String("read"),
Contents: String("read"),
ContentReferences: String("read"),
Deployments: String("read"),
Issues: String("write"),
Metadata: String("read"),
Members: String("read"),
OrganizationAdministration: String("write"),
OrganizationHooks: String("write"),
OrganizationPlan: String("read"),
OrganizationPreReceiveHooks: String("write"),
OrganizationProjects: String("read"),
OrganizationUserBlocking: String("write"),
Packages: String("read"),
Pages: String("read"),
PullRequests: String("write"),
RepositoryHooks: String("write"),
RepositoryProjects: String("read"),
RepositoryPreReceiveHooks: String("read"),
SingleFile: String("write"),
Statuses: String("write"),
TeamDiscussions: String("read"),
VulnerabilityAlerts: String("read")},
Actions: String("read"),
Administration: String("read"),
Checks: String("read"),
Contents: String("read"),
ContentReferences: String("read"),
Deployments: String("read"),
Environments: String("read"),
Issues: String("write"),
Metadata: String("read"),
Members: String("read"),
OrganizationAdministration: String("write"),
OrganizationHooks: String("write"),
OrganizationPlan: String("read"),
OrganizationPreReceiveHooks: String("write"),
OrganizationProjects: String("read"),
OrganizationSecrets: String("read"),
OrganizationSelfHostedRunners: String("read"),
OrganizationUserBlocking: String("write"),
Packages: String("read"),
Pages: String("read"),
PullRequests: String("write"),
RepositoryHooks: String("write"),
RepositoryProjects: String("read"),
RepositoryPreReceiveHooks: String("read"),
Secrets: String("read"),
SecretScanningAlerts: String("read"),
SecurityEvents: String("read"),
SingleFile: String("write"),
Statuses: String("write"),
TeamDiscussions: String("read"),
VulnerabilityAlerts: String("read"),
Workflows: String("write")},
Events: []string{"push", "pull_request"},
CreatedAt: &date,
UpdatedAt: &date,
Expand Down
56 changes: 56 additions & 0 deletions github/github-accessors.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

70 changes: 70 additions & 0 deletions github/github-accessors_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8751f3d

Please sign in to comment.