| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package coordinatorTest | 5 package coordinatorTest |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "fmt" | 8 "fmt" |
| 9 | 9 |
| 10 "github.com/golang/protobuf/proto" | 10 "github.com/golang/protobuf/proto" |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 e.Clock = clock.Get(c).(testclock.TestClock) | 176 e.Clock = clock.Get(c).(testclock.TestClock) |
| 177 | 177 |
| 178 // Install GAE config service settings. | 178 // Install GAE config service settings. |
| 179 c = settings.Use(c, settings.New(&settings.MemoryStorage{})) | 179 c = settings.Use(c, settings.New(&settings.MemoryStorage{})) |
| 180 | 180 |
| 181 // Setup luci-config configuration. | 181 // Setup luci-config configuration. |
| 182 c = memory.Use(c, e.Config) | 182 c = memory.Use(c, e.Config) |
| 183 e.ConfigIface = luciConfig.Get(c) | 183 e.ConfigIface = luciConfig.Get(c) |
| 184 | 184 |
| 185 // luci-config: Projects. | 185 // luci-config: Projects. |
| 186 » addProjectConfig := func(name luciConfig.ProjectName, localName string,
access ...string) { | 186 » addProjectConfig := func(proj luciConfig.ProjectName, localName string,
access ...string) { |
| 187 » » configSet, configPath := config.ProjectConfigPath(c, proj) |
| 188 |
| 187 var cfg configProto.ProjectCfg | 189 var cfg configProto.ProjectCfg |
| 188 » » e.modTextProtobuf(fmt.Sprintf("projects/%s", name), "project.cfg
", &cfg, func() { | 190 » » e.modTextProtobuf(configSet, configPath, &cfg, func() { |
| 189 cfg.Name = &localName | 191 cfg.Name = &localName |
| 190 cfg.Access = access | 192 cfg.Access = access |
| 191 }) | 193 }) |
| 192 } | 194 } |
| 193 addProjectConfig("proj-foo", "Foo Project", "group:all") | 195 addProjectConfig("proj-foo", "Foo Project", "group:all") |
| 194 addProjectConfig("proj-bar", "Bar Project", "group:all") | 196 addProjectConfig("proj-bar", "Bar Project", "group:all") |
| 195 addProjectConfig("proj-baz", "Baz Project", "group:all") | 197 addProjectConfig("proj-baz", "Baz Project", "group:all") |
| 196 addProjectConfig("proj-qux", "Qux Project", "group:all") | 198 addProjectConfig("proj-qux", "Qux Project", "group:all") |
| 197 addProjectConfig("proj-exclusive", "Exclusive Project", "group:auth") | 199 addProjectConfig("proj-exclusive", "Exclusive Project", "group:auth") |
| 198 | 200 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 } | 237 } |
| 236 | 238 |
| 237 // WithProjectNamespace runs f in proj's namespace, bypassing authentication | 239 // WithProjectNamespace runs f in proj's namespace, bypassing authentication |
| 238 // checks. | 240 // checks. |
| 239 func WithProjectNamespace(c context.Context, proj luciConfig.ProjectName, f func
(context.Context)) { | 241 func WithProjectNamespace(c context.Context, proj luciConfig.ProjectName, f func
(context.Context)) { |
| 240 if err := coordinator.WithProjectNamespaceNoAuth(&c, proj); err != nil { | 242 if err := coordinator.WithProjectNamespaceNoAuth(&c, proj); err != nil { |
| 241 panic(err) | 243 panic(err) |
| 242 } | 244 } |
| 243 f(c) | 245 f(c) |
| 244 } | 246 } |
| OLD | NEW |