github.com/wallyworld/juju@v0.0.0-20161013125918-6cf1bc9d917a/cmd/juju/user/user_test.go (about) 1 // Copyright 2014 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package user_test 5 6 import ( 7 jc "github.com/juju/testing/checkers" 8 gc "gopkg.in/check.v1" 9 10 "github.com/juju/juju/jujuclient" 11 "github.com/juju/juju/jujuclient/jujuclienttesting" 12 "github.com/juju/juju/testing" 13 ) 14 15 type BaseSuite struct { 16 testing.FakeJujuXDGDataHomeSuite 17 store *jujuclienttesting.MemStore 18 } 19 20 func (s *BaseSuite) SetUpTest(c *gc.C) { 21 s.FakeJujuXDGDataHomeSuite.SetUpTest(c) 22 23 s.store = jujuclienttesting.NewMemStore() 24 s.store.CurrentControllerName = "testing" 25 s.store.Controllers["testing"] = jujuclient.ControllerDetails{ 26 APIEndpoints: []string{"127.0.0.1:12345"}, 27 CACert: testing.CACert, 28 ControllerUUID: testing.ControllerTag.Id(), 29 } 30 s.store.Accounts["testing"] = jujuclient.AccountDetails{ 31 User: "current-user", 32 Password: "old-password", 33 } 34 } 35 36 func (s *BaseSuite) setPassword(c *gc.C, controller, pass string) { 37 details, ok := s.store.Accounts[controller] 38 c.Assert(ok, jc.IsTrue) 39 details.Password = pass 40 s.store.Accounts[controller] = details 41 } 42 43 func (s *BaseSuite) assertStorePassword(c *gc.C, user, pass, access string) { 44 details, err := s.store.AccountDetails("testing") 45 c.Assert(err, jc.ErrorIsNil) 46 c.Assert(details.User, gc.Equals, user) 47 c.Assert(details.Password, gc.Equals, pass) 48 c.Assert(details.LastKnownAccess, gc.Equals, access) 49 }