mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-30 06:26:34 +02:00
removed maxlength message on ds data digest
This commit is contained in:
parent
5145e3782e
commit
fa72f31d24
3 changed files with 4 additions and 33 deletions
|
@ -280,10 +280,8 @@ class DomainDsdataForm(forms.Form):
|
||||||
required=True,
|
required=True,
|
||||||
label="Digest",
|
label="Digest",
|
||||||
validators=[validate_hexadecimal],
|
validators=[validate_hexadecimal],
|
||||||
max_length=64,
|
|
||||||
error_messages={
|
error_messages={
|
||||||
"required": "Digest is required.",
|
"required": "Digest is required.",
|
||||||
"max_length": str(DsDataError(code=DsDataErrorCodes.INVALID_DIGEST_LENGTH)),
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1925,30 +1925,6 @@ class TestDomainDNSSEC(TestDomainOverview):
|
||||||
result, str(DsDataError(code=DsDataErrorCodes.INVALID_KEYTAG_SIZE)), count=2, status_code=200
|
result, str(DsDataError(code=DsDataErrorCodes.INVALID_KEYTAG_SIZE)), count=2, status_code=200
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_ds_data_form_invalid_digest_length(self):
|
|
||||||
"""DS Data form errors with invalid data (digest too long)
|
|
||||||
|
|
||||||
Uses self.app WebTest because we need to interact with forms.
|
|
||||||
"""
|
|
||||||
add_data_page = self.app.get(reverse("domain-dns-dnssec-dsdata", kwargs={"pk": self.domain_dsdata.id}))
|
|
||||||
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
|
||||||
# first two nameservers are required, so if we empty one out we should
|
|
||||||
# get a form error
|
|
||||||
add_data_page.forms[0]["form-0-key_tag"] = "1234"
|
|
||||||
add_data_page.forms[0]["form-0-algorithm"] = "3"
|
|
||||||
add_data_page.forms[0]["form-0-digest_type"] = "1"
|
|
||||||
add_data_page.forms[0][
|
|
||||||
"form-0-digest"
|
|
||||||
] = "1234567890123456789012345678901234567890123456789012345678901234567890"
|
|
||||||
with less_console_noise(): # swallow logged warning message
|
|
||||||
result = add_data_page.forms[0].submit()
|
|
||||||
# form submission was a post with an error, response should be a 200
|
|
||||||
# error text appears twice, once at the top of the page, once around
|
|
||||||
# the field.
|
|
||||||
self.assertContains(
|
|
||||||
result, str(DsDataError(code=DsDataErrorCodes.INVALID_DIGEST_LENGTH)), count=2, status_code=200
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_ds_data_form_invalid_digest_chars(self):
|
def test_ds_data_form_invalid_digest_chars(self):
|
||||||
"""DS Data form errors with invalid data (digest contains non hexadecimal chars)
|
"""DS Data form errors with invalid data (digest contains non hexadecimal chars)
|
||||||
|
|
|
@ -122,17 +122,15 @@ class DsDataErrorCodes(IntEnum):
|
||||||
- 1 BAD_DATA bad data input in ds data
|
- 1 BAD_DATA bad data input in ds data
|
||||||
- 2 INVALID_DIGEST_SHA1 invalid digest for digest type SHA-1
|
- 2 INVALID_DIGEST_SHA1 invalid digest for digest type SHA-1
|
||||||
- 3 INVALID_DIGEST_SHA256 invalid digest for digest type SHA-256
|
- 3 INVALID_DIGEST_SHA256 invalid digest for digest type SHA-256
|
||||||
- 4 INVALID_DIGEST_LENGTH invalid digest length exceeds 64
|
- 4 INVALID_DIGEST_CHARS invalid chars in digest
|
||||||
- 5 INVALID_DIGEST_CHARS invalid chars in digest
|
- 5 INVALID_KEYTAG_SIZE invalid key tag size > 65535
|
||||||
- 6 INVALID_KEYTAG_SIZE invalid key tag size > 65535
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
BAD_DATA = 1
|
BAD_DATA = 1
|
||||||
INVALID_DIGEST_SHA1 = 2
|
INVALID_DIGEST_SHA1 = 2
|
||||||
INVALID_DIGEST_SHA256 = 3
|
INVALID_DIGEST_SHA256 = 3
|
||||||
INVALID_DIGEST_LENGTH = 4
|
INVALID_DIGEST_CHARS = 4
|
||||||
INVALID_DIGEST_CHARS = 5
|
INVALID_KEYTAG_SIZE = 5
|
||||||
INVALID_KEYTAG_SIZE = 6
|
|
||||||
|
|
||||||
|
|
||||||
class DsDataError(Exception):
|
class DsDataError(Exception):
|
||||||
|
@ -147,7 +145,6 @@ class DsDataError(Exception):
|
||||||
),
|
),
|
||||||
DsDataErrorCodes.INVALID_DIGEST_SHA1: ("SHA-1 digest must be exactly 40 characters."),
|
DsDataErrorCodes.INVALID_DIGEST_SHA1: ("SHA-1 digest must be exactly 40 characters."),
|
||||||
DsDataErrorCodes.INVALID_DIGEST_SHA256: ("SHA-256 digest must be exactly 64 characters."),
|
DsDataErrorCodes.INVALID_DIGEST_SHA256: ("SHA-256 digest must be exactly 64 characters."),
|
||||||
DsDataErrorCodes.INVALID_DIGEST_LENGTH: ("Digest must be at most 64 characters."),
|
|
||||||
DsDataErrorCodes.INVALID_DIGEST_CHARS: ("Digest must contain only alphanumeric characters [0-9,a-f]."),
|
DsDataErrorCodes.INVALID_DIGEST_CHARS: ("Digest must contain only alphanumeric characters [0-9,a-f]."),
|
||||||
DsDataErrorCodes.INVALID_KEYTAG_SIZE: ("Key tag must be less than 65535"),
|
DsDataErrorCodes.INVALID_KEYTAG_SIZE: ("Key tag must be less than 65535"),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue