From 7fb8fc5827f6d6f107febe51833a4868319c4943 Mon Sep 17 00:00:00 2001 From: Kian Date: Wed, 4 Sep 2024 17:06:38 -0700 Subject: [PATCH] Allow studentorg subdomains in vhost request form (#836) --- ocfweb/account/vhost.py | 8 ++++---- tests/account/vhost_test.py | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/ocfweb/account/vhost.py b/ocfweb/account/vhost.py index 4488902b7..609d608d5 100644 --- a/ocfweb/account/vhost.py +++ b/ocfweb/account/vhost.py @@ -27,7 +27,7 @@ def available_domain(domain: str) -> bool: - if not re.match(r'^[a-zA-Z0-9]+\.berkeley\.edu$', domain): + if not re.match(r'^[a-zA-Z0-9]+\.studentorg\.berkeley\.edu$', domain): return False return not host_exists(domain) @@ -317,10 +317,10 @@ def clean_requested_subdomain(self) -> str: ) return requested_subdomain - if not requested_subdomain.endswith('.berkeley.edu'): + if not requested_subdomain.endswith('.studentorg.berkeley.edu'): raise forms.ValidationError( - 'The domain you entered does not end in ".berkeley.edu". ' - 'Maybe add ".berkeley.edu" to the end?', + 'The domain you entered does not end in ".studentorg.berkeley.edu". ' + 'Maybe add ".studentorg.berkeley.edu" to the end?', ) if not available_domain(requested_subdomain): diff --git a/tests/account/vhost_test.py b/tests/account/vhost_test.py index a4f0ae790..42979e64e 100644 --- a/tests/account/vhost_test.py +++ b/tests/account/vhost_test.py @@ -7,8 +7,8 @@ @pytest.mark.parametrize( 'domain,expected', [ # nxdomain (should be available) - ('asdfghjk.berkeley.edu', True), - ('kljasdlgjlsafdfhsadf.berkeley.edu', True), + ('asdfghjk.studentorg.berkeley.edu', True), + ('kljasdlgjlsafdfhsadf.studentorg.berkeley.edu', True), # mx record only ('g.berkeley.edu', False), @@ -22,6 +22,7 @@ # existing domains ('ocf.berkeley.edu', False), ('cs.berkeley.edu', False), + ('tbp.studentorg.berkeley.edu', False), # existing subdomains ('cory.eecs.berkeley.edu', False),