Skip to content

feat: add auto group create from OIDC #8884

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

Merged
merged 22 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add test for regexp
  • Loading branch information
Emyrk committed Aug 3, 2023
commit f8ea15db394316b7d64d74bb232ce0af4cc1b0c4
34 changes: 34 additions & 0 deletions cli/clibase/option_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,40 @@ func TestOptionSet_ParseFlags(t *testing.T) {
err := os.FlagSet().Parse([]string{"--some-unknown", "foo"})
require.Error(t, err)
})

t.Run("RegexValid", func(t *testing.T) {
t.Parallel()

var regexpString clibase.Regexp

os := clibase.OptionSet{
clibase.Option{
Name: "RegexpString",
Value: &regexpString,
Flag: "regexp-string",
},
}

err := os.FlagSet().Parse([]string{"--regexp-string", "$test^"})
require.NoError(t, err)
})

t.Run("RegexInvalid", func(t *testing.T) {
t.Parallel()

var regexpString clibase.Regexp

os := clibase.OptionSet{
clibase.Option{
Name: "RegexpString",
Value: &regexpString,
Flag: "regexp-string",
},
}

err := os.FlagSet().Parse([]string{"--regexp-string", "(("})
require.Error(t, err)
})
}

func TestOptionSet_ParseEnv(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion cli/clibase/values.go
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ func RegexpOf(s *regexp.Regexp) *Regexp {
func (s *Regexp) Set(v string) error {
exp, err := regexp.Compile(v)
if err != nil {
return xerrors.Errorf("invalid regexp %q: %w", v, err)
return xerrors.Errorf("invalid regex expression: %w", v, err)
}
*s = Regexp(*exp)
return nil
Expand Down
2 changes: 1 addition & 1 deletion codersdk/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -1082,7 +1082,7 @@ when required by your organization's security policy.`,
Description: "If provided any group name not matching the regex is ignored. This allows for filtering out groups that are not needed. This filter is applied after the group mapping.",
Flag: "oidc-group-regex-filter",
Env: "CODER_OIDC_GROUP_REGEX_FILTER",
Default: "",
Default: "*",
Value: &c.OIDC.GroupRegexFilter,
Group: &deploymentGroupOIDC,
YAML: "groupRegexFilter",
Expand Down