summaryrefslogtreecommitdiffstats
path: root/qa/t
diff options
context:
space:
mode:
Diffstat (limited to 'qa/t')
-rw-r--r--qa/t/lib/QA/Util.pm26
-rw-r--r--qa/t/test_flags.t8
-rw-r--r--qa/t/test_flags2.t2
-rw-r--r--qa/t/test_private_attachments.t6
-rw-r--r--qa/t/test_security.t4
5 files changed, 35 insertions, 11 deletions
diff --git a/qa/t/lib/QA/Util.pm b/qa/t/lib/QA/Util.pm
index 1ff37a0d7..4999e6f3b 100644
--- a/qa/t/lib/QA/Util.pm
+++ b/qa/t/lib/QA/Util.pm
@@ -13,7 +13,11 @@ use strict;
use Data::Dumper;
use Test::More;
use Test::WWW::Selenium;
+use MIME::Base64 qw(decode_base64);
+use Sys::Hostname qw(hostname);
+use Socket qw(inet_ntoa);
use WWW::Selenium::Util qw(server_is_running);
+use URI;
# Fixes wide character warnings
BEGIN {
@@ -42,6 +46,7 @@ use base qw(Exporter);
add_product
open_advanced_search_page
set_parameters
+ screenshot_page
get_selenium
get_rpc_clients
@@ -52,7 +57,7 @@ use base qw(Exporter);
# How long we wait for pages to load.
use constant WAIT_TIME => 60000;
-use constant CONF_FILE => "../config/selenium_test.conf";
+use constant CONF_FILE => $ENV{BZ_QA_CONF_FILE} // "../config/selenium_test.conf";
use constant CHROME_MODE => 1;
use constant NDASH => chr(0x2013);
@@ -92,6 +97,16 @@ sub get_config {
my $conf_file = CONF_FILE;
my $config = do($conf_file)
or die "can't read configuration '$conf_file': $!$@";
+ my $uri = URI->new($config->{browser_url});
+ if (my $ip_packed = gethostbyname($uri->host)) {
+ my $ip = inet_ntoa($ip_packed);
+ $uri->host($ip);
+ $config->{browser_ip_url} = "$uri";
+ }
+ else {
+ die "unable to find ip for $config->{browser_url}\n";
+ }
+ return $config;
}
sub get_selenium {
@@ -148,9 +163,18 @@ sub get_rpc_clients {
sub go_to_home {
my ($sel, $config) = @_;
$sel->open_ok("/$config->{bugzilla_installation}/", undef, "Go to the home page");
+ $sel->set_speed(500);
$sel->title_is("Bugzilla Main Page");
}
+sub screenshot_page {
+ my ($sel, $filename) = @_;
+ open my $fh, '>:raw', $filename or die "unable to write $filename: $!";
+ binmode $fh;
+ print $fh decode_base64($sel->capture_entire_page_screenshot_to_string());
+ close $fh;
+}
+
# Go to the home/login page and log in.
sub log_in {
my ($sel, $config, $user) = @_;
diff --git a/qa/t/test_flags.t b/qa/t/test_flags.t
index 8b7883bb5..e2ba621e6 100644
--- a/qa/t/test_flags.t
+++ b/qa/t/test_flags.t
@@ -299,7 +299,7 @@ $sel->title_like(qr/^$bug1_id /);
$sel->click_ok("link=Add an attachment");
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is("Create New Attachment for Bug #$bug1_id");
-$sel->type_ok("data", $config->{attachment_file});
+$sel->attach_file("data", $config->{attachment_file});
$sel->type_ok("description", "patch, v1");
$sel->check_ok("ispatch");
$sel->is_text_present_ok("SeleniumAttachmentFlag1Test");
@@ -326,7 +326,7 @@ my $attachment1_id = $1;
$sel->click_ok("//a[contains(text(),'Create\n Another Attachment to Bug $bug1_id')]");
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is("Create New Attachment for Bug #$bug1_id");
-$sel->type_ok("data", $config->{attachment_file});
+$sel->attach_file("data", $config->{attachment_file});
$sel->type_ok("description", "patch, v2");
$sel->check_ok("ispatch");
# Mark the previous attachment as obsolete.
@@ -350,7 +350,7 @@ my $attachment2_id = $1;
$sel->click_ok("//a[contains(text(),'Create\n Another Attachment to Bug $bug1_id')]");
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is("Create New Attachment for Bug #$bug1_id");
-$sel->type_ok("data", $config->{attachment_file});
+$sel->attach_file("data", $config->{attachment_file});
$sel->type_ok("description", "patch, v3");
$sel->click_ok("list");
$sel->select_ok("contenttypeselection", "label=plain text (text/plain)");
@@ -423,7 +423,7 @@ $sel->title_like(qr/^$bug1_id/);
$sel->click_ok("link=Add an attachment");
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is("Create New Attachment for Bug #$bug1_id");
-$sel->type_ok("data", $config->{attachment_file});
+$sel->attach_file("data", $config->{attachment_file});
$sel->type_ok("description", "patch, v4");
$sel->value_is("ispatch", "on");
diff --git a/qa/t/test_flags2.t b/qa/t/test_flags2.t
index cec9ee6ef..3d2d59db8 100644
--- a/qa/t/test_flags2.t
+++ b/qa/t/test_flags2.t
@@ -150,7 +150,7 @@ $sel->select_ok("flag_type-$flagtype1_id", "label=+");
$sel->type_ok("short_desc", "The selenium flag should be kept on product change");
$sel->type_ok("comment", "pom");
$sel->click_ok('//input[@value="Add an attachment"]');
-$sel->type_ok("data", $config->{attachment_file});
+$sel->attach_file("data", $config->{attachment_file});
$sel->type_ok("description", "small patch");
$sel->value_is("ispatch", "on");
ok(!$sel->is_element_present("flag_type-$aflagtype1_id"), "Flag type $aflagtype1_id not available in TestProduct");
diff --git a/qa/t/test_private_attachments.t b/qa/t/test_private_attachments.t
index 6126974d7..c6b6df5a1 100644
--- a/qa/t/test_private_attachments.t
+++ b/qa/t/test_private_attachments.t
@@ -33,7 +33,7 @@ $sel->type_ok("short_desc", "Some comments are private");
$sel->type_ok("comment", "and some attachments too, like this one.");
$sel->check_ok("comment_is_private");
$sel->click_ok('//input[@value="Add an attachment"]');
-$sel->type_ok("data", $config->{attachment_file});
+$sel->attach_file("data", $config->{attachment_file});
$sel->type_ok("description", "private attachment, v1");
$sel->check_ok("ispatch");
$sel->click_ok("commit");
@@ -49,7 +49,7 @@ $sel->is_checked_ok('//a[@id="comment_link_0"]/../..//div//input[@type="checkbox
$sel->click_ok("link=Add an attachment");
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is("Create New Attachment for Bug #$bug1_id");
-$sel->type_ok("data", $config->{attachment_file});
+$sel->attach_file("data", $config->{attachment_file});
$sel->type_ok("description", "public attachment, v2");
$sel->check_ok("ispatch");
# The existing attachment name must be displayed, to mark it as obsolete.
@@ -109,7 +109,7 @@ $sel->is_text_present_ok("This attachment is not mine");
$sel->click_ok("link=Add an attachment");
$sel->wait_for_page_to_load_ok(WAIT_TIME);
$sel->title_is("Create New Attachment for Bug #$bug1_id");
-$sel->type_ok("data", $config->{attachment_file});
+$sel->attach_file("data", $config->{attachment_file});
$sel->check_ok("ispatch");
# The user doesn't have editbugs privs.
$sel->is_text_present_ok("[no attachments can be made obsolete]");
diff --git a/qa/t/test_security.t b/qa/t/test_security.t
index 6d545ffd5..56fba4b01 100644
--- a/qa/t/test_security.t
+++ b/qa/t/test_security.t
@@ -24,7 +24,7 @@ file_bug_in_product($sel, "TestProduct");
my $bug_summary = "Security checks";
$sel->type_ok("short_desc", $bug_summary);
$sel->type_ok("comment", "This bug will be used to test security fixes.");
-$sel->type_ok("data", $config->{attachment_file});
+$sel->attach_file("data", $config->{attachment_file});
$sel->type_ok("description", "simple patch, v1");
my $bug1_id = create_bug($sel, $bug_summary);
@@ -54,7 +54,7 @@ $sel->title_like(qr/^$bug1_id /);
# Alternate host for attachments; no cookie should be accessible.
set_parameters($sel, { "Attachments" => {"attachment_base" => {type => "text",
- value => "http://127.0.0.1/$urlbase/"}} });
+ value => "$config->{browser_ip_url}/$urlbase/"}} });
go_to_bug($sel, $bug1_id);
$sel->click_ok("link=simple patch, v1");
$sel->wait_for_page_to_load_ok(WAIT_TIME);