Repository: google/go-github
Pull request #2902 (2023-08-26 11:53:07)

Add Repository Security Advisories APIs
Relates to #2866 

Integrates the following 2 APIs:

- [Lists repository security advisories for an organization - /orgs/{org}/security-advisories](https://docs.github.com/en/rest/security-advisories/repository-advisories?apiVersion=2022-11-28#list-repository-security-advisories-for-an-organization)
- [Lists security advisories in a repository - /repos/{owner}/{repo}/security-advisories](https://docs.github.com/en/rest/security-advisories/repository-advisories?apiVersion=2022-11-28#list-repository-security-advisories)

google-cla[bot]: Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this [failed invocation](https://github.com/google/go-github/pull/2902/checks?check_run_id=16235924353) of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.
anishrajan25: @gmlewis The PR is ready for review. Could you please have a look as per your availability?
anishrajan25: @gmlewis I have analysed the existing structs and prepared a document capturing the possibilities of embedding some structs to prevent redefining some fields.

Could you please have a look at [this document](https://docs.google.com/document/d/10ezC0VHeUWk3WBNZJjOlOld97XOLeRQpNA34Xsz0BFM/edit?usp=sharing) and add comments wherever necessary to provide your inputs?

I will fix the comments to end with period, linting, and test errors in the next commit along with updating the struct definitions.
gmlewis: I'll be back on 9/18 when I can take a look at this. Sorry for the delay and inconvenience.
anishrajan25: No worries. You can have a look whenever you are available ✌🏼 
gmlewis: @anishrajan25 - I'm back, but none of the comments I left above:
https://github.com/google/go-github/pull/2902#pullrequestreview-1599004532
have been addressed.  Please fix these issues before we can continue.
anishrajan25: Hi @gmlewis , apologies for the delay in response.

I have created [this document](https://docs.google.com/document/d/10ezC0VHeUWk3WBNZJjOlOld97XOLeRQpNA34Xsz0BFM/edit?usp=sharing), capturing the possibilities of embedding some structs to prevent redefining some fields. 
Could you please have a look and add comments wherever necessary to provide your input?

anishrajan25: I have updated the existing structs and reused them instead of creating new ones wherever possible. I have fixed the comments as well. @gmlewis Could you please have a look?
gmlewis: Please check that test pass locally with `go test ./...` before pushing.
anishrajan25: There are some failing test cases. I will update once the test cases are fixed.
anishrajan25: @gmlewis I have fixed the test cases as well. All the tests are passing on my local
gmlewis: Please run `go generate ./...` as described in CONTRIBUTING.md and push the results to this PR.

codecov[bot]: ## [Codecov](https://app.codecov.io/gh/google/go-github/pull/2902?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) Report
> Merging [#2902](https://app.codecov.io/gh/google/go-github/pull/2902?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) (8f14e49) into [master](https://app.codecov.io/gh/google/go-github/commit/8cd452b85e821c32eefcc5964e91e57f9731891f?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) (8cd452b) will **increase** coverage by `0.00%`.
> The diff coverage is `100.00%`.

```diff
@@           Coverage Diff           @@
##           master    #2902   +/-   ##
=======================================
  Coverage   98.19%   98.19%           
=======================================
  Files         145      145           
  Lines       12720    12752   +32     
=======================================
+ Hits        12490    12522   +32     
  Misses        156      156           
  Partials       74       74           
```


| [Files](https://app.codecov.io/gh/google/go-github/pull/2902?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) | Coverage Δ | |
|---|---|---|
| [github/event\_types.go](https://app.codecov.io/gh/google/go-github/pull/2902?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google#diff-Z2l0aHViL2V2ZW50X3R5cGVzLmdv) | `100.00% <ø> (ø)` | |
| [github/security\_advisories.go](https://app.codecov.io/gh/google/go-github/pull/2902?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google#diff-Z2l0aHViL3NlY3VyaXR5X2Fkdmlzb3JpZXMuZ28=) | `100.00% <100.00%> (ø)` | |



Patch:
diff --git a/github/event_types.go b/github/event_types.go
index 3161384f..e91d2268 100644
--- a/github/event_types.go
+++ b/github/event_types.go
@@ -76,6 +76,10 @@ type CommitCommentEvent struct {
 	Repo         *Repository   `json:"repository,omitempty"`
 	Sender       *User         `json:"sender,omitempty"`
 	Installation *Installation `json:"installation,omitempty"`
+
+	// The following field is only present when the webhook is triggered on
+	// a repository belonging to an organization.
+	Org *Organization `json:"organization,omitempty"`
 }
 
 // ContentReferenceEvent is triggered when the body or comment of an issue or
@@ -132,6 +136,10 @@ type DeleteEvent struct {
 	Repo         *Repository   `json:"repository,omitempty"`
 	Sender       *User         `json:"sender,omitempty"`
 	Installation *Installation `json:"installation,omitempty"`
+
+	// The following field is only present when the webhook is triggered on
+	// a repository belonging to an organization.
+	Org *Organization `json:"organization,omitempty"`
 }
 
 // DependabotAlertEvent is triggered when there is activity relating to Dependabot alerts.
@@ -192,6 +200,10 @@ type DeploymentEvent struct {
 	// The following fields are only populated by Webhook events.
 	Sender       *User         `json:"sender,omitempty"`
 	Installation *Installation `json:"installation,omitempty"`
+
+	// The following field is only present when the webhook is triggered on
+	// a repository belonging to an organization.
+	Org *Organization `json:"organization,omitempty"`
 }
 
 // DeploymentProtectionRuleEvent represents a deployment protection rule event.
@@ -227,6 +239,10 @@ type DeploymentStatusEvent struct {
 	// The following fields are only populated by Webhook events.
 	Sender       *User         `json:"sender,omitempty"`
 	Installation *Installation `json:"installation,omitempty"`
+
+	// The following field is only present when the webhook is triggered on
+	// a repository belonging to an organization.
+	Org *Organization `json:"organization,omitempty"`
 }
 
 // DiscussionCommentEvent represents a webhook event for a comment on discussion.
@@ -363,6 +379,10 @@ type GollumEvent struct {
 	Repo         *Repository   `json:"repository,omitempty"`
 	Sender       *User         `json:"sender,omitempty"`
 	Installation *Installation `json:"installation,omitempty"`
+
+	// The following field is only present when the webhook is triggered on
+	// a repository belonging to an organization.
+	Org *Organization `json:"organization,omitempty"`
 }
 
 // EditChange represents the changes when an issue, pull request, comment,
@@ -510,6 +530,10 @@ type InstallationEvent struct {
 	Sender       *User         `json:"sender,omitempty"`
 	Installation *Installation `json:"installation,omitempty"`
 	Requester    *User         `json:"requester,omitempty"`
+
+	// The following field is only present when the webhook is triggered on
+	// a repository belonging to an organization.
+	Org *Organization `json:"organization,omitempty"`
 }
 
 // InstallationRepositoriesEvent is triggered when a repository is added or
@@ -524,6 +548,10 @@ type InstallationRepositoriesEvent struct {
 	RepositorySelection *string       `json:"repository_selection,omitempty"`
 	Sender              *User         `json:"sender,omitempty"`
 	Installation        *Installation `json:"installation,omitempty"`
+
+	// The following field is only present when the webhook is triggered on
+	// a repository belonging to an organization.
+	Org *Organization `json:"organization,omitempty"`
 }
 
 // InstallationLoginChange represents a change in login on an installation.
@@ -603,6 +631,10 @@ type IssuesEvent struct {
 	Sender       *User         `json:"sender,omitempty"`
 	Installation *Installation `json:"installation,omitempty"`
 	Milestone    *Milestone    `json:"milestone,omitempty"`
+
+	// The following field is only present when the webhook is triggered on
+	// a repository belonging to an organization.
+	Org *Organization `json:"organization,omitempty"`
 }
 
 // LabelEvent is triggered when a repository's label is created, edited, or deleted.
@@ -639,6 +671,10 @@ type MarketplacePurchaseEvent struct {
 	PreviousMarketplacePurchase *MarketplacePurchase `json:"previous_marketplace_purchase,omitempty"`
 	Sender                      *User                `json:"sender,omitempty"`
 	Installation                *Installation        `json:"installation,omitempty"`
+
+	// The following field is only present when the webhook is triggered on
+	// a repository belonging to an organization.
+	Org *Organization `json:"organization,omitempty"`
 }
 
 // MemberEvent is triggered when a user is added as a collaborator to a repository.
@@ -654,6 +690,10 @@ type MemberEvent struct {
 	Repo         *Repository   `json:"repository,omitempty"`
 	Sender       *User         `json:"sender,omitempty"`
 	Installation *Installation `json:"installation,omitempty"`
+
+	// The following field is only present when the webhook is triggered on
+	// a repository belonging to an organization.
+	Org *Organization `json:"organization,omitempty"`
 }
 
 // MembershipEvent is triggered when a user is added or removed from a team.
@@ -825,6 +865,10 @@ type PageBuildEvent struct {
 	Repo         *Repository   `json:"repository,omitempty"`
 	Sender       *User         `json:"sender,omitempty"`
 	Installation *Installation `json:"installation,omitempty"`
+
+	// The following field is only present when the webhook is triggered on
+	// a repository belonging to an organization.
+	Org *Organization `json:"organization,omitempty"`
 }
 
 // PersonalAccessTokenRequestEvent occurs when there is activity relating to a
@@ -885,6 +929,10 @@ type PersonalAccessTokenRequest struct {
 
 	// Date and time when the associated fine-grained personal access token was last used for authentication.
 	TokenLastUsedAt *Timestamp `json:"token_last_used_at,omitempty"`
+
+	// The following field is only present when the webhook is triggered on
+	// a repository belonging to an organization.
+	Org *Organization `json:"organization,omitempty"`
 }
 
 // PersonalAccessTokenPermissions represents the original or newly requested
@@ -1044,6 +1092,10 @@ type PublicEvent struct {
 	Repo         *Repository   `json:"repository,omitempty"`
 	Sender       *User         `json:"sender,omitempty"`
 	Installation *Installation `json:"installation,omitempty"`
+
+	// The following field is only present when the webhook is triggered on
+	// a repository belonging to an organization.
+	Org *Organization `json:"organization,omitempty"`
 }
 
 // PullRequestEvent is triggered when a pull request is assigned, unassigned, labeled,
@@ -1129,6 +1181,10 @@ type PullRequestReviewCommentEvent struct {
 	Repo         *Repository   `json:"repository,omitempty"`
 	Sender       *User         `json:"sender,omitempty"`
 	Installation *Installation `json:"installation,omitempty"`
+
+	// The following field is only present when the webhook is triggered on
+	// a repository belonging to an organization.
+	Org *Organization `json:"organization,omitempty"`
 }
 
 // PullRequestReviewThreadEvent is triggered when a comment made as part of a
@@ -1147,6 +1203,10 @@ type PullRequestReviewThreadEvent struct {
 	Repo         *Repository   `json:"repository,omitempty"`
 	Sender       *User         `json:"sender,omitempty"`
 	Installation *Installation `json:"installation,omitempty"`
+
+	// The following field is only present when the webhook is triggered on
+	// a repository belonging to an organization.
+	Org *Organization `json:"organization,omitempty"`
 }
 
 // PullRequestTargetEvent is triggered when a pull request is assigned, unassigned, labeled,
@@ -1315,6 +1375,10 @@ type ReleaseEvent struct {
 	Repo         *Repository   `json:"repository,omitempty"`
 	Sender       *User         `json:"sender,omitempty"`
 	Installation *Installation `json:"installation,omitempty"`
+
+	// The following field is only present when the webhook is triggered on
+	// a repository belonging to an organization.
+	Org *Organization `json:"organization,omitempty"`
 }
 
 // RepositoryEvent is triggered when a repository is created, archived, unarchived,
@@ -1385,6 +1449,10 @@ type RepositoryVulnerabilityAlertEvent struct {
 
 	// The user that triggered the event.
 	Sender *User `json:"sender,omitempty"`
+
+	// The following field is only present when the webhook is triggered on
+	// a repository belonging to an organization.
+	Org *Organization `json:"organization,omitempty"`
 }
 
 // RepositoryVulnerabilityAlert represents a repository security alert.
@@ -1491,6 +1559,10 @@ type StatusEvent struct {
 	Repo         *Repository       `json:"repository,omitempty"`
 	Sender       *User             `json:"sender,omitempty"`
 	Installation *Installation     `json:"installation,omitempty"`
+
+	// The following field is only present when the webhook is triggered on
+	// a repository belonging to an organization.
+	Org *Organization `json:"organization,omitempty"`
 }
 
 // TeamEvent is triggered when an organization's team is created, modified or deleted.
@@ -1561,6 +1633,10 @@ type WatchEvent struct {
 	Repo         *Repository   `json:"repository,omitempty"`
 	Sender       *User         `json:"sender,omitempty"`
 	Installation *Installation `json:"installation,omitempty"`
+
+	// The following field is only present when the webhook is triggered on
+	// a repository belonging to an organization.
+	Org *Organization `json:"organization,omitempty"`
 }
 
 // WorkflowDispatchEvent is triggered when someone triggers a workflow run on GitHub or
@@ -1616,18 +1692,33 @@ type WorkflowRunEvent struct {
 //
 // GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#security_advisory
 type SecurityAdvisory struct {
-	CVSS            *AdvisoryCVSS            `json:"cvss,omitempty"`
-	CWEs            []*AdvisoryCWEs          `json:"cwes,omitempty"`
-	GHSAID          *string                  `json:"ghsa_id,omitempty"`
-	Summary         *string                  `json:"summary,omitempty"`
-	Description     *string                  `json:"description,omitempty"`
-	Severity        *string                  `json:"severity,omitempty"`
-	Identifiers     []*AdvisoryIdentifier    `json:"identifiers,omitempty"`
-	References      []*AdvisoryReference     `json:"references,omitempty"`
-	PublishedAt     *Timestamp               `json:"published_at,omitempty"`
-	UpdatedAt       *Timestamp               `json:"updated_at,omitempty"`
-	WithdrawnAt     *Timestamp               `json:"withdrawn_at,omitempty"`
-	Vulnerabilities []*AdvisoryVulnerability `json:"vulnerabilities,omitempty"`
+	CVSS               *AdvisoryCVSS                 `json:"cvss,omitempty"`
+	CWEs               []*AdvisoryCWEs               `json:"cwes,omitempty"`
+	GHSAID             *string                       `json:"ghsa_id,omitempty"`
+	Summary            *string                       `json:"summary,omitempty"`
+	Description        *string                       `json:"description,omitempty"`
+	Severity           *string                       `json:"severity,omitempty"`
+	Identifiers        []*AdvisoryIdentifier         `json:"identifiers,omitempty"`
+	References         []*AdvisoryReference          `json:"references,omitempty"`
+	PublishedAt        *Timestamp                    `json:"published_at,omitempty"`
+	UpdatedAt          *Timestamp                    `json:"updated_at,omitempty"`
+	WithdrawnAt        *Timestamp                    `json:"withdrawn_at,omitempty"`
+	Vulnerabilities    []*AdvisoryVulnerability      `json:"vulnerabilities,omitempty"`
+	CVEID              *string                       `json:"cve_id,omitempty"`
+	URL                *string                       `json:"url,omitempty"`
+	HTMLURL            *string                       `json:"html_url,omitempty"`
+	Author             *User                         `json:"author,omitempty"`
+	Publisher          *User                         `json:"publisher,omitempty"`
+	State              *string                       `json:"state,omitempty"`
+	CreatedAt          *Timestamp                    `json:"created_at,omitempty"`
+	ClosedAt           *Timestamp                    `json:"closed_at,omitempty"`
+	Submission         *SecurityAdvisorySubmission   `json:"submission,omitempty"`
+	CWEIDs             []string                      `json:"cwe_ids,omitempty"`
+	Credits            []*RepoAdvisoryCredit         `json:"credits,omitempty"`
+	CreditsDetailed    []*RepoAdvisoryCreditDetailed `json:"credits_detailed,omitempty"`
+	CollaboratingUsers []*User                       `json:"collaborating_users,omitempty"`
+	CollaboratingTeams []*Team                       `json:"collaborating_teams,omitempty"`
+	PrivateFork        *Repository                   `json:"private_fork,omitempty"`
 }
 
 // AdvisoryIdentifier represents the identifier for a Security Advisory.
@@ -1647,6 +1738,12 @@ type AdvisoryVulnerability struct {
 	Severity               *string               `json:"severity,omitempty"`
 	VulnerableVersionRange *string               `json:"vulnerable_version_range,omitempty"`
 	FirstPatchedVersion    *FirstPatchedVersion  `json:"first_patched_version,omitempty"`
+
+	// PatchedVersions and VulnerableFunctions are used in the following APIs:
+	// - https://docs.github.com/en/rest/security-advisories/repository-advisories?apiVersion=2022-11-28#list-repository-security-advisories-for-an-organization
+	// - https://docs.github.com/en/rest/security-advisories/repository-advisories?apiVersion=2022-11-28#list-repository-security-advisories
+	PatchedVersions     *string  `json:"patched_versions,omitempty"`
+	VulnerableFunctions []string `json:"vulnerable_functions,omitempty"`
 }
 
 // VulnerabilityPackage represents the package object for an Advisory Vulnerability.
diff --git a/github/github-accessors.go b/github/github-accessors.go
index 73170816..a0e7a743 100644
--- a/github/github-accessors.go
+++ b/github/github-accessors.go
@@ -438,6 +438,14 @@ func (a *AdvisoryVulnerability) GetPackage() *VulnerabilityPackage {
 	return a.Package
 }
 
+// GetPatchedVersions returns the PatchedVersions field if it's non-nil, zero value otherwise.
+func (a *AdvisoryVulnerability) GetPatchedVersions() string {
+	if a == nil || a.PatchedVersions == nil {
+		return ""
+	}
+	return *a.PatchedVersions
+}
+
 // GetSeverity returns the Severity field if it's non-nil, zero value otherwise.
 func (a *AdvisoryVulnerability) GetSeverity() string {
 	if a == nil || a.Severity == nil {
@@ -3814,6 +3822,14 @@ func (c *CommitCommentEvent) GetInstallation() *Installation {
 	return c.Installation
 }
 
+// GetOrg returns the Org field.
+func (c *CommitCommentEvent) GetOrg() *Organization {
+	if c == nil {
+		return nil
+	}
+	return c.Org
+}
+
 // GetRepo returns the Repo field.
 func (c *CommitCommentEvent) GetRepo() *Repository {
 	if c == nil {
@@ -5046,6 +5062,14 @@ func (d *DeleteEvent) GetInstallation() *Installation {
 	return d.Installation
 }
 
+// GetOrg returns the Org field.
+func (d *DeleteEvent) GetOrg() *Organization {
+	if d == nil {
+		return nil
+	}
+	return d.Org
+}
+
 // GetPusherType returns the PusherType field if it's non-nil, zero value otherwise.
 func (d *DeleteEvent) GetPusherType() string {
 	if d == nil || d.PusherType == nil {
@@ -5582,6 +5606,14 @@ func (d *DeploymentEvent) GetInstallation() *Installation {
 	return d.Installation
 }
 
+// GetOrg returns the Org field.
+func (d *DeploymentEvent) GetOrg() *Organization {
+	if d == nil {
+		return nil
+	}
+	return d.Org
+}
+
 // GetRepo returns the Repo field.
 func (d *DeploymentEvent) GetRepo() *Repository {
 	if d == nil {
@@ -5886,6 +5918,14 @@ func (d *DeploymentStatusEvent) GetInstallation() *Installation {
 	return d.Installation
 }
 
+// GetOrg returns the Org field.
+func (d *DeploymentStatusEvent) GetOrg() *Organization {
+	if d == nil {
+		return nil
+	}
+	return d.Org
+}
+
 // GetRepo returns the Repo field.
 func (d *DeploymentStatusEvent) GetRepo() *Repository {
 	if d == nil {
@@ -7686,6 +7726,14 @@ func (g *GollumEvent) GetInstallation() *Installation {
 	return g.Installation
 }
 
+// GetOrg returns the Org field.
+func (g *GollumEvent) GetOrg() *Organization {
+	if g == nil {
+		return nil
+	}
+	return g.Org
+}
+
 // GetRepo returns the Repo field.
 func (g *GollumEvent) GetRepo() *Repository {
 	if g == nil {
@@ -8558,6 +8606,14 @@ func (i *InstallationEvent) GetInstallation() *Installation {
 	return i.Installation
 }
 
+// GetOrg returns the Org field.
+func (i *InstallationEvent) GetOrg() *Organization {
+	if i == nil {
+		return nil
+	}
+	return i.Org
+}
+
 // GetRequester returns the Requester field.
 func (i *InstallationEvent) GetRequester() *User {
 	if i == nil {
@@ -8894,6 +8950,14 @@ func (i *InstallationRepositoriesEvent) GetInstallation() *Installation {
 	return i.Installation
 }
 
+// GetOrg returns the Org field.
+func (i *InstallationRepositoriesEvent) GetOrg() *Organization {
+	if i == nil {
+		return nil
+	}
+	return i.Org
+}
+
 // GetRepositorySelection returns the RepositorySelection field if it's non-nil, zero value otherwise.
 func (i *InstallationRepositoriesEvent) GetRepositorySelection() string {
 	if i == nil || i.RepositorySelection == nil {
@@ -9998,6 +10062,14 @@ func (i *IssuesEvent) GetMilestone() *Milestone {
 	return i.Milestone
 }
 
+// GetOrg returns the Org field.
+func (i *IssuesEvent) GetOrg() *Organization {
+	if i == nil {
+		return nil
+	}
+	return i.Org
+}
+
 // GetRepo returns the Repo field.
 func (i *IssuesEvent) GetRepo() *Repository {
 	if i == nil {
@@ -11046,6 +11118,14 @@ func (m *MarketplacePurchaseEvent) GetMarketplacePurchase() *MarketplacePurchase
 	return m.MarketplacePurchase
 }
 
+// GetOrg returns the Org field.
+func (m *MarketplacePurchaseEvent) GetOrg() *Organization {
+	if m == nil {
+		return nil
+	}
+	return m.Org
+}
+
 // GetPreviousMarketplacePurchase returns the PreviousMarketplacePurchase field.
 func (m *MarketplacePurchaseEvent) GetPreviousMarketplacePurchase() *MarketplacePurchase {
 	if m == nil {
@@ -11094,6 +11174,14 @@ func (m *MemberEvent) GetMember() *User {
 	return m.Member
 }
 
+// GetOrg returns the Org field.
+func (m *MemberEvent) GetOrg() *Organization {
+	if m == nil {
+		return nil
+	}
+	return m.Org
+}
+
 // GetRepo returns the Repo field.
 func (m *MemberEvent) GetRepo() *Repository {
 	if m == nil {
@@ -13326,6 +13414,14 @@ func (p *PageBuildEvent) GetInstallation() *Installation {
 	return p.Installation
 }
 
+// GetOrg returns the Org field.
+func (p *PageBuildEvent) GetOrg() *Organization {
+	if p == nil {
+		return nil
+	}
+	return p.Org
+}
+
 // GetRepo returns the Repo field.
 func (p *PageBuildEvent) GetRepo() *Repository {
 	if p == nil {
@@ -13862,6 +13958,14 @@ func (p *PersonalAccessTokenRequest) GetID() int64 {
 	return *p.ID
 }
 
+// GetOrg returns the Org field.
+func (p *PersonalAccessTokenRequest) GetOrg() *Organization {
+	if p == nil {
+		return nil
+	}
+	return p.Org
+}
+
 // GetOwner returns the Owner field.
 func (p *PersonalAccessTokenRequest) GetOwner() *User {
 	if p == nil {
@@ -15454,6 +15558,14 @@ func (p *PublicEvent) GetInstallation() *Installation {
 	return p.Installation
 }
 
+// GetOrg returns the Org field.
+func (p *PublicEvent) GetOrg() *Organization {
+	if p == nil {
+		return nil
+	}
+	return p.Org
+}
+
 // GetRepo returns the Repo field.
 func (p *PublicEvent) GetRepo() *Repository {
 	if p == nil {
@@ -16430,6 +16542,14 @@ func (p *PullRequestReviewCommentEvent) GetInstallation() *Installation {
 	return p.Installation
 }
 
+// GetOrg returns the Org field.
+func (p *PullRequestReviewCommentEvent) GetOrg() *Organization {
+	if p == nil {
+		return nil
+	}
+	return p.Org
+}
+
 // GetPullRequest returns the PullRequest field.
 func (p *PullRequestReviewCommentEvent) GetPullRequest() *PullRequest {
 	if p == nil {
@@ -16654,6 +16774,14 @@ func (p *PullRequestReviewThreadEvent) GetInstallation() *Installation {
 	return p.Installation
 }
 
+// GetOrg returns the Org field.
+func (p *PullRequestReviewThreadEvent) GetOrg() *Organization {
+	if p == nil {
+		return nil
+	}
+	return p.Org
+}
+
 // GetPullRequest returns the PullRequest field.
 func (p *PullRequestReviewThreadEvent) GetPullRequest() *PullRequest {
 	if p == nil {
@@ -17686,6 +17814,14 @@ func (r *ReleaseEvent) GetInstallation() *Installation {
 	return r.Installation
 }
 
+// GetOrg returns the Org field.
+func (r *ReleaseEvent) GetOrg() *Organization {
+	if r == nil {
+		return nil
+	}
+	return r.Org
+}
+
 // GetRelease returns the Release field.
 func (r *ReleaseEvent) GetRelease() *RepositoryRelease {
 	if r == nil {
@@ -17758,6 +17894,46 @@ func (r *RenameOrgResponse) GetURL() string {
 	return *r.URL
 }
 
+// GetLogin returns the Login field if it's non-nil, zero value otherwise.
+func (r *RepoAdvisoryCredit) GetLogin() string {
+	if r == nil || r.Login == nil {
+		return ""
+	}
+	return *r.Login
+}
+
+// GetType returns the Type field if it's non-nil, zero value otherwise.
+func (r *RepoAdvisoryCredit) GetType() string {
+	if r == nil || r.Type == nil {
+		return ""
+	}
+	return *r.Type
+}
+
+// GetState returns the State field if it's non-nil, zero value otherwise.
+func (r *RepoAdvisoryCreditDetailed) GetState() string {
+	if r == nil || r.State == nil {
+		return ""
+	}
+	return *r.State
+}
+
+// GetType returns the Type field if it's non-nil, zero value otherwise.
+func (r *RepoAdvisoryCreditDetailed) GetType() string {
+	if r == nil || r.Type == nil {
+		return ""
+	}
+	return *r.Type
+}
+
+// GetUser returns the User field.
+func (r *RepoAdvisoryCreditDetailed) GetUser() *User {
+	if r == nil {
+		return nil
+	}
+	return r.User
+}
+
 // GetDownloadLocation returns the DownloadLocation field if it's non-nil, zero value otherwise.
 func (r *RepoDependencies) GetDownloadLocation() string {
 	if r == nil || r.DownloadLocation == nil {
@@ -19774,6 +19950,14 @@ func (r *RepositoryVulnerabilityAlertEvent) GetInstallation() *Installation {
 	return r.Installation
 }
 
+// GetOrg returns the Org field.
+func (r *RepositoryVulnerabilityAlertEvent) GetOrg() *Organization {
+	if r == nil {
+		return nil
+	}
+	return r.Org
+}
+
 // GetRepository returns the Repository field.
 func (r *RepositoryVulnerabilityAlertEvent) GetRepository() *Repository {
 	if r == nil {
@@ -21078,6 +21262,38 @@ func (s *SecretScanningPushProtection) GetStatus() string {
 	return *s.Status
 }
 
+// GetAuthor returns the Author field.
+func (s *SecurityAdvisory) GetAuthor() *User {
+	if s == nil {
+		return nil
+	}
+	return s.Author
+}
+
+// GetClosedAt returns the ClosedAt field if it's non-nil, zero value otherwise.
+func (s *SecurityAdvisory) GetClosedAt() Timestamp {
+	if s == nil || s.ClosedAt == nil {
+		return Timestamp{}
+	}
+	return *s.ClosedAt
+}
+
+// GetCreatedAt returns the CreatedAt field if it's non-nil, zero value otherwise.
+func (s *SecurityAdvisory) GetCreatedAt() Timestamp {
+	if s == nil || s.CreatedAt == nil {
+		return Timestamp{}
+	}
+	return *s.CreatedAt
+}
+
+// GetCVEID returns the CVEID field if it's non-nil, zero value otherwise.
+func (s *SecurityAdvisory) GetCVEID() string {
+	if s == nil || s.CVEID == nil {
+		return ""
+	}
+	return *s.CVEID
+}
+
 // GetCVSS returns the CVSS field.
 func (s *SecurityAdvisory) GetCVSS() *AdvisoryCVSS {
 	if s == nil {
@@ -21102,6 +21318,22 @@ func (s *SecurityAdvisory) GetGHSAID() string {
 	return *s.GHSAID
 }
 
+// GetHTMLURL returns the HTMLURL field if it's non-nil, zero value otherwise.
+func (s *SecurityAdvisory) GetHTMLURL() string {
+	if s == nil || s.HTMLURL == nil {
+		return ""
+	}
+	return *s.HTMLURL
+}
+
+// GetPrivateFork returns the PrivateFork field.
+func (s *SecurityAdvisory) GetPrivateFork() *Repository {
+	if s == nil {
+		return nil
+	}
+	return s.PrivateFork
+}
+
 // GetPublishedAt returns the PublishedAt field if it's non-nil, zero value otherwise.
 func (s *SecurityAdvisory) GetPublishedAt() Timestamp {
 	if s == nil || s.PublishedAt == nil {
@@ -21110,6 +21342,14 @@ func (s *SecurityAdvisory) GetPublishedAt() Timestamp {
 	return *s.PublishedAt
 }
 
+// GetPublisher returns the Publisher field.
+func (s *SecurityAdvisory) GetPublisher() *User {
+	if s == nil {
+		return nil
+	}
+	return s.Publisher
+}
+
 // GetSeverity returns the Severity field if it's non-nil, zero value otherwise.
 func (s *SecurityAdvisory) GetSeverity() string {
 	if s == nil || s.Severity == nil {
@@ -21118,6 +21358,22 @@ func (s *SecurityAdvisory) GetSeverity() string {
 	return *s.Severity
 }
 
+// GetState returns the State field if it's non-nil, zero value otherwise.
+func (s *SecurityAdvisory) GetState() string {
+	if s == nil || s.State == nil {
+		return ""
+	}
+	return *s.State
+}
+
+// GetSubmission returns the Submission field.
+func (s *SecurityAdvisory) GetSubmission() *SecurityAdvisorySubmission {
+	if s == nil {
+		return nil
+	}
+	return s.Submission
+}
+
 // GetSummary returns the Summary field if it's non-nil, zero value otherwise.
 func (s *SecurityAdvisory) GetSummary() string {
 	if s == nil || s.Summary == nil {
@@ -21134,6 +21390,14 @@ func (s *SecurityAdvisory) GetUpdatedAt() Timestamp {
 	return *s.UpdatedAt
 }
 
+// GetURL returns the URL field if it's non-nil, zero value otherwise.
+func (s *SecurityAdvisory) GetURL() string {
+	if s == nil || s.URL == nil {
+		return ""
+	}
+	return *s.URL
+}
+
 // GetWithdrawnAt returns the WithdrawnAt field if it's non-nil, zero value otherwise.
 func (s *SecurityAdvisory) GetWithdrawnAt() Timestamp {
 	if s == nil || s.WithdrawnAt == nil {
@@ -21198,6 +21462,14 @@ func (s *SecurityAdvisoryEvent) GetSender() *User {
 	return s.Sender
 }
 
+// GetAccepted returns the Accepted field if it's non-nil, zero value otherwise.
+func (s *SecurityAdvisorySubmission) GetAccepted() bool {
+	if s == nil || s.Accepted == nil {
+		return false
+	}
+	return *s.Accepted
+}
+
 // GetAdvancedSecurity returns the AdvancedSecurity field.
 func (s *SecurityAndAnalysis) GetAdvancedSecurity() *AdvancedSecurity {
 	if s == nil {
@@ -21622,6 +21894,14 @@ func (s *StatusEvent) GetName() string {
 	return *s.Name
 }
 
+// GetOrg returns the Org field.
+func (s *StatusEvent) GetOrg() *Organization {
+	if s == nil {
+		return nil
+	}
+	return s.Org
+}
+
 // GetRepo returns the Repo field.
 func (s *StatusEvent) GetRepo() *Repository {
 	if s == nil {
@@ -23950,6 +24230,14 @@ func (w *WatchEvent) GetInstallation() *Installation {
 	return w.Installation
 }
 
+// GetOrg returns the Org field.
+func (w *WatchEvent) GetOrg() *Organization {
+	if w == nil {
+		return nil
+	}
+	return w.Org
+}
+
 // GetRepo returns the Repo field.
 func (w *WatchEvent) GetRepo() *Repository {
 	if w == nil {
diff --git a/github/repos.go b/github/repos.go
index e09971ab..f2059926 100644
--- a/github/repos.go
+++ b/github/repos.go
@@ -11,6 +11,7 @@ import (
 	"errors"
 	"fmt"
 	"net/http"
+	"net/url"
 	"strings"
 )
 
@@ -1273,9 +1274,11 @@ func (s *RepositoriesService) ListBranches(ctx context.Context, owner string, re
 
 // GetBranch gets the specified branch for a repository.
 //
+// Note: the branch name is URL path escaped for you. See: https://pkg.go.dev/net/url#PathEscape .
+//
 // GitHub API docs: https://docs.github.com/en/rest/branches/branches#get-a-branch
 func (s *RepositoriesService) GetBranch(ctx context.Context, owner, repo, branch string, maxRedirects int) (*Branch, *Response, error) {
-	u := fmt.Sprintf("repos/%v/%v/branches/%v", owner, repo, branch)
+	u := fmt.Sprintf("repos/%v/%v/branches/%v", owner, repo, url.PathEscape(branch))
 
 	resp, err := s.client.roundTripWithOptionalFollowRedirect(ctx, u, maxRedirects)
 	if err != nil {
@@ -1302,9 +1305,11 @@ type renameBranchRequest struct {
 // To rename a non-default branch: Users must have push access. GitHub Apps must have the `contents:write` repository permission.
 // To rename the default branch: Users must have admin or owner permissions. GitHub Apps must have the `administration:write` repository permission.
 //
+// Note: the branch name is URL path escaped for you. See: https://pkg.go.dev/net/url#PathEscape .
+//
 // GitHub API docs: https://docs.github.com/en/rest/branches/branches#rename-a-branch
 func (s *RepositoriesService) RenameBranch(ctx context.Context, owner, repo, branch, newName string) (*Branch, *Response, error) {
-	u := fmt.Sprintf("repos/%v/%v/branches/%v/rename", owner, repo, branch)
+	u := fmt.Sprintf("repos/%v/%v/branches/%v/rename", owner, repo, url.PathEscape(branch))
 	r := &renameBranchRequest{NewName: newName}
 	req, err := s.client.NewRequest("POST", u, r)
 	if err != nil {
@@ -1322,9 +1327,11 @@ func (s *RepositoriesService) RenameBranch(ctx context.Context, owner, repo, bra
 
 // GetBranchProtection gets the protection of a given branch.
 //
+// Note: the branch name is URL path escaped for you. See: https://pkg.go.dev/net/url#PathEscape .
+//
 // GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#get-branch-protection
 func (s *RepositoriesService) GetBranchProtection(ctx context.Context, owner, repo, branch string) (*Protection, *Response, error) {
-	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection", owner, repo, branch)
+	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection", owner, repo, url.PathEscape(branch))
 	req, err := s.client.NewRequest("GET", u, nil)
 	if err != nil {
 		return nil, nil, err
@@ -1347,9 +1354,11 @@ func (s *RepositoriesService) GetBranchProtection(ctx context.Context, owner, re
 
 // GetRequiredStatusChecks gets the required status checks for a given protected branch.
 //
+// Note: the branch name is URL path escaped for you. See: https://pkg.go.dev/net/url#PathEscape .
+//
 // GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#get-status-checks-protection
 func (s *RepositoriesService) GetRequiredStatusChecks(ctx context.Context, owner, repo, branch string) (*RequiredStatusChecks, *Response, error) {
-	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/required_status_checks", owner, repo, branch)
+	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/required_status_checks", owner, repo, url.PathEscape(branch))
 	req, err := s.client.NewRequest("GET", u, nil)
 	if err != nil {
 		return nil, nil, err
@@ -1369,9 +1378,11 @@ func (s *RepositoriesService) GetRequiredStatusChecks(ctx context.Context, owner
 
 // ListRequiredStatusChecksContexts lists the required status checks contexts for a given protected branch.
 //
+// Note: the branch name is URL path escaped for you. See: https://pkg.go.dev/net/url#PathEscape .
+//
 // GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#get-all-status-check-contexts
 func (s *RepositoriesService) ListRequiredStatusChecksContexts(ctx context.Context, owner, repo, branch string) (contexts []string, resp *Response, err error) {
-	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/required_status_checks/contexts", owner, repo, branch)
+	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/required_status_checks/contexts", owner, repo, url.PathEscape(branch))
 	req, err := s.client.NewRequest("GET", u, nil)
 	if err != nil {
 		return nil, nil, err
@@ -1390,9 +1401,11 @@ func (s *RepositoriesService) ListRequiredStatusChecksContexts(ctx context.Conte
 
 // UpdateBranchProtection updates the protection of a given branch.
 //
+// Note: the branch name is URL path escaped for you. See: https://pkg.go.dev/net/url#PathEscape .
+//
 // GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#update-branch-protection
 func (s *RepositoriesService) UpdateBranchProtection(ctx context.Context, owner, repo, branch string, preq *ProtectionRequest) (*Protection, *Response, error) {
-	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection", owner, repo, branch)
+	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection", owner, repo, url.PathEscape(branch))
 	req, err := s.client.NewRequest("PUT", u, preq)
 	if err != nil {
 		return nil, nil, err
@@ -1412,9 +1425,11 @@ func (s *RepositoriesService) UpdateBranchProtection(ctx context.Context, owner,
 
 // RemoveBranchProtection removes the protection of a given branch.
 //
+// Note: the branch name is URL path escaped for you. See: https://pkg.go.dev/net/url#PathEscape .
+//
 // GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#delete-branch-protection
 func (s *RepositoriesService) RemoveBranchProtection(ctx context.Context, owner, repo, branch string) (*Response, error) {
-	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection", owner, repo, branch)
+	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection", owner, repo, url.PathEscape(branch))
 	req, err := s.client.NewRequest("DELETE", u, nil)
 	if err != nil {
 		return nil, err
@@ -1425,9 +1440,11 @@ func (s *RepositoriesService) RemoveBranchProtection(ctx context.Context, owner,
 
 // GetSignaturesProtectedBranch gets required signatures of protected branch.
 //
+// Note: the branch name is URL path escaped for you. See: https://pkg.go.dev/net/url#PathEscape .
+//
 // GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#get-commit-signature-protection
 func (s *RepositoriesService) GetSignaturesProtectedBranch(ctx context.Context, owner, repo, branch string) (*SignaturesProtectedBranch, *Response, error) {
-	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/required_signatures", owner, repo, branch)
+	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/required_signatures", owner, repo, url.PathEscape(branch))
 	req, err := s.client.NewRequest("GET", u, nil)
 	if err != nil {
 		return nil, nil, err
@@ -1448,9 +1465,11 @@ func (s *RepositoriesService) GetSignaturesProtectedBranch(ctx context.Context,
 // RequireSignaturesOnProtectedBranch makes signed commits required on a protected branch.
 // It requires admin access and branch protection to be enabled.
 //
+// Note: the branch name is URL path escaped for you. See: https://pkg.go.dev/net/url#PathEscape .
+//
 // GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#create-commit-signature-protection
 func (s *RepositoriesService) RequireSignaturesOnProtectedBranch(ctx context.Context, owner, repo, branch string) (*SignaturesProtectedBranch, *Response, error) {
-	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/required_signatures", owner, repo, branch)
+	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/required_signatures", owner, repo, url.PathEscape(branch))
 	req, err := s.client.NewRequest("POST", u, nil)
 	if err != nil {
 		return nil, nil, err
@@ -1470,9 +1489,11 @@ func (s *RepositoriesService) RequireSignaturesOnProtectedBranch(ctx context.Con
 
 // OptionalSignaturesOnProtectedBranch removes required signed commits on a given branch.
 //
+// Note: the branch name is URL path escaped for you. See: https://pkg.go.dev/net/url#PathEscape .
+//
 // GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#delete-commit-signature-protection
 func (s *RepositoriesService) OptionalSignaturesOnProtectedBranch(ctx context.Context, owner, repo, branch string) (*Response, error) {
-	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/required_signatures", owner, repo, branch)
+	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/required_signatures", owner, repo, url.PathEscape(branch))
 	req, err := s.client.NewRequest("DELETE", u, nil)
 	if err != nil {
 		return nil, err
@@ -1486,9 +1507,11 @@ func (s *RepositoriesService) OptionalSignaturesOnProtectedBranch(ctx context.Co
 
 // UpdateRequiredStatusChecks updates the required status checks for a given protected branch.
 //
+// Note: the branch name is URL path escaped for you. See: https://pkg.go.dev/net/url#PathEscape .
+//
 // GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#update-status-check-protection
 func (s *RepositoriesService) UpdateRequiredStatusChecks(ctx context.Context, owner, repo, branch string, sreq *RequiredStatusChecksRequest) (*RequiredStatusChecks, *Response, error) {
-	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/required_status_checks", owner, repo, branch)
+	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/required_status_checks", owner, repo, url.PathEscape(branch))
 	req, err := s.client.NewRequest("PATCH", u, sreq)
 	if err != nil {
 		return nil, nil, err
@@ -1505,9 +1528,11 @@ func (s *RepositoriesService) UpdateRequiredStatusChecks(ctx context.Context, ow
 
 // RemoveRequiredStatusChecks removes the required status checks for a given protected branch.
 //
+// Note: the branch name is URL path escaped for you. See: https://pkg.go.dev/net/url#PathEscape .
+//
 // GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#remove-status-check-protection
 func (s *RepositoriesService) RemoveRequiredStatusChecks(ctx context.Context, owner, repo, branch string) (*Response, error) {
-	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/required_status_checks", owner, repo, branch)
+	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/required_status_checks", owner, repo, url.PathEscape(branch))
 	req, err := s.client.NewRequest("DELETE", u, nil)
 	if err != nil {
 		return nil, err
@@ -1537,9 +1562,11 @@ func (s *RepositoriesService) License(ctx context.Context, owner, repo string) (
 
 // GetPullRequestReviewEnforcement gets pull request review enforcement of a protected branch.
 //
+// Note: the branch name is URL path escaped for you. See: https://pkg.go.dev/net/url#PathEscape .
+//
 // GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#get-pull-request-review-protection
 func (s *RepositoriesService) GetPullRequestReviewEnforcement(ctx context.Context, owner, repo, branch string) (*PullRequestReviewsEnforcement, *Response, error) {
-	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/required_pull_request_reviews", owner, repo, branch)
+	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/required_pull_request_reviews", owner, repo, url.PathEscape(branch))
 	req, err := s.client.NewRequest("GET", u, nil)
 	if err != nil {
 		return nil, nil, err
@@ -1560,9 +1587,11 @@ func (s *RepositoriesService) GetPullRequestReviewEnforcement(ctx context.Contex
 // UpdatePullRequestReviewEnforcement patches pull request review enforcement of a protected branch.
 // It requires admin access and branch protection to be enabled.
 //
+// Note: the branch name is URL path escaped for you. See: https://pkg.go.dev/net/url#PathEscape .
+//
 // GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#update-pull-request-review-protection
 func (s *RepositoriesService) UpdatePullRequestReviewEnforcement(ctx context.Context, owner, repo, branch string, patch *PullRequestReviewsEnforcementUpdate) (*PullRequestReviewsEnforcement, *Response, error) {
-	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/required_pull_request_reviews", owner, repo, branch)
+	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/required_pull_request_reviews", owner, repo, url.PathEscape(branch))
 	req, err := s.client.NewRequest("PATCH", u, patch)
 	if err != nil {
 		return nil, nil, err
@@ -1583,9 +1612,11 @@ func (s *RepositoriesService) UpdatePullRequestReviewEnforcement(ctx context.Con
 // DisableDismissalRestrictions disables dismissal restrictions of a protected branch.
 // It requires admin access and branch protection to be enabled.
 //
+// Note: the branch name is URL path escaped for you. See: https://pkg.go.dev/net/url#PathEscape .
+//
 // GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#update-pull-request-review-protection
 func (s *RepositoriesService) DisableDismissalRestrictions(ctx context.Context, owner, repo, branch string) (*PullRequestReviewsEnforcement, *Response, error) {
-	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/required_pull_request_reviews", owner, repo, branch)
+	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/required_pull_request_reviews", owner, repo, url.PathEscape(branch))
 
 	data := new(struct {
 		DismissalRestrictionsRequest `json:"dismissal_restrictions"`
@@ -1610,9 +1641,11 @@ func (s *RepositoriesService) DisableDismissalRestrictions(ctx context.Context,
 
 // RemovePullRequestReviewEnforcement removes pull request enforcement of a protected branch.
 //
+// Note: the branch name is URL path escaped for you. See: https://pkg.go.dev/net/url#PathEscape .
+//
 // GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#delete-pull-request-review-protection
 func (s *RepositoriesService) RemovePullRequestReviewEnforcement(ctx context.Context, owner, repo, branch string) (*Response, error) {
-	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/required_pull_request_reviews", owner, repo, branch)
+	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/required_pull_request_reviews", owner, repo, url.PathEscape(branch))
 	req, err := s.client.NewRequest("DELETE", u, nil)
 	if err != nil {
 		return nil, err
@@ -1623,9 +1656,11 @@ func (s *RepositoriesService) RemovePullRequestReviewEnforcement(ctx context.Con
 
 // GetAdminEnforcement gets admin enforcement information of a protected branch.
 //
+// Note: the branch name is URL path escaped for you. See: https://pkg.go.dev/net/url#PathEscape .
+//
 // GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#get-admin-branch-protection
 func (s *RepositoriesService) GetAdminEnforcement(ctx context.Context, owner, repo, branch string) (*AdminEnforcement, *Response, error) {
-	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/enforce_admins", owner, repo, branch)
+	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/enforce_admins", owner, repo, url.PathEscape(branch))
 	req, err := s.client.NewRequest("GET", u, nil)
 	if err != nil {
 		return nil, nil, err
@@ -1643,9 +1678,11 @@ func (s *RepositoriesService) GetAdminEnforcement(ctx context.Context, owner, re
 // AddAdminEnforcement adds admin enforcement to a protected branch.
 // It requires admin access and branch protection to be enabled.
 //
+// Note: the branch name is URL path escaped for you. See: https://pkg.go.dev/net/url#PathEscape .
+//
 // GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#set-admin-branch-protection
 func (s *RepositoriesService) AddAdminEnforcement(ctx context.Context, owner, repo, branch string) (*AdminEnforcement, *Response, error) {
-	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/enforce_admins", owner, repo, branch)
+	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/enforce_admins", owner, repo, url.PathEscape(branch))
 	req, err := s.client.NewRequest("POST", u, nil)
 	if err != nil {
 		return nil, nil, err
@@ -1662,9 +1699,11 @@ func (s *RepositoriesService) AddAdminEnforcement(ctx context.Context, owner, re
 
 // RemoveAdminEnforcement removes admin enforcement from a protected branch.
 //
+// Note: the branch name is URL path escaped for you. See: https://pkg.go.dev/net/url#PathEscape .
+//
 // GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#delete-admin-branch-protection
 func (s *RepositoriesService) RemoveAdminEnforcement(ctx context.Context, owner, repo, branch string) (*Response, error) {
-	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/enforce_admins", owner, repo, branch)
+	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/enforce_admins", owner, repo, url.PathEscape(branch))
 	req, err := s.client.NewRequest("DELETE", u, nil)
 	if err != nil {
 		return nil, err
@@ -1731,11 +1770,13 @@ func (s *RepositoriesService) ReplaceAllTopics(ctx context.Context, owner, repo
 // ListApps lists the GitHub apps that have push access to a given protected branch.
 // It requires the GitHub apps to have `write` access to the `content` permission.
 //
+// Note: the branch name is URL path escaped for you. See: https://pkg.go.dev/net/url#PathEscape .
+//
 // GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#get-apps-with-access-to-the-protected-branch
 //
 // Deprecated: Please use ListAppRestrictions instead.
 func (s *RepositoriesService) ListApps(ctx context.Context, owner, repo, branch string) ([]*App, *Response, error) {
-	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/restrictions/apps", owner, repo, branch)
+	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/restrictions/apps", owner, repo, url.PathEscape(branch))
 	req, err := s.client.NewRequest("GET", u, nil)
 	if err != nil {
 		return nil, nil, err
@@ -1766,9 +1807,11 @@ func (s *RepositoriesService) ListAppRestrictions(ctx context.Context, owner, re
 //
 // Note: The list of users, apps, and teams in total is limited to 100 items.
 //
+// Note: the branch name is URL path escaped for you. See: https://pkg.go.dev/net/url#PathEscape .
+//
 // GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#set-app-access-restrictions
 func (s *RepositoriesService) ReplaceAppRestrictions(ctx context.Context, owner, repo, branch string, apps []string) ([]*App, *Response, error) {
-	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/restrictions/apps", owner, repo, branch)
+	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/restrictions/apps", owner, repo, url.PathEscape(branch))
 	req, err := s.client.NewRequest("PUT", u, apps)
 	if err != nil {
 		return nil, nil, err
@@ -1788,9 +1831,11 @@ func (s *RepositoriesService) ReplaceAppRestrictions(ctx context.Context, owner,
 //
 // Note: The list of users, apps, and teams in total is limited to 100 items.
 //
+// Note: the branch name is URL path escaped for you. See: https://pkg.go.dev/net/url#PathEscape .
+//
 // GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#add-app-access-restrictions
 func (s *RepositoriesService) AddAppRestrictions(ctx context.Context, owner, repo, branch string, apps []string) ([]*App, *Response, error) {
-	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/restrictions/apps", owner, repo, branch)
+	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/restrictions/apps", owner, repo, url.PathEscape(branch))
 	req, err := s.client.NewRequest("POST", u, apps)
 	if err != nil {
 		return nil, nil, err
@@ -1810,9 +1855,11 @@ func (s *RepositoriesService) AddAppRestrictions(ctx context.Context, owner, rep
 //
 // Note: The list of users, apps, and teams in total is limited to 100 items.
 //
+// Note: the branch name is URL path escaped for you. See: https://pkg.go.dev/net/url#PathEscape .
+//
 // GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#remove-app-access-restrictions
 func (s *RepositoriesService) RemoveAppRestrictions(ctx context.Context, owner, repo, branch string, apps []string) ([]*App, *Response, error) {
-	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/restrictions/apps", owner, repo, branch)
+	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/restrictions/apps", owner, repo, url.PathEscape(branch))
 	req, err := s.client.NewRequest("DELETE", u, apps)
 	if err != nil {
 		return nil, nil, err
@@ -1830,9 +1877,11 @@ func (s *RepositoriesService) RemoveAppRestrictions(ctx context.Context, owner,
 // ListTeamRestrictions lists the GitHub teams that have push access to a given protected branch.
 // It requires the GitHub teams to have `write` access to the `content` permission.
 //
+// Note: the branch name is URL path escaped for you. See: https://pkg.go.dev/net/url#PathEscape .
+//
 // GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#get-teams-with-access-to-the-protected-branch
 func (s *RepositoriesService) ListTeamRestrictions(ctx context.Context, owner, repo, branch string) ([]*Team, *Response, error) {
-	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/restrictions/teams", owner, repo, branch)
+	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/restrictions/teams", owner, repo, url.PathEscape(branch))
 	req, err := s.client.NewRequest("GET", u, nil)
 	if err != nil {
 		return nil, nil, err
@@ -1853,9 +1902,11 @@ func (s *RepositoriesService) ListTeamRestrictions(ctx context.Context, owner, r
 //
 // Note: The list of users, apps, and teams in total is limited to 100 items.
 //
+// Note: the branch name is URL path escaped for you. See: https://pkg.go.dev/net/url#PathEscape .
+//
 // GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#set-team-access-restrictions
 func (s *RepositoriesService) ReplaceTeamRestrictions(ctx context.Context, owner, repo, branch string, teams []string) ([]*Team, *Response, error) {
-	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/restrictions/teams", owner, repo, branch)
+	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/restrictions/teams", owner, repo, url.PathEscape(branch))
 	req, err := s.client.NewRequest("PUT", u, teams)
 	if err != nil {
 		return nil, nil, err
@@ -1875,9 +1926,11 @@ func (s *RepositoriesService) ReplaceTeamRestrictions(ctx context.Context, owner
 //
 // Note: The list of users, apps, and teams in total is limited to 100 items.
 //
+// Note: the branch name is URL path escaped for you. See: https://pkg.go.dev/net/url#PathEscape .
+//
 // GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#add-team-access-restrictions
 func (s *RepositoriesService) AddTeamRestrictions(ctx context.Context, owner, repo, branch string, teams []string) ([]*Team, *Response, error) {
-	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/restrictions/teams", owner, repo, branch)
+	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/restrictions/teams", owner, repo, url.PathEscape(branch))
 	req, err := s.client.NewRequest("POST", u, teams)
 	if err != nil {
 		return nil, nil, err
@@ -1897,9 +1950,11 @@ func (s *RepositoriesService) AddTeamRestrictions(ctx context.Context, owner, re
 //
 // Note: The list of users, apps, and teams in total is limited to 100 items.
 //
+// Note: the branch name is URL path escaped for you. See: https://pkg.go.dev/net/url#PathEscape .
+//
 // GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#remove-team-access-restrictions
 func (s *RepositoriesService) RemoveTeamRestrictions(ctx context.Context, owner, repo, branch string, teams []string) ([]*Team, *Response, error) {
-	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/restrictions/teams", owner, repo, branch)
+	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/restrictions/teams", owner, repo, url.PathEscape(branch))
 	req, err := s.client.NewRequest("DELETE", u, teams)
 	if err != nil {
 		return nil, nil, err
@@ -1917,9 +1972,11 @@ func (s *RepositoriesService) RemoveTeamRestrictions(ctx context.Context, owner,
 // ListUserRestrictions lists the GitHub users that have push access to a given protected branch.
 // It requires the GitHub users to have `write` access to the `content` permission.
 //
+// Note: the branch name is URL path escaped for you. See: https://pkg.go.dev/net/url#PathEscape .
+//
 // GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#get-users-with-access-to-the-protected-branch
 func (s *RepositoriesService) ListUserRestrictions(ctx context.Context, owner, repo, branch string) ([]*User, *Response, error) {
-	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/restrictions/users", owner, repo, branch)
+	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/restrictions/users", owner, repo, url.PathEscape(branch))
 	req, err := s.client.NewRequest("GET", u, nil)
 	if err != nil {
 		return nil, nil, err
@@ -1940,9 +1997,11 @@ func (s *RepositoriesService) ListUserRestrictions(ctx context.Context, owner, r
 //
 // Note: The list of users, apps, and teams in total is limited to 100 items.
 //
+// Note: the branch name is URL path escaped for you. See: https://pkg.go.dev/net/url#PathEscape .
+//
 // GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#set-team-access-restrictions
 func (s *RepositoriesService) ReplaceUserRestrictions(ctx context.Context, owner, repo, branch string, users []string) ([]*User, *Response, error) {
-	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/restrictions/users", owner, repo, branch)
+	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/restrictions/users", owner, repo, url.PathEscape(branch))
 	req, err := s.client.NewRequest("PUT", u, users)
 	if err != nil {
 		return nil, nil, err
@@ -1962,9 +2021,11 @@ func (s *RepositoriesService) ReplaceUserRestrictions(ctx context.Context, owner
 //
 // Note: The list of users, apps, and teams in total is limited to 100 items.
 //
+// Note: the branch name is URL path escaped for you. See: https://pkg.go.dev/net/url#PathEscape .
+//
 // GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#add-team-access-restrictions
 func (s *RepositoriesService) AddUserRestrictions(ctx context.Context, owner, repo, branch string, users []string) ([]*User, *Response, error) {
-	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/restrictions/users", owner, repo, branch)
+	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/restrictions/users", owner, repo, url.PathEscape(branch))
 	req, err := s.client.NewRequest("POST", u, users)
 	if err != nil {
 		return nil, nil, err
@@ -1984,9 +2045,11 @@ func (s *RepositoriesService) AddUserRestrictions(ctx context.Context, owner, re
 //
 // Note: The list of users, apps, and teams in total is limited to 100 items.
 //
+// Note: the branch name is URL path escaped for you. See: https://pkg.go.dev/net/url#PathEscape .
+//
 // GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#remove-team-access-restrictions
 func (s *RepositoriesService) RemoveUserRestrictions(ctx context.Context, owner, repo, branch string, users []string) ([]*User, *Response, error) {
-	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/restrictions/users", owner, repo, branch)
+	u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/restrictions/users", owner, repo, url.PathEscape(branch))
 	req, err := s.client.NewRequest("DELETE", u, users)
 	if err != nil {
 		return nil, nil, err
diff --git a/github/security_advisories.go b/github/security_advisories.go
index a75fce54..681d0cd4 100644
--- a/github/security_advisories.go
+++ b/github/security_advisories.go
@@ -12,6 +12,41 @@ import (
 
 type SecurityAdvisoriesService service
 
+// SecurityAdvisorySubmission represents the Security Advisory Submission.
+type SecurityAdvisorySubmission struct {
+	// Accepted represents whether a private vulnerability report was accepted by the repository's administrators.
+	Accepted *bool `json:"accepted,omitempty"`
+}
+
+// RepoAdvisoryCredit represents the credit object for a repository Security Advisory.
+type RepoAdvisoryCredit struct {
+	Login *string `json:"login,omitempty"`
+	Type  *string `json:"type,omitempty"`
+}
+
+// RepoAdvisoryCreditDetailed represents a credit given to a user for a repository Security Advisory.
+type RepoAdvisoryCreditDetailed struct {
+	User  *User   `json:"user,omitempty"`
+	Type  *string `json:"type,omitempty"`
+	State *string `json:"state,omitempty"`
+}
+
+// ListRepositorySecurityAdvisoriesOptions specifies the optional parameters to list the repository security advisories.
+type ListRepositorySecurityAdvisoriesOptions struct {
+	ListCursorOptions
+
+	// Direction in which to sort advisories. Possible values are: asc, desc.
+	// Default is "asc".
+	Direction string `url:"direction,omitempty"`
+
+	// Sort specifies how to sort advisories. Possible values are: created, updated,
+	// and published. Default value is "created".
+	Sort string `url:"sort,omitempty"`
+
+	// State filters advisories based on their state. Possible values are: triage, draft, published, closed.
+	State string `url:"state,omitempty"`
+}
+
 // RequestCVE requests a Common Vulnerabilities and Exposures (CVE) for a repository security advisory.
 // The ghsaID is the GitHub Security Advisory identifier of the advisory.
 //
@@ -35,3 +70,51 @@ func (s *SecurityAdvisoriesService) RequestCVE(ctx context.Context, owner, repo,
 
 	return resp, nil
 }
+
+// ListRepositorySecurityAdvisoriesForOrg lists the repository security advisories for an organization.
+//
+// GitHub API docs: https://docs.github.com/en/rest/security-advisories/repository-advisories?apiVersion=2022-11-28#list-repository-security-advisories-for-an-organization
+func (s *SecurityAdvisoriesService) ListRepositorySecurityAdvisoriesForOrg(ctx context.Context, org string, opt *ListRepositorySecurityAdvisoriesOptions) ([]*SecurityAdvisory, *Response, error) {
+	url := fmt.Sprintf("orgs/%v/security-advisories", org)
+	url, err := addOptions(url, opt)
+	if err != nil {
+		return nil, nil, err
+	}
+
+	req, err := s.client.NewRequest("GET", url, nil)
+	if err != nil {
+		return nil, nil, err
+	}
+
+	var advisories []*SecurityAdvisory
+	resp, err := s.client.Do(ctx, req, &advisories)
+	if err != nil {
+		return nil, resp, err
+	}
+
+	return advisories, resp, nil
+}
+
+// ListRepositorySecurityAdvisories lists the security advisories in a repository.
+//
+// GitHub API docs: https://docs.github.com/en/enterprise-cloud@latest/rest/security-advisories/repository-advisories?apiVersion=2022-11-28#list-repository-security-advisories
+func (s *SecurityAdvisoriesService) ListRepositorySecurityAdvisories(ctx context.Context, owner, repo string, opt *ListRepositorySecurityAdvisoriesOptions) ([]*SecurityAdvisory, *Response, error) {
+	url := fmt.Sprintf("repos/%v/%v/security-advisories", owner, repo)
+	url, err := addOptions(url, opt)
+	if err != nil {
+		return nil, nil, err
+	}
+
+	req, err := s.client.NewRequest("GET", url, nil)
+	if err != nil {
+		return nil, nil, err
+	}
+
+	var advisories []*SecurityAdvisory
+	resp, err := s.client.Do(ctx, req, &advisories)
+	if err != nil {
+		return nil, resp, err
+	}
+
+	return advisories, resp, nil
+}


Test patch:
diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go
index bdb4209a..9b3c36fd 100644
--- a/github/github-accessors_test.go
+++ b/github/github-accessors_test.go
@@ -503,6 +503,16 @@ func TestAdvisoryVulnerability_GetPackage(tt *testing.T) {
 	a.GetPackage()
 }
 
+func TestAdvisoryVulnerability_GetPatchedVersions(tt *testing.T) {
+	var zeroValue string
+	a := &AdvisoryVulnerability{PatchedVersions: &zeroValue}
+	a.GetPatchedVersions()
+	a = &AdvisoryVulnerability{}
+	a.GetPatchedVersions()
+	a = nil
+	a.GetPatchedVersions()
+}
+
 func TestAdvisoryVulnerability_GetSeverity(tt *testing.T) {
 	var zeroValue string
 	a := &AdvisoryVulnerability{Severity: &zeroValue}
@@ -4519,6 +4529,13 @@ func TestCommitCommentEvent_GetInstallation(tt *testing.T) {
 	c.GetInstallation()
 }
 
+func TestCommitCommentEvent_GetOrg(tt *testing.T) {
+	c := &CommitCommentEvent{}
+	c.GetOrg()
+	c = nil
+	c.GetOrg()
+}
+
 func TestCommitCommentEvent_GetRepo(tt *testing.T) {
 	c := &CommitCommentEvent{}
 	c.GetRepo()
@@ -5969,6 +5986,13 @@ func TestDeleteEvent_GetInstallation(tt *testing.T) {
 	d.GetInstallation()
 }
 
+func TestDeleteEvent_GetOrg(tt *testing.T) {
+	d := &DeleteEvent{}
+	d.GetOrg()
+	d = nil
+	d.GetOrg()
+}
+
 func TestDeleteEvent_GetPusherType(tt *testing.T) {
 	var zeroValue string
 	d := &DeleteEvent{PusherType: &zeroValue}
@@ -6570,6 +6594,13 @@ func TestDeploymentEvent_GetInstallation(tt *testing.T) {
 	d.GetInstallation()
 }
 
+func TestDeploymentEvent_GetOrg(tt *testing.T) {
+	d := &DeploymentEvent{}
+	d.GetOrg()
+	d = nil
+	d.GetOrg()
+}
+
 func TestDeploymentEvent_GetRepo(tt *testing.T) {
 	d := &DeploymentEvent{}
 	d.GetRepo()
@@ -6911,6 +6942,13 @@ func TestDeploymentStatusEvent_GetInstallation(tt *testing.T) {
 	d.GetInstallation()
 }
 
+func TestDeploymentStatusEvent_GetOrg(tt *testing.T) {
+	d := &DeploymentStatusEvent{}
+	d.GetOrg()
+	d = nil
+	d.GetOrg()
+}
+
 func TestDeploymentStatusEvent_GetRepo(tt *testing.T) {
 	d := &DeploymentStatusEvent{}
 	d.GetRepo()
@@ -9011,6 +9049,13 @@ func TestGollumEvent_GetInstallation(tt *testing.T) {
 	g.GetInstallation()
 }
 
+func TestGollumEvent_GetOrg(tt *testing.T) {
+	g := &GollumEvent{}
+	g.GetOrg()
+	g = nil
+	g.GetOrg()
+}
+
 func TestGollumEvent_GetRepo(tt *testing.T) {
 	g := &GollumEvent{}
 	g.GetRepo()
@@ -10059,6 +10104,13 @@ func TestInstallationEvent_GetInstallation(tt *testing.T) {
 	i.GetInstallation()
 }
 
+func TestInstallationEvent_GetOrg(tt *testing.T) {
+	i := &InstallationEvent{}
+	i.GetOrg()
+	i = nil
+	i.GetOrg()
+}
+
 func TestInstallationEvent_GetRequester(tt *testing.T) {
 	i := &InstallationEvent{}
 	i.GetRequester()
@@ -10470,6 +10522,13 @@ func TestInstallationRepositoriesEvent_GetInstallation(tt *testing.T) {
 	i.GetInstallation()
 }
 
+func TestInstallationRepositoriesEvent_GetOrg(tt *testing.T) {
+	i := &InstallationRepositoriesEvent{}
+	i.GetOrg()
+	i = nil
+	i.GetOrg()
+}
+
 func TestInstallationRepositoriesEvent_GetRepositorySelection(tt *testing.T) {
 	var zeroValue string
 	i := &InstallationRepositoriesEvent{RepositorySelection: &zeroValue}
@@ -11706,6 +11765,13 @@ func TestIssuesEvent_GetMilestone(tt *testing.T) {
 	i.GetMilestone()
 }
 
+func TestIssuesEvent_GetOrg(tt *testing.T) {
+	i := &IssuesEvent{}
+	i.GetOrg()
+	i = nil
+	i.GetOrg()
+}
+
 func TestIssuesEvent_GetRepo(tt *testing.T) {
 	i := &IssuesEvent{}
 	i.GetRepo()
@@ -12965,6 +13031,13 @@ func TestMarketplacePurchaseEvent_GetMarketplacePurchase(tt *testing.T) {
 	m.GetMarketplacePurchase()
 }
 
+func TestMarketplacePurchaseEvent_GetOrg(tt *testing.T) {
+	m := &MarketplacePurchaseEvent{}
+	m.GetOrg()
+	m = nil
+	m.GetOrg()
+}
+
 func TestMarketplacePurchaseEvent_GetPreviousMarketplacePurchase(tt *testing.T) {
 	m := &MarketplacePurchaseEvent{}
 	m.GetPreviousMarketplacePurchase()
@@ -13013,6 +13086,13 @@ func TestMemberEvent_GetMember(tt *testing.T) {
 	m.GetMember()
 }
 
+func TestMemberEvent_GetOrg(tt *testing.T) {
+	m := &MemberEvent{}
+	m.GetOrg()
+	m = nil
+	m.GetOrg()
+}
+
 func TestMemberEvent_GetRepo(tt *testing.T) {
 	m := &MemberEvent{}
 	m.GetRepo()
@@ -15620,6 +15700,13 @@ func TestPageBuildEvent_GetInstallation(tt *testing.T) {
 	p.GetInstallation()
 }
 
+func TestPageBuildEvent_GetOrg(tt *testing.T) {
+	p := &PageBuildEvent{}
+	p.GetOrg()
+	p = nil
+	p.GetOrg()
+}
+
 func TestPageBuildEvent_GetRepo(tt *testing.T) {
 	p := &PageBuildEvent{}
 	p.GetRepo()
@@ -16263,6 +16350,13 @@ func TestPersonalAccessTokenRequest_GetID(tt *testing.T) {
 	p.GetID()
 }
 
+func TestPersonalAccessTokenRequest_GetOrg(tt *testing.T) {
+	p := &PersonalAccessTokenRequest{}
+	p.GetOrg()
+	p = nil
+	p.GetOrg()
+}
+
 func TestPersonalAccessTokenRequest_GetOwner(tt *testing.T) {
 	p := &PersonalAccessTokenRequest{}
 	p.GetOwner()
@@ -17980,6 +18074,13 @@ func TestPublicEvent_GetInstallation(tt *testing.T) {
 	p.GetInstallation()
 }
 
+func TestPublicEvent_GetOrg(tt *testing.T) {
+	p := &PublicEvent{}
+	p.GetOrg()
+	p = nil
+	p.GetOrg()
+}
+
 func TestPublicEvent_GetRepo(tt *testing.T) {
 	p := &PublicEvent{}
 	p.GetRepo()
@@ -19110,6 +19211,13 @@ func TestPullRequestReviewCommentEvent_GetInstallation(tt *testing.T) {
 	p.GetInstallation()
 }
 
+func TestPullRequestReviewCommentEvent_GetOrg(tt *testing.T) {
+	p := &PullRequestReviewCommentEvent{}
+	p.GetOrg()
+	p = nil
+	p.GetOrg()
+}
+
 func TestPullRequestReviewCommentEvent_GetPullRequest(tt *testing.T) {
 	p := &PullRequestReviewCommentEvent{}
 	p.GetPullRequest()
@@ -19342,6 +19450,13 @@ func TestPullRequestReviewThreadEvent_GetInstallation(tt *testing.T) {
 	p.GetInstallation()
 }
 
+func TestPullRequestReviewThreadEvent_GetOrg(tt *testing.T) {
+	p := &PullRequestReviewThreadEvent{}
+	p.GetOrg()
+	p = nil
+	p.GetOrg()
+}
+
 func TestPullRequestReviewThreadEvent_GetPullRequest(tt *testing.T) {
 	p := &PullRequestReviewThreadEvent{}
 	p.GetPullRequest()
@@ -20530,6 +20645,13 @@ func TestReleaseEvent_GetInstallation(tt *testing.T) {
 	r.GetInstallation()
 }
 
+func TestReleaseEvent_GetOrg(tt *testing.T) {
+	r := &ReleaseEvent{}
+	r.GetOrg()
+	r = nil
+	r.GetOrg()
+}
+
 func TestReleaseEvent_GetRelease(tt *testing.T) {
 	r := &ReleaseEvent{}
 	r.GetRelease()
@@ -20611,6 +20733,53 @@ func TestRenameOrgResponse_GetURL(tt *testing.T) {
 	r.GetURL()
 }
 
+func TestRepoAdvisoryCredit_GetLogin(tt *testing.T) {
+	var zeroValue string
+	r := &RepoAdvisoryCredit{Login: &zeroValue}
+	r.GetLogin()
+	r = &RepoAdvisoryCredit{}
+	r.GetLogin()
+	r = nil
+	r.GetLogin()
+}
+
+func TestRepoAdvisoryCredit_GetType(tt *testing.T) {
+	var zeroValue string
+	r := &RepoAdvisoryCredit{Type: &zeroValue}
+	r.GetType()
+	r = &RepoAdvisoryCredit{}
+	r.GetType()
+	r = nil
+	r.GetType()
+}
+
+func TestRepoAdvisoryCreditDetailed_GetState(tt *testing.T) {
+	var zeroValue string
+	r := &RepoAdvisoryCreditDetailed{State: &zeroValue}
+	r.GetState()
+	r = &RepoAdvisoryCreditDetailed{}
+	r.GetState()
+	r = nil
+	r.GetState()
+}
+
+func TestRepoAdvisoryCreditDetailed_GetType(tt *testing.T) {
+	var zeroValue string
+	r := &RepoAdvisoryCreditDetailed{Type: &zeroValue}
+	r.GetType()
+	r = &RepoAdvisoryCreditDetailed{}
+	r.GetType()
+	r = nil
+	r.GetType()
+}
+
+func TestRepoAdvisoryCreditDetailed_GetUser(tt *testing.T) {
+	r := &RepoAdvisoryCreditDetailed{}
+	r.GetUser()
+	r = nil
+	r.GetUser()
+}
+
 func TestRepoDependencies_GetDownloadLocation(tt *testing.T) {
 	var zeroValue string
 	r := &RepoDependencies{DownloadLocation: &zeroValue}
@@ -23011,6 +23180,13 @@ func TestRepositoryVulnerabilityAlertEvent_GetInstallation(tt *testing.T) {
 	r.GetInstallation()
 }
 
+func TestRepositoryVulnerabilityAlertEvent_GetOrg(tt *testing.T) {
+	r := &RepositoryVulnerabilityAlertEvent{}
+	r.GetOrg()
+	r = nil
+	r.GetOrg()
+}
+
 func TestRepositoryVulnerabilityAlertEvent_GetRepository(tt *testing.T) {
 	r := &RepositoryVulnerabilityAlertEvent{}
 	r.GetRepository()
@@ -24572,6 +24748,43 @@ func TestSecretScanningPushProtection_GetStatus(tt *testing.T) {
 	s.GetStatus()
 }
 
+func TestSecurityAdvisory_GetAuthor(tt *testing.T) {
+	s := &SecurityAdvisory{}
+	s.GetAuthor()
+	s = nil
+	s.GetAuthor()
+}
+
+func TestSecurityAdvisory_GetClosedAt(tt *testing.T) {
+	var zeroValue Timestamp
+	s := &SecurityAdvisory{ClosedAt: &zeroValue}
+	s.GetClosedAt()
+	s = &SecurityAdvisory{}
+	s.GetClosedAt()
+	s = nil
+	s.GetClosedAt()
+}
+
+func TestSecurityAdvisory_GetCreatedAt(tt *testing.T) {
+	var zeroValue Timestamp
+	s := &SecurityAdvisory{CreatedAt: &zeroValue}
+	s.GetCreatedAt()
+	s = &SecurityAdvisory{}
+	s.GetCreatedAt()
+	s = nil
+	s.GetCreatedAt()
+}
+
+func TestSecurityAdvisory_GetCVEID(tt *testing.T) {
+	var zeroValue string
+	s := &SecurityAdvisory{CVEID: &zeroValue}
+	s.GetCVEID()
+	s = &SecurityAdvisory{}
+	s.GetCVEID()
+	s = nil
+	s.GetCVEID()
+}
+
 func TestSecurityAdvisory_GetCVSS(tt *testing.T) {
 	s := &SecurityAdvisory{}
 	s.GetCVSS()
@@ -24599,6 +24812,23 @@ func TestSecurityAdvisory_GetGHSAID(tt *testing.T) {
 	s.GetGHSAID()
 }
 
+func TestSecurityAdvisory_GetHTMLURL(tt *testing.T) {
+	var zeroValue string
+	s := &SecurityAdvisory{HTMLURL: &zeroValue}
+	s.GetHTMLURL()
+	s = &SecurityAdvisory{}
+	s.GetHTMLURL()
+	s = nil
+	s.GetHTMLURL()
+}
+
+func TestSecurityAdvisory_GetPrivateFork(tt *testing.T) {
+	s := &SecurityAdvisory{}
+	s.GetPrivateFork()
+	s = nil
+	s.GetPrivateFork()
+}
+
 func TestSecurityAdvisory_GetPublishedAt(tt *testing.T) {
 	var zeroValue Timestamp
 	s := &SecurityAdvisory{PublishedAt: &zeroValue}
@@ -24609,6 +24839,13 @@ func TestSecurityAdvisory_GetPublishedAt(tt *testing.T) {
 	s.GetPublishedAt()
 }
 
+func TestSecurityAdvisory_GetPublisher(tt *testing.T) {
+	s := &SecurityAdvisory{}
+	s.GetPublisher()
+	s = nil
+	s.GetPublisher()
+}
+
 func TestSecurityAdvisory_GetSeverity(tt *testing.T) {
 	var zeroValue string
 	s := &SecurityAdvisory{Severity: &zeroValue}
@@ -24619,6 +24856,23 @@ func TestSecurityAdvisory_GetSeverity(tt *testing.T) {
 	s.GetSeverity()
 }
 
+func TestSecurityAdvisory_GetState(tt *testing.T) {
+	var zeroValue string
+	s := &SecurityAdvisory{State: &zeroValue}
+	s.GetState()
+	s = &SecurityAdvisory{}
+	s.GetState()
+	s = nil
+	s.GetState()
+}
+
+func TestSecurityAdvisory_GetSubmission(tt *testing.T) {
+	s := &SecurityAdvisory{}
+	s.GetSubmission()
+	s = nil
+	s.GetSubmission()
+}
+
 func TestSecurityAdvisory_GetSummary(tt *testing.T) {
 	var zeroValue string
 	s := &SecurityAdvisory{Summary: &zeroValue}
@@ -24639,6 +24893,16 @@ func TestSecurityAdvisory_GetUpdatedAt(tt *testing.T) {
 	s.GetUpdatedAt()
 }
 
+func TestSecurityAdvisory_GetURL(tt *testing.T) {
+	var zeroValue string
+	s := &SecurityAdvisory{URL: &zeroValue}
+	s.GetURL()
+	s = &SecurityAdvisory{}
+	s.GetURL()
+	s = nil
+	s.GetURL()
+}
+
 func TestSecurityAdvisory_GetWithdrawnAt(tt *testing.T) {
 	var zeroValue Timestamp
 	s := &SecurityAdvisory{WithdrawnAt: &zeroValue}
@@ -24701,6 +24965,16 @@ func TestSecurityAdvisoryEvent_GetSender(tt *testing.T) {
 	s.GetSender()
 }
 
+func TestSecurityAdvisorySubmission_GetAccepted(tt *testing.T) {
+	var zeroValue bool
+	s := &SecurityAdvisorySubmission{Accepted: &zeroValue}
+	s.GetAccepted()
+	s = &SecurityAdvisorySubmission{}
+	s.GetAccepted()
+	s = nil
+	s.GetAccepted()
+}
+
 func TestSecurityAndAnalysis_GetAdvancedSecurity(tt *testing.T) {
 	s := &SecurityAndAnalysis{}
 	s.GetAdvancedSecurity()
@@ -25165,6 +25439,13 @@ func TestStatusEvent_GetName(tt *testing.T) {
 	s.GetName()
 }
 
+func TestStatusEvent_GetOrg(tt *testing.T) {
+	s := &StatusEvent{}
+	s.GetOrg()
+	s = nil
+	s.GetOrg()
+}
+
 func TestStatusEvent_GetRepo(tt *testing.T) {
 	s := &StatusEvent{}
 	s.GetRepo()
@@ -27925,6 +28206,13 @@ func TestWatchEvent_GetInstallation(tt *testing.T) {
 	w.GetInstallation()
 }
 
+func TestWatchEvent_GetOrg(tt *testing.T) {
+	w := &WatchEvent{}
+	w.GetOrg()
+	w = nil
+	w.GetOrg()
+}
+
 func TestWatchEvent_GetRepo(tt *testing.T) {
 	w := &WatchEvent{}
 	w.GetRepo()
diff --git a/github/repos_test.go b/github/repos_test.go
index 6aba962a..7486e488 100644
--- a/github/repos_test.go
+++ b/github/repos_test.go
@@ -919,51 +919,73 @@ func TestRepositoriesService_GetBranch(t *testing.T) {
 	client, mux, _, teardown := setup()
 	defer teardown()
 
-	mux.HandleFunc("/repos/o/r/branches/b", func(w http.ResponseWriter, r *http.Request) {
-		testMethod(t, r, "GET")
-		fmt.Fprint(w, `{"name":"n", "commit":{"sha":"s","commit":{"message":"m"}}, "protected":true}`)
-	})
+	tests := []struct {
+		branch  string
+		urlPath string
+	}{
+		{branch: "b", urlPath: "/repos/o/r/branches/b"},
+		{branch: "feat/branch-50%", urlPath: "/repos/o/r/branches/feat/branch-50%"},
+	}
+
+	for _, test := range tests {
+		mux.HandleFunc(test.urlPath, func(w http.ResponseWriter, r *http.Request) {
+			testMethod(t, r, "GET")
+			fmt.Fprint(w, `{"name":"n", "commit":{"sha":"s","commit":{"message":"m"}}, "protected":true}`)
+		})
 
-	ctx := context.Background()
-	branch, _, err := client.Repositories.GetBranch(ctx, "o", "r", "b", 0)
-	if err != nil {
-		t.Errorf("Repositories.GetBranch returned error: %v", err)
-	}
+		ctx := context.Background()
+		branch, _, err := client.Repositories.GetBranch(ctx, "o", "r", test.branch, 0)
+		if err != nil {
+			t.Errorf("Repositories.GetBranch returned error: %v", err)
+		}
 
-	want := &Branch{
-		Name: String("n"),
-		Commit: &RepositoryCommit{
-			SHA: String("s"),
-			Commit: &Commit{
-				Message: String("m"),
+		want := &Branch{
+			Name: String("n"),
+			Commit: &RepositoryCommit{
+				SHA: String("s"),
+				Commit: &Commit{
+					Message: String("m"),
+				},
 			},
-		},
-		Protected: Bool(true),
-	}
+			Protected: Bool(true),
+		}
 
-	if !cmp.Equal(branch, want) {
-		t.Errorf("Repositories.GetBranch returned %+v, want %+v", branch, want)
-	}
+		if !cmp.Equal(branch, want) {
+			t.Errorf("Repositories.GetBranch returned %+v, want %+v", branch, want)
+		}
 
-	const methodName = "GetBranch"
-	testBadOptions(t, methodName, func() (err error) {
-		_, _, err = client.Repositories.GetBranch(ctx, "\n", "\n", "\n", 0)
-		return err
-	})
+		const methodName = "GetBranch"
+		testBadOptions(t, methodName, func() (err error) {
+			_, _, err = client.Repositories.GetBranch(ctx, "\n", "\n", "\n", 0)
+			return err
+		})
+	}
 }
 
 func TestRepositoriesService_GetBranch_BadJSONResponse(t *testing.T) {
-	client, mux, _, teardown := setup()
-	defer teardown()
-
-	mux.HandleFunc("/repos/o/r/branches/b", func(w http.ResponseWriter, r *http.Request) {
-		testMethod(t, r, "GET")
-		fmt.Fprint(w, `{"name":"n", "commit":{"sha":...truncated`)
-	})
-
-	ctx := context.Background()
-	if _, _, err := client.Repositories.GetBranch(ctx, "o", "r", "b", 0); err == nil {
-		t.Error("Repositories.GetBranch returned no error; wanted JSON error")
+	tests := []struct {
+		branch  string
+		urlPath string
+	}{
+		{branch: "b", urlPath: "/repos/o/r/branches/b"},
+		{branch: "feat/branch-50%", urlPath: "/repos/o/r/branches/feat/branch-50%"},
+	}
+
+	for _, test := range tests {
+		t.Run(test.branch, func(t *testing.T) {
+			client, mux, _, teardown := setup()
+			defer teardown()
+
+			mux.HandleFunc(test.urlPath, func(w http.ResponseWriter, r *http.Request) {
+				testMethod(t, r, "GET")
+				fmt.Fprint(w, `{"name":"n", "commit":{"sha":...truncated`)
+			})
+
+			ctx := context.Background()
+			if _, _, err := client.Repositories.GetBranch(ctx, "o", "r", test.branch, 0); err == nil {
+				t.Error("Repositories.GetBranch returned no error; wanted JSON error")
+			}
+		})
 	}
 }
 
@@ -1005,492 +1027,1013 @@ func TestRepositoriesService_GetBranch_StatusMovedPermanently_followRedirects(t
 }
 
 func TestRepositoriesService_GetBranch_notFound(t *testing.T) {
-	client, mux, _, teardown := setup()
-	defer teardown()
+	tests := []struct {
+		branch  string
+		urlPath string
+	}{
+		{branch: "b", urlPath: "/repos/o/r/branches/b"},
+		{branch: "feat/branch-50%", urlPath: "/repos/o/r/branches/feat-branch-50%"},
+	}
+
+	for _, test := range tests {
+		t.Run(test.branch, func(t *testing.T) {
+			client, mux, _, teardown := setup()
+			defer teardown()
+
+			mux.HandleFunc(test.urlPath, func(w http.ResponseWriter, r *http.Request) {
+				testMethod(t, r, "GET")
+				http.Error(w, "branch not found", http.StatusNotFound)
+			})
+			ctx := context.Background()
+			_, resp, err := client.Repositories.GetBranch(ctx, "o", "r", test.branch, 1)
+			if err == nil {
+				t.Error("Repositories.GetBranch returned error: nil")
+			}
+			if resp.StatusCode != http.StatusNotFound {
+				t.Errorf("Repositories.GetBranch returned status: %d, want %d", resp.StatusCode, http.StatusNotFound)
+			}
 
-	mux.HandleFunc("/repos/o/r/branches/b", func(w http.ResponseWriter, r *http.Request) {
-		testMethod(t, r, "GET")
-		http.Error(w, "branch not found", http.StatusNotFound)
-	})
-	ctx := context.Background()
-	_, resp, err := client.Repositories.GetBranch(ctx, "o", "r", "b", 1)
-	if err == nil {
-		t.Error("Repositories.GetBranch returned error: nil")
+			// Add custom round tripper
+			client.client.Transport = roundTripperFunc(func(r *http.Request) (*http.Response, error) {
+				return nil, errors.New("failed to get branch")
+			})
+
+			const methodName = "GetBranch"
+			testBadOptions(t, methodName, func() (err error) {
+				_, _, err = client.Repositories.GetBranch(ctx, "\n", "\n", "\n", 1)
+				return err
+			})
+		})
 	}
-	if resp.StatusCode != http.StatusNotFound {
-		t.Errorf("Repositories.GetBranch returned status: %d, want %d", resp.StatusCode, http.StatusNotFound)
+}
+
+func TestRepositoriesService_RenameBranch(t *testing.T) {
+	tests := []struct {
+		branch  string
+		urlPath string
+	}{
+		{branch: "b", urlPath: "/repos/o/r/branches/b/rename"},
+		{branch: "feat/branch-50%", urlPath: "/repos/o/r/branches/feat/branch-50%/rename"},
 	}
 
-	// Add custom round tripper
-	client.client.Transport = roundTripperFunc(func(r *http.Request) (*http.Response, error) {
-		return nil, errors.New("failed to get branch")
-	})
+	for _, test := range tests {
+		t.Run(test.branch, func(t *testing.T) {
+			client, mux, _, teardown := setup()
+			defer teardown()
 
-	const methodName = "GetBranch"
-	testBadOptions(t, methodName, func() (err error) {
-		_, _, err = client.Repositories.GetBranch(ctx, "\n", "\n", "\n", 1)
-		return err
-	})
-}
+			renameBranchReq := "nn"
 
-func TestRepositoriesService_RenameBranch(t *testing.T) {
-	client, mux, _, teardown := setup()
-	defer teardown()
+			mux.HandleFunc(test.urlPath, func(w http.ResponseWriter, r *http.Request) {
+				v := new(renameBranchRequest)
+				assertNilError(t, json.NewDecoder(r.Body).Decode(v))
 
-	renameBranchReq := "nn"
+				testMethod(t, r, "POST")
+				want := &renameBranchRequest{NewName: renameBranchReq}
+				if !cmp.Equal(v, want) {
+					t.Errorf("Request body = %+v, want %+v", v, want)
+				}
 
-	mux.HandleFunc("/repos/o/r/branches/b/rename", func(w http.ResponseWriter, r *http.Request) {
-		v := new(renameBranchRequest)
-		assertNilError(t, json.NewDecoder(r.Body).Decode(v))
+				fmt.Fprint(w, `{"protected":true,"name":"nn"}`)
+			})
 
-		testMethod(t, r, "POST")
-		want := &renameBranchRequest{NewName: "nn"}
-		if !cmp.Equal(v, want) {
-			t.Errorf("Request body = %+v, want %+v", v, want)
-		}
+			ctx := context.Background()
+			got, _, err := client.Repositories.RenameBranch(ctx, "o", "r", test.branch, renameBranchReq)
+			if err != nil {
+				t.Errorf("Repositories.RenameBranch returned error: %v", err)
+			}
 
-		fmt.Fprint(w, `{"protected":true,"name":"nn"}`)
-	})
+			want := &Branch{Name: String("nn"), Protected: Bool(true)}
+			if !cmp.Equal(got, want) {
+				t.Errorf("Repositories.RenameBranch returned %+v, want %+v", got, want)
+			}
 
-	ctx := context.Background()
-	got, _, err := client.Repositories.RenameBranch(ctx, "o", "r", "b", renameBranchReq)
-	if err != nil {
-		t.Errorf("Repositories.RenameBranch returned error: %v", err)
-	}
+			const methodName = "RenameBranch"
+			testBadOptions(t, methodName, func() (err error) {
+				_, _, err = client.Repositories.RenameBranch(ctx, "\n", "\n", "\n", renameBranchReq)
+				return err
+			})
 
-	want := &Branch{Name: String("nn"), Protected: Bool(true)}
-	if !cmp.Equal(got, want) {
-		t.Errorf("Repositories.RenameBranch returned %+v, want %+v", got, want)
+			testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
+				got, resp, err := client.Repositories.RenameBranch(ctx, "o", "r", test.branch, renameBranchReq)
+				if got != nil {
+					t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
+				}
+				return resp, err
+			})
+		})
 	}
+}
 
-	const methodName = "RenameBranch"
-	testBadOptions(t, methodName, func() (err error) {
-		_, _, err = client.Repositories.RenameBranch(ctx, "\n", "\n", "\n", renameBranchReq)
-		return err
-	})
+func TestRepositoriesService_GetBranchProtection(t *testing.T) {
+	tests := []struct {
+		branch               string
+		urlPath              string
+		enforceAdminsURLPath string
+	}{
+		{branch: "b", urlPath: "/repos/o/r/branches/b/protection", enforceAdminsURLPath: "/repos/o/r/branches/b/protection/enforce_admins"},
+		{branch: "feat/branch-50%", urlPath: "/repos/o/r/branches/feat/branch-50%/protection", enforceAdminsURLPath: "/repos/o/r/branches/feat/branch-50%/protection/enforce_admins"},
+	}
+
+	for _, test := range tests {
+		t.Run(test.branch, func(t *testing.T) {
+			client, mux, _, teardown := setup()
+			defer teardown()
+
+			mux.HandleFunc(test.urlPath, func(w http.ResponseWriter, r *http.Request) {
+				testMethod(t, r, "GET")
+				// TODO: remove custom Accept header when this API fully launches
+				testHeader(t, r, "Accept", mediaTypeRequiredApprovingReviewsPreview)
+				fmt.Fprintf(w, `{
+						"required_status_checks":{
+							"strict":true,
+							"contexts":["continuous-integration"],
+							"checks": [
+								{
+									"context": "continuous-integration",
+									"app_id": null
+								}
+							]
+						},
+						"required_pull_request_reviews":{
+							"dismissal_restrictions":{
+								"users":[{
+									"id":3,
+									"login":"u"
+								}],
+								"teams":[{
+									"id":4,
+									"slug":"t"
+								}],
+								"apps":[{
+									"id":5,
+									"slug":"a"
+								}]
+							},
+							"dismiss_stale_reviews":true,
+							"require_code_owner_reviews":true,
+							"require_last_push_approval":false,
+							"required_approving_review_count":1
+							},
+							"enforce_admins":{
+								"url":"%s",
+								"enabled":true
+							},
+							"restrictions":{
+								"users":[{"id":1,"login":"u"}],
+								"teams":[{"id":2,"slug":"t"}],
+								"apps":[{"id":3,"slug":"a"}]
+							},
+							"required_conversation_resolution": {
+								"enabled": true
+							},
+							"block_creations": {
+								"enabled": false
+							},
+							"lock_branch": {
+								"enabled": false
+							},
+							"allow_fork_syncing": {
+								"enabled": false
+							}
+						}`, test.enforceAdminsURLPath)
+			})
+
+			ctx := context.Background()
+			protection, _, err := client.Repositories.GetBranchProtection(ctx, "o", "r", test.branch)
+			if err != nil {
+				t.Errorf("Repositories.GetBranchProtection returned error: %v", err)
+			}
 
-	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
-		got, resp, err := client.Repositories.RenameBranch(ctx, "o", "r", "b", renameBranchReq)
-		if got != nil {
-			t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
-		}
-		return resp, err
-	})
+			want := &Protection{
+				RequiredStatusChecks: &RequiredStatusChecks{
+					Strict:   true,
+					Contexts: []string{"continuous-integration"},
+					Checks: []*RequiredStatusCheck{
+						{
+							Context: "continuous-integration",
+						},
+					},
+				},
+				RequiredPullRequestReviews: &PullRequestReviewsEnforcement{
+					DismissStaleReviews: true,
+					DismissalRestrictions: &DismissalRestrictions{
+						Users: []*User{
+							{Login: String("u"), ID: Int64(3)},
+						},
+						Teams: []*Team{
+							{Slug: String("t"), ID: Int64(4)},
+						},
+						Apps: []*App{
+							{Slug: String("a"), ID: Int64(5)},
+						},
+					},
+					RequireCodeOwnerReviews:      true,
+					RequiredApprovingReviewCount: 1,
+					RequireLastPushApproval:      false,
+				},
+				EnforceAdmins: &AdminEnforcement{
+					URL:     String(test.enforceAdminsURLPath),
+					Enabled: true,
+				},
+				Restrictions: &BranchRestrictions{
+					Users: []*User{
+						{Login: String("u"), ID: Int64(1)},
+					},
+					Teams: []*Team{
+						{Slug: String("t"), ID: Int64(2)},
+					},
+					Apps: []*App{
+						{Slug: String("a"), ID: Int64(3)},
+					},
+				},
+				RequiredConversationResolution: &RequiredConversationResolution{
+					Enabled: true,
+				},
+				BlockCreations: &BlockCreations{
+					Enabled: Bool(false),
+				},
+				LockBranch: &LockBranch{
+					Enabled: Bool(false),
+				},
+				AllowForkSyncing: &AllowForkSyncing{
+					Enabled: Bool(false),
+				},
+			}
+			if !cmp.Equal(protection, want) {
+				t.Errorf("Repositories.GetBranchProtection returned %+v, want %+v", protection, want)
+			}
+
+			const methodName = "GetBranchProtection"
+			testBadOptions(t, methodName, func() (err error) {
+				_, _, err = client.Repositories.GetBranchProtection(ctx, "\n", "\n", "\n")
+				return err
+			})
+
+			testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
+				got, resp, err := client.Repositories.GetBranchProtection(ctx, "o", "r", test.branch)
+				if got != nil {
+					t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
+				}
+				return resp, err
+			})
+		})
+	}
 }
 
-func TestRepositoriesService_GetBranchProtection(t *testing.T) {
+func TestRepositoriesService_GetBranchProtection_noDismissalRestrictions(t *testing.T) {
 	client, mux, _, teardown := setup()
 	defer teardown()
 
-	mux.HandleFunc("/repos/o/r/branches/b/protection", func(w http.ResponseWriter, r *http.Request) {
-		testMethod(t, r, "GET")
-		// TODO: remove custom Accept header when this API fully launches
-		testHeader(t, r, "Accept", mediaTypeRequiredApprovingReviewsPreview)
-		fmt.Fprintf(w, `{
-				"required_status_checks":{
-					"strict":true,
-					"contexts":["continuous-integration"],
-					"checks": [
-						{
-							"context": "continuous-integration",
-							"app_id": null
+	tests := []struct {
+		branch               string
+		urlPath              string
+		enforceAdminsURLPath string
+	}{
+		{branch: "b", urlPath: "/repos/o/r/branches/b/protection", enforceAdminsURLPath: "/repos/o/r/branches/b/protection/enforce_admins"},
+		{branch: "feat/branch-50%", urlPath: "/repos/o/r/branches/feat/branch-50%/protection", enforceAdminsURLPath: "/repos/o/r/branches/feat/branch-50%/protection/enforce_admins"},
+	}
+
+	for _, test := range tests {
+		mux.HandleFunc(test.urlPath, func(w http.ResponseWriter, r *http.Request) {
+			testMethod(t, r, "GET")
+			// TODO: remove custom Accept header when this API fully launches
+			testHeader(t, r, "Accept", mediaTypeRequiredApprovingReviewsPreview)
+			fmt.Fprintf(w, `{
+					"required_status_checks":{
+						"strict":true,
+						"contexts":["continuous-integration"],
+						"checks": [
+							{
+								"context": "continuous-integration",
+								"app_id": null
+							}
+						]
+					},
+					"required_pull_request_reviews":{
+						"dismiss_stale_reviews":true,
+						"require_code_owner_reviews":true,
+						"required_approving_review_count":1
+						},
+						"enforce_admins":{
+							"url":"%s",
+							"enabled":true
+						},
+						"restrictions":{
+							"users":[{"id":1,"login":"u"}],
+							"teams":[{"id":2,"slug":"t"}]
 						}
-					]
+					}`, test.enforceAdminsURLPath)
+		})
+
+		ctx := context.Background()
+		protection, _, err := client.Repositories.GetBranchProtection(ctx, "o", "r", test.branch)
+		if err != nil {
+			t.Errorf("Repositories.GetBranchProtection returned error: %v", err)
+		}
+
+		want := &Protection{
+			RequiredStatusChecks: &RequiredStatusChecks{
+				Strict:   true,
+				Contexts: []string{"continuous-integration"},
+				Checks: []*RequiredStatusCheck{
+					{
+						Context: "continuous-integration",
+					},
 				},
-				"required_pull_request_reviews":{
-					"dismissal_restrictions":{
-						"users":[{
-							"id":3,
-							"login":"u"
-						}],
-						"teams":[{
-							"id":4,
-							"slug":"t"
-						}],
-						"apps":[{
-							"id":5,
-							"slug":"a"
-						}]
+			},
+			RequiredPullRequestReviews: &PullRequestReviewsEnforcement{
+				DismissStaleReviews:          true,
+				DismissalRestrictions:        nil,
+				RequireCodeOwnerReviews:      true,
+				RequiredApprovingReviewCount: 1,
+			},
+			EnforceAdmins: &AdminEnforcement{
+				URL:     String(test.enforceAdminsURLPath),
+				Enabled: true,
+			},
+			Restrictions: &BranchRestrictions{
+				Users: []*User{
+					{Login: String("u"), ID: Int64(1)},
+				},
+				Teams: []*Team{
+					{Slug: String("t"), ID: Int64(2)},
+				},
+			},
+		}
+		if !cmp.Equal(protection, want) {
+			t.Errorf("Repositories.GetBranchProtection returned %+v, want %+v", protection, want)
+		}
+	}
+}
+
+func TestRepositoriesService_GetBranchProtection_branchNotProtected(t *testing.T) {
+	tests := []struct {
+		branch  string
+		urlPath string
+	}{
+		{branch: "b", urlPath: "/repos/o/r/branches/b/protection"},
+		{branch: "feat/branch-50%", urlPath: "/repos/o/r/branches/feat/branch-50%/protection"},
+	}
+
+	for _, test := range tests {
+		t.Run(test.branch, func(t *testing.T) {
+			client, mux, _, teardown := setup()
+			defer teardown()
+
+			mux.HandleFunc(test.urlPath, func(w http.ResponseWriter, r *http.Request) {
+				testMethod(t, r, "GET")
+
+				w.WriteHeader(http.StatusBadRequest)
+				fmt.Fprintf(w, `{
+					"message": %q,
+					"documentation_url": "https://docs.github.com/rest/repos#get-branch-protection"
+					}`, githubBranchNotProtected)
+			})
+
+			ctx := context.Background()
+			protection, _, err := client.Repositories.GetBranchProtection(ctx, "o", "r", test.branch)
+
+			if protection != nil {
+				t.Errorf("Repositories.GetBranchProtection returned non-nil protection data")
+			}
+
+			if err != ErrBranchNotProtected {
+				t.Errorf("Repositories.GetBranchProtection returned an invalid error: %v", err)
+			}
+		})
+	}
+}
+
+func TestRepositoriesService_UpdateBranchProtection_Contexts(t *testing.T) {
+	tests := []struct {
+		branch  string
+		urlPath string
+	}{
+		{branch: "b", urlPath: "/repos/o/r/branches/b/protection"},
+		{branch: "feat/branch-50%", urlPath: "/repos/o/r/branches/feat/branch-50%/protection"},
+	}
+
+	for _, test := range tests {
+		t.Run(test.branch, func(t *testing.T) {
+			client, mux, _, teardown := setup()
+			defer teardown()
+
+			input := &ProtectionRequest{
+				RequiredStatusChecks: &RequiredStatusChecks{
+					Strict:   true,
+					Contexts: []string{"continuous-integration"},
+				},
+				RequiredPullRequestReviews: &PullRequestReviewsEnforcementRequest{
+					DismissStaleReviews: true,
+					DismissalRestrictionsRequest: &DismissalRestrictionsRequest{
+						Users: &[]string{"uu"},
+						Teams: &[]string{"tt"},
+						Apps:  &[]string{"aa"},
 					},
-					"dismiss_stale_reviews":true,
-					"require_code_owner_reviews":true,
-					"require_last_push_approval":false,
-					"required_approving_review_count":1
+					BypassPullRequestAllowancesRequest: &BypassPullRequestAllowancesRequest{
+						Users: []string{"uuu"},
+						Teams: []string{"ttt"},
+						Apps:  []string{"aaa"},
+					},
+				},
+				Restrictions: &BranchRestrictionsRequest{
+					Users: []string{"u"},
+					Teams: []string{"t"},
+					Apps:  []string{"a"},
+				},
+				BlockCreations:   Bool(true),
+				LockBranch:       Bool(true),
+				AllowForkSyncing: Bool(true),
+			}
+
+			mux.HandleFunc(test.urlPath, func(w http.ResponseWriter, r *http.Request) {
+				v := new(ProtectionRequest)
+				assertNilError(t, json.NewDecoder(r.Body).Decode(v))
+
+				testMethod(t, r, "PUT")
+				if !cmp.Equal(v, input) {
+					t.Errorf("Request body = %+v, want %+v", v, input)
+				}
+
+				// TODO: remove custom Accept header when this API fully launches
+				testHeader(t, r, "Accept", mediaTypeRequiredApprovingReviewsPreview)
+				fmt.Fprintf(w, `{
+					"required_status_checks":{
+						"strict":true,
+						"contexts":["continuous-integration"],
+						"checks": [
+							{
+								"context": "continuous-integration",
+								"app_id": null
+							}
+						]
 					},
-					"enforce_admins":{
-						"url":"/repos/o/r/branches/b/protection/enforce_admins",
-						"enabled":true
+					"required_pull_request_reviews":{
+						"dismissal_restrictions":{
+							"users":[{
+								"id":3,
+								"login":"uu"
+							}],
+							"teams":[{
+								"id":4,
+								"slug":"tt"
+							}],
+							"apps":[{
+								"id":5,
+								"slug":"aa"
+							}]
+						},
+						"dismiss_stale_reviews":true,
+						"require_code_owner_reviews":true,
+						"bypass_pull_request_allowances": {
+							"users":[{"id":10,"login":"uuu"}],
+							"teams":[{"id":20,"slug":"ttt"}],
+							"apps":[{"id":30,"slug":"aaa"}]
+						}
 					},
 					"restrictions":{
 						"users":[{"id":1,"login":"u"}],
 						"teams":[{"id":2,"slug":"t"}],
 						"apps":[{"id":3,"slug":"a"}]
 					},
-					"required_conversation_resolution": {
-						"enabled": true
-					},
 					"block_creations": {
-						"enabled": false
+						"enabled": true
 					},
 					"lock_branch": {
-						"enabled": false
+						"enabled": true
 					},
 					"allow_fork_syncing": {
-						"enabled": false
+						"enabled": true
 					}
 				}`)
-	})
+			})
 
-	ctx := context.Background()
-	protection, _, err := client.Repositories.GetBranchProtection(ctx, "o", "r", "b")
-	if err != nil {
-		t.Errorf("Repositories.GetBranchProtection returned error: %v", err)
-	}
+			ctx := context.Background()
+			protection, _, err := client.Repositories.UpdateBranchProtection(ctx, "o", "r", test.branch, input)
+			if err != nil {
+				t.Errorf("Repositories.UpdateBranchProtection returned error: %v", err)
+			}
 
-	want := &Protection{
-		RequiredStatusChecks: &RequiredStatusChecks{
-			Strict:   true,
-			Contexts: []string{"continuous-integration"},
-			Checks: []*RequiredStatusCheck{
-				{
-					Context: "continuous-integration",
+			want := &Protection{
+				RequiredStatusChecks: &RequiredStatusChecks{
+					Strict:   true,
+					Contexts: []string{"continuous-integration"},
+					Checks: []*RequiredStatusCheck{
+						{
+							Context: "continuous-integration",
+						},
+					},
 				},
-			},
-		},
-		RequiredPullRequestReviews: &PullRequestReviewsEnforcement{
-			DismissStaleReviews: true,
-			DismissalRestrictions: &DismissalRestrictions{
-				Users: []*User{
-					{Login: String("u"), ID: Int64(3)},
+				RequiredPullRequestReviews: &PullRequestReviewsEnforcement{
+					DismissStaleReviews: true,
+					DismissalRestrictions: &DismissalRestrictions{
+						Users: []*User{
+							{Login: String("uu"), ID: Int64(3)},
+						},
+						Teams: []*Team{
+							{Slug: String("tt"), ID: Int64(4)},
+						},
+						Apps: []*App{
+							{Slug: String("aa"), ID: Int64(5)},
+						},
+					},
+					RequireCodeOwnerReviews: true,
+					BypassPullRequestAllowances: &BypassPullRequestAllowances{
+						Users: []*User{
+							{Login: String("uuu"), ID: Int64(10)},
+						},
+						Teams: []*Team{
+							{Slug: String("ttt"), ID: Int64(20)},
+						},
+						Apps: []*App{
+							{Slug: String("aaa"), ID: Int64(30)},
+						},
+					},
 				},
-				Teams: []*Team{
-					{Slug: String("t"), ID: Int64(4)},
+				Restrictions: &BranchRestrictions{
+					Users: []*User{
+						{Login: String("u"), ID: Int64(1)},
+					},
+					Teams: []*Team{
+						{Slug: String("t"), ID: Int64(2)},
+					},
+					Apps: []*App{
+						{Slug: String("a"), ID: Int64(3)},
+					},
 				},
-				Apps: []*App{
-					{Slug: String("a"), ID: Int64(5)},
+				BlockCreations: &BlockCreations{
+					Enabled: Bool(true),
 				},
-			},
-			RequireCodeOwnerReviews:      true,
-			RequiredApprovingReviewCount: 1,
-			RequireLastPushApproval:      false,
-		},
-		EnforceAdmins: &AdminEnforcement{
-			URL:     String("/repos/o/r/branches/b/protection/enforce_admins"),
-			Enabled: true,
-		},
-		Restrictions: &BranchRestrictions{
-			Users: []*User{
-				{Login: String("u"), ID: Int64(1)},
-			},
-			Teams: []*Team{
-				{Slug: String("t"), ID: Int64(2)},
-			},
-			Apps: []*App{
-				{Slug: String("a"), ID: Int64(3)},
-			},
-		},
-		RequiredConversationResolution: &RequiredConversationResolution{
-			Enabled: true,
-		},
-		BlockCreations: &BlockCreations{
-			Enabled: Bool(false),
-		},
-		LockBranch: &LockBranch{
-			Enabled: Bool(false),
-		},
-		AllowForkSyncing: &AllowForkSyncing{
-			Enabled: Bool(false),
-		},
-	}
-	if !cmp.Equal(protection, want) {
-		t.Errorf("Repositories.GetBranchProtection returned %+v, want %+v", protection, want)
-	}
+				LockBranch: &LockBranch{
+					Enabled: Bool(true),
+				},
+				AllowForkSyncing: &AllowForkSyncing{
+					Enabled: Bool(true),
+				},
+			}
+			if !cmp.Equal(protection, want) {
+				t.Errorf("Repositories.UpdateBranchProtection returned %+v, want %+v", protection, want)
+			}
 
-	const methodName = "GetBranchProtection"
-	testBadOptions(t, methodName, func() (err error) {
-		_, _, err = client.Repositories.GetBranchProtection(ctx, "\n", "\n", "\n")
-		return err
-	})
+			const methodName = "UpdateBranchProtection"
+			testBadOptions(t, methodName, func() (err error) {
+				_, _, err = client.Repositories.UpdateBranchProtection(ctx, "\n", "\n", "\n", input)
+				return err
+			})
 
-	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
-		got, resp, err := client.Repositories.GetBranchProtection(ctx, "o", "r", "b")
-		if got != nil {
-			t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
-		}
-		return resp, err
-	})
+			testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
+				got, resp, err := client.Repositories.UpdateBranchProtection(ctx, "o", "r", test.branch, input)
+				if got != nil {
+					t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
+				}
+				return resp, err
+			})
+		})
+	}
 }
 
-func TestRepositoriesService_GetBranchProtection_noDismissalRestrictions(t *testing.T) {
-	client, mux, _, teardown := setup()
-	defer teardown()
-
-	mux.HandleFunc("/repos/o/r/branches/b/protection", func(w http.ResponseWriter, r *http.Request) {
-		testMethod(t, r, "GET")
-		// TODO: remove custom Accept header when this API fully launches
-		testHeader(t, r, "Accept", mediaTypeRequiredApprovingReviewsPreview)
-		fmt.Fprintf(w, `{
-				"required_status_checks":{
-					"strict":true,
-					"contexts":["continuous-integration"],
-					"checks": [
+func TestRepositoriesService_UpdateBranchProtection_Checks(t *testing.T) {
+	tests := []struct {
+		branch  string
+		urlPath string
+	}{
+		{branch: "b", urlPath: "/repos/o/r/branches/b/protection"},
+		{branch: "feat/branch-50%", urlPath: "/repos/o/r/branches/feat/branch-50%/protection"},
+	}
+
+	for _, test := range tests {
+		t.Run(test.branch, func(t *testing.T) {
+			client, mux, _, teardown := setup()
+			defer teardown()
+
+			input := &ProtectionRequest{
+				RequiredStatusChecks: &RequiredStatusChecks{
+					Strict: true,
+					Checks: []*RequiredStatusCheck{
 						{
-							"context": "continuous-integration",
-							"app_id": null
-						}
-					]
+							Context: "continuous-integration",
+						},
+					},
 				},
-				"required_pull_request_reviews":{
-					"dismiss_stale_reviews":true,
-					"require_code_owner_reviews":true,
-					"required_approving_review_count":1
+				RequiredPullRequestReviews: &PullRequestReviewsEnforcementRequest{
+					DismissStaleReviews: true,
+					DismissalRestrictionsRequest: &DismissalRestrictionsRequest{
+						Users: &[]string{"uu"},
+						Teams: &[]string{"tt"},
+						Apps:  &[]string{"aa"},
+					},
+					BypassPullRequestAllowancesRequest: &BypassPullRequestAllowancesRequest{
+						Users: []string{"uuu"},
+						Teams: []string{"ttt"},
+						Apps:  []string{"aaa"},
+					},
+				},
+				Restrictions: &BranchRestrictionsRequest{
+					Users: []string{"u"},
+					Teams: []string{"t"},
+					Apps:  []string{"a"},
+				},
+			}
+
+			mux.HandleFunc(test.urlPath, func(w http.ResponseWriter, r *http.Request) {
+				v := new(ProtectionRequest)
+				assertNilError(t, json.NewDecoder(r.Body).Decode(v))
+
+				testMethod(t, r, "PUT")
+				if !cmp.Equal(v, input) {
+					t.Errorf("Request body = %+v, want %+v", v, input)
+				}
+
+				// TODO: remove custom Accept header when this API fully launches
+				testHeader(t, r, "Accept", mediaTypeRequiredApprovingReviewsPreview)
+				fmt.Fprintf(w, `{
+					"required_status_checks":{
+						"strict":true,
+						"contexts":["continuous-integration"],
+						"checks": [
+							{
+								"context": "continuous-integration",
+								"app_id": null
+							}
+						]
 					},
-					"enforce_admins":{
-						"url":"/repos/o/r/branches/b/protection/enforce_admins",
-						"enabled":true
+					"required_pull_request_reviews":{
+						"dismissal_restrictions":{
+							"users":[{
+								"id":3,
+								"login":"uu"
+							}],
+							"teams":[{
+								"id":4,
+								"slug":"tt"
+							}],
+							"apps":[{
+								"id":5,
+								"slug":"aa"
+							}]
+						},
+						"dismiss_stale_reviews":true,
+						"require_code_owner_reviews":true,
+						"bypass_pull_request_allowances": {
+							"users":[{"id":10,"login":"uuu"}],
+							"teams":[{"id":20,"slug":"ttt"}],
+							"apps":[{"id":30,"slug":"aaa"}]
+						}
 					},
 					"restrictions":{
 						"users":[{"id":1,"login":"u"}],
-						"teams":[{"id":2,"slug":"t"}]
+						"teams":[{"id":2,"slug":"t"}],
+						"apps":[{"id":3,"slug":"a"}]
 					}
 				}`)
-	})
+			})
 
-	ctx := context.Background()
-	protection, _, err := client.Repositories.GetBranchProtection(ctx, "o", "r", "b")
-	if err != nil {
-		t.Errorf("Repositories.GetBranchProtection returned error: %v", err)
-	}
+			ctx := context.Background()
+			protection, _, err := client.Repositories.UpdateBranchProtection(ctx, "o", "r", test.branch, input)
+			if err != nil {
+				t.Errorf("Repositories.UpdateBranchProtection returned error: %v", err)
+			}
 
-	want := &Protection{
-		RequiredStatusChecks: &RequiredStatusChecks{
-			Strict:   true,
-			Contexts: []string{"continuous-integration"},
-			Checks: []*RequiredStatusCheck{
-				{
-					Context: "continuous-integration",
+			want := &Protection{
+				RequiredStatusChecks: &RequiredStatusChecks{
+					Strict:   true,
+					Contexts: []string{"continuous-integration"},
+					Checks: []*RequiredStatusCheck{
+						{
+							Context: "continuous-integration",
+						},
+					},
 				},
-			},
-		},
-		RequiredPullRequestReviews: &PullRequestReviewsEnforcement{
-			DismissStaleReviews:          true,
-			DismissalRestrictions:        nil,
-			RequireCodeOwnerReviews:      true,
-			RequiredApprovingReviewCount: 1,
-		},
-		EnforceAdmins: &AdminEnforcement{
-			URL:     String("/repos/o/r/branches/b/protection/enforce_admins"),
-			Enabled: true,
-		},
-		Restrictions: &BranchRestrictions{
-			Users: []*User{
-				{Login: String("u"), ID: Int64(1)},
-			},
-			Teams: []*Team{
-				{Slug: String("t"), ID: Int64(2)},
-			},
-		},
-	}
-	if !cmp.Equal(protection, want) {
-		t.Errorf("Repositories.GetBranchProtection returned %+v, want %+v", protection, want)
+				RequiredPullRequestReviews: &PullRequestReviewsEnforcement{
+					DismissStaleReviews: true,
+					DismissalRestrictions: &DismissalRestrictions{
+						Users: []*User{
+							{Login: String("uu"), ID: Int64(3)},
+						},
+						Teams: []*Team{
+							{Slug: String("tt"), ID: Int64(4)},
+						},
+						Apps: []*App{
+							{Slug: String("aa"), ID: Int64(5)},
+						},
+					},
+					RequireCodeOwnerReviews: true,
+					BypassPullRequestAllowances: &BypassPullRequestAllowances{
+						Users: []*User{
+							{Login: String("uuu"), ID: Int64(10)},
+						},
+						Teams: []*Team{
+							{Slug: String("ttt"), ID: Int64(20)},
+						},
+						Apps: []*App{
+							{Slug: String("aaa"), ID: Int64(30)},
+						},
+					},
+				},
+				Restrictions: &BranchRestrictions{
+					Users: []*User{
+						{Login: String("u"), ID: Int64(1)},
+					},
+					Teams: []*Team{
+						{Slug: String("t"), ID: Int64(2)},
+					},
+					Apps: []*App{
+						{Slug: String("a"), ID: Int64(3)},
+					},
+				},
+			}
+			if !cmp.Equal(protection, want) {
+				t.Errorf("Repositories.UpdateBranchProtection returned %+v, want %+v", protection, want)
+			}
+		})
 	}
 }
 
-func TestRepositoriesService_GetBranchProtection_branchNotProtected(t *testing.T) {
-	client, mux, _, teardown := setup()
-	defer teardown()
+func TestRepositoriesService_UpdateBranchProtection_StrictNoChecks(t *testing.T) {
+	tests := []struct {
+		branch  string
+		urlPath string
+	}{
+		{branch: "b", urlPath: "/repos/o/r/branches/b/protection"},
+		{branch: "feat/branch-50%", urlPath: "/repos/o/r/branches/feat/branch-50%/protection"},
+	}
+
+	for _, test := range tests {
+		t.Run(test.branch, func(t *testing.T) {
+			client, mux, _, teardown := setup()
+			defer teardown()
+
+			input := &ProtectionRequest{
+				RequiredStatusChecks: &RequiredStatusChecks{
+					Strict: true,
+					Checks: []*RequiredStatusCheck{},
+				},
+				RequiredPullRequestReviews: &PullRequestReviewsEnforcementRequest{
+					DismissStaleReviews: true,
+					DismissalRestrictionsRequest: &DismissalRestrictionsRequest{
+						Users: &[]string{"uu"},
+						Teams: &[]string{"tt"},
+						Apps:  &[]string{"aa"},
+					},
+					BypassPullRequestAllowancesRequest: &BypassPullRequestAllowancesRequest{
+						Users: []string{"uuu"},
+						Teams: []string{"ttt"},
+						Apps:  []string{"aaa"},
+					},
+				},
+				Restrictions: &BranchRestrictionsRequest{
+					Users: []string{"u"},
+					Teams: []string{"t"},
+					Apps:  []string{"a"},
+				},
+			}
 
-	mux.HandleFunc("/repos/o/r/branches/b/protection", func(w http.ResponseWriter, r *http.Request) {
-		testMethod(t, r, "GET")
+			mux.HandleFunc(test.urlPath, func(w http.ResponseWriter, r *http.Request) {
+				v := new(ProtectionRequest)
+				assertNilError(t, json.NewDecoder(r.Body).Decode(v))
 
-		w.WriteHeader(http.StatusBadRequest)
-		fmt.Fprintf(w, `{
-			"message": %q,
-			"documentation_url": "https://docs.github.com/rest/repos#get-branch-protection"
-			}`, githubBranchNotProtected)
-	})
+				testMethod(t, r, "PUT")
+				if !cmp.Equal(v, input) {
+					t.Errorf("Request body = %+v, want %+v", v, input)
+				}
 
-	ctx := context.Background()
-	protection, _, err := client.Repositories.GetBranchProtection(ctx, "o", "r", "b")
+				// TODO: remove custom Accept header when this API fully launches
+				testHeader(t, r, "Accept", mediaTypeRequiredApprovingReviewsPreview)
+				fmt.Fprintf(w, `{
+					"required_status_checks":{
+						"strict":true,
+						"contexts":[],
+						"checks": []
+					},
+					"required_pull_request_reviews":{
+						"dismissal_restrictions":{
+							"users":[{
+								"id":3,
+								"login":"uu"
+							}],
+							"teams":[{
+								"id":4,
+								"slug":"tt"
+							}],
+							"apps":[{
+								"id":5,
+								"slug":"aa"
+							}]
+						},
+						"dismiss_stale_reviews":true,
+						"require_code_owner_reviews":true,
+						"require_last_push_approval":false,
+						"bypass_pull_request_allowances": {
+							"users":[{"id":10,"login":"uuu"}],
+							"teams":[{"id":20,"slug":"ttt"}],
+							"apps":[{"id":30,"slug":"aaa"}]
+						}
+					},
+					"restrictions":{
+						"users":[{"id":1,"login":"u"}],
+						"teams":[{"id":2,"slug":"t"}],
+						"apps":[{"id":3,"slug":"a"}]
+					}
+				}`)
+			})
 
-	if protection != nil {
-		t.Errorf("Repositories.GetBranchProtection returned non-nil protection data")
-	}
+			ctx := context.Background()
+			protection, _, err := client.Repositories.UpdateBranchProtection(ctx, "o", "r", test.branch, input)
+			if err != nil {
+				t.Errorf("Repositories.UpdateBranchProtection returned error: %v", err)
+			}
 
-	if err != ErrBranchNotProtected {
-		t.Errorf("Repositories.GetBranchProtection returned an invalid error: %v", err)
+			want := &Protection{
+				RequiredStatusChecks: &RequiredStatusChecks{
+					Strict:   true,
+					Contexts: []string{},
+					Checks:   []*RequiredStatusCheck{},
+				},
+				RequiredPullRequestReviews: &PullRequestReviewsEnforcement{
+					DismissStaleReviews: true,
+					DismissalRestrictions: &DismissalRestrictions{
+						Users: []*User{
+							{Login: String("uu"), ID: Int64(3)},
+						},
+						Teams: []*Team{
+							{Slug: String("tt"), ID: Int64(4)},
+						},
+						Apps: []*App{
+							{Slug: String("aa"), ID: Int64(5)},
+						},
+					},
+					RequireCodeOwnerReviews: true,
+					BypassPullRequestAllowances: &BypassPullRequestAllowances{
+						Users: []*User{
+							{Login: String("uuu"), ID: Int64(10)},
+						},
+						Teams: []*Team{
+							{Slug: String("ttt"), ID: Int64(20)},
+						},
+						Apps: []*App{
+							{Slug: String("aaa"), ID: Int64(30)},
+						},
+					},
+				},
+				Restrictions: &BranchRestrictions{
+					Users: []*User{
+						{Login: String("u"), ID: Int64(1)},
+					},
+					Teams: []*Team{
+						{Slug: String("t"), ID: Int64(2)},
+					},
+					Apps: []*App{
+						{Slug: String("a"), ID: Int64(3)},
+					},
+				},
+			}
+			if !cmp.Equal(protection, want) {
+				t.Errorf("Repositories.UpdateBranchProtection returned %+v, want %+v", protection, want)
+			}
+		})
 	}
 }
 
-func TestRepositoriesService_UpdateBranchProtection_Contexts(t *testing.T) {
-	client, mux, _, teardown := setup()
-	defer teardown()
-
-	input := &ProtectionRequest{
-		RequiredStatusChecks: &RequiredStatusChecks{
-			Strict:   true,
-			Contexts: []string{"continuous-integration"},
-		},
-		RequiredPullRequestReviews: &PullRequestReviewsEnforcementRequest{
-			DismissStaleReviews: true,
-			DismissalRestrictionsRequest: &DismissalRestrictionsRequest{
-				Users: &[]string{"uu"},
-				Teams: &[]string{"tt"},
-				Apps:  &[]string{"aa"},
-			},
-			BypassPullRequestAllowancesRequest: &BypassPullRequestAllowancesRequest{
-				Users: []string{"uuu"},
-				Teams: []string{"ttt"},
-				Apps:  []string{"aaa"},
-			},
-		},
-		Restrictions: &BranchRestrictionsRequest{
-			Users: []string{"u"},
-			Teams: []string{"t"},
-			Apps:  []string{"a"},
-		},
-		BlockCreations:   Bool(true),
-		LockBranch:       Bool(true),
-		AllowForkSyncing: Bool(true),
-	}
+func TestRepositoriesService_UpdateBranchProtection_RequireLastPushApproval(t *testing.T) {
+	tests := []struct {
+		branch  string
+		urlPath string
+	}{
+		{branch: "b", urlPath: "/repos/o/r/branches/b/protection"},
+		{branch: "feat/branch-50%", urlPath: "/repos/o/r/branches/feat/branch-50%/protection"},
+	}
+
+	for _, test := range tests {
+		t.Run(test.branch, func(t *testing.T) {
+			client, mux, _, teardown := setup()
+			defer teardown()
+
+			input := &ProtectionRequest{
+				RequiredPullRequestReviews: &PullRequestReviewsEnforcementRequest{
+					RequireLastPushApproval: Bool(true),
+				},
+			}
 
-	mux.HandleFunc("/repos/o/r/branches/b/protection", func(w http.ResponseWriter, r *http.Request) {
-		v := new(ProtectionRequest)
-		assertNilError(t, json.NewDecoder(r.Body).Decode(v))
+			mux.HandleFunc(test.urlPath, func(w http.ResponseWriter, r *http.Request) {
+				v := new(ProtectionRequest)
+				assertNilError(t, json.NewDecoder(r.Body).Decode(v))
 
-		testMethod(t, r, "PUT")
-		if !cmp.Equal(v, input) {
-			t.Errorf("Request body = %+v, want %+v", v, input)
-		}
+				testMethod(t, r, "PUT")
+				if !cmp.Equal(v, input) {
+					t.Errorf("Request body = %+v, want %+v", v, input)
+				}
 
-		// TODO: remove custom Accept header when this API fully launches
-		testHeader(t, r, "Accept", mediaTypeRequiredApprovingReviewsPreview)
-		fmt.Fprintf(w, `{
-			"required_status_checks":{
-				"strict":true,
-				"contexts":["continuous-integration"],
-				"checks": [
-					{
-						"context": "continuous-integration",
-						"app_id": null
+				fmt.Fprintf(w, `{
+					"required_pull_request_reviews":{
+						"require_last_push_approval":true
 					}
-				]
-			},
-			"required_pull_request_reviews":{
-				"dismissal_restrictions":{
-					"users":[{
-						"id":3,
-						"login":"uu"
-					}],
-					"teams":[{
-						"id":4,
-						"slug":"tt"
-					}],
-					"apps":[{
-						"id":5,
-						"slug":"aa"
-					}]
+				}`)
+			})
+
+			ctx := context.Background()
+			protection, _, err := client.Repositories.UpdateBranchProtection(ctx, "o", "r", test.branch, input)
+			if err != nil {
+				t.Errorf("Repositories.UpdateBranchProtection returned error: %v", err)
+			}
+
+			want := &Protection{
+				RequiredPullRequestReviews: &PullRequestReviewsEnforcement{
+					RequireLastPushApproval: true,
 				},
-				"dismiss_stale_reviews":true,
-				"require_code_owner_reviews":true,
-				"bypass_pull_request_allowances": {
-					"users":[{"id":10,"login":"uuu"}],
-					"teams":[{"id":20,"slug":"ttt"}],
-					"apps":[{"id":30,"slug":"aaa"}]
-				}
-			},
-			"restrictions":{
-				"users":[{"id":1,"login":"u"}],
-				"teams":[{"id":2,"slug":"t"}],
-				"apps":[{"id":3,"slug":"a"}]
-			},
-			"block_creations": {
-				"enabled": true
-			},
-			"lock_branch": {
-				"enabled": true
-			},
-			"allow_fork_syncing": {
-				"enabled": true
 			}
-		}`)
+			if !cmp.Equal(protection, want) {
+				t.Errorf("Repositories.UpdateBranchProtection returned %+v, want %+v", protection, want)
+			}
+		})
+	}
+}
+
+func TestRepositoriesService_RemoveBranchProtection(t *testing.T) {
+	tests := []struct {
+		branch  string
+		urlPath string
+	}{
+		{branch: "b", urlPath: "/repos/o/r/branches/b/protection"},
+		{branch: "feat/branch-50%", urlPath: "/repos/o/r/branches/feat/branch-50%/protection"},
+	}
+
+	for _, test := range tests {
+		t.Run(test.branch, func(t *testing.T) {
+			client, mux, _, teardown := setup()
+			defer teardown()
+
+			mux.HandleFunc(test.urlPath, func(w http.ResponseWriter, r *http.Request) {
+				testMethod(t, r, "DELETE")
+				w.WriteHeader(http.StatusNoContent)
+			})
+
+			ctx := context.Background()
+			_, err := client.Repositories.RemoveBranchProtection(ctx, "o", "r", test.branch)
+			if err != nil {
+				t.Errorf("Repositories.RemoveBranchProtection returned error: %v", err)
+			}
+
+			const methodName = "RemoveBranchProtection"
+			testBadOptions(t, methodName, func() (err error) {
+				_, err = client.Repositories.RemoveBranchProtection(ctx, "\n", "\n", "\n")
+				return err
+			})
+
+			testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
+				return client.Repositories.RemoveBranchProtection(ctx, "o", "r", test.branch)
+			})
+		})
+	}
+}
+
+func TestRepositoriesService_ListLanguages_invalidOwner(t *testing.T) {
+	client, _, _, teardown := setup()
+	defer teardown()
+
+	ctx := context.Background()
+	_, _, err := client.Repositories.ListLanguages(ctx, "%", "%")
+	testURLParseError(t, err)
+}
+
+func TestRepositoriesService_License(t *testing.T) {
+	client, mux, _, teardown := setup()
+	defer teardown()
+
+	mux.HandleFunc("/repos/o/r/license", func(w http.ResponseWriter, r *http.Request) {
+		testMethod(t, r, "GET")
+		fmt.Fprint(w, `{"name": "LICENSE", "path": "LICENSE", "license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","featured":true}}`)
 	})
 
 	ctx := context.Background()
-	protection, _, err := client.Repositories.UpdateBranchProtection(ctx, "o", "r", "b", input)
+	got, _, err := client.Repositories.License(ctx, "o", "r")
 	if err != nil {
-		t.Errorf("Repositories.UpdateBranchProtection returned error: %v", err)
+		t.Errorf("Repositories.License returned error: %v", err)
 	}
 
-	want := &Protection{
-		RequiredStatusChecks: &RequiredStatusChecks{
-			Strict:   true,
-			Contexts: []string{"continuous-integration"},
-			Checks: []*RequiredStatusCheck{
-				{
-					Context: "continuous-integration",
-				},
-			},
-		},
-		RequiredPullRequestReviews: &PullRequestReviewsEnforcement{
-			DismissStaleReviews: true,
-			DismissalRestrictions: &DismissalRestrictions{
-				Users: []*User{
-					{Login: String("uu"), ID: Int64(3)},
-				},
-				Teams: []*Team{
-					{Slug: String("tt"), ID: Int64(4)},
-				},
-				Apps: []*App{
-					{Slug: String("aa"), ID: Int64(5)},
-				},
-			},
-			RequireCodeOwnerReviews: true,
-			BypassPullRequestAllowances: &BypassPullRequestAllowances{
-				Users: []*User{
-					{Login: String("uuu"), ID: Int64(10)},
-				},
-				Teams: []*Team{
-					{Slug: String("ttt"), ID: Int64(20)},
-				},
-				Apps: []*App{
-					{Slug: String("aaa"), ID: Int64(30)},
-				},
-			},
-		},
-		Restrictions: &BranchRestrictions{
-			Users: []*User{
-				{Login: String("u"), ID: Int64(1)},
-			},
-			Teams: []*Team{
-				{Slug: String("t"), ID: Int64(2)},
-			},
-			Apps: []*App{
-				{Slug: String("a"), ID: Int64(3)},
-			},
-		},
-		BlockCreations: &BlockCreations{
-			Enabled: Bool(true),
-		},
-		LockBranch: &LockBranch{
-			Enabled: Bool(true),
-		},
-		AllowForkSyncing: &AllowForkSyncing{
-			Enabled: Bool(true),
+	want := &RepositoryLicense{
+		Name: String("LICENSE"),
+		Path: String("LICENSE"),
+		License: &License{
+			Name:     String("MIT License"),
+			Key:      String("mit"),
+			SPDXID:   String("MIT"),
+			URL:      String("https://api.github.com/licenses/mit"),
+			Featured: Bool(true),
 		},
 	}
-	if !cmp.Equal(protection, want) {
-		t.Errorf("Repositories.UpdateBranchProtection returned %+v, want %+v", protection, want)
+
+	if !cmp.Equal(got, want) {
+		t.Errorf("Repositories.License returned %+v, want %+v", got, want)
 	}
 
-	const methodName = "UpdateBranchProtection"
+	const methodName = "License"
 	testBadOptions(t, methodName, func() (err error) {
-		_, _, err = client.Repositories.UpdateBranchProtection(ctx, "\n", "\n", "\n", input)
+		_, _, err = client.Repositories.License(ctx, "\n", "\n")
 		return err
 	})
 
 	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
-		got, resp, err := client.Repositories.UpdateBranchProtection(ctx, "o", "r", "b", input)
+		got, resp, err := client.Repositories.License(ctx, "o", "r")
 		if got != nil {
 			t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
 		}
@@ -1498,1532 +2041,1025 @@ func TestRepositoriesService_UpdateBranchProtection_Contexts(t *testing.T) {
 	})
 }
 
-func TestRepositoriesService_UpdateBranchProtection_Checks(t *testing.T) {
-	client, mux, _, teardown := setup()
-	defer teardown()
-
-	input := &ProtectionRequest{
-		RequiredStatusChecks: &RequiredStatusChecks{
-			Strict: true,
-			Checks: []*RequiredStatusCheck{
-				{
-					Context: "continuous-integration",
-				},
-			},
-		},
-		RequiredPullRequestReviews: &PullRequestReviewsEnforcementRequest{
-			DismissStaleReviews: true,
-			DismissalRestrictionsRequest: &DismissalRestrictionsRequest{
-				Users: &[]string{"uu"},
-				Teams: &[]string{"tt"},
-				Apps:  &[]string{"aa"},
-			},
-			BypassPullRequestAllowancesRequest: &BypassPullRequestAllowancesRequest{
-				Users: []string{"uuu"},
-				Teams: []string{"ttt"},
-				Apps:  []string{"aaa"},
-			},
-		},
-		Restrictions: &BranchRestrictionsRequest{
-			Users: []string{"u"},
-			Teams: []string{"t"},
-			Apps:  []string{"a"},
-		},
-	}
-
-	mux.HandleFunc("/repos/o/r/branches/b/protection", func(w http.ResponseWriter, r *http.Request) {
-		v := new(ProtectionRequest)
-		assertNilError(t, json.NewDecoder(r.Body).Decode(v))
+func TestRepositoriesService_GetRequiredStatusChecks(t *testing.T) {
+	tests := []struct {
+		branch  string
+		urlPath string
+	}{
+		{branch: "b", urlPath: "/repos/o/r/branches/b/protection/required_status_checks"},
+		{branch: "feat/branch-50%", urlPath: "/repos/o/r/branches/feat/branch-50%/protection/required_status_checks"},
+	}
+
+	for _, test := range tests {
+		t.Run(test.branch, func(t *testing.T) {
+			client, mux, _, teardown := setup()
+			defer teardown()
+
+			mux.HandleFunc(test.urlPath, func(w http.ResponseWriter, r *http.Request) {
+				testMethod(t, r, "GET")
+				fmt.Fprint(w, `{
+					"strict": true,
+					"contexts": ["x","y","z"],
+					"checks": [
+						{
+							"context": "x",
+							"app_id": null
+						},
+						{
+							"context": "y",
+							"app_id": null
+						},
+						{
+							"context": "z",
+							"app_id": null
+						}
+					]
+				}`)
+			})
 
-		testMethod(t, r, "PUT")
-		if !cmp.Equal(v, input) {
-			t.Errorf("Request body = %+v, want %+v", v, input)
-		}
+			ctx := context.Background()
+			checks, _, err := client.Repositories.GetRequiredStatusChecks(ctx, "o", "r", test.branch)
+			if err != nil {
+				t.Errorf("Repositories.GetRequiredStatusChecks returned error: %v", err)
+			}
 
-		// TODO: remove custom Accept header when this API fully launches
-		testHeader(t, r, "Accept", mediaTypeRequiredApprovingReviewsPreview)
-		fmt.Fprintf(w, `{
-			"required_status_checks":{
-				"strict":true,
-				"contexts":["continuous-integration"],
-				"checks": [
+			want := &RequiredStatusChecks{
+				Strict:   true,
+				Contexts: []string{"x", "y", "z"},
+				Checks: []*RequiredStatusCheck{
 					{
-						"context": "continuous-integration",
-						"app_id": null
-					}
-				]
-			},
-			"required_pull_request_reviews":{
-				"dismissal_restrictions":{
-					"users":[{
-						"id":3,
-						"login":"uu"
-					}],
-					"teams":[{
-						"id":4,
-						"slug":"tt"
-					}],
-					"apps":[{
-						"id":5,
-						"slug":"aa"
-					}]
+						Context: "x",
+					},
+					{
+						Context: "y",
+					},
+					{
+						Context: "z",
+					},
 				},
-				"dismiss_stale_reviews":true,
-				"require_code_owner_reviews":true,
-				"bypass_pull_request_allowances": {
-					"users":[{"id":10,"login":"uuu"}],
-					"teams":[{"id":20,"slug":"ttt"}],
-					"apps":[{"id":30,"slug":"aaa"}]
-				}
-			},
-			"restrictions":{
-				"users":[{"id":1,"login":"u"}],
-				"teams":[{"id":2,"slug":"t"}],
-				"apps":[{"id":3,"slug":"a"}]
 			}
-		}`)
-	})
+			if !cmp.Equal(checks, want) {
+				t.Errorf("Repositories.GetRequiredStatusChecks returned %+v, want %+v", checks, want)
+			}
 
-	ctx := context.Background()
-	protection, _, err := client.Repositories.UpdateBranchProtection(ctx, "o", "r", "b", input)
-	if err != nil {
-		t.Errorf("Repositories.UpdateBranchProtection returned error: %v", err)
-	}
+			const methodName = "GetRequiredStatusChecks"
+			testBadOptions(t, methodName, func() (err error) {
+				_, _, err = client.Repositories.GetRequiredStatusChecks(ctx, "\n", "\n", "\n")
+				return err
+			})
 
-	want := &Protection{
-		RequiredStatusChecks: &RequiredStatusChecks{
-			Strict:   true,
-			Contexts: []string{"continuous-integration"},
-			Checks: []*RequiredStatusCheck{
-				{
-					Context: "continuous-integration",
-				},
-			},
-		},
-		RequiredPullRequestReviews: &PullRequestReviewsEnforcement{
-			DismissStaleReviews: true,
-			DismissalRestrictions: &DismissalRestrictions{
-				Users: []*User{
-					{Login: String("uu"), ID: Int64(3)},
-				},
-				Teams: []*Team{
-					{Slug: String("tt"), ID: Int64(4)},
-				},
-				Apps: []*App{
-					{Slug: String("aa"), ID: Int64(5)},
-				},
-			},
-			RequireCodeOwnerReviews: true,
-			BypassPullRequestAllowances: &BypassPullRequestAllowances{
-				Users: []*User{
-					{Login: String("uuu"), ID: Int64(10)},
-				},
-				Teams: []*Team{
-					{Slug: String("ttt"), ID: Int64(20)},
-				},
-				Apps: []*App{
-					{Slug: String("aaa"), ID: Int64(30)},
-				},
-			},
-		},
-		Restrictions: &BranchRestrictions{
-			Users: []*User{
-				{Login: String("u"), ID: Int64(1)},
-			},
-			Teams: []*Team{
-				{Slug: String("t"), ID: Int64(2)},
-			},
-			Apps: []*App{
-				{Slug: String("a"), ID: Int64(3)},
-			},
-		},
-	}
-	if !cmp.Equal(protection, want) {
-		t.Errorf("Repositories.UpdateBranchProtection returned %+v, want %+v", protection, want)
+			testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
+				got, resp, err := client.Repositories.GetRequiredStatusChecks(ctx, "o", "r", test.branch)
+				if got != nil {
+					t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
+				}
+				return resp, err
+			})
+		})
 	}
 }
 
-func TestRepositoriesService_UpdateBranchProtection_StrictNoChecks(t *testing.T) {
-	client, mux, _, teardown := setup()
-	defer teardown()
-
-	input := &ProtectionRequest{
-		RequiredStatusChecks: &RequiredStatusChecks{
-			Strict: true,
-			Checks: []*RequiredStatusCheck{},
-		},
-		RequiredPullRequestReviews: &PullRequestReviewsEnforcementRequest{
-			DismissStaleReviews: true,
-			DismissalRestrictionsRequest: &DismissalRestrictionsRequest{
-				Users: &[]string{"uu"},
-				Teams: &[]string{"tt"},
-				Apps:  &[]string{"aa"},
-			},
-			BypassPullRequestAllowancesRequest: &BypassPullRequestAllowancesRequest{
-				Users: []string{"uuu"},
-				Teams: []string{"ttt"},
-				Apps:  []string{"aaa"},
-			},
-		},
-		Restrictions: &BranchRestrictionsRequest{
-			Users: []string{"u"},
-			Teams: []string{"t"},
-			Apps:  []string{"a"},
-		},
+func TestRepositoriesService_GetRequiredStatusChecks_branchNotProtected(t *testing.T) {
+	tests := []struct {
+		branch  string
+		urlPath string
+	}{
+		{branch: "b", urlPath: "/repos/o/r/branches/b/protection/required_status_checks"},
+		{branch: "feat/branch-50%", urlPath: "/repos/o/r/branches/feat/branch-50%/protection/required_status_checks"},
 	}
 
-	mux.HandleFunc("/repos/o/r/branches/b/protection", func(w http.ResponseWriter, r *http.Request) {
-		v := new(ProtectionRequest)
-		assertNilError(t, json.NewDecoder(r.Body).Decode(v))
+	for _, test := range tests {
+		t.Run(test.branch, func(t *testing.T) {
+			client, mux, _, teardown := setup()
+			defer teardown()
 
-		testMethod(t, r, "PUT")
-		if !cmp.Equal(v, input) {
-			t.Errorf("Request body = %+v, want %+v", v, input)
-		}
+			mux.HandleFunc(test.urlPath, func(w http.ResponseWriter, r *http.Request) {
+				testMethod(t, r, "GET")
 
-		// TODO: remove custom Accept header when this API fully launches
-		testHeader(t, r, "Accept", mediaTypeRequiredApprovingReviewsPreview)
-		fmt.Fprintf(w, `{
-			"required_status_checks":{
-				"strict":true,
-				"contexts":[],
-				"checks": []
-			},
-			"required_pull_request_reviews":{
-				"dismissal_restrictions":{
-					"users":[{
-						"id":3,
-						"login":"uu"
-					}],
-					"teams":[{
-						"id":4,
-						"slug":"tt"
-					}],
-					"apps":[{
-						"id":5,
-						"slug":"aa"
-					}]
-				},
-				"dismiss_stale_reviews":true,
-				"require_code_owner_reviews":true,
-				"require_last_push_approval":false,
-				"bypass_pull_request_allowances": {
-					"users":[{"id":10,"login":"uuu"}],
-					"teams":[{"id":20,"slug":"ttt"}],
-					"apps":[{"id":30,"slug":"aaa"}]
-				}
-			},
-			"restrictions":{
-				"users":[{"id":1,"login":"u"}],
-				"teams":[{"id":2,"slug":"t"}],
-				"apps":[{"id":3,"slug":"a"}]
-			}
-		}`)
-	})
+				w.WriteHeader(http.StatusBadRequest)
+				fmt.Fprintf(w, `{
+			"message": %q,
+			"documentation_url": "https://docs.github.com/rest/repos#get-branch-protection"
+			}`, githubBranchNotProtected)
+			})
 
-	ctx := context.Background()
-	protection, _, err := client.Repositories.UpdateBranchProtection(ctx, "o", "r", "b", input)
-	if err != nil {
-		t.Errorf("Repositories.UpdateBranchProtection returned error: %v", err)
-	}
+			ctx := context.Background()
+			checks, _, err := client.Repositories.GetRequiredStatusChecks(ctx, "o", "r", test.branch)
 
-	want := &Protection{
-		RequiredStatusChecks: &RequiredStatusChecks{
-			Strict:   true,
-			Contexts: []string{},
-			Checks:   []*RequiredStatusCheck{},
-		},
-		RequiredPullRequestReviews: &PullRequestReviewsEnforcement{
-			DismissStaleReviews: true,
-			DismissalRestrictions: &DismissalRestrictions{
-				Users: []*User{
-					{Login: String("uu"), ID: Int64(3)},
-				},
-				Teams: []*Team{
-					{Slug: String("tt"), ID: Int64(4)},
-				},
-				Apps: []*App{
-					{Slug: String("aa"), ID: Int64(5)},
-				},
-			},
-			RequireCodeOwnerReviews: true,
-			BypassPullRequestAllowances: &BypassPullRequestAllowances{
-				Users: []*User{
-					{Login: String("uuu"), ID: Int64(10)},
-				},
-				Teams: []*Team{
-					{Slug: String("ttt"), ID: Int64(20)},
-				},
-				Apps: []*App{
-					{Slug: String("aaa"), ID: Int64(30)},
-				},
-			},
-		},
-		Restrictions: &BranchRestrictions{
-			Users: []*User{
-				{Login: String("u"), ID: Int64(1)},
-			},
-			Teams: []*Team{
-				{Slug: String("t"), ID: Int64(2)},
-			},
-			Apps: []*App{
-				{Slug: String("a"), ID: Int64(3)},
-			},
-		},
-	}
-	if !cmp.Equal(protection, want) {
-		t.Errorf("Repositories.UpdateBranchProtection returned %+v, want %+v", protection, want)
+			if checks != nil {
+				t.Errorf("Repositories.GetRequiredStatusChecks returned non-nil status-checks data")
+			}
+
+			if err != ErrBranchNotProtected {
+				t.Errorf("Repositories.GetRequiredStatusChecks returned an invalid error: %v", err)
+			}
+		})
 	}
 }
 
-func TestRepositoriesService_UpdateBranchProtection_RequireLastPushApproval(t *testing.T) {
-	client, mux, _, teardown := setup()
-	defer teardown()
+func TestRepositoriesService_UpdateRequiredStatusChecks_Contexts(t *testing.T) {
+	tests := []struct {
+		branch  string
+		urlPath string
+	}{
+		{branch: "b", urlPath: "/repos/o/r/branches/b/protection/required_status_checks"},
+		{branch: "feat/branch-50%", urlPath: "/repos/o/r/branches/feat/branch-50%/protection/required_status_checks"},
+	}
+
+	for _, test := range tests {
+		t.Run(test.branch, func(t *testing.T) {
+			client, mux, _, teardown := setup()
+			defer teardown()
+
+			input := &RequiredStatusChecksRequest{
+				Strict:   Bool(true),
+				Contexts: []string{"continuous-integration"},
+			}
 
-	input := &ProtectionRequest{
-		RequiredPullRequestReviews: &PullRequestReviewsEnforcementRequest{
-			RequireLastPushApproval: Bool(true),
-		},
-	}
+			mux.HandleFunc(test.urlPath, func(w http.ResponseWriter, r *http.Request) {
+				v := new(RequiredStatusChecksRequest)
+				assertNilError(t, json.NewDecoder(r.Body).Decode(v))
 
-	mux.HandleFunc("/repos/o/r/branches/b/protection", func(w http.ResponseWriter, r *http.Request) {
-		v := new(ProtectionRequest)
-		assertNilError(t, json.NewDecoder(r.Body).Decode(v))
+				testMethod(t, r, "PATCH")
+				if !cmp.Equal(v, input) {
+					t.Errorf("Request body = %+v, want %+v", v, input)
+				}
+				testHeader(t, r, "Accept", mediaTypeV3)
+				fmt.Fprintf(w, `{
+					"strict":true,
+					"contexts":["continuous-integration"],
+					"checks": [
+						{
+							"context": "continuous-integration",
+							"app_id": null
+						}
+					]
+				}`)
+			})
 
-		testMethod(t, r, "PUT")
-		if !cmp.Equal(v, input) {
-			t.Errorf("Request body = %+v, want %+v", v, input)
-		}
+			ctx := context.Background()
+			statusChecks, _, err := client.Repositories.UpdateRequiredStatusChecks(ctx, "o", "r", test.branch, input)
+			if err != nil {
+				t.Errorf("Repositories.UpdateRequiredStatusChecks returned error: %v", err)
+			}
 
-		fmt.Fprintf(w, `{
-			"required_pull_request_reviews":{
-				"require_last_push_approval":true
+			want := &RequiredStatusChecks{
+				Strict:   true,
+				Contexts: []string{"continuous-integration"},
+				Checks: []*RequiredStatusCheck{
+					{
+						Context: "continuous-integration",
+					},
+				},
+			}
+			if !cmp.Equal(statusChecks, want) {
+				t.Errorf("Repositories.UpdateRequiredStatusChecks returned %+v, want %+v", statusChecks, want)
 			}
-		}`)
-	})
 
-	ctx := context.Background()
-	protection, _, err := client.Repositories.UpdateBranchProtection(ctx, "o", "r", "b", input)
-	if err != nil {
-		t.Errorf("Repositories.UpdateBranchProtection returned error: %v", err)
-	}
+			const methodName = "UpdateRequiredStatusChecks"
+			testBadOptions(t, methodName, func() (err error) {
+				_, _, err = client.Repositories.UpdateRequiredStatusChecks(ctx, "\n", "\n", "\n", input)
+				return err
+			})
 
-	want := &Protection{
-		RequiredPullRequestReviews: &PullRequestReviewsEnforcement{
-			RequireLastPushApproval: true,
-		},
-	}
-	if !cmp.Equal(protection, want) {
-		t.Errorf("Repositories.UpdateBranchProtection returned %+v, want %+v", protection, want)
+			testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
+				got, resp, err := client.Repositories.UpdateRequiredStatusChecks(ctx, "o", "r", test.branch, input)
+				if got != nil {
+					t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
+				}
+				return resp, err
+			})
+		})
 	}
 }
 
-func TestRepositoriesService_RemoveBranchProtection(t *testing.T) {
-	client, mux, _, teardown := setup()
-	defer teardown()
-
-	mux.HandleFunc("/repos/o/r/branches/b/protection", func(w http.ResponseWriter, r *http.Request) {
-		testMethod(t, r, "DELETE")
-		w.WriteHeader(http.StatusNoContent)
-	})
-
-	ctx := context.Background()
-	_, err := client.Repositories.RemoveBranchProtection(ctx, "o", "r", "b")
-	if err != nil {
-		t.Errorf("Repositories.RemoveBranchProtection returned error: %v", err)
-	}
+func TestRepositoriesService_UpdateRequiredStatusChecks_Checks(t *testing.T) {
+	tests := []struct {
+		branch  string
+		urlPath string
+	}{
+		{branch: "b", urlPath: "/repos/o/r/branches/b/protection/required_status_checks"},
+		{branch: "feat/branch-50%", urlPath: "/repos/o/r/branches/feat/branch-50%/protection/required_status_checks"},
+	}
+
+	for _, test := range tests {
+		t.Run(test.branch, func(t *testing.T) {
+			client, mux, _, teardown := setup()
+			defer teardown()
+
+			appID := int64(123)
+			noAppID := int64(-1)
+			input := &RequiredStatusChecksRequest{
+				Strict: Bool(true),
+				Checks: []*RequiredStatusCheck{
+					{
+						Context: "continuous-integration",
+					},
+					{
+						Context: "continuous-integration2",
+						AppID:   &appID,
+					},
+					{
+						Context: "continuous-integration3",
+						AppID:   &noAppID,
+					},
+				},
+			}
 
-	const methodName = "RemoveBranchProtection"
-	testBadOptions(t, methodName, func() (err error) {
-		_, err = client.Repositories.RemoveBranchProtection(ctx, "\n", "\n", "\n")
-		return err
-	})
+			mux.HandleFunc(test.urlPath, func(w http.ResponseWriter, r *http.Request) {
+				v := new(RequiredStatusChecksRequest)
+				assertNilError(t, json.NewDecoder(r.Body).Decode(v))
 
-	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
-		return client.Repositories.RemoveBranchProtection(ctx, "o", "r", "b")
-	})
-}
+				testMethod(t, r, "PATCH")
+				if !cmp.Equal(v, input) {
+					t.Errorf("Request body = %+v, want %+v", v, input)
+				}
+				testHeader(t, r, "Accept", mediaTypeV3)
+				fmt.Fprintf(w, `{
+					"strict":true,
+					"contexts":["continuous-integration"],
+					"checks": [
+						{
+							"context": "continuous-integration",
+							"app_id": null
+						},
+						{
+							"context": "continuous-integration2",
+							"app_id": 123
+						},
+						{
+							"context": "continuous-integration3",
+							"app_id": null
+						}
+					]
+				}`)
+			})
 
-func TestRepositoriesService_ListLanguages_invalidOwner(t *testing.T) {
-	client, _, _, teardown := setup()
-	defer teardown()
+			ctx := context.Background()
+			statusChecks, _, err := client.Repositories.UpdateRequiredStatusChecks(ctx, "o", "r", test.branch, input)
+			if err != nil {
+				t.Errorf("Repositories.UpdateRequiredStatusChecks returned error: %v", err)
+			}
 
-	ctx := context.Background()
-	_, _, err := client.Repositories.ListLanguages(ctx, "%", "%")
-	testURLParseError(t, err)
+			want := &RequiredStatusChecks{
+				Strict:   true,
+				Contexts: []string{"continuous-integration"},
+				Checks: []*RequiredStatusCheck{
+					{
+						Context: "continuous-integration",
+					},
+					{
+						Context: "continuous-integration2",
+						AppID:   &appID,
+					},
+					{
+						Context: "continuous-integration3",
+					},
+				},
+			}
+			if !cmp.Equal(statusChecks, want) {
+				t.Errorf("Repositories.UpdateRequiredStatusChecks returned %+v, want %+v", statusChecks, want)
+			}
+		})
+	}
 }
 
-func TestRepositoriesService_License(t *testing.T) {
-	client, mux, _, teardown := setup()
-	defer teardown()
-
-	mux.HandleFunc("/repos/o/r/license", func(w http.ResponseWriter, r *http.Request) {
-		testMethod(t, r, "GET")
-		fmt.Fprint(w, `{"name": "LICENSE", "path": "LICENSE", "license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","featured":true}}`)
-	})
-
-	ctx := context.Background()
-	got, _, err := client.Repositories.License(ctx, "o", "r")
-	if err != nil {
-		t.Errorf("Repositories.License returned error: %v", err)
-	}
+func TestRepositoriesService_RemoveRequiredStatusChecks(t *testing.T) {
+	tests := []struct {
+		branch  string
+		urlPath string
+	}{
+		{branch: "b", urlPath: "/repos/o/r/branches/b/protection/required_status_checks"},
+		{branch: "feat/branch-50%", urlPath: "/repos/o/r/branches/feat/branch-50%/protection/required_status_checks"},
+	}
+
+	for _, test := range tests {
+		t.Run(test.branch, func(t *testing.T) {
+			client, mux, _, teardown := setup()
+			defer teardown()
+
+			mux.HandleFunc(test.urlPath, func(w http.ResponseWriter, r *http.Request) {
+				testMethod(t, r, "DELETE")
+				testHeader(t, r, "Accept", mediaTypeV3)
+				w.WriteHeader(http.StatusNoContent)
+			})
+
+			ctx := context.Background()
+			_, err := client.Repositories.RemoveRequiredStatusChecks(ctx, "o", "r", test.branch)
+			if err != nil {
+				t.Errorf("Repositories.RemoveRequiredStatusChecks returned error: %v", err)
+			}
 
-	want := &RepositoryLicense{
-		Name: String("LICENSE"),
-		Path: String("LICENSE"),
-		License: &License{
-			Name:     String("MIT License"),
-			Key:      String("mit"),
-			SPDXID:   String("MIT"),
-			URL:      String("https://api.github.com/licenses/mit"),
-			Featured: Bool(true),
-		},
-	}
+			const methodName = "RemoveRequiredStatusChecks"
+			testBadOptions(t, methodName, func() (err error) {
+				_, err = client.Repositories.RemoveRequiredStatusChecks(ctx, "\n", "\n", "\n")
+				return err
+			})
 
-	if !cmp.Equal(got, want) {
-		t.Errorf("Repositories.License returned %+v, want %+v", got, want)
+			testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
+				return client.Repositories.RemoveRequiredStatusChecks(ctx, "o", "r", test.branch)
+			})
+		})
 	}
+}
 
-	const methodName = "License"
-	testBadOptions(t, methodName, func() (err error) {
-		_, _, err = client.Repositories.License(ctx, "\n", "\n")
-		return err
-	})
+func TestRepositoriesService_ListRequiredStatusChecksContexts(t *testing.T) {
+	tests := []struct {
+		branch  string
+		urlPath string
+	}{
+		{branch: "b", urlPath: "/repos/o/r/branches/b/protection/required_status_checks/contexts"},
+		{branch: "feat/branch-50%", urlPath: "/repos/o/r/branches/feat/branch-50%/protection/required_status_checks/contexts"},
+	}
+
+	for _, test := range tests {
+		t.Run(test.branch, func(t *testing.T) {
+			client, mux, _, teardown := setup()
+			defer teardown()
+
+			mux.HandleFunc(test.urlPath, func(w http.ResponseWriter, r *http.Request) {
+				testMethod(t, r, "GET")
+				fmt.Fprint(w, `["x", "y", "z"]`)
+			})
+
+			ctx := context.Background()
+			contexts, _, err := client.Repositories.ListRequiredStatusChecksContexts(ctx, "o", "r", test.branch)
+			if err != nil {
+				t.Errorf("Repositories.ListRequiredStatusChecksContexts returned error: %v", err)
+			}
 
-	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
-		got, resp, err := client.Repositories.License(ctx, "o", "r")
-		if got != nil {
-			t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
-		}
-		return resp, err
-	})
-}
+			want := []string{"x", "y", "z"}
+			if !cmp.Equal(contexts, want) {
+				t.Errorf("Repositories.ListRequiredStatusChecksContexts returned %+v, want %+v", contexts, want)
+			}
 
-func TestRepositoriesService_GetRequiredStatusChecks(t *testing.T) {
-	client, mux, _, teardown := setup()
-	defer teardown()
+			const methodName = "ListRequiredStatusChecksContexts"
+			testBadOptions(t, methodName, func() (err error) {
+				_, _, err = client.Repositories.ListRequiredStatusChecksContexts(ctx, "\n", "\n", "\n")
+				return err
+			})
 
-	mux.HandleFunc("/repos/o/r/branches/b/protection/required_status_checks", func(w http.ResponseWriter, r *http.Request) {
-		testMethod(t, r, "GET")
-		fmt.Fprint(w, `{
-			"strict": true,
-			"contexts": ["x","y","z"],
-			"checks": [
-				{
-					"context": "x",
-					"app_id": null
-				},
-				{
-					"context": "y",
-					"app_id": null
-				},
-				{
-					"context": "z",
-					"app_id": null
+			testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
+				got, resp, err := client.Repositories.ListRequiredStatusChecksContexts(ctx, "o", "r", test.branch)
+				if got != nil {
+					t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
 				}
-			]
-		}`)
-	})
-
-	ctx := context.Background()
-	checks, _, err := client.Repositories.GetRequiredStatusChecks(ctx, "o", "r", "b")
-	if err != nil {
-		t.Errorf("Repositories.GetRequiredStatusChecks returned error: %v", err)
+				return resp, err
+			})
+		})
 	}
+}
 
-	want := &RequiredStatusChecks{
-		Strict:   true,
-		Contexts: []string{"x", "y", "z"},
-		Checks: []*RequiredStatusCheck{
-			{
-				Context: "x",
-			},
-			{
-				Context: "y",
-			},
-			{
-				Context: "z",
-			},
-		},
-	}
-	if !cmp.Equal(checks, want) {
-		t.Errorf("Repositories.GetRequiredStatusChecks returned %+v, want %+v", checks, want)
+func TestRepositoriesService_ListRequiredStatusChecksContexts_branchNotProtected(t *testing.T) {
+	tests := []struct {
+		branch  string
+		urlPath string
+	}{
+		{branch: "b", urlPath: "/repos/o/r/branches/b/protection/required_status_checks/contexts"},
+		{branch: "feat/branch-50%", urlPath: "/repos/o/r/branches/feat/branch-50%/protection/required_status_checks/contexts"},
 	}
 
-	const methodName = "GetRequiredStatusChecks"
-	testBadOptions(t, methodName, func() (err error) {
-		_, _, err = client.Repositories.GetRequiredStatusChecks(ctx, "\n", "\n", "\n")
-		return err
-	})
-
-	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
-		got, resp, err := client.Repositories.GetRequiredStatusChecks(ctx, "o", "r", "b")
-		if got != nil {
-			t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
-		}
-		return resp, err
-	})
-}
-
-func TestRepositoriesService_GetRequiredStatusChecks_branchNotProtected(t *testing.T) {
-	client, mux, _, teardown := setup()
-	defer teardown()
+	for _, test := range tests {
+		t.Run(test.branch, func(t *testing.T) {
+			client, mux, _, teardown := setup()
+			defer teardown()
 
-	mux.HandleFunc("/repos/o/r/branches/b/protection/required_status_checks", func(w http.ResponseWriter, r *http.Request) {
-		testMethod(t, r, "GET")
+			mux.HandleFunc(test.urlPath, func(w http.ResponseWriter, r *http.Request) {
+				testMethod(t, r, "GET")
 
-		w.WriteHeader(http.StatusBadRequest)
-		fmt.Fprintf(w, `{
+				w.WriteHeader(http.StatusBadRequest)
+				fmt.Fprintf(w, `{
 			"message": %q,
 			"documentation_url": "https://docs.github.com/rest/repos#get-branch-protection"
 			}`, githubBranchNotProtected)
-	})
+			})
 
-	ctx := context.Background()
-	checks, _, err := client.Repositories.GetRequiredStatusChecks(ctx, "o", "r", "b")
+			ctx := context.Background()
+			contexts, _, err := client.Repositories.ListRequiredStatusChecksContexts(ctx, "o", "r", test.branch)
 
-	if checks != nil {
-		t.Errorf("Repositories.GetRequiredStatusChecks returned non-nil status-checks data")
-	}
+			if contexts != nil {
+				t.Errorf("Repositories.ListRequiredStatusChecksContexts returned non-nil contexts data")
+			}
 
-	if err != ErrBranchNotProtected {
-		t.Errorf("Repositories.GetRequiredStatusChecks returned an invalid error: %v", err)
+			if err != ErrBranchNotProtected {
+				t.Errorf("Repositories.ListRequiredStatusChecksContexts returned an invalid error: %v", err)
+			}
+		})
 	}
 }
 
-func TestRepositoriesService_UpdateRequiredStatusChecks_Contexts(t *testing.T) {
-	client, mux, _, teardown := setup()
-	defer teardown()
+func TestRepositoriesService_GetPullRequestReviewEnforcement(t *testing.T) {
+	tests := []struct {
+		branch  string
+		urlPath string
+	}{
+		{branch: "b", urlPath: "/repos/o/r/branches/b/protection/required_pull_request_reviews"},
+		{branch: "feat/branch-50%", urlPath: "/repos/o/r/branches/feat/branch-50%/protection/required_pull_request_reviews"},
+	}
+
+	for _, test := range tests {
+		t.Run(test.branch, func(t *testing.T) {
+			client, mux, _, teardown := setup()
+			defer teardown()
+
+			mux.HandleFunc(test.urlPath, func(w http.ResponseWriter, r *http.Request) {
+				testMethod(t, r, "GET")
+				// TODO: remove custom Accept header when this API fully launches
+				testHeader(t, r, "Accept", mediaTypeRequiredApprovingReviewsPreview)
+				fmt.Fprintf(w, `{
+			"dismissal_restrictions":{
+				"users":[{"id":1,"login":"u"}],
+				"teams":[{"id":2,"slug":"t"}],
+				"apps":[{"id":3,"slug":"a"}]
+			},
+			"dismiss_stale_reviews":true,
+			"require_code_owner_reviews":true,
+			"required_approving_review_count":1
+		}`)
+			})
 
-	input := &RequiredStatusChecksRequest{
-		Strict:   Bool(true),
-		Contexts: []string{"continuous-integration"},
-	}
+			ctx := context.Background()
+			enforcement, _, err := client.Repositories.GetPullRequestReviewEnforcement(ctx, "o", "r", test.branch)
+			if err != nil {
+				t.Errorf("Repositories.GetPullRequestReviewEnforcement returned error: %v", err)
+			}
 
-	mux.HandleFunc("/repos/o/r/branches/b/protection/required_status_checks", func(w http.ResponseWriter, r *http.Request) {
-		v := new(RequiredStatusChecksRequest)
-		assertNilError(t, json.NewDecoder(r.Body).Decode(v))
+			want := &PullRequestReviewsEnforcement{
+				DismissStaleReviews: true,
+				DismissalRestrictions: &DismissalRestrictions{
+					Users: []*User{
+						{Login: String("u"), ID: Int64(1)},
+					},
+					Teams: []*Team{
+						{Slug: String("t"), ID: Int64(2)},
+					},
+					Apps: []*App{
+						{Slug: String("a"), ID: Int64(3)},
+					},
+				},
+				RequireCodeOwnerReviews:      true,
+				RequiredApprovingReviewCount: 1,
+			}
 
-		testMethod(t, r, "PATCH")
-		if !cmp.Equal(v, input) {
-			t.Errorf("Request body = %+v, want %+v", v, input)
-		}
-		testHeader(t, r, "Accept", mediaTypeV3)
-		fmt.Fprintf(w, `{
-			"strict":true,
-			"contexts":["continuous-integration"],
-			"checks": [
-				{
-					"context": "continuous-integration",
-					"app_id": null
-				}
-			]
-		}`)
-	})
+			if !cmp.Equal(enforcement, want) {
+				t.Errorf("Repositories.GetPullRequestReviewEnforcement returned %+v, want %+v", enforcement, want)
+			}
 
-	ctx := context.Background()
-	statusChecks, _, err := client.Repositories.UpdateRequiredStatusChecks(ctx, "o", "r", "b", input)
-	if err != nil {
-		t.Errorf("Repositories.UpdateRequiredStatusChecks returned error: %v", err)
-	}
+			const methodName = "GetPullRequestReviewEnforcement"
+			testBadOptions(t, methodName, func() (err error) {
+				_, _, err = client.Repositories.GetPullRequestReviewEnforcement(ctx, "\n", "\n", "\n")
+				return err
+			})
 
-	want := &RequiredStatusChecks{
-		Strict:   true,
-		Contexts: []string{"continuous-integration"},
-		Checks: []*RequiredStatusCheck{
-			{
-				Context: "continuous-integration",
-			},
-		},
-	}
-	if !cmp.Equal(statusChecks, want) {
-		t.Errorf("Repositories.UpdateRequiredStatusChecks returned %+v, want %+v", statusChecks, want)
+			testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
+				got, resp, err := client.Repositories.GetPullRequestReviewEnforcement(ctx, "o", "r", test.branch)
+				if got != nil {
+					t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
+				}
+				return resp, err
+			})
+		})
 	}
+}
 
-	const methodName = "UpdateRequiredStatusChecks"
-	testBadOptions(t, methodName, func() (err error) {
-		_, _, err = client.Repositories.UpdateRequiredStatusChecks(ctx, "\n", "\n", "\n", input)
-		return err
-	})
+func TestRepositoriesService_UpdatePullRequestReviewEnforcement(t *testing.T) {
+	tests := []struct {
+		branch  string
+		urlPath string
+	}{
+		{branch: "b", urlPath: "/repos/o/r/branches/b/protection/required_pull_request_reviews"},
+		{branch: "feat/branch-50%", urlPath: "/repos/o/r/branches/feat/branch-50%/protection/required_pull_request_reviews"},
+	}
+
+	for _, test := range tests {
+		t.Run(test.branch, func(t *testing.T) {
+			client, mux, _, teardown := setup()
+			defer teardown()
+
+			input := &PullRequestReviewsEnforcementUpdate{
+				DismissalRestrictionsRequest: &DismissalRestrictionsRequest{
+					Users: &[]string{"u"},
+					Teams: &[]string{"t"},
+					Apps:  &[]string{"a"},
+				},
+			}
 
-	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
-		got, resp, err := client.Repositories.UpdateRequiredStatusChecks(ctx, "o", "r", "b", input)
-		if got != nil {
-			t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
-		}
-		return resp, err
-	})
-}
+			mux.HandleFunc(test.urlPath, func(w http.ResponseWriter, r *http.Request) {
+				v := new(PullRequestReviewsEnforcementUpdate)
+				assertNilError(t, json.NewDecoder(r.Body).Decode(v))
 
-func TestRepositoriesService_UpdateRequiredStatusChecks_Checks(t *testing.T) {
-	client, mux, _, teardown := setup()
-	defer teardown()
-
-	appID := int64(123)
-	noAppID := int64(-1)
-	input := &RequiredStatusChecksRequest{
-		Strict: Bool(true),
-		Checks: []*RequiredStatusCheck{
-			{
-				Context: "continuous-integration",
-			},
-			{
-				Context: "continuous-integration2",
-				AppID:   &appID,
-			},
-			{
-				Context: "continuous-integration3",
-				AppID:   &noAppID,
-			},
-		},
-	}
-
-	mux.HandleFunc("/repos/o/r/branches/b/protection/required_status_checks", func(w http.ResponseWriter, r *http.Request) {
-		v := new(RequiredStatusChecksRequest)
-		assertNilError(t, json.NewDecoder(r.Body).Decode(v))
-
-		testMethod(t, r, "PATCH")
-		if !cmp.Equal(v, input) {
-			t.Errorf("Request body = %+v, want %+v", v, input)
-		}
-		testHeader(t, r, "Accept", mediaTypeV3)
-		fmt.Fprintf(w, `{
-			"strict":true,
-			"contexts":["continuous-integration"],
-			"checks": [
-				{
-					"context": "continuous-integration",
-					"app_id": null
-				},
-				{
-					"context": "continuous-integration2",
-					"app_id": 123
-				},
-				{
-					"context": "continuous-integration3",
-					"app_id": null
+				testMethod(t, r, "PATCH")
+				if !cmp.Equal(v, input) {
+					t.Errorf("Request body = %+v, want %+v", v, input)
 				}
-			]
-		}`)
-	})
-
-	ctx := context.Background()
-	statusChecks, _, err := client.Repositories.UpdateRequiredStatusChecks(ctx, "o", "r", "b", input)
-	if err != nil {
-		t.Errorf("Repositories.UpdateRequiredStatusChecks returned error: %v", err)
-	}
-
-	want := &RequiredStatusChecks{
-		Strict:   true,
-		Contexts: []string{"continuous-integration"},
-		Checks: []*RequiredStatusCheck{
-			{
-				Context: "continuous-integration",
-			},
-			{
-				Context: "continuous-integration2",
-				AppID:   &appID,
-			},
-			{
-				Context: "continuous-integration3",
-			},
-		},
-	}
-	if !cmp.Equal(statusChecks, want) {
-		t.Errorf("Repositories.UpdateRequiredStatusChecks returned %+v, want %+v", statusChecks, want)
-	}
-}
-
-func TestRepositoriesService_RemoveRequiredStatusChecks(t *testing.T) {
-	client, mux, _, teardown := setup()
-	defer teardown()
-
-	mux.HandleFunc("/repos/o/r/branches/b/protection/required_status_checks", func(w http.ResponseWriter, r *http.Request) {
-		testMethod(t, r, "DELETE")
-		testHeader(t, r, "Accept", mediaTypeV3)
-		w.WriteHeader(http.StatusNoContent)
-	})
-
-	ctx := context.Background()
-	_, err := client.Repositories.RemoveRequiredStatusChecks(ctx, "o", "r", "b")
-	if err != nil {
-		t.Errorf("Repositories.RemoveRequiredStatusChecks returned error: %v", err)
-	}
-
-	const methodName = "RemoveRequiredStatusChecks"
-	testBadOptions(t, methodName, func() (err error) {
-		_, err = client.Repositories.RemoveRequiredStatusChecks(ctx, "\n", "\n", "\n")
-		return err
-	})
-
-	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
-		return client.Repositories.RemoveRequiredStatusChecks(ctx, "o", "r", "b")
-	})
-}
-
-func TestRepositoriesService_ListRequiredStatusChecksContexts(t *testing.T) {
-	client, mux, _, teardown := setup()
-	defer teardown()
-
-	mux.HandleFunc("/repos/o/r/branches/b/protection/required_status_checks/contexts", func(w http.ResponseWriter, r *http.Request) {
-		testMethod(t, r, "GET")
-		fmt.Fprint(w, `["x", "y", "z"]`)
-	})
-
-	ctx := context.Background()
-	contexts, _, err := client.Repositories.ListRequiredStatusChecksContexts(ctx, "o", "r", "b")
-	if err != nil {
-		t.Errorf("Repositories.ListRequiredStatusChecksContexts returned error: %v", err)
-	}
-
-	want := []string{"x", "y", "z"}
-	if !cmp.Equal(contexts, want) {
-		t.Errorf("Repositories.ListRequiredStatusChecksContexts returned %+v, want %+v", contexts, want)
-	}
-
-	const methodName = "ListRequiredStatusChecksContexts"
-	testBadOptions(t, methodName, func() (err error) {
-		_, _, err = client.Repositories.ListRequiredStatusChecksContexts(ctx, "\n", "\n", "\n")
-		return err
-	})
-
-	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
-		got, resp, err := client.Repositories.ListRequiredStatusChecksContexts(ctx, "o", "r", "b")
-		if got != nil {
-			t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
-		}
-		return resp, err
-	})
-}
-
-func TestRepositoriesService_ListRequiredStatusChecksContexts_branchNotProtected(t *testing.T) {
-	client, mux, _, teardown := setup()
-	defer teardown()
-
-	mux.HandleFunc("/repos/o/r/branches/b/protection/required_status_checks/contexts", func(w http.ResponseWriter, r *http.Request) {
-		testMethod(t, r, "GET")
-
-		w.WriteHeader(http.StatusBadRequest)
-		fmt.Fprintf(w, `{
-			"message": %q,
-			"documentation_url": "https://docs.github.com/rest/repos#get-branch-protection"
-			}`, githubBranchNotProtected)
-	})
-
-	ctx := context.Background()
-	contexts, _, err := client.Repositories.ListRequiredStatusChecksContexts(ctx, "o", "r", "b")
-
-	if contexts != nil {
-		t.Errorf("Repositories.ListRequiredStatusChecksContexts returned non-nil contexts data")
-	}
-
-	if err != ErrBranchNotProtected {
-		t.Errorf("Repositories.ListRequiredStatusChecksContexts returned an invalid error: %v", err)
-	}
-}
-
-func TestRepositoriesService_GetPullRequestReviewEnforcement(t *testing.T) {
-	client, mux, _, teardown := setup()
-	defer teardown()
-
-	mux.HandleFunc("/repos/o/r/branches/b/protection/required_pull_request_reviews", func(w http.ResponseWriter, r *http.Request) {
-		testMethod(t, r, "GET")
-		// TODO: remove custom Accept header when this API fully launches
-		testHeader(t, r, "Accept", mediaTypeRequiredApprovingReviewsPreview)
-		fmt.Fprintf(w, `{
-			"dismissal_restrictions":{
-				"users":[{"id":1,"login":"u"}],
-				"teams":[{"id":2,"slug":"t"}],
-				"apps":[{"id":3,"slug":"a"}]
-			},
-			"dismiss_stale_reviews":true,
-			"require_code_owner_reviews":true,
-			"required_approving_review_count":1
-		}`)
-	})
-
-	ctx := context.Background()
-	enforcement, _, err := client.Repositories.GetPullRequestReviewEnforcement(ctx, "o", "r", "b")
-	if err != nil {
-		t.Errorf("Repositories.GetPullRequestReviewEnforcement returned error: %v", err)
-	}
-
-	want := &PullRequestReviewsEnforcement{
-		DismissStaleReviews: true,
-		DismissalRestrictions: &DismissalRestrictions{
-			Users: []*User{
-				{Login: String("u"), ID: Int64(1)},
-			},
-			Teams: []*Team{
-				{Slug: String("t"), ID: Int64(2)},
-			},
-			Apps: []*App{
-				{Slug: String("a"), ID: Int64(3)},
-			},
-		},
-		RequireCodeOwnerReviews:      true,
-		RequiredApprovingReviewCount: 1,
-	}
-
-	if !cmp.Equal(enforcement, want) {
-		t.Errorf("Repositories.GetPullRequestReviewEnforcement returned %+v, want %+v", enforcement, want)
-	}
-
-	const methodName = "GetPullRequestReviewEnforcement"
-	testBadOptions(t, methodName, func() (err error) {
-		_, _, err = client.Repositories.GetPullRequestReviewEnforcement(ctx, "\n", "\n", "\n")
-		return err
-	})
-
-	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
-		got, resp, err := client.Repositories.GetPullRequestReviewEnforcement(ctx, "o", "r", "b")
-		if got != nil {
-			t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
-		}
-		return resp, err
-	})
-}
-
-func TestRepositoriesService_UpdatePullRequestReviewEnforcement(t *testing.T) {
-	client, mux, _, teardown := setup()
-	defer teardown()
-
-	input := &PullRequestReviewsEnforcementUpdate{
-		DismissalRestrictionsRequest: &DismissalRestrictionsRequest{
-			Users: &[]string{"u"},
-			Teams: &[]string{"t"},
-			Apps:  &[]string{"a"},
-		},
-	}
-
-	mux.HandleFunc("/repos/o/r/branches/b/protection/required_pull_request_reviews", func(w http.ResponseWriter, r *http.Request) {
-		v := new(PullRequestReviewsEnforcementUpdate)
-		assertNilError(t, json.NewDecoder(r.Body).Decode(v))
-
-		testMethod(t, r, "PATCH")
-		if !cmp.Equal(v, input) {
-			t.Errorf("Request body = %+v, want %+v", v, input)
-		}
-		// TODO: remove custom Accept header when this API fully launches
-		testHeader(t, r, "Accept", mediaTypeRequiredApprovingReviewsPreview)
-		fmt.Fprintf(w, `{
-			"dismissal_restrictions":{
-				"users":[{"id":1,"login":"u"}],
-				"teams":[{"id":2,"slug":"t"}],
-				"apps":[{"id":3,"slug":"a"}]
-			},
-			"dismiss_stale_reviews":true,
-			"require_code_owner_reviews":true,
-			"required_approving_review_count":3
-		}`)
-	})
-
-	ctx := context.Background()
-	enforcement, _, err := client.Repositories.UpdatePullRequestReviewEnforcement(ctx, "o", "r", "b", input)
-	if err != nil {
-		t.Errorf("Repositories.UpdatePullRequestReviewEnforcement returned error: %v", err)
-	}
-
-	want := &PullRequestReviewsEnforcement{
-		DismissStaleReviews: true,
-		DismissalRestrictions: &DismissalRestrictions{
-			Users: []*User{
-				{Login: String("u"), ID: Int64(1)},
-			},
-			Teams: []*Team{
-				{Slug: String("t"), ID: Int64(2)},
-			},
-			Apps: []*App{
-				{Slug: String("a"), ID: Int64(3)},
-			},
-		},
-		RequireCodeOwnerReviews:      true,
-		RequiredApprovingReviewCount: 3,
-	}
-	if !cmp.Equal(enforcement, want) {
-		t.Errorf("Repositories.UpdatePullRequestReviewEnforcement returned %+v, want %+v", enforcement, want)
-	}
-
-	const methodName = "UpdatePullRequestReviewEnforcement"
-	testBadOptions(t, methodName, func() (err error) {
-		_, _, err = client.Repositories.UpdatePullRequestReviewEnforcement(ctx, "\n", "\n", "\n", input)
-		return err
-	})
-
-	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
-		got, resp, err := client.Repositories.UpdatePullRequestReviewEnforcement(ctx, "o", "r", "b", input)
-		if got != nil {
-			t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
-		}
-		return resp, err
-	})
-}
-
-func TestRepositoriesService_DisableDismissalRestrictions(t *testing.T) {
-	client, mux, _, teardown := setup()
-	defer teardown()
-
-	mux.HandleFunc("/repos/o/r/branches/b/protection/required_pull_request_reviews", func(w http.ResponseWriter, r *http.Request) {
-		testMethod(t, r, "PATCH")
-		// TODO: remove custom Accept header when this API fully launches
-		testHeader(t, r, "Accept", mediaTypeRequiredApprovingReviewsPreview)
-		testBody(t, r, `{"dismissal_restrictions":{}}`+"\n")
-		fmt.Fprintf(w, `{"dismiss_stale_reviews":true,"require_code_owner_reviews":true,"required_approving_review_count":1}`)
-	})
-
-	ctx := context.Background()
-	enforcement, _, err := client.Repositories.DisableDismissalRestrictions(ctx, "o", "r", "b")
-	if err != nil {
-		t.Errorf("Repositories.DisableDismissalRestrictions returned error: %v", err)
-	}
-
-	want := &PullRequestReviewsEnforcement{
-		DismissStaleReviews:          true,
-		DismissalRestrictions:        nil,
-		RequireCodeOwnerReviews:      true,
-		RequiredApprovingReviewCount: 1,
-	}
-	if !cmp.Equal(enforcement, want) {
-		t.Errorf("Repositories.DisableDismissalRestrictions returned %+v, want %+v", enforcement, want)
-	}
-
-	const methodName = "DisableDismissalRestrictions"
-	testBadOptions(t, methodName, func() (err error) {
-		_, _, err = client.Repositories.DisableDismissalRestrictions(ctx, "\n", "\n", "\n")
-		return err
-	})
-
-	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
-		got, resp, err := client.Repositories.DisableDismissalRestrictions(ctx, "o", "r", "b")
-		if got != nil {
-			t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
-		}
-		return resp, err
-	})
-}
-
-func TestRepositoriesService_RemovePullRequestReviewEnforcement(t *testing.T) {
-	client, mux, _, teardown := setup()
-	defer teardown()
-
-	mux.HandleFunc("/repos/o/r/branches/b/protection/required_pull_request_reviews", func(w http.ResponseWriter, r *http.Request) {
-		testMethod(t, r, "DELETE")
-		w.WriteHeader(http.StatusNoContent)
-	})
-
-	ctx := context.Background()
-	_, err := client.Repositories.RemovePullRequestReviewEnforcement(ctx, "o", "r", "b")
-	if err != nil {
-		t.Errorf("Repositories.RemovePullRequestReviewEnforcement returned error: %v", err)
-	}
-
-	const methodName = "RemovePullRequestReviewEnforcement"
-	testBadOptions(t, methodName, func() (err error) {
-		_, err = client.Repositories.RemovePullRequestReviewEnforcement(ctx, "\n", "\n", "\n")
-		return err
-	})
-
-	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
-		return client.Repositories.RemovePullRequestReviewEnforcement(ctx, "o", "r", "b")
-	})
-}
-
-func TestRepositoriesService_GetAdminEnforcement(t *testing.T) {
-	client, mux, _, teardown := setup()
-	defer teardown()
-
-	mux.HandleFunc("/repos/o/r/branches/b/protection/enforce_admins", func(w http.ResponseWriter, r *http.Request) {
-		testMethod(t, r, "GET")
-		fmt.Fprintf(w, `{"url":"/repos/o/r/branches/b/protection/enforce_admins","enabled":true}`)
-	})
-
-	ctx := context.Background()
-	enforcement, _, err := client.Repositories.GetAdminEnforcement(ctx, "o", "r", "b")
-	if err != nil {
-		t.Errorf("Repositories.GetAdminEnforcement returned error: %v", err)
-	}
-
-	want := &AdminEnforcement{
-		URL:     String("/repos/o/r/branches/b/protection/enforce_admins"),
-		Enabled: true,
-	}
-
-	if !cmp.Equal(enforcement, want) {
-		t.Errorf("Repositories.GetAdminEnforcement returned %+v, want %+v", enforcement, want)
-	}
-
-	const methodName = "GetAdminEnforcement"
-	testBadOptions(t, methodName, func() (err error) {
-		_, _, err = client.Repositories.GetAdminEnforcement(ctx, "\n", "\n", "\n")
-		return err
-	})
-
-	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
-		got, resp, err := client.Repositories.GetAdminEnforcement(ctx, "o", "r", "b")
-		if got != nil {
-			t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
-		}
-		return resp, err
-	})
-}
-
-func TestRepositoriesService_AddAdminEnforcement(t *testing.T) {
-	client, mux, _, teardown := setup()
-	defer teardown()
-
-	mux.HandleFunc("/repos/o/r/branches/b/protection/enforce_admins", func(w http.ResponseWriter, r *http.Request) {
-		testMethod(t, r, "POST")
-		fmt.Fprintf(w, `{"url":"/repos/o/r/branches/b/protection/enforce_admins","enabled":true}`)
-	})
-
-	ctx := context.Background()
-	enforcement, _, err := client.Repositories.AddAdminEnforcement(ctx, "o", "r", "b")
-	if err != nil {
-		t.Errorf("Repositories.AddAdminEnforcement returned error: %v", err)
-	}
-
-	want := &AdminEnforcement{
-		URL:     String("/repos/o/r/branches/b/protection/enforce_admins"),
-		Enabled: true,
-	}
-	if !cmp.Equal(enforcement, want) {
-		t.Errorf("Repositories.AddAdminEnforcement returned %+v, want %+v", enforcement, want)
-	}
-
-	const methodName = "AddAdminEnforcement"
-	testBadOptions(t, methodName, func() (err error) {
-		_, _, err = client.Repositories.AddAdminEnforcement(ctx, "\n", "\n", "\n")
-		return err
-	})
-
-	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
-		got, resp, err := client.Repositories.AddAdminEnforcement(ctx, "o", "r", "b")
-		if got != nil {
-			t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
-		}
-		return resp, err
-	})
-}
-
-func TestRepositoriesService_RemoveAdminEnforcement(t *testing.T) {
-	client, mux, _, teardown := setup()
-	defer teardown()
-
-	mux.HandleFunc("/repos/o/r/branches/b/protection/enforce_admins", func(w http.ResponseWriter, r *http.Request) {
-		testMethod(t, r, "DELETE")
-		w.WriteHeader(http.StatusNoContent)
-	})
-
-	ctx := context.Background()
-	_, err := client.Repositories.RemoveAdminEnforcement(ctx, "o", "r", "b")
-	if err != nil {
-		t.Errorf("Repositories.RemoveAdminEnforcement returned error: %v", err)
-	}
-
-	const methodName = "RemoveAdminEnforcement"
-	testBadOptions(t, methodName, func() (err error) {
-		_, err = client.Repositories.RemoveAdminEnforcement(ctx, "\n", "\n", "\n")
-		return err
-	})
-
-	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
-		return client.Repositories.RemoveAdminEnforcement(ctx, "o", "r", "b")
-	})
-}
-
-func TestRepositoriesService_GetSignaturesProtectedBranch(t *testing.T) {
-	client, mux, _, teardown := setup()
-	defer teardown()
-
-	mux.HandleFunc("/repos/o/r/branches/b/protection/required_signatures", func(w http.ResponseWriter, r *http.Request) {
-		testMethod(t, r, "GET")
-		testHeader(t, r, "Accept", mediaTypeSignaturePreview)
-		fmt.Fprintf(w, `{"url":"/repos/o/r/branches/b/protection/required_signatures","enabled":false}`)
-	})
-
-	ctx := context.Background()
-	signature, _, err := client.Repositories.GetSignaturesProtectedBranch(ctx, "o", "r", "b")
-	if err != nil {
-		t.Errorf("Repositories.GetSignaturesProtectedBranch returned error: %v", err)
-	}
-
-	want := &SignaturesProtectedBranch{
-		URL:     String("/repos/o/r/branches/b/protection/required_signatures"),
-		Enabled: Bool(false),
-	}
-
-	if !cmp.Equal(signature, want) {
-		t.Errorf("Repositories.GetSignaturesProtectedBranch returned %+v, want %+v", signature, want)
-	}
-
-	const methodName = "GetSignaturesProtectedBranch"
-	testBadOptions(t, methodName, func() (err error) {
-		_, _, err = client.Repositories.GetSignaturesProtectedBranch(ctx, "\n", "\n", "\n")
-		return err
-	})
-
-	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
-		got, resp, err := client.Repositories.GetSignaturesProtectedBranch(ctx, "o", "r", "b")
-		if got != nil {
-			t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
-		}
-		return resp, err
-	})
-}
-
-func TestRepositoriesService_RequireSignaturesOnProtectedBranch(t *testing.T) {
-	client, mux, _, teardown := setup()
-	defer teardown()
-
-	mux.HandleFunc("/repos/o/r/branches/b/protection/required_signatures", func(w http.ResponseWriter, r *http.Request) {
-		testMethod(t, r, "POST")
-		testHeader(t, r, "Accept", mediaTypeSignaturePreview)
-		fmt.Fprintf(w, `{"url":"/repos/o/r/branches/b/protection/required_signatures","enabled":true}`)
-	})
-
-	ctx := context.Background()
-	signature, _, err := client.Repositories.RequireSignaturesOnProtectedBranch(ctx, "o", "r", "b")
-	if err != nil {
-		t.Errorf("Repositories.RequireSignaturesOnProtectedBranch returned error: %v", err)
-	}
-
-	want := &SignaturesProtectedBranch{
-		URL:     String("/repos/o/r/branches/b/protection/required_signatures"),
-		Enabled: Bool(true),
-	}
-
-	if !cmp.Equal(signature, want) {
-		t.Errorf("Repositories.RequireSignaturesOnProtectedBranch returned %+v, want %+v", signature, want)
-	}
-
-	const methodName = "RequireSignaturesOnProtectedBranch"
-	testBadOptions(t, methodName, func() (err error) {
-		_, _, err = client.Repositories.RequireSignaturesOnProtectedBranch(ctx, "\n", "\n", "\n")
-		return err
-	})
-
-	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
-		got, resp, err := client.Repositories.RequireSignaturesOnProtectedBranch(ctx, "o", "r", "b")
-		if got != nil {
-			t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
-		}
-		return resp, err
-	})
-}
-
-func TestRepositoriesService_OptionalSignaturesOnProtectedBranch(t *testing.T) {
-	client, mux, _, teardown := setup()
-	defer teardown()
-
-	mux.HandleFunc("/repos/o/r/branches/b/protection/required_signatures", func(w http.ResponseWriter, r *http.Request) {
-		testMethod(t, r, "DELETE")
-		testHeader(t, r, "Accept", mediaTypeSignaturePreview)
-		w.WriteHeader(http.StatusNoContent)
-	})
-
-	ctx := context.Background()
-	_, err := client.Repositories.OptionalSignaturesOnProtectedBranch(ctx, "o", "r", "b")
-	if err != nil {
-		t.Errorf("Repositories.OptionalSignaturesOnProtectedBranch returned error: %v", err)
-	}
-
-	const methodName = "OptionalSignaturesOnProtectedBranch"
-	testBadOptions(t, methodName, func() (err error) {
-		_, err = client.Repositories.OptionalSignaturesOnProtectedBranch(ctx, "\n", "\n", "\n")
-		return err
-	})
-
-	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
-		return client.Repositories.OptionalSignaturesOnProtectedBranch(ctx, "o", "r", "b")
-	})
-}
-
-func TestPullRequestReviewsEnforcementRequest_MarshalJSON_nilDismissalRestirctions(t *testing.T) {
-	req := PullRequestReviewsEnforcementRequest{}
-
-	got, err := json.Marshal(req)
-	if err != nil {
-		t.Errorf("PullRequestReviewsEnforcementRequest.MarshalJSON returned error: %v", err)
-	}
-
-	want := `{"dismiss_stale_reviews":false,"require_code_owner_reviews":false,"required_approving_review_count":0}`
-	if want != string(got) {
-		t.Errorf("PullRequestReviewsEnforcementRequest.MarshalJSON returned %+v, want %+v", string(got), want)
-	}
-
-	req = PullRequestReviewsEnforcementRequest{
-		DismissalRestrictionsRequest: &DismissalRestrictionsRequest{},
-	}
-
-	got, err = json.Marshal(req)
-	if err != nil {
-		t.Errorf("PullRequestReviewsEnforcementRequest.MarshalJSON returned error: %v", err)
-	}
-
-	want = `{"dismissal_restrictions":{},"dismiss_stale_reviews":false,"require_code_owner_reviews":false,"required_approving_review_count":0}`
-	if want != string(got) {
-		t.Errorf("PullRequestReviewsEnforcementRequest.MarshalJSON returned %+v, want %+v", string(got), want)
-	}
-
-	req = PullRequestReviewsEnforcementRequest{
-		DismissalRestrictionsRequest: &DismissalRestrictionsRequest{
-			Users: &[]string{},
-			Teams: &[]string{},
-			Apps:  &[]string{},
-		},
-		RequireLastPushApproval: Bool(true),
-	}
-
-	got, err = json.Marshal(req)
-	if err != nil {
-		t.Errorf("PullRequestReviewsEnforcementRequest.MarshalJSON returned error: %v", err)
-	}
-
-	want = `{"dismissal_restrictions":{"users":[],"teams":[],"apps":[]},"dismiss_stale_reviews":false,"require_code_owner_reviews":false,"required_approving_review_count":0,"require_last_push_approval":true}`
-	if want != string(got) {
-		t.Errorf("PullRequestReviewsEnforcementRequest.MarshalJSON returned %+v, want %+v", string(got), want)
-	}
-}
-
-func TestRepositoriesService_ListAllTopics(t *testing.T) {
-	client, mux, _, teardown := setup()
-	defer teardown()
-
-	mux.HandleFunc("/repos/o/r/topics", func(w http.ResponseWriter, r *http.Request) {
-		testMethod(t, r, "GET")
-		testHeader(t, r, "Accept", mediaTypeTopicsPreview)
-		fmt.Fprint(w, `{"names":["go", "go-github", "github"]}`)
-	})
-
-	ctx := context.Background()
-	got, _, err := client.Repositories.ListAllTopics(ctx, "o", "r")
-	if err != nil {
-		t.Fatalf("Repositories.ListAllTopics returned error: %v", err)
-	}
-
-	want := []string{"go", "go-github", "github"}
-	if !cmp.Equal(got, want) {
-		t.Errorf("Repositories.ListAllTopics returned %+v, want %+v", got, want)
-	}
-
-	const methodName = "ListAllTopics"
-	testBadOptions(t, methodName, func() (err error) {
-		_, _, err = client.Repositories.ListAllTopics(ctx, "\n", "\n")
-		return err
-	})
-
-	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
-		got, resp, err := client.Repositories.ListAllTopics(ctx, "o", "r")
-		if got != nil {
-			t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
-		}
-		return resp, err
-	})
-}
+				// TODO: remove custom Accept header when this API fully launches
+				testHeader(t, r, "Accept", mediaTypeRequiredApprovingReviewsPreview)
+				fmt.Fprintf(w, `{
+					"dismissal_restrictions":{
+						"users":[{"id":1,"login":"u"}],
+						"teams":[{"id":2,"slug":"t"}],
+						"apps":[{"id":3,"slug":"a"}]
+					},
+					"dismiss_stale_reviews":true,
+					"require_code_owner_reviews":true,
+					"required_approving_review_count":3
+				}`)
+			})
 
-func TestRepositoriesService_ListAllTopics_emptyTopics(t *testing.T) {
-	client, mux, _, teardown := setup()
-	defer teardown()
+			ctx := context.Background()
+			enforcement, _, err := client.Repositories.UpdatePullRequestReviewEnforcement(ctx, "o", "r", test.branch, input)
+			if err != nil {
+				t.Errorf("Repositories.UpdatePullRequestReviewEnforcement returned error: %v", err)
+			}
 
-	mux.HandleFunc("/repos/o/r/topics", func(w http.ResponseWriter, r *http.Request) {
-		testMethod(t, r, "GET")
-		testHeader(t, r, "Accept", mediaTypeTopicsPreview)
-		fmt.Fprint(w, `{"names":[]}`)
-	})
+			want := &PullRequestReviewsEnforcement{
+				DismissStaleReviews: true,
+				DismissalRestrictions: &DismissalRestrictions{
+					Users: []*User{
+						{Login: String("u"), ID: Int64(1)},
+					},
+					Teams: []*Team{
+						{Slug: String("t"), ID: Int64(2)},
+					},
+					Apps: []*App{
+						{Slug: String("a"), ID: Int64(3)},
+					},
+				},
+				RequireCodeOwnerReviews:      true,
+				RequiredApprovingReviewCount: 3,
+			}
+			if !cmp.Equal(enforcement, want) {
+				t.Errorf("Repositories.UpdatePullRequestReviewEnforcement returned %+v, want %+v", enforcement, want)
+			}
 
-	ctx := context.Background()
-	got, _, err := client.Repositories.ListAllTopics(ctx, "o", "r")
-	if err != nil {
-		t.Fatalf("Repositories.ListAllTopics returned error: %v", err)
-	}
+			const methodName = "UpdatePullRequestReviewEnforcement"
+			testBadOptions(t, methodName, func() (err error) {
+				_, _, err = client.Repositories.UpdatePullRequestReviewEnforcement(ctx, "\n", "\n", "\n", input)
+				return err
+			})
 
-	want := []string{}
-	if !cmp.Equal(got, want) {
-		t.Errorf("Repositories.ListAllTopics returned %+v, want %+v", got, want)
+			testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
+				got, resp, err := client.Repositories.UpdatePullRequestReviewEnforcement(ctx, "o", "r", test.branch, input)
+				if got != nil {
+					t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
+				}
+				return resp, err
+			})
+		})
 	}
 }
 
-func TestRepositoriesService_ReplaceAllTopics(t *testing.T) {
-	client, mux, _, teardown := setup()
-	defer teardown()
+func TestRepositoriesService_DisableDismissalRestrictions(t *testing.T) {
+	tests := []struct {
+		branch  string
+		urlPath string
+	}{
+		{branch: "b", urlPath: "/repos/o/r/branches/b/protection/required_pull_request_reviews"},
+		{branch: "feat/branch-50%", urlPath: "/repos/o/r/branches/feat/branch-50%/protection/required_pull_request_reviews"},
+	}
+
+	for _, test := range tests {
+		t.Run(test.branch, func(t *testing.T) {
+			client, mux, _, teardown := setup()
+			defer teardown()
+
+			mux.HandleFunc(test.urlPath, func(w http.ResponseWriter, r *http.Request) {
+				testMethod(t, r, "PATCH")
+				// TODO: remove custom Accept header when this API fully launches
+				testHeader(t, r, "Accept", mediaTypeRequiredApprovingReviewsPreview)
+				testBody(t, r, `{"dismissal_restrictions":{}}`+"\n")
+				fmt.Fprintf(w, `{"dismiss_stale_reviews":true,"require_code_owner_reviews":true,"required_approving_review_count":1}`)
+			})
+
+			ctx := context.Background()
+			enforcement, _, err := client.Repositories.DisableDismissalRestrictions(ctx, "o", "r", test.branch)
+			if err != nil {
+				t.Errorf("Repositories.DisableDismissalRestrictions returned error: %v", err)
+			}
 
-	mux.HandleFunc("/repos/o/r/topics", func(w http.ResponseWriter, r *http.Request) {
-		testMethod(t, r, "PUT")
-		testHeader(t, r, "Accept", mediaTypeTopicsPreview)
-		fmt.Fprint(w, `{"names":["go", "go-github", "github"]}`)
-	})
+			want := &PullRequestReviewsEnforcement{
+				DismissStaleReviews:          true,
+				DismissalRestrictions:        nil,
+				RequireCodeOwnerReviews:      true,
+				RequiredApprovingReviewCount: 1,
+			}
+			if !cmp.Equal(enforcement, want) {
+				t.Errorf("Repositories.DisableDismissalRestrictions returned %+v, want %+v", enforcement, want)
+			}
 
-	ctx := context.Background()
-	got, _, err := client.Repositories.ReplaceAllTopics(ctx, "o", "r", []string{"go", "go-github", "github"})
-	if err != nil {
-		t.Fatalf("Repositories.ReplaceAllTopics returned error: %v", err)
-	}
+			const methodName = "DisableDismissalRestrictions"
+			testBadOptions(t, methodName, func() (err error) {
+				_, _, err = client.Repositories.DisableDismissalRestrictions(ctx, "\n", "\n", "\n")
+				return err
+			})
 
-	want := []string{"go", "go-github", "github"}
-	if !cmp.Equal(got, want) {
-		t.Errorf("Repositories.ReplaceAllTopics returned %+v, want %+v", got, want)
+			testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
+				got, resp, err := client.Repositories.DisableDismissalRestrictions(ctx, "o", "r", test.branch)
+				if got != nil {
+					t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
+				}
+				return resp, err
+			})
+		})
 	}
+}
 
-	const methodName = "ReplaceAllTopics"
-	testBadOptions(t, methodName, func() (err error) {
-		_, _, err = client.Repositories.ReplaceAllTopics(ctx, "\n", "\n", []string{"\n", "\n", "\n"})
-		return err
-	})
+func TestRepositoriesService_RemovePullRequestReviewEnforcement(t *testing.T) {
+	tests := []struct {
+		branch  string
+		urlPath string
+	}{
+		{branch: "b", urlPath: "/repos/o/r/branches/b/protection/required_pull_request_reviews"},
+		{branch: "feat/branch-50%", urlPath: "/repos/o/r/branches/feat/branch-50%/protection/required_pull_request_reviews"},
+	}
+
+	for _, test := range tests {
+		t.Run(test.branch, func(t *testing.T) {
+			client, mux, _, teardown := setup()
+			defer teardown()
+
+			mux.HandleFunc(test.urlPath, func(w http.ResponseWriter, r *http.Request) {
+				testMethod(t, r, "DELETE")
+				w.WriteHeader(http.StatusNoContent)
+			})
+
+			ctx := context.Background()
+			_, err := client.Repositories.RemovePullRequestReviewEnforcement(ctx, "o", "r", test.branch)
+			if err != nil {
+				t.Errorf("Repositories.RemovePullRequestReviewEnforcement returned error: %v", err)
+			}
 
-	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
-		got, resp, err := client.Repositories.ReplaceAllTopics(ctx, "o", "r", []string{"go", "go-github", "github"})
-		if got != nil {
-			t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
-		}
-		return resp, err
-	})
+			const methodName = "RemovePullRequestReviewEnforcement"
+			testBadOptions(t, methodName, func() (err error) {
+				_, err = client.Repositories.RemovePullRequestReviewEnforcement(ctx, "\n", "\n", "\n")
+				return err
+			})
+
+			testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
+				return client.Repositories.RemovePullRequestReviewEnforcement(ctx, "o", "r", test.branch)
+			})
+		})
+	}
 }
 
-func TestRepositoriesService_ReplaceAllTopics_nilSlice(t *testing.T) {
-	client, mux, _, teardown := setup()
-	defer teardown()
+func TestRepositoriesService_GetAdminEnforcement(t *testing.T) {
+	tests := []struct {
+		branch  string
+		urlPath string
+	}{
+		{branch: "b", urlPath: "/repos/o/r/branches/b/protection/enforce_admins"},
+		{branch: "feat/branch-50%", urlPath: "/repos/o/r/branches/feat/branch-50%/protection/enforce_admins"},
+	}
+
+	for _, test := range tests {
+		t.Run(test.branch, func(t *testing.T) {
+			client, mux, _, teardown := setup()
+			defer teardown()
+
+			mux.HandleFunc(test.urlPath, func(w http.ResponseWriter, r *http.Request) {
+				testMethod(t, r, "GET")
+				fmt.Fprintf(w, `{"url":"/repos/o/r/branches/b/protection/enforce_admins","enabled":true}`)
+			})
+
+			ctx := context.Background()
+			enforcement, _, err := client.Repositories.GetAdminEnforcement(ctx, "o", "r", test.branch)
+			if err != nil {
+				t.Errorf("Repositories.GetAdminEnforcement returned error: %v", err)
+			}
 
-	mux.HandleFunc("/repos/o/r/topics", func(w http.ResponseWriter, r *http.Request) {
-		testMethod(t, r, "PUT")
-		testHeader(t, r, "Accept", mediaTypeTopicsPreview)
-		testBody(t, r, `{"names":[]}`+"\n")
-		fmt.Fprint(w, `{"names":[]}`)
-	})
+			want := &AdminEnforcement{
+				URL:     String("/repos/o/r/branches/b/protection/enforce_admins"),
+				Enabled: true,
+			}
 
-	ctx := context.Background()
-	got, _, err := client.Repositories.ReplaceAllTopics(ctx, "o", "r", nil)
-	if err != nil {
-		t.Fatalf("Repositories.ReplaceAllTopics returned error: %v", err)
-	}
+			if !cmp.Equal(enforcement, want) {
+				t.Errorf("Repositories.GetAdminEnforcement returned %+v, want %+v", enforcement, want)
+			}
 
-	want := []string{}
-	if !cmp.Equal(got, want) {
-		t.Errorf("Repositories.ReplaceAllTopics returned %+v, want %+v", got, want)
+			const methodName = "GetAdminEnforcement"
+			testBadOptions(t, methodName, func() (err error) {
+				_, _, err = client.Repositories.GetAdminEnforcement(ctx, "\n", "\n", "\n")
+				return err
+			})
+
+			testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
+				got, resp, err := client.Repositories.GetAdminEnforcement(ctx, "o", "r", test.branch)
+				if got != nil {
+					t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
+				}
+				return resp, err
+			})
+		})
 	}
 }
 
-func TestRepositoriesService_ReplaceAllTopics_emptySlice(t *testing.T) {
-	client, mux, _, teardown := setup()
-	defer teardown()
+func TestRepositoriesService_AddAdminEnforcement(t *testing.T) {
+	tests := []struct {
+		branch  string
+		urlPath string
+	}{
+		{branch: "b", urlPath: "/repos/o/r/branches/b/protection/enforce_admins"},
+		{branch: "feat/branch-50%", urlPath: "/repos/o/r/branches/feat/branch-50%/protection/enforce_admins"},
+	}
+
+	for _, test := range tests {
+		t.Run(test.branch, func(t *testing.T) {
+			client, mux, _, teardown := setup()
+			defer teardown()
+
+			mux.HandleFunc(test.urlPath, func(w http.ResponseWriter, r *http.Request) {
+				testMethod(t, r, "POST")
+				fmt.Fprintf(w, `{"url":"/repos/o/r/branches/b/protection/enforce_admins","enabled":true}`)
+			})
+
+			ctx := context.Background()
+			enforcement, _, err := client.Repositories.AddAdminEnforcement(ctx, "o", "r", test.branch)
+			if err != nil {
+				t.Errorf("Repositories.AddAdminEnforcement returned error: %v", err)
+			}
 
-	mux.HandleFunc("/repos/o/r/topics", func(w http.ResponseWriter, r *http.Request) {
-		testMethod(t, r, "PUT")
-		testHeader(t, r, "Accept", mediaTypeTopicsPreview)
-		testBody(t, r, `{"names":[]}`+"\n")
-		fmt.Fprint(w, `{"names":[]}`)
-	})
+			want := &AdminEnforcement{
+				URL:     String("/repos/o/r/branches/b/protection/enforce_admins"),
+				Enabled: true,
+			}
+			if !cmp.Equal(enforcement, want) {
+				t.Errorf("Repositories.AddAdminEnforcement returned %+v, want %+v", enforcement, want)
+			}
 
-	ctx := context.Background()
-	got, _, err := client.Repositories.ReplaceAllTopics(ctx, "o", "r", []string{})
-	if err != nil {
-		t.Fatalf("Repositories.ReplaceAllTopics returned error: %v", err)
-	}
+			const methodName = "AddAdminEnforcement"
+			testBadOptions(t, methodName, func() (err error) {
+				_, _, err = client.Repositories.AddAdminEnforcement(ctx, "\n", "\n", "\n")
+				return err
+			})
 
-	want := []string{}
-	if !cmp.Equal(got, want) {
-		t.Errorf("Repositories.ReplaceAllTopics returned %+v, want %+v", got, want)
+			testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
+				got, resp, err := client.Repositories.AddAdminEnforcement(ctx, "o", "r", test.branch)
+				if got != nil {
+					t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
+				}
+				return resp, err
+			})
+		})
 	}
 }
 
-func TestRepositoriesService_ListAppRestrictions(t *testing.T) {
-	client, mux, _, teardown := setup()
-	defer teardown()
+func TestRepositoriesService_RemoveAdminEnforcement(t *testing.T) {
+	tests := []struct {
+		branch  string
+		urlPath string
+	}{
+		{branch: "b", urlPath: "/repos/o/r/branches/b/protection/enforce_admins"},
+		{branch: "feat/branch-50%", urlPath: "/repos/o/r/branches/feat/branch-50%/protection/enforce_admins"},
+	}
+
+	for _, test := range tests {
+		t.Run(test.branch, func(t *testing.T) {
+			client, mux, _, teardown := setup()
+			defer teardown()
+
+			mux.HandleFunc(test.urlPath, func(w http.ResponseWriter, r *http.Request) {
+				testMethod(t, r, "DELETE")
+				w.WriteHeader(http.StatusNoContent)
+			})
+
+			ctx := context.Background()
+			_, err := client.Repositories.RemoveAdminEnforcement(ctx, "o", "r", test.branch)
+			if err != nil {
+				t.Errorf("Repositories.RemoveAdminEnforcement returned error: %v", err)
+			}
 
-	mux.HandleFunc("/repos/o/r/branches/b/protection/restrictions/apps", func(w http.ResponseWriter, r *http.Request) {
-		testMethod(t, r, "GET")
-	})
+			const methodName = "RemoveAdminEnforcement"
+			testBadOptions(t, methodName, func() (err error) {
+				_, err = client.Repositories.RemoveAdminEnforcement(ctx, "\n", "\n", "\n")
+				return err
+			})
 
-	ctx := context.Background()
-	_, _, err := client.Repositories.ListAppRestrictions(ctx, "o", "r", "b")
-	if err != nil {
-		t.Errorf("Repositories.ListAppRestrictions returned error: %v", err)
+			testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
+				return client.Repositories.RemoveAdminEnforcement(ctx, "o", "r", test.branch)
+			})
+		})
 	}
+}
 
-	const methodName = "ListAppRestrictions"
-	testBadOptions(t, methodName, func() (err error) {
-		_, _, err = client.Repositories.ListAppRestrictions(ctx, "\n", "\n", "\n")
-		return err
-	})
+func TestRepositoriesService_GetSignaturesProtectedBranch(t *testing.T) {
+	tests := []struct {
+		branch  string
+		urlPath string
+	}{
+		{branch: "b", urlPath: "/repos/o/r/branches/b/protection/required_signatures"},
+		{branch: "feat/branch-50%", urlPath: "/repos/o/r/branches/feat/branch-50%/protection/required_signatures"},
+	}
+
+	for _, test := range tests {
+		t.Run(test.branch, func(t *testing.T) {
+			client, mux, _, teardown := setup()
+			defer teardown()
+
+			mux.HandleFunc(test.urlPath, func(w http.ResponseWriter, r *http.Request) {
+				testMethod(t, r, "GET")
+				testHeader(t, r, "Accept", mediaTypeSignaturePreview)
+				fmt.Fprintf(w, `{"url":"/repos/o/r/branches/b/protection/required_signatures","enabled":false}`)
+			})
+
+			ctx := context.Background()
+			signature, _, err := client.Repositories.GetSignaturesProtectedBranch(ctx, "o", "r", test.branch)
+			if err != nil {
+				t.Errorf("Repositories.GetSignaturesProtectedBranch returned error: %v", err)
+			}
 
-	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
-		got, resp, err := client.Repositories.ListAppRestrictions(ctx, "o", "r", "b")
-		if got != nil {
-			t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
-		}
-		return resp, err
-	})
-}
+			want := &SignaturesProtectedBranch{
+				URL:     String("/repos/o/r/branches/b/protection/required_signatures"),
+				Enabled: Bool(false),
+			}
 
-func TestRepositoriesService_ReplaceAppRestrictions(t *testing.T) {
-	client, mux, _, teardown := setup()
-	defer teardown()
+			if !cmp.Equal(signature, want) {
+				t.Errorf("Repositories.GetSignaturesProtectedBranch returned %+v, want %+v", signature, want)
+			}
 
-	mux.HandleFunc("/repos/o/r/branches/b/protection/restrictions/apps", func(w http.ResponseWriter, r *http.Request) {
-		testMethod(t, r, "PUT")
-		fmt.Fprint(w, `[{
-				"name": "octocat"
-			}]`)
-	})
-	input := []string{"octocat"}
-	ctx := context.Background()
-	got, _, err := client.Repositories.ReplaceAppRestrictions(ctx, "o", "r", "b", input)
-	if err != nil {
-		t.Errorf("Repositories.ReplaceAppRestrictions returned error: %v", err)
-	}
-	want := []*App{
-		{Name: String("octocat")},
-	}
-	if !cmp.Equal(got, want) {
-		t.Errorf("Repositories.ReplaceAppRestrictions returned %+v, want %+v", got, want)
+			const methodName = "GetSignaturesProtectedBranch"
+			testBadOptions(t, methodName, func() (err error) {
+				_, _, err = client.Repositories.GetSignaturesProtectedBranch(ctx, "\n", "\n", "\n")
+				return err
+			})
+
+			testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
+				got, resp, err := client.Repositories.GetSignaturesProtectedBranch(ctx, "o", "r", test.branch)
+				if got != nil {
+					t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
+				}
+				return resp, err
+			})
+		})
 	}
+}
 
-	const methodName = "ReplaceAppRestrictions"
-	testBadOptions(t, methodName, func() (err error) {
-		_, _, err = client.Repositories.ReplaceAppRestrictions(ctx, "\n", "\n", "\n", input)
-		return err
-	})
+func TestRepositoriesService_RequireSignaturesOnProtectedBranch(t *testing.T) {
+	tests := []struct {
+		branch  string
+		urlPath string
+	}{
+		{branch: "b", urlPath: "/repos/o/r/branches/b/protection/required_signatures"},
+		{branch: "feat/branch-50%", urlPath: "/repos/o/r/branches/feat/branch-50%/protection/required_signatures"},
+	}
+
+	for _, test := range tests {
+		t.Run(test.branch, func(t *testing.T) {
+			client, mux, _, teardown := setup()
+			defer teardown()
+
+			mux.HandleFunc(test.urlPath, func(w http.ResponseWriter, r *http.Request) {
+				testMethod(t, r, "POST")
+				testHeader(t, r, "Accept", mediaTypeSignaturePreview)
+				fmt.Fprintf(w, `{"url":"/repos/o/r/branches/b/protection/required_signatures","enabled":true}`)
+			})
+
+			ctx := context.Background()
+			signature, _, err := client.Repositories.RequireSignaturesOnProtectedBranch(ctx, "o", "r", test.branch)
+			if err != nil {
+				t.Errorf("Repositories.RequireSignaturesOnProtectedBranch returned error: %v", err)
+			}
 
-	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
-		got, resp, err := client.Repositories.ReplaceAppRestrictions(ctx, "o", "r", "b", input)
-		if got != nil {
-			t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
-		}
-		return resp, err
-	})
-}
+			want := &SignaturesProtectedBranch{
+				URL:     String("/repos/o/r/branches/b/protection/required_signatures"),
+				Enabled: Bool(true),
+			}
 
-func TestRepositoriesService_AddAppRestrictions(t *testing.T) {
-	client, mux, _, teardown := setup()
-	defer teardown()
+			if !cmp.Equal(signature, want) {
+				t.Errorf("Repositories.RequireSignaturesOnProtectedBranch returned %+v, want %+v", signature, want)
+			}
 
-	mux.HandleFunc("/repos/o/r/branches/b/protection/restrictions/apps", func(w http.ResponseWriter, r *http.Request) {
-		testMethod(t, r, "POST")
-		fmt.Fprint(w, `[{
-				"name": "octocat"
-			}]`)
-	})
-	input := []string{"octocat"}
-	ctx := context.Background()
-	got, _, err := client.Repositories.AddAppRestrictions(ctx, "o", "r", "b", input)
-	if err != nil {
-		t.Errorf("Repositories.AddAppRestrictions returned error: %v", err)
-	}
-	want := []*App{
-		{Name: String("octocat")},
-	}
-	if !cmp.Equal(got, want) {
-		t.Errorf("Repositories.AddAppRestrictions returned %+v, want %+v", got, want)
+			const methodName = "RequireSignaturesOnProtectedBranch"
+			testBadOptions(t, methodName, func() (err error) {
+				_, _, err = client.Repositories.RequireSignaturesOnProtectedBranch(ctx, "\n", "\n", "\n")
+				return err
+			})
+
+			testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
+				got, resp, err := client.Repositories.RequireSignaturesOnProtectedBranch(ctx, "o", "r", test.branch)
+				if got != nil {
+					t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
+				}
+				return resp, err
+			})
+		})
 	}
+}
 
-	const methodName = "AddAppRestrictions"
-	testBadOptions(t, methodName, func() (err error) {
-		_, _, err = client.Repositories.AddAppRestrictions(ctx, "\n", "\n", "\n", input)
-		return err
-	})
+func TestRepositoriesService_OptionalSignaturesOnProtectedBranch(t *testing.T) {
+	tests := []struct {
+		branch  string
+		urlPath string
+	}{
+		{branch: "b", urlPath: "/repos/o/r/branches/b/protection/required_signatures"},
+		{branch: "feat/branch-50%", urlPath: "/repos/o/r/branches/feat/branch-50%/protection/required_signatures"},
+	}
+
+	for _, test := range tests {
+		t.Run(test.branch, func(t *testing.T) {
+			client, mux, _, teardown := setup()
+			defer teardown()
+
+			mux.HandleFunc(test.urlPath, func(w http.ResponseWriter, r *http.Request) {
+				testMethod(t, r, "DELETE")
+				testHeader(t, r, "Accept", mediaTypeSignaturePreview)
+				w.WriteHeader(http.StatusNoContent)
+			})
+
+			ctx := context.Background()
+			_, err := client.Repositories.OptionalSignaturesOnProtectedBranch(ctx, "o", "r", test.branch)
+			if err != nil {
+				t.Errorf("Repositories.OptionalSignaturesOnProtectedBranch returned error: %v", err)
+			}
 
-	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
-		got, resp, err := client.Repositories.AddAppRestrictions(ctx, "o", "r", "b", input)
-		if got != nil {
-			t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
-		}
-		return resp, err
-	})
+			const methodName = "OptionalSignaturesOnProtectedBranch"
+			testBadOptions(t, methodName, func() (err error) {
+				_, err = client.Repositories.OptionalSignaturesOnProtectedBranch(ctx, "\n", "\n", "\n")
+				return err
+			})
+
+			testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
+				return client.Repositories.OptionalSignaturesOnProtectedBranch(ctx, "o", "r", test.branch)
+			})
+		})
+	}
 }
 
-func TestRepositoriesService_RemoveAppRestrictions(t *testing.T) {
-	client, mux, _, teardown := setup()
-	defer teardown()
+func TestPullRequestReviewsEnforcementRequest_MarshalJSON_nilDismissalRestirctions(t *testing.T) {
+	req := PullRequestReviewsEnforcementRequest{}
 
-	mux.HandleFunc("/repos/o/r/branches/b/protection/restrictions/apps", func(w http.ResponseWriter, r *http.Request) {
-		testMethod(t, r, "DELETE")
-		fmt.Fprint(w, `[]`)
-	})
-	input := []string{"octocat"}
-	ctx := context.Background()
-	got, _, err := client.Repositories.RemoveAppRestrictions(ctx, "o", "r", "b", input)
+	got, err := json.Marshal(req)
 	if err != nil {
-		t.Errorf("Repositories.RemoveAppRestrictions returned error: %v", err)
+		t.Errorf("PullRequestReviewsEnforcementRequest.MarshalJSON returned error: %v", err)
 	}
-	want := []*App{}
-	if !cmp.Equal(got, want) {
-		t.Errorf("Repositories.RemoveAppRestrictions returned %+v, want %+v", got, want)
+
+	want := `{"dismiss_stale_reviews":false,"require_code_owner_reviews":false,"required_approving_review_count":0}`
+	if want != string(got) {
+		t.Errorf("PullRequestReviewsEnforcementRequest.MarshalJSON returned %+v, want %+v", string(got), want)
 	}
 
-	const methodName = "RemoveAppRestrictions"
-	testBadOptions(t, methodName, func() (err error) {
-		_, _, err = client.Repositories.RemoveAppRestrictions(ctx, "\n", "\n", "\n", input)
-		return err
-	})
+	req = PullRequestReviewsEnforcementRequest{
+		DismissalRestrictionsRequest: &DismissalRestrictionsRequest{},
+	}
 
-	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
-		got, resp, err := client.Repositories.RemoveAppRestrictions(ctx, "o", "r", "b", input)
-		if got != nil {
-			t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
-		}
-		return resp, err
-	})
-}
+	got, err = json.Marshal(req)
+	if err != nil {
+		t.Errorf("PullRequestReviewsEnforcementRequest.MarshalJSON returned error: %v", err)
+	}
 
-func TestRepositoriesService_ListTeamRestrictions(t *testing.T) {
-	client, mux, _, teardown := setup()
-	defer teardown()
+	want = `{"dismissal_restrictions":{},"dismiss_stale_reviews":false,"require_code_owner_reviews":false,"required_approving_review_count":0}`
+	if want != string(got) {
+		t.Errorf("PullRequestReviewsEnforcementRequest.MarshalJSON returned %+v, want %+v", string(got), want)
+	}
 
-	mux.HandleFunc("/repos/o/r/branches/b/protection/restrictions/teams", func(w http.ResponseWriter, r *http.Request) {
-		testMethod(t, r, "GET")
-	})
+	req = PullRequestReviewsEnforcementRequest{
+		DismissalRestrictionsRequest: &DismissalRestrictionsRequest{
+			Users: &[]string{},
+			Teams: &[]string{},
+			Apps:  &[]string{},
+		},
+		RequireLastPushApproval: Bool(true),
+	}
 
-	ctx := context.Background()
-	_, _, err := client.Repositories.ListTeamRestrictions(ctx, "o", "r", "b")
+	got, err = json.Marshal(req)
 	if err != nil {
-		t.Errorf("Repositories.ListTeamRestrictions returned error: %v", err)
+		t.Errorf("PullRequestReviewsEnforcementRequest.MarshalJSON returned error: %v", err)
 	}
 
-	const methodName = "ListTeamRestrictions"
-	testBadOptions(t, methodName, func() (err error) {
-		_, _, err = client.Repositories.ListTeamRestrictions(ctx, "\n", "\n", "\n")
-		return err
-	})
-
-	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
-		got, resp, err := client.Repositories.ListTeamRestrictions(ctx, "o", "r", "b")
-		if got != nil {
-			t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
-		}
-		return resp, err
-	})
+	want = `{"dismissal_restrictions":{"users":[],"teams":[],"apps":[]},"dismiss_stale_reviews":false,"require_code_owner_reviews":false,"required_approving_review_count":0,"require_last_push_approval":true}`
+	if want != string(got) {
+		t.Errorf("PullRequestReviewsEnforcementRequest.MarshalJSON returned %+v, want %+v", string(got), want)
+	}
 }
 
-func TestRepositoriesService_ReplaceTeamRestrictions(t *testing.T) {
+func TestRepositoriesService_ListAllTopics(t *testing.T) {
 	client, mux, _, teardown := setup()
 	defer teardown()
-
-	mux.HandleFunc("/repos/o/r/branches/b/protection/restrictions/teams", func(w http.ResponseWriter, r *http.Request) {
-		testMethod(t, r, "PUT")
-		fmt.Fprint(w, `[{
-				"name": "octocat"
-			}]`)
+
+	mux.HandleFunc("/repos/o/r/topics", func(w http.ResponseWriter, r *http.Request) {
+		testMethod(t, r, "GET")
+		testHeader(t, r, "Accept", mediaTypeTopicsPreview)
+		fmt.Fprint(w, `{"names":["go", "go-github", "github"]}`)
 	})
-	input := []string{"octocat"}
+
 	ctx := context.Background()
-	got, _, err := client.Repositories.ReplaceTeamRestrictions(ctx, "o", "r", "b", input)
+	got, _, err := client.Repositories.ListAllTopics(ctx, "o", "r")
 	if err != nil {
-		t.Errorf("Repositories.ReplaceTeamRestrictions returned error: %v", err)
-	}
-	want := []*Team{
-		{Name: String("octocat")},
+		t.Fatalf("Repositories.ListAllTopics returned error: %v", err)
 	}
+
+	want := []string{"go", "go-github", "github"}
 	if !cmp.Equal(got, want) {
-		t.Errorf("Repositories.ReplaceTeamRestrictions returned %+v, want %+v", got, want)
+		t.Errorf("Repositories.ListAllTopics returned %+v, want %+v", got, want)
 	}
 
-	const methodName = "ReplaceTeamRestrictions"
+	const methodName = "ListAllTopics"
 	testBadOptions(t, methodName, func() (err error) {
-		_, _, err = client.Repositories.ReplaceTeamRestrictions(ctx, "\n", "\n", "\n", input)
+		_, _, err = client.Repositories.ListAllTopics(ctx, "\n", "\n")
 		return err
 	})
 
 	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
-		got, resp, err := client.Repositories.ReplaceTeamRestrictions(ctx, "o", "r", "b", input)
+		got, resp, err := client.Repositories.ListAllTopics(ctx, "o", "r")
 		if got != nil {
 			t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
 		}
@@ -3031,71 +3067,57 @@ func TestRepositoriesService_ReplaceTeamRestrictions(t *testing.T) {
 	})
 }
 
-func TestRepositoriesService_AddTeamRestrictions(t *testing.T) {
+func TestRepositoriesService_ListAllTopics_emptyTopics(t *testing.T) {
 	client, mux, _, teardown := setup()
 	defer teardown()
 
-	mux.HandleFunc("/repos/o/r/branches/b/protection/restrictions/teams", func(w http.ResponseWriter, r *http.Request) {
-		testMethod(t, r, "POST")
-		fmt.Fprint(w, `[{
-				"name": "octocat"
-			}]`)
+	mux.HandleFunc("/repos/o/r/topics", func(w http.ResponseWriter, r *http.Request) {
+		testMethod(t, r, "GET")
+		testHeader(t, r, "Accept", mediaTypeTopicsPreview)
+		fmt.Fprint(w, `{"names":[]}`)
 	})
-	input := []string{"octocat"}
+
 	ctx := context.Background()
-	got, _, err := client.Repositories.AddTeamRestrictions(ctx, "o", "r", "b", input)
+	got, _, err := client.Repositories.ListAllTopics(ctx, "o", "r")
 	if err != nil {
-		t.Errorf("Repositories.AddTeamRestrictions returned error: %v", err)
-	}
-	want := []*Team{
-		{Name: String("octocat")},
+		t.Fatalf("Repositories.ListAllTopics returned error: %v", err)
 	}
+
+	want := []string{}
 	if !cmp.Equal(got, want) {
-		t.Errorf("Repositories.AddTeamRestrictions returned %+v, want %+v", got, want)
+		t.Errorf("Repositories.ListAllTopics returned %+v, want %+v", got, want)
 	}
-
-	const methodName = "AddTeamRestrictions"
-	testBadOptions(t, methodName, func() (err error) {
-		_, _, err = client.Repositories.AddTeamRestrictions(ctx, "\n", "\n", "\n", input)
-		return err
-	})
-
-	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
-		got, resp, err := client.Repositories.AddTeamRestrictions(ctx, "o", "r", "b", input)
-		if got != nil {
-			t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
-		}
-		return resp, err
-	})
 }
 
-func TestRepositoriesService_RemoveTeamRestrictions(t *testing.T) {
+func TestRepositoriesService_ReplaceAllTopics(t *testing.T) {
 	client, mux, _, teardown := setup()
 	defer teardown()
 
-	mux.HandleFunc("/repos/o/r/branches/b/protection/restrictions/teams", func(w http.ResponseWriter, r *http.Request) {
-		testMethod(t, r, "DELETE")
-		fmt.Fprint(w, `[]`)
+	mux.HandleFunc("/repos/o/r/topics", func(w http.ResponseWriter, r *http.Request) {
+		testMethod(t, r, "PUT")
+		testHeader(t, r, "Accept", mediaTypeTopicsPreview)
+		fmt.Fprint(w, `{"names":["go", "go-github", "github"]}`)
 	})
-	input := []string{"octocat"}
+
 	ctx := context.Background()
-	got, _, err := client.Repositories.RemoveTeamRestrictions(ctx, "o", "r", "b", input)
+	got, _, err := client.Repositories.ReplaceAllTopics(ctx, "o", "r", []string{"go", "go-github", "github"})
 	if err != nil {
-		t.Errorf("Repositories.RemoveTeamRestrictions returned error: %v", err)
+		t.Fatalf("Repositories.ReplaceAllTopics returned error: %v", err)
 	}
-	want := []*Team{}
+
+	want := []string{"go", "go-github", "github"}
 	if !cmp.Equal(got, want) {
-		t.Errorf("Repositories.RemoveTeamRestrictions returned %+v, want %+v", got, want)
+		t.Errorf("Repositories.ReplaceAllTopics returned %+v, want %+v", got, want)
 	}
 
-	const methodName = "RemoveTeamRestrictions"
+	const methodName = "ReplaceAllTopics"
 	testBadOptions(t, methodName, func() (err error) {
-		_, _, err = client.Repositories.RemoveTeamRestrictions(ctx, "\n", "\n", "\n", input)
+		_, _, err = client.Repositories.ReplaceAllTopics(ctx, "\n", "\n", []string{"\n", "\n", "\n"})
 		return err
 	})
 
 	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
-		got, resp, err := client.Repositories.RemoveTeamRestrictions(ctx, "o", "r", "b", input)
+		got, resp, err := client.Repositories.ReplaceAllTopics(ctx, "o", "r", []string{"go", "go-github", "github"})
 		if got != nil {
 			t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
 		}
@@ -3103,143 +3125,611 @@ func TestRepositoriesService_RemoveTeamRestrictions(t *testing.T) {
 	})
 }
 
-func TestRepositoriesService_ListUserRestrictions(t *testing.T) {
+func TestRepositoriesService_ReplaceAllTopics_nilSlice(t *testing.T) {
 	client, mux, _, teardown := setup()
 	defer teardown()
 
-	mux.HandleFunc("/repos/o/r/branches/b/protection/restrictions/users", func(w http.ResponseWriter, r *http.Request) {
-		testMethod(t, r, "GET")
+	mux.HandleFunc("/repos/o/r/topics", func(w http.ResponseWriter, r *http.Request) {
+		testMethod(t, r, "PUT")
+		testHeader(t, r, "Accept", mediaTypeTopicsPreview)
+		testBody(t, r, `{"names":[]}`+"\n")
+		fmt.Fprint(w, `{"names":[]}`)
 	})
 
 	ctx := context.Background()
-	_, _, err := client.Repositories.ListUserRestrictions(ctx, "o", "r", "b")
+	got, _, err := client.Repositories.ReplaceAllTopics(ctx, "o", "r", nil)
 	if err != nil {
-		t.Errorf("Repositories.ListUserRestrictions returned error: %v", err)
+		t.Fatalf("Repositories.ReplaceAllTopics returned error: %v", err)
 	}
 
-	const methodName = "ListUserRestrictions"
-	testBadOptions(t, methodName, func() (err error) {
-		_, _, err = client.Repositories.ListUserRestrictions(ctx, "\n", "\n", "\n")
-		return err
-	})
-
-	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
-		got, resp, err := client.Repositories.ListUserRestrictions(ctx, "o", "r", "b")
-		if got != nil {
-			t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
-		}
-		return resp, err
-	})
+	want := []string{}
+	if !cmp.Equal(got, want) {
+		t.Errorf("Repositories.ReplaceAllTopics returned %+v, want %+v", got, want)
+	}
 }
 
-func TestRepositoriesService_ReplaceUserRestrictions(t *testing.T) {
+func TestRepositoriesService_ReplaceAllTopics_emptySlice(t *testing.T) {
 	client, mux, _, teardown := setup()
 	defer teardown()
 
-	mux.HandleFunc("/repos/o/r/branches/b/protection/restrictions/users", func(w http.ResponseWriter, r *http.Request) {
+	mux.HandleFunc("/repos/o/r/topics", func(w http.ResponseWriter, r *http.Request) {
 		testMethod(t, r, "PUT")
-		fmt.Fprint(w, `[{
-				"name": "octocat"
-			}]`)
+		testHeader(t, r, "Accept", mediaTypeTopicsPreview)
+		testBody(t, r, `{"names":[]}`+"\n")
+		fmt.Fprint(w, `{"names":[]}`)
 	})
-	input := []string{"octocat"}
+
 	ctx := context.Background()
-	got, _, err := client.Repositories.ReplaceUserRestrictions(ctx, "o", "r", "b", input)
+	got, _, err := client.Repositories.ReplaceAllTopics(ctx, "o", "r", []string{})
 	if err != nil {
-		t.Errorf("Repositories.ReplaceUserRestrictions returned error: %v", err)
-	}
-	want := []*User{
-		{Name: String("octocat")},
+		t.Fatalf("Repositories.ReplaceAllTopics returned error: %v", err)
 	}
+
+	want := []string{}
 	if !cmp.Equal(got, want) {
-		t.Errorf("Repositories.ReplaceUserRestrictions returned %+v, want %+v", got, want)
+		t.Errorf("Repositories.ReplaceAllTopics returned %+v, want %+v", got, want)
 	}
+}
 
-	const methodName = "ReplaceUserRestrictions"
-	testBadOptions(t, methodName, func() (err error) {
-		_, _, err = client.Repositories.ReplaceUserRestrictions(ctx, "\n", "\n", "\n", input)
-		return err
-	})
+func TestRepositoriesService_ListAppRestrictions(t *testing.T) {
+	tests := []struct {
+		branch  string
+		urlPath string
+	}{
+		{branch: "b", urlPath: "/repos/o/r/branches/b/protection/restrictions/apps"},
+		{branch: "feat/branch-50%", urlPath: "/repos/o/r/branches/feat/branch-50%/protection/restrictions/apps"},
+	}
+
+	for _, test := range tests {
+		t.Run(test.branch, func(t *testing.T) {
+			client, mux, _, teardown := setup()
+			defer teardown()
+
+			mux.HandleFunc(test.urlPath, func(w http.ResponseWriter, r *http.Request) {
+				testMethod(t, r, "GET")
+			})
+
+			ctx := context.Background()
+			_, _, err := client.Repositories.ListAppRestrictions(ctx, "o", "r", test.branch)
+			if err != nil {
+				t.Errorf("Repositories.ListAppRestrictions returned error: %v", err)
+			}
 
-	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
-		got, resp, err := client.Repositories.ReplaceUserRestrictions(ctx, "o", "r", "b", input)
-		if got != nil {
-			t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
-		}
-		return resp, err
-	})
+			const methodName = "ListAppRestrictions"
+			testBadOptions(t, methodName, func() (err error) {
+				_, _, err = client.Repositories.ListAppRestrictions(ctx, "\n", "\n", "\n")
+				return err
+			})
+
+			testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
+				got, resp, err := client.Repositories.ListAppRestrictions(ctx, "o", "r", test.branch)
+				if got != nil {
+					t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
+				}
+				return resp, err
+			})
+		})
+	}
 }
 
-func TestRepositoriesService_AddUserRestrictions(t *testing.T) {
-	client, mux, _, teardown := setup()
-	defer teardown()
+func TestRepositoriesService_ReplaceAppRestrictions(t *testing.T) {
+	tests := []struct {
+		branch  string
+		urlPath string
+	}{
+		{branch: "b", urlPath: "/repos/o/r/branches/b/protection/restrictions/apps"},
+		{branch: "feat/branch-50%", urlPath: "/repos/o/r/branches/feat/branch-50%/protection/restrictions/apps"},
+	}
+
+	for _, test := range tests {
+		t.Run(test.branch, func(t *testing.T) {
+			client, mux, _, teardown := setup()
+			defer teardown()
+
+			mux.HandleFunc(test.urlPath, func(w http.ResponseWriter, r *http.Request) {
+				testMethod(t, r, "PUT")
+				fmt.Fprint(w, `[{
+				"name": "octocat"
+			}]`)
+			})
+			input := []string{"octocat"}
+			ctx := context.Background()
+			got, _, err := client.Repositories.ReplaceAppRestrictions(ctx, "o", "r", test.branch, input)
+			if err != nil {
+				t.Errorf("Repositories.ReplaceAppRestrictions returned error: %v", err)
+			}
+			want := []*App{
+				{Name: String("octocat")},
+			}
+			if !cmp.Equal(got, want) {
+				t.Errorf("Repositories.ReplaceAppRestrictions returned %+v, want %+v", got, want)
+			}
 
-	mux.HandleFunc("/repos/o/r/branches/b/protection/restrictions/users", func(w http.ResponseWriter, r *http.Request) {
-		testMethod(t, r, "POST")
-		fmt.Fprint(w, `[{
+			const methodName = "ReplaceAppRestrictions"
+			testBadOptions(t, methodName, func() (err error) {
+				_, _, err = client.Repositories.ReplaceAppRestrictions(ctx, "\n", "\n", "\n", input)
+				return err
+			})
+
+			testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
+				got, resp, err := client.Repositories.ReplaceAppRestrictions(ctx, "o", "r", test.branch, input)
+				if got != nil {
+					t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
+				}
+				return resp, err
+			})
+		})
+	}
+}
+
+func TestRepositoriesService_AddAppRestrictions(t *testing.T) {
+	tests := []struct {
+		branch  string
+		urlPath string
+	}{
+		{branch: "b", urlPath: "/repos/o/r/branches/b/protection/restrictions/apps"},
+		{branch: "feat/branch-50%", urlPath: "/repos/o/r/branches/feat/branch-50%/protection/restrictions/apps"},
+	}
+
+	for _, test := range tests {
+		t.Run(test.branch, func(t *testing.T) {
+			client, mux, _, teardown := setup()
+			defer teardown()
+
+			mux.HandleFunc(test.urlPath, func(w http.ResponseWriter, r *http.Request) {
+				testMethod(t, r, "POST")
+				fmt.Fprint(w, `[{
 				"name": "octocat"
 			}]`)
-	})
-	input := []string{"octocat"}
-	ctx := context.Background()
-	got, _, err := client.Repositories.AddUserRestrictions(ctx, "o", "r", "b", input)
-	if err != nil {
-		t.Errorf("Repositories.AddUserRestrictions returned error: %v", err)
+			})
+			input := []string{"octocat"}
+			ctx := context.Background()
+			got, _, err := client.Repositories.AddAppRestrictions(ctx, "o", "r", test.branch, input)
+			if err != nil {
+				t.Errorf("Repositories.AddAppRestrictions returned error: %v", err)
+			}
+			want := []*App{
+				{Name: String("octocat")},
+			}
+			if !cmp.Equal(got, want) {
+				t.Errorf("Repositories.AddAppRestrictions returned %+v, want %+v", got, want)
+			}
+
+			const methodName = "AddAppRestrictions"
+			testBadOptions(t, methodName, func() (err error) {
+				_, _, err = client.Repositories.AddAppRestrictions(ctx, "\n", "\n", "\n", input)
+				return err
+			})
+
+			testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
+				got, resp, err := client.Repositories.AddAppRestrictions(ctx, "o", "r", test.branch, input)
+				if got != nil {
+					t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
+				}
+				return resp, err
+			})
+		})
 	}
-	want := []*User{
-		{Name: String("octocat")},
+}
+
+func TestRepositoriesService_RemoveAppRestrictions(t *testing.T) {
+	tests := []struct {
+		branch  string
+		urlPath string
+	}{
+		{branch: "b", urlPath: "/repos/o/r/branches/b/protection/restrictions/apps"},
+		{branch: "feat/branch-50%", urlPath: "/repos/o/r/branches/feat/branch-50%/protection/restrictions/apps"},
+	}
+
+	for _, test := range tests {
+		t.Run(test.branch, func(t *testing.T) {
+			client, mux, _, teardown := setup()
+			defer teardown()
+
+			mux.HandleFunc(test.urlPath, func(w http.ResponseWriter, r *http.Request) {
+				testMethod(t, r, "DELETE")
+				fmt.Fprint(w, `[]`)
+			})
+			input := []string{"octocat"}
+			ctx := context.Background()
+			got, _, err := client.Repositories.RemoveAppRestrictions(ctx, "o", "r", test.branch, input)
+			if err != nil {
+				t.Errorf("Repositories.RemoveAppRestrictions returned error: %v", err)
+			}
+			want := []*App{}
+			if !cmp.Equal(got, want) {
+				t.Errorf("Repositories.RemoveAppRestrictions returned %+v, want %+v", got, want)
+			}
+
+			const methodName = "RemoveAppRestrictions"
+			testBadOptions(t, methodName, func() (err error) {
+				_, _, err = client.Repositories.RemoveAppRestrictions(ctx, "\n", "\n", "\n", input)
+				return err
+			})
+
+			testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
+				got, resp, err := client.Repositories.RemoveAppRestrictions(ctx, "o", "r", test.branch, input)
+				if got != nil {
+					t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
+				}
+				return resp, err
+			})
+		})
 	}
-	if !cmp.Equal(got, want) {
-		t.Errorf("Repositories.AddUserRestrictions returned %+v, want %+v", got, want)
+}
+
+func TestRepositoriesService_ListTeamRestrictions(t *testing.T) {
+	tests := []struct {
+		branch  string
+		urlPath string
+	}{
+		{branch: "b", urlPath: "/repos/o/r/branches/b/protection/restrictions/teams"},
+		{branch: "feat/branch-50%", urlPath: "/repos/o/r/branches/feat/branch-50%/protection/restrictions/teams"},
+	}
+
+	for _, test := range tests {
+		t.Run(test.branch, func(t *testing.T) {
+			client, mux, _, teardown := setup()
+			defer teardown()
+
+			mux.HandleFunc(test.urlPath, func(w http.ResponseWriter, r *http.Request) {
+				testMethod(t, r, "GET")
+			})
+
+			ctx := context.Background()
+			_, _, err := client.Repositories.ListTeamRestrictions(ctx, "o", "r", test.branch)
+			if err != nil {
+				t.Errorf("Repositories.ListTeamRestrictions returned error: %v", err)
+			}
+
+			const methodName = "ListTeamRestrictions"
+			testBadOptions(t, methodName, func() (err error) {
+				_, _, err = client.Repositories.ListTeamRestrictions(ctx, "\n", "\n", "\n")
+				return err
+			})
+
+			testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
+				got, resp, err := client.Repositories.ListTeamRestrictions(ctx, "o", "r", test.branch)
+				if got != nil {
+					t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
+				}
+				return resp, err
+			})
+		})
 	}
+}
 
-	const methodName = "AddUserRestrictions"
-	testBadOptions(t, methodName, func() (err error) {
-		_, _, err = client.Repositories.AddUserRestrictions(ctx, "\n", "\n", "\n", input)
-		return err
-	})
+func TestRepositoriesService_ReplaceTeamRestrictions(t *testing.T) {
+	tests := []struct {
+		branch  string
+		urlPath string
+	}{
+		{branch: "b", urlPath: "/repos/o/r/branches/b/protection/restrictions/teams"},
+		{branch: "feat/branch-50%", urlPath: "/repos/o/r/branches/feat/branch-50%/protection/restrictions/teams"},
+	}
+
+	for _, test := range tests {
+		t.Run(test.branch, func(t *testing.T) {
+			client, mux, _, teardown := setup()
+			defer teardown()
+
+			mux.HandleFunc(test.urlPath, func(w http.ResponseWriter, r *http.Request) {
+				testMethod(t, r, "PUT")
+				fmt.Fprint(w, `[{
+				"name": "octocat"
+			}]`)
+			})
+			input := []string{"octocat"}
+			ctx := context.Background()
+			got, _, err := client.Repositories.ReplaceTeamRestrictions(ctx, "o", "r", test.branch, input)
+			if err != nil {
+				t.Errorf("Repositories.ReplaceTeamRestrictions returned error: %v", err)
+			}
+			want := []*Team{
+				{Name: String("octocat")},
+			}
+			if !cmp.Equal(got, want) {
+				t.Errorf("Repositories.ReplaceTeamRestrictions returned %+v, want %+v", got, want)
+			}
 
-	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
-		got, resp, err := client.Repositories.AddUserRestrictions(ctx, "o", "r", "b", input)
-		if got != nil {
-			t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
-		}
-		return resp, err
-	})
+			const methodName = "ReplaceTeamRestrictions"
+			testBadOptions(t, methodName, func() (err error) {
+				_, _, err = client.Repositories.ReplaceTeamRestrictions(ctx, "\n", "\n", "\n", input)
+				return err
+			})
+
+			testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
+				got, resp, err := client.Repositories.ReplaceTeamRestrictions(ctx, "o", "r", test.branch, input)
+				if got != nil {
+					t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
+				}
+				return resp, err
+			})
+		})
+	}
 }
 
-func TestRepositoriesService_RemoveUserRestrictions(t *testing.T) {
-	client, mux, _, teardown := setup()
-	defer teardown()
+func TestRepositoriesService_AddTeamRestrictions(t *testing.T) {
+	tests := []struct {
+		branch  string
+		urlPath string
+	}{
+		{branch: "b", urlPath: "/repos/o/r/branches/b/protection/restrictions/teams"},
+		{branch: "feat/branch-50%", urlPath: "/repos/o/r/branches/feat/branch-50%/protection/restrictions/teams"},
+	}
+
+	for _, test := range tests {
+		t.Run(test.branch, func(t *testing.T) {
+			client, mux, _, teardown := setup()
+			defer teardown()
+
+			mux.HandleFunc(test.urlPath, func(w http.ResponseWriter, r *http.Request) {
+				testMethod(t, r, "POST")
+				fmt.Fprint(w, `[{
+				"name": "octocat"
+			}]`)
+			})
+			input := []string{"octocat"}
+			ctx := context.Background()
+			got, _, err := client.Repositories.AddTeamRestrictions(ctx, "o", "r", test.branch, input)
+			if err != nil {
+				t.Errorf("Repositories.AddTeamRestrictions returned error: %v", err)
+			}
+			want := []*Team{
+				{Name: String("octocat")},
+			}
+			if !cmp.Equal(got, want) {
+				t.Errorf("Repositories.AddTeamRestrictions returned %+v, want %+v", got, want)
+			}
 
-	mux.HandleFunc("/repos/o/r/branches/b/protection/restrictions/users", func(w http.ResponseWriter, r *http.Request) {
-		testMethod(t, r, "DELETE")
-		fmt.Fprint(w, `[]`)
-	})
-	input := []string{"octocat"}
-	ctx := context.Background()
-	got, _, err := client.Repositories.RemoveUserRestrictions(ctx, "o", "r", "b", input)
-	if err != nil {
-		t.Errorf("Repositories.RemoveUserRestrictions returned error: %v", err)
+			const methodName = "AddTeamRestrictions"
+			testBadOptions(t, methodName, func() (err error) {
+				_, _, err = client.Repositories.AddTeamRestrictions(ctx, "\n", "\n", "\n", input)
+				return err
+			})
+
+			testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
+				got, resp, err := client.Repositories.AddTeamRestrictions(ctx, "o", "r", test.branch, input)
+				if got != nil {
+					t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
+				}
+				return resp, err
+			})
+		})
 	}
-	want := []*User{}
-	if !cmp.Equal(got, want) {
-		t.Errorf("Repositories.RemoveUserRestrictions returned %+v, want %+v", got, want)
+}
+
+func TestRepositoriesService_RemoveTeamRestrictions(t *testing.T) {
+	tests := []struct {
+		branch  string
+		urlPath string
+	}{
+		{branch: "b", urlPath: "/repos/o/r/branches/b/protection/restrictions/teams"},
+		{branch: "feat/branch-50%", urlPath: "/repos/o/r/branches/feat/branch-50%/protection/restrictions/teams"},
+	}
+
+	for _, test := range tests {
+		t.Run(test.branch, func(t *testing.T) {
+			client, mux, _, teardown := setup()
+			defer teardown()
+
+			mux.HandleFunc(test.urlPath, func(w http.ResponseWriter, r *http.Request) {
+				testMethod(t, r, "DELETE")
+				fmt.Fprint(w, `[]`)
+			})
+			input := []string{"octocat"}
+			ctx := context.Background()
+			got, _, err := client.Repositories.RemoveTeamRestrictions(ctx, "o", "r", test.branch, input)
+			if err != nil {
+				t.Errorf("Repositories.RemoveTeamRestrictions returned error: %v", err)
+			}
+			want := []*Team{}
+			if !cmp.Equal(got, want) {
+				t.Errorf("Repositories.RemoveTeamRestrictions returned %+v, want %+v", got, want)
+			}
+
+			const methodName = "RemoveTeamRestrictions"
+			testBadOptions(t, methodName, func() (err error) {
+				_, _, err = client.Repositories.RemoveTeamRestrictions(ctx, "\n", "\n", "\n", input)
+				return err
+			})
+
+			testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
+				got, resp, err := client.Repositories.RemoveTeamRestrictions(ctx, "o", "r", test.branch, input)
+				if got != nil {
+					t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
+				}
+				return resp, err
+			})
+		})
 	}
+}
 
-	const methodName = "RemoveUserRestrictions"
-	testBadOptions(t, methodName, func() (err error) {
-		_, _, err = client.Repositories.RemoveUserRestrictions(ctx, "\n", "\n", "\n", input)
-		return err
-	})
+func TestRepositoriesService_ListUserRestrictions(t *testing.T) {
+	tests := []struct {
+		branch  string
+		urlPath string
+	}{
+		{branch: "b", urlPath: "/repos/o/r/branches/b/protection/restrictions/users"},
+		{branch: "feat/branch-50%", urlPath: "/repos/o/r/branches/feat/branch-50%/protection/restrictions/users"},
+	}
+
+	for _, test := range tests {
+		t.Run(test.branch, func(t *testing.T) {
+			client, mux, _, teardown := setup()
+			defer teardown()
+
+			mux.HandleFunc(test.urlPath, func(w http.ResponseWriter, r *http.Request) {
+				testMethod(t, r, "GET")
+			})
+
+			ctx := context.Background()
+			_, _, err := client.Repositories.ListUserRestrictions(ctx, "o", "r", test.branch)
+			if err != nil {
+				t.Errorf("Repositories.ListUserRestrictions returned error: %v", err)
+			}
 
-	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
-		got, resp, err := client.Repositories.RemoveUserRestrictions(ctx, "o", "r", "b", input)
-		if got != nil {
-			t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
-		}
-		return resp, err
-	})
+			const methodName = "ListUserRestrictions"
+			testBadOptions(t, methodName, func() (err error) {
+				_, _, err = client.Repositories.ListUserRestrictions(ctx, "\n", "\n", "\n")
+				return err
+			})
+
+			testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
+				got, resp, err := client.Repositories.ListUserRestrictions(ctx, "o", "r", test.branch)
+				if got != nil {
+					t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
+				}
+				return resp, err
+			})
+		})
+	}
+}
+
+func TestRepositoriesService_ReplaceUserRestrictions(t *testing.T) {
+	tests := []struct {
+		branch  string
+		urlPath string
+	}{
+		{branch: "b", urlPath: "/repos/o/r/branches/b/protection/restrictions/users"},
+		{branch: "feat/branch-50%", urlPath: "/repos/o/r/branches/feat/branch-50%/protection/restrictions/users"},
+	}
+
+	for _, test := range tests {
+		t.Run(test.branch, func(t *testing.T) {
+			client, mux, _, teardown := setup()
+			defer teardown()
+
+			mux.HandleFunc(test.urlPath, func(w http.ResponseWriter, r *http.Request) {
+				testMethod(t, r, "PUT")
+				fmt.Fprint(w, `[{
+				"name": "octocat"
+			}]`)
+			})
+			input := []string{"octocat"}
+			ctx := context.Background()
+			got, _, err := client.Repositories.ReplaceUserRestrictions(ctx, "o", "r", test.branch, input)
+			if err != nil {
+				t.Errorf("Repositories.ReplaceUserRestrictions returned error: %v", err)
+			}
+			want := []*User{
+				{Name: String("octocat")},
+			}
+			if !cmp.Equal(got, want) {
+				t.Errorf("Repositories.ReplaceUserRestrictions returned %+v, want %+v", got, want)
+			}
+
+			const methodName = "ReplaceUserRestrictions"
+			testBadOptions(t, methodName, func() (err error) {
+				_, _, err = client.Repositories.ReplaceUserRestrictions(ctx, "\n", "\n", "\n", input)
+				return err
+			})
+
+			testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
+				got, resp, err := client.Repositories.ReplaceUserRestrictions(ctx, "o", "r", test.branch, input)
+				if got != nil {
+					t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
+				}
+				return resp, err
+			})
+		})
+	}
+}
+
+func TestRepositoriesService_AddUserRestrictions(t *testing.T) {
+	tests := []struct {
+		branch  string
+		urlPath string
+	}{
+		{branch: "b", urlPath: "/repos/o/r/branches/b/protection/restrictions/users"},
+		{branch: "feat/branch-50%", urlPath: "/repos/o/r/branches/feat/branch-50%/protection/restrictions/users"},
+	}
+
+	for _, test := range tests {
+		t.Run(test.branch, func(t *testing.T) {
+			client, mux, _, teardown := setup()
+			defer teardown()
+
+			mux.HandleFunc(test.urlPath, func(w http.ResponseWriter, r *http.Request) {
+				testMethod(t, r, "POST")
+				fmt.Fprint(w, `[{
+				"name": "octocat"
+			}]`)
+			})
+			input := []string{"octocat"}
+			ctx := context.Background()
+			got, _, err := client.Repositories.AddUserRestrictions(ctx, "o", "r", test.branch, input)
+			if err != nil {
+				t.Errorf("Repositories.AddUserRestrictions returned error: %v", err)
+			}
+			want := []*User{
+				{Name: String("octocat")},
+			}
+			if !cmp.Equal(got, want) {
+				t.Errorf("Repositories.AddUserRestrictions returned %+v, want %+v", got, want)
+			}
+
+			const methodName = "AddUserRestrictions"
+			testBadOptions(t, methodName, func() (err error) {
+				_, _, err = client.Repositories.AddUserRestrictions(ctx, "\n", "\n", "\n", input)
+				return err
+			})
+
+			testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
+				got, resp, err := client.Repositories.AddUserRestrictions(ctx, "o", "r", test.branch, input)
+				if got != nil {
+					t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
+				}
+				return resp, err
+			})
+		})
+	}
+}
+
+func TestRepositoriesService_RemoveUserRestrictions(t *testing.T) {
+	tests := []struct {
+		branch  string
+		urlPath string
+	}{
+		{branch: "b", urlPath: "/repos/o/r/branches/b/protection/restrictions/users"},
+		{branch: "feat/branch-50%", urlPath: "/repos/o/r/branches/feat/branch-50%/protection/restrictions/users"},
+	}
+
+	for _, test := range tests {
+		t.Run(test.branch, func(t *testing.T) {
+			client, mux, _, teardown := setup()
+			defer teardown()
+
+			mux.HandleFunc(test.urlPath, func(w http.ResponseWriter, r *http.Request) {
+				testMethod(t, r, "DELETE")
+				fmt.Fprint(w, `[]`)
+			})
+			input := []string{"octocat"}
+			ctx := context.Background()
+			got, _, err := client.Repositories.RemoveUserRestrictions(ctx, "o", "r", test.branch, input)
+			if err != nil {
+				t.Errorf("Repositories.RemoveUserRestrictions returned error: %v", err)
+			}
+			want := []*User{}
+			if !cmp.Equal(got, want) {
+				t.Errorf("Repositories.RemoveUserRestrictions returned %+v, want %+v", got, want)
+			}
+
+			const methodName = "RemoveUserRestrictions"
+			testBadOptions(t, methodName, func() (err error) {
+				_, _, err = client.Repositories.RemoveUserRestrictions(ctx, "\n", "\n", "\n", input)
+				return err
+			})
+
+			testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
+				got, resp, err := client.Repositories.RemoveUserRestrictions(ctx, "o", "r", test.branch, input)
+				if got != nil {
+					t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
+				}
+				return resp, err
+			})
+		})
+	}
 }
 
 func TestRepositoriesService_Transfer(t *testing.T) {
diff --git a/github/security_advisories_test.go b/github/security_advisories_test.go
index e4a6fbd7..5476ef61 100644
--- a/github/security_advisories_test.go
+++ b/github/security_advisories_test.go
@@ -8,7 +8,10 @@ package github
 import (
 	"context"
 	"net/http"
+	"strings"
 	"testing"
+
+	"github.com/google/go-cmp/cmp"
 )
 
 func TestSecurityAdvisoriesService_RequestCVE(t *testing.T) {
@@ -50,3 +53,265 @@ func TestSecurityAdvisoriesService_RequestCVE(t *testing.T) {
 		return resp, err
 	})
 }
+
+func TestSecurityAdvisoriesService_ListRepositorySecurityAdvisoriesForOrg_BadRequest(t *testing.T) {
+	client, mux, _, teardown := setup()
+	defer teardown()
+
+	mux.HandleFunc("/orgs/o/security-advisories", func(w http.ResponseWriter, r *http.Request) {
+		testMethod(t, r, "GET")
+
+		http.Error(w, "Bad Request", 400)
+	})
+
+	ctx := context.Background()
+	advisories, resp, err := client.SecurityAdvisories.ListRepositorySecurityAdvisoriesForOrg(ctx, "o", nil)
+	if err == nil {
+		t.Errorf("Expected HTTP 400 response")
+	}
+	if got, want := resp.Response.StatusCode, http.StatusBadRequest; got != want {
+		t.Errorf("ListRepositorySecurityAdvisoriesForOrg return status %d, want %d", got, want)
+	}
+	if advisories != nil {
+		t.Errorf("ListRepositorySecurityAdvisoriesForOrg return %+v, want nil", advisories)
+	}
+}
+
+func TestSecurityAdvisoriesService_ListRepositorySecurityAdvisoriesForOrg_NotFound(t *testing.T) {
+	client, mux, _, teardown := setup()
+	defer teardown()
+
+	mux.HandleFunc("/orgs/o/security-advisories", func(w http.ResponseWriter, r *http.Request) {
+		testMethod(t, r, "GET")
+
+		query := r.URL.Query()
+		if query.Get("state") != "draft" {
+			t.Errorf("ListRepositorySecurityAdvisoriesForOrg returned %+v, want %+v", query.Get("state"), "draft")
+		}
+
+		http.NotFound(w, r)
+	})
+
+	ctx := context.Background()
+	advisories, resp, err := client.SecurityAdvisories.ListRepositorySecurityAdvisoriesForOrg(ctx, "o", &ListRepositorySecurityAdvisoriesOptions{
+		State: "draft",
+	})
+	if err == nil {
+		t.Errorf("Expected HTTP 404 response")
+	}
+	if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want {
+		t.Errorf("ListRepositorySecurityAdvisoriesForOrg return status %d, want %d", got, want)
+	}
+	if advisories != nil {
+		t.Errorf("ListRepositorySecurityAdvisoriesForOrg return %+v, want nil", advisories)
+	}
+}
+
+func TestSecurityAdvisoriesService_ListRepositorySecurityAdvisoriesForOrg_UnmarshalError(t *testing.T) {
+	client, mux, _, teardown := setup()
+	defer teardown()
+
+	mux.HandleFunc("/orgs/o/security-advisories", func(w http.ResponseWriter, r *http.Request) {
+		testMethod(t, r, "GET")
+
+		w.WriteHeader(http.StatusOK)
+		assertWrite(t, w, []byte(`[{"ghsa_id": 12334354}]`))
+	})
+
+	ctx := context.Background()
+	advisories, resp, err := client.SecurityAdvisories.ListRepositorySecurityAdvisoriesForOrg(ctx, "o", nil)
+	if err == nil {
+		t.Errorf("Expected unmarshal error")
+	} else if !strings.Contains(err.Error(), "json: cannot unmarshal number into Go struct field SecurityAdvisory.ghsa_id of type string") {
+		t.Errorf("ListRepositorySecurityAdvisoriesForOrg returned unexpected error: %v", err)
+	}
+	if got, want := resp.Response.StatusCode, http.StatusOK; got != want {
+		t.Errorf("ListRepositorySecurityAdvisoriesForOrg return status %d, want %d", got, want)
+	}
+	if advisories != nil {
+		t.Errorf("ListRepositorySecurityAdvisoriesForOrg return %+v, want nil", advisories)
+	}
+}
+
+func TestSecurityAdvisoriesService_ListRepositorySecurityAdvisoriesForOrg(t *testing.T) {
+	client, mux, _, teardown := setup()
+	defer teardown()
+
+	mux.HandleFunc("/orgs/o/security-advisories", func(w http.ResponseWriter, r *http.Request) {
+		testMethod(t, r, "GET")
+
+		w.WriteHeader(http.StatusOK)
+		assertWrite(t, w, []byte(`[
+			{
+				"ghsa_id": "GHSA-abcd-1234-efgh",
+   				"cve_id": "CVE-2050-00000"
+ 			}
+		]`))
+	})
+
+	ctx := context.Background()
+	advisories, resp, err := client.SecurityAdvisories.ListRepositorySecurityAdvisoriesForOrg(ctx, "o", nil)
+	if err != nil {
+		t.Errorf("ListRepositorySecurityAdvisoriesForOrg returned error: %v, want nil", err)
+	}
+	if got, want := resp.Response.StatusCode, http.StatusOK; got != want {
+		t.Errorf("ListRepositorySecurityAdvisoriesForOrg return status %d, want %d", got, want)
+	}
+
+	want := []*SecurityAdvisory{
+		{
+			GHSAID: String("GHSA-abcd-1234-efgh"),
+			CVEID:  String("CVE-2050-00000"),
+		},
+	}
+	if !cmp.Equal(advisories, want) {
+		t.Errorf("ListRepositorySecurityAdvisoriesForOrg returned %+v, want %+v", advisories, want)
+	}
+
+	methodName := "ListRepositorySecurityAdvisoriesForOrg"
+	testBadOptions(t, methodName, func() (err error) {
+		_, _, err = client.SecurityAdvisories.ListRepositorySecurityAdvisoriesForOrg(ctx, "\n", &ListRepositorySecurityAdvisoriesOptions{
+			Sort: "\n",
+		})
+		return err
+	})
+
+	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
+		got, resp, err := client.SecurityAdvisories.ListRepositorySecurityAdvisoriesForOrg(ctx, "o", nil)
+		if got != nil {
+			t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
+		}
+		return resp, err
+	})
+}
+
+func TestSecurityAdvisoriesService_ListRepositorySecurityAdvisories_BadRequest(t *testing.T) {
+	client, mux, _, teardown := setup()
+	defer teardown()
+
+	mux.HandleFunc("/repos/o/r/security-advisories", func(w http.ResponseWriter, r *http.Request) {
+		testMethod(t, r, "GET")
+
+		http.Error(w, "Bad Request", 400)
+	})
+
+	ctx := context.Background()
+	advisories, resp, err := client.SecurityAdvisories.ListRepositorySecurityAdvisories(ctx, "o", "r", nil)
+	if err == nil {
+		t.Errorf("Expected HTTP 400 response")
+	}
+	if got, want := resp.Response.StatusCode, http.StatusBadRequest; got != want {
+		t.Errorf("ListRepositorySecurityAdvisories return status %d, want %d", got, want)
+	}
+	if advisories != nil {
+		t.Errorf("ListRepositorySecurityAdvisories return %+v, want nil", advisories)
+	}
+}
+
+func TestSecurityAdvisoriesService_ListRepositorySecurityAdvisories_NotFound(t *testing.T) {
+	client, mux, _, teardown := setup()
+	defer teardown()
+
+	mux.HandleFunc("/repos/o/r/security-advisories", func(w http.ResponseWriter, r *http.Request) {
+		testMethod(t, r, "GET")
+
+		query := r.URL.Query()
+		if query.Get("state") != "draft" {
+			t.Errorf("ListRepositorySecurityAdvisories returned %+v, want %+v", query.Get("state"), "draft")
+		}
+
+		http.NotFound(w, r)
+	})
+
+	ctx := context.Background()
+	advisories, resp, err := client.SecurityAdvisories.ListRepositorySecurityAdvisories(ctx, "o", "r", &ListRepositorySecurityAdvisoriesOptions{
+		State: "draft",
+	})
+	if err == nil {
+		t.Errorf("Expected HTTP 404 response")
+	}
+	if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want {
+		t.Errorf("ListRepositorySecurityAdvisories return status %d, want %d", got, want)
+	}
+	if advisories != nil {
+		t.Errorf("ListRepositorySecurityAdvisories return %+v, want nil", advisories)
+	}
+}
+
+func TestSecurityAdvisoriesService_ListRepositorySecurityAdvisories_UnmarshalError(t *testing.T) {
+	client, mux, _, teardown := setup()
+	defer teardown()
+
+	mux.HandleFunc("/repos/o/r/security-advisories", func(w http.ResponseWriter, r *http.Request) {
+		testMethod(t, r, "GET")
+
+		w.WriteHeader(http.StatusOK)
+		assertWrite(t, w, []byte(`[{"ghsa_id": 12334354}]`))
+	})
+
+	ctx := context.Background()
+	advisories, resp, err := client.SecurityAdvisories.ListRepositorySecurityAdvisories(ctx, "o", "r", nil)
+	if err == nil {
+		t.Errorf("Expected unmarshal error")
+	} else if !strings.Contains(err.Error(), "json: cannot unmarshal number into Go struct field SecurityAdvisory.ghsa_id of type string") {
+		t.Errorf("ListRepositorySecurityAdvisories returned unexpected error: %v", err)
+	}
+	if got, want := resp.Response.StatusCode, http.StatusOK; got != want {
+		t.Errorf("ListRepositorySecurityAdvisories return status %d, want %d", got, want)
+	}
+	if advisories != nil {
+		t.Errorf("ListRepositorySecurityAdvisories return %+v, want nil", advisories)
+	}
+}
+
+func TestSecurityAdvisoriesService_ListRepositorySecurityAdvisories(t *testing.T) {
+	client, mux, _, teardown := setup()
+	defer teardown()
+
+	mux.HandleFunc("/repos/o/r/security-advisories", func(w http.ResponseWriter, r *http.Request) {
+		testMethod(t, r, "GET")
+
+		w.WriteHeader(http.StatusOK)
+		assertWrite(t, w, []byte(`[
+			{
+				"ghsa_id": "GHSA-abcd-1234-efgh",
+   				"cve_id": "CVE-2050-00000"
+ 			}
+		]`))
+	})
+
+	ctx := context.Background()
+	advisories, resp, err := client.SecurityAdvisories.ListRepositorySecurityAdvisories(ctx, "o", "r", nil)
+	if err != nil {
+		t.Errorf("ListRepositorySecurityAdvisories returned error: %v, want nil", err)
+	}
+	if got, want := resp.Response.StatusCode, http.StatusOK; got != want {
+		t.Errorf("ListRepositorySecurityAdvisories return status %d, want %d", got, want)
+	}
+
+	want := []*SecurityAdvisory{
+		{
+			GHSAID: String("GHSA-abcd-1234-efgh"),
+			CVEID:  String("CVE-2050-00000"),
+		},
+	}
+	if !cmp.Equal(advisories, want) {
+		t.Errorf("ListRepositorySecurityAdvisories returned %+v, want %+v", advisories, want)
+	}
+
+	methodName := "ListRepositorySecurityAdvisories"
+	testBadOptions(t, methodName, func() (err error) {
+		_, _, err = client.SecurityAdvisories.ListRepositorySecurityAdvisories(ctx, "\n", "\n", &ListRepositorySecurityAdvisoriesOptions{
+			Sort: "\n",
+		})
+		return err
+	})
+
+	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
+		got, resp, err := client.SecurityAdvisories.ListRepositorySecurityAdvisories(ctx, "o", "r", nil)
+		if got != nil {
+			t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
+		}
+		return resp, err
+	})
+}