Exemple #1
0
def get_arctic_store_ex(config):
    """ get arctic store """

    store = None
    try:
        conn = pymongo.MongoClient(config.get("MONGODB", "MONGO_SERVER"))

        # authenticate
        auth = authenticate(conn[config.get("MONGODB", "MONGO_DATABASE")],\
              config.get("MONGODB", "MONGO_USER"),\
              config.get("MONGODB", "MONGO_PASSWORD"))
        if auth == True:
            store = arctic.Arctic(conn)

    except Exception as ex:
        print('Exception in getting arctic store {}'.format(str(ex.args)))

    finally:
        return store
Exemple #2
0
def test_authenticate():
    db = create_autospec(Database)
    db.authenticate.return_value = sentinel.ret
    assert auth.authenticate(db, sentinel.user,
                             sentinel.password) == sentinel.ret
Exemple #3
0
def test_authenticate_fails_exception():
    db = create_autospec(Database)
    db.authenticate.side_effect = PyMongoError("error")
    with pytest.raises(PyMongoError):
        assert auth.authenticate(db, sentinel.user, sentinel.password) is False
Exemple #4
0
def test_authenticate_fails():
    db = create_autospec(Database)
    error = "command SON([('saslStart', 1), ('mechanism', 'SCRAM-SHA-1'), ('payload', Binary('n,,n=foo,r=OTI3MzA3MTEzMTIx', 0)), ('autoAuthorize', 1)]) on namespace admin.$cmd failed: Authentication failed."
    db.authenticate.side_effect = OperationFailure(error)
    assert auth.authenticate(db, sentinel.user, sentinel.password) is False
Exemple #5
0
def test_authenticate():
    db = create_autospec(Database)
    db.authenticate.return_value = sentinel.ret
    assert auth.authenticate(db, sentinel.user, sentinel.password) == sentinel.ret
Exemple #6
0
def test_authenticate_fails_exception():
    db = create_autospec(Database)
    db.authenticate.side_effect = PyMongoError("error")
    with pytest.raises(PyMongoError):
        assert auth.authenticate(db, sentinel.user, sentinel.password) is False
Exemple #7
0
def test_authenticate_fails():
    db = create_autospec(Database)
    error = "command SON([('saslStart', 1), ('mechanism', 'SCRAM-SHA-1'), ('payload', Binary('n,,n=foo,r=OTI3MzA3MTEzMTIx', 0)), ('autoAuthorize', 1)]) on namespace admin.$cmd failed: Authentication failed."
    db.authenticate.side_effect = OperationFailure(error)
    assert auth.authenticate(db, sentinel.user, sentinel.password) is False
Exemple #8
0
def test_authenticate_fails():
    db = create_autospec(Database)
    db.authenticate.side_effect = PyMongoError("error")
    assert auth.authenticate(db, sentinel.user, sentinel.password) is False
Exemple #9
0
def test_authenticate_fails():
    db = create_autospec(Database)
    db.authenticate.side_effect = PyMongoError("error")
    assert auth.authenticate(db, sentinel.user, sentinel.password) is False