41 lines
1.7 KiB
JavaScript
41 lines
1.7 KiB
JavaScript
'use strict';
|
|
|
|
const MongoStorageAdapter = require('../src/Adapters/Storage/Mongo/MongoStorageAdapter');
|
|
const MongoClient = require('mongodb').MongoClient;
|
|
|
|
describe('MongoStorageAdapter', () => {
|
|
it('auto-escapes symbols in auth information', () => {
|
|
spyOn(MongoClient, 'connect').and.returnValue(Promise.resolve(null));
|
|
new MongoStorageAdapter({
|
|
uri: 'mongodb://user!with@+ symbols:password!with@+ symbols@localhost:1234/parse'
|
|
}).connect();
|
|
expect(MongoClient.connect).toHaveBeenCalledWith(
|
|
'mongodb://user!with%40%2B%20symbols:password!with%40%2B%20symbols@localhost:1234/parse',
|
|
jasmine.any(Object)
|
|
);
|
|
});
|
|
|
|
it("doesn't double escape already URI-encoded information", () => {
|
|
spyOn(MongoClient, 'connect').and.returnValue(Promise.resolve(null));
|
|
new MongoStorageAdapter({
|
|
uri: 'mongodb://user!with%40%2B%20symbols:password!with%40%2B%20symbols@localhost:1234/parse'
|
|
}).connect();
|
|
expect(MongoClient.connect).toHaveBeenCalledWith(
|
|
'mongodb://user!with%40%2B%20symbols:password!with%40%2B%20symbols@localhost:1234/parse',
|
|
jasmine.any(Object)
|
|
);
|
|
});
|
|
|
|
// https://github.com/ParsePlatform/parse-server/pull/148#issuecomment-180407057
|
|
it('preserves replica sets', () => {
|
|
spyOn(MongoClient, 'connect').and.returnValue(Promise.resolve(null));
|
|
new MongoStorageAdapter({
|
|
uri: 'mongodb://test:testpass@ds056315-a0.mongolab.com:59325,ds059315-a1.mongolab.com:59315/testDBname?replicaSet=rs-ds059415'
|
|
}).connect();
|
|
expect(MongoClient.connect).toHaveBeenCalledWith(
|
|
'mongodb://test:testpass@ds056315-a0.mongolab.com:59325,ds059315-a1.mongolab.com:59315/testDBname?replicaSet=rs-ds059415',
|
|
jasmine.any(Object)
|
|
);
|
|
});
|
|
});
|