Ejemplo n.º 1
0
func (s *adminSuite) TestSetMongoPassword(c *gc.C) {
	dialInfo := s.setUpMongo(c)
	session, err := mgo.DialWithInfo(dialInfo)
	c.Assert(err, gc.IsNil)
	defer session.Close()
	db := session.DB("juju")

	err = db.Login("foo", "bar")
	c.Assert(err, gc.ErrorMatches, "auth fails")

	err = mongo.SetMongoPassword("foo", "bar", db)
	c.Assert(err, gc.IsNil)
	err = db.Login("foo", "bar")
	c.Assert(err, gc.IsNil)
}
Ejemplo n.º 2
0
func (s *adminSuite) TestSetMongoPassword(c *gc.C) {
	dialInfo := s.setUpMongo(c)
	session, err := mgo.DialWithInfo(dialInfo)
	c.Assert(err, gc.IsNil)
	defer session.Close()
	db := session.DB("juju")

	err = db.Login("foo", "bar")
	c.Assert(err, gc.ErrorMatches, "auth fails")

	err = mongo.SetMongoPassword("foo", "bar", db)
	c.Assert(err, gc.IsNil)
	err = db.Login("foo", "bar")
	c.Assert(err, gc.IsNil)
	checkRoles(c, db, "foo",
		[]interface{}{string(mgo.RoleReadWriteAny), string(mgo.RoleUserAdmin), string(mgo.RoleClusterAdmin)})
}
Ejemplo n.º 3
0
func (st *State) setMongoPassword(name, password string) error {
	return mongo.SetMongoPassword(name, password,
		st.db,
		st.db.Session.DB("presence"),
		st.db.Session.DB("admin"))
}