mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-14 21:44:08 +02:00
Merge pull request #1302 from cisagov/dk/1237-domain-bug
Issue #1237 - domain bug - unable to manage a domain for a transition domain
This commit is contained in:
commit
b05d99815a
4 changed files with 84 additions and 39 deletions
|
@ -16,49 +16,60 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="grid-row grid-gap">
|
<div class="grid-row grid-gap">
|
||||||
<div class="tablet:grid-col-3">
|
<div class="tablet:grid-col-3">
|
||||||
{% include 'domain_sidebar.html' %}
|
{% if domain.domain_info %}
|
||||||
|
{% include 'domain_sidebar.html' %}
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="tablet:grid-col-9">
|
<div class="tablet:grid-col-9">
|
||||||
<main id="main-content" class="grid-container">
|
<main id="main-content" class="grid-container">
|
||||||
|
{% if not domain.domain_info %}
|
||||||
{% if is_analyst_or_superuser and analyst_action == 'edit' and analyst_action_location == domain.pk %}
|
<div class="usa-alert usa-alert--error margin-bottom-2">
|
||||||
<div class="usa-alert usa-alert--warning margin-bottom-2">
|
|
||||||
<div class="usa-alert__body">
|
|
||||||
<h4 class="usa-alert__heading larger-font-sizing">Attention!</h4>
|
|
||||||
<p class="usa-alert__text ">
|
|
||||||
You are making changes to a registrant’s domain. When finished making changes, close this tab and inform the registrant of your updates.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% else %}
|
|
||||||
<a href="{% url 'home' %}" class="breadcrumb__back">
|
|
||||||
<svg class="usa-icon" aria-hidden="true" focusable="false" role="img">
|
|
||||||
<use xlink:href="{% static 'img/sprite.svg' %}#arrow_back"></use>
|
|
||||||
</svg>
|
|
||||||
|
|
||||||
<p class="margin-left-05 margin-top-0 margin-bottom-0 line-height-sans-1">
|
|
||||||
Back to manage your domains
|
|
||||||
</p>
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
|
||||||
{# messages block is under the back breadcrumb link #}
|
|
||||||
{% if messages %}
|
|
||||||
{% for message in messages %}
|
|
||||||
<div class="usa-alert usa-alert--{{ message.tags }} usa-alert--slim margin-bottom-3">
|
|
||||||
<div class="usa-alert__body">
|
<div class="usa-alert__body">
|
||||||
{{ message }}
|
<h4 class="usa-alert__heading larger-font-sizing">Domain missing domain information</h4>
|
||||||
|
<p class="usa-alert__text ">
|
||||||
|
You are attempting to manage a domain, {{ domain.name }}, which does not have a domain information object. Please correct this in the admin by editing the domain, and adding domain information, as appropriate.
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% else %}
|
||||||
|
{% if is_analyst_or_superuser and analyst_action == 'edit' and analyst_action_location == domain.pk %}
|
||||||
|
<div class="usa-alert usa-alert--warning margin-bottom-2">
|
||||||
|
<div class="usa-alert__body">
|
||||||
|
<h4 class="usa-alert__heading larger-font-sizing">Attention!</h4>
|
||||||
|
<p class="usa-alert__text ">
|
||||||
|
You are making changes to a registrant’s domain. When finished making changes, close this tab and inform the registrant of your updates.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<a href="{% url 'home' %}" class="breadcrumb__back">
|
||||||
|
<svg class="usa-icon" aria-hidden="true" focusable="false" role="img">
|
||||||
|
<use xlink:href="{% static 'img/sprite.svg' %}#arrow_back"></use>
|
||||||
|
</svg>
|
||||||
|
|
||||||
|
<p class="margin-left-05 margin-top-0 margin-bottom-0 line-height-sans-1">
|
||||||
|
Back to manage your domains
|
||||||
|
</p>
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
{# messages block is under the back breadcrumb link #}
|
||||||
|
{% if messages %}
|
||||||
|
{% for message in messages %}
|
||||||
|
<div class="usa-alert usa-alert--{{ message.tags }} usa-alert--slim margin-bottom-3">
|
||||||
|
<div class="usa-alert__body">
|
||||||
|
{{ message }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% block domain_content %}
|
||||||
|
|
||||||
|
<h1 class="break-word">{{ domain.name }}</h1>
|
||||||
|
|
||||||
|
{% endblock %} {# domain_content #}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% block domain_content %}
|
|
||||||
|
|
||||||
<h1 class="break-word">{{ domain.name }}</h1>
|
|
||||||
|
|
||||||
{% endblock %} {# domain_content #}
|
|
||||||
|
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -453,7 +453,7 @@ def create_user():
|
||||||
p = "userpass"
|
p = "userpass"
|
||||||
user = User.objects.create_user(
|
user = User.objects.create_user(
|
||||||
username="staffuser",
|
username="staffuser",
|
||||||
email="user@example.com",
|
email="staff@example.com",
|
||||||
is_staff=True,
|
is_staff=True,
|
||||||
password=p,
|
password=p,
|
||||||
)
|
)
|
||||||
|
|
|
@ -5,7 +5,7 @@ from django.conf import settings
|
||||||
from django.test import Client, TestCase
|
from django.test import Client, TestCase
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.contrib.auth import get_user_model
|
from django.contrib.auth import get_user_model
|
||||||
from .common import MockEppLib, completed_application # type: ignore
|
from .common import MockEppLib, completed_application, create_user # type: ignore
|
||||||
|
|
||||||
from django_webtest import WebTest # type: ignore
|
from django_webtest import WebTest # type: ignore
|
||||||
import boto3_mocking # type: ignore
|
import boto3_mocking # type: ignore
|
||||||
|
@ -1105,6 +1105,9 @@ class TestWithDomainPermissions(TestWithUser):
|
||||||
self.domain_just_nameserver, _ = Domain.objects.get_or_create(
|
self.domain_just_nameserver, _ = Domain.objects.get_or_create(
|
||||||
name="justnameserver.com"
|
name="justnameserver.com"
|
||||||
)
|
)
|
||||||
|
self.domain_no_information, _ = Domain.objects.get_or_create(
|
||||||
|
name="noinformation.gov"
|
||||||
|
)
|
||||||
|
|
||||||
self.domain_dsdata, _ = Domain.objects.get_or_create(name="dnssec-dsdata.gov")
|
self.domain_dsdata, _ = Domain.objects.get_or_create(name="dnssec-dsdata.gov")
|
||||||
self.domain_multdsdata, _ = Domain.objects.get_or_create(
|
self.domain_multdsdata, _ = Domain.objects.get_or_create(
|
||||||
|
@ -1278,6 +1281,29 @@ class TestDomainOverview(TestWithDomainPermissions, WebTest):
|
||||||
self.assertContains(detail_page, "(1.2.3.4,")
|
self.assertContains(detail_page, "(1.2.3.4,")
|
||||||
self.assertContains(detail_page, "2.3.4.5)")
|
self.assertContains(detail_page, "2.3.4.5)")
|
||||||
|
|
||||||
|
def test_domain_with_no_information_or_application(self):
|
||||||
|
"""Test that domain management page returns 200 and displays error
|
||||||
|
when no domain information or domain application exist"""
|
||||||
|
# have to use staff user for this test
|
||||||
|
staff_user = create_user()
|
||||||
|
# staff_user.save()
|
||||||
|
self.client.force_login(staff_user)
|
||||||
|
|
||||||
|
# need to set the analyst_action and analyst_action_location
|
||||||
|
# in the session to emulate user clicking Manage Domain
|
||||||
|
# in the admin interface
|
||||||
|
session = self.client.session
|
||||||
|
session["analyst_action"] = "foo"
|
||||||
|
session["analyst_action_location"] = self.domain_no_information.id
|
||||||
|
session.save()
|
||||||
|
|
||||||
|
detail_page = self.client.get(
|
||||||
|
reverse("domain", kwargs={"pk": self.domain_no_information.id})
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertContains(detail_page, "noinformation.gov")
|
||||||
|
self.assertContains(detail_page, "Domain missing domain information")
|
||||||
|
|
||||||
|
|
||||||
class TestDomainManagers(TestDomainOverview):
|
class TestDomainManagers(TestDomainOverview):
|
||||||
def test_domain_managers(self):
|
def test_domain_managers(self):
|
||||||
|
|
|
@ -100,7 +100,15 @@ class DomainPermission(PermissionsLoginMixin):
|
||||||
if DomainInformation.objects.filter(id=pk).exists():
|
if DomainInformation.objects.filter(id=pk).exists():
|
||||||
requested_domain = DomainInformation.objects.get(id=pk)
|
requested_domain = DomainInformation.objects.get(id=pk)
|
||||||
|
|
||||||
if requested_domain.domain_application.status not in valid_domain_statuses:
|
# if no domain information or application exist, the user
|
||||||
|
# should be able to manage the domain; however, if domain information
|
||||||
|
# and domain application exist, and application is not in valid status,
|
||||||
|
# user should not be able to manage domain
|
||||||
|
if (
|
||||||
|
requested_domain
|
||||||
|
and requested_domain.domain_application
|
||||||
|
and requested_domain.domain_application.status not in valid_domain_statuses
|
||||||
|
):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Valid session keys exist,
|
# Valid session keys exist,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue