From 1fba3a731c84c86f076424ee17362ace03512a7a Mon Sep 17 00:00:00 2001 From: Sergei Tsoganov Date: Wed, 23 Nov 2022 14:55:34 +0200 Subject: [PATCH] Added tests --- .../v1/registrar/xml_console_controller.rb | 3 + .../repp/v1/registrar/xml_console_test.rb | 105 ++++++++++++++++++ 2 files changed, 108 insertions(+) create mode 100644 test/integration/repp/v1/registrar/xml_console_test.rb diff --git a/app/controllers/repp/v1/registrar/xml_console_controller.rb b/app/controllers/repp/v1/registrar/xml_console_controller.rb index e022a31a6..37d28192f 100644 --- a/app/controllers/repp/v1/registrar/xml_console_controller.rb +++ b/app/controllers/repp/v1/registrar/xml_console_controller.rb @@ -4,6 +4,9 @@ module Repp class XmlConsoleController < BaseController include EppRequestable + THROTTLED_ACTIONS = %i[load_xml create].freeze + include Shunter::Integration::Throttle + PREFS = %w[ domain-ee contact-ee diff --git a/test/integration/repp/v1/registrar/xml_console_test.rb b/test/integration/repp/v1/registrar/xml_console_test.rb new file mode 100644 index 000000000..19c82496f --- /dev/null +++ b/test/integration/repp/v1/registrar/xml_console_test.rb @@ -0,0 +1,105 @@ +require 'test_helper' + +class ReppV1RegistrarXmlConsoleTest < ActionDispatch::IntegrationTest + def setup + @user = users(:api_bestnames) + token = Base64.encode64("#{@user.username}:#{@user.plain_text_password}") + token = "Basic #{token}" + + @auth_headers = { 'Authorization' => token } + adapter = ENV['shunter_default_adapter'].constantize.new + adapter&.clear! + end + + def test_load_schema_path + get load_xml_repp_v1_registrar_xml_console_path, params: { obj: 'domain', epp_action: 'update' }, + headers: @auth_headers + + assert_response :ok + json = JSON.parse(response.body, symbolize_names: true) + assert_equal update_payload, json[:data][:xml] + end + + def test_check_schema_path + post repp_v1_registrar_xml_console_path, params: { xml_console: { payload: payload } }.to_json, + headers: @auth_headers + + assert_response :ok + end + + private + + def payload + <<~XML + + + + + + auction.test + + + + + XML + end + + def update_payload + <<~XML + + + + + + example.ee + + + + ns1.example.com + + + ns2.example.com + + + mak21 + + + + + ns1.example.net + + + mak21 + + + mak21 + + newpw + + + + + + + + + 257 + 3 + 8 + 700b97b591ed27ec2590d19f06f88bba700b97b591ed27ec2590d19f + + + + + + dGVzdCBmYWlsCg== + + + + test_bestnames-#{Time.zone.now.to_i} + + + XML + end +end \ No newline at end of file