* Return contacts inside domain object
* Return registrant uuid and name inside domain object
This commit is contained in:
Maciej Szlosarczyk 2018-10-04 09:54:52 +03:00
parent b6cc22dbfc
commit f551140a0d
No known key found for this signature in database
GPG key ID: 41D62D42D3B0D765
6 changed files with 484 additions and 255 deletions

View file

@ -17,7 +17,6 @@ Returns domains of the current registrant.
HTTP/1.1 200 HTTP/1.1 200
Content-Type: application/json Content-Type: application/json
{
[ [
{ {
"id":"98d1083a-8863-4153-93e4-caee4a013535", "id":"98d1083a-8863-4153-93e4-caee4a013535",
@ -26,9 +25,32 @@ Content-Type: application/json
"name":"Best Names", "name":"Best Names",
"website":"example.com" "website":"example.com"
}, },
"registered_at": "2015-09-09T09:11:14.861Z",
"valid_to":"2016-09-09T09:11:14.861Z", "valid_to":"2016-09-09T09:11:14.861Z",
"registrant_id": 1, "registered_at":"2015-09-09T09:11:14.861Z",
"registrant":{
"name":"John Smith",
"id":"acadf23e-47c4-4606-8f67-76e071a1cca2"
},
"admin_contacts":[
{
"name":"John Smith",
"id":"62015e7d-42c8-4d68-8164-e9b71680fd95"
},
{
"name":"William Smith",
"id":"a041c5b6-7772-4fac-83cd-fbce3b2c8867"
}
],
"tech_contacts":[
{
"name":"John Smith",
"id":"62015e7d-42c8-4d68-8164-e9b71680fd95"
},
{
"name":"William Smith",
"id":"a041c5b6-7772-4fac-83cd-fbce3b2c8867"
}
],
"transfer_code":"98oiewslkfkd", "transfer_code":"98oiewslkfkd",
"created_at":"2015-09-09T09:11:14.861Z", "created_at":"2015-09-09T09:11:14.861Z",
"updated_at":"2015-09-09T09:11:14.860Z", "updated_at":"2015-09-09T09:11:14.860Z",
@ -46,7 +68,9 @@ Content-Type: application/json
"registrant_verification_asked_at":null, "registrant_verification_asked_at":null,
"registrant_verification_token":null, "registrant_verification_token":null,
"locked_by_registrant_at":"2015-09-09T09:11:14.861Z", "locked_by_registrant_at":"2015-09-09T09:11:14.861Z",
"pending_json": {}, "pending_json":{
},
"force_delete_at":null, "force_delete_at":null,
"statuses":[ "statuses":[
"ok" "ok"
@ -54,21 +78,33 @@ Content-Type: application/json
"nameservers":[ "nameservers":[
{ {
"hostname":"ns1.bestnames.test", "hostname":"ns1.bestnames.test",
"ipv4": ["173.245.58.41"], "ipv4":[
"ipv6": ["2400:cb00:2049:1::adf5:3a33"] "173.245.58.41"
],
"ipv6":[
"2400:cb00:2049:1::adf5:3a33"
]
}, },
{ {
"hostname":"ns1.bestnames.test", "hostname":"ns1.bestnames.test",
"ipv4": ["173.245.58.51"], "ipv4":[
"ipv6": ["2400:cb00:2049:1::adf5:3b29"] "173.245.58.51"
],
"ipv6":[
"2400:cb00:2049:1::adf5:3b29"
]
}, },
], ],
"reserved":false, "reserved":false,
"status_notes": {}, "status_notes":{
"statuses_backup": []
} },
"statuses_backup":[
] ]
} }
]
``` ```
#### Request #### Request
@ -97,7 +133,6 @@ Content-Type: application/json
HTTP/1.1 200 HTTP/1.1 200
Content-Type: application/json Content-Type: application/json
{
[ [
{ {
"id":"98d1083a-8863-4153-93e4-caee4a013535", "id":"98d1083a-8863-4153-93e4-caee4a013535",
@ -108,7 +143,30 @@ Content-Type: application/json
}, },
"valid_to":"2016-09-09T09:11:14.861Z", "valid_to":"2016-09-09T09:11:14.861Z",
"registered_at":"2015-09-09T09:11:14.861Z", "registered_at":"2015-09-09T09:11:14.861Z",
"registrant_id": 1, "registrant":{
"name":"John Smith",
"id":"acadf23e-47c4-4606-8f67-76e071a1cca2"
},
"admin_contacts":[
{
"name":"John Smith",
"id":"62015e7d-42c8-4d68-8164-e9b71680fd95"
},
{
"name":"William Smith",
"id":"a041c5b6-7772-4fac-83cd-fbce3b2c8867"
}
],
"tech_contacts":[
{
"name":"John Smith",
"id":"62015e7d-42c8-4d68-8164-e9b71680fd95"
},
{
"name":"William Smith",
"id":"a041c5b6-7772-4fac-83cd-fbce3b2c8867"
}
],
"transfer_code":"98oiewslkfkd", "transfer_code":"98oiewslkfkd",
"created_at":"2015-09-09T09:11:14.861Z", "created_at":"2015-09-09T09:11:14.861Z",
"updated_at":"2015-09-09T09:11:14.860Z", "updated_at":"2015-09-09T09:11:14.860Z",
@ -126,7 +184,9 @@ Content-Type: application/json
"registrant_verification_asked_at":null, "registrant_verification_asked_at":null,
"registrant_verification_token":null, "registrant_verification_token":null,
"locked_by_registrant_at":"2015-09-09T09:11:14.861Z", "locked_by_registrant_at":"2015-09-09T09:11:14.861Z",
"pending_json": {}, "pending_json":{
},
"force_delete_at":null, "force_delete_at":null,
"statuses":[ "statuses":[
"ok" "ok"
@ -134,21 +194,33 @@ Content-Type: application/json
"nameservers":[ "nameservers":[
{ {
"hostname":"ns1.bestnames.test", "hostname":"ns1.bestnames.test",
"ipv4": ["173.245.58.41"], "ipv4":[
"ipv6": ["2400:cb00:2049:1::adf5:3a33"] "173.245.58.41"
],
"ipv6":[
"2400:cb00:2049:1::adf5:3a33"
]
}, },
{ {
"hostname":"ns1.bestnames.test", "hostname":"ns1.bestnames.test",
"ipv4": ["173.245.58.51"], "ipv4":[
"ipv6": ["2400:cb00:2049:1::adf5:3b29"] "173.245.58.51"
],
"ipv6":[
"2400:cb00:2049:1::adf5:3b29"
]
}, },
], ],
"reserved":false, "reserved":false,
"status_notes": {}, "status_notes":{
"statuses_backup": []
} },
"statuses_backup":[
] ]
} }
]
``` ```
## GET api/v1/registrant/domains/$UUID ## GET api/v1/registrant/domains/$UUID
@ -177,9 +249,32 @@ Content-Type: application/json
"name":"Best Names", "name":"Best Names",
"website":"example.com" "website":"example.com"
}, },
"registered_at": "2015-09-09T09:11:14.861Z",
"valid_to":"2016-09-09T09:11:14.861Z", "valid_to":"2016-09-09T09:11:14.861Z",
"registrant_id": 1, "registered_at":"2015-09-09T09:11:14.861Z",
"registrant":{
"name":"John Smith",
"id":"acadf23e-47c4-4606-8f67-76e071a1cca2"
},
"admin_contacts":[
{
"name":"John Smith",
"id":"62015e7d-42c8-4d68-8164-e9b71680fd95"
},
{
"name":"William Smith",
"id":"a041c5b6-7772-4fac-83cd-fbce3b2c8867"
}
],
"tech_contacts":[
{
"name":"John Smith",
"id":"62015e7d-42c8-4d68-8164-e9b71680fd95"
},
{
"name":"William Smith",
"id":"a041c5b6-7772-4fac-83cd-fbce3b2c8867"
}
],
"transfer_code":"98oiewslkfkd", "transfer_code":"98oiewslkfkd",
"created_at":"2015-09-09T09:11:14.861Z", "created_at":"2015-09-09T09:11:14.861Z",
"updated_at":"2015-09-09T09:11:14.860Z", "updated_at":"2015-09-09T09:11:14.860Z",
@ -197,7 +292,9 @@ Content-Type: application/json
"registrant_verification_asked_at":null, "registrant_verification_asked_at":null,
"registrant_verification_token":null, "registrant_verification_token":null,
"locked_by_registrant_at":"2015-09-09T09:11:14.861Z", "locked_by_registrant_at":"2015-09-09T09:11:14.861Z",
"pending_json": {}, "pending_json":{
},
"force_delete_at":null, "force_delete_at":null,
"statuses":[ "statuses":[
"ok" "ok"
@ -205,18 +302,30 @@ Content-Type: application/json
"nameservers":[ "nameservers":[
{ {
"hostname":"ns1.bestnames.test", "hostname":"ns1.bestnames.test",
"ipv4": ["173.245.58.41"], "ipv4":[
"ipv6": ["2400:cb00:2049:1::adf5:3a33"] "173.245.58.41"
],
"ipv6":[
"2400:cb00:2049:1::adf5:3a33"
]
}, },
{ {
"hostname":"ns1.bestnames.test", "hostname":"ns1.bestnames.test",
"ipv4": ["173.245.58.51"], "ipv4":[
"ipv6": ["2400:cb00:2049:1::adf5:3b29"] "173.245.58.51"
}, ],
"ipv6":[
"2400:cb00:2049:1::adf5:3b29"
]
}
], ],
"reserved":false, "reserved":false,
"status_notes": {}, "status_notes":{
"statuses_backup": []
},
"statuses_backup":[
]
} }
``` ```

