forked from parse-community/parse-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Regression test parse-community#1649 * Address comments * Comment * Change emails to help debug flaky test failures * More logging info to debug flaky tests
- Loading branch information
1 parent
98f8db3
commit 0850c18
Showing
2 changed files
with
77 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
"use strict"; | ||
|
||
var request = require('request'); | ||
var Config = require("../src/Config"); | ||
let MockEmailAdapterWithOptions = require('./MockEmailAdapterWithOptions'); | ||
let request = require('request'); | ||
let Config = require("../src/Config"); | ||
|
||
describe("Custom Pages Configuration", () => { | ||
it("should set the custom pages", (done) => { | ||
setServerConfiguration({ | ||
|
@@ -62,7 +64,7 @@ describe("Email Verification", () => { | |
var user = new Parse.User(); | ||
user.setPassword("asdf"); | ||
user.setUsername("zxcv"); | ||
user.setEmail('cool_guy@parse.com'); | ||
user.setEmail('testIfEnabled@parse.com'); | ||
user.signUp(null, { | ||
success: function(user) { | ||
expect(emailAdapter.sendVerificationEmail).toHaveBeenCalled(); | ||
|
@@ -150,7 +152,7 @@ describe("Email Verification", () => { | |
expect(emailAdapter.sendVerificationEmail).not.toHaveBeenCalled(); | ||
user.fetch() | ||
.then((user) => { | ||
user.set("email", "cool_guy@parse.com"); | ||
user.set("email", "testWhenUpdating@parse.com"); | ||
return user.save(); | ||
}).then((user) => { | ||
return user.fetch(); | ||
|
@@ -204,7 +206,7 @@ describe("Email Verification", () => { | |
expect(emailAdapter.sendVerificationEmail).not.toHaveBeenCalled(); | ||
user.fetch() | ||
.then((user) => { | ||
user.set("email", "cool_guy@parse.com"); | ||
user.set("email", "testValidLinkWhenUpdating@parse.com"); | ||
return user.save(); | ||
}).then((user) => { | ||
return user.fetch(); | ||
|
@@ -228,7 +230,7 @@ describe("Email Verification", () => { | |
var calls = 0; | ||
var emailAdapter = { | ||
sendMail: function(options){ | ||
expect(options.to).toBe('cool_guy@parse.com'); | ||
expect(options.to).toBe('testSendSimpleAdapter@parse.com'); | ||
if (calls == 0) { | ||
expect(options.subject).toEqual('Please verify your e-mail for My Cool App'); | ||
expect(options.text.match(/verify_email/)).not.toBe(null); | ||
|
@@ -258,15 +260,15 @@ describe("Email Verification", () => { | |
var user = new Parse.User(); | ||
user.setPassword("asdf"); | ||
user.setUsername("zxcv"); | ||
user.set("email", "cool_guy@parse.com"); | ||
user.set("email", "testSendSimpleAdapter@parse.com"); | ||
user.signUp(null, { | ||
success: function(user) { | ||
expect(calls).toBe(1); | ||
user.fetch() | ||
.then((user) => { | ||
return user.save(); | ||
}).then((user) => { | ||
return Parse.User.requestPasswordReset("cool_guy@parse.com").catch((err) => { | ||
return Parse.User.requestPasswordReset("testSendSimpleAdapter@parse.com").catch((err) => { | ||
fail('Should not fail requesting a password'); | ||
done(); | ||
}) | ||
|
@@ -282,6 +284,42 @@ describe("Email Verification", () => { | |
}); | ||
}); | ||
|
||
it('fails if you include an emailAdapter, set verifyUserEmails to false, dont set a publicServerURL, and try to send a password reset email (regression test for #1649)', done => { | ||
setServerConfiguration({ | ||
serverURL: 'http://localhost:8378/1', | ||
appId: 'test', | ||
appName: 'unused', | ||
javascriptKey: 'test', | ||
dotNetKey: 'windows', | ||
clientKey: 'client', | ||
restAPIKey: 'rest', | ||
masterKey: 'test', | ||
collectionPrefix: 'test_', | ||
fileKey: 'test', | ||
verifyUserEmails: false, | ||
emailAdapter: MockEmailAdapterWithOptions({ | ||
fromAddress: '[email protected]', | ||
apiKey: 'k', | ||
domain: 'd', | ||
}), | ||
}) | ||
|
||
let user = new Parse.User(); | ||
user.setPassword("asdf"); | ||
user.setUsername("zxcv"); | ||
user.set("email", "[email protected]"); | ||
user.signUp(null) | ||
.then(user => Parse.User.requestPasswordReset("[email protected]")) | ||
.then(result => { | ||
console.log(result); | ||
fail('sending password reset email should not have succeeded'); | ||
done(); | ||
}, error => { | ||
expect(error.message).toEqual('An appName, publicServerURL, and emailAdapter are required for password reset functionality.') | ||
done(); | ||
}); | ||
}); | ||
|
||
it('does not send verification email if email verification is disabled', done => { | ||
var emailAdapter = { | ||
sendVerificationEmail: () => Promise.resolve(), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters