| OLD | NEW |
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 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 auth | 5 package auth |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "testing" | 8 "testing" |
| 9 | 9 |
| 10 "golang.org/x/net/context" | 10 "golang.org/x/net/context" |
| 11 | 11 |
| 12 "github.com/luci/luci-go/server/auth/identity" | 12 "github.com/luci/luci-go/server/auth/identity" |
| 13 . "github.com/smartystreets/goconvey/convey" | 13 . "github.com/smartystreets/goconvey/convey" |
| 14 ) | 14 ) |
| 15 | 15 |
| 16 func TestState(t *testing.T) { | 16 func TestState(t *testing.T) { |
| 17 t.Parallel() |
| 18 |
| 17 Convey("Check empty ctx", t, func() { | 19 Convey("Check empty ctx", t, func() { |
| 18 ctx := context.Background() | 20 ctx := context.Background() |
| 19 So(GetState(ctx), ShouldBeNil) | 21 So(GetState(ctx), ShouldBeNil) |
| 20 So(CurrentUser(ctx).Identity, ShouldEqual, identity.AnonymousIde
ntity) | 22 So(CurrentUser(ctx).Identity, ShouldEqual, identity.AnonymousIde
ntity) |
| 21 So(CurrentIdentity(ctx), ShouldEqual, identity.AnonymousIdentity
) | 23 So(CurrentIdentity(ctx), ShouldEqual, identity.AnonymousIdentity
) |
| 22 | 24 |
| 23 res, err := IsMember(ctx, "group") | 25 res, err := IsMember(ctx, "group") |
| 24 So(res, ShouldBeFalse) | 26 So(res, ShouldBeFalse) |
| 25 So(err, ShouldEqual, ErrNoAuthState) | 27 So(err, ShouldEqual, ErrNoAuthState) |
| 26 }) | 28 }) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 37 So(GetState(ctx).PeerIdentity(), ShouldEqual, identity.Identity(
"user:abc@example.com")) | 39 So(GetState(ctx).PeerIdentity(), ShouldEqual, identity.Identity(
"user:abc@example.com")) |
| 38 So(GetState(ctx).PeerIP(), ShouldBeNil) | 40 So(GetState(ctx).PeerIP(), ShouldBeNil) |
| 39 So(CurrentUser(ctx).Identity, ShouldEqual, identity.Identity("us
er:abc@example.com")) | 41 So(CurrentUser(ctx).Identity, ShouldEqual, identity.Identity("us
er:abc@example.com")) |
| 40 So(CurrentIdentity(ctx), ShouldEqual, identity.Identity("user:ab
c@example.com")) | 42 So(CurrentIdentity(ctx), ShouldEqual, identity.Identity("user:ab
c@example.com")) |
| 41 | 43 |
| 42 res, err := IsMember(ctx, "group") | 44 res, err := IsMember(ctx, "group") |
| 43 So(err, ShouldBeNil) | 45 So(err, ShouldBeNil) |
| 44 So(res, ShouldBeTrue) // fakeDB always returns true | 46 So(res, ShouldBeTrue) // fakeDB always returns true |
| 45 }) | 47 }) |
| 46 } | 48 } |
| OLD | NEW |