Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(419)

Side by Side Diff: state/user_test.go

Issue 61620043: Started working on add/remove user support
Patch Set: Started working on add/remove user support Created 11 years, 1 month ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « state/user.go ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 Canonical Ltd. 1 // Copyright 2013 Canonical Ltd.
2 // Licensed under the AGPLv3, see LICENCE file for details. 2 // Licensed under the AGPLv3, see LICENCE file for details.
3 3
4 package state_test 4 package state_test
5 5
6 import ( 6 import (
7 jc "github.com/juju/testing/checkers" 7 jc "github.com/juju/testing/checkers"
8 gc "launchpad.net/gocheck" 8 gc "launchpad.net/gocheck"
9 9
10 "launchpad.net/juju-core/state" 10 "launchpad.net/juju-core/state"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 c.Assert(lastHash, gc.Equals, afterHash) 151 c.Assert(lastHash, gc.Equals, afterHash)
152 } 152 }
153 153
154 func (s *UserSuite) TestName(c *gc.C) { 154 func (s *UserSuite) TestName(c *gc.C) {
155 u, err := s.State.AddUser("someuser", "") 155 u, err := s.State.AddUser("someuser", "")
156 c.Assert(err, gc.IsNil) 156 c.Assert(err, gc.IsNil)
157 157
158 c.Assert(u.Name(), gc.Equals, "someuser") 158 c.Assert(u.Name(), gc.Equals, "someuser")
159 c.Assert(u.Tag(), gc.Equals, "user-someuser") 159 c.Assert(u.Tag(), gc.Equals, "user-someuser")
160 } 160 }
161
162 func (s *UserSuite) TestDeactivate(c *gc.C) {
163 u, err := s.State.AddUser("someuser", "")
164 c.Assert(err, gc.IsNil)
165 c.Assert(u.IsDeactivated(), gc.Equals, false)
166
167 err = u.Deactivate()
168 c.Assert(err, gc.IsNil)
169 c.Assert(u.IsDeactivated(), gc.Equals, true)
170 c.Assert(u.PasswordValid(""), gc.Equals, false)
171
172 }
173
174 func (s *UserSuite) TestCantDeactivateAdminUser(c *gc.C) {
175 u, err := s.State.User(state.AdminUser)
176 c.Assert(err, gc.IsNil)
177 err = u.Deactivate()
178 c.Assert(err, gc.ErrorMatches, "Can't deactivate admin user")
179 }
OLDNEW
« no previous file with comments | « state/user.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b