Page MenuHomePhabricator

ApiCreateAccountTest::testValid() sends confirmation mail to invalid address
Closed, ResolvedPublic

Description

When $wgEmailAuthentication is set to true, ApiCreateAccountTest::testValid() sends e-mail address confirmation mail to invalid address test@domain.test.

It is very annoying to receive a "Delivery Status Notification" mail from my provider saying that the e-mail address mentioned above is invalid.


Version: unspecified
Severity: normal

Details

Reference
bz44192

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 1:29 AM
bzimport set Reference to bz44192.

Are there any unit tests that legitimately need email to be sent? Or would it be fine to simply just add an if statement to User::sendMail to not send mail in the case of unit tests.

To easiest to me seems to remove the e-mail address from the request when creating the account; I don't like the idea to have a special case for unit tests in User or UserMailer.

OK, but then if $wgEmailConfirmToEdit is turned on, then the test just fails.

Setting 'email' => '', on line 54 works well for me.

If you give an empty email when $wgEmailConfirmToEdit is set to true, a UsageException will be thrown saying the email parameter must be set. Switching from dependence on one configuration variable to another doesn't really fix the problem.

Oh yes, I forgot about $wgEmailConfirmToEdit...

In this case the easiest seems to force $wgEmailAuthentication to false so that it won't send any mail away during the tests.

(In reply to comment #6)

In this case the easiest seems to force $wgEmailAuthentication to false so
that it won't send any mail away during the tests.

I've opened Bug 44206 to stub out email handling.

(In reply to comment #8)

Gerrit change #48247

Status Merged

(In reply to comment #11)

Generic solution to disable all email:
https://gerrit.wikimedia.org/r/#/c/51576/

successfully merged