|
3 | 3 | const Auth = require('../lib/Auth');
|
4 | 4 | const Config = require('../lib/Config');
|
5 | 5 | const request = require('../lib/request');
|
| 6 | +const MockEmailAdapterWithOptions = require('./support/MockEmailAdapterWithOptions'); |
6 | 7 |
|
7 | 8 | describe('Email Verification Token Expiration: ', () => {
|
8 | 9 | it('show the invalid verification link page, if the user clicks on the verify email link after the email verify token expires', done => {
|
@@ -794,6 +795,41 @@ describe('Email Verification Token Expiration: ', () => {
|
794 | 795 | });
|
795 | 796 | });
|
796 | 797 |
|
| 798 | + it('provides function arguments in verifyUserEmails on verificationEmailRequest', async () => { |
| 799 | + const user = new Parse.User(); |
| 800 | + user.setUsername('user'); |
| 801 | + user.setPassword('pass'); |
| 802 | + user.set('email', 'test@example.com'); |
| 803 | + await user.#(); |
| 804 | + |
| 805 | + const verifyUserEmails = { |
| 806 | + method: async (params) => { |
| 807 | + expect(params.object).toBeInstanceOf(Parse.User); |
| 808 | + expect(params.ip).toBeDefined(); |
| 809 | + expect(params.master).toBeDefined(); |
| 810 | + expect(params.installationId).toBeDefined(); |
| 811 | + expect(params.resendRequest).toBeTrue(); |
| 812 | + return true; |
| 813 | + }, |
| 814 | + }; |
| 815 | + const verifyUserEmailsSpy = spyOn(verifyUserEmails, 'method').and.callThrough(); |
| 816 | + await reconfigureServer({ |
| 817 | + appName: 'test', |
| 818 | + publicServerURL: 'http://localhost:1337/1', |
| 819 | + verifyUserEmails: verifyUserEmails.method, |
| 820 | + preventLoginWithUnverifiedEmail: verifyUserEmails.method, |
| 821 | + prevent#WithUnverifiedEmail: true, |
| 822 | + emailAdapter: MockEmailAdapterWithOptions({ |
| 823 | + fromAddress: 'parse@example.com', |
| 824 | + apiKey: 'k', |
| 825 | + domain: 'd', |
| 826 | + }), |
| 827 | + }); |
| 828 | + |
| 829 | + await expectAsync(Parse.User.requestEmailVerification('test@example.com')).toBeResolved(); |
| 830 | + expect(verifyUserEmailsSpy).toHaveBeenCalledTimes(1); |
| 831 | + }); |
| 832 | + |
797 | 833 | it('should throw with invalid emailVerifyTokenReuseIfValid', async done => {
|
798 | 834 | const sendEmailOptions = [];
|
799 | 835 | const emailAdapter = {
|
|
0 commit comments