Forráskód Böngészése

feat(api): always return domain details after account activation

Peter Thomassen 5 éve
szülő
commit
0313a579f8
2 módosított fájl, 10 hozzáadás és 6 törlés
  1. 8 5
      api/desecapi/tests/test_user_management.py
  2. 2 1
      api/desecapi/views.py

+ 8 - 5
api/desecapi/tests/test_user_management.py

@@ -283,10 +283,13 @@ class UserManagementTestCase(DesecTestCase, PublicSuffixMockMixin):
 
     def assertRegistrationWithDomainVerificationSuccessResponse(self, response, domain=None, email=None):
         self.assertNoEmailSent()  # do not send email in any case
-        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'
+        text = 'Success! Please check the docs for the next steps'
+        if domain:
+            has_local_suffix = self.has_local_suffix(domain)
+            if has_local_suffix:
+                text = 'Success! Here is the password'
+            self.assertEqual('keys' in response.data['domain'], not has_local_suffix)
+            self.assertEqual(response.data['domain']['name'], domain)
         self.assertContains(response=response, text=text, status_code=status.HTTP_200_OK)
 
     def assertResetPasswordSuccessResponse(self, response):
@@ -430,7 +433,7 @@ class UserManagementTestCase(DesecTestCase, PublicSuffixMockMixin):
         if self.has_local_suffix(domain):
             cm = self.requests_desec_domain_creation_auto_delegation(domain)
         else:
-            cm = self.requests_desec_domain_creation(domain)[:-1]
+            cm = self.requests_desec_domain_creation(domain)
         with self.assertPdnsRequests(cm):
             response = self.client.verify(confirmation_link)
         self.assertRegistrationWithDomainVerificationSuccessResponse(response, domain, email)

+ 2 - 1
api/desecapi/views.py

@@ -681,7 +681,8 @@ class AuthenticatedActivateUserActionView(AuthenticatedActionView):
             })
         else:
             return Response({
-                'detail': 'Success! Please check the docs for the next steps, https://desec.readthedocs.io/.'
+                'detail': 'Success! Please check the docs for the next steps, https://desec.readthedocs.io/.',
+                'domain': serializers.DomainSerializer(domain, include_keys=True).data,
             })