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

Side by Side Diff: milo/appengine/settings/acl_test.go

Issue 2241853002: Milo: ACL support (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@lucicfg
Patch Set: rebase Created 4 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
« no previous file with comments | « milo/appengine/settings/acl.go ('k') | milo/common/miloerror/error.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file.
4
5 package settings
6
7 import (
8 "testing"
9
10 "github.com/luci/gae/impl/memory"
11 lucicfg "github.com/luci/luci-go/common/config"
12 memcfg "github.com/luci/luci-go/common/config/impl/memory"
13 "github.com/luci/luci-go/common/logging/gologger"
14 "github.com/luci/luci-go/server/auth"
15 "github.com/luci/luci-go/server/auth/authtest"
16 "github.com/luci/luci-go/server/auth/identity"
17 "golang.org/x/net/context"
18
19 . "github.com/smartystreets/goconvey/convey"
20 )
21
22 func TestACL(t *testing.T) {
23 t.Parallel()
24
25 Convey("Test Environment", t, func() {
26 c := memory.UseWithAppID(context.Background(), "dev~luci-milo")
27 c = gologger.StdConfig.Use(c)
28
29 Convey("Set up projects", func() {
30 c = lucicfg.SetImplementation(c, memcfg.New(aclConfgs))
31 err := update(c)
32 So(err, ShouldBeNil)
33
34 Convey("Anon wants to...", func() {
35 c = auth.WithState(c, &authtest.FakeState{
36 Identity: identity.AnonymousIdenti ty,
37 IdentityGroups: []string{"all"},
38 })
39 Convey("Read public project", func() {
40 ok, err := IsAllowed(c, "opensource")
41 So(ok, ShouldEqual, true)
42 So(err, ShouldBeNil)
43 })
44 Convey("Read private project", func() {
45 ok, err := IsAllowed(c, "secret")
46 So(ok, ShouldEqual, false)
47 So(err, ShouldBeNil)
48 })
49
50 })
51 Convey("alicebob@google.com wants to...", func() {
52 c = auth.WithState(c, &authtest.FakeState{
53 Identity: "user:alicebob@google.co m",
54 IdentityGroups: []string{"google.com", " all"},
55 })
56 Convey("Read private project", func() {
57 ok, err := IsAllowed(c, "secret")
58 So(ok, ShouldEqual, true)
59 So(err, ShouldBeNil)
60 })
61 })
62
63 Convey("eve@notgoogle.com wants to...", func() {
64 c = auth.WithState(c, &authtest.FakeState{
65 Identity: "user:eve@notgoogle.com" ,
66 IdentityGroups: []string{"all"},
67 })
68 Convey("Read public project", func() {
69 ok, err := IsAllowed(c, "opensource")
70 So(ok, ShouldEqual, true)
71 So(err, ShouldBeNil)
72 })
73 Convey("Read private project", func() {
74 ok, err := IsAllowed(c, "secret")
75 So(ok, ShouldEqual, false)
76 So(err, ShouldBeNil)
77 })
78 })
79 })
80 })
81 }
82
83 var secretProjectCfg = `
84 ID: "secret"
85 Readers: "google.com"
86 `
87
88 var publicProjectCfg = `
89 ID: "opensource"
90 Readers: "all"
91 `
92
93 var aclConfgs = map[string]memcfg.ConfigSet{
94 "projects/secret.git": {
95 "luci-milo.cfg": secretProjectCfg,
96 },
97 "projects/opensource.git": {
98 "luci-milo.cfg": publicProjectCfg,
99 },
100 }
OLDNEW
« no previous file with comments | « milo/appengine/settings/acl.go ('k') | milo/common/miloerror/error.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698