Skip to content

Commit

Permalink
Make enterprise admin match case insensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
jingcheng16 committed Aug 29, 2024
1 parent 6a78832 commit 6d0bc4a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion corehq/apps/accounting/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 7 additions & 0 deletions corehq/apps/accounting/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from django.core import mail
from django.db import models
from django.test import SimpleTestCase

from unittest import mock

Expand Down Expand Up @@ -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=['[email protected]'])
self.assertTrue(account.has_enterprise_admin('[email protected]'))

0 comments on commit 6d0bc4a

Please sign in to comment.