mirror of
https://github.com/oauth2-proxy/oauth2-proxy.git
synced 2026-10-22 04:32:02 +02:00
feat: make google-groups argument optional (#3138)
add test cases update documentation refactor code and some cleanup update changelog Signed-off-by: Jan Larwig <jan@larwig.com>
This commit is contained in:
@@ -55,18 +55,38 @@ func TestNewOptions(t *testing.T) {
|
||||
assert.Equal(t, expected, err.Error())
|
||||
}
|
||||
|
||||
func TestGoogleGroupOptions(t *testing.T) {
|
||||
func TestGoogleGroupOptionsWithoutServiceAccountJSON(t *testing.T) {
|
||||
o := testOptions()
|
||||
o.Providers[0].GoogleConfig.Groups = []string{"googlegroup"}
|
||||
o.Providers[0].GoogleConfig.AdminEmail = "admin@example.com"
|
||||
err := Validate(o)
|
||||
assert.NotEqual(t, nil, err)
|
||||
|
||||
expected := errorMsg([]string{
|
||||
"missing setting: google-admin-email",
|
||||
"missing setting: google-service-account-json or google-use-application-default-credentials"})
|
||||
assert.Equal(t, expected, err.Error())
|
||||
}
|
||||
|
||||
func TestGoogleGroupOptionsWithoutAdminEmail(t *testing.T) {
|
||||
o := testOptions()
|
||||
o.Providers[0].GoogleConfig.UseApplicationDefaultCredentials = true
|
||||
err := Validate(o)
|
||||
assert.NotEqual(t, nil, err)
|
||||
|
||||
expected := errorMsg([]string{
|
||||
"missing setting: google-admin-email"})
|
||||
assert.Equal(t, expected, err.Error())
|
||||
}
|
||||
|
||||
func TestGoogleGroupOptionsWithoutGroups(t *testing.T) {
|
||||
o := testOptions()
|
||||
// Set admin email and application default credentials but no groups - should still require them
|
||||
o.Providers[0].GoogleConfig.AdminEmail = "admin@example.com"
|
||||
o.Providers[0].GoogleConfig.UseApplicationDefaultCredentials = true
|
||||
err := Validate(o)
|
||||
// Should pass validation since google-group is now optional
|
||||
assert.Equal(t, nil, err)
|
||||
}
|
||||
|
||||
func TestGoogleGroupInvalidFile(t *testing.T) {
|
||||
o := testOptions()
|
||||
o.Providers[0].GoogleConfig.Groups = []string{"test_group"}
|
||||
|
||||
Reference in New Issue
Block a user