Page MenuHomePhabricator

unit test failure when auth.email-domains is configured
Closed, ResolvedPublic

Description

PhabricatorTestCase::generateNewTester() uses a example.com email address, but this fails when the phabricator instance has auth.email-domains configured. For me this caused unit test failures when running arc diff for D14318

Specific errors I saw:

   FAIL  ManiphestTaskTestCase::testTaskAdjacentBlocks
EXCEPTION (Exception): Email address must be @rajant.com
#0 /home/jsmith/code/phabricator-install/phabricator/src/applications/people/editor/PhabricatorUserEditor.php(60): PhabricatorUserEditor->willAddEmail(Object(PhabricatorUserEmail))
#1 /home/jsmith/code/phabricator-install/phabricator/src/infrastructure/testing/PhabricatorTestCase.php(197): PhabricatorUserEditor->createNewUser(Object(PhabricatorUser), Object(PhabricatorUserEmail))
#2 /home/jsmith/code/phabricator-install/phabricator/src/applications/maniphest/__tests__/ManiphestTaskTestCase.php(94): PhabricatorTestCase->generateNewTestUser()
#3 [internal function]: ManiphestTaskTestCase->testTaskAdjacentBlocks()
#4 /home/jsmith/code/arc/arcanist/src/unit/engine/phutil/PhutilTestCase.php(492): call_user_func_array(Array, Array)
#5 /home/jsmith/code/arc/arcanist/src/unit/engine/PhutilUnitTestEngine.php(69): PhutilTestCase->run()
#6 /home/jsmith/code/arc/arcanist/src/unit/engine/ArcanistConfigurationDrivenUnitTestEngine.php(143): PhutilUnitTestEngine->run()
#7 /home/jsmith/code/arc/arcanist/src/workflow/ArcanistUnitWorkflow.php(175): ArcanistConfigurationDrivenUnitTestEngine->run()
#8 /home/jsmith/code/arc/arcanist/src/workflow/ArcanistDiffWorkflow.php(1330): ArcanistUnitWorkflow->run()
#9 /home/jsmith/code/arc/arcanist/src/workflow/ArcanistDiffWorkflow.php(1218): ArcanistDiffWorkflow->runUnit()
#10 /home/jsmith/code/arc/arcanist/src/workflow/ArcanistDiffWorkflow.php(474): ArcanistDiffWorkflow->runLintUnit()
#11 /home/jsmith/code/arc/arcanist/scripts/arcanist.php(382): ArcanistDiffWorkflow->run()
#12 {main}
   FAIL  ManiphestTaskTestCase::testTaskReordering
EXCEPTION (Exception): Email address must be @rajant.com
#0 /home/jsmith/code/phabricator-install/phabricator/src/applications/people/editor/PhabricatorUserEditor.php(60): PhabricatorUserEditor->willAddEmail(Object(PhabricatorUserEmail))
#1 /home/jsmith/code/phabricator-install/phabricator/src/infrastructure/testing/PhabricatorTestCase.php(197): PhabricatorUserEditor->createNewUser(Object(PhabricatorUser), Object(PhabricatorUserEmail))
#2 /home/jsmith/code/phabricator-install/phabricator/src/applications/maniphest/__tests__/ManiphestTaskTestCase.php(12): PhabricatorTestCase->generateNewTestUser()
#3 [internal function]: ManiphestTaskTestCase->testTaskReordering()
#4 /home/jsmith/code/arc/arcanist/src/unit/engine/phutil/PhutilTestCase.php(492): call_user_func_array(Array, Array)
#5 /home/jsmith/code/arc/arcanist/src/unit/engine/PhutilUnitTestEngine.php(69): PhutilTestCase->run()
#6 /home/jsmith/code/arc/arcanist/src/unit/engine/ArcanistConfigurationDrivenUnitTestEngine.php(143): PhutilUnitTestEngine->run()
#7 /home/jsmith/code/arc/arcanist/src/workflow/ArcanistUnitWorkflow.php(175): ArcanistConfigurationDrivenUnitTestEngine->run()
#8 /home/jsmith/code/arc/arcanist/src/workflow/ArcanistDiffWorkflow.php(1330): ArcanistUnitWorkflow->run()
#9 /home/jsmith/code/arc/arcanist/src/workflow/ArcanistDiffWorkflow.php(1218): ArcanistDiffWorkflow->runUnit()
#10 /home/jsmith/code/arc/arcanist/src/workflow/ArcanistDiffWorkflow.php(474): ArcanistDiffWorkflow->runLintUnit()
#11 /home/jsmith/code/arc/arcanist/scripts/arcanist.php(382): ArcanistDiffWorkflow->run()
#12 {main}

Event Timeline

epriestley triaged this task as Normal priority.

To reproduce:

  • Set auth.email-domains to something nonempty.
  • Run arc unit --everything.
  • You should get the test failure described above.

To fix:

  • We're going to always override this value when running unit tests.
  • Find the overrideEnvConfig() call in PhabricatorAccessControlTestCase that resets auth.email-domains for unit tests. This is the override we want, but it only affects a few tests right now.
  • Move it up the class hierarchy to PhabricatorTestCase->willRunTests(), next to all the other environmental overrides there. This will make it affect all tests.
  • Run arc unit --everything again.
  • Tests should be clean, now.