| 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 services | 5 package services |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "testing" | 8 "testing" |
| 9 | 9 |
| 10 "github.com/luci/gae/impl/memory" | 10 "github.com/luci/gae/impl/memory" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 . "github.com/smartystreets/goconvey/convey" | 21 . "github.com/smartystreets/goconvey/convey" |
| 22 ) | 22 ) |
| 23 | 23 |
| 24 func TestGetConfig(t *testing.T) { | 24 func TestGetConfig(t *testing.T) { |
| 25 t.Parallel() | 25 t.Parallel() |
| 26 | 26 |
| 27 Convey(`With a testing configuration`, t, func() { | 27 Convey(`With a testing configuration`, t, func() { |
| 28 c := memory.Use(context.Background()) | 28 c := memory.Use(context.Background()) |
| 29 c = settings.Use(c, settings.New(&gaesettings.Storage{})) | 29 c = settings.Use(c, settings.New(&gaesettings.Storage{})) |
| 30 | 30 |
| 31 fs := authtest.FakeState{} |
| 32 c = auth.WithState(c, &fs) |
| 33 |
| 31 svcStub := ct.Services{} | 34 svcStub := ct.Services{} |
| 32 svcStub.InitConfig() | 35 svcStub.InitConfig() |
| 33 svcStub.ServiceConfig.Coordinator.ServiceAuthGroup = "test-servi
ces" | 36 svcStub.ServiceConfig.Coordinator.ServiceAuthGroup = "test-servi
ces" |
| 34 c = coordinator.WithServices(c, &svcStub) | 37 c = coordinator.WithServices(c, &svcStub) |
| 35 | 38 |
| 36 svr := New() | 39 svr := New() |
| 37 | 40 |
| 38 fs := authtest.FakeState{} | |
| 39 c = auth.WithState(c, &fs) | |
| 40 | |
| 41 Convey(`Returns Forbidden error if not a service.`, func() { | 41 Convey(`Returns Forbidden error if not a service.`, func() { |
| 42 _, err := svr.GetConfig(c, nil) | 42 _, err := svr.GetConfig(c, nil) |
| 43 So(err, ShouldBeRPCPermissionDenied) | 43 So(err, ShouldBeRPCPermissionDenied) |
| 44 }) | 44 }) |
| 45 | 45 |
| 46 Convey(`When logged in as a service, can retrieve the configurat
ion.`, func() { | 46 Convey(`When logged in as a service, can retrieve the configurat
ion.`, func() { |
| 47 fs.IdentityGroups = []string{"test-services"} | 47 fs.IdentityGroups = []string{"test-services"} |
| 48 | 48 |
| 49 cr, err := svr.GetConfig(c, nil) | 49 cr, err := svr.GetConfig(c, nil) |
| 50 So(err, ShouldBeRPCOK) | 50 So(err, ShouldBeRPCOK) |
| 51 So(cr, ShouldResemble, &logdog.GetConfigResponse{ | 51 So(cr, ShouldResemble, &logdog.GetConfigResponse{ |
| 52 ConfigServiceUrl: svcStub.GlobalConfig.ConfigSer
viceURL, | 52 ConfigServiceUrl: svcStub.GlobalConfig.ConfigSer
viceURL, |
| 53 ConfigSet: svcStub.GlobalConfig.ConfigSet
, | 53 ConfigSet: svcStub.GlobalConfig.ConfigSet
, |
| 54 ConfigPath: svcStub.GlobalConfig.ConfigPat
h, | 54 ConfigPath: svcStub.GlobalConfig.ConfigPat
h, |
| 55 }) | 55 }) |
| 56 }) | 56 }) |
| 57 }) | 57 }) |
| 58 } | 58 } |
| OLD | NEW |