mirror of
https://github.com/internetee/registry.git
synced 2025-05-16 17:37:17 +02:00
parent
624cc70bef
commit
2185178162
3 changed files with 38 additions and 0 deletions
|
@ -57,5 +57,6 @@ module Repp
|
|||
mount Repp::DomainV1
|
||||
mount Repp::ContactV1
|
||||
mount Repp::AccountV1
|
||||
mount Repp::DomainTransfersV1
|
||||
end
|
||||
end
|
||||
|
|
18
app/api/repp/domain_transfers_v1.rb
Normal file
18
app/api/repp/domain_transfers_v1.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
module Repp
|
||||
class DomainTransfersV1 < Grape::API
|
||||
version 'v1', using: :path
|
||||
|
||||
resource :domain_transfers do
|
||||
post '/' do
|
||||
params['domainTransfers'].each do |domain_transfer|
|
||||
domain_name = domain_transfer['domainName']
|
||||
auth_info = domain_transfer['authInfo']
|
||||
new_registrar = current_user.registrar
|
||||
|
||||
domain = Domain.find_by(name: domain_name)
|
||||
domain.transfer(registrar: new_registrar, auth_info: auth_info)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
19
test/api/domain_transfers_test.rb
Normal file
19
test/api/domain_transfers_test.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
require 'test_helper'
|
||||
|
||||
class Repp::DomainTransfersTest < ActionDispatch::IntegrationTest
|
||||
def test_post_to_domain_transfers
|
||||
request_params = { format: :json, domainTransfers: [{ domainName: domains(:shop).name, authInfo: domains(:shop).auth_info }] }
|
||||
post '/repp/v1/domain_transfers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
assert_response :created
|
||||
|
||||
assert_difference -> { domains(:shop).domain_transfers.count } do
|
||||
post '/repp/v1/domain_transfers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def http_auth_key
|
||||
ActionController::HttpAuthentication::Basic.encode_credentials(users(:api).username, users(:api).password)
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue