2014-10-22 05:32:19 +00:00
|
|
|
package influxdb_test
|
2013-10-21 18:29:25 +00:00
|
|
|
|
|
|
|
import (
|
2014-06-23 17:14:00 +00:00
|
|
|
"testing"
|
2014-06-27 16:57:06 +00:00
|
|
|
|
2014-10-22 05:32:19 +00:00
|
|
|
"github.com/influxdb/influxdb"
|
2013-10-21 18:29:25 +00:00
|
|
|
)
|
|
|
|
|
2014-10-22 05:32:19 +00:00
|
|
|
// Ensure the user's password can be changed.
|
|
|
|
func TestUser_ChangePassword(t *testing.T) {
|
2014-10-23 04:21:48 +00:00
|
|
|
u := &influxdb.ClusterAdmin{influxdb.CommonUser{"root", "", false, "root"}}
|
2014-10-22 05:32:19 +00:00
|
|
|
if err := u.ChangePassword("password"); err != nil {
|
|
|
|
t.Fatalf("unexpected error: %s", err)
|
|
|
|
}
|
2013-10-21 18:29:25 +00:00
|
|
|
}
|
|
|
|
|
2014-10-22 05:32:19 +00:00
|
|
|
/*
|
2013-10-22 22:45:43 +00:00
|
|
|
func (self *UserSuite) TestProperties(c *C) {
|
2014-04-07 20:40:18 +00:00
|
|
|
u := ClusterAdmin{CommonUser{Name: "root"}}
|
2013-10-21 18:29:25 +00:00
|
|
|
c.Assert(u.IsClusterAdmin(), Equals, true)
|
2014-06-22 20:36:42 +00:00
|
|
|
c.Assert(u.IsDbAdmin("db"), Equals, true)
|
2013-10-22 22:45:43 +00:00
|
|
|
c.Assert(u.GetName(), Equals, "root")
|
2014-01-31 20:40:10 +00:00
|
|
|
hash, err := HashPassword("foobar")
|
2013-12-12 18:04:46 +00:00
|
|
|
c.Assert(err, IsNil)
|
2014-01-31 20:40:10 +00:00
|
|
|
c.Assert(u.ChangePassword(string(hash)), IsNil)
|
2013-10-22 22:45:43 +00:00
|
|
|
c.Assert(u.isValidPwd("foobar"), Equals, true)
|
|
|
|
c.Assert(u.isValidPwd("password"), Equals, false)
|
|
|
|
|
2014-04-07 20:40:18 +00:00
|
|
|
dbUser := DbUser{CommonUser{Name: "db_user"}, "db", nil, nil, true}
|
2013-10-22 22:45:43 +00:00
|
|
|
c.Assert(dbUser.IsClusterAdmin(), Equals, false)
|
|
|
|
c.Assert(dbUser.IsDbAdmin("db"), Equals, true)
|
|
|
|
c.Assert(dbUser.GetName(), Equals, "db_user")
|
2014-01-31 20:40:10 +00:00
|
|
|
hash, err = HashPassword("password")
|
2013-12-12 18:04:46 +00:00
|
|
|
c.Assert(err, IsNil)
|
2014-01-31 20:40:10 +00:00
|
|
|
c.Assert(dbUser.ChangePassword(string(hash)), IsNil)
|
2013-10-22 22:45:43 +00:00
|
|
|
c.Assert(dbUser.isValidPwd("password"), Equals, true)
|
|
|
|
c.Assert(dbUser.isValidPwd("password1"), Equals, false)
|
2013-10-21 18:29:25 +00:00
|
|
|
}
|
2014-10-22 05:32:19 +00:00
|
|
|
*/
|