mirror of
https://github.com/VinylDNS/vinyldns
synced 2025-09-01 14:55:22 +00:00
reject recordset names with spaces (#908)
This commit is contained in:
@@ -1165,7 +1165,7 @@ def test_reverse_create_recordset_reverse_record_types(shared_zone_test_context,
|
|||||||
client.wait_until_recordset_change_status(result, 'Complete')
|
client.wait_until_recordset_change_status(result, 'Complete')
|
||||||
|
|
||||||
|
|
||||||
def test_create_invalid_recordset_name(shared_zone_test_context):
|
def test_create_invalid_length_recordset_name(shared_zone_test_context):
|
||||||
"""
|
"""
|
||||||
Test creating a record set where the name is too long
|
Test creating a record set where the name is too long
|
||||||
"""
|
"""
|
||||||
@@ -1185,6 +1185,26 @@ def test_create_invalid_recordset_name(shared_zone_test_context):
|
|||||||
client.create_recordset(new_rs, status=400)
|
client.create_recordset(new_rs, status=400)
|
||||||
|
|
||||||
|
|
||||||
|
def test_create_recordset_name_with_spaces(shared_zone_test_context):
|
||||||
|
"""
|
||||||
|
Test creating a record set with any spaces fails
|
||||||
|
"""
|
||||||
|
client = shared_zone_test_context.ok_vinyldns_client
|
||||||
|
|
||||||
|
new_rs = {
|
||||||
|
'zoneId': shared_zone_test_context.system_test_zone['id'],
|
||||||
|
'name': 'a a',
|
||||||
|
'type': 'A',
|
||||||
|
'ttl': 100,
|
||||||
|
'records': [
|
||||||
|
{
|
||||||
|
'address': '10.1.1.1'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
client.create_recordset(new_rs, status=400)
|
||||||
|
|
||||||
|
|
||||||
def test_user_cannot_create_record_in_unowned_zone(shared_zone_test_context):
|
def test_user_cannot_create_record_in_unowned_zone(shared_zone_test_context):
|
||||||
"""
|
"""
|
||||||
Test user can create a record that it a shared zone that it is a member of
|
Test user can create a record that it a shared zone that it is a member of
|
||||||
|
@@ -382,6 +382,52 @@ def test_update_recordset_long_name(shared_zone_test_context):
|
|||||||
client.wait_until_recordset_change_status(result, 'Complete')
|
client.wait_until_recordset_change_status(result, 'Complete')
|
||||||
|
|
||||||
|
|
||||||
|
def test_update_recordset_with_spaces(shared_zone_test_context):
|
||||||
|
"""
|
||||||
|
Test updating a record set where the name contains spaces
|
||||||
|
"""
|
||||||
|
client = shared_zone_test_context.ok_vinyldns_client
|
||||||
|
result_rs = None
|
||||||
|
|
||||||
|
try:
|
||||||
|
new_rs = {
|
||||||
|
'id': 'abc',
|
||||||
|
'zoneId': shared_zone_test_context.system_test_zone['id'],
|
||||||
|
'name': 'a',
|
||||||
|
'type': 'A',
|
||||||
|
'ttl': 100,
|
||||||
|
'records': [
|
||||||
|
{
|
||||||
|
'address': '10.1.1.1'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
result = client.create_recordset(new_rs, status=202)
|
||||||
|
|
||||||
|
result_rs = result['recordSet']
|
||||||
|
verify_recordset(result_rs, new_rs)
|
||||||
|
result_rs = client.wait_until_recordset_change_status(result, 'Complete')['recordSet']
|
||||||
|
|
||||||
|
update_rs = {
|
||||||
|
'id': 'abc',
|
||||||
|
'zoneId': shared_zone_test_context.system_test_zone['id'],
|
||||||
|
'name': 'a a',
|
||||||
|
'type': 'A',
|
||||||
|
'ttl': 100,
|
||||||
|
'records': [
|
||||||
|
{
|
||||||
|
'address': '10.1.1.1'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
client.update_recordset(update_rs, status=400)
|
||||||
|
finally:
|
||||||
|
if result_rs:
|
||||||
|
result = client.delete_recordset(result_rs['zoneId'], result_rs['id'], status=(202, 404))
|
||||||
|
if result:
|
||||||
|
client.wait_until_recordset_change_status(result, 'Complete')
|
||||||
|
|
||||||
|
|
||||||
def test_user_can_update_record_in_zone_it_owns(shared_zone_test_context):
|
def test_user_can_update_record_in_zone_it_owns(shared_zone_test_context):
|
||||||
"""
|
"""
|
||||||
Test user can update a record that it owns
|
Test user can update a record that it owns
|
||||||
|
@@ -124,6 +124,7 @@ trait DnsJsonProtocol extends JsonValidation {
|
|||||||
|
|
||||||
def checkDomainNameLen(s: String): Boolean = s.length <= 255
|
def checkDomainNameLen(s: String): Boolean = s.length <= 255
|
||||||
def nameContainsDots(s: String): Boolean = s.contains(".")
|
def nameContainsDots(s: String): Boolean = s.contains(".")
|
||||||
|
def nameDoesNotContainSpaces(s: String): Boolean = !s.contains(" ")
|
||||||
|
|
||||||
val ipv4Re =
|
val ipv4Re =
|
||||||
"""^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$""".r
|
"""^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$""".r
|
||||||
@@ -162,7 +163,10 @@ trait DnsJsonProtocol extends JsonValidation {
|
|||||||
(js \ "zoneId").required[String]("Missing RecordSet.zoneId"),
|
(js \ "zoneId").required[String]("Missing RecordSet.zoneId"),
|
||||||
(js \ "name")
|
(js \ "name")
|
||||||
.required[String]("Missing RecordSet.name")
|
.required[String]("Missing RecordSet.name")
|
||||||
.check("Record name must not exceed 255 characters" -> checkDomainNameLen),
|
.check(
|
||||||
|
"Record name must not exceed 255 characters" -> checkDomainNameLen,
|
||||||
|
"Record name cannot contain spaces" -> nameDoesNotContainSpaces
|
||||||
|
),
|
||||||
recordType,
|
recordType,
|
||||||
(js \ "ttl")
|
(js \ "ttl")
|
||||||
.required[Long]("Missing RecordSet.ttl")
|
.required[Long]("Missing RecordSet.ttl")
|
||||||
|
Reference in New Issue
Block a user