Skip to content

Commit 903847b

Browse files
authored
Merge pull request #2 from dblythy/afterLiveQueryEvent
After live query event
2 parents 2c587a9 + e38afed commit 903847b

File tree

9 files changed

+999
-814
lines changed

9 files changed

+999
-814
lines changed

package-lock.json

Lines changed: 182 additions & 127 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
"license": "BSD-3-Clause",
2121
"dependencies": {
2222
"@apollographql/graphql-playground-html": "1.6.26",
23-
"@graphql-tools/stitch": "6.0.12",
24-
"@graphql-tools/utils": "6.0.12",
23+
"@graphql-tools/stitch": "6.0.13",
24+
"@graphql-tools/utils": "6.0.13",
2525
"@parse/fs-files-adapter": "1.0.1",
2626
"@parse/push-adapter": "3.2.0",
2727
"@parse/s3-files-adapter": "1.4.0",
2828
"@parse/simple-mailgun-adapter": "1.1.0",
29-
"apollo-server-express": "2.15.1",
29+
"apollo-server-express": "2.16.0",
3030
"bcryptjs": "2.4.3",
3131
"body-parser": "1.19.0",
3232
"commander": "5.1.0",
@@ -41,8 +41,8 @@
4141
"intersect": "1.0.1",
4242
"jsonwebtoken": "8.5.1",
4343
"jwks-rsa": "1.8.1",
44-
"ldapjs": "2.0.0",
45-
"lodash": "4.17.19",
44+
"ldapjs": "2.1.0",
45+
"lodash": "4.17.20",
4646
"lru-cache": "5.1.1",
4747
"mime": "2.4.6",
4848
"mongodb": "3.5.9",
@@ -53,8 +53,8 @@
5353
"semver": "7.3.2",
5454
"subscriptions-transport-ws": "0.9.17",
5555
"tv4": "1.3.0",
56-
"uuid": "8.2.0",
57-
"winston": "3.2.1",
56+
"uuid": "8.3.0",
57+
"winston": "3.3.2",
5858
"winston-daily-rotate-file": "4.5.0",
5959
"ws": "7.3.1"
6060
},

spec/AuthenticationAdapters.spec.js

