Remote-Connection.t 914 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. use strict;
  2. use warnings;
  3. use Test::More;
  4. use Test::Fatal;
  5. use Test::LWP::UserAgent;
  6. BEGIN: {
  7. unless (use_ok('Selenium::Remote::RemoteConnection')) {
  8. BAIL_OUT("Couldn't load Selenium::Remote::RemoteConnection");
  9. exit;
  10. }
  11. }
  12. REDIRECT: {
  13. my $tua = Test::LWP::UserAgent->new(
  14. max_redirect => 0
  15. );
  16. $tua->map_response(qr/redirect/, HTTP::Response->new(303, undef, ['Location' => 'http://localhost/elsewhere']));
  17. $tua->map_response(qr/elsewhere/, HTTP::Response->new(200, 'OK', undef, ''));
  18. my $conn = Selenium::Remote::RemoteConnection->new(
  19. remote_server_addr => 'localhost',
  20. port => '',
  21. ua => $tua
  22. );
  23. my $redirect_endpoint = {
  24. method => 'GET',
  25. url => 'http://localhost/redirect'
  26. };
  27. is( exception { $conn->request($redirect_endpoint) }, undef,
  28. '303 redirects no longer kill us');
  29. }
  30. done_testing;