View file

@ -25,9 +25,32 @@ Content-Type: application/json
"name":"Best Names", "name":"Best Names",
"website":"example.com" "website":"example.com"
}, },
"registrant":{
"name":"John Smith",
"id":"acadf23e-47c4-4606-8f67-76e071a1cca2"
},
"admin_contacts":[
{
"name":"John Smith",
"id":"62015e7d-42c8-4d68-8164-e9b71680fd95"
},
{
"name":"William Smith",
"id":"a041c5b6-7772-4fac-83cd-fbce3b2c8867"
}
],
"tech_contacts":[
{
"name":"John Smith",
"id":"62015e7d-42c8-4d68-8164-e9b71680fd95"
},
{
"name":"William Smith",
"id":"a041c5b6-7772-4fac-83cd-fbce3b2c8867"
}
],
"registered_at":"2015-09-09T09:11:14.861Z", "registered_at":"2015-09-09T09:11:14.861Z",
"valid_to":"2016-09-09T09:11:14.861Z", "valid_to":"2016-09-09T09:11:14.861Z",
"registrant_id": 1,
"transfer_code":"98oiewslkfkd", "transfer_code":"98oiewslkfkd",
"created_at":"2015-09-09T09:11:14.861Z", "created_at":"2015-09-09T09:11:14.861Z",
"updated_at":"2015-09-09T09:11:14.860Z", "updated_at":"2015-09-09T09:11:14.860Z",
@ -45,7 +68,9 @@ Content-Type: application/json
"registrant_verification_asked_at":null, "registrant_verification_asked_at":null,
"registrant_verification_token":null, "registrant_verification_token":null,
"locked_by_registrant_at":"2015-09-09T09:11:14.861Z", "locked_by_registrant_at":"2015-09-09T09:11:14.861Z",
"pending_json": {}, "pending_json":{
},
"force_delete_at":null, "force_delete_at":null,
"statuses":[ "statuses":[
"serverUpdateProhibited", "serverUpdateProhibited",
@ -55,18 +80,30 @@ Content-Type: application/json
"nameservers":[ "nameservers":[
{ {
"hostname":"ns1.bestnames.test", "hostname":"ns1.bestnames.test",
"ipv4": ["173.245.58.41"], "ipv4":[
"ipv6": ["2400:cb00:2049:1::adf5:3a33"] "173.245.58.41"
],
"ipv6":[
"2400:cb00:2049:1::adf5:3a33"
]
}, },
{ {
"hostname":"ns1.bestnames.test", "hostname":"ns1.bestnames.test",
"ipv4": ["173.245.58.51"], "ipv4":[
"ipv6": ["2400:cb00:2049:1::adf5:3b29"] "173.245.58.51"
}, ],
"ipv6":[
"2400:cb00:2049:1::adf5:3b29"
]
}
], ],
"reserved":false, "reserved":false,
"status_notes": {}, "status_notes":{
"statuses_backup": []
},
"statuses_backup":[
]
} }
``` ```
@ -135,7 +172,30 @@ Content-Type: application/json
}, },
"registered_at":"2015-09-09T09:11:14.861Z", "registered_at":"2015-09-09T09:11:14.861Z",
"valid_to":"2016-09-09T09:11:14.861Z", "valid_to":"2016-09-09T09:11:14.861Z",
"registrant_id": 1, "registrant":{
"name":"John Smith",
"id":"acadf23e-47c4-4606-8f67-76e071a1cca2"
},
"admin_contacts":[
{
"name":"John Smith",
"id":"62015e7d-42c8-4d68-8164-e9b71680fd95"
},
{
"name":"William Smith",
"id":"a041c5b6-7772-4fac-83cd-fbce3b2c8867"
}
],
"tech_contacts":[
{
"name":"John Smith",
"id":"62015e7d-42c8-4d68-8164-e9b71680fd95"
},
{
"name":"William Smith",
"id":"a041c5b6-7772-4fac-83cd-fbce3b2c8867"
}
],
"transfer_code":"98oiewslkfkd", "transfer_code":"98oiewslkfkd",
"created_at":"2015-09-09T09:11:14.861Z", "created_at":"2015-09-09T09:11:14.861Z",
"updated_at":"2015-09-09T09:11:14.860Z", "updated_at":"2015-09-09T09:11:14.860Z",
@ -153,7 +213,9 @@ Content-Type: application/json
"registrant_verification_asked_at":null, "registrant_verification_asked_at":null,
"registrant_verification_token":null, "registrant_verification_token":null,
"locked_by_registrant_at":null, "locked_by_registrant_at":null,
"pending_json": {}, "pending_json":{
},
"force_delete_at":null, "force_delete_at":null,
"statuses":[ "statuses":[
"ok" "ok"
@ -161,18 +223,30 @@ Content-Type: application/json
"nameservers":[ "nameservers":[
{ {
"hostname":"ns1.bestnames.test", "hostname":"ns1.bestnames.test",
"ipv4": ["173.245.58.41"], "ipv4":[
"ipv6": ["2400:cb00:2049:1::adf5:3a33"] "173.245.58.41"
],
"ipv6":[
"2400:cb00:2049:1::adf5:3a33"
]
}, },
{ {
"hostname":"ns1.bestnames.test", "hostname":"ns1.bestnames.test",
"ipv4": ["173.245.58.51"], "ipv4":[
"ipv6": ["2400:cb00:2049:1::adf5:3b29"] "173.245.58.51"
}, ],
"ipv6":[
"2400:cb00:2049:1::adf5:3b29"
]
}
], ],
"reserved":false, "reserved":false,
"status_notes": {}, "status_notes":{
"statuses_backup": []
},
"statuses_backup":[
]
} }
``` ```

