Skip to content

Commit 8a4bdb5

Browse files
authored
Add SecretScanningPushProtection field to SecurityAndAnalysis struct (#2476)
Fixes: #2475.
1 parent 182338c commit 8a4bdb5

File tree

5 files changed

+49
-7
lines changed

5 files changed

+49
-7
lines changed

github/github-accessors.go

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github/github-accessors_test.go

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github/github-stringify_test.go

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github/repos.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,9 @@ type RepositoryListOptions struct {
205205
// SecurityAndAnalysis specifies the optional advanced security features
206206
// that are enabled on a given repository.
207207
type SecurityAndAnalysis struct {
208-
AdvancedSecurity *AdvancedSecurity `json:"advanced_security,omitempty"`
209-
SecretScanning *SecretScanning `json:"secret_scanning,omitempty"`
208+
AdvancedSecurity *AdvancedSecurity `json:"advanced_security,omitempty"`
209+
SecretScanning *SecretScanning `json:"secret_scanning,omitempty"`
210+
SecretScanningPushProtection *SecretScanningPushProtection `json:"secret_scanning_push_protection,omitempty"`
210211
}
211212

212213
func (s SecurityAndAnalysis) String() string {
@@ -235,6 +236,13 @@ func (s SecretScanning) String() string {
235236
return Stringify(s)
236237
}
237238

239+
// SecretScanningPushProtection specifies the state of secret scanning push protection on a repository.
240+
//
241+
// GitHub API docs: https://docs.github.com/en/code-security/secret-scanning/about-secret-scanning#about-secret-scanning-for-partner-patterns
242+
type SecretScanningPushProtection struct {
243+
Status *string `json:"status,omitempty"`
244+
}
245+
238246
// List the repositories for a user. Passing the empty string will list
239247
// repositories for the authenticated user.
240248
//

github/repos_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ func TestRepositoriesService_Get(t *testing.T) {
360360
mux.HandleFunc("/repos/o/r", func(w http.ResponseWriter, r *http.Request) {
361361
testMethod(t, r, "GET")
362362
testHeader(t, r, "Accept", strings.Join(wantAcceptHeaders, ", "))
363-
fmt.Fprint(w, `{"id":1,"name":"n","description":"d","owner":{"login":"l"},"license":{"key":"mit"},"security_and_analysis":{"advanced_security":{"status":"enabled"},"secret_scanning":{"status":"enabled"}}}`)
363+
fmt.Fprint(w, `{"id":1,"name":"n","description":"d","owner":{"login":"l"},"license":{"key":"mit"},"security_and_analysis":{"advanced_security":{"status":"enabled"},"secret_scanning":{"status":"enabled"},"secret_scanning_push_protection":{"status":"enabled"}}}`)
364364
})
365365

366366
ctx := context.Background()
@@ -369,7 +369,7 @@ func TestRepositoriesService_Get(t *testing.T) {
369369
t.Errorf("Repositories.Get returned error: %v", err)
370370
}
371371

372-
want := &Repository{ID: Int64(1), Name: String("n"), Description: String("d"), Owner: &User{Login: String("l")}, License: &License{Key: String("mit")}, SecurityAndAnalysis: &SecurityAndAnalysis{AdvancedSecurity: &AdvancedSecurity{Status: String("enabled")}, SecretScanning: &SecretScanning{String("enabled")}}}
372+
want := &Repository{ID: Int64(1), Name: String("n"), Description: String("d"), Owner: &User{Login: String("l")}, License: &License{Key: String("mit")}, SecurityAndAnalysis: &SecurityAndAnalysis{AdvancedSecurity: &AdvancedSecurity{Status: String("enabled")}, SecretScanning: &SecretScanning{String("enabled")}, SecretScanningPushProtection: &SecretScanningPushProtection{String("enabled")}}}
373373
if !cmp.Equal(got, want) {
374374
t.Errorf("Repositories.Get returned %+v, want %+v", got, want)
375375
}

0 commit comments

Comments
 (0)