mirror of
https://github.com/internetee/registry.git
synced 2025-07-22 18:56:05 +02:00
Write tests around API for domain lock
This commit is contained in:
parent
2a7caaa33e
commit
0a0962e007
6 changed files with 89 additions and 17 deletions
|
@ -22,6 +22,15 @@ module Api
|
|||
header.gsub(pattern, '') if header&.match(pattern)
|
||||
end
|
||||
|
||||
def associated_domains(user)
|
||||
country_code, ident = user.registrant_ident.split('-')
|
||||
|
||||
BusinessRegistryCache.fetch_associated_domains(ident, country_code)
|
||||
rescue Soap::Arireg::NotAvailableError => error
|
||||
Rails.logger.fatal("[EXCEPTION] #{error}")
|
||||
user.domains
|
||||
end
|
||||
|
||||
def authenticate
|
||||
decryptor = AuthTokenDecryptor.create_with_defaults(bearer_token)
|
||||
decryptor.decrypt_token
|
||||
|
|
|
@ -32,17 +32,6 @@ module Api
|
|||
render json: { errors: [{ base: ['Domain not found'] }] }, status: :not_found
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def associated_domains(user)
|
||||
country_code, ident = user.registrant_ident.split('-')
|
||||
|
||||
BusinessRegistryCache.fetch_associated_domains(ident, country_code)
|
||||
rescue Soap::Arireg::NotAvailableError => error
|
||||
Rails.logger.fatal("[EXCEPTION] #{error}")
|
||||
user.domains
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,16 +8,16 @@ module Api
|
|||
if @domain.apply_registry_lock
|
||||
render json: @domain
|
||||
else
|
||||
render json: { errors: [{ base: 'Domain cannot be locked' }] },
|
||||
render json: { errors: [{ base: ['Domain cannot be locked'] }] },
|
||||
status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
def delete
|
||||
def destroy
|
||||
if @domain.remove_registry_lock
|
||||
render json: @domain
|
||||
else
|
||||
render json: { errors: [{ base: 'Domain cannot be unlocked' }] },
|
||||
render json: { errors: [{ base: ['Domain cannot be unlocked'] }] },
|
||||
status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
@ -25,7 +25,8 @@ module Api
|
|||
private
|
||||
|
||||
def set_domain
|
||||
@domain = Domain.find_by(uuid: params[:domain_uuid])
|
||||
domain_pool = associated_domains(current_user)
|
||||
@domain = domain_pool.find_by(uuid: params[:domain_uuid])
|
||||
|
||||
return if @domain
|
||||
render json: { errors: [{ base: ['Domain not found'] }] },
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue