Skip to content

Commit

Permalink
Merge pull request #1622 from cisagov/rjm/1577-unknown-domain-expired…
Browse files Browse the repository at this point in the history
…-bug

Issue 1577: UNKNOWN domain expired bug
  • Loading branch information
rachidatecs authored Jan 11, 2024
2 parents c362b1a + 2e6fe68 commit c5a584f
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 18 deletions.
5 changes: 3 additions & 2 deletions src/registrar/templates/domain_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
<span class="text-bold text-primary-darker">
Status:
</span>
{% if domain.is_expired %}
{# UNKNOWN domains would not have an expiration date and thus would show 'Expired' #}
{% if domain.is_expired and domain.state != domain.State.UNKNOWN %}
Expired
{% elif domain.state == domain.State.UNKNOWN or domain.state == domain.State.DNS_NEEDED%}
{% elif domain.state == domain.State.UNKNOWN or domain.state == domain.State.DNS_NEEDED %}
DNS needed
{% else %}
{{ domain.state|title }}
Expand Down
5 changes: 3 additions & 2 deletions src/registrar/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@ <h2>Domains</h2>
</th>
<td data-sort-value="{{ domain.expiration_date|date:"U" }}" data-label="Expires">{{ domain.expiration_date|date }}</td>
<td data-label="Status">
{% if domain.is_expired %}
{# UNKNOWN domains would not have an expiration date and thus would show 'Expired' #}
{% if domain.is_expired and domain.state != domain.State.UNKNOWN %}
Expired
{% elif domain.state == "unknown" or domain.state == "dns needed"%}
{% elif domain.state == domain.State.UNKNOWN or domain.state == domain.State.DNS_NEEDED %}
DNS needed
{% else %}
{{ domain.state|title }}
Expand Down
73 changes: 59 additions & 14 deletions src/registrar/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
User,
)
from registrar.views.application import ApplicationWizard, Step
from datetime import date, datetime, timedelta
from django.utils import timezone

from .common import less_console_noise

Expand Down Expand Up @@ -94,18 +96,6 @@ def test_home_lists_domain_applications(self):
# clean up
application.delete()

def test_home_lists_domains(self):
response = self.client.get("/")
domain, _ = Domain.objects.get_or_create(name="igorville.gov")
self.assertNotContains(response, "igorville.gov")
role, _ = UserDomainRole.objects.get_or_create(user=self.user, domain=domain, role=UserDomainRole.Roles.MANAGER)
response = self.client.get("/")
# count = 2 because it is also in screenreader content
self.assertContains(response, "igorville.gov", count=2)
self.assertContains(response, "Expired")
# clean up
role.delete()

def test_application_form_view(self):
response = self.client.get("/register/", follow=True)
self.assertContains(
Expand Down Expand Up @@ -1605,8 +1595,20 @@ def setUp(self):
self.domain_with_ip, _ = Domain.objects.get_or_create(name="nameserverwithip.gov")
self.domain_just_nameserver, _ = Domain.objects.get_or_create(name="justnameserver.com")
self.domain_no_information, _ = Domain.objects.get_or_create(name="noinformation.gov")
self.domain_on_hold, _ = Domain.objects.get_or_create(name="on-hold.gov", state=Domain.State.ON_HOLD)
self.domain_deleted, _ = Domain.objects.get_or_create(name="deleted.gov", state=Domain.State.DELETED)
self.domain_on_hold, _ = Domain.objects.get_or_create(
name="on-hold.gov",
state=Domain.State.ON_HOLD,
expiration_date=timezone.make_aware(
datetime.combine(date.today() + timedelta(days=1), datetime.min.time())
),
)
self.domain_deleted, _ = Domain.objects.get_or_create(
name="deleted.gov",
state=Domain.State.DELETED,
expiration_date=timezone.make_aware(
datetime.combine(date.today() + timedelta(days=1), datetime.min.time())
),
)

self.domain_dsdata, _ = Domain.objects.get_or_create(name="dnssec-dsdata.gov")
self.domain_multdsdata, _ = Domain.objects.get_or_create(name="dnssec-multdsdata.gov")
Expand Down Expand Up @@ -1754,6 +1756,49 @@ def test_domain_detail_link_works(self):
self.assertContains(detail_page, "igorville.gov")
self.assertContains(detail_page, "Status")

def test_unknown_domain_does_not_show_as_expired_on_homepage(self):
"""An UNKNOWN domain does not show as expired on the homepage.
It shows as 'DNS needed'"""
# At the time of this test's writing, there are 6 UNKNOWN domains inherited
# from constructors. Let's reset.
Domain.objects.all().delete()
UserDomainRole.objects.all().delete()
self.domain, _ = Domain.objects.get_or_create(name="igorville.gov")
home_page = self.app.get("/")
self.assertNotContains(home_page, "igorville.gov")
self.role, _ = UserDomainRole.objects.get_or_create(
user=self.user, domain=self.domain, role=UserDomainRole.Roles.MANAGER
)
home_page = self.app.get("/")
self.assertContains(home_page, "igorville.gov")
igorville = Domain.objects.get(name="igorville.gov")
self.assertEquals(igorville.state, Domain.State.UNKNOWN)
self.assertNotContains(home_page, "Expired")
self.assertContains(home_page, "DNS needed")

def test_unknown_domain_does_not_show_as_expired_on_detail_page(self):
"""An UNKNOWN domain does not show as expired on the detail page.
It shows as 'DNS needed'"""
# At the time of this test's writing, there are 6 UNKNOWN domains inherited
# from constructors. Let's reset.
Domain.objects.all().delete()
UserDomainRole.objects.all().delete()

self.domain, _ = Domain.objects.get_or_create(name="igorville.gov")
self.domain_information, _ = DomainInformation.objects.get_or_create(creator=self.user, domain=self.domain)
self.role, _ = UserDomainRole.objects.get_or_create(
user=self.user, domain=self.domain, role=UserDomainRole.Roles.MANAGER
)

home_page = self.app.get("/")
self.assertContains(home_page, "igorville.gov")
igorville = Domain.objects.get(name="igorville.gov")
self.assertEquals(igorville.state, Domain.State.UNKNOWN)
detail_page = home_page.click("Manage", index=0)
self.assertNotContains(detail_page, "Expired")

self.assertContains(detail_page, "DNS needed")

def test_domain_detail_blocked_for_ineligible_user(self):
"""We could easily duplicate this test for all domain management
views, but a single url test should be solid enough since all domain
Expand Down

0 comments on commit c5a584f

Please sign in to comment.