diff --git a/test/integration/epp/login/credentials_test.rb b/test/integration/epp/login/credentials_test.rb deleted file mode 100644 index 0f7dac97c..000000000 --- a/test/integration/epp/login/credentials_test.rb +++ /dev/null @@ -1,64 +0,0 @@ -require 'test_helper' - -class EppLoginCredentialsTest < EppTestCase - def test_correct_credentials - 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 - - - - - XML - - post epp_login_path, params: { frame: request_xml }, - headers: { 'HTTP_COOKIE' => 'session=new_session_id' } - assert EppSession.find_by(session_id: 'new_session_id') - assert_equal users(:api_bestnames), EppSession.find_by(session_id: 'new_session_id').user - assert_epp_response :completed_successfully - end - - def test_already_logged_in - assert true # Handled by EPP proxy - end - - def test_wrong_credentials - request_xml = <<-XML - - - - - non-existent - valid-but-wrong - - 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 - - - - - XML - - post epp_login_path, params: { frame: request_xml }, - headers: { 'HTTP_COOKIE' => 'session=any_random_string' } - - assert_epp_response :authentication_error_server_closing_connection - end -end diff --git a/test/integration/epp/login/password_change_test.rb b/test/integration/epp/login/password_change_test.rb deleted file mode 100644 index 3b1834406..000000000 --- a/test/integration/epp/login/password_change_test.rb +++ /dev/null @@ -1,32 +0,0 @@ -require 'test_helper' - -class EppLoginPasswordChangeTest < EppTestCase - def test_password_change - request_xml = <<-XML - - - - - test_bestnames - testtest - new-password - - 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 - - - - - XML - - post epp_login_path, params: { frame: request_xml }, - headers: { 'HTTP_COOKIE' => 'session=new_session_id' } - assert_equal 'new-password', users(:api_bestnames).plain_text_password - assert_epp_response :completed_successfully - end -end \ No newline at end of file diff --git a/test/integration/epp/login/session_limit_test.rb b/test/integration/epp/login/session_limit_test.rb deleted file mode 100644 index f1d83fe7b..000000000 --- a/test/integration/epp/login/session_limit_test.rb +++ /dev/null @@ -1,61 +0,0 @@ -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, params: { frame: request_xml }, - headers: { '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, params: { frame: request_xml }, - headers: { '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 - - - - - XML - end -end diff --git a/test/integration/epp/login_test.rb b/test/integration/epp/login_test.rb new file mode 100644 index 000000000..d3ef22ec1 --- /dev/null +++ b/test/integration/epp/login_test.rb @@ -0,0 +1,167 @@ +require 'test_helper' + +class EppLoginTest < EppTestCase + def test_correct_credentials + 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 + + post '/epp/session/login', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=new_session_id' } + assert EppSession.find_by(session_id: 'new_session_id') + assert_equal users(:api_bestnames), EppSession.find_by(session_id: 'new_session_id').user + assert_epp_response :completed_successfully + end + + def test_already_logged_in + assert true # Handled by mod_epp + end + + def test_wrong_credentials + request_xml = <<-XML + + + + + non-existent + valid-but-wrong + + 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 + + post '/epp/session/login', { frame: request_xml }, 'HTTP_COOKIE' => 'session=any_random_string' + + assert_epp_response :authentication_error_server_closing_connection + end + + def test_password_change + request_xml = <<-XML + + + + + test_bestnames + testtest + new-password + + 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 + + post '/epp/session/login', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=new_session_id' } + assert_equal 'new-password', users(:api_bestnames).plain_text_password + assert_epp_response :completed_successfully + end + + def test_not_reached + travel_to Time.zone.parse('2010-07-05') + EppSession.delete_all + 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 + + (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/session/login', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=new_session_id' } + end + assert_epp_response :completed_successfully + end + + def test_reached + travel_to Time.zone.parse('2010-07-05') + EppSession.delete_all + 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 + + 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/session/login', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=new_session_id' } + end + assert_epp_response :authentication_error_server_closing_connection + end +end