mirror of
https://github.com/internetee/registry.git
synced 2025-06-08 05:34:46 +02:00
Refactor
This commit is contained in:
parent
4c884cce37
commit
9baa65a775
6 changed files with 159 additions and 22 deletions
|
@ -7,6 +7,14 @@ class DummyEppController < Epp::BaseController
|
|||
end
|
||||
|
||||
class EppBaseTest < EppTestCase
|
||||
setup do
|
||||
@original_session_timeout = EppSession.timeout
|
||||
end
|
||||
|
||||
teardown do
|
||||
EppSession.timeout = @original_session_timeout
|
||||
end
|
||||
|
||||
def test_internal_error
|
||||
Rails.application.routes.draw do
|
||||
post 'epp/command/internal_error', to: 'dummy_epp#internal_error',
|
||||
|
@ -81,6 +89,62 @@ class EppBaseTest < EppTestCase
|
|||
assert_epp_response :authorization_error
|
||||
end
|
||||
|
||||
def test_deletes_session_when_timed_out
|
||||
now = Time.zone.parse('2010-07-05')
|
||||
travel_to now
|
||||
timeout = 0.second
|
||||
EppSession.timeout = timeout
|
||||
session = epp_sessions(:api_bestnames)
|
||||
session.update!(updated_at: now - timeout - 1.second)
|
||||
|
||||
authentication_enabled_epp_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>
|
||||
<info>
|
||||
<domain:info xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>#{domains(:shop).name}</domain:name>
|
||||
</domain:info>
|
||||
</info>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
post '/epp/command/info', { frame: authentication_enabled_epp_request_xml },
|
||||
'HTTP_COOKIE' => "session=#{session.session_id}"
|
||||
|
||||
assert_epp_response :authorization_error
|
||||
assert_nil EppSession.find_by(session_id: session.session_id)
|
||||
end
|
||||
|
||||
def test_session_last_access_is_updated_when_not_timed_out
|
||||
now = Time.zone.parse('2010-07-05')
|
||||
travel_to now
|
||||
timeout = 1.seconds
|
||||
EppSession.timeout = timeout
|
||||
session = epp_sessions(:api_bestnames)
|
||||
session.last_access = now - timeout
|
||||
|
||||
authentication_enabled_epp_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>
|
||||
<info>
|
||||
<domain:info xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>#{domains(:shop).name}</domain:name>
|
||||
</domain:info>
|
||||
</info>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post '/epp/command/info', { frame: authentication_enabled_epp_request_xml },
|
||||
'HTTP_COOKIE' => "session=#{session.session_id}"
|
||||
session.reload
|
||||
|
||||
assert_epp_response :completed_successfully
|
||||
assert_equal now, session.last_access
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def valid_command_path
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue