mirror of
https://github.com/internetee/registry.git
synced 2025-06-10 22:54:47 +02:00
REPP: Domain renew tests
This commit is contained in:
parent
b3cf665ed5
commit
d838e56112
2 changed files with 44 additions and 1 deletions
|
@ -24,7 +24,6 @@ module Actions
|
||||||
period: params[:period],
|
period: params[:period],
|
||||||
unit: params[:period_unit],
|
unit: params[:period_unit],
|
||||||
registrar: user)
|
registrar: user)
|
||||||
|
|
||||||
task.valid?
|
task.valid?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
44
test/integration/repp/v1/domains/renews_test.rb
Normal file
44
test/integration/repp/v1/domains/renews_test.rb
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class ReppV1DomainsRenewsTest < ActionDispatch::IntegrationTest
|
||||||
|
def setup
|
||||||
|
@user = users(:api_bestnames)
|
||||||
|
@domain = domains(:shop)
|
||||||
|
token = Base64.encode64("#{@user.username}:#{@user.plain_text_password}")
|
||||||
|
token = "Basic #{token}"
|
||||||
|
|
||||||
|
@auth_headers = { 'Authorization' => token }
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_domain_can_be_renewed
|
||||||
|
original_valid_to = @domain.valid_to
|
||||||
|
travel_to Time.zone.parse('2010-07-05')
|
||||||
|
|
||||||
|
@auth_headers['Content-Type'] = 'application/json'
|
||||||
|
payload = { renew: { period: 1, period_unit: 'y' } }
|
||||||
|
post "/repp/v1/domains/#{@domain.name}/renew", headers: @auth_headers, params: payload.to_json
|
||||||
|
json = JSON.parse(response.body, symbolize_names: true)
|
||||||
|
|
||||||
|
assert_response :ok
|
||||||
|
assert_equal 1000, json[:code]
|
||||||
|
assert_equal 'Command completed successfully', json[:message]
|
||||||
|
|
||||||
|
assert @domain.valid_to, original_valid_to + 1.year
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_domain_renew_pricing_error
|
||||||
|
original_valid_to = @domain.valid_to
|
||||||
|
travel_to Time.zone.parse('2010-07-05')
|
||||||
|
|
||||||
|
@auth_headers['Content-Type'] = 'application/json'
|
||||||
|
payload = { renew: { period: 100, period_unit: 'y' } }
|
||||||
|
post "/repp/v1/domains/#{@domain.name}/renew", headers: @auth_headers, params: payload.to_json
|
||||||
|
json = JSON.parse(response.body, symbolize_names: true)
|
||||||
|
|
||||||
|
assert_response :bad_request
|
||||||
|
assert_equal 2104, json[:code]
|
||||||
|
assert_equal 'Active price missing for this operation!', json[:message]
|
||||||
|
|
||||||
|
assert @domain.valid_to, original_valid_to
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Add a link
Reference in a new issue