Repository: cisagov/manage.get.gov

Issue:
Subdomain request checking and error presentation
### Story

As a domain applicant, if I'm typing a subdomain on the domain page
I want to be presented with an error
so that I know that I can't submit a subdomain.


### Acceptance Criteria

- [ ] Leverage the existing in page error handling to present the user with content derived from #324 
- [ ] Add a unit test to check validation
- [ ] Submissions should be denied if two dots are present. (Check for the edge case when two "." are not separated by characters:   that state being "..")
- [ ] Submissions should be denied if two dots are present. (Check for the edge case when a "." is at the beginning if the domain without characters in front:   that state being ".something."
- [ ] Confirm other edge cases

### Additional Context

_No response_

### Issue Links

Blocked by: #324
Related to: #720 


Discussion:
Lower priority.

Resolving patch:
diff --git a/src/api/views.py b/src/api/views.py
--- a/src/api/views.py
+++ b/src/api/views.py
@@ -84,6 +84,7 @@ def available(request, domain=""):
     Response is a JSON dictionary with the key "available" and value true or
     false.
     """
+    domain = request.GET.get("domain", "")
     DraftDomain = apps.get_model("registrar.DraftDomain")
     # validate that the given domain could be a domain name and fail early if
     # not.
diff --git a/src/registrar/config/urls.py b/src/registrar/config/urls.py
--- a/src/registrar/config/urls.py
+++ b/src/registrar/config/urls.py
@@ -73,7 +73,7 @@
     path("health/", views.health),
     path("openid/", include("djangooidc.urls")),
     path("register/", include((application_urls, APPLICATION_NAMESPACE))),
-    path("api/v1/available/<domain>", available, name="available"),
+    path("api/v1/available/", available, name="available"),
     path("api/v1/get-report/current-federal", get_current_federal, name="get-current-federal"),
     path("api/v1/get-report/current-full", get_current_full, name="get-current-full"),
     path(


Test patch:
diff --git a/src/api/tests/test_available.py b/src/api/tests/test_available.py
--- a/src/api/tests/test_available.py
+++ b/src/api/tests/test_available.py
@@ -15,7 +15,7 @@
     commands,
 )
 
-API_BASE_PATH = "/api/v1/available/"
+API_BASE_PATH = "/api/v1/available/?domain="
 
 
 class AvailableViewTest(MockEppLib):
diff --git a/src/registrar/tests/test_forms.py b/src/registrar/tests/test_forms.py
--- a/src/registrar/tests/test_forms.py
+++ b/src/registrar/tests/test_forms.py
@@ -74,6 +74,24 @@ def test_requested_domain_ending_dotcom_invalid(self):
             ["Enter the .gov domain you want without any periods."],
         )
 
+    def test_requested_domain_two_dots_invalid(self):
+        """don't accept domains that are subdomains"""
+        form = DotGovDomainForm(data={"requested_domain": "sub.top-level-agency.gov"})
+        self.assertEqual(
+            form.errors["requested_domain"],
+            ["Enter the .gov domain you want without any periods."],
+        )
+        form = DotGovDomainForm(data={"requested_domain": ".top-level-agency.gov"})
+        self.assertEqual(
+            form.errors["requested_domain"],
+            ["Enter the .gov domain you want without any periods."],
+        )
+        form = DotGovDomainForm(data={"requested_domain": "..gov"})
+        self.assertEqual(
+            form.errors["requested_domain"],
+            ["Enter the .gov domain you want without any periods."],
+        )
+
     def test_requested_domain_invalid_characters(self):
         """must be a valid .gov domain name."""
         form = DotGovDomainForm(data={"requested_domain": "underscores_forever"})
diff --git a/src/registrar/tests/test_url_auth.py b/src/registrar/tests/test_url_auth.py
--- a/src/registrar/tests/test_url_auth.py
+++ b/src/registrar/tests/test_url_auth.py
@@ -110,7 +110,7 @@ class TestURLAuth(TestCase):
         "/openid/callback",
         "/openid/callback/login/",
         "/openid/callback/logout/",
-        "/api/v1/available/whitehouse.gov",
+        "/api/v1/available/",
         "/api/v1/get-report/current-federal",
         "/api/v1/get-report/current-full",
     ]