Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(139)

Side by Side Diff: tokenserver/appengine/impl/serviceaccounts/config_test.go

Issue 2993023002: tokenserver: Boilerplate for loading and serving service_accounts.cfg. (Closed)
Patch Set: fix comments Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The LUCI Authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 package serviceaccounts
16
17 import (
18 "testing"
19
20 "github.com/golang/protobuf/proto"
21
22 "github.com/luci/luci-go/tokenserver/api/admin/v1"
23 "github.com/luci/luci-go/tokenserver/appengine/impl/utils/policy"
24
25 . "github.com/smartystreets/goconvey/convey"
26 )
27
28 func TestRules(t *testing.T) {
29 t.Parallel()
30
31 Convey("Loads", t, func() {
Vadim Sh. 2017/08/04 02:25:13 there'll be more here eventually
32 cfg, err := loadConfig(`
33 rules {
34 name: "rule 1"
35 owner: "developer@example.com"
36 service_account: "abc@robots.com"
37 allowed_scope: "https://scope"
38 end_user: "user:abc@example.com"
39 end_user: "group:group-name"
40 proxy: "user:proxy@example.com"
41 max_grant_validity_duration: 3600
42 }
43 `)
44 So(err, ShouldBeNil)
45 So(cfg, ShouldNotBeNil)
46 })
47 }
48
49 func loadConfig(text string) (*Rules, error) {
50 cfg := &admin.ServiceAccountsPermissions{}
51 err := proto.UnmarshalText(text, cfg)
52 if err != nil {
53 return nil, err
54 }
55 rules, err := prepareRules(policy.ConfigBundle{serviceAccountsCfg: cfg}, "fake-revision")
56 if err != nil {
57 return nil, err
58 }
59 return rules.(*Rules), nil
60 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698