Skip to content

Commit

Permalink
auth_test.go: fix expected auth error messages for 2.4
Browse files Browse the repository at this point in the history
niemeyer committed Mar 26, 2013
1 parent 7ff7995 commit 671a6ab
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions auth_test.go
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ func (s *S) TestAuthLogin(c *C) {

coll := session.DB("mydb").C("mycoll")
err = coll.Insert(M{"n": 1})
c.Assert(err, ErrorMatches, "unauthorized|need to login")
c.Assert(err, ErrorMatches, "unauthorized|need to login|not authorized .*")

admindb := session.DB("admin")

@@ -66,15 +66,15 @@ func (s *S) TestAuthLoginLogout(c *C) {

coll := session.DB("mydb").C("mycoll")
err = coll.Insert(M{"n": 1})
c.Assert(err, ErrorMatches, "unauthorized|need to login")
c.Assert(err, ErrorMatches, "unauthorized|need to login|not authorized .*")

// Must have dropped auth from the session too.
session = session.Copy()
defer session.Close()

coll = session.DB("mydb").C("mycoll")
err = coll.Insert(M{"n": 1})
c.Assert(err, ErrorMatches, "unauthorized|need to login")
c.Assert(err, ErrorMatches, "unauthorized|need to login|not authorized .*")
}

func (s *S) TestAuthLoginLogoutAll(c *C) {
@@ -90,15 +90,15 @@ func (s *S) TestAuthLoginLogoutAll(c *C) {

coll := session.DB("mydb").C("mycoll")
err = coll.Insert(M{"n": 1})
c.Assert(err, ErrorMatches, "unauthorized|need to login")
c.Assert(err, ErrorMatches, "unauthorized|need to login|not authorized .*")

// Must have dropped auth from the session too.
session = session.Copy()
defer session.Close()

coll = session.DB("mydb").C("mycoll")
err = coll.Insert(M{"n": 1})
c.Assert(err, ErrorMatches, "unauthorized|need to login")
c.Assert(err, ErrorMatches, "unauthorized|need to login|not authorized .*")
}

func (s *S) TestAuthAddUser(c *C) {
@@ -123,7 +123,7 @@ func (s *S) TestAuthAddUser(c *C) {

coll := session.DB("mydb").C("mycoll")
err = coll.Insert(M{"n": 1})
c.Assert(err, ErrorMatches, "unauthorized")
c.Assert(err, ErrorMatches, "unauthorized|not authorized .*")

err = mydb.Login("mywuser", "mypass")
c.Assert(err, IsNil)
@@ -156,7 +156,7 @@ func (s *S) TestAuthAddUserReplaces(c *C) {

// ReadOnly flag was changed too.
err = mydb.C("mycoll").Insert(M{"n": 1})
c.Assert(err, ErrorMatches, "unauthorized")
c.Assert(err, ErrorMatches, "unauthorized|not authorized .*")
}

func (s *S) TestAuthRemoveUser(c *C) {
@@ -233,7 +233,7 @@ func (s *S) TestAuthLoginSwitchUser(c *C) {

// Can't write.
err = coll.Insert(M{"n": 1})
c.Assert(err, ErrorMatches, "unauthorized")
c.Assert(err, ErrorMatches, "unauthorized|not authorized .*")

// But can read.
result := struct{ N int }{}
@@ -268,7 +268,7 @@ func (s *S) TestAuthLoginChangePassword(c *C) {

// The second login must be in effect, which means read-only.
err = mydb.C("mycoll").Insert(M{"n": 1})
c.Assert(err, ErrorMatches, "unauthorized")
c.Assert(err, ErrorMatches, "unauthorized|not authorized .*")
}

func (s *S) TestAuthLoginCachingWithSessionRefresh(c *C) {
@@ -335,7 +335,7 @@ func (s *S) TestAuthLoginCachingWithNewSession(c *C) {

coll := session.DB("mydb").C("mycoll")
err = coll.Insert(M{"n": 1})
c.Assert(err, ErrorMatches, "unauthorized|need to login")
c.Assert(err, ErrorMatches, "unauthorized|need to login|not authorized for .*")
}

func (s *S) TestAuthLoginCachingAcrossPool(c *C) {
@@ -432,7 +432,7 @@ func (s *S) TestAuthLoginCachingAcrossPoolWithLogout(c *C) {
// Can't write, since root has been implicitly logged out
// when the collection went into the pool, and not revalidated.
err = other.DB("mydb").C("mycoll").Insert(M{"n": 1})
c.Assert(err, ErrorMatches, "unauthorized")
c.Assert(err, ErrorMatches, "unauthorized|not authorized .*")

// But can read due to the revalidated myuser login.
result := struct{ N int }{}
@@ -533,7 +533,7 @@ func (s *S) TestAuthURLWithDatabase(c *C) {
err = ucoll.FindId(0).One(nil)
c.Assert(err, Equals, mgo.ErrNotFound)
err = ucoll.Insert(M{"n": 1})
c.Assert(err, ErrorMatches, "unauthorized")
c.Assert(err, ErrorMatches, "unauthorized|not authorized .*")
}

func (s *S) TestDefaultDatabase(c *C) {

0 comments on commit 671a6ab

Please sign in to comment.