| Index: appengine/logdog/coordinator/coordinatorTest/context.go
|
| diff --git a/appengine/logdog/coordinator/coordinatorTest/context.go b/appengine/logdog/coordinator/coordinatorTest/context.go
|
| index 90dec0ae85c8aa70647e0be7e597636a7eb6e75d..2621a1dceeb55afdfe3901c363398ab269f7732d 100644
|
| --- a/appengine/logdog/coordinator/coordinatorTest/context.go
|
| +++ b/appengine/logdog/coordinator/coordinatorTest/context.go
|
| @@ -6,9 +6,11 @@ package coordinatorTest
|
|
|
| import (
|
| "fmt"
|
| + "strings"
|
|
|
| "github.com/golang/protobuf/proto"
|
| ds "github.com/luci/gae/service/datastore"
|
| + "github.com/luci/gae/service/info"
|
| "github.com/luci/luci-go/appengine/logdog/coordinator"
|
| "github.com/luci/luci-go/appengine/logdog/coordinator/config"
|
| "github.com/luci/luci-go/appengine/tumble"
|
| @@ -66,6 +68,12 @@ func (e *Environment) JoinGroup(g string) {
|
| e.AuthState.IdentityGroups = append(e.AuthState.IdentityGroups, g)
|
| }
|
|
|
| +// LeaveAllGroups clears all auth groups that the user is currently a member of.
|
| +func (e *Environment) LeaveAllGroups() {
|
| + e.AuthState.IdentityGroups = nil
|
| + e.JoinGroup("all")
|
| +}
|
| +
|
| // ClearCoordinatorConfig removes the Coordinator configuration entry,
|
| // simulating a missing config.
|
| func (e *Environment) ClearCoordinatorConfig(c context.Context) {
|
| @@ -75,15 +83,12 @@ func (e *Environment) ClearCoordinatorConfig(c context.Context) {
|
|
|
| // ModServiceConfig loads the current service configuration, invokes the
|
| // callback with its contents, and writes the result back to config.
|
| -func (e *Environment) ModServiceConfig(c context.Context, fn func(*svcconfig.Coordinator)) {
|
| +func (e *Environment) ModServiceConfig(c context.Context, fn func(*svcconfig.Config)) {
|
| configSet, configPath := config.ServiceConfigPath(c)
|
|
|
| var cfg svcconfig.Config
|
| e.modTextProtobuf(configSet, configPath, &cfg, func() {
|
| - if cfg.Coordinator == nil {
|
| - cfg.Coordinator = &svcconfig.Coordinator{}
|
| - }
|
| - fn(cfg.Coordinator)
|
| + fn(&cfg)
|
| })
|
| }
|
|
|
| @@ -196,22 +201,46 @@ func Install() (context.Context, *Environment) {
|
| e.ConfigIface = luciConfig.Get(c)
|
|
|
| // luci-config: Projects.
|
| + projectName := info.Get(c).AppID()
|
| addProjectConfig := func(proj luciConfig.ProjectName, access ...string) {
|
| e.ModProjectConfig(proj, func(pcfg *svcconfig.ProjectConfig) {
|
| - pcfg.ReaderAuthGroups = access
|
| + for _, a := range access {
|
| + parts := strings.SplitN(a, ":", 2)
|
| + group, field := parts[0], &pcfg.ReaderAuthGroups
|
| + if len(parts) == 2 {
|
| + switch parts[1] {
|
| + case "R":
|
| + break
|
| + case "W":
|
| + field = &pcfg.WriterAuthGroups
|
| + default:
|
| + panic(a)
|
| + }
|
| + }
|
| + *field = append(*field, group)
|
| + }
|
| })
|
| }
|
| - addProjectConfig("proj-foo", "all")
|
| - addProjectConfig("proj-bar", "all")
|
| - addProjectConfig("proj-exclusive", "auth")
|
| + addProjectConfig("proj-foo", "all:R", "all:W")
|
| + addProjectConfig("proj-bar", "all:R", "auth:W")
|
| + addProjectConfig("proj-exclusive", "auth:R", "auth:W")
|
|
|
| // Add a project without a LogDog project config.
|
| e.addConfigEntry("projects/proj-unconfigured", "not-logdog.cfg", "junk")
|
| e.addConfigEntry("projects/proj-malformed", svcconfig.ProjectConfigFilename, "!!! not a text protobuf !!!")
|
|
|
| // luci-config: Coordinator Defaults
|
| - e.ModServiceConfig(c, func(cfg *svcconfig.Coordinator) {
|
| - *cfg = svcconfig.Coordinator{
|
| + e.ModServiceConfig(c, func(cfg *svcconfig.Config) {
|
| + cfg.Transport = &svcconfig.Transport{
|
| + Type: &svcconfig.Transport_Pubsub{
|
| + Pubsub: &svcconfig.Transport_PubSub{
|
| + Project: projectName,
|
| + Topic: "test-topic",
|
| + },
|
| + },
|
| + }
|
| + cfg.Coordinator = &svcconfig.Coordinator{
|
| + Project: projectName,
|
| AdminAuthGroup: "admin",
|
| ServiceAuthGroup: "services",
|
| }
|
| @@ -228,7 +257,7 @@ func Install() (context.Context, *Environment) {
|
| c = auth.WithState(c, &e.AuthState)
|
|
|
| // Setup authentication state.
|
| - e.JoinGroup("all")
|
| + e.LeaveAllGroups()
|
|
|
| // Setup our default Coordinator services.
|
| e.Services = Services{
|
|
|