diff --git a/corehq/apps/accounting/models.py b/corehq/apps/accounting/models.py index c443c0dbc137..2f2d80cd2a5d 100644 --- a/corehq/apps/accounting/models.py +++ b/corehq/apps/accounting/models.py @@ -532,7 +532,8 @@ def get_domains(self): 'subscriber__domain', flat=True)) def has_enterprise_admin(self, email): - return self.is_customer_billing_account and email in self.enterprise_admin_emails + lower_emails = [e.lower() for e in self.enterprise_admin_emails] + return self.is_customer_billing_account and email.lower() in lower_emails def update_autopay_user(self, new_user, domain): if self.auto_pay_enabled and new_user != self.auto_pay_user: diff --git a/corehq/apps/accounting/tests/test_models.py b/corehq/apps/accounting/tests/test_models.py index 63e18f19f187..4f7e5ae9d679 100644 --- a/corehq/apps/accounting/tests/test_models.py +++ b/corehq/apps/accounting/tests/test_models.py @@ -3,6 +3,7 @@ from django.core import mail from django.db import models +from django.test import SimpleTestCase from unittest import mock @@ -343,3 +344,9 @@ def test_unset_autopay(self, fake_customer): self.assertEqual(self.fake_card.metadata, {"auto_pay_{}".format(self.billing_account.id): 'False'}) self.assertIsNone(self.billing_account.auto_pay_user) self.assertFalse(self.billing_account.auto_pay_enabled) + + +class SimpleBillingAccountTest(SimpleTestCase): + def test_has_enterprise_admin_does_case_insensitive_match(self): + account = BillingAccount(is_customer_billing_account=True, enterprise_admin_emails=['TEST@dimagi.com']) + self.assertTrue(account.has_enterprise_admin('test@DIMAGI.com'))