Various fixes for auth tests with old mongos versions.
This commit is contained in:
parent
13cd9bee6f
commit
04ff22e3c9
@ -728,6 +728,11 @@ class Database(common.BaseObject):
|
||||
# See SERVER-4225 for more information.
|
||||
if 'login' in str(exc):
|
||||
pass
|
||||
# First admin user add fails gle from mongos 2.0.x
|
||||
# and 2.2.x.
|
||||
elif (exc.details and
|
||||
'getlasterror' in exc.details.get('note', '')):
|
||||
pass
|
||||
else:
|
||||
raise
|
||||
|
||||
|
||||
@ -1053,7 +1053,7 @@ class MongoClient(common.BaseObject):
|
||||
# for some errors.
|
||||
if "errObjects" in result:
|
||||
for errobj in result["errObjects"]:
|
||||
if errobj["err"] == error_msg:
|
||||
if errobj.get("err") == error_msg:
|
||||
details = errobj
|
||||
break
|
||||
|
||||
|
||||
@ -226,6 +226,9 @@ class TestClient(unittest.TestCase, TestRequestMixin):
|
||||
# from a master in a master-slave pair.
|
||||
if server_is_master_with_slave(c):
|
||||
raise SkipTest("SERVER-2329")
|
||||
if (not version.at_least(c, (2, 6, 0)) and
|
||||
is_mongos(c) and server_started_with_auth(c)):
|
||||
raise SkipTest("Need mongos >= 2.6.0 to test with authentication")
|
||||
# We test copy twice; once starting in a request and once not. In
|
||||
# either case the copy should succeed (because it starts a request
|
||||
# internally) and should leave us in the same state as before the copy.
|
||||
@ -262,8 +265,7 @@ class TestClient(unittest.TestCase, TestRequestMixin):
|
||||
self.assertEqual("bar", c.pymongo_test2.test.find_one()["foo"])
|
||||
|
||||
# See SERVER-6427 for mongos
|
||||
if (version.at_least(c, (1, 3, 3, 1)) and
|
||||
not is_mongos(c) and server_started_with_auth(c)):
|
||||
if not is_mongos(c) and server_started_with_auth(c):
|
||||
|
||||
c.drop_database("pymongo_test1")
|
||||
|
||||
|
||||
@ -609,7 +609,10 @@ class TestCollection(unittest.TestCase):
|
||||
db.drop_collection("test")
|
||||
if version.at_least(db.connection, (1, 9)):
|
||||
db.create_collection("test", capped=True, size=4096)
|
||||
self.assertEqual(db.test.options(), {"capped": True, 'size': 4096})
|
||||
result = db.test.options()
|
||||
# mongos 2.2.x adds an $auth field when auth is enabled.
|
||||
result.pop('$auth', None)
|
||||
self.assertEqual(result, {"capped": True, 'size': 4096})
|
||||
else:
|
||||
db.create_collection("test", capped=True)
|
||||
self.assertEqual(db.test.options(), {"capped": True})
|
||||
|
||||
@ -110,7 +110,10 @@ class TestDatabase(unittest.TestCase):
|
||||
db.drop_collection("test.foo")
|
||||
db.create_collection("test.foo")
|
||||
self.assertTrue(u"test.foo" in db.collection_names())
|
||||
self.assertEqual(db.test.foo.options(), {})
|
||||
result = db.test.foo.options()
|
||||
# mongos 2.2.x adds an $auth field when auth is enabled.
|
||||
result.pop('$auth', None)
|
||||
self.assertEqual(result, {})
|
||||
self.assertRaises(CollectionInvalid, db.create_collection, "test.foo")
|
||||
|
||||
def test_collection_names(self):
|
||||
@ -601,8 +604,8 @@ class TestDatabase(unittest.TestCase):
|
||||
def test_authenticate_multiple(self):
|
||||
client = get_client()
|
||||
if (is_mongos(client) and not
|
||||
version.at_least(self.client, (2, 0, 0))):
|
||||
raise SkipTest("Auth with sharding requires MongoDB >= 2.0.0")
|
||||
version.at_least(self.client, (2, 2, 0))):
|
||||
raise SkipTest("Need mongos >= 2.2.0")
|
||||
if not server_started_with_auth(client):
|
||||
raise SkipTest("Authentication is not enabled on server")
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user