influxdb/user_test.go

40 lines
1.2 KiB
Go
Raw Normal View History

2014-10-22 05:32:19 +00:00
package influxdb_test
import (
2014-06-23 17:14:00 +00:00
"testing"
2014-10-22 05:32:19 +00:00
"github.com/influxdb/influxdb"
)
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)
}
}
2014-10-22 05:32:19 +00:00
/*
func (self *UserSuite) TestProperties(c *C) {
u := ClusterAdmin{CommonUser{Name: "root"}}
c.Assert(u.IsClusterAdmin(), Equals, true)
c.Assert(u.IsDbAdmin("db"), Equals, true)
c.Assert(u.GetName(), Equals, "root")
hash, err := HashPassword("foobar")
c.Assert(err, IsNil)
c.Assert(u.ChangePassword(string(hash)), IsNil)
c.Assert(u.isValidPwd("foobar"), Equals, true)
c.Assert(u.isValidPwd("password"), Equals, false)
dbUser := DbUser{CommonUser{Name: "db_user"}, "db", nil, nil, true}
c.Assert(dbUser.IsClusterAdmin(), Equals, false)
c.Assert(dbUser.IsDbAdmin("db"), Equals, true)
c.Assert(dbUser.GetName(), Equals, "db_user")
hash, err = HashPassword("password")
c.Assert(err, IsNil)
c.Assert(dbUser.ChangePassword(string(hash)), IsNil)
c.Assert(dbUser.isValidPwd("password"), Equals, true)
c.Assert(dbUser.isValidPwd("password1"), Equals, false)
}
2014-10-22 05:32:19 +00:00
*/