fix(prettier): Properly handle lint-stage files (#6970)
Now handles top level files and recursive files in folders. Set max line length to be 100
This commit is contained in:
@@ -7,8 +7,7 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const MongoStorageAdapter = require('../lib/Adapters/Storage/Mongo/MongoStorageAdapter')
|
||||
.default;
|
||||
const MongoStorageAdapter = require('../lib/Adapters/Storage/Mongo/MongoStorageAdapter').default;
|
||||
const request = require('../lib/request');
|
||||
const passwordCrypto = require('../lib/password');
|
||||
const Config = require('../lib/Config');
|
||||
@@ -87,9 +86,7 @@ describe('Parse.User testing', () => {
|
||||
})
|
||||
.catch(err => {
|
||||
expect(err.status).toBe(404);
|
||||
expect(err.text).toMatch(
|
||||
'{"code":101,"error":"Invalid username/password."}'
|
||||
);
|
||||
expect(err.text).toMatch('{"code":101,"error":"Invalid username/password."}');
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -116,9 +113,7 @@ describe('Parse.User testing', () => {
|
||||
})
|
||||
.catch(err => {
|
||||
expect(err.status).toBe(404);
|
||||
expect(err.text).toMatch(
|
||||
'{"code":101,"error":"Invalid username/password."}'
|
||||
);
|
||||
expect(err.text).toMatch('{"code":101,"error":"Invalid username/password."}');
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -243,8 +238,7 @@ describe('Parse.User testing', () => {
|
||||
});
|
||||
|
||||
it_only_db('mongo')('should let legacy users without ACL login', async () => {
|
||||
const databaseURI =
|
||||
'mongodb://localhost:27017/parseServerMongoAdapterTestDatabase';
|
||||
const databaseURI = 'mongodb://localhost:27017/parseServerMongoAdapterTestDatabase';
|
||||
const adapter = new MongoStorageAdapter({
|
||||
collectionPrefix: 'test_',
|
||||
uri: databaseURI,
|
||||
@@ -262,8 +256,7 @@ describe('Parse.User testing', () => {
|
||||
const collection = await adapter._adaptiveCollection('_User');
|
||||
await collection.insertOne({
|
||||
// the hashed password is 'password' hashed
|
||||
_hashed_password:
|
||||
'$2b$10$mJ2ca2UbCM9hlojYHZxkQe8pyEXe5YMg0nMdvP4AJBeqlTEZJ6/Uu',
|
||||
_hashed_password: '$2b$10$mJ2ca2UbCM9hlojYHZxkQe8pyEXe5YMg0nMdvP4AJBeqlTEZJ6/Uu',
|
||||
_session_token: 'xxx',
|
||||
email: 'xxx@a.b',
|
||||
username: 'oldUser',
|
||||
@@ -419,10 +412,7 @@ describe('Parse.User testing', () => {
|
||||
.then(
|
||||
function () {
|
||||
// This should have failed actually.
|
||||
ok(
|
||||
false,
|
||||
"Shouldn't have been able to log in with garbage session token."
|
||||
);
|
||||
ok(false, "Shouldn't have been able to log in with garbage session token.");
|
||||
},
|
||||
function (error) {
|
||||
ok(error);
|
||||
@@ -576,10 +566,7 @@ describe('Parse.User testing', () => {
|
||||
await user.save({ ACL: acl }, { useMasterKey: true });
|
||||
|
||||
// Try to update from admin... should all work fine
|
||||
await user.save(
|
||||
{ key: 'fromAdmin' },
|
||||
{ sessionToken: admin.getSessionToken() }
|
||||
);
|
||||
await user.save({ key: 'fromAdmin' }, { sessionToken: admin.getSessionToken() });
|
||||
await user.fetch();
|
||||
expect(user.toJSON().key).toEqual('fromAdmin');
|
||||
|
||||
@@ -896,11 +883,7 @@ describe('Parse.User testing', () => {
|
||||
equal(aliceAgain.get('username'), 'alice');
|
||||
equal(aliceAgain.id, alice.id, 'currentUser should have objectId');
|
||||
ok(aliceAgain.getSessionToken(), 'currentUser should have a sessionToken');
|
||||
equal(
|
||||
alice.get('password'),
|
||||
undefined,
|
||||
'currentUser should not have password'
|
||||
);
|
||||
equal(alice.get('password'), undefined, 'currentUser should not have password');
|
||||
done();
|
||||
});
|
||||
|
||||
@@ -920,16 +903,9 @@ describe('Parse.User testing', () => {
|
||||
delete Parse.User._currentUserMatchesDisk;
|
||||
|
||||
const userFromDisk = Parse.User.current();
|
||||
equal(
|
||||
userFromDisk.get('password'),
|
||||
undefined,
|
||||
'password should not be in attributes'
|
||||
);
|
||||
equal(userFromDisk.get('password'), undefined, 'password should not be in attributes');
|
||||
equal(userFromDisk.id, id, 'id should be set');
|
||||
ok(
|
||||
userFromDisk.getSessionToken(),
|
||||
'currentUser should have a sessionToken'
|
||||
);
|
||||
ok(userFromDisk.getSessionToken(), 'currentUser should have a sessionToken');
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -963,11 +939,7 @@ describe('Parse.User testing', () => {
|
||||
'saving user should not remove existing fields'
|
||||
);
|
||||
|
||||
equal(
|
||||
userInMemory.get('some_field'),
|
||||
1,
|
||||
'saving user should save specified field'
|
||||
);
|
||||
equal(userInMemory.get('some_field'), 1, 'saving user should save specified field');
|
||||
|
||||
equal(
|
||||
userInMemory.get('password'),
|
||||
@@ -993,10 +965,7 @@ describe('Parse.User testing', () => {
|
||||
|
||||
ok(userInMemory.createdAt instanceof Date);
|
||||
|
||||
ok(
|
||||
userInMemory.getSessionToken(),
|
||||
'user should have a sessionToken after saving'
|
||||
);
|
||||
ok(userInMemory.getSessionToken(), 'user should have a sessionToken after saving');
|
||||
|
||||
// Force the current user to read from localStorage, and check again
|
||||
delete Parse.User._currentUser;
|
||||
@@ -1009,11 +978,7 @@ describe('Parse.User testing', () => {
|
||||
'userFromDisk should have previously existing fields'
|
||||
);
|
||||
|
||||
equal(
|
||||
userFromDisk.get('some_field'),
|
||||
1,
|
||||
'userFromDisk should have saved field'
|
||||
);
|
||||
equal(userFromDisk.get('some_field'), 1, 'userFromDisk should have saved field');
|
||||
|
||||
equal(
|
||||
userFromDisk.get('password'),
|
||||
@@ -1039,10 +1004,7 @@ describe('Parse.User testing', () => {
|
||||
|
||||
ok(userFromDisk.createdAt instanceof Date);
|
||||
|
||||
ok(
|
||||
userFromDisk.getSessionToken(),
|
||||
'userFromDisk should have a sessionToken'
|
||||
);
|
||||
ok(userFromDisk.getSessionToken(), 'userFromDisk should have a sessionToken');
|
||||
|
||||
done();
|
||||
},
|
||||
@@ -1239,10 +1201,7 @@ describe('Parse.User testing', () => {
|
||||
ok(model.extended(), 'Should have used subclass.');
|
||||
strictEqual(provider.authData.id, provider.synchronizedUserId);
|
||||
strictEqual(provider.authData.access_token, provider.synchronizedAuthToken);
|
||||
strictEqual(
|
||||
provider.authData.expiration_date,
|
||||
provider.synchronizedExpiration
|
||||
);
|
||||
strictEqual(provider.authData.expiration_date, provider.synchronizedExpiration);
|
||||
ok(model._isLinked('facebook'), 'User should be linked to facebook');
|
||||
done();
|
||||
});
|
||||
@@ -1288,10 +1247,7 @@ describe('Parse.User testing', () => {
|
||||
ok(model.extended(), 'Should have used subclass.');
|
||||
strictEqual(provider.authData.id, provider.synchronizedUserId);
|
||||
strictEqual(provider.authData.access_token, provider.synchronizedAuthToken);
|
||||
strictEqual(
|
||||
provider.authData.expiration_date,
|
||||
provider.synchronizedExpiration
|
||||
);
|
||||
strictEqual(provider.authData.expiration_date, provider.synchronizedExpiration);
|
||||
ok(model._isLinked('facebook'), 'User should be linked to facebook');
|
||||
|
||||
Parse.Cloud.run('checkLogin').then(done, done);
|
||||
@@ -1299,10 +1255,7 @@ describe('Parse.User testing', () => {
|
||||
|
||||
it('log in with provider and update token', async done => {
|
||||
const provider = getMockFacebookProvider();
|
||||
const secondProvider = getMockFacebookProviderWithIdToken(
|
||||
'8675309',
|
||||
'jenny_valid_token'
|
||||
);
|
||||
const secondProvider = getMockFacebookProviderWithIdToken('8675309', 'jenny_valid_token');
|
||||
Parse.User._registerAuthenticationProvider(provider);
|
||||
await Parse.User._logInWith('facebook');
|
||||
Parse.User._registerAuthenticationProvider(secondProvider);
|
||||
@@ -1384,10 +1337,7 @@ describe('Parse.User testing', () => {
|
||||
ok(model.extended(), 'Should have used the subclass.');
|
||||
strictEqual(provider.authData.id, provider.synchronizedUserId);
|
||||
strictEqual(provider.authData.access_token, provider.synchronizedAuthToken);
|
||||
strictEqual(
|
||||
provider.authData.expiration_date,
|
||||
provider.synchronizedExpiration
|
||||
);
|
||||
strictEqual(provider.authData.expiration_date, provider.synchronizedExpiration);
|
||||
ok(model._isLinked('facebook'), 'User should be linked to facebook');
|
||||
|
||||
Parse.User.logOut().then(async () => {
|
||||
@@ -1395,10 +1345,7 @@ describe('Parse.User testing', () => {
|
||||
provider.loggedOut = false;
|
||||
const innerModel = await Parse.User._logInWith('facebook');
|
||||
ok(innerModel instanceof Parse.User, 'Model should be a Parse.User');
|
||||
ok(
|
||||
innerModel === Parse.User.current(),
|
||||
'Returned model should be the current user'
|
||||
);
|
||||
ok(innerModel === Parse.User.current(), 'Returned model should be the current user');
|
||||
ok(provider.authData.id === provider.synchronizedUserId);
|
||||
ok(provider.authData.access_token === provider.synchronizedAuthToken);
|
||||
ok(innerModel._isLinked('facebook'), 'User should be linked to facebook');
|
||||
@@ -1584,10 +1531,7 @@ describe('Parse.User testing', () => {
|
||||
strictEqual(Parse.User.current(), model);
|
||||
strictEqual(provider.authData.id, provider.synchronizedUserId);
|
||||
strictEqual(provider.authData.access_token, provider.synchronizedAuthToken);
|
||||
strictEqual(
|
||||
provider.authData.expiration_date,
|
||||
provider.synchronizedExpiration
|
||||
);
|
||||
strictEqual(provider.authData.expiration_date, provider.synchronizedExpiration);
|
||||
ok(model._isLinked('facebook'), 'User should be linked');
|
||||
done();
|
||||
});
|
||||
@@ -1606,10 +1550,7 @@ describe('Parse.User testing', () => {
|
||||
strictEqual(Parse.User.current(), model);
|
||||
strictEqual(provider.authData.id, provider.synchronizedUserId);
|
||||
strictEqual(provider.authData.access_token, provider.synchronizedAuthToken);
|
||||
strictEqual(
|
||||
provider.authData.expiration_date,
|
||||
provider.synchronizedExpiration
|
||||
);
|
||||
strictEqual(provider.authData.expiration_date, provider.synchronizedExpiration);
|
||||
ok(model._isLinked('facebook'), 'User should be linked.');
|
||||
const user2 = new Parse.User();
|
||||
user2.set('username', 'testLinkWithProviderToAlreadyLinkedUser2');
|
||||
@@ -1704,10 +1645,7 @@ describe('Parse.User testing', () => {
|
||||
ok(model.extended(), 'Should have used the subclass.');
|
||||
strictEqual(provider.authData.id, provider.synchronizedUserId);
|
||||
strictEqual(provider.authData.access_token, provider.synchronizedAuthToken);
|
||||
strictEqual(
|
||||
provider.authData.expiration_date,
|
||||
provider.synchronizedExpiration
|
||||
);
|
||||
strictEqual(provider.authData.expiration_date, provider.synchronizedExpiration);
|
||||
ok(model._isLinked('facebook'), 'User should be linked to facebook.');
|
||||
await model._unlinkFrom('facebook');
|
||||
ok(!model._isLinked('facebook'), 'User should not be linked.');
|
||||
@@ -1726,10 +1664,7 @@ describe('Parse.User testing', () => {
|
||||
ok(model.extended(), 'Should have used the subclass.');
|
||||
strictEqual(provider.authData.id, provider.synchronizedUserId);
|
||||
strictEqual(provider.authData.access_token, provider.synchronizedAuthToken);
|
||||
strictEqual(
|
||||
provider.authData.expiration_date,
|
||||
provider.synchronizedExpiration
|
||||
);
|
||||
strictEqual(provider.authData.expiration_date, provider.synchronizedExpiration);
|
||||
ok(model._isLinked('facebook'), 'User should be linked to facebook');
|
||||
|
||||
await model._unlinkFrom('facebook');
|
||||
@@ -1756,10 +1691,7 @@ describe('Parse.User testing', () => {
|
||||
ok(model.extended(), 'Should have used the subclass.');
|
||||
strictEqual(provider.authData.id, provider.synchronizedUserId);
|
||||
strictEqual(provider.authData.access_token, provider.synchronizedAuthToken);
|
||||
strictEqual(
|
||||
provider.authData.expiration_date,
|
||||
provider.synchronizedExpiration
|
||||
);
|
||||
strictEqual(provider.authData.expiration_date, provider.synchronizedExpiration);
|
||||
ok(model._isLinked('facebook'), 'User should be linked to facebook');
|
||||
Parse.User._registerAuthenticationProvider(mockProvider);
|
||||
const objectId = model.id;
|
||||
@@ -1772,10 +1704,7 @@ describe('Parse.User testing', () => {
|
||||
|
||||
it('link multiple providers and updates token', async done => {
|
||||
const provider = getMockFacebookProvider();
|
||||
const secondProvider = getMockFacebookProviderWithIdToken(
|
||||
'8675309',
|
||||
'jenny_valid_token'
|
||||
);
|
||||
const secondProvider = getMockFacebookProviderWithIdToken('8675309', 'jenny_valid_token');
|
||||
|
||||
const mockProvider = getMockMyOauthProvider();
|
||||
Parse.User._registerAuthenticationProvider(provider);
|
||||
@@ -1802,10 +1731,7 @@ describe('Parse.User testing', () => {
|
||||
ok(model.extended(), 'Should have used the subclass.');
|
||||
strictEqual(provider.authData.id, provider.synchronizedUserId);
|
||||
strictEqual(provider.authData.access_token, provider.synchronizedAuthToken);
|
||||
strictEqual(
|
||||
provider.authData.expiration_date,
|
||||
provider.synchronizedExpiration
|
||||
);
|
||||
strictEqual(provider.authData.expiration_date, provider.synchronizedExpiration);
|
||||
ok(model._isLinked('facebook'), 'User should be linked to facebook');
|
||||
Parse.User._registerAuthenticationProvider(mockProvider);
|
||||
const objectId = model.id;
|
||||
@@ -1857,9 +1783,7 @@ describe('Parse.User testing', () => {
|
||||
// make sure the location header is properly set
|
||||
expect(userId).not.toBeUndefined();
|
||||
expect(body.objectId).toEqual(userId);
|
||||
expect(response.headers.location).toEqual(
|
||||
Parse.serverURL + '/users/' + userId
|
||||
);
|
||||
expect(response.headers.location).toEqual(Parse.serverURL + '/users/' + userId);
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -1891,9 +1815,7 @@ describe('Parse.User testing', () => {
|
||||
// Simulate a remotely expired token (like a short lived one)
|
||||
// In this case, we want success as it was valid once.
|
||||
// If the client needs an updated one, do lock the user out
|
||||
defaultConfiguration.auth.shortLivedAuth.setValidAccessToken(
|
||||
'otherToken'
|
||||
);
|
||||
defaultConfiguration.auth.shortLivedAuth.setValidAccessToken('otherToken');
|
||||
return Parse.User._logInWith('shortLivedAuth', {});
|
||||
})
|
||||
.then(
|
||||
@@ -1932,9 +1854,7 @@ describe('Parse.User testing', () => {
|
||||
// Simulate a remotely expired token (like a short lived one)
|
||||
// In this case, we want success as it was valid once.
|
||||
// If the client needs an updated one, do lock the user out
|
||||
defaultConfiguration.auth.shortLivedAuth.setValidAccessToken(
|
||||
'otherToken'
|
||||
);
|
||||
defaultConfiguration.auth.shortLivedAuth.setValidAccessToken('otherToken');
|
||||
return request({
|
||||
method: 'PUT',
|
||||
url: Parse.serverURL + '/users/' + Parse.User.current().id,
|
||||
@@ -2176,10 +2096,7 @@ describe('Parse.User testing', () => {
|
||||
equal(users.length, 2);
|
||||
users.forEach(user => {
|
||||
expect(user.getSessionToken()).toBeUndefined();
|
||||
ok(
|
||||
!user.getSessionToken(),
|
||||
'user should not have a session token.'
|
||||
);
|
||||
ok(!user.getSessionToken(), 'user should not have a session token.');
|
||||
});
|
||||
done();
|
||||
},
|
||||
@@ -2286,10 +2203,7 @@ describe('Parse.User testing', () => {
|
||||
user2.set('username', 'Test1');
|
||||
user2.set('password', 'test');
|
||||
await expectAsync(user2.signUp()).toBeRejectedWith(
|
||||
new Parse.Error(
|
||||
Parse.Error.USERNAME_TAKEN,
|
||||
'Account already exists for this username.'
|
||||
)
|
||||
new Parse.Error(Parse.Error.USERNAME_TAKEN, 'Account already exists for this username.')
|
||||
);
|
||||
});
|
||||
|
||||
@@ -2303,10 +2217,7 @@ describe('Parse.User testing', () => {
|
||||
user2.setUsername('Test1');
|
||||
user2.setPassword('test');
|
||||
await expectAsync(user2.signUp()).toBeRejectedWith(
|
||||
new Parse.Error(
|
||||
Parse.Error.USERNAME_TAKEN,
|
||||
'Account already exists for this username.'
|
||||
)
|
||||
new Parse.Error(Parse.Error.USERNAME_TAKEN, 'Account already exists for this username.')
|
||||
);
|
||||
});
|
||||
|
||||
@@ -2322,10 +2233,7 @@ describe('Parse.User testing', () => {
|
||||
user2.setPassword('test');
|
||||
user2.setEmail('Test@Example.Com');
|
||||
await expectAsync(user2.signUp()).toBeRejectedWith(
|
||||
new Parse.Error(
|
||||
Parse.Error.EMAIL_TAKEN,
|
||||
'Account already exists for this email address.'
|
||||
)
|
||||
new Parse.Error(Parse.Error.EMAIL_TAKEN, 'Account already exists for this email address.')
|
||||
);
|
||||
});
|
||||
|
||||
@@ -2344,10 +2252,7 @@ describe('Parse.User testing', () => {
|
||||
|
||||
user2.setEmail('Test@Example.Com');
|
||||
await expectAsync(user2.save()).toBeRejectedWith(
|
||||
new Parse.Error(
|
||||
Parse.Error.EMAIL_TAKEN,
|
||||
'Account already exists for this email address.'
|
||||
)
|
||||
new Parse.Error(Parse.Error.EMAIL_TAKEN, 'Account already exists for this email address.')
|
||||
);
|
||||
});
|
||||
|
||||
@@ -2375,9 +2280,7 @@ describe('Parse.User testing', () => {
|
||||
];
|
||||
|
||||
// need a bunch of spare random strings per api request
|
||||
spyOn(cryptoUtils, 'randomString').and.returnValues(
|
||||
...insensitiveCollisions
|
||||
);
|
||||
spyOn(cryptoUtils, 'randomString').and.returnValues(...insensitiveCollisions);
|
||||
});
|
||||
|
||||
it('should not fail on case insensitive matches', async () => {
|
||||
@@ -2721,8 +2624,7 @@ describe('Parse.User testing', () => {
|
||||
});
|
||||
|
||||
it('password format matches hosted parse', done => {
|
||||
const hashed =
|
||||
'$2a$10$8/wZJyEuiEaobBBqzTG.jeY.XSFJd0rzaN//ososvEI4yLqI.4aie';
|
||||
const hashed = '$2a$10$8/wZJyEuiEaobBBqzTG.jeY.XSFJd0rzaN//ososvEI4yLqI.4aie';
|
||||
passwordCrypto.compare('test', hashed).then(
|
||||
pass => {
|
||||
expect(pass).toBe(true);
|
||||
@@ -2876,8 +2778,7 @@ describe('Parse.User testing', () => {
|
||||
'_User',
|
||||
{
|
||||
username: 'user',
|
||||
_hashed_password:
|
||||
'$2a$10$8/wZJyEuiEaobBBqzTG.jeY.XSFJd0rzaN//ososvEI4yLqI.4aie',
|
||||
_hashed_password: '$2a$10$8/wZJyEuiEaobBBqzTG.jeY.XSFJd0rzaN//ososvEI4yLqI.4aie',
|
||||
_auth_data_facebook: null,
|
||||
},
|
||||
{}
|
||||
@@ -2911,8 +2812,7 @@ describe('Parse.User testing', () => {
|
||||
'_User',
|
||||
{
|
||||
username: 'user',
|
||||
_hashed_password:
|
||||
'$2a$10$8/wZJyEuiEaobBBqzTG.jeY.XSFJd0rzaN//ososvEI4yLqI.4aie',
|
||||
_hashed_password: '$2a$10$8/wZJyEuiEaobBBqzTG.jeY.XSFJd0rzaN//ososvEI4yLqI.4aie',
|
||||
_auth_data_facebook: null,
|
||||
},
|
||||
{}
|
||||
@@ -3114,9 +3014,7 @@ describe('Parse.User testing', () => {
|
||||
expect(emailCalled).toBeTruthy();
|
||||
expect(emailOptions).toBeDefined();
|
||||
expect(err.status).toBe(400);
|
||||
expect(err.text).toMatch(
|
||||
'{"code":125,"error":"you must provide a valid email string"}'
|
||||
);
|
||||
expect(err.text).toMatch('{"code":125,"error":"you must provide a valid email string"}');
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -3405,9 +3303,7 @@ describe('Parse.User testing', () => {
|
||||
done();
|
||||
})
|
||||
.catch(err => {
|
||||
expect(err.message).toBe(
|
||||
"Clients aren't allowed to manually update email verification."
|
||||
);
|
||||
expect(err.message).toBe("Clients aren't allowed to manually update email verification.");
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -3525,8 +3421,7 @@ describe('Parse.User testing', () => {
|
||||
})
|
||||
.then(() =>
|
||||
request({
|
||||
url:
|
||||
'http://localhost:8378/1/login?email=test@email.com&username=hello&password=world',
|
||||
url: 'http://localhost:8378/1/login?email=test@email.com&username=hello&password=world',
|
||||
headers: {
|
||||
'X-Parse-Application-Id': Parse.applicationId,
|
||||
'X-Parse-REST-API-Key': 'rest',
|
||||
@@ -3629,9 +3524,7 @@ describe('Parse.User testing', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
}).pend(
|
||||
'this test fails. See: https://github.com/parse-community/parse-server/issues/5097'
|
||||
);
|
||||
}).pend('this test fails. See: https://github.com/parse-community/parse-server/issues/5097');
|
||||
|
||||
it('should be able to update user with authData passed', done => {
|
||||
let objectId;
|
||||
@@ -4033,44 +3926,35 @@ describe('Parse.User testing', () => {
|
||||
});
|
||||
|
||||
describe('issue #4897', () => {
|
||||
it_only_db('mongo')(
|
||||
'should be able to login with a legacy user (no ACL)',
|
||||
async () => {
|
||||
// This issue is a side effect of the locked users and legacy users which don't have ACL's
|
||||
// In this scenario, a legacy user wasn't be able to login as there's no ACL on it
|
||||
const database = Config.get(Parse.applicationId).database;
|
||||
const collection = await database.adapter._adaptiveCollection('_User');
|
||||
await collection.insertOne({
|
||||
_id: 'ABCDEF1234',
|
||||
name: '<some_name>',
|
||||
email: '<some_email>',
|
||||
username: '<some_username>',
|
||||
_hashed_password: '<some_password>',
|
||||
_auth_data_facebook: {
|
||||
id: '8675309',
|
||||
access_token: 'jenny',
|
||||
},
|
||||
sessionToken: '<some_session_token>',
|
||||
});
|
||||
const provider = getMockFacebookProvider();
|
||||
Parse.User._registerAuthenticationProvider(provider);
|
||||
const model = await Parse.User._logInWith('facebook', {});
|
||||
expect(model.id).toBe('ABCDEF1234');
|
||||
ok(model instanceof Parse.User, 'Model should be a Parse.User');
|
||||
strictEqual(Parse.User.current(), model);
|
||||
ok(model.extended(), 'Should have used subclass.');
|
||||
strictEqual(provider.authData.id, provider.synchronizedUserId);
|
||||
strictEqual(
|
||||
provider.authData.access_token,
|
||||
provider.synchronizedAuthToken
|
||||
);
|
||||
strictEqual(
|
||||
provider.authData.expiration_date,
|
||||
provider.synchronizedExpiration
|
||||
);
|
||||
ok(model._isLinked('facebook'), 'User should be linked to facebook');
|
||||
}
|
||||
);
|
||||
it_only_db('mongo')('should be able to login with a legacy user (no ACL)', async () => {
|
||||
// This issue is a side effect of the locked users and legacy users which don't have ACL's
|
||||
// In this scenario, a legacy user wasn't be able to login as there's no ACL on it
|
||||
const database = Config.get(Parse.applicationId).database;
|
||||
const collection = await database.adapter._adaptiveCollection('_User');
|
||||
await collection.insertOne({
|
||||
_id: 'ABCDEF1234',
|
||||
name: '<some_name>',
|
||||
email: '<some_email>',
|
||||
username: '<some_username>',
|
||||
_hashed_password: '<some_password>',
|
||||
_auth_data_facebook: {
|
||||
id: '8675309',
|
||||
access_token: 'jenny',
|
||||
},
|
||||
sessionToken: '<some_session_token>',
|
||||
});
|
||||
const provider = getMockFacebookProvider();
|
||||
Parse.User._registerAuthenticationProvider(provider);
|
||||
const model = await Parse.User._logInWith('facebook', {});
|
||||
expect(model.id).toBe('ABCDEF1234');
|
||||
ok(model instanceof Parse.User, 'Model should be a Parse.User');
|
||||
strictEqual(Parse.User.current(), model);
|
||||
ok(model.extended(), 'Should have used subclass.');
|
||||
strictEqual(provider.authData.id, provider.synchronizedUserId);
|
||||
strictEqual(provider.authData.access_token, provider.synchronizedAuthToken);
|
||||
strictEqual(provider.authData.expiration_date, provider.synchronizedExpiration);
|
||||
ok(model._isLinked('facebook'), 'User should be linked to facebook');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user