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

Side by Side Diff: milo/buildsource/buildbot/build_test.go

Issue 2977863002: [milo] Refactor all html knowledge out of backends. (Closed)
Patch Set: now with case insensitivity Created 3 years, 5 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/buildsource/buildbot/build.go ('k') | milo/buildsource/buildbot/builder.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The LUCI Authors. 1 // Copyright 2016 The LUCI Authors.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with 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 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and 12 // See the License for the specific language governing permissions and
13 // limitations under the License. 13 // limitations under the License.
14 14
15 package buildbot 15 package buildbot
16 16
17 import ( 17 import (
18 "encoding/json" 18 "encoding/json"
19 "flag" 19 "flag"
20 "fmt" 20 "fmt"
21 "io/ioutil" 21 "io/ioutil"
22 "path" 22 "path"
23 "strings" 23 "strings"
24 "testing" 24 "testing"
25 25
26 "golang.org/x/net/context"
27
28 . "github.com/smartystreets/goconvey/convey"
29
26 "github.com/luci/gae/impl/memory" 30 "github.com/luci/gae/impl/memory"
27 ds "github.com/luci/gae/service/datastore" 31 ds "github.com/luci/gae/service/datastore"
32
28 "github.com/luci/luci-go/common/clock/testclock" 33 "github.com/luci/luci-go/common/clock/testclock"
29 memcfg "github.com/luci/luci-go/common/config/impl/memory" 34 memcfg "github.com/luci/luci-go/common/config/impl/memory"
30 "github.com/luci/luci-go/luci_config/server/cfgclient/backend/testconfig " 35 "github.com/luci/luci-go/luci_config/server/cfgclient/backend/testconfig "
31 "github.com/luci/luci-go/server/auth" 36 "github.com/luci/luci-go/server/auth"
32 "github.com/luci/luci-go/server/auth/authtest" 37 "github.com/luci/luci-go/server/auth/authtest"
33 "github.com/luci/luci-go/server/auth/identity" 38 "github.com/luci/luci-go/server/auth/identity"
34 39
35 » "golang.org/x/net/context" 40 » "github.com/luci/luci-go/milo/common"
36
37 » . "github.com/smartystreets/goconvey/convey"
38 ) 41 )
39 42
40 var generate = flag.Bool("test.generate", false, "Generate expectations instead of running tests.") 43 var generate = flag.Bool("test.generate", false, "Generate expectations instead of running tests.")
41 44
42 func load(name string) ([]byte, error) { 45 func load(name string) ([]byte, error) {
43 filename := strings.Join([]string{"expectations", name}, "/") 46 filename := strings.Join([]string{"expectations", name}, "/")
44 return ioutil.ReadFile(filename) 47 return ioutil.ReadFile(filename)
45 } 48 }
46 49
47 func shouldMatchExpectationsFor(actualContents interface{}, expectedFilename ... interface{}) string { 50 func shouldMatchExpectationsFor(actualContents interface{}, expectedFilename ... interface{}) string {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 } 99 }
97 100
98 Convey(`Disallow anonomyous users from accessing internal builds `, func() { 101 Convey(`Disallow anonomyous users from accessing internal builds `, func() {
99 ds.Put(c, &buildbotBuild{ 102 ds.Put(c, &buildbotBuild{
100 Master: "fake", 103 Master: "fake",
101 Buildername: "fake", 104 Buildername: "fake",
102 Number: 1, 105 Number: 1,
103 Internal: true, 106 Internal: true,
104 }) 107 })
105 _, err := getBuild(c, "fake", "fake", 1) 108 _, err := getBuild(c, "fake", "fake", 1)
106 » » » So(err, ShouldResemble, errNotAuth) 109 » » » So(common.ErrorTag.In(err), ShouldEqual, common.CodeUnau thorized)
107 }) 110 })
108 }) 111 })
109 } 112 }
110 113
111 var internalConfig = ` 114 var internalConfig = `
112 buildbot: { 115 buildbot: {
113 internal_reader: "googlers" 116 internal_reader: "googlers"
114 public_subscription: "projects/luci-milo/subscriptions/buildbot-public" 117 public_subscription: "projects/luci-milo/subscriptions/buildbot-public"
115 internal_subscription: "projects/luci-milo/subscriptions/buildbot-privat e" 118 internal_subscription: "projects/luci-milo/subscriptions/buildbot-privat e"
116 } 119 }
117 ` 120 `
118 121
119 var bbAclConfigs = map[string]memcfg.ConfigSet{ 122 var bbAclConfigs = map[string]memcfg.ConfigSet{
120 "services/luci-milo": { 123 "services/luci-milo": {
121 "settings.cfg": internalConfig, 124 "settings.cfg": internalConfig,
122 }, 125 },
123 } 126 }
OLDNEW
« no previous file with comments | « milo/buildsource/buildbot/build.go ('k') | milo/buildsource/buildbot/builder.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698