From 44209930dac90cd66efbd02e2da6633d043f134c Mon Sep 17 00:00:00 2001 From: maishivamhoo123 Date: Wed, 20 May 2026 07:00:33 +0000 Subject: [PATCH 1/5] feat: add support for getting Copilot cloud agent configuration Signed-off-by: maishivamhoo123 --- github/copilot_cloud_agent.go | 54 +++++++++++ github/copilot_cloud_agent_test.go | 148 +++++++++++++++++++++++++++++ github/github-accessors.go | 80 ++++++++++++++++ github/github-accessors_test.go | 107 +++++++++++++++++++++ openapi_operations.yaml | 5 + 5 files changed, 394 insertions(+) create mode 100644 github/copilot_cloud_agent.go create mode 100644 github/copilot_cloud_agent_test.go diff --git a/github/copilot_cloud_agent.go b/github/copilot_cloud_agent.go new file mode 100644 index 00000000000..1a688ee25a8 --- /dev/null +++ b/github/copilot_cloud_agent.go @@ -0,0 +1,54 @@ +// Copyright 2026 The go-github AUTHORS. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package github + +import ( + "context" + "encoding/json" + "fmt" +) + +// CopilotCloudAgentConfiguration represents the Copilot cloud agent configuration for a repository. +// +// GitHub API docs: https://docs.github.com/en/rest/copilot/copilot-cloud-agent-management?apiVersion=2026-03-10#get-copilot-cloud-agent-configuration-for-a-repository +type CopilotCloudAgentConfiguration struct { + McpConfiguration *json.RawMessage `json:"mcp_configuration,omitempty"` + EnabledTools *EnabledTools `json:"enabled_tools,omitempty"` + RequireActionsWorkflowApproval *bool `json:"require_actions_workflow_approval,omitempty"` + IsFirewallEnabled *bool `json:"is_firewall_enabled,omitempty"` + IsFirewallRecommendedAllowlistEnabled *bool `json:"is_firewall_recommended_allowlist_enabled,omitempty"` + CustomAllowlist []string `json:"custom_allowlist,omitempty"` +} + +// EnabledTools represents the enabled review tools for Copilot cloud agent. +type EnabledTools struct { + Codeql *bool `json:"codeql,omitempty"` + CopilotCodeReview *bool `json:"copilot_code_review,omitempty"` + SecretScanning *bool `json:"secret_scanning,omitempty"` + DependencyVulnerabilityChecks *bool `json:"dependency_vulnerability_checks,omitempty"` +} + +// GetCopilotCloudAgentConfiguration gets the Copilot cloud agent configuration for a repository. +// +// GitHub API docs: https://docs.github.com/rest/copilot/copilot-cloud-agent-management?apiVersion=2026-03-10#get-copilot-cloud-agent-configuration-for-a-repository +// +//meta:operation GET /repos/{owner}/{repo}/copilot/cloud-agent/configuration +func (s *CopilotService) GetCopilotCloudAgentConfiguration(ctx context.Context, owner, repo string) (*CopilotCloudAgentConfiguration, *Response, error) { + u := fmt.Sprintf("repos/%v/%v/copilot/cloud-agent/configuration", owner, repo) + + req, err := s.client.NewRequest(ctx, "GET", u, nil) + if err != nil { + return nil, nil, err + } + + var config CopilotCloudAgentConfiguration + resp, err := s.client.Do(req, &config) + if err != nil { + return nil, resp, err + } + + return &config, resp, nil +} diff --git a/github/copilot_cloud_agent_test.go b/github/copilot_cloud_agent_test.go new file mode 100644 index 00000000000..bcf5d13b832 --- /dev/null +++ b/github/copilot_cloud_agent_test.go @@ -0,0 +1,148 @@ +// Copyright 2026 The go-github AUTHORS. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package github + +import ( + "fmt" + "net/http" + "testing" + + "github.com/google/go-cmp/cmp" +) + +func TestCopilotService_GetCopilotCloudAgentConfiguration(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + + mux.HandleFunc("/repos/o/r/copilot/cloud-agent/configuration", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + fmt.Fprint(w, `{ + "mcp_configuration": null, + "enabled_tools": { + "codeql": true, + "copilot_code_review": true, + "secret_scanning": true, + "dependency_vulnerability_checks": true + }, + "require_actions_workflow_approval": true, + "is_firewall_enabled": true, + "is_firewall_recommended_allowlist_enabled": true, + "custom_allowlist": [] + }`) + }) + + ctx := t.Context() + config, _, err := client.Copilot.GetCopilotCloudAgentConfiguration(ctx, "o", "r") + if err != nil { + t.Errorf("GetCopilotCloudAgentConfiguration returned error: %v", err) + } + + want := &CopilotCloudAgentConfiguration{ + McpConfiguration: nil, + EnabledTools: &EnabledTools{ + Codeql: Ptr(true), + CopilotCodeReview: Ptr(true), + SecretScanning: Ptr(true), + DependencyVulnerabilityChecks: Ptr(true), + }, + RequireActionsWorkflowApproval: Ptr(true), + IsFirewallEnabled: Ptr(true), + IsFirewallRecommendedAllowlistEnabled: Ptr(true), + CustomAllowlist: []string{}, + } + + if !cmp.Equal(config, want) { + t.Errorf("GetCopilotCloudAgentConfiguration returned %+v, want %+v", config, want) + } + + const methodName = "GetCopilotCloudAgentConfiguration" + testBadOptions(t, methodName, func() (err error) { + _, _, err = client.Copilot.GetCopilotCloudAgentConfiguration(ctx, "\n", "\n") + return err + }) + + testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { + got, resp, err := client.Copilot.GetCopilotCloudAgentConfiguration(ctx, "o", "r") + if got != nil { + t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) + } + return resp, err + }) +} + +func TestCopilotService_GetCopilotCloudAgentConfiguration_InvalidOwner(t *testing.T) { + t.Parallel() + client, _, _ := setup(t) + + ctx := t.Context() + _, _, err := client.Copilot.GetCopilotCloudAgentConfiguration(ctx, "%", "r") + testURLParseError(t, err) +} + +func TestCopilotService_GetCopilotCloudAgentConfiguration_InvalidRepo(t *testing.T) { + t.Parallel() + client, _, _ := setup(t) + + ctx := t.Context() + _, _, err := client.Copilot.GetCopilotCloudAgentConfiguration(ctx, "o", "%") + testURLParseError(t, err) +} + +func TestCopilotService_GetCopilotCloudAgentConfiguration_NotFound(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + + mux.HandleFunc("/repos/o/r/copilot/cloud-agent/configuration", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + w.WriteHeader(http.StatusNotFound) + }) + + ctx := t.Context() + config, resp, err := client.Copilot.GetCopilotCloudAgentConfiguration(ctx, "o", "r") + if err == nil { + t.Error("Expected HTTP 404 response") + } + if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { + t.Errorf("GetCopilotCloudAgentConfiguration return status %v, want %v", got, want) + } + if config != nil { + t.Errorf("GetCopilotCloudAgentConfiguration return %+v, want nil", config) + } +} + +func TestCopilotCloudAgentConfiguration_Marshal(t *testing.T) { + t.Parallel() + testJSONMarshal(t, &CopilotCloudAgentConfiguration{}, "{}") + + u := &CopilotCloudAgentConfiguration{ + McpConfiguration: nil, + EnabledTools: &EnabledTools{ + Codeql: Ptr(true), + CopilotCodeReview: Ptr(false), + SecretScanning: Ptr(true), + DependencyVulnerabilityChecks: Ptr(false), + }, + RequireActionsWorkflowApproval: Ptr(true), + IsFirewallEnabled: Ptr(false), + IsFirewallRecommendedAllowlistEnabled: Ptr(true), + CustomAllowlist: []string{"192.168.0.0/16"}, + } + + want := `{ + "enabled_tools": { + "codeql": true, + "copilot_code_review": false, + "secret_scanning": true, + "dependency_vulnerability_checks": false + }, + "require_actions_workflow_approval": true, + "is_firewall_enabled": false, + "is_firewall_recommended_allowlist_enabled": true, + "custom_allowlist": ["192.168.0.0/16"] + }` + + testJSONMarshal(t, u, want) +} diff --git a/github/github-accessors.go b/github/github-accessors.go index 5636e7d3f5c..a3e8943610a 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -8190,6 +8190,54 @@ func (c *ContributorStats) GetWeeks() []*WeeklyStats { return c.Weeks } +// GetCustomAllowlist returns the CustomAllowlist slice if it's non-nil, nil otherwise. +func (c *CopilotCloudAgentConfiguration) GetCustomAllowlist() []string { + if c == nil || c.CustomAllowlist == nil { + return nil + } + return c.CustomAllowlist +} + +// GetEnabledTools returns the EnabledTools field. +func (c *CopilotCloudAgentConfiguration) GetEnabledTools() *EnabledTools { + if c == nil { + return nil + } + return c.EnabledTools +} + +// GetIsFirewallEnabled returns the IsFirewallEnabled field if it's non-nil, zero value otherwise. +func (c *CopilotCloudAgentConfiguration) GetIsFirewallEnabled() bool { + if c == nil || c.IsFirewallEnabled == nil { + return false + } + return *c.IsFirewallEnabled +} + +// GetIsFirewallRecommendedAllowlistEnabled returns the IsFirewallRecommendedAllowlistEnabled field if it's non-nil, zero value otherwise. +func (c *CopilotCloudAgentConfiguration) GetIsFirewallRecommendedAllowlistEnabled() bool { + if c == nil || c.IsFirewallRecommendedAllowlistEnabled == nil { + return false + } + return *c.IsFirewallRecommendedAllowlistEnabled +} + +// GetMcpConfiguration returns the McpConfiguration field if it's non-nil, zero value otherwise. +func (c *CopilotCloudAgentConfiguration) GetMcpConfiguration() json.RawMessage { + if c == nil || c.McpConfiguration == nil { + return json.RawMessage{} + } + return *c.McpConfiguration +} + +// GetRequireActionsWorkflowApproval returns the RequireActionsWorkflowApproval field if it's non-nil, zero value otherwise. +func (c *CopilotCloudAgentConfiguration) GetRequireActionsWorkflowApproval() bool { + if c == nil || c.RequireActionsWorkflowApproval == nil { + return false + } + return *c.RequireActionsWorkflowApproval +} + // GetParameters returns the Parameters field. func (c *CopilotCodeReviewBranchRule) GetParameters() CopilotCodeReviewRuleParameters { if c == nil { @@ -14070,6 +14118,38 @@ func (e *EditTopics) GetFrom() []string { return e.From } +// GetCodeql returns the Codeql field if it's non-nil, zero value otherwise. +func (e *EnabledTools) GetCodeql() bool { + if e == nil || e.Codeql == nil { + return false + } + return *e.Codeql +} + +// GetCopilotCodeReview returns the CopilotCodeReview field if it's non-nil, zero value otherwise. +func (e *EnabledTools) GetCopilotCodeReview() bool { + if e == nil || e.CopilotCodeReview == nil { + return false + } + return *e.CopilotCodeReview +} + +// GetDependencyVulnerabilityChecks returns the DependencyVulnerabilityChecks field if it's non-nil, zero value otherwise. +func (e *EnabledTools) GetDependencyVulnerabilityChecks() bool { + if e == nil || e.DependencyVulnerabilityChecks == nil { + return false + } + return *e.DependencyVulnerabilityChecks +} + +// GetSecretScanning returns the SecretScanning field if it's non-nil, zero value otherwise. +func (e *EnabledTools) GetSecretScanning() bool { + if e == nil || e.SecretScanning == nil { + return false + } + return *e.SecretScanning +} + // GetEncryptedValue returns the EncryptedValue field. func (e *EncryptedSecret) GetEncryptedValue() string { if e == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 9648c076cd7..fbc5e576b96 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -10522,6 +10522,69 @@ func TestContributorStats_GetWeeks(tt *testing.T) { c.GetWeeks() } +func TestCopilotCloudAgentConfiguration_GetCustomAllowlist(tt *testing.T) { + tt.Parallel() + zeroValue := []string{} + c := &CopilotCloudAgentConfiguration{CustomAllowlist: zeroValue} + c.GetCustomAllowlist() + c = &CopilotCloudAgentConfiguration{} + c.GetCustomAllowlist() + c = nil + c.GetCustomAllowlist() +} + +func TestCopilotCloudAgentConfiguration_GetEnabledTools(tt *testing.T) { + tt.Parallel() + c := &CopilotCloudAgentConfiguration{} + c.GetEnabledTools() + c = nil + c.GetEnabledTools() +} + +func TestCopilotCloudAgentConfiguration_GetIsFirewallEnabled(tt *testing.T) { + tt.Parallel() + var zeroValue bool + c := &CopilotCloudAgentConfiguration{IsFirewallEnabled: &zeroValue} + c.GetIsFirewallEnabled() + c = &CopilotCloudAgentConfiguration{} + c.GetIsFirewallEnabled() + c = nil + c.GetIsFirewallEnabled() +} + +func TestCopilotCloudAgentConfiguration_GetIsFirewallRecommendedAllowlistEnabled(tt *testing.T) { + tt.Parallel() + var zeroValue bool + c := &CopilotCloudAgentConfiguration{IsFirewallRecommendedAllowlistEnabled: &zeroValue} + c.GetIsFirewallRecommendedAllowlistEnabled() + c = &CopilotCloudAgentConfiguration{} + c.GetIsFirewallRecommendedAllowlistEnabled() + c = nil + c.GetIsFirewallRecommendedAllowlistEnabled() +} + +func TestCopilotCloudAgentConfiguration_GetMcpConfiguration(tt *testing.T) { + tt.Parallel() + var zeroValue json.RawMessage + c := &CopilotCloudAgentConfiguration{McpConfiguration: &zeroValue} + c.GetMcpConfiguration() + c = &CopilotCloudAgentConfiguration{} + c.GetMcpConfiguration() + c = nil + c.GetMcpConfiguration() +} + +func TestCopilotCloudAgentConfiguration_GetRequireActionsWorkflowApproval(tt *testing.T) { + tt.Parallel() + var zeroValue bool + c := &CopilotCloudAgentConfiguration{RequireActionsWorkflowApproval: &zeroValue} + c.GetRequireActionsWorkflowApproval() + c = &CopilotCloudAgentConfiguration{} + c.GetRequireActionsWorkflowApproval() + c = nil + c.GetRequireActionsWorkflowApproval() +} + func TestCopilotCodeReviewBranchRule_GetParameters(tt *testing.T) { tt.Parallel() c := &CopilotCodeReviewBranchRule{} @@ -17830,6 +17893,50 @@ func TestEditTopics_GetFrom(tt *testing.T) { e.GetFrom() } +func TestEnabledTools_GetCodeql(tt *testing.T) { + tt.Parallel() + var zeroValue bool + e := &EnabledTools{Codeql: &zeroValue} + e.GetCodeql() + e = &EnabledTools{} + e.GetCodeql() + e = nil + e.GetCodeql() +} + +func TestEnabledTools_GetCopilotCodeReview(tt *testing.T) { + tt.Parallel() + var zeroValue bool + e := &EnabledTools{CopilotCodeReview: &zeroValue} + e.GetCopilotCodeReview() + e = &EnabledTools{} + e.GetCopilotCodeReview() + e = nil + e.GetCopilotCodeReview() +} + +func TestEnabledTools_GetDependencyVulnerabilityChecks(tt *testing.T) { + tt.Parallel() + var zeroValue bool + e := &EnabledTools{DependencyVulnerabilityChecks: &zeroValue} + e.GetDependencyVulnerabilityChecks() + e = &EnabledTools{} + e.GetDependencyVulnerabilityChecks() + e = nil + e.GetDependencyVulnerabilityChecks() +} + +func TestEnabledTools_GetSecretScanning(tt *testing.T) { + tt.Parallel() + var zeroValue bool + e := &EnabledTools{SecretScanning: &zeroValue} + e.GetSecretScanning() + e = &EnabledTools{} + e.GetSecretScanning() + e = nil + e.GetSecretScanning() +} + func TestEncryptedSecret_GetEncryptedValue(tt *testing.T) { tt.Parallel() e := &EncryptedSecret{} diff --git a/openapi_operations.yaml b/openapi_operations.yaml index 0f22a6f6856..1427933ef61 100644 --- a/openapi_operations.yaml +++ b/openapi_operations.yaml @@ -5638,6 +5638,11 @@ openapi_operations: - descriptions/api.github.com/api.github.com.json - descriptions/ghec/ghec.json - descriptions/ghes-3.21/ghes-3.21.json + - name: GET /repos/{owner}/{repo}/copilot/cloud-agent/configuration + documentation_url: https://docs.github.com/rest/copilot/copilot-cloud-agent-management?apiVersion=2026-03-10#get-copilot-cloud-agent-configuration-for-a-repository + openapi_files: + - descriptions/api.github.com/api.github.com.json + - descriptions/ghec/ghec.json - name: GET /repos/{owner}/{repo}/dependabot/alerts documentation_url: https://docs.github.com/rest/dependabot/alerts#list-dependabot-alerts-for-a-repository openapi_files: From 0451661aa6df309efb773be1efbc10a69c953fd5 Mon Sep 17 00:00:00 2001 From: maishivamhoo123 Date: Thu, 21 May 2026 15:18:38 +0000 Subject: [PATCH 2/5] fix: Update CopilotCloudAgentConfiguration to use pointer type Signed-off-by: maishivamhoo123 --- github/copilot_cloud_agent.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/github/copilot_cloud_agent.go b/github/copilot_cloud_agent.go index 1a688ee25a8..e6f44c3d9dd 100644 --- a/github/copilot_cloud_agent.go +++ b/github/copilot_cloud_agent.go @@ -33,7 +33,7 @@ type EnabledTools struct { // GetCopilotCloudAgentConfiguration gets the Copilot cloud agent configuration for a repository. // -// GitHub API docs: https://docs.github.com/rest/copilot/copilot-cloud-agent-management?apiVersion=2026-03-10#get-copilot-cloud-agent-configuration-for-a-repository +// GitHub API docs: https://docs.github.com/rest/copilot/copilot-cloud-agent-management?apiVersion=2022-11-28#get-copilot-cloud-agent-configuration-for-a-repository // //meta:operation GET /repos/{owner}/{repo}/copilot/cloud-agent/configuration func (s *CopilotService) GetCopilotCloudAgentConfiguration(ctx context.Context, owner, repo string) (*CopilotCloudAgentConfiguration, *Response, error) { @@ -44,11 +44,11 @@ func (s *CopilotService) GetCopilotCloudAgentConfiguration(ctx context.Context, return nil, nil, err } - var config CopilotCloudAgentConfiguration + var config *CopilotCloudAgentConfiguration resp, err := s.client.Do(req, &config) if err != nil { return nil, resp, err } - return &config, resp, nil + return config, resp, nil } From 0d6344cb26b5f385cbbf2c542710a12e879af33a Mon Sep 17 00:00:00 2001 From: maishivamhoo123 Date: Fri, 22 May 2026 12:41:12 +0000 Subject: [PATCH 3/5] fixed all the recomended changes Signed-off-by: maishivamhoo123 --- github/copilot_cloud_agent.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/github/copilot_cloud_agent.go b/github/copilot_cloud_agent.go index e6f44c3d9dd..745a4114b37 100644 --- a/github/copilot_cloud_agent.go +++ b/github/copilot_cloud_agent.go @@ -25,10 +25,10 @@ type CopilotCloudAgentConfiguration struct { // EnabledTools represents the enabled review tools for Copilot cloud agent. type EnabledTools struct { - Codeql *bool `json:"codeql,omitempty"` - CopilotCodeReview *bool `json:"copilot_code_review,omitempty"` - SecretScanning *bool `json:"secret_scanning,omitempty"` - DependencyVulnerabilityChecks *bool `json:"dependency_vulnerability_checks,omitempty"` + Codeql *bool `json:"codeql"` + CopilotCodeReview *bool `json:"copilot_code_review"` + SecretScanning *bool `json:"secret_scanning"` + DependencyVulnerabilityChecks *bool `json:"dependency_vulnerability_checks"` } // GetCopilotCloudAgentConfiguration gets the Copilot cloud agent configuration for a repository. From 8310c32d1eb78498e514a9628c654a3debbcdc0d Mon Sep 17 00:00:00 2001 From: maishivamhoo123 Date: Sat, 23 May 2026 04:48:50 +0000 Subject: [PATCH 4/5] the recommended changes added Signed-off-by: maishivamhoo123 --- github/copilot_cloud_agent.go | 20 +- github/copilot_cloud_agent_test.go | 327 +++++++++++++++++++++++------ github/github-accessors.go | 46 ++-- github/github-accessors_test.go | 35 +-- 4 files changed, 306 insertions(+), 122 deletions(-) diff --git a/github/copilot_cloud_agent.go b/github/copilot_cloud_agent.go index 745a4114b37..85ef0edd607 100644 --- a/github/copilot_cloud_agent.go +++ b/github/copilot_cloud_agent.go @@ -15,20 +15,20 @@ import ( // // GitHub API docs: https://docs.github.com/en/rest/copilot/copilot-cloud-agent-management?apiVersion=2026-03-10#get-copilot-cloud-agent-configuration-for-a-repository type CopilotCloudAgentConfiguration struct { - McpConfiguration *json.RawMessage `json:"mcp_configuration,omitempty"` - EnabledTools *EnabledTools `json:"enabled_tools,omitempty"` - RequireActionsWorkflowApproval *bool `json:"require_actions_workflow_approval,omitempty"` - IsFirewallEnabled *bool `json:"is_firewall_enabled,omitempty"` - IsFirewallRecommendedAllowlistEnabled *bool `json:"is_firewall_recommended_allowlist_enabled,omitempty"` - CustomAllowlist []string `json:"custom_allowlist,omitempty"` + McpConfiguration *json.RawMessage `json:"mcp_configuration"` + EnabledTools EnabledTools `json:"enabled_tools"` + RequireActionsWorkflowApproval bool `json:"require_actions_workflow_approval"` + IsFirewallEnabled bool `json:"is_firewall_enabled"` + IsFirewallRecommendedAllowlistEnabled bool `json:"is_firewall_recommended_allowlist_enabled"` + CustomAllowlist []string `json:"custom_allowlist"` } // EnabledTools represents the enabled review tools for Copilot cloud agent. type EnabledTools struct { - Codeql *bool `json:"codeql"` - CopilotCodeReview *bool `json:"copilot_code_review"` - SecretScanning *bool `json:"secret_scanning"` - DependencyVulnerabilityChecks *bool `json:"dependency_vulnerability_checks"` + Codeql bool `json:"codeql"` + CopilotCodeReview bool `json:"copilot_code_review"` + SecretScanning bool `json:"secret_scanning"` + DependencyVulnerabilityChecks bool `json:"dependency_vulnerability_checks"` } // GetCopilotCloudAgentConfiguration gets the Copilot cloud agent configuration for a repository. diff --git a/github/copilot_cloud_agent_test.go b/github/copilot_cloud_agent_test.go index bcf5d13b832..45f3b5260b5 100644 --- a/github/copilot_cloud_agent_test.go +++ b/github/copilot_cloud_agent_test.go @@ -6,6 +6,7 @@ package github import ( + "encoding/json" "fmt" "net/http" "testing" @@ -15,56 +16,147 @@ import ( func TestCopilotService_GetCopilotCloudAgentConfiguration(t *testing.T) { t.Parallel() - client, mux, _ := setup(t) - mux.HandleFunc("/repos/o/r/copilot/cloud-agent/configuration", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") - fmt.Fprint(w, `{ - "mcp_configuration": null, - "enabled_tools": { - "codeql": true, - "copilot_code_review": true, - "secret_scanning": true, - "dependency_vulnerability_checks": true + tests := []struct { + name string + responseBody string + want *CopilotCloudAgentConfiguration + wantErr bool + }{ + { + name: "with null mcp_configuration", + responseBody: `{ + "mcp_configuration": null, + "enabled_tools": { + "codeql": true, + "copilot_code_review": true, + "secret_scanning": true, + "dependency_vulnerability_checks": true + }, + "require_actions_workflow_approval": true, + "is_firewall_enabled": true, + "is_firewall_recommended_allowlist_enabled": true, + "custom_allowlist": [] + }`, + want: &CopilotCloudAgentConfiguration{ + McpConfiguration: nil, + EnabledTools: EnabledTools{ + Codeql: true, + CopilotCodeReview: true, + SecretScanning: true, + DependencyVulnerabilityChecks: true, + }, + RequireActionsWorkflowApproval: true, + IsFirewallEnabled: true, + IsFirewallRecommendedAllowlistEnabled: true, + CustomAllowlist: []string{}, }, - "require_actions_workflow_approval": true, - "is_firewall_enabled": true, - "is_firewall_recommended_allowlist_enabled": true, - "custom_allowlist": [] - }`) - }) - - ctx := t.Context() - config, _, err := client.Copilot.GetCopilotCloudAgentConfiguration(ctx, "o", "r") - if err != nil { - t.Errorf("GetCopilotCloudAgentConfiguration returned error: %v", err) - } - - want := &CopilotCloudAgentConfiguration{ - McpConfiguration: nil, - EnabledTools: &EnabledTools{ - Codeql: Ptr(true), - CopilotCodeReview: Ptr(true), - SecretScanning: Ptr(true), - DependencyVulnerabilityChecks: Ptr(true), + wantErr: false, + }, + { + name: "with custom allowlist", + responseBody: `{ + "mcp_configuration": null, + "enabled_tools": { + "codeql": false, + "copilot_code_review": true, + "secret_scanning": false, + "dependency_vulnerability_checks": true + }, + "require_actions_workflow_approval": false, + "is_firewall_enabled": true, + "is_firewall_recommended_allowlist_enabled": true, + "custom_allowlist": ["192.168.0.0/16", "10.0.0.0/8"] + }`, + want: &CopilotCloudAgentConfiguration{ + McpConfiguration: nil, + EnabledTools: EnabledTools{ + Codeql: false, + CopilotCodeReview: true, + SecretScanning: false, + DependencyVulnerabilityChecks: true, + }, + RequireActionsWorkflowApproval: false, + IsFirewallEnabled: true, + IsFirewallRecommendedAllowlistEnabled: true, + CustomAllowlist: []string{"192.168.0.0/16", "10.0.0.0/8"}, + }, + wantErr: false, + }, + { + name: "all tools disabled", + responseBody: `{ + "mcp_configuration": null, + "enabled_tools": { + "codeql": false, + "copilot_code_review": false, + "secret_scanning": false, + "dependency_vulnerability_checks": false + }, + "require_actions_workflow_approval": false, + "is_firewall_enabled": false, + "is_firewall_recommended_allowlist_enabled": false, + "custom_allowlist": [] + }`, + want: &CopilotCloudAgentConfiguration{ + McpConfiguration: nil, + EnabledTools: EnabledTools{ + Codeql: false, + CopilotCodeReview: false, + SecretScanning: false, + DependencyVulnerabilityChecks: false, + }, + RequireActionsWorkflowApproval: false, + IsFirewallEnabled: false, + IsFirewallRecommendedAllowlistEnabled: false, + CustomAllowlist: []string{}, + }, + wantErr: false, }, - RequireActionsWorkflowApproval: Ptr(true), - IsFirewallEnabled: Ptr(true), - IsFirewallRecommendedAllowlistEnabled: Ptr(true), - CustomAllowlist: []string{}, } - if !cmp.Equal(config, want) { - t.Errorf("GetCopilotCloudAgentConfiguration returned %+v, want %+v", config, want) + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + + mux.HandleFunc("/repos/o/r/copilot/cloud-agent/configuration", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + fmt.Fprint(w, tt.responseBody) + }) + + ctx := t.Context() + config, _, err := client.Copilot.GetCopilotCloudAgentConfiguration(ctx, "o", "r") + if (err != nil) != tt.wantErr { + t.Errorf("GetCopilotCloudAgentConfiguration returned error: %v, wantErr: %v", err, tt.wantErr) + } + + if !cmp.Equal(config, tt.want) { + t.Errorf("GetCopilotCloudAgentConfiguration returned %+v, want %+v", config, tt.want) + } + }) } +} +func TestCopilotService_GetCopilotCloudAgentConfiguration_BadOptions(t *testing.T) { + t.Parallel() + client, _, _ := setup(t) + + ctx := t.Context() const methodName = "GetCopilotCloudAgentConfiguration" testBadOptions(t, methodName, func() (err error) { _, _, err = client.Copilot.GetCopilotCloudAgentConfiguration(ctx, "\n", "\n") return err }) +} + +func TestCopilotService_GetCopilotCloudAgentConfiguration_NewRequestFailure(t *testing.T) { + t.Parallel() + client, _, _ := setup(t) + const methodName = "GetCopilotCloudAgentConfiguration" testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { + ctx := t.Context() got, resp, err := client.Copilot.GetCopilotCloudAgentConfiguration(ctx, "o", "r") if got != nil { t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) @@ -113,36 +205,149 @@ func TestCopilotService_GetCopilotCloudAgentConfiguration_NotFound(t *testing.T) } } +func TestCopilotService_GetCopilotCloudAgentConfiguration_Forbidden(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + + mux.HandleFunc("/repos/o/r/copilot/cloud-agent/configuration", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + w.WriteHeader(http.StatusForbidden) + }) + + ctx := t.Context() + config, resp, err := client.Copilot.GetCopilotCloudAgentConfiguration(ctx, "o", "r") + if err == nil { + t.Error("Expected HTTP 403 response") + } + if got, want := resp.Response.StatusCode, http.StatusForbidden; got != want { + t.Errorf("GetCopilotCloudAgentConfiguration return status %v, want %v", got, want) + } + if config != nil { + t.Errorf("GetCopilotCloudAgentConfiguration return %+v, want nil", config) + } +} + func TestCopilotCloudAgentConfiguration_Marshal(t *testing.T) { t.Parallel() - testJSONMarshal(t, &CopilotCloudAgentConfiguration{}, "{}") - - u := &CopilotCloudAgentConfiguration{ - McpConfiguration: nil, - EnabledTools: &EnabledTools{ - Codeql: Ptr(true), - CopilotCodeReview: Ptr(false), - SecretScanning: Ptr(true), - DependencyVulnerabilityChecks: Ptr(false), + + tests := []struct { + name string + u *CopilotCloudAgentConfiguration + want string + }{ + { + name: "empty configuration", + u: &CopilotCloudAgentConfiguration{}, + want: `{"mcp_configuration":null,"enabled_tools":{"codeql":false,"copilot_code_review":false,"secret_scanning":false,"dependency_vulnerability_checks":false},"require_actions_workflow_approval":false,"is_firewall_enabled":false,"is_firewall_recommended_allowlist_enabled":false,"custom_allowlist":null}`, + }, + { + name: "with all settings configured", + u: &CopilotCloudAgentConfiguration{ + McpConfiguration: nil, + EnabledTools: EnabledTools{ + Codeql: true, + CopilotCodeReview: false, + SecretScanning: true, + DependencyVulnerabilityChecks: false, + }, + RequireActionsWorkflowApproval: true, + IsFirewallEnabled: false, + IsFirewallRecommendedAllowlistEnabled: true, + CustomAllowlist: []string{"192.168.0.0/16"}, + }, + want: `{"mcp_configuration":null,"enabled_tools":{"codeql":true,"copilot_code_review":false,"secret_scanning":true,"dependency_vulnerability_checks":false},"require_actions_workflow_approval":true,"is_firewall_enabled":false,"is_firewall_recommended_allowlist_enabled":true,"custom_allowlist":["192.168.0.0/16"]}`, }, - RequireActionsWorkflowApproval: Ptr(true), - IsFirewallEnabled: Ptr(false), - IsFirewallRecommendedAllowlistEnabled: Ptr(true), - CustomAllowlist: []string{"192.168.0.0/16"}, + { + name: "with mcp configuration", + u: &CopilotCloudAgentConfiguration{ + McpConfiguration: func() *json.RawMessage { + raw := json.RawMessage(`{"type":"resource","uri":"stdio://server"}`) + return &raw + }(), + EnabledTools: EnabledTools{ + Codeql: true, + CopilotCodeReview: true, + SecretScanning: true, + DependencyVulnerabilityChecks: true, + }, + RequireActionsWorkflowApproval: true, + IsFirewallEnabled: true, + IsFirewallRecommendedAllowlistEnabled: false, + CustomAllowlist: []string{}, + }, + want: `{"mcp_configuration":{"type":"resource","uri":"stdio://server"},"enabled_tools":{"codeql":true,"copilot_code_review":true,"secret_scanning":true,"dependency_vulnerability_checks":true},"require_actions_workflow_approval":true,"is_firewall_enabled":true,"is_firewall_recommended_allowlist_enabled":false,"custom_allowlist":[]}`, + }, + { + name: "with multiple allowlist entries", + u: &CopilotCloudAgentConfiguration{ + McpConfiguration: nil, + EnabledTools: EnabledTools{ + Codeql: false, + CopilotCodeReview: false, + SecretScanning: false, + DependencyVulnerabilityChecks: false, + }, + RequireActionsWorkflowApproval: false, + IsFirewallEnabled: true, + IsFirewallRecommendedAllowlistEnabled: true, + CustomAllowlist: []string{"192.168.0.0/16", "10.0.0.0/8", "172.16.0.0/12"}, + }, + want: `{"mcp_configuration":null,"enabled_tools":{"codeql":false,"copilot_code_review":false,"secret_scanning":false,"dependency_vulnerability_checks":false},"require_actions_workflow_approval":false,"is_firewall_enabled":true,"is_firewall_recommended_allowlist_enabled":true,"custom_allowlist":["192.168.0.0/16","10.0.0.0/8","172.16.0.0/12"]}`, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + t.Parallel() + testJSONMarshal(t, tt.u, tt.want) + }) } +} + +func TestEnabledTools_Marshal(t *testing.T) { + t.Parallel() - want := `{ - "enabled_tools": { - "codeql": true, - "copilot_code_review": false, - "secret_scanning": true, - "dependency_vulnerability_checks": false + tests := []struct { + name string + u *EnabledTools + want string + }{ + { + name: "all enabled", + u: &EnabledTools{ + Codeql: true, + CopilotCodeReview: true, + SecretScanning: true, + DependencyVulnerabilityChecks: true, + }, + want: `{"codeql":true,"copilot_code_review":true,"secret_scanning":true,"dependency_vulnerability_checks":true}`, + }, + { + name: "all disabled", + u: &EnabledTools{ + Codeql: false, + CopilotCodeReview: false, + SecretScanning: false, + DependencyVulnerabilityChecks: false, + }, + want: `{"codeql":false,"copilot_code_review":false,"secret_scanning":false,"dependency_vulnerability_checks":false}`, }, - "require_actions_workflow_approval": true, - "is_firewall_enabled": false, - "is_firewall_recommended_allowlist_enabled": true, - "custom_allowlist": ["192.168.0.0/16"] - }` + { + name: "mixed settings", + u: &EnabledTools{ + Codeql: true, + CopilotCodeReview: false, + SecretScanning: true, + DependencyVulnerabilityChecks: false, + }, + want: `{"codeql":true,"copilot_code_review":false,"secret_scanning":true,"dependency_vulnerability_checks":false}`, + }, + } - testJSONMarshal(t, u, want) + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + t.Parallel() + testJSONMarshal(t, tt.u, tt.want) + }) + } } diff --git a/github/github-accessors.go b/github/github-accessors.go index a3e8943610a..85eff7f4723 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -8199,27 +8199,27 @@ func (c *CopilotCloudAgentConfiguration) GetCustomAllowlist() []string { } // GetEnabledTools returns the EnabledTools field. -func (c *CopilotCloudAgentConfiguration) GetEnabledTools() *EnabledTools { +func (c *CopilotCloudAgentConfiguration) GetEnabledTools() EnabledTools { if c == nil { - return nil + return EnabledTools{} } return c.EnabledTools } -// GetIsFirewallEnabled returns the IsFirewallEnabled field if it's non-nil, zero value otherwise. +// GetIsFirewallEnabled returns the IsFirewallEnabled field. func (c *CopilotCloudAgentConfiguration) GetIsFirewallEnabled() bool { - if c == nil || c.IsFirewallEnabled == nil { + if c == nil { return false } - return *c.IsFirewallEnabled + return c.IsFirewallEnabled } -// GetIsFirewallRecommendedAllowlistEnabled returns the IsFirewallRecommendedAllowlistEnabled field if it's non-nil, zero value otherwise. +// GetIsFirewallRecommendedAllowlistEnabled returns the IsFirewallRecommendedAllowlistEnabled field. func (c *CopilotCloudAgentConfiguration) GetIsFirewallRecommendedAllowlistEnabled() bool { - if c == nil || c.IsFirewallRecommendedAllowlistEnabled == nil { + if c == nil { return false } - return *c.IsFirewallRecommendedAllowlistEnabled + return c.IsFirewallRecommendedAllowlistEnabled } // GetMcpConfiguration returns the McpConfiguration field if it's non-nil, zero value otherwise. @@ -8230,12 +8230,12 @@ func (c *CopilotCloudAgentConfiguration) GetMcpConfiguration() json.RawMessage { return *c.McpConfiguration } -// GetRequireActionsWorkflowApproval returns the RequireActionsWorkflowApproval field if it's non-nil, zero value otherwise. +// GetRequireActionsWorkflowApproval returns the RequireActionsWorkflowApproval field. func (c *CopilotCloudAgentConfiguration) GetRequireActionsWorkflowApproval() bool { - if c == nil || c.RequireActionsWorkflowApproval == nil { + if c == nil { return false } - return *c.RequireActionsWorkflowApproval + return c.RequireActionsWorkflowApproval } // GetParameters returns the Parameters field. @@ -14118,36 +14118,36 @@ func (e *EditTopics) GetFrom() []string { return e.From } -// GetCodeql returns the Codeql field if it's non-nil, zero value otherwise. +// GetCodeql returns the Codeql field. func (e *EnabledTools) GetCodeql() bool { - if e == nil || e.Codeql == nil { + if e == nil { return false } - return *e.Codeql + return e.Codeql } -// GetCopilotCodeReview returns the CopilotCodeReview field if it's non-nil, zero value otherwise. +// GetCopilotCodeReview returns the CopilotCodeReview field. func (e *EnabledTools) GetCopilotCodeReview() bool { - if e == nil || e.CopilotCodeReview == nil { + if e == nil { return false } - return *e.CopilotCodeReview + return e.CopilotCodeReview } -// GetDependencyVulnerabilityChecks returns the DependencyVulnerabilityChecks field if it's non-nil, zero value otherwise. +// GetDependencyVulnerabilityChecks returns the DependencyVulnerabilityChecks field. func (e *EnabledTools) GetDependencyVulnerabilityChecks() bool { - if e == nil || e.DependencyVulnerabilityChecks == nil { + if e == nil { return false } - return *e.DependencyVulnerabilityChecks + return e.DependencyVulnerabilityChecks } -// GetSecretScanning returns the SecretScanning field if it's non-nil, zero value otherwise. +// GetSecretScanning returns the SecretScanning field. func (e *EnabledTools) GetSecretScanning() bool { - if e == nil || e.SecretScanning == nil { + if e == nil { return false } - return *e.SecretScanning + return e.SecretScanning } // GetEncryptedValue returns the EncryptedValue field. diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index fbc5e576b96..69f5cfff6c0 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -10543,10 +10543,7 @@ func TestCopilotCloudAgentConfiguration_GetEnabledTools(tt *testing.T) { func TestCopilotCloudAgentConfiguration_GetIsFirewallEnabled(tt *testing.T) { tt.Parallel() - var zeroValue bool - c := &CopilotCloudAgentConfiguration{IsFirewallEnabled: &zeroValue} - c.GetIsFirewallEnabled() - c = &CopilotCloudAgentConfiguration{} + c := &CopilotCloudAgentConfiguration{} c.GetIsFirewallEnabled() c = nil c.GetIsFirewallEnabled() @@ -10554,10 +10551,7 @@ func TestCopilotCloudAgentConfiguration_GetIsFirewallEnabled(tt *testing.T) { func TestCopilotCloudAgentConfiguration_GetIsFirewallRecommendedAllowlistEnabled(tt *testing.T) { tt.Parallel() - var zeroValue bool - c := &CopilotCloudAgentConfiguration{IsFirewallRecommendedAllowlistEnabled: &zeroValue} - c.GetIsFirewallRecommendedAllowlistEnabled() - c = &CopilotCloudAgentConfiguration{} + c := &CopilotCloudAgentConfiguration{} c.GetIsFirewallRecommendedAllowlistEnabled() c = nil c.GetIsFirewallRecommendedAllowlistEnabled() @@ -10576,10 +10570,7 @@ func TestCopilotCloudAgentConfiguration_GetMcpConfiguration(tt *testing.T) { func TestCopilotCloudAgentConfiguration_GetRequireActionsWorkflowApproval(tt *testing.T) { tt.Parallel() - var zeroValue bool - c := &CopilotCloudAgentConfiguration{RequireActionsWorkflowApproval: &zeroValue} - c.GetRequireActionsWorkflowApproval() - c = &CopilotCloudAgentConfiguration{} + c := &CopilotCloudAgentConfiguration{} c.GetRequireActionsWorkflowApproval() c = nil c.GetRequireActionsWorkflowApproval() @@ -17895,10 +17886,7 @@ func TestEditTopics_GetFrom(tt *testing.T) { func TestEnabledTools_GetCodeql(tt *testing.T) { tt.Parallel() - var zeroValue bool - e := &EnabledTools{Codeql: &zeroValue} - e.GetCodeql() - e = &EnabledTools{} + e := &EnabledTools{} e.GetCodeql() e = nil e.GetCodeql() @@ -17906,10 +17894,7 @@ func TestEnabledTools_GetCodeql(tt *testing.T) { func TestEnabledTools_GetCopilotCodeReview(tt *testing.T) { tt.Parallel() - var zeroValue bool - e := &EnabledTools{CopilotCodeReview: &zeroValue} - e.GetCopilotCodeReview() - e = &EnabledTools{} + e := &EnabledTools{} e.GetCopilotCodeReview() e = nil e.GetCopilotCodeReview() @@ -17917,10 +17902,7 @@ func TestEnabledTools_GetCopilotCodeReview(tt *testing.T) { func TestEnabledTools_GetDependencyVulnerabilityChecks(tt *testing.T) { tt.Parallel() - var zeroValue bool - e := &EnabledTools{DependencyVulnerabilityChecks: &zeroValue} - e.GetDependencyVulnerabilityChecks() - e = &EnabledTools{} + e := &EnabledTools{} e.GetDependencyVulnerabilityChecks() e = nil e.GetDependencyVulnerabilityChecks() @@ -17928,10 +17910,7 @@ func TestEnabledTools_GetDependencyVulnerabilityChecks(tt *testing.T) { func TestEnabledTools_GetSecretScanning(tt *testing.T) { tt.Parallel() - var zeroValue bool - e := &EnabledTools{SecretScanning: &zeroValue} - e.GetSecretScanning() - e = &EnabledTools{} + e := &EnabledTools{} e.GetSecretScanning() e = nil e.GetSecretScanning() From ccf294809c92058d37169482f4264cb6970add59 Mon Sep 17 00:00:00 2001 From: maishivamhoo123 Date: Sun, 24 May 2026 04:03:41 +0000 Subject: [PATCH 5/5] added all the recomended changes Signed-off-by: maishivamhoo123 --- github/copilot_cloud_agent.go | 20 ++++----- github/copilot_cloud_agent_test.go | 68 +++++++++++++++--------------- github/github-accessors.go | 68 +++++++++++++++--------------- github/github-accessors_test.go | 64 ++++++++++++++-------------- 4 files changed, 110 insertions(+), 110 deletions(-) diff --git a/github/copilot_cloud_agent.go b/github/copilot_cloud_agent.go index 85ef0edd607..b167a078b51 100644 --- a/github/copilot_cloud_agent.go +++ b/github/copilot_cloud_agent.go @@ -15,28 +15,28 @@ import ( // // GitHub API docs: https://docs.github.com/en/rest/copilot/copilot-cloud-agent-management?apiVersion=2026-03-10#get-copilot-cloud-agent-configuration-for-a-repository type CopilotCloudAgentConfiguration struct { - McpConfiguration *json.RawMessage `json:"mcp_configuration"` - EnabledTools EnabledTools `json:"enabled_tools"` - RequireActionsWorkflowApproval bool `json:"require_actions_workflow_approval"` - IsFirewallEnabled bool `json:"is_firewall_enabled"` - IsFirewallRecommendedAllowlistEnabled bool `json:"is_firewall_recommended_allowlist_enabled"` - CustomAllowlist []string `json:"custom_allowlist"` + McpConfiguration *json.RawMessage `json:"mcp_configuration"` + EnabledTools *CopilotCloudAgentEnabledTools `json:"enabled_tools"` + RequireActionsWorkflowApproval bool `json:"require_actions_workflow_approval"` + IsFirewallEnabled bool `json:"is_firewall_enabled"` + IsFirewallRecommendedAllowlistEnabled bool `json:"is_firewall_recommended_allowlist_enabled"` + CustomAllowlist []string `json:"custom_allowlist"` } -// EnabledTools represents the enabled review tools for Copilot cloud agent. -type EnabledTools struct { +// CopilotCloudAgentEnabledTools represents the enabled review tools for Copilot cloud agent. +type CopilotCloudAgentEnabledTools struct { Codeql bool `json:"codeql"` CopilotCodeReview bool `json:"copilot_code_review"` SecretScanning bool `json:"secret_scanning"` DependencyVulnerabilityChecks bool `json:"dependency_vulnerability_checks"` } -// GetCopilotCloudAgentConfiguration gets the Copilot cloud agent configuration for a repository. +// GetCloudAgentConfiguration gets the Copilot cloud agent configuration for a repository. // // GitHub API docs: https://docs.github.com/rest/copilot/copilot-cloud-agent-management?apiVersion=2022-11-28#get-copilot-cloud-agent-configuration-for-a-repository // //meta:operation GET /repos/{owner}/{repo}/copilot/cloud-agent/configuration -func (s *CopilotService) GetCopilotCloudAgentConfiguration(ctx context.Context, owner, repo string) (*CopilotCloudAgentConfiguration, *Response, error) { +func (s *CopilotService) GetCloudAgentConfiguration(ctx context.Context, owner, repo string) (*CopilotCloudAgentConfiguration, *Response, error) { u := fmt.Sprintf("repos/%v/%v/copilot/cloud-agent/configuration", owner, repo) req, err := s.client.NewRequest(ctx, "GET", u, nil) diff --git a/github/copilot_cloud_agent_test.go b/github/copilot_cloud_agent_test.go index 45f3b5260b5..73b3a587173 100644 --- a/github/copilot_cloud_agent_test.go +++ b/github/copilot_cloud_agent_test.go @@ -14,7 +14,7 @@ import ( "github.com/google/go-cmp/cmp" ) -func TestCopilotService_GetCopilotCloudAgentConfiguration(t *testing.T) { +func TestCopilotService_GetCloudAgentConfiguration(t *testing.T) { t.Parallel() tests := []struct { @@ -40,7 +40,7 @@ func TestCopilotService_GetCopilotCloudAgentConfiguration(t *testing.T) { }`, want: &CopilotCloudAgentConfiguration{ McpConfiguration: nil, - EnabledTools: EnabledTools{ + EnabledTools: &CopilotCloudAgentEnabledTools{ Codeql: true, CopilotCodeReview: true, SecretScanning: true, @@ -70,7 +70,7 @@ func TestCopilotService_GetCopilotCloudAgentConfiguration(t *testing.T) { }`, want: &CopilotCloudAgentConfiguration{ McpConfiguration: nil, - EnabledTools: EnabledTools{ + EnabledTools: &CopilotCloudAgentEnabledTools{ Codeql: false, CopilotCodeReview: true, SecretScanning: false, @@ -100,7 +100,7 @@ func TestCopilotService_GetCopilotCloudAgentConfiguration(t *testing.T) { }`, want: &CopilotCloudAgentConfiguration{ McpConfiguration: nil, - EnabledTools: EnabledTools{ + EnabledTools: &CopilotCloudAgentEnabledTools{ Codeql: false, CopilotCodeReview: false, SecretScanning: false, @@ -126,38 +126,38 @@ func TestCopilotService_GetCopilotCloudAgentConfiguration(t *testing.T) { }) ctx := t.Context() - config, _, err := client.Copilot.GetCopilotCloudAgentConfiguration(ctx, "o", "r") + config, _, err := client.Copilot.GetCloudAgentConfiguration(ctx, "o", "r") if (err != nil) != tt.wantErr { - t.Errorf("GetCopilotCloudAgentConfiguration returned error: %v, wantErr: %v", err, tt.wantErr) + t.Errorf("GetCloudAgentConfiguration returned error: %v, wantErr: %v", err, tt.wantErr) } if !cmp.Equal(config, tt.want) { - t.Errorf("GetCopilotCloudAgentConfiguration returned %+v, want %+v", config, tt.want) + t.Errorf("GetCloudAgentConfiguration returned %+v, want %+v", config, tt.want) } }) } } -func TestCopilotService_GetCopilotCloudAgentConfiguration_BadOptions(t *testing.T) { +func TestCopilotService_GetCloudAgentConfiguration_BadOptions(t *testing.T) { t.Parallel() client, _, _ := setup(t) ctx := t.Context() - const methodName = "GetCopilotCloudAgentConfiguration" + const methodName = "GetCloudAgentConfiguration" testBadOptions(t, methodName, func() (err error) { - _, _, err = client.Copilot.GetCopilotCloudAgentConfiguration(ctx, "\n", "\n") + _, _, err = client.Copilot.GetCloudAgentConfiguration(ctx, "\n", "\n") return err }) } -func TestCopilotService_GetCopilotCloudAgentConfiguration_NewRequestFailure(t *testing.T) { +func TestCopilotService_GetCloudAgentConfiguration_NewRequestFailure(t *testing.T) { t.Parallel() client, _, _ := setup(t) - const methodName = "GetCopilotCloudAgentConfiguration" + const methodName = "GetCloudAgentConfiguration" testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { ctx := t.Context() - got, resp, err := client.Copilot.GetCopilotCloudAgentConfiguration(ctx, "o", "r") + got, resp, err := client.Copilot.GetCloudAgentConfiguration(ctx, "o", "r") if got != nil { t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) } @@ -165,25 +165,25 @@ func TestCopilotService_GetCopilotCloudAgentConfiguration_NewRequestFailure(t *t }) } -func TestCopilotService_GetCopilotCloudAgentConfiguration_InvalidOwner(t *testing.T) { +func TestCopilotService_GetCloudAgentConfiguration_InvalidOwner(t *testing.T) { t.Parallel() client, _, _ := setup(t) ctx := t.Context() - _, _, err := client.Copilot.GetCopilotCloudAgentConfiguration(ctx, "%", "r") + _, _, err := client.Copilot.GetCloudAgentConfiguration(ctx, "%", "r") testURLParseError(t, err) } -func TestCopilotService_GetCopilotCloudAgentConfiguration_InvalidRepo(t *testing.T) { +func TestCopilotService_GetCloudAgentConfiguration_InvalidRepo(t *testing.T) { t.Parallel() client, _, _ := setup(t) ctx := t.Context() - _, _, err := client.Copilot.GetCopilotCloudAgentConfiguration(ctx, "o", "%") + _, _, err := client.Copilot.GetCloudAgentConfiguration(ctx, "o", "%") testURLParseError(t, err) } -func TestCopilotService_GetCopilotCloudAgentConfiguration_NotFound(t *testing.T) { +func TestCopilotService_GetCloudAgentConfiguration_NotFound(t *testing.T) { t.Parallel() client, mux, _ := setup(t) @@ -193,19 +193,19 @@ func TestCopilotService_GetCopilotCloudAgentConfiguration_NotFound(t *testing.T) }) ctx := t.Context() - config, resp, err := client.Copilot.GetCopilotCloudAgentConfiguration(ctx, "o", "r") + config, resp, err := client.Copilot.GetCloudAgentConfiguration(ctx, "o", "r") if err == nil { t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { - t.Errorf("GetCopilotCloudAgentConfiguration return status %v, want %v", got, want) + t.Errorf("GetCloudAgentConfiguration return status %v, want %v", got, want) } if config != nil { - t.Errorf("GetCopilotCloudAgentConfiguration return %+v, want nil", config) + t.Errorf("GetCloudAgentConfiguration return %+v, want nil", config) } } -func TestCopilotService_GetCopilotCloudAgentConfiguration_Forbidden(t *testing.T) { +func TestCopilotService_GetCloudAgentConfiguration_Forbidden(t *testing.T) { t.Parallel() client, mux, _ := setup(t) @@ -215,15 +215,15 @@ func TestCopilotService_GetCopilotCloudAgentConfiguration_Forbidden(t *testing.T }) ctx := t.Context() - config, resp, err := client.Copilot.GetCopilotCloudAgentConfiguration(ctx, "o", "r") + config, resp, err := client.Copilot.GetCloudAgentConfiguration(ctx, "o", "r") if err == nil { t.Error("Expected HTTP 403 response") } if got, want := resp.Response.StatusCode, http.StatusForbidden; got != want { - t.Errorf("GetCopilotCloudAgentConfiguration return status %v, want %v", got, want) + t.Errorf("GetCloudAgentConfiguration return status %v, want %v", got, want) } if config != nil { - t.Errorf("GetCopilotCloudAgentConfiguration return %+v, want nil", config) + t.Errorf("GetCloudAgentConfiguration return %+v, want nil", config) } } @@ -238,13 +238,13 @@ func TestCopilotCloudAgentConfiguration_Marshal(t *testing.T) { { name: "empty configuration", u: &CopilotCloudAgentConfiguration{}, - want: `{"mcp_configuration":null,"enabled_tools":{"codeql":false,"copilot_code_review":false,"secret_scanning":false,"dependency_vulnerability_checks":false},"require_actions_workflow_approval":false,"is_firewall_enabled":false,"is_firewall_recommended_allowlist_enabled":false,"custom_allowlist":null}`, + want: `{"mcp_configuration":null,"enabled_tools":null,"require_actions_workflow_approval":false,"is_firewall_enabled":false,"is_firewall_recommended_allowlist_enabled":false,"custom_allowlist":null}`, }, { name: "with all settings configured", u: &CopilotCloudAgentConfiguration{ McpConfiguration: nil, - EnabledTools: EnabledTools{ + EnabledTools: &CopilotCloudAgentEnabledTools{ Codeql: true, CopilotCodeReview: false, SecretScanning: true, @@ -264,7 +264,7 @@ func TestCopilotCloudAgentConfiguration_Marshal(t *testing.T) { raw := json.RawMessage(`{"type":"resource","uri":"stdio://server"}`) return &raw }(), - EnabledTools: EnabledTools{ + EnabledTools: &CopilotCloudAgentEnabledTools{ Codeql: true, CopilotCodeReview: true, SecretScanning: true, @@ -281,7 +281,7 @@ func TestCopilotCloudAgentConfiguration_Marshal(t *testing.T) { name: "with multiple allowlist entries", u: &CopilotCloudAgentConfiguration{ McpConfiguration: nil, - EnabledTools: EnabledTools{ + EnabledTools: &CopilotCloudAgentEnabledTools{ Codeql: false, CopilotCodeReview: false, SecretScanning: false, @@ -304,17 +304,17 @@ func TestCopilotCloudAgentConfiguration_Marshal(t *testing.T) { } } -func TestEnabledTools_Marshal(t *testing.T) { +func TestCopilotCloudAgentEnabledTools_Marshal(t *testing.T) { t.Parallel() tests := []struct { name string - u *EnabledTools + u *CopilotCloudAgentEnabledTools want string }{ { name: "all enabled", - u: &EnabledTools{ + u: &CopilotCloudAgentEnabledTools{ Codeql: true, CopilotCodeReview: true, SecretScanning: true, @@ -324,7 +324,7 @@ func TestEnabledTools_Marshal(t *testing.T) { }, { name: "all disabled", - u: &EnabledTools{ + u: &CopilotCloudAgentEnabledTools{ Codeql: false, CopilotCodeReview: false, SecretScanning: false, @@ -334,7 +334,7 @@ func TestEnabledTools_Marshal(t *testing.T) { }, { name: "mixed settings", - u: &EnabledTools{ + u: &CopilotCloudAgentEnabledTools{ Codeql: true, CopilotCodeReview: false, SecretScanning: true, diff --git a/github/github-accessors.go b/github/github-accessors.go index 85eff7f4723..4ed63c6f9d0 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -8199,9 +8199,9 @@ func (c *CopilotCloudAgentConfiguration) GetCustomAllowlist() []string { } // GetEnabledTools returns the EnabledTools field. -func (c *CopilotCloudAgentConfiguration) GetEnabledTools() EnabledTools { +func (c *CopilotCloudAgentConfiguration) GetEnabledTools() *CopilotCloudAgentEnabledTools { if c == nil { - return EnabledTools{} + return nil } return c.EnabledTools } @@ -8238,6 +8238,38 @@ func (c *CopilotCloudAgentConfiguration) GetRequireActionsWorkflowApproval() boo return c.RequireActionsWorkflowApproval } +// GetCodeql returns the Codeql field. +func (c *CopilotCloudAgentEnabledTools) GetCodeql() bool { + if c == nil { + return false + } + return c.Codeql +} + +// GetCopilotCodeReview returns the CopilotCodeReview field. +func (c *CopilotCloudAgentEnabledTools) GetCopilotCodeReview() bool { + if c == nil { + return false + } + return c.CopilotCodeReview +} + +// GetDependencyVulnerabilityChecks returns the DependencyVulnerabilityChecks field. +func (c *CopilotCloudAgentEnabledTools) GetDependencyVulnerabilityChecks() bool { + if c == nil { + return false + } + return c.DependencyVulnerabilityChecks +} + +// GetSecretScanning returns the SecretScanning field. +func (c *CopilotCloudAgentEnabledTools) GetSecretScanning() bool { + if c == nil { + return false + } + return c.SecretScanning +} + // GetParameters returns the Parameters field. func (c *CopilotCodeReviewBranchRule) GetParameters() CopilotCodeReviewRuleParameters { if c == nil { @@ -14118,38 +14150,6 @@ func (e *EditTopics) GetFrom() []string { return e.From } -// GetCodeql returns the Codeql field. -func (e *EnabledTools) GetCodeql() bool { - if e == nil { - return false - } - return e.Codeql -} - -// GetCopilotCodeReview returns the CopilotCodeReview field. -func (e *EnabledTools) GetCopilotCodeReview() bool { - if e == nil { - return false - } - return e.CopilotCodeReview -} - -// GetDependencyVulnerabilityChecks returns the DependencyVulnerabilityChecks field. -func (e *EnabledTools) GetDependencyVulnerabilityChecks() bool { - if e == nil { - return false - } - return e.DependencyVulnerabilityChecks -} - -// GetSecretScanning returns the SecretScanning field. -func (e *EnabledTools) GetSecretScanning() bool { - if e == nil { - return false - } - return e.SecretScanning -} - // GetEncryptedValue returns the EncryptedValue field. func (e *EncryptedSecret) GetEncryptedValue() string { if e == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 69f5cfff6c0..0128b90436d 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -10576,6 +10576,38 @@ func TestCopilotCloudAgentConfiguration_GetRequireActionsWorkflowApproval(tt *te c.GetRequireActionsWorkflowApproval() } +func TestCopilotCloudAgentEnabledTools_GetCodeql(tt *testing.T) { + tt.Parallel() + c := &CopilotCloudAgentEnabledTools{} + c.GetCodeql() + c = nil + c.GetCodeql() +} + +func TestCopilotCloudAgentEnabledTools_GetCopilotCodeReview(tt *testing.T) { + tt.Parallel() + c := &CopilotCloudAgentEnabledTools{} + c.GetCopilotCodeReview() + c = nil + c.GetCopilotCodeReview() +} + +func TestCopilotCloudAgentEnabledTools_GetDependencyVulnerabilityChecks(tt *testing.T) { + tt.Parallel() + c := &CopilotCloudAgentEnabledTools{} + c.GetDependencyVulnerabilityChecks() + c = nil + c.GetDependencyVulnerabilityChecks() +} + +func TestCopilotCloudAgentEnabledTools_GetSecretScanning(tt *testing.T) { + tt.Parallel() + c := &CopilotCloudAgentEnabledTools{} + c.GetSecretScanning() + c = nil + c.GetSecretScanning() +} + func TestCopilotCodeReviewBranchRule_GetParameters(tt *testing.T) { tt.Parallel() c := &CopilotCodeReviewBranchRule{} @@ -17884,38 +17916,6 @@ func TestEditTopics_GetFrom(tt *testing.T) { e.GetFrom() } -func TestEnabledTools_GetCodeql(tt *testing.T) { - tt.Parallel() - e := &EnabledTools{} - e.GetCodeql() - e = nil - e.GetCodeql() -} - -func TestEnabledTools_GetCopilotCodeReview(tt *testing.T) { - tt.Parallel() - e := &EnabledTools{} - e.GetCopilotCodeReview() - e = nil - e.GetCopilotCodeReview() -} - -func TestEnabledTools_GetDependencyVulnerabilityChecks(tt *testing.T) { - tt.Parallel() - e := &EnabledTools{} - e.GetDependencyVulnerabilityChecks() - e = nil - e.GetDependencyVulnerabilityChecks() -} - -func TestEnabledTools_GetSecretScanning(tt *testing.T) { - tt.Parallel() - e := &EnabledTools{} - e.GetSecretScanning() - e = nil - e.GetSecretScanning() -} - func TestEncryptedSecret_GetEncryptedValue(tt *testing.T) { tt.Parallel() e := &EncryptedSecret{}