@@ -118,6 +118,7 @@ const defaultConfiguration = {
118
118
} ,
119
119
auth : {
120
120
// Override the facebook provider
121
+ custom : mockCustom ( ) ,
121
122
facebook : mockFacebook ( ) ,
122
123
myoauth : {
123
124
module : path . resolve ( __dirname , 'myoauth' ) , // relative path as it's run from src
@@ -348,6 +349,24 @@ function range(n) {
348
349
return answer ;
349
350
}
350
351
352
+ function mockCustomAuthenticator ( id , password ) {
353
+ const custom = { } ;
354
+ custom . validateAuthData = function ( authData ) {
355
+ if ( authData . id === id && authData . password . startsWith ( password ) ) {
356
+ return Promise . resolve ( ) ;
357
+ }
358
+ throw new Parse . Error ( Parse . Error . OBJECT_NOT_FOUND , 'not validated' ) ;
359
+ } ;
360
+ custom . validateAppId = function ( ) {
361
+ return Promise . resolve ( ) ;
362
+ } ;
363
+ return custom ;
364
+ }
365
+
366
+ function mockCustom ( ) {
367
+ return mockCustomAuthenticator ( 'fastrde' , 'password' ) ;
368
+ }
369
+
351
370
function mockFacebookAuthenticator ( id , token ) {
352
371
const facebook = { } ;
353
372
facebook . validateAuthData = function ( authData ) {
@@ -406,6 +425,7 @@ global.jequal = jequal;
406
425
global . range = range ;
407
426
global . reconfigureServer = reconfigureServer ;
408
427
global . defaultConfiguration = defaultConfiguration ;
428
+ global . mockCustomAuthenticator = mockCustomAuthenticator ;
409
429
global . mockFacebookAuthenticator = mockFacebookAuthenticator ;
410
430
global . jfail = function ( err ) {
411
431
fail ( JSON . stringify ( err ) ) ;
0 commit comments