| 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" |
| 18 . "github.com/smartystreets/goconvey/convey" | 19 . "github.com/smartystreets/goconvey/convey" |
| 19 "golang.org/x/net/context" | 20 "golang.org/x/net/context" |
| 20 ) | 21 ) |
| 21 | 22 |
| 22 var generate = flag.Bool("test.generate", false, "Generate expectations instead
of running tests.") | 23 var generate = flag.Bool("test.generate", false, "Generate expectations instead
of running tests.") |
| 23 | 24 |
| 24 func load(name string) ([]byte, error) { | 25 func load(name string) ([]byte, error) { |
| 25 filename := strings.Join([]string{"expectations", name}, "/") | 26 filename := strings.Join([]string{"expectations", name}, "/") |
| 26 return ioutil.ReadFile(filename) | 27 return ioutil.ReadFile(filename) |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 Convey(`A test Environment`, t, func() { | 65 Convey(`A test Environment`, t, func() { |
| 65 | 66 |
| 66 for _, tc := range testCases { | 67 for _, tc := range testCases { |
| 67 Convey(fmt.Sprintf("Test Case: %s/%s", tc.builder, tc.bu
ild), func() { | 68 Convey(fmt.Sprintf("Test Case: %s/%s", tc.builder, tc.bu
ild), func() { |
| 68 build, err := build(c, "debug", tc.builder, tc.b
uild) | 69 build, err := build(c, "debug", tc.builder, tc.b
uild) |
| 69 So(err, ShouldBeNil) | 70 So(err, ShouldBeNil) |
| 70 fname := fmt.Sprintf("%s.%s.build.json", tc.buil
der, tc.build) | 71 fname := fmt.Sprintf("%s.%s.build.json", tc.buil
der, tc.build) |
| 71 So(build, shouldMatchExpectationsFor, fname) | 72 So(build, shouldMatchExpectationsFor, fname) |
| 72 }) | 73 }) |
| 73 } | 74 } |
| 75 |
| 76 Convey(`Disallow anonomyous users from accessing internal builds
`, func() { |
| 77 ds := datastore.Get(c) |
| 78 ds.Put(&buildbotBuild{ |
| 79 Master: "fake", |
| 80 Buildername: "fake", |
| 81 Number: 1, |
| 82 Internal: true, |
| 83 }) |
| 84 b, err := getBuild(c, "fake", "fake", "1") |
| 85 So(b, ShouldBeNil) |
| 86 So(err, ShouldResemble, errBuildNotFound) |
| 87 }) |
| 74 }) | 88 }) |
| 75 } | 89 } |
| OLD | NEW |