mirror of
https://github.com/internetee/registry.git
synced 2025-06-07 21:25:39 +02:00
Merge pull request #997 from internetee/registry-991-refactor-registrant-api-domain-details-response
Registry 991 add new items to registrant api domain response
This commit is contained in:
commit
db6cde7943
13 changed files with 661 additions and 152 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
require 'serializers/registrant_api/domain'
|
||||||
|
|
||||||
module Api
|
module Api
|
||||||
module V1
|
module V1
|
||||||
module Registrant
|
module Registrant
|
||||||
|
@ -17,7 +19,13 @@ module Api
|
||||||
end
|
end
|
||||||
|
|
||||||
@domains = associated_domains(current_registrant_user).limit(limit).offset(offset)
|
@domains = associated_domains(current_registrant_user).limit(limit).offset(offset)
|
||||||
render json: @domains
|
|
||||||
|
serialized_domains = @domains.map do |item|
|
||||||
|
serializer = Serializers::RegistrantApi::Domain.new(item)
|
||||||
|
serializer.to_json
|
||||||
|
end
|
||||||
|
|
||||||
|
render json: serialized_domains
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
@ -25,7 +33,8 @@ module Api
|
||||||
@domain = domain_pool.find_by(uuid: params[:uuid])
|
@domain = domain_pool.find_by(uuid: params[:uuid])
|
||||||
|
|
||||||
if @domain
|
if @domain
|
||||||
render json: @domain
|
serializer = Serializers::RegistrantApi::Domain.new(@domain)
|
||||||
|
render json: serializer.to_json
|
||||||
else
|
else
|
||||||
render json: { errors: [{ base: ['Domain not found'] }] }, status: :not_found
|
render json: { errors: [{ base: ['Domain not found'] }] }, status: :not_found
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
require 'serializers/registrant_api/domain'
|
||||||
|
|
||||||
module Api
|
module Api
|
||||||
module V1
|
module V1
|
||||||
module Registrant
|
module Registrant
|
||||||
|
@ -7,7 +9,7 @@ module Api
|
||||||
|
|
||||||
def create
|
def create
|
||||||
if @domain.apply_registry_lock
|
if @domain.apply_registry_lock
|
||||||
render json: @domain
|
render json: serialized_domain(@domain)
|
||||||
else
|
else
|
||||||
render json: { errors: [{ base: ['Domain cannot be locked'] }] },
|
render json: { errors: [{ base: ['Domain cannot be locked'] }] },
|
||||||
status: :unprocessable_entity
|
status: :unprocessable_entity
|
||||||
|
@ -16,7 +18,7 @@ module Api
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
if @domain.remove_registry_lock
|
if @domain.remove_registry_lock
|
||||||
render json: @domain
|
render json: serialized_domain(@domain)
|
||||||
else
|
else
|
||||||
render json: { errors: [{ base: ['Domain is not locked'] }] },
|
render json: { errors: [{ base: ['Domain is not locked'] }] },
|
||||||
status: :unprocessable_entity
|
status: :unprocessable_entity
|
||||||
|
@ -42,6 +44,11 @@ module Api
|
||||||
] },
|
] },
|
||||||
status: :unauthorized and return
|
status: :unauthorized and return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def serialized_domain(domain)
|
||||||
|
serializer = Serializers::RegistrantApi::Domain.new(domain)
|
||||||
|
serializer.to_json
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
5
db/migrate/20181002090319_remove_domain_status_field.rb
Normal file
5
db/migrate/20181002090319_remove_domain_status_field.rb
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
class RemoveDomainStatusField < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
remove_column :domains, :status
|
||||||
|
end
|
||||||
|
end
|
|
@ -885,7 +885,6 @@ CREATE TABLE public.domains (
|
||||||
name character varying,
|
name character varying,
|
||||||
registrar_id integer NOT NULL,
|
registrar_id integer NOT NULL,
|
||||||
registered_at timestamp without time zone,
|
registered_at timestamp without time zone,
|
||||||
status character varying,
|
|
||||||
valid_to timestamp without time zone NOT NULL,
|
valid_to timestamp without time zone NOT NULL,
|
||||||
registrant_id integer NOT NULL,
|
registrant_id integer NOT NULL,
|
||||||
transfer_code character varying NOT NULL,
|
transfer_code character varying NOT NULL,
|
||||||
|
@ -4778,3 +4777,5 @@ INSERT INTO schema_migrations (version) VALUES ('20180824092855');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20180824102834');
|
INSERT INTO schema_migrations (version) VALUES ('20180824102834');
|
||||||
|
|
||||||
|
INSERT INTO schema_migrations (version) VALUES ('20181002090319');
|
||||||
|
|
||||||
|
|
|
@ -11,63 +11,108 @@ Returns domains of the current registrant.
|
||||||
| ---------- | -------- | ---- | -------------- | ----------- |
|
| ---------- | -------- | ---- | -------------- | ----------- |
|
||||||
| limit | false | Integer | [1..200] | How many domains to show |
|
| limit | false | Integer | [1..200] | How many domains to show |
|
||||||
| offset | false | Integer | | Domain number to start at |
|
| offset | false | Integer | | Domain number to start at |
|
||||||
| details | false | String | ["true", "false"] | Whether to include details |
|
|
||||||
|
|
||||||
#### Request
|
|
||||||
```
|
|
||||||
GET api/v1/registrant/domains?limit=1&details=true HTTP/1.1
|
|
||||||
Accept: application/json
|
|
||||||
Authorization: Bearer Z2l0bGFiOmdoeXQ5ZTRmdQ==
|
|
||||||
Content-Type: application/json
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Response
|
#### Response
|
||||||
```
|
```
|
||||||
HTTP/1.1 200
|
HTTP/1.1 200
|
||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
|
|
||||||
{
|
[
|
||||||
"domains": [
|
{
|
||||||
{
|
"id":"98d1083a-8863-4153-93e4-caee4a013535",
|
||||||
"uuid": "98d1083a-8863-4153-93e4-caee4a013535",
|
"name":"domain0.ee",
|
||||||
"name": "domain0.ee",
|
"registrar":{
|
||||||
"registrar_id": 2,
|
"name":"Best Names",
|
||||||
"registered_at": "2015-09-09T09:11:14.861Z",
|
"website":"example.com"
|
||||||
"status": null,
|
},
|
||||||
"valid_from": "2015-09-09T09:11:14.861Z",
|
"valid_to":"2016-09-09T09:11:14.861Z",
|
||||||
"valid_to": "2016-09-09T09:11:14.861Z",
|
"registered_at":"2015-09-09T09:11:14.861Z",
|
||||||
"registrant_id": 1,
|
"registrant":{
|
||||||
"transfer_code": "98oiewslkfkd",
|
"name":"John Smith",
|
||||||
"created_at": "2015-09-09T09:11:14.861Z",
|
"id":"acadf23e-47c4-4606-8f67-76e071a1cca2"
|
||||||
"updated_at": "2015-09-09T09:11:14.860Z",
|
},
|
||||||
"name_dirty": "domain0.ee",
|
"admin_contacts":[
|
||||||
"name_puny": "domain0.ee",
|
{
|
||||||
"period": 1,
|
"name":"John Smith",
|
||||||
"period_unit": "y",
|
"id":"62015e7d-42c8-4d68-8164-e9b71680fd95"
|
||||||
"creator_str": null,
|
|
||||||
"updator_str": null,
|
|
||||||
"legacy_id": null,
|
|
||||||
"legacy_registrar_id": null,
|
|
||||||
"legacy_registrant_id": null,
|
|
||||||
"outzone_at": "2016-09-24T09:11:14.861Z",
|
|
||||||
"delete_at": "2016-10-24T09:11:14.861Z",
|
|
||||||
"registrant_verification_asked_at": null,
|
|
||||||
"registrant_verification_token": null,
|
|
||||||
"pending_json": {
|
|
||||||
},
|
},
|
||||||
"force_delete_at": null,
|
{
|
||||||
"statuses": [
|
"name":"William Smith",
|
||||||
"ok"
|
"id":"a041c5b6-7772-4fac-83cd-fbce3b2c8867"
|
||||||
],
|
}
|
||||||
"reserved": false,
|
],
|
||||||
"status_notes": {
|
"tech_contacts":[
|
||||||
|
{
|
||||||
|
"name":"John Smith",
|
||||||
|
"id":"62015e7d-42c8-4d68-8164-e9b71680fd95"
|
||||||
},
|
},
|
||||||
"statuses_backup": [
|
{
|
||||||
]
|
"name":"William Smith",
|
||||||
}
|
"id":"a041c5b6-7772-4fac-83cd-fbce3b2c8867"
|
||||||
],
|
}
|
||||||
"total_number_of_records": 2
|
],
|
||||||
}
|
"transfer_code":"98oiewslkfkd",
|
||||||
|
"created_at":"2015-09-09T09:11:14.861Z",
|
||||||
|
"updated_at":"2015-09-09T09:11:14.860Z",
|
||||||
|
"name_dirty":"domain0.ee",
|
||||||
|
"name_puny":"domain0.ee",
|
||||||
|
"period":1,
|
||||||
|
"period_unit":"y",
|
||||||
|
"creator_str":null,
|
||||||
|
"updator_str":null,
|
||||||
|
"legacy_id":null,
|
||||||
|
"legacy_registrar_id":null,
|
||||||
|
"legacy_registrant_id":null,
|
||||||
|
"outzone_at":"2016-09-24T09:11:14.861Z",
|
||||||
|
"delete_at":"2016-10-24T09:11:14.861Z",
|
||||||
|
"registrant_verification_asked_at":null,
|
||||||
|
"registrant_verification_token":null,
|
||||||
|
"locked_by_registrant_at":"2015-09-09T09:11:14.861Z",
|
||||||
|
"pending_json":{
|
||||||
|
|
||||||
|
},
|
||||||
|
"force_delete_at":null,
|
||||||
|
"statuses":[
|
||||||
|
"ok"
|
||||||
|
],
|
||||||
|
"nameservers":[
|
||||||
|
{
|
||||||
|
"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":{
|
||||||
|
|
||||||
|
},
|
||||||
|
"statuses_backup":[
|
||||||
|
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Request
|
||||||
|
```
|
||||||
|
GET api/v1/registrant/domains HTTP/1.1
|
||||||
|
Accept: application/json
|
||||||
|
Authorization: Bearer Z2l0bGFiOmdoeXQ5ZTRmdQ==
|
||||||
|
Content-Type: application/json
|
||||||
```
|
```
|
||||||
|
|
||||||
## GET api/v1/registrant/domains
|
## GET api/v1/registrant/domains
|
||||||
|
@ -77,7 +122,7 @@ Returns domain names with offset.
|
||||||
|
|
||||||
#### Request
|
#### Request
|
||||||
```
|
```
|
||||||
GET api/v1/registrant/domains?offset=1 HTTP/1.1
|
GET api/v1/registrant/domains?offset=1&limit=1 HTTP/1.1
|
||||||
Accept: application/json
|
Accept: application/json
|
||||||
Authorization: Bearer Z2l0bGFiOmdoeXQ5ZTRmdQ==
|
Authorization: Bearer Z2l0bGFiOmdoeXQ5ZTRmdQ==
|
||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
|
@ -88,12 +133,94 @@ Content-Type: application/json
|
||||||
HTTP/1.1 200
|
HTTP/1.1 200
|
||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
|
|
||||||
{
|
[
|
||||||
"domains": [
|
{
|
||||||
"domain1.ee"
|
"id":"98d1083a-8863-4153-93e4-caee4a013535",
|
||||||
],
|
"name":"domain0.ee",
|
||||||
"total_number_of_records": 2
|
"registrar":{
|
||||||
}
|
"name":"Best Names",
|
||||||
|
"website":"example.com"
|
||||||
|
},
|
||||||
|
"valid_to":"2016-09-09T09:11:14.861Z",
|
||||||
|
"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",
|
||||||
|
"created_at":"2015-09-09T09:11:14.861Z",
|
||||||
|
"updated_at":"2015-09-09T09:11:14.860Z",
|
||||||
|
"name_dirty":"domain0.ee",
|
||||||
|
"name_puny":"domain0.ee",
|
||||||
|
"period":1,
|
||||||
|
"period_unit":"y",
|
||||||
|
"creator_str":null,
|
||||||
|
"updator_str":null,
|
||||||
|
"legacy_id":null,
|
||||||
|
"legacy_registrar_id":null,
|
||||||
|
"legacy_registrant_id":null,
|
||||||
|
"outzone_at":"2016-09-24T09:11:14.861Z",
|
||||||
|
"delete_at":"2016-10-24T09:11:14.861Z",
|
||||||
|
"registrant_verification_asked_at":null,
|
||||||
|
"registrant_verification_token":null,
|
||||||
|
"locked_by_registrant_at":"2015-09-09T09:11:14.861Z",
|
||||||
|
"pending_json":{
|
||||||
|
|
||||||
|
},
|
||||||
|
"force_delete_at":null,
|
||||||
|
"statuses":[
|
||||||
|
"ok"
|
||||||
|
],
|
||||||
|
"nameservers":[
|
||||||
|
{
|
||||||
|
"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":{
|
||||||
|
|
||||||
|
},
|
||||||
|
"statuses_backup":[
|
||||||
|
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
## GET api/v1/registrant/domains/$UUID
|
## GET api/v1/registrant/domains/$UUID
|
||||||
|
@ -116,38 +243,89 @@ HTTP/1.1 200
|
||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
|
|
||||||
{
|
{
|
||||||
"uuid": "98d1083a-8863-4153-93e4-caee4a013535",
|
"id":"98d1083a-8863-4153-93e4-caee4a013535",
|
||||||
"name": "domain0.ee",
|
"name":"domain0.ee",
|
||||||
"registrar_id": 2,
|
"registrar":{
|
||||||
"registered_at": "2015-09-09T09:11:14.861Z",
|
"name":"Best Names",
|
||||||
"status": null,
|
"website":"example.com"
|
||||||
"valid_from": "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",
|
||||||
"transfer_code": "98oiewslkfkd",
|
"registrant":{
|
||||||
"created_at": "2015-09-09T09:11:14.861Z",
|
"name":"John Smith",
|
||||||
"updated_at": "2015-09-09T09:11:14.860Z",
|
"id":"acadf23e-47c4-4606-8f67-76e071a1cca2"
|
||||||
"name_dirty": "domain0.ee",
|
},
|
||||||
"name_puny": "domain0.ee",
|
"admin_contacts":[
|
||||||
"period": 1,
|
{
|
||||||
"period_unit": "y",
|
"name":"John Smith",
|
||||||
"creator_str": null,
|
"id":"62015e7d-42c8-4d68-8164-e9b71680fd95"
|
||||||
"updator_str": null,
|
},
|
||||||
"legacy_id": null,
|
{
|
||||||
"legacy_registrar_id": null,
|
"name":"William Smith",
|
||||||
"legacy_registrant_id": null,
|
"id":"a041c5b6-7772-4fac-83cd-fbce3b2c8867"
|
||||||
"outzone_at": "2016-09-24T09:11:14.861Z",
|
}
|
||||||
"delete_at": "2016-10-24T09:11:14.861Z",
|
],
|
||||||
"registrant_verification_asked_at": null,
|
"tech_contacts":[
|
||||||
"registrant_verification_token": null,
|
{
|
||||||
"pending_json": {},
|
"name":"John Smith",
|
||||||
"force_delete_at": null,
|
"id":"62015e7d-42c8-4d68-8164-e9b71680fd95"
|
||||||
"statuses": [
|
},
|
||||||
|
{
|
||||||
|
"name":"William Smith",
|
||||||
|
"id":"a041c5b6-7772-4fac-83cd-fbce3b2c8867"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"transfer_code":"98oiewslkfkd",
|
||||||
|
"created_at":"2015-09-09T09:11:14.861Z",
|
||||||
|
"updated_at":"2015-09-09T09:11:14.860Z",
|
||||||
|
"name_dirty":"domain0.ee",
|
||||||
|
"name_puny":"domain0.ee",
|
||||||
|
"period":1,
|
||||||
|
"period_unit":"y",
|
||||||
|
"creator_str":null,
|
||||||
|
"updator_str":null,
|
||||||
|
"legacy_id":null,
|
||||||
|
"legacy_registrar_id":null,
|
||||||
|
"legacy_registrant_id":null,
|
||||||
|
"outzone_at":"2016-09-24T09:11:14.861Z",
|
||||||
|
"delete_at":"2016-10-24T09:11:14.861Z",
|
||||||
|
"registrant_verification_asked_at":null,
|
||||||
|
"registrant_verification_token":null,
|
||||||
|
"locked_by_registrant_at":"2015-09-09T09:11:14.861Z",
|
||||||
|
"pending_json":{
|
||||||
|
|
||||||
|
},
|
||||||
|
"force_delete_at":null,
|
||||||
|
"statuses":[
|
||||||
"ok"
|
"ok"
|
||||||
],
|
],
|
||||||
"reserved": false,
|
"nameservers":[
|
||||||
"status_notes": {},
|
{
|
||||||
"statuses_backup": []
|
"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":{
|
||||||
|
|
||||||
|
},
|
||||||
|
"statuses_backup":[
|
||||||
|
|
||||||
|
]
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -19,40 +19,91 @@ HTTP/1.1 200
|
||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
|
|
||||||
{
|
{
|
||||||
"uuid": "98d1083a-8863-4153-93e4-caee4a013535",
|
"id":"98d1083a-8863-4153-93e4-caee4a013535",
|
||||||
"name": "domain0.ee",
|
"name":"domain0.ee",
|
||||||
"registrar_id": 2,
|
"registrar":{
|
||||||
"registered_at": "2015-09-09T09:11:14.861Z",
|
"name":"Best Names",
|
||||||
"status": null,
|
"website":"example.com"
|
||||||
"valid_from": "2015-09-09T09:11:14.861Z",
|
},
|
||||||
"valid_to": "2016-09-09T09:11:14.861Z",
|
"registrant":{
|
||||||
"registrant_id": 1,
|
"name":"John Smith",
|
||||||
"transfer_code": "98oiewslkfkd",
|
"id":"acadf23e-47c4-4606-8f67-76e071a1cca2"
|
||||||
"created_at": "2015-09-09T09:11:14.861Z",
|
},
|
||||||
"updated_at": "2015-09-09T09:11:14.860Z",
|
"admin_contacts":[
|
||||||
"name_dirty": "domain0.ee",
|
{
|
||||||
"name_puny": "domain0.ee",
|
"name":"John Smith",
|
||||||
"period": 1,
|
"id":"62015e7d-42c8-4d68-8164-e9b71680fd95"
|
||||||
"period_unit": "y",
|
},
|
||||||
"creator_str": null,
|
{
|
||||||
"updator_str": null,
|
"name":"William Smith",
|
||||||
"legacy_id": null,
|
"id":"a041c5b6-7772-4fac-83cd-fbce3b2c8867"
|
||||||
"legacy_registrar_id": null,
|
}
|
||||||
"legacy_registrant_id": null,
|
],
|
||||||
"outzone_at": "2016-09-24T09:11:14.861Z",
|
"tech_contacts":[
|
||||||
"delete_at": "2016-10-24T09:11:14.861Z",
|
{
|
||||||
"registrant_verification_asked_at": null,
|
"name":"John Smith",
|
||||||
"registrant_verification_token": null,
|
"id":"62015e7d-42c8-4d68-8164-e9b71680fd95"
|
||||||
"pending_json": {},
|
},
|
||||||
"force_delete_at": null,
|
{
|
||||||
"statuses": [
|
"name":"William Smith",
|
||||||
|
"id":"a041c5b6-7772-4fac-83cd-fbce3b2c8867"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"registered_at":"2015-09-09T09:11:14.861Z",
|
||||||
|
"valid_to":"2016-09-09T09:11:14.861Z",
|
||||||
|
"transfer_code":"98oiewslkfkd",
|
||||||
|
"created_at":"2015-09-09T09:11:14.861Z",
|
||||||
|
"updated_at":"2015-09-09T09:11:14.860Z",
|
||||||
|
"name_dirty":"domain0.ee",
|
||||||
|
"name_puny":"domain0.ee",
|
||||||
|
"period":1,
|
||||||
|
"period_unit":"y",
|
||||||
|
"creator_str":null,
|
||||||
|
"updator_str":null,
|
||||||
|
"legacy_id":null,
|
||||||
|
"legacy_registrar_id":null,
|
||||||
|
"legacy_registrant_id":null,
|
||||||
|
"outzone_at":"2016-09-24T09:11:14.861Z",
|
||||||
|
"delete_at":"2016-10-24T09:11:14.861Z",
|
||||||
|
"registrant_verification_asked_at":null,
|
||||||
|
"registrant_verification_token":null,
|
||||||
|
"locked_by_registrant_at":"2015-09-09T09:11:14.861Z",
|
||||||
|
"pending_json":{
|
||||||
|
|
||||||
|
},
|
||||||
|
"force_delete_at":null,
|
||||||
|
"statuses":[
|
||||||
"serverUpdateProhibited",
|
"serverUpdateProhibited",
|
||||||
"serverDeleteProhibited",
|
"serverDeleteProhibited",
|
||||||
"serverTransferProhibited"
|
"serverTransferProhibited"
|
||||||
],
|
],
|
||||||
"reserved": false,
|
"nameservers":[
|
||||||
"status_notes": {},
|
{
|
||||||
"statuses_backup": []
|
"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":{
|
||||||
|
|
||||||
|
},
|
||||||
|
"statuses_backup":[
|
||||||
|
|
||||||
|
]
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -113,38 +164,89 @@ HTTP/1.1 200
|
||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
|
|
||||||
{
|
{
|
||||||
"uuid": "98d1083a-8863-4153-93e4-caee4a013535",
|
"id":"98d1083a-8863-4153-93e4-caee4a013535",
|
||||||
"name": "domain0.ee",
|
"name":"domain0.ee",
|
||||||
"registrar_id": 2,
|
"registrar":{
|
||||||
"registered_at": "2015-09-09T09:11:14.861Z",
|
"name":"Best Names",
|
||||||
"status": null,
|
"website":"example.com"
|
||||||
"valid_from": "2015-09-09T09:11:14.861Z",
|
},
|
||||||
"valid_to": "2016-09-09T09:11:14.861Z",
|
"registered_at":"2015-09-09T09:11:14.861Z",
|
||||||
"registrant_id": 1,
|
"valid_to":"2016-09-09T09:11:14.861Z",
|
||||||
"transfer_code": "98oiewslkfkd",
|
"registrant":{
|
||||||
"created_at": "2015-09-09T09:11:14.861Z",
|
"name":"John Smith",
|
||||||
"updated_at": "2015-09-09T09:11:14.860Z",
|
"id":"acadf23e-47c4-4606-8f67-76e071a1cca2"
|
||||||
"name_dirty": "domain0.ee",
|
},
|
||||||
"name_puny": "domain0.ee",
|
"admin_contacts":[
|
||||||
"period": 1,
|
{
|
||||||
"period_unit": "y",
|
"name":"John Smith",
|
||||||
"creator_str": null,
|
"id":"62015e7d-42c8-4d68-8164-e9b71680fd95"
|
||||||
"updator_str": null,
|
},
|
||||||
"legacy_id": null,
|
{
|
||||||
"legacy_registrar_id": null,
|
"name":"William Smith",
|
||||||
"legacy_registrant_id": null,
|
"id":"a041c5b6-7772-4fac-83cd-fbce3b2c8867"
|
||||||
"outzone_at": "2016-09-24T09:11:14.861Z",
|
}
|
||||||
"delete_at": "2016-10-24T09:11:14.861Z",
|
],
|
||||||
"registrant_verification_asked_at": null,
|
"tech_contacts":[
|
||||||
"registrant_verification_token": null,
|
{
|
||||||
"pending_json": {},
|
"name":"John Smith",
|
||||||
"force_delete_at": null,
|
"id":"62015e7d-42c8-4d68-8164-e9b71680fd95"
|
||||||
"statuses": [
|
},
|
||||||
|
{
|
||||||
|
"name":"William Smith",
|
||||||
|
"id":"a041c5b6-7772-4fac-83cd-fbce3b2c8867"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"transfer_code":"98oiewslkfkd",
|
||||||
|
"created_at":"2015-09-09T09:11:14.861Z",
|
||||||
|
"updated_at":"2015-09-09T09:11:14.860Z",
|
||||||
|
"name_dirty":"domain0.ee",
|
||||||
|
"name_puny":"domain0.ee",
|
||||||
|
"period":1,
|
||||||
|
"period_unit":"y",
|
||||||
|
"creator_str":null,
|
||||||
|
"updator_str":null,
|
||||||
|
"legacy_id":null,
|
||||||
|
"legacy_registrar_id":null,
|
||||||
|
"legacy_registrant_id":null,
|
||||||
|
"outzone_at":"2016-09-24T09:11:14.861Z",
|
||||||
|
"delete_at":"2016-10-24T09:11:14.861Z",
|
||||||
|
"registrant_verification_asked_at":null,
|
||||||
|
"registrant_verification_token":null,
|
||||||
|
"locked_by_registrant_at":null,
|
||||||
|
"pending_json":{
|
||||||
|
|
||||||
|
},
|
||||||
|
"force_delete_at":null,
|
||||||
|
"statuses":[
|
||||||
"ok"
|
"ok"
|
||||||
],
|
],
|
||||||
"reserved": false,
|
"nameservers":[
|
||||||
"status_notes": {},
|
{
|
||||||
"statuses_backup": []
|
"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":{
|
||||||
|
|
||||||
|
},
|
||||||
|
"statuses_backup":[
|
||||||
|
|
||||||
|
]
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
83
lib/serializers/registrant_api/domain.rb
Normal file
83
lib/serializers/registrant_api/domain.rb
Normal file
|
@ -0,0 +1,83 @@
|
||||||
|
module Serializers
|
||||||
|
module RegistrantApi
|
||||||
|
class Domain
|
||||||
|
attr_reader :domain
|
||||||
|
|
||||||
|
def initialize(domain)
|
||||||
|
@domain = domain
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_json
|
||||||
|
{
|
||||||
|
id: domain.uuid,
|
||||||
|
name: domain.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,
|
||||||
|
updated_at: domain.updated_at,
|
||||||
|
registrant: {
|
||||||
|
name: domain.registrant.name,
|
||||||
|
id: domain.registrant.uuid,
|
||||||
|
},
|
||||||
|
tech_contacts: contacts(:tech),
|
||||||
|
admin_contacts: contacts(:admin),
|
||||||
|
transfer_code: domain.transfer_code,
|
||||||
|
name_dirty: domain.name_dirty,
|
||||||
|
name_puny: domain.name_puny,
|
||||||
|
period: domain.period,
|
||||||
|
period_unit: domain.period_unit,
|
||||||
|
creator_str: domain.creator_str,
|
||||||
|
updator_str: domain.updator_str,
|
||||||
|
legacy_id: domain.legacy_id,
|
||||||
|
legacy_registrar_id: domain.legacy_registrar_id,
|
||||||
|
legacy_registrant_id: domain.legacy_registrant_id,
|
||||||
|
outzone_at: domain.outzone_at,
|
||||||
|
delete_at: domain.delete_at,
|
||||||
|
registrant_verification_asked_at: domain.registrant_verification_asked_at,
|
||||||
|
registrant_verification_token: domain.registrant_verification_token,
|
||||||
|
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,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def contacts(type)
|
||||||
|
contact_pool = begin
|
||||||
|
if type == :tech
|
||||||
|
domain.tech_contacts
|
||||||
|
elsif type == :admin
|
||||||
|
domain.admin_contacts
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
array_of_contacts = []
|
||||||
|
contact_pool.map do |contact|
|
||||||
|
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
|
||||||
|
|
||||||
|
array_of_nameservers
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
1
test/fixtures/domains.yml
vendored
1
test/fixtures/domains.yml
vendored
|
@ -48,6 +48,7 @@ metro:
|
||||||
|
|
||||||
hospital:
|
hospital:
|
||||||
name: hospital.test
|
name: hospital.test
|
||||||
|
name_dirty: hospital.test
|
||||||
registrar: goodnames
|
registrar: goodnames
|
||||||
registrant: john
|
registrant: john
|
||||||
transfer_code: 23118v2
|
transfer_code: 23118v2
|
||||||
|
|
10
test/fixtures/nameservers.yml
vendored
10
test/fixtures/nameservers.yml
vendored
|
@ -16,10 +16,20 @@ shop_ns2:
|
||||||
|
|
||||||
airport_ns1:
|
airport_ns1:
|
||||||
hostname: ns1.bestnames.test
|
hostname: ns1.bestnames.test
|
||||||
|
ipv4:
|
||||||
|
- 192.0.2.2
|
||||||
|
ipv6:
|
||||||
|
- 2001:db8::2
|
||||||
domain: airport
|
domain: airport
|
||||||
|
|
||||||
airport_ns2:
|
airport_ns2:
|
||||||
hostname: ns2.bestnames.test
|
hostname: ns2.bestnames.test
|
||||||
|
ipv4:
|
||||||
|
- 192.0.2.0
|
||||||
|
- 192.0.2.3
|
||||||
|
- 192.0.2.1
|
||||||
|
ipv6:
|
||||||
|
- 2001:db8::1
|
||||||
domain: airport
|
domain: airport
|
||||||
|
|
||||||
metro_ns1:
|
metro_ns1:
|
||||||
|
|
1
test/fixtures/registrars.yml
vendored
1
test/fixtures/registrars.yml
vendored
|
@ -11,6 +11,7 @@ bestnames:
|
||||||
accounting_customer_code: bestnames
|
accounting_customer_code: bestnames
|
||||||
language: en
|
language: en
|
||||||
billing_email: billing@example.com
|
billing_email: billing@example.com
|
||||||
|
website: bestnames.test
|
||||||
|
|
||||||
goodnames:
|
goodnames:
|
||||||
name: Good Names
|
name: Good Names
|
||||||
|
|
|
@ -27,7 +27,17 @@ class RegistrantApiDomainsTest < ApplicationIntegrationTest
|
||||||
assert_equal(200, response.status)
|
assert_equal(200, response.status)
|
||||||
|
|
||||||
domain = JSON.parse(response.body, symbolize_names: true)
|
domain = JSON.parse(response.body, symbolize_names: true)
|
||||||
|
|
||||||
assert_equal('hospital.test', domain[:name])
|
assert_equal('hospital.test', domain[:name])
|
||||||
|
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([], domain[:nameservers])
|
||||||
|
assert(domain.has_key?(:locked_by_registrant_at))
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_get_non_existent_domain_details_by_uuid
|
def test_get_non_existent_domain_details_by_uuid
|
||||||
|
@ -45,6 +55,9 @@ class RegistrantApiDomainsTest < ApplicationIntegrationTest
|
||||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||||
array_of_domain_names = response_json.map { |x| x[:name] }
|
array_of_domain_names = response_json.map { |x| x[:name] }
|
||||||
assert(array_of_domain_names.include?('hospital.test'))
|
assert(array_of_domain_names.include?('hospital.test'))
|
||||||
|
|
||||||
|
array_of_domain_registrars = response_json.map { |x| x[:registrar] }
|
||||||
|
assert(array_of_domain_registrars.include?({name: 'Good Names', website: nil}))
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_root_accepts_limit_and_offset_parameters
|
def test_root_accepts_limit_and_offset_parameters
|
||||||
|
|
|
@ -77,6 +77,7 @@ class RegistrantApiRegistryLocksTest < ApplicationIntegrationTest
|
||||||
|
|
||||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||||
assert(response_json[:statuses].include?(DomainStatus::OK))
|
assert(response_json[:statuses].include?(DomainStatus::OK))
|
||||||
|
refute(response_json[:locked_by_registrant_at])
|
||||||
@domain.reload
|
@domain.reload
|
||||||
refute(@domain.locked_by_registrant?)
|
refute(@domain.locked_by_registrant?)
|
||||||
end
|
end
|
||||||
|
@ -121,6 +122,26 @@ class RegistrantApiRegistryLocksTest < ApplicationIntegrationTest
|
||||||
assert(response_json[:statuses].include?(DomainStatus::SERVER_UPDATE_PROHIBITED))
|
assert(response_json[:statuses].include?(DomainStatus::SERVER_UPDATE_PROHIBITED))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_locking_domains_returns_serialized_domain_object
|
||||||
|
post '/api/v1/registrant/domains/1b3ee442-e8fe-4922-9492-8fcb9dccc69c/registry_lock',
|
||||||
|
{}, @auth_headers
|
||||||
|
|
||||||
|
assert_equal(200, response.status)
|
||||||
|
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||||
|
|
||||||
|
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(
|
||||||
|
[{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
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def auth_token
|
def auth_token
|
||||||
|
|
78
test/lib/serializers/registrant_api/domain_test.rb
Normal file
78
test/lib/serializers/registrant_api/domain_test.rb
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
require 'test_helper'
|
||||||
|
require 'serializers/registrant_api/domain'
|
||||||
|
|
||||||
|
class SerializersRegistrantApiDomainTest < ApplicationIntegrationTest
|
||||||
|
def setup
|
||||||
|
@domain = domains(:airport)
|
||||||
|
@serializer = Serializers::RegistrantApi::Domain.new(@domain)
|
||||||
|
@json = @serializer.to_json
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_returns_uuid_as_id
|
||||||
|
assert_equal(@domain.uuid, @json[:id])
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_returns_domain_locked_by_registrant_time_or_nil
|
||||||
|
assert_not(@json[:locked_by_registrant_at])
|
||||||
|
|
||||||
|
travel_to Time.zone.parse('2010-07-05 10:30')
|
||||||
|
@domain.apply_registry_lock
|
||||||
|
serializer_for_locked_domain = Serializers::RegistrantApi::Domain.new(@domain.reload)
|
||||||
|
new_json = serializer_for_locked_domain.to_json
|
||||||
|
|
||||||
|
assert_equal(Time.zone.parse('2010-07-05 10:30'), new_json[:locked_by_registrant_at])
|
||||||
|
travel_back
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_returns_registrar_name
|
||||||
|
assert_equal({name: 'Best Names', website: 'bestnames.test' }, @json[:registrar])
|
||||||
|
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
|
||||||
|
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)
|
||||||
|
new_json = other_serializer.to_json
|
||||||
|
|
||||||
|
assert_equal([], new_json[:nameservers])
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_other_fields_are_also_present
|
||||||
|
keys = %i[id name registrar registered_at valid_to created_at updated_at
|
||||||
|
registrant tech_contacts admin_contacts transfer_code name_dirty name_puny period
|
||||||
|
period_unit creator_str updator_str legacy_id legacy_registrar_id legacy_registrant_id
|
||||||
|
outzone_at delete_at registrant_verification_asked_at
|
||||||
|
registrant_verification_token pending_json force_delete_at statuses
|
||||||
|
locked_by_registrant_at reserved status_notes nameservers]
|
||||||
|
|
||||||
|
assert_equal(keys, @json.keys & keys)
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Add a link
Reference in a new issue