Browse Source

fix(api): use LOCAL_PUBLIC_SUFFIX setting in tests

Nils Wisiol 5 years ago
parent
commit
5e3a8ecd40
2 changed files with 6 additions and 2 deletions
  1. 4 0
      api/desecapi/tests/base.py
  2. 2 2
      api/desecapi/tests/test_user_management.py

+ 4 - 0
api/desecapi/tests/base.py

@@ -681,6 +681,10 @@ class DesecTestCase(MockPDNSTestCase):
             suffix = random.sample(suffix, 1)[0]
         return (random.choice(string.ascii_letters) + cls.random_string() + '--test' + '.' + suffix).lower()
 
+    @classmethod
+    def has_local_suffix(cls, domain_name: str):
+        return any([domain_name.endswith(f'.{suffix}') for suffix in settings.LOCAL_PUBLIC_SUFFIXES])
+
     @classmethod
     def create_token(cls, user):
         token = Token.objects.create(user=user)

+ 2 - 2
api/desecapi/tests/test_user_management.py

@@ -250,7 +250,7 @@ class UserManagementTestCase(DesecTestCase, PublicSuffixMockMixin):
         )
 
     def assertRegistrationWithDomainVerificationSuccessResponse(self, response, domain=None):
-        if domain and domain.endswith('.dedyn.io'):
+        if domain and self.has_local_suffix(domain):
             text = 'Success! Here is the password'
         else:
             text = 'Success! Please check the docs for the next steps'
@@ -390,7 +390,7 @@ class UserManagementTestCase(DesecTestCase, PublicSuffixMockMixin):
             self.assertVerificationFailureInvalidCodeResponse(response)
             return
 
-        if domain.endswith('.dedyn.io'):
+        if self.has_local_suffix(domain):
             cm = self.requests_desec_domain_creation_auto_delegation(domain)
         else:
             cm = self.requests_desec_domain_creation(domain)