mirror of
https://github.com/internetee/registry.git
synced 2025-07-23 03:06:14 +02:00
Merge remote-tracking branch 'origin/master' into repp-domains
This commit is contained in:
commit
221e4ba578
140 changed files with 2575 additions and 731 deletions
|
@ -50,10 +50,10 @@ class RegistrantApiDomainsTest < ApplicationIntegrationTest
|
|||
assert_equal(200, response.status)
|
||||
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
array_of_domain_names = response_json.map { |x| x[:name] }
|
||||
array_of_domain_names = response_json[:domains].map { |x| x[:name] }
|
||||
assert(array_of_domain_names.include?('hospital.test'))
|
||||
|
||||
array_of_domain_registrars = response_json.map { |x| x[:registrar] }
|
||||
array_of_domain_registrars = response_json[:domains].map { |x| x[:registrar] }
|
||||
assert(array_of_domain_registrars.include?({name: 'Good Names', website: nil}))
|
||||
end
|
||||
|
||||
|
@ -63,12 +63,12 @@ class RegistrantApiDomainsTest < ApplicationIntegrationTest
|
|||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_equal(200, response.status)
|
||||
assert_equal(2, response_json.count)
|
||||
assert_equal(2, response_json[:domains].count)
|
||||
|
||||
get '/api/v1/registrant/domains', headers: @auth_headers
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_equal(4, response_json.count)
|
||||
assert_equal(4, response_json[:domains].count)
|
||||
end
|
||||
|
||||
def test_root_does_not_accept_limit_higher_than_200
|
||||
|
|
75
test/integration/api/v1/bounces/create_test.rb
Normal file
75
test/integration/api/v1/bounces/create_test.rb
Normal file
|
@ -0,0 +1,75 @@
|
|||
require 'test_helper'
|
||||
|
||||
class BouncesApiV1CreateTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
@api_key = "Basic #{ENV['api_shared_key']}"
|
||||
@headers = { "Authorization": "#{@api_key}" }
|
||||
@json_body = { "data": valid_bounce_request }.as_json
|
||||
end
|
||||
|
||||
def test_authorizes_api_request
|
||||
post api_v1_bounces_path, params: @json_body, headers: @headers
|
||||
assert_response :created
|
||||
|
||||
invalid_headers = { "Authorization": "Basic invalid_api_key" }
|
||||
post api_v1_bounces_path, params: @json_body, headers: invalid_headers
|
||||
assert_response :unauthorized
|
||||
end
|
||||
|
||||
def test_returns_bad_request_if_invalid_payload
|
||||
invalid_json_body = @json_body.dup
|
||||
invalid_json_body['data']['bounce']['bouncedRecipients'] = nil
|
||||
|
||||
post api_v1_bounces_path, params: invalid_json_body, headers: @headers
|
||||
assert_response :bad_request
|
||||
|
||||
invalid_json_body = 'aaaa'
|
||||
post api_v1_bounces_path, params: invalid_json_body, headers: @headers
|
||||
assert_response :bad_request
|
||||
end
|
||||
|
||||
def test_saves_new_bounce_object
|
||||
request_body = @json_body.dup
|
||||
random_mail = "#{rand(10000..99999)}@registry.test"
|
||||
request_body['data']['bounce']['bouncedRecipients'][0]['emailAddress'] = random_mail
|
||||
|
||||
post api_v1_bounces_path, params: request_body, headers: @headers
|
||||
assert_response :created
|
||||
|
||||
bounced_mail = BouncedMailAddress.last
|
||||
assert bounced_mail.email = random_mail
|
||||
assert '5.1.1', bounced_mail.status
|
||||
assert 'failed', bounced_mail.action
|
||||
end
|
||||
|
||||
def valid_bounce_request
|
||||
{
|
||||
"notificationType": "Bounce",
|
||||
"mail": {
|
||||
"source": "noreply@registry.test",
|
||||
"sourceIp": "195.43.86.5",
|
||||
"messageId": "010f0174a0c7d348-ea6e2fc1-0854-4073-b71f-5cecf9b0d0b2-000000",
|
||||
"sourceArn": "arn:aws:ses:us-east-2:65026820000:identity/noreply@registry.test",
|
||||
"timestamp": "2020-09-18T10:34:44.000Z",
|
||||
"destination": [ "bounced@registry.test" ],
|
||||
"sendingAccountId": "650268220000"
|
||||
},
|
||||
"bounce": {
|
||||
"timestamp": "2020-09-18T10:34:44.911Z",
|
||||
"bounceType": "Permanent",
|
||||
"feedbackId": "010f0174a0c7d4f9-27d59756-6111-4d5f-xxxx-26bee0d55fa2-000000",
|
||||
"remoteMtaIp": "127.0.01",
|
||||
"reportingMTA": "dsn; xxx.amazonses.com",
|
||||
"bounceSubType": "General",
|
||||
"bouncedRecipients": [
|
||||
{
|
||||
"action": "failed",
|
||||
"status": "5.1.1",
|
||||
"emailAddress": "bounced@registry.test",
|
||||
"diagnosticCode": "smtp; 550 5.1.1 user unknown"
|
||||
}
|
||||
]
|
||||
}
|
||||
}.as_json
|
||||
end
|
||||
end
|
|
@ -35,7 +35,6 @@ class EppDomainDeleteBaseTest < EppTestCase
|
|||
XML
|
||||
|
||||
post epp_delete_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
# binding.pry
|
||||
assert_includes Domain.find_by(name: 'invalid.test').statuses, DomainStatus::PENDING_DELETE_CONFIRMATION
|
||||
assert_epp_response :completed_successfully_action_pending
|
||||
end
|
||||
|
@ -90,7 +89,9 @@ class EppDomainDeleteBaseTest < EppTestCase
|
|||
</epp>
|
||||
XML
|
||||
|
||||
post epp_delete_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
perform_enqueued_jobs do
|
||||
post epp_delete_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
end
|
||||
@domain.reload
|
||||
|
||||
assert @domain.registrant_verification_asked?
|
||||
|
@ -121,7 +122,9 @@ class EppDomainDeleteBaseTest < EppTestCase
|
|||
</epp>
|
||||
XML
|
||||
|
||||
post epp_delete_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
perform_enqueued_jobs do
|
||||
post epp_delete_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
end
|
||||
@domain.reload
|
||||
|
||||
assert_not @domain.registrant_verification_asked?
|
||||
|
@ -152,7 +155,9 @@ class EppDomainDeleteBaseTest < EppTestCase
|
|||
</epp>
|
||||
XML
|
||||
|
||||
post epp_delete_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
perform_enqueued_jobs do
|
||||
post epp_delete_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
end
|
||||
@domain.reload
|
||||
|
||||
assert_not @domain.registrant_verification_asked?
|
||||
|
|
|
@ -503,6 +503,30 @@ class EppDomainUpdateBaseTest < EppTestCase
|
|||
assert_not_includes(@domain.statuses, DomainStatus::CLIENT_HOLD)
|
||||
end
|
||||
|
||||
def test_update_domain_returns_error_when_removing_unassigned_status
|
||||
assert_not_includes(@domain.statuses, DomainStatus::CLIENT_HOLD)
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<update>
|
||||
<domain:update xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>#{@domain.name}</domain:name>
|
||||
<domain:rem>
|
||||
<domain:status s="clientHold"/>
|
||||
</domain:rem>
|
||||
</domain:update>
|
||||
</update>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post epp_update_path, params: { frame: request_xml },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
@domain.reload
|
||||
assert_epp_response :object_does_not_exist
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def assert_verification_and_notification_emails
|
||||
|
|
91
test/integration/repp/v1/domains/bulk_renew_test.rb
Normal file
91
test/integration/repp/v1/domains/bulk_renew_test.rb
Normal file
|
@ -0,0 +1,91 @@
|
|||
require 'test_helper'
|
||||
|
||||
class ReppV1DomainsBulkRenewTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
travel_to Time.zone.parse('2010-07-05 10:30')
|
||||
@user = users(:api_bestnames)
|
||||
token = Base64.encode64("#{@user.username}:#{@user.plain_text_password}")
|
||||
token = "Basic #{token}"
|
||||
|
||||
@auth_headers = { 'Authorization' => token }
|
||||
end
|
||||
|
||||
def test_renews_domains
|
||||
payload = {
|
||||
"domains": [
|
||||
'shop.test',
|
||||
'airport.test',
|
||||
'library.test'
|
||||
],
|
||||
"renew_period": "1y"
|
||||
}
|
||||
|
||||
assert_changes -> { Domain.find_by(name: 'shop.test').valid_to } do
|
||||
assert_changes -> { Domain.find_by(name: 'airport.test').valid_to } do
|
||||
assert_changes -> { Domain.find_by(name: 'library.test').valid_to } do
|
||||
post "/repp/v1/domains/renew/bulk", 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 json[:data][:updated_domains].include? 'shop.test'
|
||||
assert json[:data][:updated_domains].include? 'airport.test'
|
||||
assert json[:data][:updated_domains].include? 'library.test'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_throws_error_when_domain_not_renewable
|
||||
payload = {
|
||||
"domains": [
|
||||
'invalid.test',
|
||||
],
|
||||
"renew_period": "1y"
|
||||
}
|
||||
assert_no_changes -> { Domain.find_by(name: 'invalid.test').valid_to } do
|
||||
post "/repp/v1/domains/renew/bulk", headers: @auth_headers, params: payload
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :bad_request
|
||||
assert_equal 2002, json[:code]
|
||||
assert_equal 'Domain renew error for invalid.test', json[:message]
|
||||
end
|
||||
end
|
||||
|
||||
def test_throws_error_when_not_enough_balance
|
||||
billing_prices(:renew_one_year).update(price_cents: 99999999)
|
||||
payload = {
|
||||
"domains": [
|
||||
'invalid.test',
|
||||
],
|
||||
"renew_period": "1y"
|
||||
}
|
||||
|
||||
assert_no_changes -> { Domain.find_by(name: 'invalid.test').valid_to } do
|
||||
post "/repp/v1/domains/renew/bulk", headers: @auth_headers, params: payload
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :bad_request
|
||||
assert_equal 2002, json[:code]
|
||||
assert_equal 'Not enough funds for renew domains', json[:message]
|
||||
end
|
||||
end
|
||||
|
||||
def test_throws_error_if_invalid_renew_period
|
||||
payload = {
|
||||
"domains": [
|
||||
'shop.test'
|
||||
],
|
||||
"renew_period": "nope"
|
||||
}
|
||||
|
||||
post "/repp/v1/domains/renew/bulk", headers: @auth_headers, params: payload
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :bad_request
|
||||
assert_equal 2005, json[:code]
|
||||
assert_equal 'Invalid renew period', json[:message]
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue