Add (failing) tests for uri encoding auth
This commit is contained in:
37
spec/MongoStorageAdapter.spec.js
Normal file
37
spec/MongoStorageAdapter.spec.js
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
'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('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('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('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)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user