View file

@ -9,49 +9,71 @@ module Serializers
def to_json def to_json
{ {
id: @domain.uuid, id: domain.uuid,
name: @domain.name, name: domain.name,
registrar: { registrar: {
name: @domain.registrar.name, name: domain.registrar.name,
website: @domain.registrar.website, website: domain.registrar.website,
}, },
registered_at: @domain.registered_at, registered_at: domain.registered_at,
valid_to: @domain.valid_to, valid_to: domain.valid_to,
created_at: @domain.created_at, created_at: domain.created_at,
updated_at: @domain.updated_at, updated_at: domain.updated_at,
registrant: @domain.registrant_name, registrant: {
transfer_code: @domain.transfer_code, name: domain.registrant.name,
name_dirty: @domain.name_dirty, id: domain.registrant.uuid,
name_puny: @domain.name_puny, },
period: @domain.period, tech_contacts: contacts(:tech),
period_unit: @domain.period_unit, admin_contacts: contacts(:admin),
creator_str: @domain.creator_str, transfer_code: domain.transfer_code,
updator_str: @domain.updator_str, name_dirty: domain.name_dirty,
legacy_id: @domain.legacy_id, name_puny: domain.name_puny,
legacy_registrar_id: @domain.legacy_registrar_id, period: domain.period,
legacy_registrant_id: @domain.legacy_registrant_id, period_unit: domain.period_unit,
outzone_at: @domain.outzone_at, creator_str: domain.creator_str,
delete_at: @domain.delete_at, updator_str: domain.updator_str,
registrant_verification_asked_at: @domain.registrant_verification_asked_at, legacy_id: domain.legacy_id,
registrant_verification_token: @domain.registrant_verification_token, legacy_registrar_id: domain.legacy_registrar_id,
pending_json: @domain.pending_json, legacy_registrant_id: domain.legacy_registrant_id,
force_delete_at: @domain.force_delete_at, outzone_at: domain.outzone_at,
statuses: @domain.statuses, delete_at: domain.delete_at,
locked_by_registrant_at: @domain.locked_by_registrant_at, registrant_verification_asked_at: domain.registrant_verification_asked_at,
reserved: @domain.reserved, registrant_verification_token: domain.registrant_verification_token,
status_notes: @domain.status_notes, pending_json: domain.pending_json,
force_delete_at: domain.force_delete_at,
statuses: domain.statuses,
locked_by_registrant_at: domain.locked_by_registrant_at,
reserved: domain.reserved,
status_notes: domain.status_notes,
nameservers: nameservers, nameservers: nameservers,
} }
end end
private private
def nameservers def contacts(type)
array_of_nameservers = Array.new contact_pool = begin
if type == :tech
domain.tech_contacts
elsif type == :admin
domain.admin_contacts
end
end
@domain.nameservers.map do |nameserver| array_of_contacts = []
array_of_nameservers.push({ hostname: nameserver.hostname, ipv4: nameserver.ipv4, contact_pool.map do |contact|
ipv6: nameserver.ipv6 }) array_of_contacts.push(name: contact.name, id: contact.uuid)
end
array_of_contacts
end
def nameservers
array_of_nameservers = []
domain.nameservers.map do |nameserver|
array_of_nameservers.push(hostname: nameserver.hostname, ipv4: nameserver.ipv4,
ipv6: nameserver.ipv6)
end end
array_of_nameservers array_of_nameservers

