Skip to content

Commit

Permalink
Remove now obsolete tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wallyworld committed Mar 10, 2022
1 parent 2d7cc4f commit 0f38e9f
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 66 deletions.
12 changes: 0 additions & 12 deletions api/client_macaroon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,3 @@ func (s *clientMacaroonSuite) TestAddLocalCharmSuccess(c *gc.C) {
c.Assert(err, jc.ErrorIsNil)
c.Assert(savedURL.String(), gc.Equals, curl.String())
}

func (s *clientMacaroonSuite) TestAddLocalCharmUnauthorized(c *gc.C) {
client := s.createTestClient(c)
s.DischargerLogin = func() string { return "baduser" }
charmArchive := testcharms.Repo.CharmArchive(c.MkDir(), "dummy")
curl := charm.MustParseURL(
fmt.Sprintf("local:quantal/%s-%d", charmArchive.Meta().Name, charmArchive.Revision()),
)
// Upload an archive with its original revision.
_, err := client.AddLocalCharm(curl, charmArchive, false)
c.Assert(err, gc.ErrorMatches, `.*invalid entity name or password$`)
}
13 changes: 0 additions & 13 deletions api/state_macaroon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ import (
"net/url"

"github.com/go-macaroon-bakery/macaroon-bakery/v3/httpbakery"
"github.com/juju/errors"
jc "github.com/juju/testing/checkers"
gc "gopkg.in/check.v1"
"gopkg.in/macaroon.v2"

"github.com/juju/juju/api"
apitesting "github.com/juju/juju/api/testing"
"github.com/juju/juju/core/permission"
"github.com/juju/juju/rpc"
)

var _ = gc.Suite(&macaroonLoginSuite{})
Expand Down Expand Up @@ -58,17 +56,6 @@ func (s *macaroonLoginSuite) TestFailedToObtainDischargeLogin(c *gc.C) {
c.Assert(err, gc.ErrorMatches, `cannot get discharge from "https://.*": third party refused discharge: cannot discharge: login denied by discharger`)
}

func (s *macaroonLoginSuite) TestUnknownUserLogin(c *gc.C) {
s.DischargerLogin = func() string {
return "testUnknown"
}
err := s.client.Login(nil, "", "", s.macSlice)
c.Assert(errors.Cause(err), gc.DeepEquals, &rpc.RequestError{
Message: "invalid entity name or password",
Code: "unauthorized access",
})
}

func (s *macaroonLoginSuite) TestConnectStream(c *gc.C) {
catcher := urlCatcher{}
s.PatchValue(api.WebsocketDial, catcher.recordLocation)
Expand Down
30 changes: 1 addition & 29 deletions apiserver/admin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1206,25 +1206,6 @@ func (s *macaroonLoginSuite) TestPublicKeyLocatorErrorIsNotPersistent(c *gc.C) {
c.Assert(err, jc.ErrorIsNil)
}

func (s *macaroonLoginSuite) TestLoginToController(c *gc.C) {
// Note that currently we cannot use macaroon auth
// to log into the controller rather than a model
// because there's no place to store the fact that
// a given external user is allowed access to the controller.
s.DischargerLogin = func() string {
return "test@somewhere"
}
info := s.APIInfo(c)

// Zero the model tag so that we log into the controller
// not the model.
info.ModelTag = names.ModelTag{}

client, err := api.Open(info, api.DialOpts{})
assertInvalidEntityPassword(c, err)
c.Assert(client, gc.Equals, nil)
}

func (s *macaroonLoginSuite) login(c *gc.C, info *api.Info) (params.LoginResult, error) {
cookieJar := apitesting.NewClearableCookieJar()

Expand Down Expand Up @@ -1282,7 +1263,7 @@ func (s *macaroonLoginSuite) TestRemoteUserLoginToControllerNoAccess(c *gc.C) {
info.ModelTag = names.ModelTag{}

_, err := s.login(c, info)
assertInvalidEntityPassword(c, err)
assertPermissionDenied(c, err)
}

func (s *macaroonLoginSuite) TestRemoteUserLoginToControllerLoginAccess(c *gc.C) {
Expand Down Expand Up @@ -1434,15 +1415,6 @@ func (s *macaroonLoginSuite) TestFailedToObtainDischargeLogin(c *gc.C) {
c.Assert(client, gc.Equals, nil)
}

func (s *macaroonLoginSuite) TestUnknownUserLogin(c *gc.C) {
s.DischargerLogin = func() string {
return "testUnknown@somewhere"
}
client, err := api.Open(s.APIInfo(c), api.DialOpts{})
assertInvalidEntityPassword(c, err)
c.Assert(client, gc.Equals, nil)
}

func assertInvalidEntityPassword(c *gc.C, err error) {
c.Assert(errors.Cause(err), gc.DeepEquals, &rpc.RequestError{
Message: "invalid entity name or password",
Expand Down
2 changes: 1 addition & 1 deletion apiserver/authentication/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type taggedAuthenticator interface {
func (*EntityAuthenticator) Authenticate(ctx context.Context, entityFinder EntityFinder, tag names.Tag, req params.LoginRequest) (state.Entity, error) {
entity, err := entityFinder.FindEntity(tag)
if errors.IsNotFound(err) {
logger.Debugf("cannot authenticate unknown agent: %v", tag)
logger.Debugf("cannot authenticate unknown entity: %v", tag)
return nil, errors.Trace(apiservererrors.ErrBadCreds)
}
if err != nil {
Expand Down
11 changes: 0 additions & 11 deletions cmd/modelcmd/modelcommand_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -541,14 +541,3 @@ func (s *macaroonLoginSuite) TestsFailToObtainDischargeLogin(c *gc.C) {
_, err := cmd.NewAPIRoot()
c.Assert(err, gc.ErrorMatches, "cannot get discharge.*", gc.Commentf("%s", errors.Details(err)))
}

func (s *macaroonLoginSuite) TestsUnknownUserLogin(c *gc.C) {
s.DischargerLogin = func() string {
return "testUnknown@nowhere"
}

cmd := s.newModelCommandBase()
cmd.SetAPIOpen(s.apiOpen)
_, err := cmd.NewAPIRoot()
c.Assert(err, gc.ErrorMatches, "invalid entity name or password \\(unauthorized access\\)", gc.Commentf("details: %s", errors.Details(err)))
}

0 comments on commit 0f38e9f

Please sign in to comment.