Skip to content

Commit

Permalink
Allow studentorg subdomains in vhost request form (#836)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kalissaac authored Sep 5, 2024
1 parent ed623b8 commit 7fb8fc5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
8 changes: 4 additions & 4 deletions ocfweb/account/vhost.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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):
Expand Down
5 changes: 3 additions & 2 deletions tests/account/vhost_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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),
Expand Down

0 comments on commit 7fb8fc5

Please sign in to comment.