mirror of
https://github.com/internetee/registry.git
synced 2025-06-08 05:34:46 +02:00
Update registry lock controller to also return special serialization
This commit is contained in:
parent
ce8451d004
commit
5e5162e44e
5 changed files with 28 additions and 13 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
require 'serializers/registrant_api/domain'
|
||||||
|
|
||||||
module Api
|
module Api
|
||||||
module V1
|
module V1
|
||||||
module Registrant
|
module Registrant
|
||||||
|
@ -7,7 +9,8 @@ module Api
|
||||||
|
|
||||||
def create
|
def create
|
||||||
if @domain.apply_registry_lock
|
if @domain.apply_registry_lock
|
||||||
render json: @domain
|
serializer = Serializers::RegistrantApi::Domain.new(@domain)
|
||||||
|
render json: serializer.to_json
|
||||||
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 +19,8 @@ module Api
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
if @domain.remove_registry_lock
|
if @domain.remove_registry_lock
|
||||||
render json: @domain
|
serializer = Serializers::RegistrantApi::Domain.new(@domain)
|
||||||
|
render json: serializer.to_json
|
||||||
else
|
else
|
||||||
render json: { errors: [{ base: ['Domain is not locked'] }] },
|
render json: { errors: [{ base: ['Domain is not locked'] }] },
|
||||||
status: :unprocessable_entity
|
status: :unprocessable_entity
|
||||||
|
|
|
@ -23,7 +23,7 @@ Content-Type: application/json
|
||||||
"id": "98d1083a-8863-4153-93e4-caee4a013535",
|
"id": "98d1083a-8863-4153-93e4-caee4a013535",
|
||||||
"name": "domain0.ee",
|
"name": "domain0.ee",
|
||||||
"registrar": "Best Names",
|
"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",
|
"valid_to": "2016-09-09T09:11:14.861Z",
|
||||||
"registrant_id": 1,
|
"registrant_id": 1,
|
||||||
"transfer_code": "98oiewslkfkd",
|
"transfer_code": "98oiewslkfkd",
|
||||||
|
@ -89,6 +89,7 @@ Content-Type: application/json
|
||||||
"name": "domain0.ee",
|
"name": "domain0.ee",
|
||||||
"registrar": "Best Names",
|
"registrar": "Best Names",
|
||||||
"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_id": 1,
|
||||||
"transfer_code": "98oiewslkfkd",
|
"transfer_code": "98oiewslkfkd",
|
||||||
"created_at": "2015-09-09T09:11:14.861Z",
|
"created_at": "2015-09-09T09:11:14.861Z",
|
||||||
|
|
|
@ -19,12 +19,10 @@ 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": "Best Names",
|
||||||
"registered_at": "2015-09-09T09:11:14.861Z",
|
"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",
|
"valid_to": "2016-09-09T09:11:14.861Z",
|
||||||
"registrant_id": 1,
|
"registrant_id": 1,
|
||||||
"transfer_code": "98oiewslkfkd",
|
"transfer_code": "98oiewslkfkd",
|
||||||
|
@ -43,6 +41,7 @@ Content-Type: application/json
|
||||||
"delete_at": "2016-10-24T09:11:14.861Z",
|
"delete_at": "2016-10-24T09:11:14.861Z",
|
||||||
"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",
|
||||||
"pending_json": {},
|
"pending_json": {},
|
||||||
"force_delete_at": null,
|
"force_delete_at": null,
|
||||||
"statuses": [
|
"statuses": [
|
||||||
|
@ -113,12 +112,10 @@ 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": "Best Names",
|
||||||
"registered_at": "2015-09-09T09:11:14.861Z",
|
"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",
|
"valid_to": "2016-09-09T09:11:14.861Z",
|
||||||
"registrant_id": 1,
|
"registrant_id": 1,
|
||||||
"transfer_code": "98oiewslkfkd",
|
"transfer_code": "98oiewslkfkd",
|
||||||
|
@ -137,6 +134,7 @@ Content-Type: application/json
|
||||||
"delete_at": "2016-10-24T09:11:14.861Z",
|
"delete_at": "2016-10-24T09:11:14.861Z",
|
||||||
"registrant_verification_asked_at": null,
|
"registrant_verification_asked_at": null,
|
||||||
"registrant_verification_token": null,
|
"registrant_verification_token": null,
|
||||||
|
"locked_by_registrant_at": null,
|
||||||
"pending_json": {},
|
"pending_json": {},
|
||||||
"force_delete_at": null,
|
"force_delete_at": null,
|
||||||
"statuses": [
|
"statuses": [
|
||||||
|
|
|
@ -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,19 @@ 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('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
|
private
|
||||||
|
|
||||||
def auth_token
|
def auth_token
|
||||||
|
|
|
@ -47,8 +47,6 @@ class SerializersRegistrantApiDomainTest < ApplicationIntegrationTest
|
||||||
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]
|
||||||
|
|
||||||
pp @json
|
|
||||||
|
|
||||||
assert_equal(keys, @json.keys & keys)
|
assert_equal(keys, @json.keys & keys)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue