| OLD | NEW |
| 1 // Copyright 2016 The LUCI Authors. All rights reserved. | 1 // Copyright 2016 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
| 4 | 4 |
| 5 package buildbot | 5 package buildbot |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "encoding/json" | 8 "encoding/json" |
| 9 "flag" | 9 "flag" |
| 10 "fmt" | 10 "fmt" |
| 11 "io/ioutil" | 11 "io/ioutil" |
| 12 "path" | 12 "path" |
| 13 "strings" | 13 "strings" |
| 14 "testing" | 14 "testing" |
| 15 | 15 |
| 16 "github.com/luci/gae/impl/memory" | 16 "github.com/luci/gae/impl/memory" |
| 17 "github.com/luci/gae/service/datastore" |
| 17 "github.com/luci/luci-go/common/clock/testclock" | 18 "github.com/luci/luci-go/common/clock/testclock" |
| 19 "github.com/luci/luci-go/milo/common/miloerror" |
| 18 . "github.com/smartystreets/goconvey/convey" | 20 . "github.com/smartystreets/goconvey/convey" |
| 19 "golang.org/x/net/context" | 21 "golang.org/x/net/context" |
| 20 ) | 22 ) |
| 21 | 23 |
| 22 var generate = flag.Bool("test.generate", false, "Generate expectations instead
of running tests.") | 24 var generate = flag.Bool("test.generate", false, "Generate expectations instead
of running tests.") |
| 23 | 25 |
| 24 func load(name string) ([]byte, error) { | 26 func load(name string) ([]byte, error) { |
| 25 filename := strings.Join([]string{"expectations", name}, "/") | 27 filename := strings.Join([]string{"expectations", name}, "/") |
| 26 return ioutil.ReadFile(filename) | 28 return ioutil.ReadFile(filename) |
| 27 } | 29 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 Convey(`A test Environment`, t, func() { | 66 Convey(`A test Environment`, t, func() { |
| 65 | 67 |
| 66 for _, tc := range testCases { | 68 for _, tc := range testCases { |
| 67 Convey(fmt.Sprintf("Test Case: %s/%s", tc.builder, tc.bu
ild), func() { | 69 Convey(fmt.Sprintf("Test Case: %s/%s", tc.builder, tc.bu
ild), func() { |
| 68 build, err := build(c, "debug", tc.builder, tc.b
uild) | 70 build, err := build(c, "debug", tc.builder, tc.b
uild) |
| 69 So(err, ShouldBeNil) | 71 So(err, ShouldBeNil) |
| 70 fname := fmt.Sprintf("%s.%s.build.json", tc.buil
der, tc.build) | 72 fname := fmt.Sprintf("%s.%s.build.json", tc.buil
der, tc.build) |
| 71 So(build, shouldMatchExpectationsFor, fname) | 73 So(build, shouldMatchExpectationsFor, fname) |
| 72 }) | 74 }) |
| 73 } | 75 } |
| 76 |
| 77 Convey(`Disallow anonomyous users from accessing internal builds
`, func() { |
| 78 ds := datastore.Get(c) |
| 79 ds.Put(&buildbotBuild{ |
| 80 Master: "fake", |
| 81 Buildername: "fake", |
| 82 Number: 1, |
| 83 Internal: true, |
| 84 }) |
| 85 b, err := getBuild(c, "fake", "fake", "1") |
| 86 So(b, ShouldBeNil) |
| 87 So(err, ShouldResemble, miloerror.Error{ |
| 88 Message: "Cannot fetch project buildbot-internal
:\ndatastore: no such entity", |
| 89 Code: 500, |
| 90 }) |
| 91 }) |
| 74 }) | 92 }) |
| 75 } | 93 } |
| OLD | NEW |