Lines changed: 18 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ describe('AuthenticationProviders', function () {
2525
'gcenter',
2626
'gpgames',
2727
'facebook',
28-
'facebookaccountkit',
2928
'github',
3029
'instagram',
3130
'google',
@@ -43,7 +42,7 @@ describe('AuthenticationProviders', function () {
4342
'phantauth',
4443
'microsoft',
4544
].map(function (providerName) {
46-
it('Should validate structure of ' + providerName, (done) => {
45+
it('Should validate structure of ' + providerName, done => {
4746
const provider = require('../lib/Adapters/Auth/' + providerName);
4847
jequal(typeof provider.validateAuthData, 'function');
4948
jequal(typeof provider.validateAppId, 'function');
@@ -71,7 +70,7 @@ describe('AuthenticationProviders', function () {
7170
return;
7271
}
7372
spyOn(require('../lib/Adapters/Auth/httpsRequest'), 'get').and.callFake(
74-
(options) => {
73+
options => {
7574
if (
7675
options ===
7776
'https://oauth.vk.com/access_token?client_id=appId&client_secret=appSecret&v=5.59&grant_type=client_credentials'
@@ -175,7 +174,7 @@ describe('AuthenticationProviders', function () {
175174
body: jsonBody,
176175
};
177176
return request(options)
178-
.then((response) => {
177+
.then(response => {
179178
if (callback) {
180179
callback(null, response, response.data);
181180
}
@@ -184,15 +183,15 @@ describe('AuthenticationProviders', function () {
184183
body: response.data,
185184
};
186185
})
187-
.catch((error) => {
186+
.catch(error => {
188187
if (callback) {
189188
callback(error);
190189
}
191190
throw error;
192191
});
193192
};
194193

195-
it('should create user with REST API', (done) => {
194+
it('should create user with REST API', done => {
196195
createOAuthUser((error, response, body) => {
197196
expect(error).toBe(null);
198197
const b = body;
@@ -203,7 +202,7 @@ describe('AuthenticationProviders', function () {
203202
const q = new Parse.Query('_Session');
204203
q.equalTo('sessionToken', sessionToken);
205204
q.first({ useMasterKey: true })
206-
.then((res) => {
205+
.then(res => {
207206
if (!res) {
208207
fail('should not fail fetching the session');
209208
done();
@@ -219,7 +218,7 @@ describe('AuthenticationProviders', function () {
219218
});
220219
});
221220

222-
it('should only create a single user with REST API', (done) => {
221+
it('should only create a single user with REST API', done => {
223222
let objectId;
224223
createOAuthUser((error, response, body) => {
225224
expect(error).toBe(null);
@@ -239,9 +238,9 @@ describe('AuthenticationProviders', function () {
239238
});
240239
});
241240

242-
it("should fail to link if session token don't match user", (done) => {
241+
it("should fail to link if session token don't match user", done => {
243242
Parse.User.signUp('myUser', 'password')
244-
.then((user) => {
243+
.then(user => {
245244
return createOAuthUserWithSessionToken(user.getSessionToken());
246245
})
247246
.then(() => {
@@ -250,7 +249,7 @@ describe('AuthenticationProviders', function () {
250249
.then(() => {
251250
return Parse.User.signUp('myUser2', 'password');
252251
})
253-
.then((user) => {
252+
.then(user => {
254253
return createOAuthUserWithSessionToken(user.getSessionToken());
255254
})
256255
.then(fail, ({ data }) => {
@@ -330,7 +329,7 @@ describe('AuthenticationProviders', function () {
330329
expect(typeof authAdapter.validateAppId).toBe('function');
331330
}
332331

333-
it('properly loads custom adapter', (done) => {
332+
it('properly loads custom adapter', done => {
334333
const validAuthData = {
335334
id: 'hello',
336335
token: 'world',
@@ -370,14 +369,14 @@ describe('AuthenticationProviders', function () {
370369
expect(appIdSpy).not.toHaveBeenCalled();
371370
done();
372371
},
373-
(err) => {
372+
err => {
374373
jfail(err);
375374
done();
376375
}
377376
);
378377
});
379378

380-
it('properly loads custom adapter module object', (done) => {
379+
it('properly loads custom adapter module object', done => {
381380
const authenticationHandler = authenticationLoader({
382381
customAuthentication: path.resolve('./spec/support/CustomAuth.js'),
383382
});
@@ -394,14 +393,14 @@ describe('AuthenticationProviders', function () {
394393
() => {
395394
done();
396395
},
397-
(err) => {
396+
err => {
398397
jfail(err);
399398
done();
400399
}
401400
);
402401
});
403402

404-
it('properly loads custom adapter module object (again)', (done) => {
403+
it('properly loads custom adapter module object (again)', done => {
405404
const authenticationHandler = authenticationLoader({
406405
customAuthentication: {
407406
module: path.resolve('./spec/support/CustomAuthFunction.js'),
@@ -421,7 +420,7 @@ describe('AuthenticationProviders', function () {
421420
() => {
422421
done();
423422
},
424-
(err) => {
423+
err => {
425424
jfail(err);
426425
done();
427426
}
@@ -512,84 +511,6 @@ describe('AuthenticationProviders', function () {
512511
expect(appIds).toEqual(['a', 'b']);
513512
expect(providerOptions).toEqual(options.custom);
514513
});
515-
516-
it('properly loads Facebook accountkit adapter with options', () => {
517-
const options = {
518-
facebookaccountkit: {
519-
appIds: ['a', 'b'],
520-
appSecret: 'secret',
521-
},
522-
};
523-
const {
524-
adapter,
525-
appIds,
526-
providerOptions,
527-
} = authenticationLoader.loadAuthAdapter('facebookaccountkit', options);
528-
validateAuthenticationAdapter(adapter);
529-
expect(appIds).toEqual(['a', 'b']);
530-
expect(providerOptions.appSecret).toEqual('secret');
531-
});
532-
533-
it('should fail if Facebook appIds is not configured properly', (done) => {
534-
const options = {
535-
facebookaccountkit: {
536-
appIds: [],
537-
},
538-
};
539-
const { adapter, appIds } = authenticationLoader.loadAuthAdapter(
540-
'facebookaccountkit',
541-
options
542-
);
543-
adapter.validateAppId(appIds).then(done.fail, (err) => {
544-
expect(err.code).toBe(Parse.Error.OBJECT_NOT_FOUND);
545-
done();
546-
});
547-
});
548-
549-
it('should fail to validate Facebook accountkit auth with bad token', (done) => {
550-
const options = {
551-
facebookaccountkit: {
552-
appIds: ['a', 'b'],
553-
},
554-
};
555-
const authData = {
556-
id: 'fakeid',
557-
access_token: 'badtoken',
558-
};
559-
const { adapter } = authenticationLoader.loadAuthAdapter(
560-
'facebookaccountkit',
561-
options
562-
);
563-
adapter.validateAuthData(authData).then(done.fail, (err) => {
564-
expect(err.code).toBe(190);
565-
expect(err.type).toBe('OAuthException');
566-
done();
567-
});
568-
});
569-
570-
it('should fail to validate Facebook accountkit auth with bad token regardless of app secret proof', (done) => {
571-
const options = {
572-
facebookaccountkit: {
573-
appIds: ['a', 'b'],
574-
appSecret: 'badsecret',
575-
},
576-
};
577-
const authData = {
578-
id: 'fakeid',
579-
access_token: 'badtoken',
580-
};
581-
const { adapter, providerOptions } = authenticationLoader.loadAuthAdapter(
582-
'facebookaccountkit',
583-
options
584-
);
585-
adapter
586-
.validateAuthData(authData, providerOptions)
587-
.then(done.fail, (err) => {
588-
expect(err.code).toBe(190);
589-
expect(err.type).toBe('OAuthException');
590-
done();
591-
});
592-
});
593514
});
594515

595516
describe('instagram auth adapter', () => {
@@ -1653,13 +1574,13 @@ describe('microsoft graph auth adapter', () => {
16531574
});
16541575
});
16551576

1656-
it('should fail to validate Microsoft Graph auth with bad token', (done) => {
1577+
it('should fail to validate Microsoft Graph auth with bad token', done => {
16571578
const authData = {
16581579
id: 'fake-id',
16591580
16601581
access_token: 'very.long.bad.token',
16611582
};
1662-
microsoft.validateAuthData(authData).then(done.fail, (err) => {
1583+
microsoft.validateAuthData(authData).then(done.fail, err => {
16631584
expect(err.code).toBe(101);
16641585
expect(err.message).toBe(
16651586
'Microsoft Graph auth is invalid for this user.'

spec/FilesController.spec.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const mockAdapter = {
2424

2525
// Small additional tests to improve overall coverage
2626
describe('FilesController', () => {
27-
it('should properly expand objects', (done) => {
27+
it('should properly expand objects', done => {
2828
const config = Config.get(Parse.applicationId);
2929
const gridStoreAdapter = new GridFSBucketAdapter(
3030
'mongodb://localhost:27017/parse'
@@ -48,7 +48,7 @@ describe('FilesController', () => {
4848
done();
4949
});
5050

51-
it('should create a server log on failure', (done) => {
51+
it('should create a server log on failure', done => {
5252
const logController = new LoggerController(new WinstonLoggerAdapter());
5353

5454
reconfigureServer({ filesAdapter: mockAdapter })
@@ -57,28 +57,28 @@ describe('FilesController', () => {
5757
() => done.fail('should not succeed'),
5858
() => setImmediate(() => Promise.resolve('done'))
5959
)
60-
.then(() => new Promise((resolve) => setTimeout(resolve, 200)))
60+
.then(() => new Promise(resolve => setTimeout(resolve, 200)))
6161
.then(() =>
6262
logController.getLogs({ from: Date.now() - 1000, size: 1000 })
6363
)
64-
.then((logs) => {
64+
.then(logs => {
6565
// we get two logs here: 1. the source of the failure to save the file
6666
// and 2 the message that will be sent back to the client.
6767

6868
const log1 = logs.find(
69-
(x) => x.message === 'Error creating a file: it failed with xyz'
69+
x => x.message === 'Error creating a file: it failed with xyz'
7070
);
7171
expect(log1.level).toBe('error');
7272

73-
const log2 = logs.find((x) => x.message === 'it failed with xyz');
73+
const log2 = logs.find(x => x.message === 'it failed with xyz');
7474
expect(log2.level).toBe('error');
7575
expect(log2.code).toBe(130);
7676

7777
done();
7878
});
7979
});
8080

81-
it('should create a parse error when a string is returned', (done) => {
81+
it('should create a parse error when a string is returned', done => {
8282
const mock2 = mockAdapter;
8383
mock2.validateFilename = () => {
8484
return 'Bad file! No biscuit!';
@@ -91,7 +91,7 @@ describe('FilesController', () => {
9191
done();
9292
});
9393

94-
it('should add a unique hash to the file name when the preserveFileName option is false', (done) => {
94+
it('should add a unique hash to the file name when the preserveFileName option is false', done => {
9595
const config = Config.get(Parse.applicationId);
9696
const gridStoreAdapter = new GridFSBucketAdapter(
9797
'mongodb://localhost:27017/parse'
@@ -114,7 +114,7 @@ describe('FilesController', () => {
114114
done();
115115
});
116116

117-
it('should not add a unique hash to the file name when the preserveFileName option is true', (done) => {
117+
it('should not add a unique hash to the file name when the preserveFileName option is true', done => {
118118
const config = Config.get(Parse.applicationId);
119119
const gridStoreAdapter = new GridFSBucketAdapter(
120120
'mongodb://localhost:27017/parse'
@@ -145,7 +145,7 @@ describe('FilesController', () => {
145145
expect(result).toEqual({});
146146
});
147147

148-
it('should reject slashes in file names', (done) => {
148+
it('should reject slashes in file names', done => {
149149
const gridStoreAdapter = new GridFSBucketAdapter(
150150
'mongodb://localhost:27017/parse'
151151
);
@@ -154,7 +154,7 @@ describe('FilesController', () => {
154154
done();
155155
});
156156

157-
it('should also reject slashes in file names', (done) => {
157+
it('should also reject slashes in file names', done => {
158158
const gridStoreAdapter = new GridStoreAdapter(
159159
'mongodb://localhost:27017/parse'
160160
);

0 commit comments

Comments
 (0)