Skip to content

Commit 92ff61f

Browse files
acinaderdplewis
authored andcommitted
Add two unit tests: (#769)
1. test loggin in with the js sdk to verify documentation change 2. add a negative test that proves we need the master key to link
1 parent aa03b23 commit 92ff61f

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

integration/test/ParseUserTest.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,30 @@ describe('Parse User', () => {
619619
expect(user._isLinked(provider)).toBe(false);
620620
});
621621

622+
it('linked account can login with authData', async () => {
623+
const user = new Parse.User();
624+
user.setUsername('Alice');
625+
user.setPassword('sekrit');
626+
await user.save(null, { useMasterKey: true });
627+
await user._linkWith(provider.getAuthType(), provider.getAuthData(), { useMasterKey: true });
628+
expect(user._isLinked(provider)).toBe(true);
629+
expect(user.authenticated()).toBeFalsy();
630+
Parse.User.enableUnsafeCurrentUser();
631+
const loggedIn = await Parse.User.logInWith(provider.getAuthType(), provider.getAuthData());
632+
expect(loggedIn.authenticated()).toBeTruthy();
633+
});
634+
635+
it('linking un-authenticated user without master key will throw', async (done) => {
636+
const user = new Parse.User();
637+
user.setUsername('Alice');
638+
user.setPassword('sekrit');
639+
await user.save(null, { useMasterKey: true });
640+
user._linkWith(provider.getAuthType(), provider.getAuthData())
641+
.then(() => done.fail('should fail'))
642+
.catch(e => expect(e.message).toBe(`Cannot modify user ${user.id}.`))
643+
.then(done);
644+
});
645+
622646
it('can link with custom auth', async () => {
623647
Parse.User.enableUnsafeCurrentUser();
624648
const provider = {

0 commit comments

Comments
 (0)