From bc23e97592e917b1faafd87c49a21c231a8d0bde Mon Sep 17 00:00:00 2001 From: Killian Date: Fri, 16 Apr 2021 16:57:38 +0200 Subject: [PATCH 1/4] Adding failling test --- spec/ParseUser.spec.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/spec/ParseUser.spec.js b/spec/ParseUser.spec.js index 91aeb4920a..51d15eb3cd 100644 --- a/spec/ParseUser.spec.js +++ b/spec/ParseUser.spec.js @@ -4031,4 +4031,30 @@ describe('Security Advisory GHSA-8w3j-g983-8jh5', function () { const user = await query.get('1234ABCDEF', { useMasterKey: true }); expect(user.get('authData')).toEqual({ custom: { id: 'linkedID' } }); }); + + describe('issue #6641', () => { + fit('succes to login when masterkey and instalationId is provided and when password is not provided', done => { + const user = new Parse.User(); + user + .save({ + username: 'yolo', + password: 'yolopass', + email: 'yo@lo.com', + }) + .then(async savedUser => { + const installationId = '123456789'; + const query = new Parse.Query(Parse.User); + const result = await query.get(savedUser.id, { + useMasterKey: true, + installationId: installationId, + }); + return await result.logIn({ useMasterKey: true, installationId: installationId }); + }) + .then(() => done()) + .catch(() => { + fail(); + done(); + }); + }); + }); }); From 29c47ea9b80f1c57c78eabae01e0892cb5acd35a Mon Sep 17 00:00:00 2001 From: Killian Date: Mon, 19 Apr 2021 11:17:43 +0200 Subject: [PATCH 2/4] add get session failling test --- spec/ParseUser.spec.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/spec/ParseUser.spec.js b/spec/ParseUser.spec.js index 51d15eb3cd..3b91e38065 100644 --- a/spec/ParseUser.spec.js +++ b/spec/ParseUser.spec.js @@ -4056,5 +4056,32 @@ describe('Security Advisory GHSA-8w3j-g983-8jh5', function () { done(); }); }); + + fit('succes to get session token when masterkey and instalationId is provided', async done => { + const user = new Parse.User(); + user.set('username', 'yolo'); + user.set('password', 'yolopass'); + user.set('email', 'yo@lo.com'); + const savedUser = await user.signUp(); + + const installationId = '123456789'; + const querySession = new Parse.Query(Parse.Session); + const session = await querySession.first(); + + expect(session).not.toBe(undefined); + + const userQuery = new Parse.Query(Parse.User); + const result = await userQuery.get(savedUser.id, { + useMasterKey: true, + installationId: installationId, + }); + + const userSession = await result.getSessionToken({ + useMasterKey: true, + installationId: installationId, + }); + expect(userSession).toEqual(session); + done(); + }); }); }); From 1503245f476838f53b05c44fbc952d5c8fb4c060 Mon Sep 17 00:00:00 2001 From: Killian Date: Mon, 19 Apr 2021 11:52:33 +0200 Subject: [PATCH 3/4] refactor --- spec/Auth.spec.js | 50 +++++++++++++++++++++++++++++++++++++++ spec/ParseUser.spec.js | 53 ------------------------------------------ 2 files changed, 50 insertions(+), 53 deletions(-) diff --git a/spec/Auth.spec.js b/spec/Auth.spec.js index 5ed6bfe941..668542ae29 100644 --- a/spec/Auth.spec.js +++ b/spec/Auth.spec.js @@ -241,4 +241,54 @@ describe('Auth', () => { expect(cloudRoles2.length).toBe(rolesNumber); }); }); + + fit('succes to login when masterkey and instalationId is provided and when password is not provided', async done => { + const user = new Parse.User(); + const savedUser = await user.save({ + username: 'yolo', + password: 'yolopass', + email: 'yo@lo.com', + }); + const installationId = '123456789'; + const query = new Parse.Query(Parse.User); + const result = await query.get(savedUser.id, { + useMasterKey: true, + installationId: installationId, + }); + + try { + await result.logIn({ useMasterKey: true, installationId: installationId }); + } catch (error) { + fail(error.message); + } + + done(); + }); + + fit('succes to get session token when masterkey and instalationId is provided', async done => { + const user = new Parse.User(); + user.set('username', 'yolo'); + user.set('password', 'yolopass'); + user.set('email', 'yo@lo.com'); + const savedUser = await user.signUp(); + + const installationId = '123456789'; + const querySession = new Parse.Query(Parse.Session); + const session = await querySession.first(); + + expect(session).not.toBeUndefined(); + + const userQuery = new Parse.Query(Parse.User); + const result = await userQuery.get(savedUser.id, { + useMasterKey: true, + installationId: installationId, + }); + + const userSession = await result.getSessionToken({ + useMasterKey: true, + installationId: installationId, + }); + expect(userSession).toEqual(session); + done(); + }); }); diff --git a/spec/ParseUser.spec.js b/spec/ParseUser.spec.js index 3b91e38065..91aeb4920a 100644 --- a/spec/ParseUser.spec.js +++ b/spec/ParseUser.spec.js @@ -4031,57 +4031,4 @@ describe('Security Advisory GHSA-8w3j-g983-8jh5', function () { const user = await query.get('1234ABCDEF', { useMasterKey: true }); expect(user.get('authData')).toEqual({ custom: { id: 'linkedID' } }); }); - - describe('issue #6641', () => { - fit('succes to login when masterkey and instalationId is provided and when password is not provided', done => { - const user = new Parse.User(); - user - .save({ - username: 'yolo', - password: 'yolopass', - email: 'yo@lo.com', - }) - .then(async savedUser => { - const installationId = '123456789'; - const query = new Parse.Query(Parse.User); - const result = await query.get(savedUser.id, { - useMasterKey: true, - installationId: installationId, - }); - return await result.logIn({ useMasterKey: true, installationId: installationId }); - }) - .then(() => done()) - .catch(() => { - fail(); - done(); - }); - }); - - fit('succes to get session token when masterkey and instalationId is provided', async done => { - const user = new Parse.User(); - user.set('username', 'yolo'); - user.set('password', 'yolopass'); - user.set('email', 'yo@lo.com'); - const savedUser = await user.signUp(); - - const installationId = '123456789'; - const querySession = new Parse.Query(Parse.Session); - const session = await querySession.first(); - - expect(session).not.toBe(undefined); - - const userQuery = new Parse.Query(Parse.User); - const result = await userQuery.get(savedUser.id, { - useMasterKey: true, - installationId: installationId, - }); - - const userSession = await result.getSessionToken({ - useMasterKey: true, - installationId: installationId, - }); - expect(userSession).toEqual(session); - done(); - }); - }); }); From 9ea9e448765a83d4e6068a1b0287fb5f4d004546 Mon Sep 17 00:00:00 2001 From: Killian Date: Mon, 19 Apr 2021 12:20:42 +0200 Subject: [PATCH 4/4] refactor --- spec/Auth.spec.js | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/spec/Auth.spec.js b/spec/Auth.spec.js index 668542ae29..077758eaa3 100644 --- a/spec/Auth.spec.js +++ b/spec/Auth.spec.js @@ -242,7 +242,7 @@ describe('Auth', () => { }); }); - fit('succes to login when masterkey and instalationId is provided and when password is not provided', async done => { + fit('succes to login when masterkey and instalationId is provided and when password is not provided', async () => { const user = new Parse.User(); const savedUser = await user.save({ username: 'yolo', @@ -261,11 +261,9 @@ describe('Auth', () => { } catch (error) { fail(error.message); } - - done(); }); - fit('succes to get session token when masterkey and instalationId is provided', async done => { + fit('succes to get session token when masterkey and instalationId is provided', async () => { const user = new Parse.User(); user.set('username', 'yolo'); user.set('password', 'yolopass'); @@ -284,11 +282,7 @@ describe('Auth', () => { installationId: installationId, }); - const userSession = await result.getSessionToken({ - useMasterKey: true, - installationId: installationId, - }); + const userSession = result.getSessionToken(); expect(userSession).toEqual(session); - done(); }); });