diff --git a/app/controllers/api/v1/registrant/registry_locks_controller.rb b/app/controllers/api/v1/registrant/registry_locks_controller.rb index 27c98cc9f..5100cd748 100644 --- a/app/controllers/api/v1/registrant/registry_locks_controller.rb +++ b/app/controllers/api/v1/registrant/registry_locks_controller.rb @@ -1,3 +1,5 @@ +require 'serializers/registrant_api/domain' + module Api module V1 module Registrant @@ -7,7 +9,8 @@ module Api def create if @domain.apply_registry_lock - render json: @domain + serializer = Serializers::RegistrantApi::Domain.new(@domain) + render json: serializer.to_json else render json: { errors: [{ base: ['Domain cannot be locked'] }] }, status: :unprocessable_entity @@ -16,7 +19,8 @@ module Api def destroy if @domain.remove_registry_lock - render json: @domain + serializer = Serializers::RegistrantApi::Domain.new(@domain) + render json: serializer.to_json else render json: { errors: [{ base: ['Domain is not locked'] }] }, status: :unprocessable_entity diff --git a/doc/registrant-api/v1/domain.md b/doc/registrant-api/v1/domain.md index f56bb6014..5c309ce15 100644 --- a/doc/registrant-api/v1/domain.md +++ b/doc/registrant-api/v1/domain.md @@ -23,7 +23,7 @@ Content-Type: application/json "id": "98d1083a-8863-4153-93e4-caee4a013535", "name": "domain0.ee", "registrar": "Best Names", - "valid_from": "2015-09-09T09:11:14.861Z", + "registered_at": "2015-09-09T09:11:14.861Z", "valid_to": "2016-09-09T09:11:14.861Z", "registrant_id": 1, "transfer_code": "98oiewslkfkd", @@ -89,6 +89,7 @@ Content-Type: application/json "name": "domain0.ee", "registrar": "Best Names", "valid_to": "2016-09-09T09:11:14.861Z", + "registered_at": "2015-09-09T09:11:14.861Z", "registrant_id": 1, "transfer_code": "98oiewslkfkd", "created_at": "2015-09-09T09:11:14.861Z", diff --git a/doc/registrant-api/v1/registry_lock.md b/doc/registrant-api/v1/registry_lock.md index b8d440554..849b27db5 100644 --- a/doc/registrant-api/v1/registry_lock.md +++ b/doc/registrant-api/v1/registry_lock.md @@ -19,12 +19,10 @@ HTTP/1.1 200 Content-Type: application/json { - "uuid": "98d1083a-8863-4153-93e4-caee4a013535", + "id": "98d1083a-8863-4153-93e4-caee4a013535", "name": "domain0.ee", - "registrar_id": 2, + "registrar": "Best Names", "registered_at": "2015-09-09T09:11:14.861Z", - "status": null, - "valid_from": "2015-09-09T09:11:14.861Z", "valid_to": "2016-09-09T09:11:14.861Z", "registrant_id": 1, "transfer_code": "98oiewslkfkd", @@ -43,6 +41,7 @@ Content-Type: application/json "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": [ @@ -113,12 +112,10 @@ HTTP/1.1 200 Content-Type: application/json { - "uuid": "98d1083a-8863-4153-93e4-caee4a013535", + "id": "98d1083a-8863-4153-93e4-caee4a013535", "name": "domain0.ee", - "registrar_id": 2, + "registrar": "Best Names", "registered_at": "2015-09-09T09:11:14.861Z", - "status": null, - "valid_from": "2015-09-09T09:11:14.861Z", "valid_to": "2016-09-09T09:11:14.861Z", "registrant_id": 1, "transfer_code": "98oiewslkfkd", @@ -137,6 +134,7 @@ Content-Type: application/json "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": [ diff --git a/test/integration/api/registrant/registrant_api_registry_locks_test.rb b/test/integration/api/registrant/registrant_api_registry_locks_test.rb index bb50bdc1b..846bcb8e5 100644 --- a/test/integration/api/registrant/registrant_api_registry_locks_test.rb +++ b/test/integration/api/registrant/registrant_api_registry_locks_test.rb @@ -77,6 +77,7 @@ class RegistrantApiRegistryLocksTest < ApplicationIntegrationTest response_json = JSON.parse(response.body, symbolize_names: true) assert(response_json[:statuses].include?(DomainStatus::OK)) + refute(response_json[:locked_by_registrant_at]) @domain.reload refute(@domain.locked_by_registrant?) end @@ -121,6 +122,19 @@ class RegistrantApiRegistryLocksTest < ApplicationIntegrationTest assert(response_json[:statuses].include?(DomainStatus::SERVER_UPDATE_PROHIBITED)) 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('Best Names', response_json[:registrar]) + assert_equal(['ns1.bestnames.test', 'ns2.bestnames.test'].to_set, + response_json[:nameservers].to_set) + assert_equal(Time.zone.parse('2010-07-05'), response_json[:locked_by_registrant_at]) + end + private def auth_token diff --git a/test/lib/serializers/registrant_api/domain_test.rb b/test/lib/serializers/registrant_api/domain_test.rb index 74facf87c..6a9b552d1 100644 --- a/test/lib/serializers/registrant_api/domain_test.rb +++ b/test/lib/serializers/registrant_api/domain_test.rb @@ -47,8 +47,6 @@ class SerializersRegistrantApiDomainTest < ApplicationIntegrationTest registrant_verification_token pending_json force_delete_at statuses locked_by_registrant_at reserved status_notes nameservers] - pp @json - assert_equal(keys, @json.keys & keys) end end