[auth-proxy] Move to space seperated --role flags.
Commas interfere with MultiString.
Bug: b/249507110
Change-Id: I48922b936e43333a91aa24c5f2fafcbf8b73c4ba
Reviewed-on: https://skia-review.googlesource.com/c/buildbot/+/587076
Reviewed-by: Ravi Mistry <rmistry@google.com>
Commit-Queue: Joe Gregorio <jcgregorio@google.com>
diff --git a/kube/go/authproxy/authproxy.go b/kube/go/authproxy/authproxy.go
index 63cc29f..5fa9733 100644
--- a/kube/go/authproxy/authproxy.go
+++ b/kube/go/authproxy/authproxy.go
@@ -238,7 +238,7 @@
return skerr.Fmt("Failed parsing --role flag: %q : %s", roleFlag, err)
}
} else {
- allow = allowed.NewAllowedFromList(strings.Split(allowedRuleAsString, ","))
+ allow = allowed.NewAllowedFromList(strings.Split(allowedRuleAsString, " "))
}
if existing, ok := a.allowedRoles[rolename]; ok {
a.allowedRoles[rolename] = allowed.UnionOf(existing, allow)
diff --git a/kube/go/authproxy/authproxy_test.go b/kube/go/authproxy/authproxy_test.go
index 4a68299..e456a34 100644
--- a/kube/go/authproxy/authproxy_test.go
+++ b/kube/go/authproxy/authproxy_test.go
@@ -363,3 +363,27 @@
err := a.populateAllowedRoles(m)
require.Contains(t, err.Error(), "Invalid format")
}
+
+func TestAppPopulateAllowedRoles_CommaSeparatedRoles_RoleContainsUnionOfAllows(t *testing.T) {
+ m := mockCriaClient(t)
+ a := newEmptyApp()
+ a.roleFlags = []string{
+ "viewer=google.com chromium.org",
+ }
+
+ err := a.populateAllowedRoles(m)
+ require.NoError(t, err)
+ require.True(t, a.allowedRoles[roles.Viewer].Member("fred@chromium.org"))
+ require.True(t, a.allowedRoles[roles.Viewer].Member("barney@google.com"))
+}
+
+func TestAppPopulateAllowedRoles_TestMultiFlagParsing(t *testing.T) {
+ a := newEmptyApp()
+ err := a.Flagset().Parse([]string{"--role=viewer=google.com chromium.org", "--role=editor=google.com chromium.org"})
+ require.NoError(t, err)
+ expected := []string{
+ "viewer=google.com chromium.org",
+ "editor=google.com chromium.org",
+ }
+ require.Equal(t, expected, a.roleFlags)
+}