require 'test_helper' class EppLoginSessionLimitTest < EppTestCase setup do travel_to Time.zone.parse('2010-07-05') EppSession.delete_all end def test_not_reached (EppSession.limit_per_registrar - 1).times do EppSession.create!(session_id: SecureRandom.hex, user: users(:api_bestnames), updated_at: Time.zone.parse('2010-07-05')) end assert_difference 'EppSession.count' do post epp_login_path, { frame: request_xml }, { 'HTTP_COOKIE' => 'session=new_session_id' } end assert_epp_response :completed_successfully end def test_reached EppSession.limit_per_registrar.times do EppSession.create!(session_id: SecureRandom.hex, user: users(:api_bestnames), updated_at: Time.zone.parse('2010-07-05')) end assert_no_difference 'EppSession.count' do post epp_login_path, { frame: request_xml }, { 'HTTP_COOKIE' => 'session=new_session_id' } end assert_epp_response :authentication_error_server_closing_connection end private def request_xml <<-XML test_bestnames testtest 1.0 en https://epp.tld.ee/schema/domain-eis-1.0.xsd https://epp.tld.ee/schema/contact-ee-1.1.xsd urn:ietf:params:xml:ns:host-1.0 urn:ietf:params:xml:ns:keyrelay-1.0 XML end end