|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +const MongoStorageAdapter = require('../src/Adapters/Storage/Mongo/MongoStorageAdapter'); |
| 4 | +const MongoClient = require('mongodb').MongoClient; |
| 5 | + |
| 6 | +describe('MongoStorageAdapter', () => { |
| 7 | + it('auto-escapes symbols in auth information', () => { |
| 8 | + spyOn(MongoClient, 'connect').and.returnValue(Promise.resolve(null)); |
| 9 | + new MongoStorageAdapter('mongodb://user!with@+ symbols:password!with@+ symbols@localhost:1234/parse', {}) |
| 10 | + .connect(); |
| 11 | + expect(MongoClient.connect).toHaveBeenCalledWith( |
| 12 | + 'mongodb://user!with%40%2B%20symbols:password!with%40%2B%20symbols@localhost:1234/parse', |
| 13 | + jasmine.any(Object) |
| 14 | + ); |
| 15 | + }); |
| 16 | + |
| 17 | + it("doesn't double escape already URI-encoded information", () => { |
| 18 | + spyOn(MongoClient, 'connect').and.returnValue(Promise.resolve(null)); |
| 19 | + new MongoStorageAdapter('mongodb://user!with%40%2B%20symbols:password!with%40%2B%20symbols@localhost:1234/parse', {}) |
| 20 | + .connect(); |
| 21 | + expect(MongoClient.connect).toHaveBeenCalledWith( |
| 22 | + 'mongodb://user!with%40%2B%20symbols:password!with%40%2B%20symbols@localhost:1234/parse', |
| 23 | + jasmine.any(Object) |
| 24 | + ); |
| 25 | + }); |
| 26 | + |
| 27 | + // https://github.com/ParsePlatform/parse-server/pull/148#issuecomment-180407057 |
| 28 | + it('preserves replica sets', () => { |
| 29 | + spyOn(MongoClient, 'connect').and.returnValue(Promise.resolve(null)); |
| 30 | + new MongoStorageAdapter('mongodb://test:[email protected]:59325,ds059315-a1.mongolab.com:59315/testDBname?replicaSet=rs-ds059415', {}) |
| 31 | + .connect(); |
| 32 | + expect(MongoClient.connect).toHaveBeenCalledWith( |
| 33 | + 'mongodb://test:[email protected]:59325,ds059315-a1.mongolab.com:59315/testDBname?replicaSet=rs-ds059415', |
| 34 | + jasmine.any(Object) |
| 35 | + ); |
| 36 | + }); |
| 37 | +}); |
0 commit comments