View file

@ -30,6 +30,11 @@ class RegistrantApiDomainsTest < ApplicationIntegrationTest
assert_equal('hospital.test', domain[:name]) assert_equal('hospital.test', domain[:name])
assert_equal('5edda1a5-3548-41ee-8b65-6d60daf85a37', domain[:id]) assert_equal('5edda1a5-3548-41ee-8b65-6d60daf85a37', domain[:id])
assert_equal({name: 'John', id: 'eb2f2766-b44c-4e14-9f16-32ab1a7cb957'}, domain[:registrant])
assert_equal([{name: 'John', id: 'eb2f2766-b44c-4e14-9f16-32ab1a7cb957'}],
domain[:admin_contacts])
assert_equal([{name: 'John', id: 'eb2f2766-b44c-4e14-9f16-32ab1a7cb957'}],
domain[:tech_contacts])
assert_equal({ name: 'Good Names', website: nil }, domain[:registrar]) assert_equal({ name: 'Good Names', website: nil }, domain[:registrar])
assert_equal([], domain[:nameservers]) assert_equal([], domain[:nameservers])
assert(domain.has_key?(:locked_by_registrant_at)) assert(domain.has_key?(:locked_by_registrant_at))

View file

@ -130,6 +130,11 @@ class RegistrantApiRegistryLocksTest < ApplicationIntegrationTest
response_json = JSON.parse(response.body, symbolize_names: true) response_json = JSON.parse(response.body, symbolize_names: true)
assert_equal({ name: 'Best Names', website: 'bestnames.test' }, response_json[:registrar]) assert_equal({ name: 'Best Names', website: 'bestnames.test' }, response_json[:registrar])
assert_equal({name: 'John', id: 'eb2f2766-b44c-4e14-9f16-32ab1a7cb957'}, response_json[:registrant])
assert_equal([{name: 'Jane', id: '9db3de62-2414-4487-bee2-d5c155567768'}], response_json[:admin_contacts])
assert_equal([{name: 'William', id: '0aa54704-d6f7-4ca9-b8ca-2827d9a4e4eb'},
{name: 'Acme Ltd', id: 'f1dd365c-5be9-4b3d-a44e-3fa002465e4d'}],
response_json[:tech_contacts])
assert_equal( assert_equal(
[{hostname: 'ns1.bestnames.test', ipv4: ['192.0.2.1'], ipv6: ['2001:db8::1']}, [{hostname: 'ns1.bestnames.test', ipv4: ['192.0.2.1'], ipv6: ['2001:db8::1']},
{hostname: 'ns2.bestnames.test', ipv4: ['192.0.2.2'], ipv6: ['2001:db8::2']}].to_set, {hostname: 'ns2.bestnames.test', ipv4: ['192.0.2.2'], ipv6: ['2001:db8::2']}].to_set,

View file

@ -28,6 +28,20 @@ class SerializersRegistrantApiDomainTest < ApplicationIntegrationTest
assert_equal({name: 'Best Names', website: 'bestnames.test' }, @json[:registrar]) assert_equal({name: 'Best Names', website: 'bestnames.test' }, @json[:registrar])
end end
def test_returns_registrant_name_and_uuid
assert_equal({name: 'John', id: 'eb2f2766-b44c-4e14-9f16-32ab1a7cb957'},
@json[:registrant])
end
def test_returns_contacts_name_and_uuid
assert_equal([{name: 'John', id: 'eb2f2766-b44c-4e14-9f16-32ab1a7cb957'},
{name: 'William', id: '0aa54704-d6f7-4ca9-b8ca-2827d9a4e4eb'}].to_set,
@json[:admin_contacts].to_set)
assert_equal([{name: 'William', id: '0aa54704-d6f7-4ca9-b8ca-2827d9a4e4eb'}].to_set,
@json[:tech_contacts].to_set)
end
def test_returns_nameserver_hostnames_or_an_empty_array def test_returns_nameserver_hostnames_or_an_empty_array
expected_nameserver_1 = { expected_nameserver_1 = {
hostname: 'ns1.bestnames.test', hostname: 'ns1.bestnames.test',
@ -53,8 +67,8 @@ class SerializersRegistrantApiDomainTest < ApplicationIntegrationTest
def test_other_fields_are_also_present def test_other_fields_are_also_present
keys = %i[id name registrar registered_at valid_to created_at updated_at keys = %i[id name registrar registered_at valid_to created_at updated_at
registrant transfer_code name_dirty name_puny period period_unit registrant tech_contacts admin_contacts transfer_code name_dirty name_puny period
creator_str updator_str legacy_id legacy_registrar_id legacy_registrant_id period_unit creator_str updator_str legacy_id legacy_registrar_id legacy_registrant_id
outzone_at delete_at registrant_verification_asked_at outzone_at delete_at registrant_verification_asked_at
registrant_verification_token pending_json force_delete_at statuses registrant_verification_token pending_json force_delete_at statuses
locked_by_registrant_at reserved status_notes nameservers] locked_by_registrant_at reserved status_notes nameservers]