Loading settings.go +108 −4 File changed.Preview size limit exceeded, changes collapsed. Show changes settings_test.go +152 −0 Changes for settings_test.go: 152 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -304,6 +304,158 @@ func TestGetSettings_SecretPushProtectionAvailable(t *testing.T) { assert.True(t, settings.SecretPushProtectionAvailable) } func TestSettings_RateLimits(t *testing.T) { t.Parallel() mux, client := setup(t) body := `{ "id": 1, "ai_action_api_rate_limit": 160, "audit_events_api_limit": 10, "autocomplete_users_limit": 300, "autocomplete_users_unauthenticated_limit": 100, "group_audit_events_api_limit": 10, "project_audit_events_api_limit": 10, "virtual_registries_endpoints_api_limit": 1000, "job_play_limit_per_user_project": 300, "job_retry_limit_per_user_project": 300, "pipeline_cancel_limit_per_user_project": 300, "pipeline_retry_limit_per_user_project": 300, "throttle_authenticated_mcp_enabled": true, "throttle_authenticated_mcp_period_in_seconds": 60, "throttle_authenticated_mcp_requests_per_period": 3000, "ci_lint_limit_per_user": 400, "concurrent_pull_request_import_jobs_limit": 500, "concurrent_relation_batch_export_limit": 25, "concurrent_relation_export_limit": 8192, "git_push_pipeline_limit": 4, "group_secrets_limit": 20000, "import_jobs_concurrency_limit": 100, "max_github_response_size_limit": 8, "max_http_response_size_limit": 100, "pipeline_limit_per_user": 25, "project_secrets_limit": 20000, "raw_blob_request_limit_unauthenticated": 300, "runner_jobs_endpoints_api_limit": 600, "runner_jobs_patch_trace_api_limit": 300, "runner_jobs_request_api_limit": 600, "scan_execution_policies_action_limit": 10, "scan_execution_policies_schedule_limit": 5, "tags_create_limit": 5, "throttle_authenticated_dependency_proxy_enabled": true, "throttle_authenticated_dependency_proxy_period_in_seconds": 60, "throttle_authenticated_dependency_proxy_requests_per_period": 3000, "throttle_authenticated_git_http_enabled": true, "throttle_authenticated_git_http_period_in_seconds": 60, "throttle_authenticated_git_http_requests_per_period": 3600, "throttle_unauthenticated_git_http_enabled": true, "throttle_unauthenticated_git_http_period_in_seconds": 60, "throttle_unauthenticated_git_http_requests_per_period": 3600, "users_api_limit_followers": 100, "users_api_limit_following": 100, "users_api_limit_gpg_key": 120, "users_api_limit_gpg_keys": 120, "users_api_limit_ssh_key": 120, "users_api_limit_ssh_keys": 120, "users_api_limit_status": 240, "web_hook_event_resend_limit": 5, "web_hook_test_limit": 5 }` mux.HandleFunc("/api/v4/application/settings", func(w http.ResponseWriter, r *http.Request) { switch r.Method { case http.MethodGet: case http.MethodPut: testBodyJSON(t, r, map[string]any{ "concurrent_relation_export_limit": float64(8192), "job_play_limit_per_user_project": float64(300), "job_retry_limit_per_user_project": float64(300), "pipeline_retry_limit_per_user_project": float64(300), "throttle_authenticated_git_http_enabled": true, "throttle_authenticated_git_http_period_in_seconds": float64(60), "throttle_authenticated_git_http_requests_per_period": float64(3600), "users_api_limit_following": float64(100), "web_hook_test_limit": float64(5), }) default: assert.Failf(t, "unexpected method", "got %s", r.Method) } fmt.Fprint(w, body) }) want := &Settings{ ID: 1, AIActionAPIRateLimit: 160, AuditEventsAPILimit: 10, AutocompleteUsersLimit: 300, AutocompleteUsersUnauthenticatedLimit: 100, GroupAuditEventsAPILimit: 10, ProjectAuditEventsAPILimit: 10, VirtualRegistriesEndpointsAPILimit: 1000, JobPlayLimitPerUserProject: 300, JobRetryLimitPerUserProject: 300, PipelineCancelLimitPerUserProject: 300, PipelineRetryLimitPerUserProject: 300, ThrottleAuthenticatedMCPEnabled: true, ThrottleAuthenticatedMCPPeriodInSeconds: 60, ThrottleAuthenticatedMCPRequestsPerPeriod: 3000, CILintLimitPerUser: 400, ConcurrentPullRequestImportJobsLimit: 500, ConcurrentRelationBatchExportLimit: 25, ConcurrentRelationExportLimit: 8192, GitPushPipelineLimit: 4, GroupSecretsLimit: 20000, ImportJobsConcurrencyLimit: 100, MaxGitHubResponseSizeLimit: 8, MaxHTTPResponseSizeLimit: 100, PipelineLimitPerUser: 25, ProjectSecretsLimit: 20000, RawBlobRequestLimitUnauthenticated: 300, RunnerJobsEndpointsAPILimit: 600, RunnerJobsPatchTraceAPILimit: 300, RunnerJobsRequestAPILimit: 600, ScanExecutionPoliciesActionLimit: 10, ScanExecutionPoliciesScheduleLimit: 5, TagsCreateLimit: 5, ThrottleAuthenticatedDependencyProxyEnabled: true, ThrottleAuthenticatedDependencyProxyPeriodInSeconds: 60, ThrottleAuthenticatedDependencyProxyRequestsPerPeriod: 3000, ThrottleAuthenticatedGitHTTPEnabled: true, ThrottleAuthenticatedGitHTTPPeriodInSeconds: 60, ThrottleAuthenticatedGitHTTPRequestsPerPeriod: 3600, ThrottleUnauthenticatedGitHTTPEnabled: true, ThrottleUnauthenticatedGitHTTPPeriodInSeconds: 60, ThrottleUnauthenticatedGitHTTPRequestsPerPeriod: 3600, UsersAPILimitFollowers: 100, UsersAPILimitFollowing: 100, UsersAPILimitGPGKey: 120, UsersAPILimitGPGKeys: 120, UsersAPILimitSSHKey: 120, UsersAPILimitSSHKeys: 120, UsersAPILimitStatus: 240, WebHookEventResendLimit: 5, WebHookTestLimit: 5, } settings, _, err := client.Settings.GetSettings() require.NoError(t, err) assert.Equal(t, want, settings) updated, _, err := client.Settings.UpdateSettings(&UpdateSettingsOptions{ ConcurrentRelationExportLimit: new(int64(8192)), JobPlayLimitPerUserProject: new(int64(300)), JobRetryLimitPerUserProject: new(int64(300)), PipelineRetryLimitPerUserProject: new(int64(300)), ThrottleAuthenticatedGitHTTPEnabled: new(true), ThrottleAuthenticatedGitHTTPPeriodInSeconds: new(int64(60)), ThrottleAuthenticatedGitHTTPRequestsPerPeriod: new(int64(3600)), UsersAPILimitFollowing: new(int64(100)), WebHookTestLimit: new(int64(5)), }) require.NoError(t, err) assert.Equal(t, want, updated) } func TestGetSettings_PreventMergeRequestsApproval(t *testing.T) { t.Parallel() mux, client := setup(t) Loading Loading
settings_test.go +152 −0 Changes for settings_test.go: 152 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -304,6 +304,158 @@ func TestGetSettings_SecretPushProtectionAvailable(t *testing.T) { assert.True(t, settings.SecretPushProtectionAvailable) } func TestSettings_RateLimits(t *testing.T) { t.Parallel() mux, client := setup(t) body := `{ "id": 1, "ai_action_api_rate_limit": 160, "audit_events_api_limit": 10, "autocomplete_users_limit": 300, "autocomplete_users_unauthenticated_limit": 100, "group_audit_events_api_limit": 10, "project_audit_events_api_limit": 10, "virtual_registries_endpoints_api_limit": 1000, "job_play_limit_per_user_project": 300, "job_retry_limit_per_user_project": 300, "pipeline_cancel_limit_per_user_project": 300, "pipeline_retry_limit_per_user_project": 300, "throttle_authenticated_mcp_enabled": true, "throttle_authenticated_mcp_period_in_seconds": 60, "throttle_authenticated_mcp_requests_per_period": 3000, "ci_lint_limit_per_user": 400, "concurrent_pull_request_import_jobs_limit": 500, "concurrent_relation_batch_export_limit": 25, "concurrent_relation_export_limit": 8192, "git_push_pipeline_limit": 4, "group_secrets_limit": 20000, "import_jobs_concurrency_limit": 100, "max_github_response_size_limit": 8, "max_http_response_size_limit": 100, "pipeline_limit_per_user": 25, "project_secrets_limit": 20000, "raw_blob_request_limit_unauthenticated": 300, "runner_jobs_endpoints_api_limit": 600, "runner_jobs_patch_trace_api_limit": 300, "runner_jobs_request_api_limit": 600, "scan_execution_policies_action_limit": 10, "scan_execution_policies_schedule_limit": 5, "tags_create_limit": 5, "throttle_authenticated_dependency_proxy_enabled": true, "throttle_authenticated_dependency_proxy_period_in_seconds": 60, "throttle_authenticated_dependency_proxy_requests_per_period": 3000, "throttle_authenticated_git_http_enabled": true, "throttle_authenticated_git_http_period_in_seconds": 60, "throttle_authenticated_git_http_requests_per_period": 3600, "throttle_unauthenticated_git_http_enabled": true, "throttle_unauthenticated_git_http_period_in_seconds": 60, "throttle_unauthenticated_git_http_requests_per_period": 3600, "users_api_limit_followers": 100, "users_api_limit_following": 100, "users_api_limit_gpg_key": 120, "users_api_limit_gpg_keys": 120, "users_api_limit_ssh_key": 120, "users_api_limit_ssh_keys": 120, "users_api_limit_status": 240, "web_hook_event_resend_limit": 5, "web_hook_test_limit": 5 }` mux.HandleFunc("/api/v4/application/settings", func(w http.ResponseWriter, r *http.Request) { switch r.Method { case http.MethodGet: case http.MethodPut: testBodyJSON(t, r, map[string]any{ "concurrent_relation_export_limit": float64(8192), "job_play_limit_per_user_project": float64(300), "job_retry_limit_per_user_project": float64(300), "pipeline_retry_limit_per_user_project": float64(300), "throttle_authenticated_git_http_enabled": true, "throttle_authenticated_git_http_period_in_seconds": float64(60), "throttle_authenticated_git_http_requests_per_period": float64(3600), "users_api_limit_following": float64(100), "web_hook_test_limit": float64(5), }) default: assert.Failf(t, "unexpected method", "got %s", r.Method) } fmt.Fprint(w, body) }) want := &Settings{ ID: 1, AIActionAPIRateLimit: 160, AuditEventsAPILimit: 10, AutocompleteUsersLimit: 300, AutocompleteUsersUnauthenticatedLimit: 100, GroupAuditEventsAPILimit: 10, ProjectAuditEventsAPILimit: 10, VirtualRegistriesEndpointsAPILimit: 1000, JobPlayLimitPerUserProject: 300, JobRetryLimitPerUserProject: 300, PipelineCancelLimitPerUserProject: 300, PipelineRetryLimitPerUserProject: 300, ThrottleAuthenticatedMCPEnabled: true, ThrottleAuthenticatedMCPPeriodInSeconds: 60, ThrottleAuthenticatedMCPRequestsPerPeriod: 3000, CILintLimitPerUser: 400, ConcurrentPullRequestImportJobsLimit: 500, ConcurrentRelationBatchExportLimit: 25, ConcurrentRelationExportLimit: 8192, GitPushPipelineLimit: 4, GroupSecretsLimit: 20000, ImportJobsConcurrencyLimit: 100, MaxGitHubResponseSizeLimit: 8, MaxHTTPResponseSizeLimit: 100, PipelineLimitPerUser: 25, ProjectSecretsLimit: 20000, RawBlobRequestLimitUnauthenticated: 300, RunnerJobsEndpointsAPILimit: 600, RunnerJobsPatchTraceAPILimit: 300, RunnerJobsRequestAPILimit: 600, ScanExecutionPoliciesActionLimit: 10, ScanExecutionPoliciesScheduleLimit: 5, TagsCreateLimit: 5, ThrottleAuthenticatedDependencyProxyEnabled: true, ThrottleAuthenticatedDependencyProxyPeriodInSeconds: 60, ThrottleAuthenticatedDependencyProxyRequestsPerPeriod: 3000, ThrottleAuthenticatedGitHTTPEnabled: true, ThrottleAuthenticatedGitHTTPPeriodInSeconds: 60, ThrottleAuthenticatedGitHTTPRequestsPerPeriod: 3600, ThrottleUnauthenticatedGitHTTPEnabled: true, ThrottleUnauthenticatedGitHTTPPeriodInSeconds: 60, ThrottleUnauthenticatedGitHTTPRequestsPerPeriod: 3600, UsersAPILimitFollowers: 100, UsersAPILimitFollowing: 100, UsersAPILimitGPGKey: 120, UsersAPILimitGPGKeys: 120, UsersAPILimitSSHKey: 120, UsersAPILimitSSHKeys: 120, UsersAPILimitStatus: 240, WebHookEventResendLimit: 5, WebHookTestLimit: 5, } settings, _, err := client.Settings.GetSettings() require.NoError(t, err) assert.Equal(t, want, settings) updated, _, err := client.Settings.UpdateSettings(&UpdateSettingsOptions{ ConcurrentRelationExportLimit: new(int64(8192)), JobPlayLimitPerUserProject: new(int64(300)), JobRetryLimitPerUserProject: new(int64(300)), PipelineRetryLimitPerUserProject: new(int64(300)), ThrottleAuthenticatedGitHTTPEnabled: new(true), ThrottleAuthenticatedGitHTTPPeriodInSeconds: new(int64(60)), ThrottleAuthenticatedGitHTTPRequestsPerPeriod: new(int64(3600)), UsersAPILimitFollowing: new(int64(100)), WebHookTestLimit: new(int64(5)), }) require.NoError(t, err) assert.Equal(t, want, updated) } func TestGetSettings_PreventMergeRequestsApproval(t *testing.T) { t.Parallel() mux, client := setup(t) Loading