mirror of
https://github.com/internetee/registry.git
synced 2025-06-10 06:34:46 +02:00
Expand on the response about registrar and nameservers
* Return website for registrar * Return IPv4 and IPv6 addresses for nameservers
This commit is contained in:
parent
28304559fd
commit
2a4995226f
8 changed files with 121 additions and 25 deletions
|
@ -22,7 +22,10 @@ Content-Type: application/json
|
|||
{
|
||||
"id": "98d1083a-8863-4153-93e4-caee4a013535",
|
||||
"name": "domain0.ee",
|
||||
"registrar": "Best Names",
|
||||
"registrar": {
|
||||
"name": "Best Names",
|
||||
"website": "example.com"
|
||||
},
|
||||
"registered_at": "2015-09-09T09:11:14.861Z",
|
||||
"valid_to": "2016-09-09T09:11:14.861Z",
|
||||
"registrant_id": 1,
|
||||
|
@ -49,8 +52,16 @@ Content-Type: application/json
|
|||
"ok"
|
||||
],
|
||||
"nameservers": [
|
||||
"ns1.bestnames.test",
|
||||
"ns2.bestnames.test"
|
||||
{
|
||||
"hostname": "ns1.bestnames.test",
|
||||
"ipv4": ["173.245.58.41"],
|
||||
"ipv6": ["2400:cb00:2049:1::adf5:3a33"]
|
||||
},
|
||||
{
|
||||
"hostname": "ns1.bestnames.test",
|
||||
"ipv4": ["173.245.58.51"],
|
||||
"ipv6": ["2400:cb00:2049:1::adf5:3b29"]
|
||||
},
|
||||
],
|
||||
"reserved": false,
|
||||
"status_notes": {},
|
||||
|
@ -91,7 +102,10 @@ Content-Type: application/json
|
|||
{
|
||||
"id": "98d1083a-8863-4153-93e4-caee4a013535",
|
||||
"name": "domain0.ee",
|
||||
"registrar": "Best Names",
|
||||
"registrar": {
|
||||
"name": "Best Names",
|
||||
"website": "example.com"
|
||||
},
|
||||
"valid_to": "2016-09-09T09:11:14.861Z",
|
||||
"registered_at": "2015-09-09T09:11:14.861Z",
|
||||
"registrant_id": 1,
|
||||
|
@ -118,8 +132,16 @@ Content-Type: application/json
|
|||
"ok"
|
||||
],
|
||||
"nameservers": [
|
||||
"ns1.bestnames.test",
|
||||
"ns2.bestnames.test"
|
||||
{
|
||||
"hostname": "ns1.bestnames.test",
|
||||
"ipv4": ["173.245.58.41"],
|
||||
"ipv6": ["2400:cb00:2049:1::adf5:3a33"]
|
||||
},
|
||||
{
|
||||
"hostname": "ns1.bestnames.test",
|
||||
"ipv4": ["173.245.58.51"],
|
||||
"ipv6": ["2400:cb00:2049:1::adf5:3b29"]
|
||||
},
|
||||
],
|
||||
"reserved": false,
|
||||
"status_notes": {},
|
||||
|
@ -151,7 +173,10 @@ Content-Type: application/json
|
|||
{
|
||||
"id": "98d1083a-8863-4153-93e4-caee4a013535",
|
||||
"name": "domain0.ee",
|
||||
"registrar": "Best Names",
|
||||
"registrar": {
|
||||
"name": "Best Names",
|
||||
"website": "example.com"
|
||||
},
|
||||
"registered_at": "2015-09-09T09:11:14.861Z",
|
||||
"valid_to": "2016-09-09T09:11:14.861Z",
|
||||
"registrant_id": 1,
|
||||
|
@ -178,8 +203,16 @@ Content-Type: application/json
|
|||
"ok"
|
||||
],
|
||||
"nameservers": [
|
||||
"ns1.bestnames.test",
|
||||
"ns2.bestnames.test"
|
||||
{
|
||||
"hostname": "ns1.bestnames.test",
|
||||
"ipv4": ["173.245.58.41"],
|
||||
"ipv6": ["2400:cb00:2049:1::adf5:3a33"]
|
||||
},
|
||||
{
|
||||
"hostname": "ns1.bestnames.test",
|
||||
"ipv4": ["173.245.58.51"],
|
||||
"ipv6": ["2400:cb00:2049:1::adf5:3b29"]
|
||||
},
|
||||
],
|
||||
"reserved": false,
|
||||
"status_notes": {},
|
||||
|
|
|
@ -21,7 +21,10 @@ Content-Type: application/json
|
|||
{
|
||||
"id": "98d1083a-8863-4153-93e4-caee4a013535",
|
||||
"name": "domain0.ee",
|
||||
"registrar": "Best Names",
|
||||
"registrar": {
|
||||
"name": "Best Names",
|
||||
"website": "example.com"
|
||||
},
|
||||
"registered_at": "2015-09-09T09:11:14.861Z",
|
||||
"valid_to": "2016-09-09T09:11:14.861Z",
|
||||
"registrant_id": 1,
|
||||
|
@ -50,8 +53,16 @@ Content-Type: application/json
|
|||
"serverTransferProhibited"
|
||||
],
|
||||
"nameservers": [
|
||||
"ns1.bestnames.test",
|
||||
"ns2.bestnames.test"
|
||||
{
|
||||
"hostname": "ns1.bestnames.test",
|
||||
"ipv4": ["173.245.58.41"],
|
||||
"ipv6": ["2400:cb00:2049:1::adf5:3a33"]
|
||||
},
|
||||
{
|
||||
"hostname": "ns1.bestnames.test",
|
||||
"ipv4": ["173.245.58.51"],
|
||||
"ipv6": ["2400:cb00:2049:1::adf5:3b29"]
|
||||
},
|
||||
],
|
||||
"reserved": false,
|
||||
"status_notes": {},
|
||||
|
@ -118,7 +129,10 @@ Content-Type: application/json
|
|||
{
|
||||
"id": "98d1083a-8863-4153-93e4-caee4a013535",
|
||||
"name": "domain0.ee",
|
||||
"registrar": "Best Names",
|
||||
"registrar": {
|
||||
"name": "Best Names",
|
||||
"website": "example.com"
|
||||
},
|
||||
"registered_at": "2015-09-09T09:11:14.861Z",
|
||||
"valid_to": "2016-09-09T09:11:14.861Z",
|
||||
"registrant_id": 1,
|
||||
|
@ -145,8 +159,16 @@ Content-Type: application/json
|
|||
"ok"
|
||||
],
|
||||
"nameservers": [
|
||||
"ns1.bestnames.test",
|
||||
"ns2.bestnames.test"
|
||||
{
|
||||
"hostname": "ns1.bestnames.test",
|
||||
"ipv4": ["173.245.58.41"],
|
||||
"ipv6": ["2400:cb00:2049:1::adf5:3a33"]
|
||||
},
|
||||
{
|
||||
"hostname": "ns1.bestnames.test",
|
||||
"ipv4": ["173.245.58.51"],
|
||||
"ipv6": ["2400:cb00:2049:1::adf5:3b29"]
|
||||
},
|
||||
],
|
||||
"reserved": false,
|
||||
"status_notes": {},
|
||||
|
|
|
@ -11,7 +11,10 @@ module Serializers
|
|||
{
|
||||
id: @domain.uuid,
|
||||
name: @domain.name,
|
||||
registrar: @domain.registrar.name,
|
||||
registrar: {
|
||||
name: @domain.registrar.name,
|
||||
website: @domain.registrar.website,
|
||||
},
|
||||
registered_at: @domain.registered_at,
|
||||
valid_to: @domain.valid_to,
|
||||
created_at: @domain.created_at,
|
||||
|
@ -37,9 +40,22 @@ module Serializers
|
|||
locked_by_registrant_at: @domain.locked_by_registrant_at,
|
||||
reserved: @domain.reserved,
|
||||
status_notes: @domain.status_notes,
|
||||
nameservers: @domain.nameservers.map(&:hostname),
|
||||
nameservers: nameservers,
|
||||
}
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def nameservers
|
||||
array_of_nameservers = Array.new
|
||||
|
||||
@domain.nameservers.map do |nameserver|
|
||||
array_of_nameservers << { hostname: nameserver.hostname, ipv4: nameserver.ipv4,
|
||||
ipv6: nameserver.ipv6 }
|
||||
end
|
||||
|
||||
array_of_nameservers
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
10
test/fixtures/nameservers.yml
vendored
10
test/fixtures/nameservers.yml
vendored
|
@ -16,10 +16,20 @@ shop_ns2:
|
|||
|
||||
airport_ns1:
|
||||
hostname: ns1.bestnames.test
|
||||
ipv4:
|
||||
- 192.0.2.2
|
||||
ipv6:
|
||||
- 2001:db8::2
|
||||
domain: airport
|
||||
|
||||
airport_ns2:
|
||||
hostname: ns2.bestnames.test
|
||||
ipv4:
|
||||
- 192.0.2.0
|
||||
- 192.0.2.3
|
||||
- 192.0.2.1
|
||||
ipv6:
|
||||
- 2001:db8::1
|
||||
domain: airport
|
||||
|
||||
metro_ns1:
|
||||
|
|
3
test/fixtures/registrars.yml
vendored
3
test/fixtures/registrars.yml
vendored
|
@ -11,6 +11,7 @@ bestnames:
|
|||
accounting_customer_code: bestnames
|
||||
language: en
|
||||
billing_email: billing@example.com
|
||||
website: bestnames.test
|
||||
|
||||
goodnames:
|
||||
name: Good Names
|
||||
|
@ -41,4 +42,4 @@ complete:
|
|||
language: en
|
||||
vat_no: US12345
|
||||
vat_rate: 0.05
|
||||
billing_email: billing@bestnames.test
|
||||
billing_email: billing@bestnames.test
|
||||
|
|
|
@ -30,7 +30,7 @@ class RegistrantApiDomainsTest < ApplicationIntegrationTest
|
|||
|
||||
assert_equal('hospital.test', domain[:name])
|
||||
assert_equal('5edda1a5-3548-41ee-8b65-6d60daf85a37', domain[:id])
|
||||
assert_equal('Good Names', domain[:registrar])
|
||||
assert_equal({ name: 'Good Names', website: nil }, domain[:registrar])
|
||||
assert_equal([], domain[:nameservers])
|
||||
assert(domain.has_key?(:locked_by_registrant_at))
|
||||
end
|
||||
|
@ -52,7 +52,7 @@ class RegistrantApiDomainsTest < ApplicationIntegrationTest
|
|||
assert(array_of_domain_names.include?('hospital.test'))
|
||||
|
||||
array_of_domain_registrars = response_json.map { |x| x[:registrar] }
|
||||
assert(array_of_domain_registrars.include?('Good Names'))
|
||||
assert(array_of_domain_registrars.include?({name: 'Good Names', website: nil}))
|
||||
end
|
||||
|
||||
def test_root_accepts_limit_and_offset_parameters
|
||||
|
|
|
@ -129,8 +129,10 @@ class RegistrantApiRegistryLocksTest < ApplicationIntegrationTest
|
|||
assert_equal(200, response.status)
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_equal('Best Names', response_json[:registrar])
|
||||
assert_equal(['ns1.bestnames.test', 'ns2.bestnames.test'].to_set,
|
||||
assert_equal({ name: 'Best Names', website: 'bestnames.test' }, response_json[:registrar])
|
||||
assert_equal(
|
||||
[{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,
|
||||
response_json[:nameservers].to_set)
|
||||
assert_equal(Time.zone.parse('2010-07-05'), response_json[:locked_by_registrant_at])
|
||||
end
|
||||
|
|
|
@ -25,12 +25,24 @@ class SerializersRegistrantApiDomainTest < ApplicationIntegrationTest
|
|||
end
|
||||
|
||||
def test_returns_registrar_name
|
||||
assert_equal('Best Names', @json[:registrar])
|
||||
assert_equal({name: 'Best Names', website: 'bestnames.test' }, @json[:registrar])
|
||||
end
|
||||
|
||||
def test_returns_nameserver_hostnames_or_an_empty_array
|
||||
expected_nameservers = ['ns1.bestnames.test', 'ns2.bestnames.test']
|
||||
assert_equal(expected_nameservers.to_set, @json[:nameservers].to_set)
|
||||
expected_nameserver_1 = {
|
||||
hostname: 'ns1.bestnames.test',
|
||||
ipv4: ['192.0.2.2'],
|
||||
ipv6: ['2001:db8::2']
|
||||
}
|
||||
|
||||
expected_nameserver_2 = {
|
||||
hostname: 'ns2.bestnames.test',
|
||||
ipv4: ['192.0.2.0', '192.0.2.3', '192.0.2.1'],
|
||||
ipv6: ['2001:db8::1']
|
||||
}
|
||||
|
||||
assert(@json[:nameservers].include?(expected_nameserver_1))
|
||||
assert(@json[:nameservers].include?(expected_nameserver_2))
|
||||
|
||||
other_domain = domains(:hospital)
|
||||
other_serializer = Serializers::RegistrantApi::Domain.new(other_domain)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue