-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat: deprecate the oauth2 experiment in favor of CODER_OAUTH2_PROVIDER_ENABLE #29257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: plat-492-2-gate
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| package coderd | ||
|
|
||
| import ( | ||
| "context" | ||
| "sync" | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/require" | ||
|
|
||
| "cdr.dev/slog/v3" | ||
| "github.com/coder/coder/v2/codersdk" | ||
| ) | ||
|
|
||
| // logRecorder keeps every entry so a test can count log lines. | ||
| type logRecorder struct { | ||
| mu sync.Mutex | ||
| entries []slog.SinkEntry | ||
| } | ||
|
|
||
| func (s *logRecorder) LogEntry(_ context.Context, e slog.SinkEntry) { | ||
| s.mu.Lock() | ||
| defer s.mu.Unlock() | ||
| s.entries = append(s.entries, e) | ||
| } | ||
|
|
||
| func (*logRecorder) Sync() {} | ||
|
|
||
| func (s *logRecorder) messages(level slog.Level) []string { | ||
| s.mu.Lock() | ||
| defer s.mu.Unlock() | ||
| var out []string | ||
| for _, e := range s.entries { | ||
| if e.Level == level { | ||
| out = append(out, e.Message) | ||
| } | ||
| } | ||
| return out | ||
| } | ||
|
|
||
| // count returns how many entries at level carry exactly msg. | ||
| func (s *logRecorder) count(level slog.Level, msg string) int { | ||
| var n int | ||
| for _, m := range s.messages(level) { | ||
| if m == msg { | ||
| n++ | ||
| } | ||
| } | ||
| return n | ||
| } | ||
|
|
||
| func TestReadExperimentsDeprecatedOAuth2(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| rec := &logRecorder{} | ||
| log := slog.Make(rec) | ||
| var once sync.Once | ||
| raw := []string{string(codersdk.ExperimentOAuth2), string(codersdk.ExperimentMCPServerHTTP)} | ||
|
|
||
| got := parseExperiments(log, raw, &once) | ||
| require.Equal(t, codersdk.Experiments{codersdk.ExperimentMCPServerHTTP}, got, | ||
| "the oauth2 experiment must be dropped, not passed through") | ||
| require.Equal(t, 1, rec.count(slog.LevelWarn, oauth2ExperimentDeprecatedMessage)) | ||
| require.NotContains(t, rec.messages(slog.LevelWarn), "ignoring unknown experiment", | ||
| "oauth2 must be matched before the unknown-experiment branch") | ||
|
|
||
| // A second read in the same process returns the same values and does not | ||
| // repeat the deprecation warning. Upper-case input is matched too. | ||
| got = parseExperiments(log, []string{"OAuth2", string(codersdk.ExperimentMCPServerHTTP)}, &once) | ||
| require.Equal(t, codersdk.Experiments{codersdk.ExperimentMCPServerHTTP}, got) | ||
| require.Equal(t, 1, rec.count(slog.LevelWarn, oauth2ExperimentDeprecatedMessage), | ||
| "deprecation warning must be logged once per process") | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5192,7 +5192,7 @@ const ( | |
| ExperimentAutoFillParameters Experiment = "auto-fill-parameters" // This should not be taken out of experiments until we have redesigned the feature. | ||
| ExperimentNotifications Experiment = "notifications" // Sends notifications via SMTP and webhooks following certain events. | ||
| ExperimentWorkspaceUsage Experiment = "workspace-usage" // Enables the new workspace usage tracking. | ||
| ExperimentOAuth2 Experiment = "oauth2" // Enables OAuth2 provider functionality. | ||
| ExperimentOAuth2 Experiment = "oauth2" // Deprecated: has no effect; use CODER_OAUTH2_PROVIDER_ENABLE. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not just delete it? |
||
| ExperimentMCPServerHTTP Experiment = "mcp-server-http" // Enables the MCP HTTP server functionality. | ||
| ExperimentMCPToolSearch Experiment = "mcp-tool-search" // Defers MCP tool schemas behind a searchable catalog in agent chats. | ||
| ExperimentWorkspaceBuildUpdates Experiment = "workspace-build-updates" // Enables publishing workspace build updates to the all builds pubsub channel. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.