mirror of
https://github.com/internetee/registry.git
synced 2025-06-08 13:44:47 +02:00
REPP: Domain transfer test
This commit is contained in:
parent
9a36b0403c
commit
774ada6ebb
3 changed files with 53 additions and 3 deletions
|
@ -29,7 +29,7 @@ module Repp
|
|||
@errors ||= []
|
||||
@successful = []
|
||||
|
||||
params[:data][:domain_transfers].each do |transfer|
|
||||
transfer_params[:domain_transfers].each do |transfer|
|
||||
initiate_transfer(transfer)
|
||||
end
|
||||
|
||||
|
@ -57,6 +57,7 @@ module Repp
|
|||
add_error("#{domain_name} transfer code is wrong")
|
||||
return
|
||||
end
|
||||
|
||||
domain
|
||||
end
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ class ReppV1DomainsTransferInfoTest < ActionDispatch::IntegrationTest
|
|||
headers = @auth_headers
|
||||
headers['Auth-Code'] = @domain.transfer_code
|
||||
|
||||
get "/repp/v1/domains/#{@domain.name}/transfer_info", headers: @auth_headers
|
||||
get "/repp/v1/domains/#{@domain.name}/transfer_info", headers: headers
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :ok
|
||||
|
@ -29,7 +29,7 @@ class ReppV1DomainsTransferInfoTest < ActionDispatch::IntegrationTest
|
|||
headers = @auth_headers
|
||||
headers['Auth-Code'] = 'jhfgifhdg'
|
||||
|
||||
get "/repp/v1/domains/#{@domain.name}/transfer_info", headers: @auth_headers
|
||||
get "/repp/v1/domains/#{@domain.name}/transfer_info", headers: headers
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :bad_request
|
||||
|
|
49
test/integration/repp/v1/domains/transfer_test.rb
Normal file
49
test/integration/repp/v1/domains/transfer_test.rb
Normal file
|
@ -0,0 +1,49 @@
|
|||
require 'test_helper'
|
||||
|
||||
class ReppV1DomainsTransferTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
@user = users(:api_bestnames)
|
||||
token = Base64.encode64("#{@user.username}:#{@user.plain_text_password}")
|
||||
token = "Basic #{token}"
|
||||
@domain = domains(:hospital)
|
||||
|
||||
@auth_headers = { 'Authorization' => token }
|
||||
end
|
||||
|
||||
def test_transfers_domain
|
||||
payload = {
|
||||
"data": {
|
||||
"domain_transfers": [
|
||||
{ "domain_name": @domain.name, "transfer_code": @domain.transfer_code }
|
||||
]
|
||||
}
|
||||
}
|
||||
post "/repp/v1/domains/transfer", headers: @auth_headers, params: payload
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :ok
|
||||
assert_equal 1000, json[:code]
|
||||
assert_equal 'Command completed successfully', json[:message]
|
||||
|
||||
assert_equal @domain.name, json[:data][0][:attributes][:domain_name]
|
||||
assert_equal 'domain_transfer', json[:data][0][:type]
|
||||
end
|
||||
|
||||
def test_does_not_transfer_domain_with_invalid_auth_code
|
||||
payload = {
|
||||
"data": {
|
||||
"domain_transfers": [
|
||||
{ "domain_name": @domain.name, "transfer_code": "sdfgsdfg" }
|
||||
]
|
||||
}
|
||||
}
|
||||
post "/repp/v1/domains/transfer", headers: @auth_headers, params: payload
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :bad_request
|
||||
assert_equal 2304, json[:code]
|
||||
assert_equal 'Command failed', json[:message]
|
||||
|
||||
assert_equal "#{@domain.name} transfer code is wrong", json[:data][0][:title]
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue