]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
no bug - reformat tests too
authorPerl Tidy <perltidy@bugzilla.org>
Wed, 5 Dec 2018 15:48:51 +0000 (10:48 -0500)
committerDylan William Hardison <dylan@hardison.net>
Wed, 5 Dec 2018 15:48:51 +0000 (10:48 -0500)
98 files changed:
extensions/BMO/t/bounty_attachment.t
extensions/PhabBugz/t/basic.t
extensions/PhabBugz/t/feed-daemon-guts.t
qa/t/archived/test_email_preferences.t
qa/t/rest_bugzilla.t
qa/t/rest_classification.t
qa/t/selenium_server_start.t
qa/t/selenium_server_stop.t
qa/t/test_bmo_autolinkification.t
qa/t/test_bmo_enter_new_bug.t
qa/t/test_bmo_retire_values.t
qa/t/test_bug_edit.t
qa/t/test_choose_priority.t
qa/t/test_classifications.t
qa/t/test_config.t
qa/t/test_create_user_accounts.t
qa/t/test_custom_fields.t
qa/t/test_custom_fields_admin.t
qa/t/test_default_groups.t
qa/t/test_dependencies.t
qa/t/test_edit_products_properties.t
qa/t/test_enter_new_bug.t
qa/t/test_flags.t
qa/t/test_flags2.t
qa/t/test_groups.t
qa/t/test_keywords.t
qa/t/test_login.t
qa/t/test_milestones.t
qa/t/test_private_attachments.t
qa/t/test_qa_contact.t
qa/t/test_require_login.t
qa/t/test_sanity_check.t
qa/t/test_saved_searches.t
qa/t/test_search.t
qa/t/test_security.t
qa/t/test_shared_searches.t
qa/t/test_show_all_products.t
qa/t/test_status_whiteboard.t
qa/t/test_sudo_sessions.t
qa/t/test_target_milestones.t
qa/t/test_time_summary.t
qa/t/test_user_groups.t
qa/t/test_user_matching.t
qa/t/test_user_preferences.t
qa/t/test_user_privs.t
qa/t/test_votes.t
qa/t/webservice_bug_add_attachment.t
qa/t/webservice_bug_add_comment.t
qa/t/webservice_bug_attachments.t
qa/t/webservice_bug_comments.t
qa/t/webservice_bug_create.t
qa/t/webservice_bug_fields.t
qa/t/webservice_bug_get.t
qa/t/webservice_bug_get_bugs.t
qa/t/webservice_bug_history.t
qa/t/webservice_bug_legal_values.t
qa/t/webservice_bug_search.t
qa/t/webservice_bug_update.t
qa/t/webservice_bug_update_see_also.t
qa/t/webservice_bugzilla.t
qa/t/webservice_group_create.t
qa/t/webservice_jsonp.t
qa/t/webservice_product.t
qa/t/webservice_product_create.t
qa/t/webservice_product_get.t
qa/t/webservice_user_create.t
qa/t/webservice_user_get.t
qa/t/webservice_user_login_logout.t
qa/t/webservice_user_offer_account_by_email.t
t/001compile.t
t/002goodperl.t
t/004template.t
t/005whitespace.t
t/006spellcheck.t
t/007util.t
t/008filter.t
t/009bugwords.t
t/010dependencies.t
t/011pod.t
t/012throwables.t
t/901-secure-mail-loop.t
t/902-crypt-openpgp-random.t
t/903-passwdqc-conf.t
t/bmo/comments.t
t/bmo/passwords.t
t/critic.t
t/css.t
t/daemon-control-catch-signal.t
t/docker.t
t/extract-nicks.t
t/hash-sig.t
t/markdown.t
t/mock-db.t
t/mock-params.t
t/mojo-example.t
t/mojo-oauth2.t
t/sqlite-memory.t
xt/search.t

index 6e596eebae06b9b309c10fe048c632ecaa64f157..61552c074c45549444f0ef8eb8e6022d7df6acfd 100644 (file)
@@ -13,46 +13,69 @@ use Test::More;
 use Bugzilla;
 BEGIN { Bugzilla->extensions }
 
-my $class = 'Bugzilla::Extension::BMO';
+my $class  = 'Bugzilla::Extension::BMO';
 my $parse  = $class->can('parse_bounty_attachment_description');
 my $format = $class->can('format_bounty_attachment_description');
 
 ok($parse, "got the function");
 
 my $bughunter = $parse->('bughunter@hacker.org, , 2014-06-25, , ,false');
-is_deeply({ reporter_email => 'bughunter@hacker.org',
-            amount_paid    => '',
-            reported_date  => '2014-06-25',
-            fixed_date     => '',
-            awarded_date   => '',
-            publish        => 0,
-            credit         => []}, $bughunter);
-
-my $hfli = $parse->('hfli@fortinet.com, 1000, 2010-07-16, 2010-08-04, 2011-06-15, true, Fortiguard Labs');
-is_deeply({  reporter_email => 'hfli@fortinet.com',
-             amount_paid    => '1000',
-             reported_date  => '2010-07-16',
-             fixed_date     => '2010-08-04',
-             awarded_date   => '2011-06-15',
-             publish        => 1,
-             credit         => ['Fortiguard Labs']}, $hfli);
-
-is('batman@justiceleague.america,1000,2015-01-01,2015-02-02,2015-03-03,true,JLA,Wayne Industries,Test',
-   $format->({ reporter_email => 'batman@justiceleague.america',
-               amount_paid    => 1000,
-               reported_date  => '2015-01-01',
-               fixed_date     => '2015-02-02',
-               awarded_date   => '2015-03-03',
-               publish        => 1,
-               credit         => ['JLA', 'Wayne Industries', 'Test'] }));
-
-my $dylan = $parse->('dylan@hardison.net,2,2014-09-23,2014-09-24,2014-09-25,true,Foo bar,Bork,');
-is_deeply({ reporter_email => 'dylan@hardison.net',
-            amount_paid    => 2,
-            reported_date  => '2014-09-23',
-            fixed_date     => '2014-09-24',
-            awarded_date   => '2014-09-25',
-            publish        => 1,
-            credit         => ['Foo bar', 'Bork']}, $dylan);
+is_deeply(
+  {
+    reporter_email => 'bughunter@hacker.org',
+    amount_paid    => '',
+    reported_date  => '2014-06-25',
+    fixed_date     => '',
+    awarded_date   => '',
+    publish        => 0,
+    credit         => []
+  },
+  $bughunter
+);
+
+my $hfli
+  = $parse->(
+  'hfli@fortinet.com, 1000, 2010-07-16, 2010-08-04, 2011-06-15, true, Fortiguard Labs'
+  );
+is_deeply(
+  {
+    reporter_email => 'hfli@fortinet.com',
+    amount_paid    => '1000',
+    reported_date  => '2010-07-16',
+    fixed_date     => '2010-08-04',
+    awarded_date   => '2011-06-15',
+    publish        => 1,
+    credit         => ['Fortiguard Labs']
+  },
+  $hfli
+);
+
+is(
+  'batman@justiceleague.america,1000,2015-01-01,2015-02-02,2015-03-03,true,JLA,Wayne Industries,Test',
+  $format->({
+    reporter_email => 'batman@justiceleague.america',
+    amount_paid    => 1000,
+    reported_date  => '2015-01-01',
+    fixed_date     => '2015-02-02',
+    awarded_date   => '2015-03-03',
+    publish        => 1,
+    credit         => ['JLA', 'Wayne Industries', 'Test']
+  })
+);
+
+my $dylan = $parse->(
+  'dylan@hardison.net,2,2014-09-23,2014-09-24,2014-09-25,true,Foo bar,Bork,');
+is_deeply(
+  {
+    reporter_email => 'dylan@hardison.net',
+    amount_paid    => 2,
+    reported_date  => '2014-09-23',
+    fixed_date     => '2014-09-24',
+    awarded_date   => '2014-09-25',
+    publish        => 1,
+    credit         => ['Foo bar', 'Bork']
+  },
+  $dylan
+);
 
 done_testing;
index 2f05496cd20ccc411c7f2b55761e6f7d21399344..161c58637a77e47be563668bbdf9acc0ad6fc8b1 100644 (file)
@@ -11,7 +11,7 @@ use 5.10.1;
 use lib qw( . lib local/lib/perl5 );
 use Bugzilla;
 
-BEGIN { Bugzilla->extensions };
+BEGIN { Bugzilla->extensions }
 
 use Test::More;
 use Test2::Tools::Mock;
@@ -30,68 +30,65 @@ our @project_members;
 
 
 my $User = mock 'Bugzilla::Extension::PhabBugz::User' => (
-    add_constructor => [
-        'fake_new' => 'hash',
-    ],
-    override => [
-        'match' => sub { [ mock() ] },
-    ],
+  add_constructor => ['fake_new' => 'hash',],
+  override        => ['match'    => sub { [mock()] },],
 );
 
 my $Feed = mock 'Bugzilla::Extension::PhabBugz::Feed' => (
-    override => [
-        get_group_members => sub {
-            return [ map { Bugzilla::Extension::PhabBugz::User->fake_new(%$_) } @group_members ];
-        }
-    ]
+  override => [
+    get_group_members => sub {
+      return [map { Bugzilla::Extension::PhabBugz::User->fake_new(%$_) }
+          @group_members];
+    }
+  ]
 );
 
 my $Project = mock 'Bugzilla::Extension::PhabBugz::Project' => (
-    override_constructor => [
-        new_from_query => 'ref_copy',
-    ],
-    override => [
-        'members' => sub {
-            return [ map { Bugzilla::Extension::PhabBugz::User->fake_new(%$_) } @project_members ];
-        }
-    ]
+  override_constructor => [new_from_query => 'ref_copy',],
+  override             => [
+    'members' => sub {
+      return [map { Bugzilla::Extension::PhabBugz::User->fake_new(%$_) }
+          @project_members];
+    }
+  ]
 );
 
-local Bugzilla->params->{phabricator_enabled} = 1;
-local Bugzilla->params->{phabricator_api_key} = 'FAKE-API-KEY';
+local Bugzilla->params->{phabricator_enabled}  = 1;
+local Bugzilla->params->{phabricator_api_key}  = 'FAKE-API-KEY';
 local Bugzilla->params->{phabricator_base_uri} = 'http://fake.fabricator.tld';
 
 my $Bugzilla = mock 'Bugzilla' => (
-    override => [
-        'dbh'  => sub { mock() },
-        'user' => sub { Bugzilla::User->new({ name => 'phab-bot@bmo.tld' }) },
-    ],
+  override => [
+    'dbh'  => sub { mock() },
+    'user' => sub { Bugzilla::User->new({name => 'phab-bot@bmo.tld'}) },
+  ],
 );
 
 my $BugzillaGroup = mock 'Bugzilla::Group' => (
-    add_constructor => [
-        'fake_new' => 'hash',
-    ],
-    override => [
-        'match' => sub { [ Bugzilla::Group->fake_new(id => 1, name => 'firefox-security' ) ] },
-    ],
+  add_constructor => ['fake_new' => 'hash',],
+  override        => [
+    'match' =>
+      sub { [Bugzilla::Group->fake_new(id => 1, name => 'firefox-security')] },
+  ],
 );
 
 my $BugzillaUser = mock 'Bugzilla::User' => (
-    add_constructor => [
-        'fake_new' => 'hash',
-    ],
-    override => [
-        'new' => sub {
-            my ($class, $hash) = @_;
-            if ($hash->{name} eq 'phab-bot@bmo.tld') {
-                return $class->fake_new( id => 8_675_309, login_name => 'phab-bot@bmo.tld', realname => 'Fake PhabBot' );
-            }
-            else {
-            }
-        },
-        'match' => sub { [ mock() ] },
-    ],
+  add_constructor => ['fake_new' => 'hash',],
+  override        => [
+    'new' => sub {
+      my ($class, $hash) = @_;
+      if ($hash->{name} eq 'phab-bot@bmo.tld') {
+        return $class->fake_new(
+          id         => 8_675_309,
+          login_name => 'phab-bot@bmo.tld',
+          realname   => 'Fake PhabBot'
+        );
+      }
+      else {
+      }
+    },
+    'match' => sub { [mock()] },
+  ],
 );
 
 
@@ -99,78 +96,66 @@ my $feed = Bugzilla::Extension::PhabBugz::Feed->new;
 
 # Same members in both
 do {
-    my $UserAgent = mock 'Mojo::UserAgent' => (
-        override => [
-            'post' => sub {
-                my ($self, $url, undef, $params) = @_;
-                my $data = decode_json($params->{params});
-                is_deeply($data->{transactions}, [], 'no-op');
-                return mock_useragent_tx('{}');
-            },
-        ],
-    );
-    local @group_members = (
-        { phid => 'foo' },
-    );
-    local @project_members = (
-        { phid => 'foo' },
-    );
-    $feed->group_query;
+  my $UserAgent = mock 'Mojo::UserAgent' => (
+    override => [
+      'post' => sub {
+        my ($self, $url, undef, $params) = @_;
+        my $data = decode_json($params->{params});
+        is_deeply($data->{transactions}, [], 'no-op');
+        return mock_useragent_tx('{}');
+      },
+    ],
+  );
+  local @group_members   = ({phid => 'foo'},);
+  local @project_members = ({phid => 'foo'},);
+  $feed->group_query;
 };
 
 # Project has members not in group
 do {
-    my $UserAgent = mock 'Mojo::UserAgent' => (
-        override => [
-            'post' => sub {
-                my ($self, $url, undef, $params) = @_;
-                my $data = decode_json($params->{params});
-                my $expected = [ { type => 'members.remove', value => ['foo'] } ];
-                is_deeply($data->{transactions}, $expected, 'remove foo');
-                return mock_useragent_tx('{}');
-            },
-        ]
-    );
-    local @group_members = ();
-    local @project_members = (
-        { phid => 'foo' },
-    );
-    $feed->group_query;
+  my $UserAgent = mock 'Mojo::UserAgent' => (
+    override => [
+      'post' => sub {
+        my ($self, $url, undef, $params) = @_;
+        my $data = decode_json($params->{params});
+        my $expected = [{type => 'members.remove', value => ['foo']}];
+        is_deeply($data->{transactions}, $expected, 'remove foo');
+        return mock_useragent_tx('{}');
+      },
+    ]
+  );
+  local @group_members = ();
+  local @project_members = ({phid => 'foo'},);
+  $feed->group_query;
 };
 
 # Group has members not in project
 do {
-    my $UserAgent = mock 'Mojo::UserAgent' => (
-        override => [
-            'post' => sub {
-                my ($self, $url, undef, $params) = @_;
-                my $data = decode_json($params->{params});
-                my $expected = [ { type => 'members.add', value => ['foo'] } ];
-                is_deeply($data->{transactions}, $expected, 'add foo');
-                return mock_useragent_tx('{}');
-            },
-        ]
-    );
-    local @group_members = (
-        { phid => 'foo' },
-    );
-    local @project_members = (
-    );
-    $feed->group_query;
+  my $UserAgent = mock 'Mojo::UserAgent' => (
+    override => [
+      'post' => sub {
+        my ($self, $url, undef, $params) = @_;
+        my $data = decode_json($params->{params});
+        my $expected = [{type => 'members.add', value => ['foo']}];
+        is_deeply($data->{transactions}, $expected, 'add foo');
+        return mock_useragent_tx('{}');
+      },
+    ]
+  );
+  local @group_members = ({phid => 'foo'},);
+  local @project_members = ();
+  $feed->group_query;
 };
 
 do {
-    my $Revision  = mock 'Bugzilla::Extension::PhabBugz::Revision' => (
-        override => [
-            'update' => sub { 1 },
-        ],
-    );
-    my $UserAgent = mock 'Mojo::UserAgent' => (
-        override => [
-            'post' => sub {
-                my ($self, $url, undef, $params) = @_;
-                if ($url =~ /differential\.revision\.search/) {
-                    my $content = <<JSON;
+  my $Revision = mock 'Bugzilla::Extension::PhabBugz::Revision' =>
+    (override => ['update' => sub {1},],);
+  my $UserAgent = mock 'Mojo::UserAgent' => (
+    override => [
+      'post' => sub {
+        my ($self, $url, undef, $params) = @_;
+        if ($url =~ /differential\.revision\.search/) {
+          my $content = <<JSON;
 {
     "error_info": null,
     "error_code": null,
@@ -217,35 +202,32 @@ do {
     }
 }
 JSON
-                    return mock_useragent_tx($content);
-                }
-                else {
-                    return mock_useragent_tx("bad request");
-                }
-            },
-        ],
-    );
-    my $Attachment = mock 'Bugzilla::Attachment' => (
-        add_constructor => [ fake_new => 'hash' ],
-    );
-    my $Bug = mock 'Bugzilla::Bug' => (
-        add_constructor => [ fake_new => 'hash' ],
-    );
-    my $bug = Bugzilla::Bug->fake_new(
-        bug_id      => 23,
-        attachments => [
-            Bugzilla::Attachment->fake_new(
-                mimetype => 'text/x-phabricator-request',
-                filename => 'phabricator-D9999-url.txt',
-            ),
-        ]
-    );
+          return mock_useragent_tx($content);
+        }
+        else {
+          return mock_useragent_tx("bad request");
+        }
+      },
+    ],
+  );
+  my $Attachment
+    = mock 'Bugzilla::Attachment' => (add_constructor => [fake_new => 'hash'],);
+  my $Bug = mock 'Bugzilla::Bug' => (add_constructor => [fake_new => 'hash'],);
+  my $bug = Bugzilla::Bug->fake_new(
+    bug_id      => 23,
+    attachments => [
+      Bugzilla::Attachment->fake_new(
+        mimetype => 'text/x-phabricator-request',
+        filename => 'phabricator-D9999-url.txt',
+      ),
+    ]
+  );
 
-    my $revisions = get_attachment_revisions($bug);
-    is(ref($revisions), 'ARRAY', 'it is an array ref');
-    isa_ok($revisions->[0], 'Bugzilla::Extension::PhabBugz::Revision');
-    is($revisions->[0]->bug_id, 23, 'Bugzila ID is 23');
-    ok( try { $revisions->[0]->update }, 'update revision');
+  my $revisions = get_attachment_revisions($bug);
+  is(ref($revisions), 'ARRAY', 'it is an array ref');
+  isa_ok($revisions->[0], 'Bugzilla::Extension::PhabBugz::Revision');
+  is($revisions->[0]->bug_id, 23, 'Bugzila ID is 23');
+  ok(try { $revisions->[0]->update }, 'update revision');
 
 };
 
index 0c508be98773f6e8a7548c545351cc1943fadca1..44d65eab4179f37b3c8814f579fae17df85efeb5 100644 (file)
@@ -24,8 +24,11 @@ use Digest::SHA qw(sha1_hex);
 
 use ok 'Bugzilla::Extension::PhabBugz::Feed';
 use ok 'Bugzilla::Extension::PhabBugz::Constants', 'PHAB_AUTOMATION_USER';
-use ok 'Bugzilla::Config', 'SetParam';
-can_ok('Bugzilla::Extension::PhabBugz::Feed', qw( group_query feed_query user_query ));
+use ok 'Bugzilla::Config',                         'SetParam';
+can_ok(
+  'Bugzilla::Extension::PhabBugz::Feed',
+  qw( group_query feed_query user_query )
+);
 
 Bugzilla->error_mode(ERROR_MODE_TEST);
 
@@ -34,127 +37,117 @@ my $phab_bot = create_user(PHAB_AUTOMATION_USER, '*');
 my $UserAgent = mock 'Mojo::UserAgent' => ();
 
 {
-    SetParam('phabricator_enabled', 0);
-    my $feed = Bugzilla::Extension::PhabBugz::Feed->new;
-    my $Feed = mock 'Bugzilla::Extension::PhabBugz::Feed' => (
-        override => [
-            get_last_id => sub { die "get_last_id" },
-        ],
-    );
-
-    foreach my $method (qw( feed_query user_query group_query )) {
-        try {
-            $feed->$method;
-            pass "disabling the phabricator sync: $method";
-        }
-        catch {
-            fail "disabling the phabricator sync: $method";
-        }
+  SetParam('phabricator_enabled', 0);
+  my $feed = Bugzilla::Extension::PhabBugz::Feed->new;
+  my $Feed = mock 'Bugzilla::Extension::PhabBugz::Feed' =>
+    (override => [get_last_id => sub { die "get_last_id" },],);
+
+  foreach my $method (qw( feed_query user_query group_query )) {
+    try {
+      $feed->$method;
+      pass "disabling the phabricator sync: $method";
+    }
+    catch {
+      fail "disabling the phabricator sync: $method";
     }
+  }
 }
 
 my @bad_response = (
-    ['http error', mock_useragent_tx("doesn't matter", sub { $_->code(500) }) ],
-    ['invalid json', mock_useragent_tx('<xml>foo</xml>') ],
-    ['json containing error code', mock_useragent_tx(encode_json({error_code => 1234 }))],
+  ['http error',   mock_useragent_tx("doesn't matter", sub { $_->code(500) })],
+  ['invalid json', mock_useragent_tx('<xml>foo</xml>')],
+  [
+    'json containing error code',
+    mock_useragent_tx(encode_json({error_code => 1234}))
+  ],
 );
 
-SetParam(phabricator_enabled => 1);
-SetParam(phabricator_api_key => 'FAKE-API-KEY');
+SetParam(phabricator_enabled  => 1);
+SetParam(phabricator_api_key  => 'FAKE-API-KEY');
 SetParam(phabricator_base_uri => 'http://fake.fabricator.tld/');
 
 foreach my $bad_response (@bad_response) {
-    my $feed = Bugzilla::Extension::PhabBugz::Feed->new;
-    $UserAgent->override(
-        post => sub {
-            my ( $self, $url, undef, $params ) = @_;
-            return $bad_response->[1];
-        }
-    );
-
-    foreach my $method (qw( feed_query user_query group_query )) {
-        try {
-            # This is a hack to get reasonable exception objects.
-            local $Bugzilla::Template::is_processing = 1;
-            $feed->$method;
-            fail "$method - $bad_response->[0]";
-        }
-        catch {
-            is( $_->type, 'bugzilla.code.phabricator_api_error', "$method - $bad_response->[0]" );
-        };
+  my $feed = Bugzilla::Extension::PhabBugz::Feed->new;
+  $UserAgent->override(
+    post => sub {
+      my ($self, $url, undef, $params) = @_;
+      return $bad_response->[1];
     }
-    $UserAgent->reset('post');
+  );
+
+  foreach my $method (qw( feed_query user_query group_query )) {
+    try {
+      # This is a hack to get reasonable exception objects.
+      local $Bugzilla::Template::is_processing = 1;
+      $feed->$method;
+      fail "$method - $bad_response->[0]";
+    }
+    catch {
+      is(
+        $_->type,
+        'bugzilla.code.phabricator_api_error',
+        "$method - $bad_response->[0]"
+      );
+    };
+  }
+  $UserAgent->reset('post');
 }
 
-my $feed      = Bugzilla::Extension::PhabBugz::Feed->new;
-my $json      = JSON::MaybeXS->new( canonical => 1, pretty => 1 );
-my $dylan     = create_user( 'dylan@mozilla.com', '*', realname => 'Dylan Hardison :dylan' );
-my $evildylan = create_user( 'dylan@gmail.com', '*', realname => 'Evil Dylan :dylan' );
-my $myk       = create_user( 'myk@mozilla.com', '*', realname => 'Myk Melez :myk' );
+my $feed = Bugzilla::Extension::PhabBugz::Feed->new;
+my $json = JSON::MaybeXS->new(canonical => 1, pretty => 1);
+my $dylan
+  = create_user('dylan@mozilla.com', '*', realname => 'Dylan Hardison :dylan');
+my $evildylan
+  = create_user('dylan@gmail.com', '*', realname => 'Evil Dylan :dylan');
+my $myk = create_user('myk@mozilla.com', '*', realname => 'Myk Melez :myk');
 
 my $phab_bot_phid = next_phid('PHID-USER');
 
 done_testing;
 
 sub user_search {
-    my (%conf) = @_;
-
-    return {
-        error_info => undef,
-        error_code => undef,
-        result     => {
-            cursor => {
-                after  => $conf{after},
-                order  => undef,
-                limit  => 100,
-                before => undef
+  my (%conf) = @_;
+
+  return {
+    error_info => undef,
+    error_code => undef,
+    result     => {
+      cursor =>
+        {after => $conf{after}, order => undef, limit => 100, before => undef},
+      query => {queryKey => undef},
+      maps  => {},
+      data  => [
+        map {
+          +{
+            attachments => {
+              $_->{bmo_id}
+              ? ("external-accounts" =>
+                  {"external-accounts" => [{type => 'bmo', id => $_->{bmo_id},}]})
+              : (),
             },
-            query => {
-                queryKey => undef
+            fields => {
+              roles        => ["verified", "approved", "activated"],
+              realName     => $_->{realname},
+              dateModified => time,
+              policy       => {view => "public", edit => "no-one"},
+              dateCreated  => time,
+              username     => $_->{username},
             },
-            maps => {},
-            data => [
-                map {
-                    +{
-                        attachments => {
-                            $_->{bmo_id}
-                            ? ( "external-accounts" => {
-                                    "external-accounts" => [
-                                        {
-                                            type => 'bmo',
-                                            id   => $_->{bmo_id},
-                                        }
-                                    ]
-                                }
-                              )
-                            : (),
-                        },
-                        fields => {
-                            roles        => [ "verified", "approved", "activated" ],
-                            realName     => $_->{realname},
-                            dateModified => time,
-                            policy       => {
-                                view => "public",
-                                edit => "no-one"
-                            },
-                            dateCreated => time,
-                            username    => $_->{username},
-                        },
-                        phid => next_phid("PHID-USER"),
-                        type => "USER",
-                        id   => $_->{phab_id},
-                      },
-                } @{ $conf{users} },
-            ]
-        }
-    };
+            phid => next_phid("PHID-USER"),
+            type => "USER",
+            id   => $_->{phab_id},
+            },
+        } @{$conf{users}},
+      ]
+    }
+  };
 
 }
 
 sub next_phid {
-    my ($prefix) = @_;
-    state $number = 'a' x 20;
-    return $prefix . '-' .  ($number++);
+  my ($prefix) = @_;
+  state $number = 'a' x 20;
+  return $prefix . '-' . ($number++);
 }
 
 
index cc314ea2c52c4eda6497ccb83e3afeb752b77852..fe51ee140370d41a1343a9b2686a41092b05b3be 100644 (file)
@@ -59,76 +59,86 @@ $sel->click_ok("link=Email Preferences");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->is_text_present_ok("Email Preferences");
 $sel->click_ok("//input[\@value='Disable All Bugmail']");
-$sel->click_ok("email-0-1", undef, 'Set "I\'m added to or removed from this capacity" for Assignee role');
-$sel->click_ok("email-0-5", undef, 'Set "The priority, status, severity, or milestone changes" for Assignee role');
-$sel->click_ok("email-0-2", undef, 'Set "New comments are added" for Assignee role');
-$sel->click_ok("email-0-0", undef, 'Set "Any field not mentioned above changes" for Assignee role');
+$sel->click_ok("email-0-1", undef,
+  'Set "I\'m added to or removed from this capacity" for Assignee role');
+$sel->click_ok("email-0-5", undef,
+  'Set "The priority, status, severity, or milestone changes" for Assignee role');
+$sel->click_ok("email-0-2", undef,
+  'Set "New comments are added" for Assignee role');
+$sel->click_ok("email-0-0", undef,
+  'Set "Any field not mentioned above changes" for Assignee role');
 $sel->click_ok("email-3-8", undef, 'Set "The CC field changes" for CCed role');
-$sel->click_ok("email-1-10", undef, 'Set "A new bug is created" for QA Contact role');
-$sel->click_ok("email-100-101", undef, 'Set "Email me when someone sets a flag I asked for" global option');
+$sel->click_ok("email-1-10", undef,
+  'Set "A new bug is created" for QA Contact role');
+$sel->click_ok("email-100-101", undef,
+  'Set "Email me when someone sets a flag I asked for" global option');
+
 # Restore the old 4.2 behavior for 'Disable All Mail'.
-foreach my $col (0..3) {
-    foreach my $row (50..51) {
-        $sel->click_ok("neg-email-$col-$row");
-    }
+foreach my $col (0 .. 3) {
+  foreach my $row (50 .. 51) {
+    $sel->click_ok("neg-email-$col-$row");
+  }
 }
-$sel->value_is("email-0-1", "on");
-$sel->value_is("email-0-10", "off");
-$sel->value_is("email-0-6", "off");
-$sel->value_is("email-0-5", "on");
-$sel->value_is("email-0-2", "on");
-$sel->value_is("email-0-3", "off");
-$sel->value_is("email-0-4", "off");
-$sel->value_is("email-0-7", "off");
-$sel->value_is("email-0-8", "off");
-$sel->value_is("email-0-9", "off");
-$sel->value_is("email-0-0", "on");
+$sel->value_is("email-0-1",      "on");
+$sel->value_is("email-0-10",     "off");
+$sel->value_is("email-0-6",      "off");
+$sel->value_is("email-0-5",      "on");
+$sel->value_is("email-0-2",      "on");
+$sel->value_is("email-0-3",      "off");
+$sel->value_is("email-0-4",      "off");
+$sel->value_is("email-0-7",      "off");
+$sel->value_is("email-0-8",      "off");
+$sel->value_is("email-0-9",      "off");
+$sel->value_is("email-0-0",      "on");
 $sel->value_is("neg-email-0-50", "off");
 $sel->value_is("neg-email-0-51", "off");
-$sel->value_is("email-1-1", "off");
-$sel->value_is("email-1-10", "on");
-$sel->value_is("email-1-6", "off");
-$sel->value_is("email-1-5", "off");
-$sel->value_is("email-1-2", "off");
-$sel->value_is("email-1-3", "off");
-$sel->value_is("email-1-4", "off");
-$sel->value_is("email-1-7", "off");
-$sel->value_is("email-1-8", "off");
-$sel->value_is("email-1-9", "off");
-$sel->value_is("email-1-0", "off");
+$sel->value_is("email-1-1",      "off");
+$sel->value_is("email-1-10",     "on");
+$sel->value_is("email-1-6",      "off");
+$sel->value_is("email-1-5",      "off");
+$sel->value_is("email-1-2",      "off");
+$sel->value_is("email-1-3",      "off");
+$sel->value_is("email-1-4",      "off");
+$sel->value_is("email-1-7",      "off");
+$sel->value_is("email-1-8",      "off");
+$sel->value_is("email-1-9",      "off");
+$sel->value_is("email-1-0",      "off");
 $sel->value_is("neg-email-1-50", "off");
 $sel->value_is("neg-email-1-51", "off");
-ok(!$sel->is_editable("email-2-1"), 'The "I\'m added to or removed from this capacity" for Reporter role is disabled');
-$sel->value_is("email-2-10", "off");
-$sel->value_is("email-2-6", "off");
-$sel->value_is("email-2-5", "off");
-$sel->value_is("email-2-2", "off");
-$sel->value_is("email-2-3", "off");
-$sel->value_is("email-2-4", "off");
-$sel->value_is("email-2-7", "off");
-$sel->value_is("email-2-8", "off");
-$sel->value_is("email-2-9", "off");
-$sel->value_is("email-2-0", "off");
+ok(!$sel->is_editable("email-2-1"),
+  'The "I\'m added to or removed from this capacity" for Reporter role is disabled'
+);
+$sel->value_is("email-2-10",     "off");
+$sel->value_is("email-2-6",      "off");
+$sel->value_is("email-2-5",      "off");
+$sel->value_is("email-2-2",      "off");
+$sel->value_is("email-2-3",      "off");
+$sel->value_is("email-2-4",      "off");
+$sel->value_is("email-2-7",      "off");
+$sel->value_is("email-2-8",      "off");
+$sel->value_is("email-2-9",      "off");
+$sel->value_is("email-2-0",      "off");
 $sel->value_is("neg-email-2-50", "off");
 $sel->value_is("neg-email-2-51", "off");
-$sel->value_is("email-3-1", "off");
-$sel->value_is("email-3-10", "off");
-$sel->value_is("email-3-6", "off");
-$sel->value_is("email-3-5", "off");
-$sel->value_is("email-3-2", "off");
-$sel->value_is("email-3-3", "off");
-$sel->value_is("email-3-4", "off");
-$sel->value_is("email-3-7", "off");
-$sel->value_is("email-3-8", "on");
-$sel->value_is("email-3-9", "off");
-$sel->value_is("email-3-0", "off");
+$sel->value_is("email-3-1",      "off");
+$sel->value_is("email-3-10",     "off");
+$sel->value_is("email-3-6",      "off");
+$sel->value_is("email-3-5",      "off");
+$sel->value_is("email-3-2",      "off");
+$sel->value_is("email-3-3",      "off");
+$sel->value_is("email-3-4",      "off");
+$sel->value_is("email-3-7",      "off");
+$sel->value_is("email-3-8",      "on");
+$sel->value_is("email-3-9",      "off");
+$sel->value_is("email-3-0",      "off");
 $sel->value_is("neg-email-3-50", "off");
 $sel->value_is("neg-email-3-51", "off");
-$sel->value_is("email-100-100", "off");
-$sel->value_is("email-100-101", "on");
+$sel->value_is("email-100-100",  "off");
+$sel->value_is("email-100-101",  "on");
 $sel->click_ok("update", undef, "Submit modified admin email preferences");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
-$sel->is_text_present_ok("The changes to your email preferences have been saved.");
+$sel->is_text_present_ok(
+  "The changes to your email preferences have been saved.");
 
 # Set "After changing a bug" default preference to "Show the updated bug"
 # This simplifies bug changes below
@@ -148,95 +158,120 @@ log_in($sel, $config, 'editbugs');
 $sel->open_ok("$config->{bugzilla_installation}/userprefs.cgi?tab=email");
 $sel->is_text_present_ok("Email Preferences");
 $sel->click_ok("//input[\@value='Enable All Bugmail']");
-$sel->click_ok("email-3-1", undef, 'Clear "I\'m added to or removed from this capacity" for CCed role');
-$sel->click_ok("email-3-5", undef, 'Clear "The priority, status, severity, or milestone changes" for CCed role');
-$sel->click_ok("email-2-2", undef, 'Clear "New comments are added" for Reporter role');
-$sel->click_ok("email-3-2", undef, 'Clear "New comments are added" for CCed role');
-$sel->click_ok("email-2-8", undef, 'Clear "The CC field changes" for Reporter role');
-$sel->click_ok("email-3-8", undef, 'Clear "The CC field changes" for CCed role');
-$sel->click_ok("email-2-0", undef, 'Clear "Any field not mentioned above changes" for Reporter role');
-$sel->click_ok("email-3-0", undef, 'Clear "Any field not mentioned above changes" for CCed role');
-$sel->click_ok("neg-email-0-51", undef, 'Set "Change was made by me" override for Assignee role');
-$sel->click_ok("email-100-101", undef, 'Clear "Email me when someone sets a flag I asked for" global option');
-$sel->value_is("email-0-1", "on");
-$sel->value_is("email-0-10", "on");
-$sel->value_is("email-0-6", "on");
-$sel->value_is("email-0-5", "on");
-$sel->value_is("email-0-2", "on");
-$sel->value_is("email-0-3", "on");
-$sel->value_is("email-0-4", "on");
-$sel->value_is("email-0-7", "on");
-$sel->value_is("email-0-8", "on");
-$sel->value_is("email-0-9", "on");
-$sel->value_is("email-0-0", "on");
+$sel->click_ok("email-3-1", undef,
+  'Clear "I\'m added to or removed from this capacity" for CCed role');
+$sel->click_ok("email-3-5", undef,
+  'Clear "The priority, status, severity, or milestone changes" for CCed role');
+$sel->click_ok("email-2-2", undef,
+  'Clear "New comments are added" for Reporter role');
+$sel->click_ok("email-3-2", undef,
+  'Clear "New comments are added" for CCed role');
+$sel->click_ok("email-2-8", undef,
+  'Clear "The CC field changes" for Reporter role');
+$sel->click_ok("email-3-8", undef,
+  'Clear "The CC field changes" for CCed role');
+$sel->click_ok("email-2-0", undef,
+  'Clear "Any field not mentioned above changes" for Reporter role');
+$sel->click_ok("email-3-0", undef,
+  'Clear "Any field not mentioned above changes" for CCed role');
+$sel->click_ok("neg-email-0-51", undef,
+  'Set "Change was made by me" override for Assignee role');
+$sel->click_ok("email-100-101", undef,
+  'Clear "Email me when someone sets a flag I asked for" global option');
+$sel->value_is("email-0-1",      "on");
+$sel->value_is("email-0-10",     "on");
+$sel->value_is("email-0-6",      "on");
+$sel->value_is("email-0-5",      "on");
+$sel->value_is("email-0-2",      "on");
+$sel->value_is("email-0-3",      "on");
+$sel->value_is("email-0-4",      "on");
+$sel->value_is("email-0-7",      "on");
+$sel->value_is("email-0-8",      "on");
+$sel->value_is("email-0-9",      "on");
+$sel->value_is("email-0-0",      "on");
 $sel->value_is("neg-email-0-50", "off");
 $sel->value_is("neg-email-0-51", "on");
-$sel->value_is("email-1-1", "on");
-$sel->value_is("email-1-10", "on");
-$sel->value_is("email-1-6", "on");
-$sel->value_is("email-1-5", "on");
-$sel->value_is("email-1-2", "on");
-$sel->value_is("email-1-3", "on");
-$sel->value_is("email-1-4", "on");
-$sel->value_is("email-1-7", "on");
-$sel->value_is("email-1-8", "on");
-$sel->value_is("email-1-9", "on");
-$sel->value_is("email-1-0", "on");
+$sel->value_is("email-1-1",      "on");
+$sel->value_is("email-1-10",     "on");
+$sel->value_is("email-1-6",      "on");
+$sel->value_is("email-1-5",      "on");
+$sel->value_is("email-1-2",      "on");
+$sel->value_is("email-1-3",      "on");
+$sel->value_is("email-1-4",      "on");
+$sel->value_is("email-1-7",      "on");
+$sel->value_is("email-1-8",      "on");
+$sel->value_is("email-1-9",      "on");
+$sel->value_is("email-1-0",      "on");
 $sel->value_is("neg-email-1-50", "off");
 $sel->value_is("neg-email-1-51", "off");
-ok(!$sel->is_editable("email-2-1"), 'The "I\'m added to or removed from this capacity" for Reporter role is disabled');
-$sel->value_is("email-2-10", "on");
-$sel->value_is("email-2-6", "on");
-$sel->value_is("email-2-5", "on");
-$sel->value_is("email-2-2", "off");
-$sel->value_is("email-2-3", "on");
-$sel->value_is("email-2-4", "on");
-$sel->value_is("email-2-7", "on");
-$sel->value_is("email-2-8", "off");
-$sel->value_is("email-2-9", "on");
-$sel->value_is("email-2-0", "off");
+ok(!$sel->is_editable("email-2-1"),
+  'The "I\'m added to or removed from this capacity" for Reporter role is disabled'
+);
+$sel->value_is("email-2-10",     "on");
+$sel->value_is("email-2-6",      "on");
+$sel->value_is("email-2-5",      "on");
+$sel->value_is("email-2-2",      "off");
+$sel->value_is("email-2-3",      "on");
+$sel->value_is("email-2-4",      "on");
+$sel->value_is("email-2-7",      "on");
+$sel->value_is("email-2-8",      "off");
+$sel->value_is("email-2-9",      "on");
+$sel->value_is("email-2-0",      "off");
 $sel->value_is("neg-email-2-50", "off");
 $sel->value_is("neg-email-2-51", "off");
-$sel->value_is("email-3-1", "off");
-$sel->value_is("email-3-10", "on");
-$sel->value_is("email-3-6", "on");
-$sel->value_is("email-3-5", "off");
-$sel->value_is("email-3-2", "off");
-$sel->value_is("email-3-3", "on");
-$sel->value_is("email-3-4", "on");
-$sel->value_is("email-3-7", "on");
-$sel->value_is("email-3-8", "off");
-$sel->value_is("email-3-9", "on");
-$sel->value_is("email-3-0", "off");
+$sel->value_is("email-3-1",      "off");
+$sel->value_is("email-3-10",     "on");
+$sel->value_is("email-3-6",      "on");
+$sel->value_is("email-3-5",      "off");
+$sel->value_is("email-3-2",      "off");
+$sel->value_is("email-3-3",      "on");
+$sel->value_is("email-3-4",      "on");
+$sel->value_is("email-3-7",      "on");
+$sel->value_is("email-3-8",      "off");
+$sel->value_is("email-3-9",      "on");
+$sel->value_is("email-3-0",      "off");
 $sel->value_is("neg-email-3-50", "off");
 $sel->value_is("neg-email-3-51", "off");
-$sel->value_is("email-100-100", "on");
-$sel->value_is("email-100-101", "off");
-$sel->click_ok("update", undef, "Submit modified normal user email preferences");
+$sel->value_is("email-100-100",  "on");
+$sel->value_is("email-100-101",  "off");
+$sel->click_ok("update", undef,
+  "Submit modified normal user email preferences");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
-$sel->is_text_present_ok("The changes to your email preferences have been saved.");
+$sel->is_text_present_ok(
+  "The changes to your email preferences have been saved.");
 
 # Always show email recipients
-ok($sel->create_cookie('show_bugmail_recipients=1'), 'Always show recipient list');
+ok($sel->create_cookie('show_bugmail_recipients=1'),
+  'Always show recipient list');
 
 # Create a test bug (bugmail to both normal user and admin)
 file_bug_in_product($sel, "Another Product");
 $sel->select_ok("component", "label=c1");
-$sel->type_ok("short_desc", "Selenium Email Preference test bug", "Enter bug summary");
-$sel->type_ok("comment", "Created by Selenium to test Email Preferences", "Enter bug description");
+$sel->type_ok(
+  "short_desc",
+  "Selenium Email Preference test bug",
+  "Enter bug summary"
+);
+$sel->type_ok(
+  "comment",
+  "Created by Selenium to test Email Preferences",
+  "Enter bug description"
+);
 $sel->type_ok("assigned_to", $config->{editbugs_user_login});
-$sel->type_ok("qa_contact", $config->{admin_user_login});
-$sel->type_ok("cc", $config->{admin_user_login});
+$sel->type_ok("qa_contact",  $config->{admin_user_login});
+$sel->type_ok("cc",          $config->{admin_user_login});
 $sel->click_ok("commit");
 $sel->wait_for_page_to_load(WAIT_TIME);
 my $bug1_id = $sel->get_value("//input[\@name='id' and \@type='hidden']");
-$sel->is_text_present_ok('has been added to the database', "Bug $bug1_id created");
+$sel->is_text_present_ok('has been added to the database',
+  "Bug $bug1_id created");
 my @email_sentto = get_email_sentto($sel);
 is_deeply(\@email_sentto, \@email_both, "Admin and normal user got bugmail");
 
 # Make normal user changes (first pass)
 #
 go_to_bug($sel, $bug1_id);
+
 # Severity change (bugmail to normal user but not admin)
 $sel->select_ok("bug_severity", "label=blocker");
 $sel->selected_label_is("bug_severity", "blocker");
@@ -245,14 +280,20 @@ $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->is_text_present_ok("Changes submitted for bug $bug1_id");
 @email_sentto = get_email_sentto($sel);
 is_deeply(\@email_sentto, \@email_normal, "Normal user got bugmail");
+
 # Add a comment (bugmail to no one)
-$sel->type_ok("comment", "This is a Selenium generated normal user test comment 1 of 2. (No bugmail should be generated for this.)");
-$sel->value_is("comment", "This is a Selenium generated normal user test comment 1 of 2. (No bugmail should be generated for this.)");
+$sel->type_ok("comment",
+  "This is a Selenium generated normal user test comment 1 of 2. (No bugmail should be generated for this.)"
+);
+$sel->value_is("comment",
+  "This is a Selenium generated normal user test comment 1 of 2. (No bugmail should be generated for this.)"
+);
 $sel->click_ok("commit");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->is_text_present_ok("Changes submitted for bug $bug1_id");
 @email_sentto = get_email_sentto($sel);
 ok($email_sentto[0] eq "no one", "No bugmail sent");
+
 # Add normal user to CC list (bugmail to admin but not normal user)
 $sel->type_ok("newcc", $config->{editbugs_user_login});
 $sel->value_is("newcc", $config->{editbugs_user_login});
@@ -261,6 +302,7 @@ $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->is_text_present_ok("Changes submitted for bug $bug1_id");
 @email_sentto = get_email_sentto($sel);
 is_deeply(\@email_sentto, \@email_admin, "Admin got bugmail");
+
 # Request a flag from admin (bugmail to no one, request mail to no one)
 $sel->select_ok("flag_type-4", "label=?");
 $sel->type_ok("requestee_type-4", $config->{admin_user_login});
@@ -276,6 +318,7 @@ ok($email_sentto[0] eq "no one", "No bugmail sent");
 logout($sel);
 log_in($sel, $config, 'admin');
 go_to_bug($sel, $bug1_id);
+
 # Severity change (bugmail to normal user but not admin)
 $sel->select_ok("bug_severity", "label=trivial");
 $sel->selected_label_is("bug_severity", "trivial");
@@ -284,14 +327,20 @@ $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->is_text_present_ok("Changes submitted for bug $bug1_id");
 @email_sentto = get_email_sentto($sel);
 is_deeply(\@email_sentto, \@email_normal, "Normal user got bugmail");
+
 # Add a comment (bugmail to normal user but not admin)
-$sel->type_ok("comment", "This is a Selenium generated admin user test comment. (Only normal user should get bugmail for this.)");
-$sel->value_is("comment", "This is a Selenium generated admin user test comment. (Only normal user should get bugmail for this.)");
+$sel->type_ok("comment",
+  "This is a Selenium generated admin user test comment. (Only normal user should get bugmail for this.)"
+);
+$sel->value_is("comment",
+  "This is a Selenium generated admin user test comment. (Only normal user should get bugmail for this.)"
+);
 $sel->click_ok("commit");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->is_text_present_ok("Changes submitted for bug $bug1_id");
 @email_sentto = get_email_sentto($sel);
 is_deeply(\@email_sentto, \@email_normal, "Normal user got bugmail");
+
 # Remove normal user from CC list (bugmail to both normal user and admin)
 $sel->click_ok("removecc");
 $sel->add_selection_ok("cc", "label=$config->{editbugs_user_login}");
@@ -302,6 +351,7 @@ $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->is_text_present_ok("Changes submitted for bug $bug1_id");
 @email_sentto = get_email_sentto($sel);
 is_deeply(\@email_sentto, \@email_both, "Admin and normal user got bugmail");
+
 # Reassign bug to admin user (bugmail to both normal user and admin)
 $sel->type_ok("assigned_to", $config->{admin_user_login});
 $sel->value_is("assigned_to", $config->{admin_user_login});
@@ -310,6 +360,7 @@ $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->is_text_present_ok("Changes submitted for bug $bug1_id");
 @email_sentto = get_email_sentto($sel);
 is_deeply(\@email_sentto, \@email_both, "Admin and normal user got bugmail");
+
 # Request a flag from normal user (bugmail to admin but not normal user and request mail to admin)
 $sel->select_ok("flag_type-4", "label=?");
 $sel->type_ok("requestee_type-4", $config->{editbugs_user_login});
@@ -318,6 +369,7 @@ $sel->click_ok("commit");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 @email_sentto = get_email_sentto($sel);
 is_deeply(\@email_sentto, \@email_admin, "Admin got bugmail");
+
 # Grant a normal user flag request (bugmail to admin but not normal user and request mail to no one)
 my $flag1_id = set_flag($sel, $config->{admin_user_login}, "?", "+");
 $sel->click_ok("commit");
@@ -330,6 +382,7 @@ is_deeply(\@email_sentto, \@email_admin, "Admin got bugmail");
 logout($sel);
 log_in($sel, $config, 'editbugs');
 go_to_bug($sel, $bug1_id);
+
 # Severity change (bugmail to both admin and normal user)
 $sel->select_ok("bug_severity", "label=normal");
 $sel->selected_label_is("bug_severity", "normal");
@@ -338,14 +391,20 @@ $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->is_text_present_ok("Changes submitted for bug $bug1_id");
 @email_sentto = get_email_sentto($sel);
 is_deeply(\@email_sentto, \@email_both, "Admin and normal user got bugmail");
+
 # Add a comment (bugmail to admin but not normal user)
-$sel->type_ok("comment", "This is a Selenium generated normal user test comment 2 of 2. (Only admin should get bugmail for this.)");
-$sel->value_is("comment", "This is a Selenium generated normal user test comment 2 of 2. (Only admin should get bugmail for this.)");
+$sel->type_ok("comment",
+  "This is a Selenium generated normal user test comment 2 of 2. (Only admin should get bugmail for this.)"
+);
+$sel->value_is("comment",
+  "This is a Selenium generated normal user test comment 2 of 2. (Only admin should get bugmail for this.)"
+);
 $sel->click_ok("commit");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->is_text_present_ok("Changes submitted for bug $bug1_id");
 @email_sentto = get_email_sentto($sel);
 is_deeply(\@email_sentto, \@email_admin, "Admin got bugmail");
+
 # Reassign to normal user (bugmail to admin but not normal user)
 $sel->type_ok("assigned_to", $config->{editbugs_user_login});
 $sel->value_is("assigned_to", $config->{editbugs_user_login});
@@ -353,12 +412,14 @@ $sel->click_ok("commit");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 @email_sentto = get_email_sentto($sel);
 is_deeply(\@email_sentto, \@email_admin, "Admin got bugmail");
+
 # Deny a flag requested by admin (bugmail to no one and request mail to admin)
 my $flag2_id = set_flag($sel, $config->{editbugs_user_login}, "?", "-");
 $sel->click_ok("commit");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 @email_sentto = get_email_sentto($sel);
 ok($email_sentto[0] eq "no one", "No bugmail sent");
+
 # Cancel both flags (bugmail and request mail to no one)
 set_flag($sel, undef, "+", "X", $flag1_id);
 set_flag($sel, undef, "-", "X", $flag2_id);
@@ -370,31 +431,41 @@ logout($sel);
 
 # Help functions
 sub get_email_sentto {
-    my ($sel) = @_;
-    my @email_sentto;
-    my $index = 1;
-    while ($sel->is_element_present("//dt[text()='Email sent to:']/following-sibling::dd/code[$index]")) {
-        push(@email_sentto,
-             $sel->get_text("//dt[text()='Email sent to:']/following-sibling::dd/code[$index]"));
-        $index++;
-    }
-    return ("no one") if !@email_sentto;
-    return sort @email_sentto;
+  my ($sel) = @_;
+  my @email_sentto;
+  my $index = 1;
+  while ($sel->is_element_present(
+    "//dt[text()='Email sent to:']/following-sibling::dd/code[$index]"))
+  {
+    push(
+      @email_sentto,
+      $sel->get_text(
+        "//dt[text()='Email sent to:']/following-sibling::dd/code[$index]")
+    );
+    $index++;
+  }
+  return ("no one") if !@email_sentto;
+  return sort @email_sentto;
 }
 
 sub set_flag {
-    my ($sel, $login, $curval, $newval, $prev_id) = @_;
+  my ($sel, $login, $curval, $newval, $prev_id) = @_;
 
-    # Retrieve flag id for the flag to be set
-    my $flag_id = $prev_id;
-    if (defined $login) {
-        my $flag_name = $sel->get_attribute("//table[\@id='flags']//input[\@value='$login']\@name");
-        $flag_name =~ /^requestee-(\d+)$/;
-        $flag_id = $1;
-    }
+  # Retrieve flag id for the flag to be set
+  my $flag_id = $prev_id;
+  if (defined $login) {
+    my $flag_name
+      = $sel->get_attribute("//table[\@id='flags']//input[\@value='$login']\@name");
+    $flag_name =~ /^requestee-(\d+)$/;
+    $flag_id = $1;
+  }
 
-    # Set new value for the flag (verifies current value)
-    $sel->select_ok("//select[\@id=\"flag-$flag_id\"]/option[\@value=\"$curval\" and \@selected]/..", "value=$newval", "Set flag ID $flag_id to $newval from $curval");
+  # Set new value for the flag (verifies current value)
+  $sel->select_ok(
+    "//select[\@id=\"flag-$flag_id\"]/option[\@value=\"$curval\" and \@selected]/..",
+    "value=$newval",
+    "Set flag ID $flag_id to $newval from $curval"
+  );
 
-   return $flag_id;
+  return $flag_id;
 }
index 01ee6af65977b6b88645f9a79538605360a902df..b4185d000dac5d6946a088f65307ed051b8ecff9 100644 (file)
@@ -17,7 +17,7 @@ use lib qw(lib ../../lib ../../local/lib/perl5);
 use Test::More tests => 11;
 use QA::REST;
 
-my $rest = get_rest_client();
+my $rest   = get_rest_client();
 my $config = $rest->bz_config;
 
 my $version = $rest->call('version')->{version};
@@ -26,31 +26,42 @@ ok($version, "GET /rest/version returns $version");
 my $extensions = $rest->call('extensions')->{extensions};
 isa_ok($extensions, 'HASH', 'GET /rest/extensions');
 my @ext_names = sort keys %$extensions;
+
 # There is always at least the QA extension enabled.
-ok(scalar(@ext_names), scalar(@ext_names) . ' extension(s) found: ' . join(', ', @ext_names));
-ok($extensions->{QA}, 'The QA extension is enabled, with version ' . $extensions->{QA}->{version});
+ok(scalar(@ext_names),
+  scalar(@ext_names) . ' extension(s) found: ' . join(', ', @ext_names));
+ok($extensions->{QA},
+  'The QA extension is enabled, with version ' . $extensions->{QA}->{version});
 
 my $timezone = $rest->call('timezone')->{timezone};
 ok($timezone, "GET /rest/timezone retuns $timezone");
 
 my $time = $rest->call('time');
 foreach my $type (qw(db_time web_time)) {
-    ok($time->{$type}, "GET /rest/time returns $type = " . $time->{$type});
+  ok($time->{$type}, "GET /rest/time returns $type = " . $time->{$type});
 }
 
 # Logged-out users can only access the maintainer and requirelogin parameters.
-my $params = $rest->call('parameters')->{parameters};
+my $params      = $rest->call('parameters')->{parameters};
 my @param_names = sort keys %$params;
-ok(@param_names == 2 && defined $params->{maintainer} && defined $params->{requirelogin},
-   'Only 2 parameters accessible to logged-out users: ' . join(', ', @param_names));
+ok(
+  @param_names == 2
+    && defined $params->{maintainer}
+    && defined $params->{requirelogin},
+  'Only 2 parameters accessible to logged-out users: ' . join(', ', @param_names)
+);
 
 # Powerless users can access much more parameters.
-$params = $rest->call('parameters', { api_key => $config->{unprivileged_user_api_key} })->{parameters};
+$params
+  = $rest->call('parameters', {api_key => $config->{unprivileged_user_api_key}})
+  ->{parameters};
 @param_names = sort keys %$params;
-ok(@param_names > 2, scalar(@param_names) . ' parameters accessible to powerless users');
+ok(@param_names > 2,
+  scalar(@param_names) . ' parameters accessible to powerless users');
 
 # Admins can access all parameters.
-$params = $rest->call('parameters', { api_key => $config->{admin_user_api_key} })->{parameters};
+$params = $rest->call('parameters', {api_key => $config->{admin_user_api_key}})
+  ->{parameters};
 @param_names = sort keys %$params;
 ok(@param_names > 2, scalar(@param_names) . ' parameters accessible to admins');
 
index f5485de2bf07ab44dec15475ae64f1d0f8b89844..e1083e98a600a1173d943703a6cb253fb4a71d17 100644 (file)
@@ -17,43 +17,67 @@ use lib qw(lib ../../lib ../../local/lib/perl5);
 use Test::More tests => 7;
 use QA::REST;
 
-my $rest = get_rest_client();
+my $rest   = get_rest_client();
 my $config = $rest->bz_config;
-my $args = { api_key => $config->{admin_user_api_key} };
+my $args   = {api_key => $config->{admin_user_api_key}};
 
 my $params = $rest->call('parameters', $args)->{parameters};
 my $use_class = $params->{useclassification};
-ok(defined($use_class), 'Classifications are ' . ($use_class ? 'enabled' : 'disabled'));
+ok(defined($use_class),
+  'Classifications are ' . ($use_class ? 'enabled' : 'disabled'));
 
 # Admins can always access classifications, even when they are disabled.
 my $class = $rest->call('classification/1', $args)->{classifications}->[0];
-ok($class->{id}, "Admin found classification '" . $class->{name} . "' with the description '" . $class->{description} . "'");
-my @products = sort map { $_->{name} } @{ $class->{products} };
-ok(scalar(@products), scalar(@products) . ' product(s) found: ' . join(', ', @products));
+ok($class->{id},
+      "Admin found classification '"
+    . $class->{name}
+    . "' with the description '"
+    . $class->{description}
+    . "'");
+my @products = sort map { $_->{name} } @{$class->{products}};
+ok(scalar(@products),
+  scalar(@products) . ' product(s) found: ' . join(', ', @products));
 
 $class = $rest->call('classification/Class2_QA', $args)->{classifications}->[0];
-ok($class->{id}, "Admin found classification '" . $class->{name} . "' with the description '" . $class->{description} . "'");
-@products = sort map { $_->{name} } @{ $class->{products} };
-ok(scalar(@products), scalar(@products) . ' product(s) found: ' . join(', ', @products));
+ok($class->{id},
+      "Admin found classification '"
+    . $class->{name}
+    . "' with the description '"
+    . $class->{description}
+    . "'");
+@products = sort map { $_->{name} } @{$class->{products}};
+ok(scalar(@products),
+  scalar(@products) . ' product(s) found: ' . join(', ', @products));
 
 if ($use_class) {
-    # When classifications are enabled, everybody can query classifications...
-    # ... including logged-out users.
-    $class = $rest->call('classification/1')->{classifications}->[0];
-    ok($class->{id}, 'Logged-out users can access classification ' . $class->{name});
-    # ... and non-admins.
-    $class = $rest->call('classification/1', { api_key => $config->{editbugs_user_api_key} })->{classifications}->[0];
-    ok($class->{id}, 'Non-admins can access classification ' . $class->{name});
+
+  # When classifications are enabled, everybody can query classifications...
+  # ... including logged-out users.
+  $class = $rest->call('classification/1')->{classifications}->[0];
+  ok($class->{id},
+    'Logged-out users can access classification ' . $class->{name});
+
+  # ... and non-admins.
+  $class = $rest->call('classification/1',
+    {api_key => $config->{editbugs_user_api_key}})->{classifications}->[0];
+  ok($class->{id}, 'Non-admins can access classification ' . $class->{name});
 }
 else {
-    # When classifications are disabled, only users in the 'editclassifications'
-    # group can access this method...
-    # ... logged-out users get an error.
-    my $error = $rest->call('classification/1', undef, undef, MUST_FAIL);
-    ok($error->{error} && $error->{code} == 900,
-       'Logged-out users cannot query classifications when disabled: ' . $error->{message});
-    # ... as well as non-admins.
-    $error = $rest->call('classification/1', { api_key => $config->{editbugs_user_api_key} }, undef, MUST_FAIL);
-    ok($error->{error} && $error->{code} == 900,
-       'Non-admins cannot query classifications when disabled: ' . $error->{message});
+  # When classifications are disabled, only users in the 'editclassifications'
+  # group can access this method...
+  # ... logged-out users get an error.
+  my $error = $rest->call('classification/1', undef, undef, MUST_FAIL);
+  ok(
+    $error->{error} && $error->{code} == 900,
+    'Logged-out users cannot query classifications when disabled: '
+      . $error->{message}
+  );
+
+  # ... as well as non-admins.
+  $error
+    = $rest->call('classification/1',
+    {api_key => $config->{editbugs_user_api_key}},
+    undef, MUST_FAIL);
+  ok($error->{error} && $error->{code} == 900,
+    'Non-admins cannot query classifications when disabled: ' . $error->{message});
 }
index c08db293c59d7c540a2018ac5d98314d84935d2e..e70216433d23b0b510aa1c6f0a5ab913d7d85663 100644 (file)
@@ -9,9 +9,11 @@ use strict;
 use warnings;
 
 use constant DISPLAY => 99;
+
 #use constant DISPLAY => 0;
 
 use Test::More tests => 12;
+
 #use Test::More tests => 4;
 
 my $pid;
@@ -21,63 +23,63 @@ $pid = xserver_start();
 ok($pid, "X Server started with PID $pid on display " . DISPLAY);
 ok(open(XPID, ">testing.x.pid"), "Opening testing.x.pid");
 ok((print XPID $pid), "Writing testing.x.pid");
-ok(close(XPID),  "Closing testing.x.pid");
+ok(close(XPID),       "Closing testing.x.pid");
 
 # Start the VNC service second
 ok($pid = vnc_start(), "VNC desktop started with PID $pid");
 ok(open(VNCPID, ">testing.vnc.pid"), "Opening testing.vnc.pid");
 ok((print VNCPID $pid), "Writing testing.vnc.pid");
-ok(close(VNCPID),  "Closing testing.vnc.pid");
+ok(close(VNCPID),       "Closing testing.vnc.pid");
 
 # Start the selenium server third
 ok($pid = selenium_start(), "Selenium RC server started with PID $pid");
 ok(open(SPID, ">testing.selenium.pid"), "Opening testing.selenium.pid");
 ok((print SPID $pid), "Writing testing.selenium.pid");
-ok(close(SPID),  "Closing testing.selenium.pid");
+ok(close(SPID),       "Closing testing.selenium.pid");
 
 sleep(10);
 
 # Subroutines
 
 sub xserver_start {
-    my $pid;
-    my @x_cmd = qw(Xvfb -ac -screen 0 1600x1200x24 -fbdir /tmp);
-    push(@x_cmd, ":" . DISPLAY);
-    $pid = fork();
-    if (!$pid) {
-        open(STDOUT, ">/dev/null");
-        open(STDERR, ">/dev/null");
-        exec(@x_cmd) || die "unable to execute: $!";
-    }
-    else {
-        return $pid;
-    }
-    return 0;
+  my $pid;
+  my @x_cmd = qw(Xvfb -ac -screen 0 1600x1200x24 -fbdir /tmp);
+  push(@x_cmd, ":" . DISPLAY);
+  $pid = fork();
+  if (!$pid) {
+    open(STDOUT, ">/dev/null");
+    open(STDERR, ">/dev/null");
+    exec(@x_cmd) || die "unable to execute: $!";
+  }
+  else {
+    return $pid;
+  }
+  return 0;
 }
 
 sub vnc_start {
-    my @vnc_cmd = qw(x11vnc -viewonly -forever -nopw -quiet -display);
-    push(@vnc_cmd, ":" . DISPLAY);
-    my $pid = fork();
-    if (!$pid) {
-        open(STDOUT, ">/dev/null");
-        open(STDERR, ">/dev/null");
-        exec(@vnc_cmd) || die "unabled to execute: $!";
-    }
-    return $pid;
+  my @vnc_cmd = qw(x11vnc -viewonly -forever -nopw -quiet -display);
+  push(@vnc_cmd, ":" . DISPLAY);
+  my $pid = fork();
+  if (!$pid) {
+    open(STDOUT, ">/dev/null");
+    open(STDERR, ">/dev/null");
+    exec(@vnc_cmd) || die "unabled to execute: $!";
+  }
+  return $pid;
 }
 
 sub selenium_start {
-    my @selenium_cmd = qw(java -jar ../config/selenium-server-standalone.jar
-                               -firefoxProfileTemplate ../config/firefox
-                               -log ../config/selenium.log
-                               -singlewindow);
-    unshift(@selenium_cmd, "env", "DISPLAY=:" . DISPLAY);
-    my $pid = fork();
-    if (!$pid) {
-        open(STDOUT, ">/dev/null");
-        open(STDERR, ">/dev/null");
-        exec(@selenium_cmd) || die "unable to execute: $!";
-    }
-    return $pid;
+  my @selenium_cmd = qw(java -jar ../config/selenium-server-standalone.jar
+    -firefoxProfileTemplate ../config/firefox
+    -log ../config/selenium.log
+    -singlewindow);
+  unshift(@selenium_cmd, "env", "DISPLAY=:" . DISPLAY);
+  my $pid = fork();
+  if (!$pid) {
+    open(STDOUT, ">/dev/null");
+    open(STDERR, ">/dev/null");
+    exec(@selenium_cmd) || die "unable to execute: $!";
+  }
+  return $pid;
 }
index 62a29f38c33d0ac397d4595ac6a2867144f70b1d..7633e57d78fb1292e1445110d80f57ccad5b98eb 100644 (file)
@@ -29,6 +29,6 @@ ok(unlink("testing.vnc.pid"), "Removing testing.vnc.pid");
 # Stop the Xvfb server third
 ok(open(XPID, "<testing.x.pid"), "Opening testing.x.pid");
 ok(($pid = <XPID>), "Reading testing.x.pid");
-ok(close(XPID),  "Closing testing.x.pid");
+ok(close(XPID), "Closing testing.x.pid");
 ok(kill(9, $pid), "Killing process $pid");
 ok(unlink("testing.x.pid"), "Removing testing.x.pid");
index af61f09a4184295d02708386a8ee5979c27798dd..a8bce05cdc2fa7f0fc279169d968aa5f6081cff3 100644 (file)
@@ -19,7 +19,7 @@ log_in($sel, $config, 'unprivileged');
 file_bug_in_product($sel, 'TestProduct');
 my $bug_summary = "linkification test bug";
 $sel->type_ok("short_desc", $bug_summary);
-$sel->type_ok("comment", "linkification test");
+$sel->type_ok("comment",    "linkification test");
 $sel->click_ok("commit");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_like(qr/\d+ \S $bug_summary/, "Bug created");
@@ -31,7 +31,9 @@ $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_like(qr/\d+ \S $bug_summary/, "crash report added");
 $sel->click_ok("link=bug $bug_id");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
-$sel->attribute_is('link=bp-63f096f7-253b-4ee2-ae3d-8bb782090824@href', 'https://crash-stats.mozilla.com/report/index/63f096f7-253b-4ee2-ae3d-8bb782090824');
+$sel->attribute_is('link=bp-63f096f7-253b-4ee2-ae3d-8bb782090824@href',
+  'https://crash-stats.mozilla.com/report/index/63f096f7-253b-4ee2-ae3d-8bb782090824'
+);
 
 $sel->type_ok("comment", "CVE-2010-2884");
 $sel->click_ok("commit");
@@ -39,7 +41,8 @@ $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_like(qr/\d+ \S $bug_summary/, "cve added");
 $sel->click_ok("link=bug $bug_id");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
-$sel->attribute_is('link=CVE-2010-2884@href', 'https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2010-2884');
+$sel->attribute_is('link=CVE-2010-2884@href',
+  'https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2010-2884');
 
 $sel->type_ok("comment", "r12345");
 $sel->click_ok("commit");
@@ -47,7 +50,8 @@ $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_like(qr/\d+ \S $bug_summary/, "svn revision added");
 $sel->click_ok("link=bug $bug_id");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
-$sel->attribute_is('link=r12345@href', 'https://viewvc.svn.mozilla.org/vc?view=rev&revision=12345');
+$sel->attribute_is('link=r12345@href',
+  'https://viewvc.svn.mozilla.org/vc?view=rev&revision=12345');
 
 logout($sel);
 
index 021e25f0629a6168fa41de5fd562447811de88dd..b499a7fc9f924dfb5348c2fe0dbc3dc6a45ecfed 100644 (file)
@@ -23,7 +23,7 @@ use QA::Util;
 my ($sel, $config) = get_selenium();
 
 log_in($sel, $config, 'admin');
-set_parameters($sel, { "Bug Fields" => {"useclassification-off" => undef} });
+set_parameters($sel, {"Bug Fields" => {"useclassification-off" => undef}});
 
 # mktgevent and swag are dependent so we create the mktgevent bug first so
 # we can provide the bug id to swag
@@ -90,15 +90,23 @@ _check_product('Marketing');
 _check_component('Marketing', 'Trademark Permissions');
 _check_group('marketing-private');
 
-$sel->open_ok("/$config->{bugzilla_installation}/enter_bug.cgi?product=Marketing&format=trademark");
+$sel->open_ok(
+  "/$config->{bugzilla_installation}/enter_bug.cgi?product=Marketing&format=trademark"
+);
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
-$sel->title_is("Trademark Usage Requests", "Open custom bug entry form - trademark");
+$sel->title_is("Trademark Usage Requests",
+  "Open custom bug entry form - trademark");
 $sel->type_ok("short_desc", "Bug created by Selenium", "Enter bug summary");
-$sel->type_ok("comment", "--- Bug created by Selenium ---", "Enter bug description");
+$sel->type_ok(
+  "comment",
+  "--- Bug created by Selenium ---",
+  "Enter bug description"
+);
 $sel->click_ok("commit", undef, "Submit bug data to post_bug.cgi");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->is_text_present_ok('has been added to the database', 'Bug created');
-my $trademark_bug_id = $sel->get_value('//input[@name="id" and @type="hidden"]');
+my $trademark_bug_id
+  = $sel->get_value('//input[@name="id" and @type="hidden"]');
 
 # itrequest
 
@@ -173,14 +181,25 @@ _check_component('mozilla.org', 'Discussion Forums');
 _check_version('mozilla.org', 'other');
 _check_component('mozilla.org', 'Discussion Forums');
 
-$sel->open_ok("/$config->{bugzilla_installation}/enter_bug.cgi?product=mozilla.org&format=mozlist");
+$sel->open_ok(
+  "/$config->{bugzilla_installation}/enter_bug.cgi?product=mozilla.org&format=mozlist"
+);
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
-$sel->title_is("Mozilla Discussion Forum", "Open custom bug entry form - mozlist");
+$sel->title_is("Mozilla Discussion Forum",
+  "Open custom bug entry form - mozlist");
 $sel->type_ok("listName", "test-list", "Enter name for mailing list");
-$sel->type_ok("listAdmin", $config->{'admin_user_login'}, "Enter list administator");
+$sel->type_ok(
+  "listAdmin",
+  $config->{'admin_user_login'},
+  "Enter list administator"
+);
 $sel->type_ok("cc", $config->{'unprivileged_user_login'}, "Enter cc address");
 $sel->check_ok("name=groups", "value=infra", "Select private group");
-$sel->type_ok("comment", "--- Bug created by Selenium ---", "Enter bug description");
+$sel->type_ok(
+  "comment",
+  "--- Bug created by Selenium ---",
+  "Enter bug description"
+);
 $sel->click_ok("commit", undef, "Submit bug data to post_bug.cgi");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->is_text_present_ok('has been added to the database', 'Bug created');
@@ -214,193 +233,216 @@ _check_product('Legal');
 _check_component('Legal', 'Contract Request');
 _check_group('mozilla-employee-confidential');
 
-$sel->open_ok("/$config->{bugzilla_installation}/enter_bug.cgi?product=Legal&format=legal");
+$sel->open_ok(
+  "/$config->{bugzilla_installation}/enter_bug.cgi?product=Legal&format=legal");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
-$sel->title_is("Mozilla Corporation Legal Requests", "Open custom bug entry form - legal");
+$sel->title_is("Mozilla Corporation Legal Requests",
+  "Open custom bug entry form - legal");
 $sel->select_ok("component", "value=Contract Request", "Select request type");
-$sel->select_ok("business_unit", "value=Connected Devices", "Select business unit");
+$sel->select_ok(
+  "business_unit",
+  "value=Connected Devices",
+  "Select business unit"
+);
 $sel->type_ok("short_desc", "Bug created by Selenium", "Enter request summary");
 $sel->type_ok("cc", $config->{'unprivileged_user_login'}, "Enter cc address");
 $sel->type_ok("important_dates", "Important dates", "Enter important dates");
-$sel->type_ok("comment", "--- Bug created by Selenium ---", "Enter request description");
+$sel->type_ok(
+  "comment",
+  "--- Bug created by Selenium ---",
+  "Enter request description"
+);
 $sel->click_ok("commit", undef, "Submit bug data to post_bug.cgi");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->is_text_present_ok('has been added to the database', 'Bug created');
 my $legal_bug_id = $sel->get_value('//input[@name="id" and @type="hidden"]');
 
-set_parameters($sel, { "Bug Fields" => {"useclassification-on" => undef} });
+set_parameters($sel, {"Bug Fields" => {"useclassification-on" => undef}});
 logout($sel);
 
 sub _check_product {
-    my ($product, $version) = @_;
-
-    go_to_admin($sel);
-    $sel->click_ok("link=Products");
-    $sel->wait_for_page_to_load_ok(WAIT_TIME);
-    $sel->title_is("Select product");
-
-    my $product_description = "$product Description";
-
-    my $text = trim($sel->get_text("bugzilla-body"));
-    if ($text =~ /$product_description/) {
-        # Product exists already
-        return 1;
-    }
-
-    $sel->click_ok("link=Add");
-    $sel->wait_for_page_to_load_ok(WAIT_TIME);
-    $sel->title_is("Add Product");
-    $sel->type_ok("product", $product);
-    $sel->type_ok("description", $product_description);
-    $sel->type_ok("version", $version) if $version;
-    $sel->select_ok("security_group_id", "label=core-security");
-    $sel->select_ok("default_op_sys_id", "Unspecified");
-    $sel->select_ok("default_platform_id", "Unspecified");
-    $sel->click_ok('//input[@type="submit" and @value="Add"]');
-    $sel->wait_for_page_to_load_ok(WAIT_TIME);
-    $text = trim($sel->get_text("message"));
-    ok($text =~ /You will need to add at least one component before anyone can enter bugs against this product/,
-       "Display a reminder about missing components");
+  my ($product, $version) = @_;
 
+  go_to_admin($sel);
+  $sel->click_ok("link=Products");
+  $sel->wait_for_page_to_load_ok(WAIT_TIME);
+  $sel->title_is("Select product");
+
+  my $product_description = "$product Description";
+
+  my $text = trim($sel->get_text("bugzilla-body"));
+  if ($text =~ /$product_description/) {
+
+    # Product exists already
     return 1;
+  }
+
+  $sel->click_ok("link=Add");
+  $sel->wait_for_page_to_load_ok(WAIT_TIME);
+  $sel->title_is("Add Product");
+  $sel->type_ok("product",     $product);
+  $sel->type_ok("description", $product_description);
+  $sel->type_ok("version",     $version) if $version;
+  $sel->select_ok("security_group_id",   "label=core-security");
+  $sel->select_ok("default_op_sys_id",   "Unspecified");
+  $sel->select_ok("default_platform_id", "Unspecified");
+  $sel->click_ok('//input[@type="submit" and @value="Add"]');
+  $sel->wait_for_page_to_load_ok(WAIT_TIME);
+  $text = trim($sel->get_text("message"));
+  ok(
+    $text
+      =~ /You will need to add at least one component before anyone can enter bugs against this product/,
+    "Display a reminder about missing components"
+  );
+
+  return 1;
 }
 
 sub _check_component {
-    my ($product, $component) = @_;
-
-    go_to_admin($sel);
-    $sel->click_ok("link=components");
-    $sel->wait_for_page_to_load_ok(WAIT_TIME);
-    $sel->title_is("Edit components for which product?");
-
-    $sel->click_ok("//*[\@id='bugzilla-body']//a[normalize-space(text())='$product']");
-    $sel->wait_for_page_to_load_ok(WAIT_TIME);
-    $sel->title_is("Select component of product '$product'");
-
-    my $component_description = "$component Description";
-
-    my $text = trim($sel->get_text("bugzilla-body"));
-    if ($text =~ /$component_description/) {
-        # Component exists already
-        return 1;
-    }
-
-    # Add the watch user for component watching
-    my $watch_user = lc $component . "@" . lc $product . ".bugs";
-    $watch_user =~ s/ & /-/;
-    $watch_user =~ s/\s+/\-/g;
-    $watch_user =~ s/://g;
-
-    go_to_admin($sel);
-    $sel->click_ok("link=components");
-    $sel->wait_for_page_to_load_ok(WAIT_TIME);
-    $sel->title_is("Edit components for which product?");
-    $sel->click_ok("//*[\@id='bugzilla-body']//a[normalize-space(text())='$product']");
-    $sel->wait_for_page_to_load_ok(WAIT_TIME);
-    $sel->title_is("Select component of product '$product'");
-    $sel->click_ok("link=Add");
-    $sel->wait_for_page_to_load_ok(WAIT_TIME);
-    $sel->title_is("Add component to the $product product");
-    $sel->type_ok("component", $component);
-    $sel->type_ok("description", $component_description);
-    $sel->type_ok("initialowner", $config->{'admin_user_login'});
-    $sel->uncheck_ok("watch_user_auto");
-    $sel->type_ok("watch_user", $watch_user);
-    $sel->check_ok("watch_user_auto");
-    $sel->click_ok('//input[@type="submit" and @value="Add"]');
-    $sel->wait_for_page_to_load_ok(WAIT_TIME);
-    $sel->title_is("Component Created");
-    $text = trim($sel->get_text("message"));
-    ok($text eq "The component $component has been created.", "Component successfully created");
+  my ($product, $component) = @_;
+
+  go_to_admin($sel);
+  $sel->click_ok("link=components");
+  $sel->wait_for_page_to_load_ok(WAIT_TIME);
+  $sel->title_is("Edit components for which product?");
 
+  $sel->click_ok(
+    "//*[\@id='bugzilla-body']//a[normalize-space(text())='$product']");
+  $sel->wait_for_page_to_load_ok(WAIT_TIME);
+  $sel->title_is("Select component of product '$product'");
+
+  my $component_description = "$component Description";
+
+  my $text = trim($sel->get_text("bugzilla-body"));
+  if ($text =~ /$component_description/) {
+
+    # Component exists already
     return 1;
+  }
+
+  # Add the watch user for component watching
+  my $watch_user = lc $component . "@" . lc $product . ".bugs";
+  $watch_user =~ s/ & /-/;
+  $watch_user =~ s/\s+/\-/g;
+  $watch_user =~ s/://g;
+
+  go_to_admin($sel);
+  $sel->click_ok("link=components");
+  $sel->wait_for_page_to_load_ok(WAIT_TIME);
+  $sel->title_is("Edit components for which product?");
+  $sel->click_ok(
+    "//*[\@id='bugzilla-body']//a[normalize-space(text())='$product']");
+  $sel->wait_for_page_to_load_ok(WAIT_TIME);
+  $sel->title_is("Select component of product '$product'");
+  $sel->click_ok("link=Add");
+  $sel->wait_for_page_to_load_ok(WAIT_TIME);
+  $sel->title_is("Add component to the $product product");
+  $sel->type_ok("component",    $component);
+  $sel->type_ok("description",  $component_description);
+  $sel->type_ok("initialowner", $config->{'admin_user_login'});
+  $sel->uncheck_ok("watch_user_auto");
+  $sel->type_ok("watch_user", $watch_user);
+  $sel->check_ok("watch_user_auto");
+  $sel->click_ok('//input[@type="submit" and @value="Add"]');
+  $sel->wait_for_page_to_load_ok(WAIT_TIME);
+  $sel->title_is("Component Created");
+  $text = trim($sel->get_text("message"));
+  ok($text eq "The component $component has been created.",
+    "Component successfully created");
+
+  return 1;
 }
 
 sub _check_group {
-    my ($group) = @_;
-
-    go_to_admin($sel);
-    $sel->click_ok("link=Groups");
-    $sel->wait_for_page_to_load(WAIT_TIME);
-    $sel->title_is("Edit Groups");
-
-    my $group_description = "$group Description";
-
-    my $text = trim($sel->get_text("bugzilla-body"));
-    if ($text =~ /$group_description/) {
-        # Group exists already
-        return 1;
-    }
-
-    $sel->title_is("Edit Groups");
-    $sel->click_ok("link=Add Group");
-    $sel->wait_for_page_to_load(WAIT_TIME);
-    $sel->title_is("Add group");
-    $sel->type_ok("name", $group);
-    $sel->type_ok("desc", $group_description);
-    $sel->type_ok("owner", $config->{'admin_user_login'});
-    $sel->check_ok("isactive");
-    $sel->check_ok("insertnew");
-    $sel->click_ok("create");
-    $sel->wait_for_page_to_load(WAIT_TIME);
-    $sel->title_is("New Group Created");
-    my $group_id = $sel->get_value("group_id");
+  my ($group) = @_;
+
+  go_to_admin($sel);
+  $sel->click_ok("link=Groups");
+  $sel->wait_for_page_to_load(WAIT_TIME);
+  $sel->title_is("Edit Groups");
 
+  my $group_description = "$group Description";
+
+  my $text = trim($sel->get_text("bugzilla-body"));
+  if ($text =~ /$group_description/) {
+
+    # Group exists already
     return 1;
+  }
+
+  $sel->title_is("Edit Groups");
+  $sel->click_ok("link=Add Group");
+  $sel->wait_for_page_to_load(WAIT_TIME);
+  $sel->title_is("Add group");
+  $sel->type_ok("name",  $group);
+  $sel->type_ok("desc",  $group_description);
+  $sel->type_ok("owner", $config->{'admin_user_login'});
+  $sel->check_ok("isactive");
+  $sel->check_ok("insertnew");
+  $sel->click_ok("create");
+  $sel->wait_for_page_to_load(WAIT_TIME);
+  $sel->title_is("New Group Created");
+  my $group_id = $sel->get_value("group_id");
+
+  return 1;
 }
 
 sub _check_version {
-    my ($product, $version) = @_;
-
-    go_to_admin($sel);
-    $sel->click_ok("link=versions");
-    $sel->wait_for_page_to_load(WAIT_TIME);
-    $sel->title_is("Edit versions for which product?");
-    $sel->click_ok("//*[\@id='bugzilla-body']//a[normalize-space(text())='$product']");
-    $sel->wait_for_page_to_load(WAIT_TIME);
-
-    my $text = trim($sel->get_text("bugzilla-body"));
-    if ($text =~ /$version/) {
-        # Version exists already
-        return 1;
-    }
-
-    $sel->click_ok("link=Add");
-    $sel->wait_for_page_to_load(WAIT_TIME);
-    $sel->title_like(qr/^Add Version to Product/);
-    $sel->type_ok("version", $version);
-    $sel->click_ok("create");
-    $sel->wait_for_page_to_load(WAIT_TIME);
-    $sel->title_is("Version Created");
+  my ($product, $version) = @_;
+
+  go_to_admin($sel);
+  $sel->click_ok("link=versions");
+  $sel->wait_for_page_to_load(WAIT_TIME);
+  $sel->title_is("Edit versions for which product?");
+  $sel->click_ok(
+    "//*[\@id='bugzilla-body']//a[normalize-space(text())='$product']");
+  $sel->wait_for_page_to_load(WAIT_TIME);
+
+  my $text = trim($sel->get_text("bugzilla-body"));
+  if ($text =~ /$version/) {
 
+    # Version exists already
     return 1;
+  }
+
+  $sel->click_ok("link=Add");
+  $sel->wait_for_page_to_load(WAIT_TIME);
+  $sel->title_like(qr/^Add Version to Product/);
+  $sel->type_ok("version", $version);
+  $sel->click_ok("create");
+  $sel->wait_for_page_to_load(WAIT_TIME);
+  $sel->title_is("Version Created");
+
+  return 1;
 }
 
 sub _check_user {
-    my ($user) = @_;
-
-    go_to_admin($sel);
-    $sel->click_ok("link=Users");
-    $sel->wait_for_page_to_load(WAIT_TIME);
-    $sel->title_is("Search users");
-    $sel->type_ok("matchstr", $user);
-    $sel->click_ok("search");
-    $sel->wait_for_page_to_load(WAIT_TIME);
-
-    my $text = trim($sel->get_text("bugzilla-body"));
-    if ($text =~ /$user/) {
-        # User exists already
-        return 1;
-    }
-
-    $sel->click_ok("link=add a new user");
-    $sel->wait_for_page_to_load(WAIT_TIME);
-    $sel->title_is('Add user');
-    $sel->type_ok('login', $user);
-    $sel->type_ok('password', 'icohF1io2ohw');
-    $sel->click_ok("add");
-    $sel->wait_for_page_to_load(WAIT_TIME);
-    $sel->is_text_present('regexp:The user account .* has been created successfully');
+  my ($user) = @_;
+
+  go_to_admin($sel);
+  $sel->click_ok("link=Users");
+  $sel->wait_for_page_to_load(WAIT_TIME);
+  $sel->title_is("Search users");
+  $sel->type_ok("matchstr", $user);
+  $sel->click_ok("search");
+  $sel->wait_for_page_to_load(WAIT_TIME);
+
+  my $text = trim($sel->get_text("bugzilla-body"));
+  if ($text =~ /$user/) {
 
+    # User exists already
     return 1;
+  }
+
+  $sel->click_ok("link=add a new user");
+  $sel->wait_for_page_to_load(WAIT_TIME);
+  $sel->title_is('Add user');
+  $sel->type_ok('login',    $user);
+  $sel->type_ok('password', 'icohF1io2ohw');
+  $sel->click_ok("add");
+  $sel->wait_for_page_to_load(WAIT_TIME);
+  $sel->is_text_present(
+    'regexp:The user account .* has been created successfully');
+
+  return 1;
 }
index 5fbcb045a83e531e5c4538c9f2f7bb641304818f..14a5f56462607c4ef6445ce9adb281769f50e0ad 100644 (file)
@@ -19,21 +19,26 @@ my ($text, $bug_id);
 my $admin_user_login = $config->{admin_user_login};
 
 log_in($sel, $config, 'admin');
-set_parameters($sel, { "Bug Fields"              => {"useclassification-off" => undef,
-                                                     "usetargetmilestone-on" => undef},
-                       "Administrative Policies" => {"allowbugdeletion-on"   => undef},
-                     });
+set_parameters(
+  $sel,
+  {
+    "Bug Fields" =>
+      {"useclassification-off" => undef, "usetargetmilestone-on" => undef},
+    "Administrative Policies" => {"allowbugdeletion-on" => undef},
+  }
+);
 
 # create a clean bug
 
 file_bug_in_product($sel, "TestProduct");
 $sel->select_ok("component", "label=TestComponent");
 $sel->type_ok("short_desc", "testing testComponent");
-$sel->type_ok("comment", "testing");
+$sel->type_ok("comment",    "testing");
 $sel->click_ok("commit");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 my $clean_bug_id = $sel->get_value("//input[\@name='id' and \@type='hidden']");
-$sel->is_text_present_ok('has been added to the database', "Bug $clean_bug_id created");
+$sel->is_text_present_ok('has been added to the database',
+  "Bug $clean_bug_id created");
 
 #
 # component
@@ -51,19 +56,22 @@ $sel->click_ok("link=Edit components:");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Select component of product 'TestProduct'");
 $text = trim($sel->get_text("bugzilla-body"));
+
 if ($text =~ /TempComponent/) {
-    $sel->click_ok("//a[contains(\@href, '/editcomponents.cgi?action=del&product=TestProduct&component=TempComponent')]");
-    $sel->wait_for_page_to_load_ok(WAIT_TIME);
-    $sel->title_is("Delete component 'TempComponent' from 'TestProduct' product");
-    $sel->click_ok("delete");
-    $sel->wait_for_page_to_load_ok(WAIT_TIME);
-    $sel->title_is("Component Deleted");
+  $sel->click_ok(
+    "//a[contains(\@href, '/editcomponents.cgi?action=del&product=TestProduct&component=TempComponent')]"
+  );
+  $sel->wait_for_page_to_load_ok(WAIT_TIME);
+  $sel->title_is("Delete component 'TempComponent' from 'TestProduct' product");
+  $sel->click_ok("delete");
+  $sel->wait_for_page_to_load_ok(WAIT_TIME);
+  $sel->title_is("Component Deleted");
 }
 $sel->click_ok("link=Add");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Add component to the TestProduct product");
-$sel->type_ok("component", "TempComponent");
-$sel->type_ok("description", "Temp component");
+$sel->type_ok("component",    "TempComponent");
+$sel->type_ok("description",  "Temp component");
 $sel->type_ok("initialowner", $admin_user_login);
 $sel->uncheck_ok("watch_user_auto");
 $sel->type_ok("watch_user", 'tempcomponent@testproduct.bugs');
@@ -77,11 +85,12 @@ $sel->title_is("Component Created");
 file_bug_in_product($sel, "TestProduct");
 $sel->select_ok("component", "label=TempComponent");
 $sel->type_ok("short_desc", "testing tempComponent");
-$sel->type_ok("comment", "testing");
+$sel->type_ok("comment",    "testing");
 $sel->click_ok("commit");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $bug_id = $sel->get_value("//input[\@name='id' and \@type='hidden']");
-$sel->is_text_present_ok('has been added to the database', "Bug $bug_id created");
+$sel->is_text_present_ok('has been added to the database',
+  "Bug $bug_id created");
 
 # disable TestProduct:TestComponent for bug entry
 
@@ -108,30 +117,37 @@ ok($text =~ /Disabled for bugs/, "Component deactivation confirmed");
 # update bug TempComponent bug
 
 go_to_bug($sel, $bug_id);
+
 # make sure the component is still tempcomponent
 $sel->selected_label_is("component", 'TempComponent');
+
 # update
 $sel->click_ok("commit");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->is_text_present_ok("Changes submitted for bug $bug_id");
 $sel->click_ok("link=bug $bug_id");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
+
 # make sure the component is still tempcomponent
 ok($sel->get_selected_labels("component"), 'TempComponent');
 
 # try creating new bug with TempComponent
 
 file_bug_in_product($sel, "TestProduct");
-ok(!$sel->is_element_present(
+ok(
+  !$sel->is_element_present(
     q#//select[@id='component']/option[@value='TempComponent']#),
-    'TempComponent is missing from create');
+  'TempComponent is missing from create'
+);
 
 # try changing compoent of existing bug to TempComponent
 
 go_to_bug($sel, $clean_bug_id);
-ok(!$sel->is_element_present(
+ok(
+  !$sel->is_element_present(
     q#//select[@id='component']/option[@value='TempComponent']#),
-    'TempComponent is missing from update');
+  'TempComponent is missing from update'
+);
 
 # delete TempComponent
 
@@ -144,7 +160,9 @@ $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Edit Product 'TestProduct'");
 $sel->click_ok("link=Edit components:");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
-$sel->click_ok("//a[contains(\@href, '/editcomponents.cgi?action=del&product=TestProduct&component=TempComponent')]");
+$sel->click_ok(
+  "//a[contains(\@href, '/editcomponents.cgi?action=del&product=TestProduct&component=TempComponent')]"
+);
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Delete component 'TempComponent' from 'TestProduct' product");
 $sel->click_ok("delete");
@@ -168,13 +186,16 @@ $sel->click_ok("link=Edit versions:");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Select version of product 'TestProduct'");
 $text = trim($sel->get_text("bugzilla-body"));
+
 if ($text =~ /TempVersion/) {
-    $sel->click_ok("//a[contains(\@href, '/editversions.cgi?action=del&product=TestProduct&version=TempVersion')]");
-    $sel->wait_for_page_to_load_ok(WAIT_TIME);
-    $sel->title_is("Delete Version of Product 'TestProduct'");
-    $sel->click_ok("delete");
-    $sel->wait_for_page_to_load_ok(WAIT_TIME);
-    $sel->title_is("Version Deleted");
+  $sel->click_ok(
+    "//a[contains(\@href, '/editversions.cgi?action=del&product=TestProduct&version=TempVersion')]"
+  );
+  $sel->wait_for_page_to_load_ok(WAIT_TIME);
+  $sel->title_is("Delete Version of Product 'TestProduct'");
+  $sel->click_ok("delete");
+  $sel->wait_for_page_to_load_ok(WAIT_TIME);
+  $sel->title_is("Version Deleted");
 }
 $sel->click_ok("link=Add");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
@@ -189,11 +210,12 @@ $sel->title_is("Version Created");
 file_bug_in_product($sel, "TestProduct");
 $sel->select_ok("version", "label=TempVersion");
 $sel->type_ok("short_desc", "testing tempVersion");
-$sel->type_ok("comment", "testing");
+$sel->type_ok("comment",    "testing");
 $sel->click_ok("commit");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $bug_id = $sel->get_value("//input[\@name='id' and \@type='hidden']");
-$sel->is_text_present_ok('has been added to the database', "Bug $bug_id created");
+$sel->is_text_present_ok('has been added to the database',
+  "Bug $bug_id created");
 
 # disable new version for bug entry
 
@@ -220,16 +242,20 @@ ok($text =~ /Disabled for bugs/, "Version deactivation confirmed");
 # update new version bug
 
 go_to_bug($sel, $bug_id);
+
 # make sure the version is still tempversion
 $sel->selected_label_is("version", 'TempVersion');
+
 # update
 $sel->click_ok("commit");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->is_text_present_ok("Changes submitted for bug $bug_id");
 $sel->click_ok("link=bug $bug_id");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
+
 # make sure the version is still tempversion
 $sel->selected_label_is("version", 'TempVersion');
+
 # change the version so it can be deleted
 $sel->select_ok("version", "label=unspecified");
 $sel->click_ok("commit");
@@ -239,16 +265,20 @@ $sel->is_text_present_ok("Changes submitted for bug $bug_id");
 # try creating new bug with new version
 
 file_bug_in_product($sel, "TestProduct");
-ok(!$sel->is_element_present(
+ok(
+  !$sel->is_element_present(
     q#//select[@id='version']/option[@value='TempVersion']#),
-    'TempVersion is missing from create');
+  'TempVersion is missing from create'
+);
 
 # try changing existing bug to new version
 
 go_to_bug($sel, $clean_bug_id);
-ok(!$sel->is_element_present(
+ok(
+  !$sel->is_element_present(
     q#//select[@id='version']/option[@value='TempVersion']#),
-    'TempVersion is missing from update');
+  'TempVersion is missing from update'
+);
 
 # delete new version
 
@@ -263,7 +293,9 @@ $sel->click_ok("link=Edit versions:");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Select version of product 'TestProduct'");
 $text = trim($sel->get_text("bugzilla-body"));
-$sel->click_ok("//a[contains(\@href, '/editversions.cgi?action=del&product=TestProduct&version=TempVersion')]");
+$sel->click_ok(
+  "//a[contains(\@href, '/editversions.cgi?action=del&product=TestProduct&version=TempVersion')]"
+);
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Delete Version of Product 'TestProduct'");
 $sel->click_ok("delete");
@@ -287,19 +319,22 @@ $sel->click_ok("link=Edit milestones:");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Select milestone of product 'TestProduct'");
 $text = trim($sel->get_text("bugzilla-body"));
+
 if ($text =~ /TempMilestone/) {
-    $sel->click_ok("//a[contains(\@href, '/editmilestones.cgi?action=del&product=TestProduct&milestone=TempMilestone')]");
-    $sel->wait_for_page_to_load_ok(WAIT_TIME);
-    $sel->title_is("Delete Milestone of Product 'TestProduct'");
-    $sel->click_ok("delete");
-    $sel->wait_for_page_to_load_ok(WAIT_TIME);
-    $sel->title_is("Milestone Deleted");
+  $sel->click_ok(
+    "//a[contains(\@href, '/editmilestones.cgi?action=del&product=TestProduct&milestone=TempMilestone')]"
+  );
+  $sel->wait_for_page_to_load_ok(WAIT_TIME);
+  $sel->title_is("Delete Milestone of Product 'TestProduct'");
+  $sel->click_ok("delete");
+  $sel->wait_for_page_to_load_ok(WAIT_TIME);
+  $sel->title_is("Milestone Deleted");
 }
 $sel->click_ok("link=Add");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Add Milestone to Product 'TestProduct'");
 $sel->type_ok("milestone", "TempMilestone");
-$sel->type_ok("sortkey", "999");
+$sel->type_ok("sortkey",   "999");
 $sel->click_ok("create");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Milestone Created");
@@ -309,11 +344,12 @@ $sel->title_is("Milestone Created");
 file_bug_in_product($sel, "TestProduct");
 $sel->select_ok("target_milestone", "label=TempMilestone");
 $sel->type_ok("short_desc", "testing tempMilestone");
-$sel->type_ok("comment", "testing");
+$sel->type_ok("comment",    "testing");
 $sel->click_ok("commit");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $bug_id = $sel->get_value("//input[\@name='id' and \@type='hidden']");
-$sel->is_text_present_ok('has been added to the database', "Bug $bug_id created");
+$sel->is_text_present_ok('has been added to the database',
+  "Bug $bug_id created");
 
 # disable milestone for bug entry
 
@@ -340,30 +376,37 @@ ok($text =~ /Disabled for bugs/, "Milestone deactivation confirmed");
 # update milestone bug
 
 go_to_bug($sel, $bug_id);
+
 # make sure the milestone is still tempmilestone
 $sel->selected_label_is("target_milestone", 'TempMilestone');
+
 # update
 $sel->click_ok("commit");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->is_text_present_ok("Changes submitted for bug $bug_id");
 $sel->click_ok("link=bug $bug_id");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
+
 # make sure the milestone is still tempmilestone
 $sel->selected_label_is("target_milestone", 'TempMilestone');
 
 # try creating new bug with milestone
 
 file_bug_in_product($sel, "TestProduct");
-ok(!$sel->is_element_present(
+ok(
+  !$sel->is_element_present(
     q#//select[@id='target_milestone']/option[@value='TempMilestone']#),
-    'TempMilestone is missing from create');
+  'TempMilestone is missing from create'
+);
 
 # try changing existing bug to milestone
 
 go_to_bug($sel, $clean_bug_id);
-ok(!$sel->is_element_present(
+ok(
+  !$sel->is_element_present(
     q#//select[@id='target_milestone']/option[@value='TempMilestone']#),
-    'TempMilestone is missing from update');
+  'TempMilestone is missing from update'
+);
 
 # delete milestone
 
@@ -378,7 +421,9 @@ $sel->click_ok("link=Edit milestones:");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Select milestone of product 'TestProduct'");
 $text = trim($sel->get_text("bugzilla-body"));
-$sel->click_ok("//a[contains(\@href, '/editmilestones.cgi?action=del&product=TestProduct&milestone=TempMilestone')]");
+$sel->click_ok(
+  "//a[contains(\@href, '/editmilestones.cgi?action=del&product=TestProduct&milestone=TempMilestone')]"
+);
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Delete Milestone of Product 'TestProduct'");
 $sel->click_ok("delete");
index 3eccd5d048f2fd13d0594228df73380f054b9cb3..bb78dcce72ade29f42f890bf95ff189b8e8dd6ac 100644 (file)
@@ -16,17 +16,17 @@ use QA::Util;
 my ($sel, $config) = get_selenium();
 
 log_in($sel, $config, 'admin');
-set_parameters($sel, { "Bug Fields" => {"usestatuswhiteboard-on" => undef} });
+set_parameters($sel, {"Bug Fields" => {"usestatuswhiteboard-on" => undef}});
 
 # Clear the saved search, in case this test didn't complete previously.
 if ($sel->is_text_present("My bugs from QA_Selenium")) {
-    $sel->click_ok("link=My bugs from QA_Selenium");
-    $sel->wait_for_page_to_load_ok(WAIT_TIME);
-    $sel->title_is("Bug List: My bugs from QA_Selenium");
-    $sel->click_ok("link=Forget Search 'My bugs from QA_Selenium'");
-    $sel->wait_for_page_to_load_ok(WAIT_TIME);
-    $sel->title_is("Search is gone");
-    $sel->is_text_present_ok("OK, the My bugs from QA_Selenium search is gone");
+  $sel->click_ok("link=My bugs from QA_Selenium");
+  $sel->wait_for_page_to_load_ok(WAIT_TIME);
+  $sel->title_is("Bug List: My bugs from QA_Selenium");
+  $sel->click_ok("link=Forget Search 'My bugs from QA_Selenium'");
+  $sel->wait_for_page_to_load_ok(WAIT_TIME);
+  $sel->title_is("Search is gone");
+  $sel->is_text_present_ok("OK, the My bugs from QA_Selenium search is gone");
 }
 
 # Just in case the test failed before completion previously, reset the CANEDIT bit.
@@ -35,7 +35,8 @@ $sel->click_ok("link=Groups");
 check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/editgroups.cgi});
 $sel->title_is("Edit Groups");
 $sel->click_ok("link=Master");
-check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/editgroups.cgi?action=changeform&group=25});
+check_page_load($sel, WAIT_TIME,
+  q{http://HOSTNAME:8000/bmo/editgroups.cgi?action=changeform&group=25});
 $sel->title_is("Change Group: Master");
 my $group_url = $sel->get_location();
 $group_url =~ /group=(\d+)$/;
@@ -50,30 +51,34 @@ log_in($sel, $config, 'QA_Selenium_TEST');
 file_bug_in_product($sel, 'TestProduct');
 $sel->select_ok("bug_severity", "label=critical");
 $sel->type_ok("short_desc", "Test bug editing");
-$sel->type_ok("comment", "ploc");
+$sel->type_ok("comment",    "ploc");
 $sel->click_ok("commit");
-check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=__BUG_ID__});
+check_page_load($sel, WAIT_TIME,
+  qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=__BUG_ID__});
 my $bug1_id = $sel->get_value('//input[@name="id" and @type="hidden"]');
-$sel->is_text_present_ok('has been added to the database', "Bug $bug1_id created");
+$sel->is_text_present_ok('has been added to the database',
+  "Bug $bug1_id created");
 
 # Now edit field values of the bug you just filed.
 
 $sel->select_ok("rep_platform", "label=Other");
-$sel->select_ok("op_sys", "label=Other");
-$sel->select_ok("priority", "label=Highest");
+$sel->select_ok("op_sys",       "label=Other");
+$sel->select_ok("priority",     "label=Highest");
 $sel->select_ok("bug_severity", "label=blocker");
-$sel->type_ok("bug_file_loc", "foo.cgi?action=bar");
+$sel->type_ok("bug_file_loc",      "foo.cgi?action=bar");
 $sel->type_ok("status_whiteboard", "[Selenium was here]");
-$sel->type_ok("comment", "new comment from me :)");
+$sel->type_ok("comment",           "new comment from me :)");
 $sel->select_ok("bug_status", "label=RESOLVED");
 $sel->click_ok("commit");
-check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id});
+check_page_load($sel, WAIT_TIME,
+  qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id});
 $sel->is_text_present_ok("Changes submitted for bug $bug1_id");
 
 # Now move the bug into another product, which has a mandatory group.
 
 $sel->click_ok("link=bug $bug1_id");
-check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id});
+check_page_load($sel, WAIT_TIME,
+  qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id});
 $sel->title_like(qr/^$bug1_id /);
 $sel->select_ok("product", "label=QA-Selenium-TEST");
 $sel->type_ok("comment", "moving to QA-Selenium-TEST");
@@ -81,34 +86,49 @@ $sel->click_ok("commit");
 check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/process_bug.cgi});
 $sel->title_is("Verify New Product Details...");
 $sel->select_ok("component", "label=QA-Selenium-TEST");
-$sel->is_element_present_ok('//input[@type="checkbox" and @name="groups" and @value="QA-Selenium-TEST"]');
-ok(!$sel->is_editable('//input[@type="checkbox" and @name="groups" and @value="QA-Selenium-TEST"]'), "QA-Selenium-TEST group not editable");
-$sel->is_checked_ok('//input[@type="checkbox" and @name="groups" and @value="QA-Selenium-TEST"]', "QA-Selenium-TEST group is selected");
+$sel->is_element_present_ok(
+  '//input[@type="checkbox" and @name="groups" and @value="QA-Selenium-TEST"]');
+ok(
+  !$sel->is_editable(
+    '//input[@type="checkbox" and @name="groups" and @value="QA-Selenium-TEST"]'),
+  "QA-Selenium-TEST group not editable"
+);
+$sel->is_checked_ok(
+  '//input[@type="checkbox" and @name="groups" and @value="QA-Selenium-TEST"]',
+  "QA-Selenium-TEST group is selected");
 $sel->click_ok("change_product");
-check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id});
+check_page_load($sel, WAIT_TIME,
+  qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id});
 $sel->is_text_present_ok("Changes submitted for bug $bug1_id");
 $sel->click_ok("link=bug $bug1_id");
-check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id});
+check_page_load($sel, WAIT_TIME,
+  qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id});
 $sel->title_like(qr/^$bug1_id /);
 $sel->select_ok("bug_severity", "label=normal");
-$sel->select_ok("priority", "label=High");
+$sel->select_ok("priority",     "label=High");
 $sel->select_ok("rep_platform", "label=All");
-$sel->select_ok("op_sys", "label=All");
+$sel->select_ok("op_sys",       "label=All");
 $sel->click_ok("cc_edit_area_showhide");
-$sel->type_ok("newcc", $config->{admin_user_login});
+$sel->type_ok("newcc",   $config->{admin_user_login});
 $sel->type_ok("comment", "Unchecking the reporter_accessible checkbox");
+
 # This checkbox is checked by default.
 $sel->click_ok("reporter_accessible");
 $sel->select_ok("bug_status", "label=VERIFIED");
 $sel->click_ok("commit");
-check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id});
+check_page_load($sel, WAIT_TIME,
+  qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id});
 $sel->is_text_present_ok("Changes submitted for bug $bug1_id");
 $sel->click_ok("link=bug $bug1_id");
-check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id});
+check_page_load($sel, WAIT_TIME,
+  qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id});
 $sel->title_like(qr/^$bug1_id /);
-$sel->type_ok("comment", "I am the reporter, but I can see the bug anyway as I belong to the mandatory group");
+$sel->type_ok("comment",
+  "I am the reporter, but I can see the bug anyway as I belong to the mandatory group"
+);
 $sel->click_ok("commit");
-check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id});
+check_page_load($sel, WAIT_TIME,
+  qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id});
 $sel->is_text_present_ok("Changes submitted for bug $bug1_id");
 logout($sel);
 
@@ -118,23 +138,26 @@ logout($sel);
 log_in($sel, $config, 'admin');
 go_to_bug($sel, $bug1_id);
 $sel->select_ok("bug_severity", "label=blocker");
-$sel->select_ok("priority", "label=Highest");
+$sel->select_ok("priority",     "label=Highest");
 $sel->type_ok("status_whiteboard", "[Selenium was here][admin too]");
 $sel->select_ok("bug_status", "label=CONFIRMED");
 $sel->click_ok("bz_assignee_edit_action");
 $sel->type_ok("assigned_to", $config->{admin_user_login});
-$sel->type_ok("comment", "I have editbugs privs. Taking!");
+$sel->type_ok("comment",     "I have editbugs privs. Taking!");
 $sel->click_ok("commit");
-check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id});
+check_page_load($sel, WAIT_TIME,
+  qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id});
 $sel->is_text_present_ok("Changes submitted for bug $bug1_id");
 
 $sel->click_ok("link=bug $bug1_id");
-check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id});
+check_page_load($sel, WAIT_TIME,
+  qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id});
 $sel->title_like(qr/^$bug1_id /);
 $sel->click_ok("cc_edit_area_showhide");
 $sel->type_ok("newcc", $config->{unprivileged_user_login});
 $sel->click_ok("commit");
-check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id});
+check_page_load($sel, WAIT_TIME,
+  qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id});
 $sel->is_text_present_ok("Changes submitted for bug $bug1_id");
 logout($sel);
 
@@ -151,9 +174,12 @@ logout($sel);
 log_in($sel, $config, 'admin');
 go_to_bug($sel, $bug1_id);
 $sel->click_ok("cclist_accessible");
-$sel->type_ok("comment", "I am allowed to turn off cclist_accessible despite not being in the mandatory group");
+$sel->type_ok("comment",
+  "I am allowed to turn off cclist_accessible despite not being in the mandatory group"
+);
 $sel->click_ok("commit");
-check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id});
+check_page_load($sel, WAIT_TIME,
+  qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id});
 $sel->is_text_present_ok("Changes submitted for bug $bug1_id");
 logout($sel);
 
@@ -162,7 +188,8 @@ logout($sel);
 log_in($sel, $config, 'unprivileged');
 $sel->type_ok("quicksearch_top", $bug1_id);
 $sel->submit("header-search");
-check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id});
+check_page_load($sel, WAIT_TIME,
+  qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id});
 $sel->title_is("Access Denied");
 $sel->is_text_present_ok("You are not authorized to access bug $bug1_id");
 logout($sel);
@@ -172,6 +199,7 @@ logout($sel);
 log_in($sel, $config, 'admin');
 go_to_bug($sel, $bug1_id);
 $sel->select_ok("product", "label=TestProduct");
+
 # When selecting a new product, Bugzilla tries to reassign the bug by default,
 # so we have to uncheck it.
 $sel->click_ok("set_default_assignee");
@@ -181,23 +209,46 @@ $sel->click_ok("commit");
 check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/process_bug.cgi});
 $sel->title_is("Verify New Product Details...");
 $sel->select_ok("component", "label=TestComponent");
-$sel->is_text_present_ok("These groups are not legal for the 'TestProduct' product or you are not allowed to restrict bugs to these groups");
-$sel->is_element_present_ok('//input[@type="checkbox" and @name="groups" and @value="QA-Selenium-TEST"]');
-ok(!$sel->is_editable('//input[@type="checkbox" and @name="groups" and @value="QA-Selenium-TEST"]'), "QA-Selenium-TEST group not editable");
-ok(!$sel->is_checked('//input[@type="checkbox" and @name="groups" and @value="QA-Selenium-TEST"]'), "QA-Selenium-TEST group not selected");
-$sel->is_element_present_ok('//input[@type="checkbox" and @name="groups" and @value="Master"]');
-$sel->is_editable_ok('//input[@type="checkbox" and @name="groups" and @value="Master"]', "Master group is editable");
-ok(!$sel->is_checked('//input[@type="checkbox" and @name="groups" and @value="Master"]'), "Master group not selected by default");
+$sel->is_text_present_ok(
+  "These groups are not legal for the 'TestProduct' product or you are not allowed to restrict bugs to these groups"
+);
+$sel->is_element_present_ok(
+  '//input[@type="checkbox" and @name="groups" and @value="QA-Selenium-TEST"]');
+ok(
+  !$sel->is_editable(
+    '//input[@type="checkbox" and @name="groups" and @value="QA-Selenium-TEST"]'),
+  "QA-Selenium-TEST group not editable"
+);
+ok(
+  !$sel->is_checked(
+    '//input[@type="checkbox" and @name="groups" and @value="QA-Selenium-TEST"]'),
+  "QA-Selenium-TEST group not selected"
+);
+$sel->is_element_present_ok(
+  '//input[@type="checkbox" and @name="groups" and @value="Master"]');
+$sel->is_editable_ok(
+  '//input[@type="checkbox" and @name="groups" and @value="Master"]',
+  "Master group is editable");
+ok(
+  !$sel->is_checked(
+    '//input[@type="checkbox" and @name="groups" and @value="Master"]'),
+  "Master group not selected by default"
+);
 $sel->click_ok("change_product");
-check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id});
+check_page_load($sel, WAIT_TIME,
+  qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id});
 $sel->is_text_present_ok("Changes submitted for bug $bug1_id");
 $sel->click_ok("link=bug $bug1_id");
-check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id});
+check_page_load($sel, WAIT_TIME,
+  qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id});
 $sel->title_like(qr/^$bug1_id /);
 $sel->click_ok("cclist_accessible");
-$sel->type_ok("comment", "I am allowed to turn off cclist_accessible despite not being in the mandatory group");
+$sel->type_ok("comment",
+  "I am allowed to turn off cclist_accessible despite not being in the mandatory group"
+);
 $sel->click_ok("commit");
-check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id});
+check_page_load($sel, WAIT_TIME,
+  qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id});
 $sel->is_text_present_ok("Changes submitted for bug $bug1_id");
 logout($sel);
 
@@ -206,17 +257,24 @@ logout($sel);
 
 log_in($sel, $config, 'unprivileged');
 go_to_bug($sel, $bug1_id);
-$sel->type_ok("comment", "I have no privs, I can only comment (and remove people from the CC list)");
-ok(!$sel->is_element_present('//select[@name="product"]'), "Product field not editable");
-ok(!$sel->is_element_present('//select[@name="bug_severity"]'), "Severity field not editable");
-ok(!$sel->is_element_present('//select[@name="priority"]'), "Priority field not editable");
-ok(!$sel->is_element_present('//select[@name="op_sys"]'), "OS field not editable");
-ok(!$sel->is_element_present('//select[@name="rep_platform"]'), "Hardware field not editable");
+$sel->type_ok("comment",
+  "I have no privs, I can only comment (and remove people from the CC list)");
+ok(!$sel->is_element_present('//select[@name="product"]'),
+  "Product field not editable");
+ok(!$sel->is_element_present('//select[@name="bug_severity"]'),
+  "Severity field not editable");
+ok(!$sel->is_element_present('//select[@name="priority"]'),
+  "Priority field not editable");
+ok(!$sel->is_element_present('//select[@name="op_sys"]'),
+  "OS field not editable");
+ok(!$sel->is_element_present('//select[@name="rep_platform"]'),
+  "Hardware field not editable");
 $sel->click_ok("cc_edit_area_showhide");
 $sel->add_selection_ok("cc", "label=" . $config->{admin_user_login});
 $sel->click_ok("removecc");
 $sel->click_ok("commit");
-check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id});
+check_page_load($sel, WAIT_TIME,
+  qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id});
 $sel->is_text_present_ok("Changes submitted for bug $bug1_id");
 logout($sel);
 
@@ -225,7 +283,9 @@ logout($sel);
 log_in($sel, $config, 'admin');
 edit_product($sel, "TestProduct");
 $sel->click_ok("link=Edit Group Access Controls:");
-check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/editproducts.cgi?action=editgroupcontrols&product=TestProduct});
+check_page_load($sel, WAIT_TIME,
+  q{http://HOSTNAME:8000/bmo/editproducts.cgi?action=editgroupcontrols&product=TestProduct}
+);
 $sel->title_is("Edit Group Controls for TestProduct");
 $sel->check_ok("canedit_$master_gid");
 $sel->click_ok("submit");
@@ -237,7 +297,8 @@ $sel->title_is("Update group access controls for TestProduct");
 go_to_bug($sel, $bug1_id);
 $sel->type_ok("comment", "Do nothing except adding a comment...");
 $sel->click_ok("commit");
-check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id});
+check_page_load($sel, WAIT_TIME,
+  qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id});
 $sel->is_text_present_ok("Changes submitted for bug $bug1_id");
 logout($sel);
 
@@ -249,7 +310,8 @@ $sel->type_ok("comment", "Just a comment too...");
 $sel->click_ok("commit");
 check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/process_bug.cgi});
 $sel->title_is("Product Edit Access Denied");
-$sel->is_text_present_ok("You are not permitted to edit bugs in product TestProduct.");
+$sel->is_text_present_ok(
+  "You are not permitted to edit bugs in product TestProduct.");
 logout($sel);
 
 # Test searches and "format for printing".
@@ -272,24 +334,32 @@ $sel->select_ok("emailtype2", "label=is");
 $sel->type_ok("email2", $config->{QA_Selenium_TEST_user_login});
 screenshot_page($sel, '/app/artifacts/line271.png');
 $sel->click_ok("Search");
-check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/buglist.cgi?emailreporter2=1&emailtype2=exact&order=Importance&list_id=15&emailtype1=exact&emailcc2=1&query_format=advanced&emailassigned_to1=1&emailqa_contact2=1&email2=QA-Selenium-TEST%40mozilla.test&email1=admin%40mozilla.test&emailassigned_to2=1&product=TestProduct});
+check_page_load($sel, WAIT_TIME,
+  q{http://HOSTNAME:8000/bmo/buglist.cgi?emailreporter2=1&emailtype2=exact&order=Importance&list_id=15&emailtype1=exact&emailcc2=1&query_format=advanced&emailassigned_to1=1&emailqa_contact2=1&email2=QA-Selenium-TEST%40mozilla.test&email1=admin%40mozilla.test&emailassigned_to2=1&product=TestProduct}
+);
 $sel->title_is("Bug List");
 screenshot_page($sel, '/app/artifacts/line275.png');
 $sel->is_text_present_ok("One bug found.");
 $sel->type_ok("save_newqueryname", "My bugs from QA_Selenium");
 $sel->click_ok("remember");
-check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/buglist.cgi?newquery=email1%3Dadmin%2540mozilla.test%26email2%3DQA-Selenium-TEST%2540mozilla.test%26emailassigned_to1%3D1%26emailassigned_to2%3D1%26emailcc2%3D1%26emailqa_contact2%3D1%26emailreporter2%3D1%26emailtype1%3Dexact%26emailtype2%3Dexact%26list_id%3D15%26product%3DTestProduct%26query_format%3Dadvanced%26order%3Dpriority%252Cbug_severity&cmdtype=doit&remtype=asnamed&token=1531926552-dc69995d79c786af046436ec6717000b&newqueryname=My%20bugs%20from%20QA_Selenium&list_id=16});
+check_page_load($sel, WAIT_TIME,
+  q{http://HOSTNAME:8000/bmo/buglist.cgi?newquery=email1%3Dadmin%2540mozilla.test%26email2%3DQA-Selenium-TEST%2540mozilla.test%26emailassigned_to1%3D1%26emailassigned_to2%3D1%26emailcc2%3D1%26emailqa_contact2%3D1%26emailreporter2%3D1%26emailtype1%3Dexact%26emailtype2%3Dexact%26list_id%3D15%26product%3DTestProduct%26query_format%3Dadvanced%26order%3Dpriority%252Cbug_severity&cmdtype=doit&remtype=asnamed&token=1531926552-dc69995d79c786af046436ec6717000b&newqueryname=My%20bugs%20from%20QA_Selenium&list_id=16}
+);
 $sel->title_is("Search created");
-$sel->is_text_present_ok("OK, you have a new search named My bugs from QA_Selenium.");
+$sel->is_text_present_ok(
+  "OK, you have a new search named My bugs from QA_Selenium.");
 $sel->click_ok("link=My bugs from QA_Selenium");
-check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/buglist.cgi?cmdtype=runnamed&namedcmd=My%20bugs%20from%20QA_Selenium&list_id=17});
+check_page_load($sel, WAIT_TIME,
+  q{http://HOSTNAME:8000/bmo/buglist.cgi?cmdtype=runnamed&namedcmd=My%20bugs%20from%20QA_Selenium&list_id=17}
+);
 $sel->title_is("Bug List: My bugs from QA_Selenium");
 $sel->click_ok("long_format");
 check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/show_bug.cgi});
 $sel->title_is("Full Text Bug Listing");
 $sel->is_text_present_ok("Bug $bug1_id");
 $sel->is_text_present_ok("Status: CONFIRMED");
-$sel->is_text_present_ok("Reporter: QA-Selenium-TEST <$config->{QA_Selenium_TEST_user_login}>");
+$sel->is_text_present_ok(
+  "Reporter: QA-Selenium-TEST <$config->{QA_Selenium_TEST_user_login}>");
 $sel->is_text_present_ok("Assignee: QA Admin <$config->{admin_user_login}>");
 $sel->is_text_present_ok("Severity: blocker");
 $sel->is_text_present_ok("Priority: Highest");
@@ -303,30 +373,37 @@ log_in($sel, $config, 'QA_Selenium_TEST');
 file_bug_in_product($sel, 'TestProduct');
 $sel->select_ok("bug_severity", "label=blocker");
 $sel->type_ok("short_desc", "New bug from me");
+
 # We turned on the CANEDIT bit for TestProduct.
 $sel->type_ok("comment", "I can enter a new bug, but not edit it, right?");
 $sel->click_ok("commit");
-check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=__BUG_ID__});
+check_page_load($sel, WAIT_TIME,
+  qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=__BUG_ID__});
 my $bug2_id = $sel->get_value('//input[@name="id" and @type="hidden"]');
-$sel->is_text_present_ok('has been added to the database', "Bug $bug2_id created");
+$sel->is_text_present_ok('has been added to the database',
+  "Bug $bug2_id created");
 
 # Clicking the "Back" button and resubmitting the form again should trigger a suspicous action error.
 
 $sel->go_back_ok();
-check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/enter_bug.cgi?product=TestProduct&format=__default__});
+check_page_load($sel, WAIT_TIME,
+  q{http://HOSTNAME:8000/bmo/enter_bug.cgi?product=TestProduct&format=__default__}
+);
 $sel->title_is("Enter Bug: TestProduct");
 $sel->click_ok("commit");
 check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/post_bug.cgi});
 $sel->title_is("Suspicious Action");
 $sel->is_text_present_ok("you have no valid token for the create_bug action");
 $sel->click_ok('//input[@value="Confirm Changes"]');
-check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/show_bug.cgi?id=14});
+check_page_load($sel, WAIT_TIME,
+  q{http://HOSTNAME:8000/bmo/show_bug.cgi?id=14});
 $sel->is_text_present_ok('has been added to the database', 'Bug created');
 $sel->type_ok("comment", "New comment not allowed");
 $sel->click_ok("commit");
 check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/process_bug.cgi});
 $sel->title_is("Product Edit Access Denied");
-$sel->is_text_present_ok("You are not permitted to edit bugs in product TestProduct.");
+$sel->is_text_present_ok(
+  "You are not permitted to edit bugs in product TestProduct.");
 logout($sel);
 
 # Reassign the newly created bug to the admin.
@@ -335,23 +412,28 @@ log_in($sel, $config, 'admin');
 go_to_bug($sel, $bug2_id);
 $sel->click_ok("bz_assignee_edit_action");
 $sel->type_ok("assigned_to", $config->{admin_user_login});
-$sel->type_ok("comment", "Taking!");
+$sel->type_ok("comment",     "Taking!");
 $sel->click_ok("commit");
-check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug2_id});
+check_page_load($sel, WAIT_TIME,
+  qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug2_id});
 $sel->is_text_present_ok("Changes submitted for bug $bug2_id");
 
 # Test mass-change.
 
 $sel->click_ok("link=My bugs from QA_Selenium");
 screenshot_page($sel, '/app/artifacts/line344.png');
-check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/buglist.cgi?cmdtype=runnamed&namedcmd=My%20bugs%20from%20QA_Selenium&list_id=19});
+check_page_load($sel, WAIT_TIME,
+  q{http://HOSTNAME:8000/bmo/buglist.cgi?cmdtype=runnamed&namedcmd=My%20bugs%20from%20QA_Selenium&list_id=19}
+);
 screenshot_page($sel, '/app/artifacts/line346.png');
 $sel->title_is("Bug List: My bugs from QA_Selenium");
 screenshot_page($sel, '/app/artifacts/line348.png');
 $sel->is_text_present_ok("2 bugs found");
 screenshot_page($sel, '/app/artifacts/line350.png');
 $sel->click_ok("link=Change Several Bugs at Once");
-check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/buglist.cgi?email1=admin%40mozilla.test&email2=QA-Selenium-TEST%40mozilla.test&emailassigned_to1=1&emailassigned_to2=1&emailcc2=1&emailqa_contact2=1&emailreporter2=1&emailtype1=exact&emailtype2=exact&product=TestProduct&query_format=advanced&order=priority%2Cbug_severity&tweak=1&list_id=20});
+check_page_load($sel, WAIT_TIME,
+  q{http://HOSTNAME:8000/bmo/buglist.cgi?email1=admin%40mozilla.test&email2=QA-Selenium-TEST%40mozilla.test&emailassigned_to1=1&emailassigned_to2=1&emailcc2=1&emailqa_contact2=1&emailreporter2=1&emailtype1=exact&emailtype2=exact&product=TestProduct&query_format=advanced&order=priority%2Cbug_severity&tweak=1&list_id=20}
+);
 $sel->title_is("Bug List");
 $sel->click_ok("check_all");
 $sel->type_ok("comment", 'Mass change"');
@@ -362,25 +444,30 @@ check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/process_bug.cgi});
 $sel->title_is("Bugs processed");
 
 $sel->click_ok("link=bug $bug1_id");
-check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id});
+check_page_load($sel, WAIT_TIME,
+  qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id});
 $sel->title_like(qr/$bug1_id /);
 $sel->selected_label_is("resolution", "WORKSFORME");
 $sel->select_ok("resolution", "label=INVALID");
 $sel->click_ok("commit");
-check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id});
+check_page_load($sel, WAIT_TIME,
+  qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id});
 $sel->is_text_present_ok("Changes submitted for bug $bug1_id");
 
 $sel->click_ok("link=bug $bug1_id");
-check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id});
+check_page_load($sel, WAIT_TIME,
+  qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id});
 $sel->title_like(qr/$bug1_id /);
 $sel->selected_label_is("resolution", "INVALID");
 
 $sel->click_ok("link=History");
-check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_activity.cgi?id=$bug1_id});
+check_page_load($sel, WAIT_TIME,
+  qq{http://HOSTNAME:8000/bmo/show_activity.cgi?id=$bug1_id});
 $sel->title_is("Changes made to bug $bug1_id");
 $sel->is_text_present_ok("URL foo.cgi?action=bar");
 $sel->is_text_present_ok("Severity critical blocker");
-$sel->is_text_present_ok("Whiteboard [Selenium was here] [Selenium was here][admin too]");
+$sel->is_text_present_ok(
+  "Whiteboard [Selenium was here] [Selenium was here][admin too]");
 $sel->is_text_present_ok("Product QA-Selenium-TEST TestProduct");
 $sel->is_text_present_ok("Status CONFIRMED RESOLVED");
 
@@ -431,53 +518,68 @@ $sel->is_text_present_ok("Status CONFIRMED RESOLVED");
 # Make sure token checks are working correctly for single bug editing and mass change,
 # first with no token, then with an invalid token.
 
-foreach my $params (["no_token_single_bug", ""], ["invalid_token_single_bug", "&token=1"]) {
-    my ($comment, $token) = @$params;
-    $sel->open_ok("/$config->{bugzilla_installation}/process_bug.cgi?id=$bug1_id&comment=$comment$token",
-                  undef, "Edit a single bug with " . ($token ? "an invalid" : "no") . " token");
-    $sel->title_is("Suspicious Action");
-    $sel->is_text_present_ok($token ? "an invalid token" : "web browser directly");
-    $sel->click_ok("confirm");
-    check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id});
-    $sel->is_text_present_ok("Changes submitted for bug $bug1_id");
-    $sel->click_ok("link=bug $bug1_id");
-    check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id});
-    $sel->title_like(qr/^$bug1_id /);
-    $sel->is_text_present_ok($comment);
+foreach my $params (["no_token_single_bug", ""],
+  ["invalid_token_single_bug", "&token=1"])
+{
+  my ($comment, $token) = @$params;
+  $sel->open_ok(
+    "/$config->{bugzilla_installation}/process_bug.cgi?id=$bug1_id&comment=$comment$token",
+    undef, "Edit a single bug with " . ($token ? "an invalid" : "no") . " token"
+  );
+  $sel->title_is("Suspicious Action");
+  $sel->is_text_present_ok($token ? "an invalid token" : "web browser directly");
+  $sel->click_ok("confirm");
+  check_page_load($sel, WAIT_TIME,
+    qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id});
+  $sel->is_text_present_ok("Changes submitted for bug $bug1_id");
+  $sel->click_ok("link=bug $bug1_id");
+  check_page_load($sel, WAIT_TIME,
+    qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id});
+  $sel->title_like(qr/^$bug1_id /);
+  $sel->is_text_present_ok($comment);
 }
 
-foreach my $params (["no_token_mass_change", ""], ["invalid_token_mass_change", "&token=1"]) {
-    my ($comment, $token) = @$params;
-    $sel->open_ok("/$config->{bugzilla_installation}/process_bug.cgi?id_$bug1_id=1&id_$bug2_id=1&comment=$comment$token",
-                  undef, "Mass change with " . ($token ? "an invalid" : "no") . " token");
-    $sel->title_is("Suspicious Action");
-    $sel->is_text_present_ok("no valid token for the buglist_mass_change action");
-    $sel->click_ok("confirm");
+foreach my $params (["no_token_mass_change", ""],
+  ["invalid_token_mass_change", "&token=1"])
+{
+  my ($comment, $token) = @$params;
+  $sel->open_ok(
+    "/$config->{bugzilla_installation}/process_bug.cgi?id_$bug1_id=1&id_$bug2_id=1&comment=$comment$token",
+    undef, "Mass change with " . ($token ? "an invalid" : "no") . " token"
+  );
+  $sel->title_is("Suspicious Action");
+  $sel->is_text_present_ok("no valid token for the buglist_mass_change action");
+  $sel->click_ok("confirm");
+  check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/process_bug.cgi});
+  $sel->title_is("Bugs processed");
+  foreach my $bug_id ($bug1_id, $bug2_id) {
+    $sel->click_ok("link=bug $bug_id");
+    check_page_load($sel, WAIT_TIME,
+      qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug_id});
+    $sel->title_like(qr/^$bug_id /);
+    $sel->is_text_present_ok($comment);
+    next if $bug_id == $bug2_id;
+    $sel->go_back_ok();
     check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/process_bug.cgi});
     $sel->title_is("Bugs processed");
-    foreach my $bug_id ($bug1_id, $bug2_id) {
-        $sel->click_ok("link=bug $bug_id");
-        check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug_id});
-        $sel->title_like(qr/^$bug_id /);
-        $sel->is_text_present_ok($comment);
-        next if $bug_id == $bug2_id;
-        $sel->go_back_ok();
-        check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/process_bug.cgi});
-        $sel->title_is("Bugs processed");
-    }
+  }
 }
 
 # Now move these bugs out of our radar.
 
 $sel->click_ok("link=My bugs from QA_Selenium");
-check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/buglist.cgi?cmdtype=runnamed&namedcmd=My%20bugs%20from%20QA_Selenium&list_id=21});
+check_page_load($sel, WAIT_TIME,
+  q{http://HOSTNAME:8000/bmo/buglist.cgi?cmdtype=runnamed&namedcmd=My%20bugs%20from%20QA_Selenium&list_id=21}
+);
 $sel->title_is("Bug List: My bugs from QA_Selenium");
 $sel->is_text_present_ok("2 bugs found");
 $sel->click_ok("link=Change Several Bugs at Once");
-check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/buglist.cgi?email1=admin%40mozilla.test&email2=QA-Selenium-TEST%40mozilla.test&emailassigned_to1=1&emailassigned_to2=1&emailcc2=1&emailqa_contact2=1&emailreporter2=1&emailtype1=exact&emailtype2=exact&product=TestProduct&query_format=advanced&order=priority%2Cbug_severity&tweak=1&list_id=22});
+check_page_load($sel, WAIT_TIME,
+  q{http://HOSTNAME:8000/bmo/buglist.cgi?email1=admin%40mozilla.test&email2=QA-Selenium-TEST%40mozilla.test&emailassigned_to1=1&emailassigned_to2=1&emailcc2=1&emailqa_contact2=1&emailreporter2=1&emailtype1=exact&emailtype2=exact&product=TestProduct&query_format=advanced&order=priority%2Cbug_severity&tweak=1&list_id=22}
+);
 $sel->title_is("Bug List");
 $sel->click_ok("check_all");
-$sel->type_ok("comment", "Reassigning to the reporter");
+$sel->type_ok("comment",     "Reassigning to the reporter");
 $sel->type_ok("assigned_to", $config->{QA_Selenium_TEST_user_login});
 $sel->click_ok("commit");
 check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/process_bug.cgi});
@@ -486,10 +588,14 @@ $sel->title_is("Bugs processed");
 # Now delete the saved search.
 
 $sel->click_ok("link=My bugs from QA_Selenium");
-check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/buglist.cgi?cmdtype=runnamed&namedcmd=My%20bugs%20from%20QA_Selenium&list_id=23});
+check_page_load($sel, WAIT_TIME,
+  q{http://HOSTNAME:8000/bmo/buglist.cgi?cmdtype=runnamed&namedcmd=My%20bugs%20from%20QA_Selenium&list_id=23}
+);
 $sel->title_is("Bug List: My bugs from QA_Selenium");
 $sel->click_ok("link=Forget Search 'My bugs from QA_Selenium'");
-check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/buglist.cgi?cmdtype=dorem&remaction=forget&namedcmd=My%20bugs%20from%20QA_Selenium&token=1531926582-f228fa8ebc2f2b3970f2a791e54534ec&list_id=24});
+check_page_load($sel, WAIT_TIME,
+  q{http://HOSTNAME:8000/bmo/buglist.cgi?cmdtype=dorem&remaction=forget&namedcmd=My%20bugs%20from%20QA_Selenium&token=1531926582-f228fa8ebc2f2b3970f2a791e54534ec&list_id=24}
+);
 $sel->title_is("Search is gone");
 $sel->is_text_present_ok("OK, the My bugs from QA_Selenium search is gone");
 
@@ -498,14 +604,16 @@ clear_canedit_on_testproduct($sel, $master_gid);
 logout($sel);
 
 sub clear_canedit_on_testproduct {
-    my ($sel, $master_gid) = @_;
-
-    edit_product($sel, "TestProduct");
-    $sel->click_ok("link=Edit Group Access Controls:");
-check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/editproducts.cgi?action=editgroupcontrols&product=TestProduct});
-    $sel->title_is("Edit Group Controls for TestProduct");
-    $sel->uncheck_ok("canedit_$master_gid");
-    $sel->click_ok("submit");
-check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/editproducts.cgi});
-    $sel->title_is("Update group access controls for TestProduct");
+  my ($sel, $master_gid) = @_;
+
+  edit_product($sel, "TestProduct");
+  $sel->click_ok("link=Edit Group Access Controls:");
+  check_page_load($sel, WAIT_TIME,
+    q{http://HOSTNAME:8000/bmo/editproducts.cgi?action=editgroupcontrols&product=TestProduct}
+  );
+  $sel->title_is("Edit Group Controls for TestProduct");
+  $sel->uncheck_ok("canedit_$master_gid");
+  $sel->click_ok("submit");
+  check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/editproducts.cgi});
+  $sel->title_is("Update group access controls for TestProduct");
 }
index 95f401e663a5351284679874b54601199ca6416c..6320df65235a2008c024155a3991703c046199da 100644 (file)
@@ -16,11 +16,14 @@ use QA::Util;
 my ($sel, $config) = get_selenium();
 
 log_in($sel, $config, 'admin');
-set_parameters($sel, { "Bug Change Policies" => {"letsubmitterchoosepriority-off" => undef} });
+set_parameters($sel,
+  {"Bug Change Policies" => {"letsubmitterchoosepriority-off" => undef}});
 file_bug_in_product($sel, "TestProduct");
 ok(!$sel->is_text_present("Priority"), "The Priority label is not present");
-ok(!$sel->is_element_present("//select[\@name='priority']"), "The Priority drop-down menu is not present");
-set_parameters($sel, { "Bug Change Policies" => {"letsubmitterchoosepriority-on" => undef} });
+ok(!$sel->is_element_present("//select[\@name='priority']"),
+  "The Priority drop-down menu is not present");
+set_parameters($sel,
+  {"Bug Change Policies" => {"letsubmitterchoosepriority-on" => undef}});
 file_bug_in_product($sel, "TestProduct");
 $sel->is_text_present_ok("Priority");
 $sel->is_element_present_ok("//select[\@name='priority']");
index e9ea18ab9119e8ef7fcdd85ee73836fe584914b5..a9ac8f5a7b50fc7c8a88c314c4642d52cc439082 100644 (file)
@@ -18,7 +18,7 @@ my ($sel, $config) = get_selenium();
 # Enable classifications
 
 log_in($sel, $config, 'admin');
-set_parameters($sel, { "Bug Fields" => {"useclassification-on" => undef} });
+set_parameters($sel, {"Bug Fields" => {"useclassification-on" => undef}});
 
 # Create a new classification.
 
@@ -31,25 +31,29 @@ $sel->title_is("Select classification");
 # Accessing action=delete directly must 1) trigger the security check page,
 # and 2) automatically reclassify products in this classification.
 if ($sel->is_text_present("cone")) {
-    $sel->open_ok("/$config->{bugzilla_installation}/editclassifications.cgi?action=delete&amp;classification=cone");
-    $sel->title_is("Suspicious Action");
-    $sel->click_ok("confirm");
-    $sel->wait_for_page_to_load_ok(WAIT_TIME);
-    $sel->title_is("Classification Deleted");
+  $sel->open_ok(
+    "/$config->{bugzilla_installation}/editclassifications.cgi?action=delete&amp;classification=cone"
+  );
+  $sel->title_is("Suspicious Action");
+  $sel->click_ok("confirm");
+  $sel->wait_for_page_to_load_ok(WAIT_TIME);
+  $sel->title_is("Classification Deleted");
 }
 if ($sel->is_text_present("ctwo")) {
-    $sel->open_ok("/$config->{bugzilla_installation}/editclassifications.cgi?action=delete&amp;classification=ctwo");
-    $sel->title_is("Suspicious Action");
-    $sel->click_ok("confirm");
-    $sel->wait_for_page_to_load_ok(WAIT_TIME);
-    $sel->title_is("Classification Deleted");
+  $sel->open_ok(
+    "/$config->{bugzilla_installation}/editclassifications.cgi?action=delete&amp;classification=ctwo"
+  );
+  $sel->title_is("Suspicious Action");
+  $sel->click_ok("confirm");
+  $sel->wait_for_page_to_load_ok(WAIT_TIME);
+  $sel->title_is("Classification Deleted");
 }
 
 $sel->click_ok("link=Add");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Add new classification");
 $sel->type_ok("classification", "cone");
-$sel->type_ok("description", "Classification number 1");
+$sel->type_ok("description",    "Classification number 1");
 $sel->click_ok('//input[@type="submit" and @value="Add"]');
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("New Classification Created");
@@ -62,7 +66,8 @@ $sel->click_ok("add_products");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Reclassify products");
 my @products = $sel->get_select_options("myprodlist");
-ok(scalar @products == 1 && $products[0] eq 'TestProduct', "TestProduct successfully added to 'cone'");
+ok(scalar @products == 1 && $products[0] eq 'TestProduct',
+  "TestProduct successfully added to 'cone'");
 
 # Create a new bug in this product/classification.
 
@@ -72,7 +77,8 @@ $sel->type_ok("comment", "Created by Selenium with classifications turned on");
 $sel->click_ok("commit");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 my $bug1_id = $sel->get_value('//input[@name="id" and @type="hidden"]');
-$sel->is_text_present_ok('has been added to the database', "Bug $bug1_id created");
+$sel->is_text_present_ok('has been added to the database',
+  "Bug $bug1_id created");
 
 # Rename 'cone' to 'Unclassified', which must be rejected as it already exists,
 # then to 'ctwo', which is not yet in use. Should work fine, even with products
@@ -109,18 +115,23 @@ go_to_admin($sel);
 $sel->click_ok("link=Classifications");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Select classification");
-$sel->click_ok('//a[contains(@href,"/editclassifications.cgi?action=del&classification=ctwo")]');
+$sel->click_ok(
+  '//a[contains(@href,"/editclassifications.cgi?action=del&classification=ctwo")]'
+);
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Error");
 my $error = trim($sel->get_text("error_msg"));
-ok($error =~ /there are products for this classification/, "Reject classification deletion");
+ok($error =~ /there are products for this classification/,
+  "Reject classification deletion");
 
 # Reclassify the product before deleting the classification.
 
 $sel->go_back_ok();
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Select classification");
-$sel->click_ok('//a[contains(@href,"/editclassifications.cgi?action=reclassify&classification=ctwo")]');
+$sel->click_ok(
+  '//a[contains(@href,"/editclassifications.cgi?action=reclassify&classification=ctwo")]'
+);
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Reclassify products");
 $sel->add_selection_ok("myprodlist", "label=TestProduct");
@@ -130,7 +141,9 @@ $sel->title_is("Reclassify products");
 $sel->click_ok("link=edit");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Select classification");
-$sel->click_ok('//a[contains(@href,"/editclassifications.cgi?action=del&classification=ctwo")]');
+$sel->click_ok(
+  '//a[contains(@href,"/editclassifications.cgi?action=del&classification=ctwo")]'
+);
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Delete classification");
 $sel->is_text_present_ok("Do you really want to delete this classification?");
@@ -140,7 +153,7 @@ $sel->title_is("Classification Deleted");
 
 # Disable classifications and make sure you cannot edit them anymore.
 
-set_parameters($sel, { "Bug Fields" => {"useclassification-off" => undef} });
+set_parameters($sel, {"Bug Fields" => {"useclassification-off" => undef}});
 $sel->open_ok("/$config->{bugzilla_installation}/editclassifications.cgi");
 $sel->title_is("Classification Not Enabled");
 logout($sel);
index ef1d8d89813dc4c0caef5429b0855492e008b805..7ad97190a707f6a698adf4a30291db3c7d420550 100644 (file)
@@ -18,12 +18,13 @@ my ($sel, $config) = get_selenium();
 # Turn on 'requirelogin' and log out.
 
 log_in($sel, $config, 'admin');
-set_parameters($sel, { "User Authentication" => {"requirelogin-on" => undef} });
+set_parameters($sel, {"User Authentication" => {"requirelogin-on" => undef}});
 logout($sel);
 
 # Accessing config.cgi should display no sensitive data.
 
-$sel->open_ok("/$config->{bugzilla_installation}/config.cgi", undef, "Go to config.cgi (JS format)");
+$sel->open_ok("/$config->{bugzilla_installation}/config.cgi",
+  undef, "Go to config.cgi (JS format)");
 $sel->is_text_present_ok("var status = [ ];");
 $sel->is_text_present_ok("var status_open = [ ];");
 $sel->is_text_present_ok("var status_closed = [ ];");
@@ -33,13 +34,14 @@ $sel->is_text_present_ok("var platform = [ ];");
 $sel->is_text_present_ok("var severity = [ ];");
 $sel->is_text_present_ok("var field = [\n];");
 
-ok(!$sel->is_text_present("cf_"), "No custom field displayed");
+ok(!$sel->is_text_present("cf_"),        "No custom field displayed");
 ok(!$sel->is_text_present("component["), "No component displayed");
-ok(!$sel->is_text_present("version["), "No version displayed");
-ok(!$sel->is_text_present("target_milestone["), "No target milestone displayed");
+ok(!$sel->is_text_present("version["),   "No version displayed");
+ok(!$sel->is_text_present("target_milestone["),
+  "No target milestone displayed");
 
 # Turn on 'requirelogin' and log out.
 
 log_in($sel, $config, 'admin');
-set_parameters($sel, { "User Authentication" => {"requirelogin-off" => undef} });
+set_parameters($sel, {"User Authentication" => {"requirelogin-off" => undef}});
 logout($sel);
index ba0f396711555ad60e2fa68d7537e5bdcbb9daf0..25f93ba65f09f7d1db0e6b29e6dafcdb47b56f47 100644 (file)
@@ -18,7 +18,13 @@ my ($sel, $config) = get_selenium();
 # Set the email regexp for new bugzilla accounts to end with @bugzilla.test.
 
 log_in($sel, $config, 'admin');
-set_parameters($sel, { "User Authentication" => {"createemailregexp" => {type => "text", value => '[^@]+@bugzilla\.test$'}} });
+set_parameters(
+  $sel,
+  {
+    "User Authentication" =>
+      {"createemailregexp" => {type => "text", value => '[^@]+@bugzilla\.test$'}}
+  }
+);
 logout($sel);
 
 # Create a valid account. We need to randomize the login address, because a request
@@ -50,58 +56,69 @@ $sel->click_ok('//input[@value="Create Account"]');
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Too Soon For New Token");
 my $error_msg = trim($sel->get_text("error_msg"));
-ok($error_msg =~ /Please wait a while and try again/, "Too soon for this account");
+ok($error_msg =~ /Please wait a while and try again/,
+  "Too soon for this account");
 
 # These accounts do not pass the regexp.
-my @accounts = ('test@yahoo.com', 'test@bugzilla.net', 'test@bugzilla.test.com');
+my @accounts
+  = ('test@yahoo.com', 'test@bugzilla.net', 'test@bugzilla.test.com');
 foreach my $account (@accounts) {
-    $sel->click_ok("link=New Account");
-    $sel->wait_for_page_to_load_ok(WAIT_TIME);
-    $sel->title_is("Create a new Bugzilla account");
-    $sel->type_ok("login", $account);
-    $sel->check_ok("etiquette", "Agree to abide by code of conduct");
-    $sel->click_ok('//input[@value="Create Account"]');
-    $sel->wait_for_page_to_load_ok(WAIT_TIME);
-    $sel->title_is("Account Creation Restricted");
-    $sel->is_text_present_ok("User account creation has been restricted.");
+  $sel->click_ok("link=New Account");
+  $sel->wait_for_page_to_load_ok(WAIT_TIME);
+  $sel->title_is("Create a new Bugzilla account");
+  $sel->type_ok("login", $account);
+  $sel->check_ok("etiquette", "Agree to abide by code of conduct");
+  $sel->click_ok('//input[@value="Create Account"]');
+  $sel->wait_for_page_to_load_ok(WAIT_TIME);
+  $sel->title_is("Account Creation Restricted");
+  $sel->is_text_present_ok("User account creation has been restricted.");
 }
 
 # These accounts are illegal and should cause a javascript alert.
 @accounts = qw(
-    test\bugzilla@bugzilla.test
-    testbugzilla.test
-    test@bugzilla
-    test@bugzilla.
-    'test'@bugzilla.test
-    test&test@bugzilla.test
-    [test]@bugzilla.test
+  test\bugzilla@bugzilla.test
+  testbugzilla.test
+  test@bugzilla
+  test@bugzilla.
+  'test'@bugzilla.test
+  test&test@bugzilla.test
+  [test]@bugzilla.test
 );
+
 foreach my $account (@accounts) {
-    $sel->click_ok("link=New Account");
-    $sel->wait_for_page_to_load_ok(WAIT_TIME);
-    $sel->title_is("Create a new Bugzilla account");
-    $sel->type_ok("login", $account);
-    $sel->check_ok("etiquette", "Agree to abide by code of conduct");
-    $sel->click_ok('//input[@value="Create Account"]');
-    ok($sel->get_alert() =~ /The e-mail address doesn't pass our syntax checking for a legal email address/,
-        'Invalid email address detected');
+  $sel->click_ok("link=New Account");
+  $sel->wait_for_page_to_load_ok(WAIT_TIME);
+  $sel->title_is("Create a new Bugzilla account");
+  $sel->type_ok("login", $account);
+  $sel->check_ok("etiquette", "Agree to abide by code of conduct");
+  $sel->click_ok('//input[@value="Create Account"]');
+  ok(
+    $sel->get_alert()
+      =~ /The e-mail address doesn't pass our syntax checking for a legal email address/,
+    'Invalid email address detected'
+  );
 }
 
 # These accounts are illegal but do not cause a javascript alert
 @accounts = ('test@bugzilla.org@bugzilla.test', 'test@bugzilla..test');
+
 # Logins larger than 127 characters must be rejected, for security reasons.
 push @accounts, 'selenium-' . random_string(110) . '@bugzilla.test';
 foreach my $account (@accounts) {
-    $sel->click_ok("link=New Account");
-    $sel->wait_for_page_to_load_ok(WAIT_TIME);
-    $sel->title_is("Create a new Bugzilla account");
-    $sel->type_ok("login", $account);
-    $sel->check_ok("etiquette", "Agree to abide by code of conduct");
-    $sel->click_ok('//input[@value="Create Account"]');
-    $sel->wait_for_page_to_load_ok(WAIT_TIME);
-    $sel->title_is("Invalid Email Address");
-    my $error_msg = trim($sel->get_text("error_msg"));
-    ok($error_msg =~ /^The e-mail address you entered (\S+) didn't pass our syntax checking/, "Invalid email address detected");
+  $sel->click_ok("link=New Account");
+  $sel->wait_for_page_to_load_ok(WAIT_TIME);
+  $sel->title_is("Create a new Bugzilla account");
+  $sel->type_ok("login", $account);
+  $sel->check_ok("etiquette", "Agree to abide by code of conduct");
+  $sel->click_ok('//input[@value="Create Account"]');
+  $sel->wait_for_page_to_load_ok(WAIT_TIME);
+  $sel->title_is("Invalid Email Address");
+  my $error_msg = trim($sel->get_text("error_msg"));
+  ok(
+    $error_msg
+      =~ /^The e-mail address you entered (\S+) didn't pass our syntax checking/,
+    "Invalid email address detected"
+  );
 }
 
 # This account already exists.
@@ -114,11 +131,20 @@ $sel->click_ok('//input[@value="Create Account"]');
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Account Already Exists");
 $error_msg = trim($sel->get_text("error_msg"));
-ok($error_msg eq "There is already an account with the login name $config->{admin_user_login}.", "Account already exists");
+ok(
+  $error_msg eq
+    "There is already an account with the login name $config->{admin_user_login}.",
+  "Account already exists"
+);
 
 # Turn off user account creation.
 log_in($sel, $config, 'admin');
-set_parameters($sel, { "User Authentication" => {"createemailregexp" => {type => "text", value => ''}} });
+set_parameters(
+  $sel,
+  {
+    "User Authentication" => {"createemailregexp" => {type => "text", value => ''}}
+  }
+);
 logout($sel);
 
 # Make sure that links pointing to createaccount.cgi are all deactivated.
@@ -132,13 +158,22 @@ ok(!$sel->is_text_present("New Account"), "No link named 'New Account'");
 $sel->open_ok("/$config->{bugzilla_installation}/createaccount.cgi");
 $sel->title_is("Account Creation Disabled");
 $error_msg = trim($sel->get_text("error_msg"));
-ok($error_msg =~ /^User account creation has been disabled. New accounts must be created by an administrator/,
-   "User account creation disabled");
+ok(
+  $error_msg
+    =~ /^User account creation has been disabled. New accounts must be created by an administrator/,
+  "User account creation disabled"
+);
 
 # Re-enable user account creation.
 
 log_in($sel, $config, 'admin');
-set_parameters($sel, { "User Authentication" => {"createemailregexp" => {type => "text", value => '.*'}} });
+set_parameters(
+  $sel,
+  {
+    "User Authentication" =>
+      {"createemailregexp" => {type => "text", value => '.*'}}
+  }
+);
 
 # Make sure selenium-<random_string>@bugzilla.test has not be added to the DB yet.
 go_to_admin($sel);
index d08e23eb064e4ca602f91799cd42749e6409a741..85f2fe3a23cf6753d01da090e36b4378fbb485fe 100644 (file)
@@ -21,7 +21,8 @@ log_in($sel, $config, 'admin');
 file_bug_in_product($sel, 'TestProduct');
 my $bug_summary = "What's your ID?";
 $sel->type_ok("short_desc", $bug_summary);
-$sel->type_ok("comment", "Use the ID of this bug to generate a unique custom field name.");
+$sel->type_ok("comment",
+  "Use the ID of this bug to generate a unique custom field name.");
 $sel->type_ok("bug_severity", "label=normal");
 my $bug1_id = create_bug($sel, $bug_summary);
 
@@ -38,13 +39,16 @@ $sel->type_ok("name", "cf_qa_freetext_$bug1_id");
 $sel->type_ok("desc", "Freetext$bug1_id");
 $sel->select_ok("type", "label=Free Text");
 $sel->type_ok("sortkey", $bug1_id);
+
 # These values are off by default.
 $sel->value_is("enter_bug", "off");
-$sel->value_is("obsolete", "off");
+$sel->value_is("obsolete",  "off");
 $sel->click_ok("create");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Custom Field Created");
-$sel->is_text_present_ok("The new custom field 'cf_qa_freetext_$bug1_id' has been successfully created.");
+$sel->is_text_present_ok(
+  "The new custom field 'cf_qa_freetext_$bug1_id' has been successfully created."
+);
 
 $sel->click_ok("link=Add a new custom field");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
@@ -58,11 +62,12 @@ $sel->value_is("enter_bug", "on");
 $sel->click_ok("new_bugmail");
 sleep 10;
 $sel->value_is("new_bugmail", "on");
-$sel->value_is("obsolete", "off");
+$sel->value_is("obsolete",    "off");
 $sel->click_ok("create");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Custom Field Created");
-$sel->is_text_present_ok("The new custom field 'cf_qa_list_$bug1_id' has been successfully created.");
+$sel->is_text_present_ok(
+  "The new custom field 'cf_qa_list_$bug1_id' has been successfully created.");
 
 $sel->click_ok("link=Add a new custom field");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
@@ -70,15 +75,16 @@ $sel->title_is("Add a new Custom Field");
 $sel->type_ok("name", "cf_qa_bugid_$bug1_id");
 $sel->type_ok("desc", "Reference$bug1_id");
 $sel->select_ok("type", "label=Bug ID");
-$sel->type_ok("sortkey", $bug1_id);
+$sel->type_ok("sortkey",      $bug1_id);
 $sel->type_ok("reverse_desc", "IsRef$bug1_id");
 $sel->click_ok("enter_bug");
 $sel->value_is("enter_bug", "on");
-$sel->value_is("obsolete", "off");
+$sel->value_is("obsolete",  "off");
 $sel->click_ok("create");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Custom Field Created");
-$sel->is_text_present_ok("The new custom field 'cf_qa_bugid_$bug1_id' has been successfully created.");
+$sel->is_text_present_ok(
+  "The new custom field 'cf_qa_bugid_$bug1_id' has been successfully created.");
 
 # Add values to the custom fields.
 
@@ -87,27 +93,32 @@ $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Edit the Custom Field 'cf_qa_list_$bug1_id' (List$bug1_id)");
 $sel->click_ok("link=Edit legal values for this field");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
-$sel->title_is("Select value for the 'List$bug1_id' (cf_qa_list_$bug1_id) field");
+$sel->title_is(
+  "Select value for the 'List$bug1_id' (cf_qa_list_$bug1_id) field");
 
 $sel->click_ok("link=Add");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Add Value for the 'List$bug1_id' (cf_qa_list_$bug1_id) field");
-$sel->type_ok("value", "have fun?");
+$sel->type_ok("value",   "have fun?");
 $sel->type_ok("sortkey", "805");
 $sel->click_ok("create");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("New Field Value Created");
-$sel->is_text_present_ok("The value have fun? has been added as a valid choice for the List$bug1_id (cf_qa_list_$bug1_id) field.");
+$sel->is_text_present_ok(
+  "The value have fun? has been added as a valid choice for the List$bug1_id (cf_qa_list_$bug1_id) field."
+);
 
 $sel->click_ok("link=Add");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Add Value for the 'List$bug1_id' (cf_qa_list_$bug1_id) field");
-$sel->type_ok("value", "storage");
+$sel->type_ok("value",   "storage");
 $sel->type_ok("sortkey", "49");
 $sel->click_ok("create");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("New Field Value Created");
-$sel->is_text_present_ok("The value storage has been added as a valid choice for the List$bug1_id (cf_qa_list_$bug1_id) field.");
+$sel->is_text_present_ok(
+  "The value storage has been added as a valid choice for the List$bug1_id (cf_qa_list_$bug1_id) field."
+);
 
 # Also create a new bug status and a new resolution.
 
@@ -121,7 +132,7 @@ $sel->title_is("Select value for the 'Resolution' (resolution) field");
 $sel->click_ok("link=Add");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Add Value for the 'Resolution' (resolution) field");
-$sel->type_ok("value", "UPSTREAM");
+$sel->type_ok("value",   "UPSTREAM");
 $sel->type_ok("sortkey", 450);
 $sel->click_ok("create");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
@@ -137,7 +148,7 @@ $sel->title_is("Select value for the 'Status' (bug_status) field");
 $sel->click_ok("link=Add");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Add Value for the 'Status' (bug_status) field");
-$sel->type_ok("value", "SUSPENDED");
+$sel->type_ok("value",   "SUSPENDED");
 $sel->type_ok("sortkey", 250);
 $sel->click_ok("open_status");
 $sel->click_ok("create");
@@ -147,7 +158,7 @@ $sel->title_is("New Field Value Created");
 $sel->click_ok("link=Add");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Add Value for the 'Status' (bug_status) field");
-$sel->type_ok("value", "IN_QA");
+$sel->type_ok("value",   "IN_QA");
 $sel->type_ok("sortkey", 550);
 $sel->click_ok("closed_status");
 $sel->click_ok("create");
@@ -157,13 +168,20 @@ $sel->title_is("New Field Value Created");
 $sel->click_ok("link=status workflow page");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Edit Workflow");
-$sel->click_ok('//td[@title="From UNCONFIRMED to SUSPENDED"]//input[@type="checkbox"]');
-$sel->click_ok('//td[@title="From CONFIRMED to SUSPENDED"]//input[@type="checkbox"]');
-$sel->click_ok('//td[@title="From SUSPENDED to CONFIRMED"]//input[@type="checkbox"]');
-$sel->click_ok('//td[@title="From SUSPENDED to IN_PROGRESS"]//input[@type="checkbox"]');
-$sel->click_ok('//td[@title="From RESOLVED to IN_QA"]//input[@type="checkbox"]');
-$sel->click_ok('//td[@title="From IN_QA to VERIFIED"]//input[@type="checkbox"]');
-$sel->click_ok('//td[@title="From IN_QA to CONFIRMED"]//input[@type="checkbox"]');
+$sel->click_ok(
+  '//td[@title="From UNCONFIRMED to SUSPENDED"]//input[@type="checkbox"]');
+$sel->click_ok(
+  '//td[@title="From CONFIRMED to SUSPENDED"]//input[@type="checkbox"]');
+$sel->click_ok(
+  '//td[@title="From SUSPENDED to CONFIRMED"]//input[@type="checkbox"]');
+$sel->click_ok(
+  '//td[@title="From SUSPENDED to IN_PROGRESS"]//input[@type="checkbox"]');
+$sel->click_ok(
+  '//td[@title="From RESOLVED to IN_QA"]//input[@type="checkbox"]');
+$sel->click_ok(
+  '//td[@title="From IN_QA to VERIFIED"]//input[@type="checkbox"]');
+$sel->click_ok(
+  '//td[@title="From IN_QA to CONFIRMED"]//input[@type="checkbox"]');
 $sel->click_ok('//input[@value="Commit Changes"]');
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Edit Workflow");
@@ -175,13 +193,19 @@ $sel->is_text_present_ok("List$bug1_id:");
 $sel->is_element_present_ok("cf_qa_list_$bug1_id");
 $sel->is_text_present_ok("Reference$bug1_id:");
 $sel->is_element_present_ok("cf_qa_bugid_$bug1_id");
-ok(!$sel->is_text_present("Freetext$bug1_id:"), "Freetext$bug1_id is not displayed");
-ok(!$sel->is_element_present("cf_qa_freetext_$bug1_id"), "cf_qa_freetext_$bug1_id is not available");
+ok(
+  !$sel->is_text_present("Freetext$bug1_id:"),
+  "Freetext$bug1_id is not displayed"
+);
+ok(
+  !$sel->is_element_present("cf_qa_freetext_$bug1_id"),
+  "cf_qa_freetext_$bug1_id is not available"
+);
 my $bug_summary2 = "Et de un";
 $sel->type_ok("short_desc", $bug_summary2);
 $sel->select_ok("bug_severity", "critical");
 $sel->type_ok("cf_qa_bugid_$bug1_id", $bug1_id);
-$sel->type_ok("comment", "hops!");
+$sel->type_ok("comment",              "hops!");
 my $bug2_id = create_bug($sel, $bug_summary2);
 
 # Both fields are editable.
@@ -257,27 +281,32 @@ $sel->click_ok("link=cf_qa_list_$bug1_id");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Edit the Custom Field 'cf_qa_list_$bug1_id' (List$bug1_id)");
 $sel->select_ok("visibility_field_id", "label=Severity (bug_severity)");
-$sel->select_ok("visibility_values", "label=critical");
+$sel->select_ok("visibility_values",   "label=critical");
 $sel->click_ok("edit");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Custom Field Updated");
 
 go_to_bug($sel, $bug1_id);
-$sel->is_element_present_ok("cf_qa_list_$bug1_id", "List$bug1_id is in the DOM of the page...");
-ok(!$sel->is_visible("cf_qa_list_$bug1_id"), "... but is not displayed with severity = 'normal'");
+$sel->is_element_present_ok("cf_qa_list_$bug1_id",
+  "List$bug1_id is in the DOM of the page...");
+ok(!$sel->is_visible("cf_qa_list_$bug1_id"),
+  "... but is not displayed with severity = 'normal'");
 $sel->select_ok("bug_severity", "major");
 ok(!$sel->is_visible("cf_qa_list_$bug1_id"), "... nor with severity = 'major'");
 $sel->select_ok("bug_severity", "critical");
-$sel->is_visible_ok("cf_qa_list_$bug1_id", "... but is visible with severity = 'critical'");
+$sel->is_visible_ok("cf_qa_list_$bug1_id",
+  "... but is visible with severity = 'critical'");
 edit_bug_and_return($sel, $bug1_id, $bug_summary);
 $sel->is_visible_ok("cf_qa_list_$bug1_id");
 
 go_to_bug($sel, $bug2_id);
 $sel->is_visible_ok("cf_qa_list_$bug1_id");
 $sel->select_ok("bug_severity", "minor");
-ok(!$sel->is_visible("cf_qa_list_$bug1_id"), "List$bug1_id is not displayed with severity = 'minor'");
+ok(!$sel->is_visible("cf_qa_list_$bug1_id"),
+  "List$bug1_id is not displayed with severity = 'minor'");
 edit_bug_and_return($sel, $bug2_id, $bug_summary2);
-ok(!$sel->is_visible("cf_qa_list_$bug1_id"), "List$bug1_id is not displayed with severity = 'minor'");
+ok(!$sel->is_visible("cf_qa_list_$bug1_id"),
+  "List$bug1_id is not displayed with severity = 'minor'");
 
 # Add a new value which is only listed under some condition.
 
@@ -297,11 +326,12 @@ $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Edit the Custom Field 'cf_qa_list_$bug1_id' (List$bug1_id)");
 $sel->click_ok("link=Edit legal values for this field");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
-$sel->title_is("Select value for the 'List$bug1_id' (cf_qa_list_$bug1_id) field");
+$sel->title_is(
+  "Select value for the 'List$bug1_id' (cf_qa_list_$bug1_id) field");
 $sel->click_ok("link=Add");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Add Value for the 'List$bug1_id' (cf_qa_list_$bug1_id) field");
-$sel->type_ok("value", "ghost");
+$sel->type_ok("value",   "ghost");
 $sel->type_ok("sortkey", "500");
 $sel->select_ok("visibility_value_id", "label=FIXED");
 $sel->click_ok("id=create");
@@ -313,8 +343,8 @@ my @labels = $sel->get_select_options("cf_qa_list_$bug1_id");
 ok(grep(/^ghost$/, @labels), "ghost is in the DOM of the page...");
 my $disabled = $sel->get_attribute("v4_cf_qa_list_$bug1_id\@disabled");
 ok($disabled, "... but is not available for selection by default");
-$sel->select_ok("bug_status", "label=RESOLVED");
-$sel->select_ok("resolution", "label=FIXED");
+$sel->select_ok("bug_status",          "label=RESOLVED");
+$sel->select_ok("resolution",          "label=FIXED");
 $sel->select_ok("cf_qa_list_$bug1_id", "label=ghost");
 edit_bug_and_return($sel, $bug1_id, $bug_summary);
 $sel->selected_label_is("cf_qa_list_$bug1_id", "ghost");
@@ -327,10 +357,14 @@ $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Edit values for which field?");
 $sel->click_ok("link=List$bug1_id");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
-$sel->title_is("Select value for the 'List$bug1_id' (cf_qa_list_$bug1_id) field");
-$sel->click_ok("//a[contains(\@href, '/editvalues.cgi?action=del&field=cf_qa_list_$bug1_id&value=have%20fun%3F')]");
+$sel->title_is(
+  "Select value for the 'List$bug1_id' (cf_qa_list_$bug1_id) field");
+$sel->click_ok(
+  "//a[contains(\@href, '/editvalues.cgi?action=del&field=cf_qa_list_$bug1_id&value=have%20fun%3F')]"
+);
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
-$sel->title_is("Delete Value 'have fun?' from the 'List$bug1_id' (cf_qa_list_$bug1_id) field");
+$sel->title_is(
+  "Delete Value 'have fun?' from the 'List$bug1_id' (cf_qa_list_$bug1_id) field");
 $sel->is_text_present_ok("Do you really want to delete this value?");
 $sel->click_ok("delete");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
@@ -338,9 +372,12 @@ $sel->title_is("Field Value Deleted");
 
 # This value cannot be deleted as it's in use.
 
-$sel->click_ok("//a[contains(\@href, '/editvalues.cgi?action=del&field=cf_qa_list_$bug1_id&value=storage')]");
+$sel->click_ok(
+  "//a[contains(\@href, '/editvalues.cgi?action=del&field=cf_qa_list_$bug1_id&value=storage')]"
+);
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
-$sel->title_is("Delete Value 'storage' from the 'List$bug1_id' (cf_qa_list_$bug1_id) field");
+$sel->title_is(
+  "Delete Value 'storage' from the 'List$bug1_id' (cf_qa_list_$bug1_id) field");
 $sel->is_text_present_ok("There is 1 bug with this field value");
 
 # Mark the <select> field as obsolete, making it unavailable in bug reports.
@@ -359,7 +396,8 @@ $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Custom Field Updated");
 go_to_bug($sel, $bug1_id);
 $sel->value_is("cf_qa_freetext_$bug1_id", "thanks");
-ok(!$sel->is_element_present("cf_qa_list_$bug1_id"), "The custom list is not visible");
+ok(!$sel->is_element_present("cf_qa_list_$bug1_id"),
+  "The custom list is not visible");
 
 # Custom fields are also viewable by logged out users.
 
@@ -387,7 +425,8 @@ $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Custom Fields");
 $sel->click_ok("link=cf_qa_freetext_$bug1_id");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
-$sel->title_is("Edit the Custom Field 'cf_qa_freetext_$bug1_id' (Freetext$bug1_id)");
+$sel->title_is(
+  "Edit the Custom Field 'cf_qa_freetext_$bug1_id' (Freetext$bug1_id)");
 $sel->click_ok("obsolete");
 $sel->value_is("obsolete", "on");
 $sel->click_ok("edit");
@@ -403,7 +442,9 @@ $sel->title_is("Edit values for which field?");
 $sel->click_ok("link=Status");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Select value for the 'Status' (bug_status) field");
-$sel->click_ok('//a[contains(@href,"/editvalues.cgi?action=del&field=bug_status&value=SUSPENDED")]');
+$sel->click_ok(
+  '//a[contains(@href,"/editvalues.cgi?action=del&field=bug_status&value=SUSPENDED")]'
+);
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Delete Value 'SUSPENDED' from the 'Status' (bug_status) field");
 $sel->is_text_present_ok("Sorry, but the 'SUSPENDED' value cannot be deleted");
@@ -426,21 +467,27 @@ $sel->title_is("Edit values for which field?");
 $sel->click_ok("link=Status");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Select value for the 'Status' (bug_status) field");
-$sel->click_ok('//a[contains(@href,"/editvalues.cgi?action=del&field=bug_status&value=SUSPENDED")]');
+$sel->click_ok(
+  '//a[contains(@href,"/editvalues.cgi?action=del&field=bug_status&value=SUSPENDED")]'
+);
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Delete Value 'SUSPENDED' from the 'Status' (bug_status) field");
 $sel->click_ok("delete");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Field Value Deleted");
-$sel->is_text_present_ok("The value SUSPENDED of the Status (bug_status) field has been deleted");
+$sel->is_text_present_ok(
+  "The value SUSPENDED of the Status (bug_status) field has been deleted");
 
-$sel->click_ok('//a[contains(@href,"/editvalues.cgi?action=del&field=bug_status&value=IN_QA")]');
+$sel->click_ok(
+  '//a[contains(@href,"/editvalues.cgi?action=del&field=bug_status&value=IN_QA")]'
+);
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Delete Value 'IN_QA' from the 'Status' (bug_status) field");
 $sel->click_ok("delete");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Field Value Deleted");
-$sel->is_text_present_ok("The value IN_QA of the Status (bug_status) field has been deleted");
+$sel->is_text_present_ok(
+  "The value IN_QA of the Status (bug_status) field has been deleted");
 
 go_to_admin($sel);
 $sel->click_ok("link=Field Values");
@@ -449,12 +496,16 @@ $sel->title_is("Edit values for which field?");
 $sel->click_ok("link=Resolution");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Select value for the 'Resolution' (resolution) field");
-$sel->click_ok('//a[contains(@href,"/editvalues.cgi?action=del&field=resolution&value=UPSTREAM")]');
+$sel->click_ok(
+  '//a[contains(@href,"/editvalues.cgi?action=del&field=resolution&value=UPSTREAM")]'
+);
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
-$sel->title_is("Delete Value 'UPSTREAM' from the 'Resolution' (resolution) field");
+$sel->title_is(
+  "Delete Value 'UPSTREAM' from the 'Resolution' (resolution) field");
 $sel->click_ok("delete");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Field Value Deleted");
-$sel->is_text_present_ok("The value UPSTREAM of the Resolution (resolution) field has been deleted");
+$sel->is_text_present_ok(
+  "The value UPSTREAM of the Resolution (resolution) field has been deleted");
 
 logout($sel);
index 58b83a86e53c272a22612a8c458596b11b0385e1..541793f6b743b038f50b9c0b51a821a7fcaf4e18 100644 (file)
@@ -24,30 +24,34 @@ $sel->click_ok("link=Custom Fields");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Custom Fields");
 
-my @types = ("Bug ID", "Large Text Box", "Free Text", "Multiple-Selection Box",
-             "Drop Down", "Date/Time");
+my @types = (
+  "Bug ID", "Large Text Box",
+  "Free Text", "Multiple-Selection Box",
+  "Drop Down", "Date/Time"
+);
 my $counter = int(rand(10000));
 
 foreach my $type (@types) {
-    my $fname = "cf_field" . ++$counter;
-    my $fdesc = "Field" . $counter;
-
-    $sel->click_ok("link=Add a new custom field");
-    $sel->wait_for_page_to_load_ok(WAIT_TIME);
-    $sel->title_is("Add a new Custom Field");
-    $sel->type_ok("name", $fname);
-    $sel->type_ok("desc", $fdesc);
-    $sel->select_ok("type", "label=$type");
-    $sel->click_ok("obsolete");
-    $sel->click_ok("create");
-    $sel->wait_for_page_to_load_ok(WAIT_TIME);
-    $sel->title_is("Custom Field Created");
-    $sel->click_ok("//a[contains(\@href,'/editfields.cgi?action=del&name=$fname')]");
-    $sel->wait_for_page_to_load_ok(WAIT_TIME);
-    $sel->title_is("Delete the Custom Field '$fname' ($fdesc)");
-    $sel->click_ok("link=Delete field '$fdesc'");
-    $sel->wait_for_page_to_load_ok(WAIT_TIME);
-    $sel->title_is("Custom Field Deleted");
+  my $fname = "cf_field" . ++$counter;
+  my $fdesc = "Field" . $counter;
+
+  $sel->click_ok("link=Add a new custom field");
+  $sel->wait_for_page_to_load_ok(WAIT_TIME);
+  $sel->title_is("Add a new Custom Field");
+  $sel->type_ok("name", $fname);
+  $sel->type_ok("desc", $fdesc);
+  $sel->select_ok("type", "label=$type");
+  $sel->click_ok("obsolete");
+  $sel->click_ok("create");
+  $sel->wait_for_page_to_load_ok(WAIT_TIME);
+  $sel->title_is("Custom Field Created");
+  $sel->click_ok(
+    "//a[contains(\@href,'/editfields.cgi?action=del&name=$fname')]");
+  $sel->wait_for_page_to_load_ok(WAIT_TIME);
+  $sel->title_is("Delete the Custom Field '$fname' ($fdesc)");
+  $sel->click_ok("link=Delete field '$fdesc'");
+  $sel->wait_for_page_to_load_ok(WAIT_TIME);
+  $sel->title_is("Custom Field Deleted");
 }
 
 logout($sel);
index 6956b86b808d84b0f43f1d67db167993e081a321..3c16087bf230e6ad6a105e8b252eceffb44deb25 100644 (file)
@@ -19,12 +19,12 @@ my ($sel, $config) = get_selenium();
 # it has automatically a group created for it with the same name.
 
 log_in($sel, $config, 'admin');
-set_parameters($sel, { "Group Security" => {"makeproductgroups-on" => undef} });
+set_parameters($sel, {"Group Security" => {"makeproductgroups-on" => undef}});
 add_product($sel);
-$sel->type_ok("product", "ready_to_die");
+$sel->type_ok("product",     "ready_to_die");
 $sel->type_ok("description", "will die");
-$sel->select_ok("security_group_id", "label=core-security");
-$sel->select_ok("default_op_sys_id", "Unspecified");
+$sel->select_ok("security_group_id",   "label=core-security");
+$sel->select_ok("default_op_sys_id",   "Unspecified");
 $sel->select_ok("default_platform_id", "Unspecified");
 $sel->click_ok('//input[@value="Add"]');
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
@@ -43,7 +43,8 @@ $sel->value_is("desc", "Access to bugs in the ready_to_die product");
 my @groups = $sel->get_select_options("members_remove");
 ok((grep { $_ eq 'admin' } @groups), "'admin' inherits group membership");
 @groups = $sel->get_select_options("bless_from_remove");
-ok((grep { $_ eq 'admin' } @groups), "'admin' inherits can bless group membership");
+ok((grep { $_ eq 'admin' } @groups),
+  "'admin' inherits can bless group membership");
 $sel->is_checked_ok("isactive");
 
 # Check that the automatically created product group has the membercontrol
@@ -53,15 +54,16 @@ edit_product($sel, "ready_to_die");
 $sel->click_ok("link=Edit Group Access Controls:");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Edit Group Controls for ready_to_die");
-$sel->value_is("entry_$group1_id", "off");
+$sel->value_is("entry_$group1_id",   "off");
 $sel->value_is("canedit_$group1_id", "off");
 $sel->selected_label_is("membercontrol_$group1_id", "Default");
-$sel->selected_label_is("othercontrol_$group1_id", "NA");
+$sel->selected_label_is("othercontrol_$group1_id",  "NA");
 
 edit_product($sel, "ready_to_die");
 $sel->go_back_ok();
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
-$sel->click_ok('//a[contains(@href,"/editproducts.cgi?action=del&product=ready_to_die")]');
+$sel->click_ok(
+  '//a[contains(@href,"/editproducts.cgi?action=del&product=ready_to_die")]');
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Delete Product 'ready_to_die'");
 $sel->click_ok("delete");
@@ -80,10 +82,10 @@ $sel->is_text_present_ok("Access to bugs in the ready_to_die product");
 # a new "ready_to_die_" one must be created.
 
 add_product($sel);
-$sel->type_ok("product", "ready_to_die");
+$sel->type_ok("product",     "ready_to_die");
 $sel->type_ok("description", "will die");
-$sel->select_ok("security_group_id", "label=core-security");
-$sel->select_ok("default_op_sys_id", "Unspecified");
+$sel->select_ok("security_group_id",   "label=core-security");
+$sel->select_ok("default_op_sys_id",   "Unspecified");
 $sel->select_ok("default_platform_id", "Unspecified");
 $sel->click_ok('//input[@value="Add"]');
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
@@ -103,7 +105,8 @@ $sel->value_is("desc", "Access to bugs in the ready_to_die product");
 @groups = $sel->get_select_options("members_remove");
 ok((grep { $_ eq 'admin' } @groups), "'admin' inherits group membership");
 @groups = $sel->get_select_options("bless_from_remove");
-ok((grep { $_ eq 'admin' } @groups), "'admin' inherits can bless group membership");
+ok((grep { $_ eq 'admin' } @groups),
+  "'admin' inherits can bless group membership");
 $sel->value_is("isactive", "on");
 
 # Check group settings. The old 'ready_to_die' group has no relationship
@@ -113,14 +116,14 @@ edit_product($sel, "ready_to_die");
 $sel->click_ok("link=Edit Group Access Controls:");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Edit Group Controls for ready_to_die");
-$sel->value_is("entry_$group1_id", "off");
-$sel->value_is("entry_$group2_id", "off");
+$sel->value_is("entry_$group1_id",   "off");
+$sel->value_is("entry_$group2_id",   "off");
 $sel->value_is("canedit_$group1_id", "off");
 $sel->value_is("canedit_$group2_id", "off");
 $sel->selected_label_is("membercontrol_$group1_id", "NA");
-$sel->selected_label_is("othercontrol_$group1_id", "NA");
+$sel->selected_label_is("othercontrol_$group1_id",  "NA");
 $sel->selected_label_is("membercontrol_$group2_id", "Default");
-$sel->selected_label_is("othercontrol_$group2_id", "NA");
+$sel->selected_label_is("othercontrol_$group2_id",  "NA");
 
 # Delete the ready_to_die_ group. It's bound to the ready_to_die product,
 # so the deletion requires explicit agreement from the admin.
@@ -129,7 +132,8 @@ go_to_admin($sel);
 $sel->click_ok("link=Groups");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Edit Groups");
-$sel->click_ok("//a[contains(\@href, '/editgroups.cgi?action=del&group=$group2_id')]");
+$sel->click_ok(
+  "//a[contains(\@href, '/editgroups.cgi?action=del&group=$group2_id')]");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Delete group");
 $sel->is_text_present_ok("This group is tied to the following products");
@@ -137,8 +141,10 @@ $sel->click_ok("delete");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Cannot Delete Group");
 my $text = trim($sel->get_text("error_msg"));
-ok($text =~ qr/All references to this group must be removed/,
-   "Group ready_to_die_ cannot be deleted as it is bound to a product");
+ok(
+  $text =~ qr/All references to this group must be removed/,
+  "Group ready_to_die_ cannot be deleted as it is bound to a product"
+);
 $sel->go_back_ok();
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Delete group");
@@ -147,12 +153,14 @@ $sel->click_ok("delete");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Group Deleted");
 $text = trim($sel->get_text("message"));
-ok($text =~ qr/The group ready_to_die_ has been deleted/, "Group ready_to_die_ has been deleted");
+ok($text =~ qr/The group ready_to_die_ has been deleted/,
+  "Group ready_to_die_ has been deleted");
 
 edit_product($sel, "ready_to_die");
 $sel->go_back_ok();
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
-$sel->click_ok('//a[contains(@href,"/editproducts.cgi?action=del&product=ready_to_die")]');
+$sel->click_ok(
+  '//a[contains(@href,"/editproducts.cgi?action=del&product=ready_to_die")]');
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Delete Product 'ready_to_die'");
 $sel->click_ok("delete");
@@ -162,12 +170,12 @@ $sel->title_is("Product Deleted");
 # Reset the makeproductgroups parameter. Now creating a new product must
 # not create a new group, nor bind any group with it.
 
-set_parameters($sel, { "Group Security" => {"makeproductgroups-off" => undef} });
+set_parameters($sel, {"Group Security" => {"makeproductgroups-off" => undef}});
 add_product($sel);
-$sel->type_ok("product", "ready_to_die");
+$sel->type_ok("product",     "ready_to_die");
 $sel->type_ok("description", "will die");
-$sel->select_ok("security_group_id", "label=core-security");
-$sel->select_ok("default_op_sys_id", "Unspecified");
+$sel->select_ok("security_group_id",   "label=core-security");
+$sel->select_ok("default_op_sys_id",   "Unspecified");
 $sel->select_ok("default_platform_id", "Unspecified");
 $sel->click_ok('//input[@value="Add"]');
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
@@ -180,10 +188,10 @@ $sel->title_is("Edit Product 'ready_to_die'");
 $sel->click_ok("link=Edit Group Access Controls:");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Edit Group Controls for ready_to_die");
-$sel->value_is("entry_$group1_id", "off");
+$sel->value_is("entry_$group1_id",   "off");
 $sel->value_is("canedit_$group1_id", "off");
 $sel->selected_label_is("membercontrol_$group1_id", "NA");
-$sel->selected_label_is("othercontrol_$group1_id", "NA");
+$sel->selected_label_is("othercontrol_$group1_id",  "NA");
 
 # Delete remaining groups and products.
 
@@ -192,19 +200,22 @@ $sel->click_ok("link=Groups");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Edit Groups");
 ok(!$sel->is_text_present('ready_to_die__'), 'No ready_to_die__ group created');
-$sel->click_ok("//a[contains(\@href, '/editgroups.cgi?action=del&group=$group1_id')]");
+$sel->click_ok(
+  "//a[contains(\@href, '/editgroups.cgi?action=del&group=$group1_id')]");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Delete group");
 $sel->click_ok("delete");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Group Deleted");
 $text = trim($sel->get_text("message"));
-ok($text =~ /The group ready_to_die has been deleted/, "Group ready_to_die has been deleted");
+ok($text =~ /The group ready_to_die has been deleted/,
+  "Group ready_to_die has been deleted");
 
 edit_product($sel, "ready_to_die");
 $sel->go_back_ok();
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
-$sel->click_ok('//a[contains(@href,"/editproducts.cgi?action=del&product=ready_to_die")]');
+$sel->click_ok(
+  '//a[contains(@href,"/editproducts.cgi?action=del&product=ready_to_die")]');
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Delete Product 'ready_to_die'");
 $sel->click_ok("delete");
index c054a4d0883a47cfb28bb5e2676b3a6892ee359a..1deefb84ecf3ef996a6fe6ae64989e2d7045ae0c 100644 (file)
@@ -21,15 +21,15 @@ log_in($sel, $config, 'admin');
 file_bug_in_product($sel, "TestProduct");
 my $bug_summary = "Dependency Checks";
 $sel->type_ok("short_desc", $bug_summary);
-$sel->type_ok("comment", "This bug is public");
+$sel->type_ok("comment",    "This bug is public");
 my $bug1_id = create_bug($sel, $bug_summary);
 
 file_bug_in_product($sel, "TestProduct");
 $sel->type_ok("alias", "secret_qa_bug_$bug1_id+1");
 my $bug_summary2 = "Big Ben";
 $sel->type_ok("short_desc", $bug_summary2);
-$sel->type_ok("comment", "This bug is private");
-$sel->type_ok("dependson", $bug1_id);
+$sel->type_ok("comment",    "This bug is private");
+$sel->type_ok("dependson",  $bug1_id);
 $sel->check_ok('//input[@name="groups" and @value="Master"]');
 my $bug2_id = create_bug($sel, $bug_summary2);
 
@@ -45,8 +45,11 @@ logout($sel);
 
 log_in($sel, $config, 'editbugs');
 go_to_bug($sel, $bug1_id);
-ok(!$sel->is_text_present("secret_qa_bug_$bug1_id+1"), "The alias of the private bug is not visible");
-$sel->select_ok("priority", "label=High");
+ok(
+  !$sel->is_text_present("secret_qa_bug_$bug1_id+1"),
+  "The alias of the private bug is not visible"
+);
+$sel->select_ok("priority",   "label=High");
 $sel->select_ok("bug_status", "VERIFIED");
 $sel->type_ok("comment", "Can I still edit this bug?");
 edit_bug($sel, $bug1_id);
index 7d6b80a4d6ce77cb8d93c1c22f5347ca7fe9a527..6848b444bdde3e3f25cd2d7410eebf8c41408ead 100644 (file)
@@ -15,15 +15,19 @@ use QA::Util;
 
 my ($sel, $config) = get_selenium();
 
-my $admin_user_login = $config->{admin_user_login};
+my $admin_user_login        = $config->{admin_user_login};
 my $unprivileged_user_login = $config->{unprivileged_user_login};
-my $permanent_user = $config->{permanent_user};
+my $permanent_user          = $config->{permanent_user};
 
 log_in($sel, $config, 'admin');
-set_parameters($sel, { "Bug Fields"              => {"useclassification-off" => undef,
-                                                     "usetargetmilestone-on" => undef},
-                       "Administrative Policies" => {"allowbugdeletion-on"   => undef}
-                     });
+set_parameters(
+  $sel,
+  {
+    "Bug Fields" =>
+      {"useclassification-off" => undef, "usetargetmilestone-on" => undef},
+    "Administrative Policies" => {"allowbugdeletion-on" => undef}
+  }
+);
 
 # Create a product and add components to it. Do some cleanup first
 # if the script failed during a previous run.
@@ -31,47 +35,55 @@ set_parameters($sel, { "Bug Fields"              => {"useclassification-off" =>
 go_to_admin($sel);
 $sel->click_ok("link=Products");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
+
 # No risk to get the "Select classification" page. We turned off useclassification.
 $sel->title_is("Select product");
 
 my $text = trim($sel->get_text("bugzilla-body"));
 if ($text =~ /(Kill me!|Kill me nicely)/) {
-    my $product = $1;
-    my $escaped_product = url_quote($product);
-    $sel->click_ok("//a[contains(\@href,'/editproducts.cgi?action=del&product=$escaped_product')]");
-    $sel->wait_for_page_to_load_ok(WAIT_TIME);
-    $sel->title_is("Delete Product '$product'");
-    $sel->click_ok("delete");
-    $sel->wait_for_page_to_load_ok(WAIT_TIME);
-    $sel->title_is("Product Deleted");
+  my $product         = $1;
+  my $escaped_product = url_quote($product);
+  $sel->click_ok(
+    "//a[contains(\@href,'/editproducts.cgi?action=del&product=$escaped_product')]"
+  );
+  $sel->wait_for_page_to_load_ok(WAIT_TIME);
+  $sel->title_is("Delete Product '$product'");
+  $sel->click_ok("delete");
+  $sel->wait_for_page_to_load_ok(WAIT_TIME);
+  $sel->title_is("Product Deleted");
 }
 
 $sel->click_ok("link=Add");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Add Product");
 $sel->type_ok("product", "Kill me!");
-$sel->type_ok("description", "I will disappear very soon. Do not add bugs to it.");
+$sel->type_ok("description",
+  "I will disappear very soon. Do not add bugs to it.");
 $sel->type_ok("defaultmilestone", "0.1a");
+
 # Since Bugzilla 4.0, the voting system is in an extension.
 if ($config->{test_extensions}) {
-    $sel->type_ok("votesperuser", "1");
-    $sel->type_ok("maxvotesperbug", "1");
-    $sel->type_ok("votestoconfirm", "10");
+  $sel->type_ok("votesperuser",   "1");
+  $sel->type_ok("maxvotesperbug", "1");
+  $sel->type_ok("votestoconfirm", "10");
 }
 $sel->type_ok("version", "0.1a");
-$sel->select_ok("security_group_id", "label=core-security");
-$sel->select_ok("default_op_sys_id", "Unspecified");
+$sel->select_ok("security_group_id",   "label=core-security");
+$sel->select_ok("default_op_sys_id",   "Unspecified");
 $sel->select_ok("default_platform_id", "Unspecified");
 $sel->click_ok('//input[@type="submit" and @value="Add"]');
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $text = trim($sel->get_text("message"));
-ok($text =~ /You will need to add at least one component before anyone can enter bugs against this product/,
-   "Display a reminder about missing components");
+ok(
+  $text
+    =~ /You will need to add at least one component before anyone can enter bugs against this product/,
+  "Display a reminder about missing components"
+);
 $sel->click_ok("link=add at least one component");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Add component to the Kill me! product");
-$sel->type_ok("component", "first comp");
-$sel->type_ok("description", "comp 1");
+$sel->type_ok("component",    "first comp");
+$sel->type_ok("description",  "comp 1");
 $sel->type_ok("initialowner", $admin_user_login);
 $sel->uncheck_ok("watch_user_auto");
 $sel->type_ok("watch_user", "first-comp\@kill-me.bugs");
@@ -80,15 +92,16 @@ $sel->click_ok("create");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Component Created");
 $text = trim($sel->get_text("message"));
-ok($text eq 'The component first comp has been created.', "Component successfully created");
+ok($text eq 'The component first comp has been created.',
+  "Component successfully created");
 
 # Try creating a second component with the same name.
 
 $sel->click_ok("link=Add");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Add component to the Kill me! product");
-$sel->type_ok("component", "first comp");
-$sel->type_ok("description", "comp 2");
+$sel->type_ok("component",    "first comp");
+$sel->type_ok("description",  "comp 2");
 $sel->type_ok("initialowner", $admin_user_login);
 $sel->uncheck_ok("watch_user_auto");
 $sel->type_ok("watch_user", "first-comp\@kill-me.bugs");
@@ -102,9 +115,10 @@ $sel->title_is("Component Already Exists");
 $sel->go_back_ok();
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->type_ok("component", "second comp");
+
 # FIXME - Re-enter the default assignee (regression due to bug 577574)
 $sel->type_ok("initialowner", $admin_user_login);
-$sel->type_ok("initialcc", $permanent_user);
+$sel->type_ok("initialcc",    $permanent_user);
 $sel->uncheck_ok("watch_user_auto");
 $sel->type_ok("watch_user", "second-comp\@kill-me.bugs");
 $sel->check_ok("watch_user_auto");
@@ -137,7 +151,7 @@ $sel->click_ok("link=Add");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Add Milestone to Product 'Kill me!'");
 $sel->type_ok("milestone", "0.2");
-$sel->type_ok("sortkey", "2");
+$sel->type_ok("sortkey",   "2");
 $sel->click_ok("create");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Milestone Created");
@@ -148,6 +162,7 @@ $sel->click_ok("link=Add");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Add Milestone to Product 'Kill me!'");
 $sel->type_ok("milestone", "0.1a");
+
 # Negative sortkeys are valid for milestones.
 $sel->type_ok("sortkey", "-2");
 $sel->click_ok("create");
@@ -163,33 +178,39 @@ $sel->title_is("Milestone Created");
 # Now create an UNCONFIRMED bug and add it to the newly created product.
 
 file_bug_in_product($sel, "Kill me!");
-$sel->select_ok("version", "label=0.1a");
+$sel->select_ok("version",   "label=0.1a");
 $sel->select_ok("component", "label=first comp");
+
 # UNCONFIRMED must be present.
 $sel->select_ok("bug_status", "label=UNCONFIRMED");
-$sel->type_ok("cc", $unprivileged_user_login);
+$sel->type_ok("cc",           $unprivileged_user_login);
 $sel->type_ok("bug_file_loc", "http://www.test.com");
-$sel->type_ok("short_desc", "test create/edit product properties");
-$sel->type_ok("comment", "this bug will soon be dead");
+$sel->type_ok("short_desc",   "test create/edit product properties");
+$sel->type_ok("comment",      "this bug will soon be dead");
 $sel->click_ok("commit");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->is_text_present_ok('has been added to the database', 'Bug created');
 my $bug1_id = $sel->get_value("//input[\@name='id' and \@type='hidden']");
 my @cc_list = $sel->get_select_options("cc");
-ok(grep($_ eq $unprivileged_user_login, @cc_list), "$unprivileged_user_login correctly added to the CC list");
-ok(!grep($_ eq $permanent_user, @cc_list), "$permanent_user not in the CC list for 'first comp' by default");
+ok(
+  grep($_ eq $unprivileged_user_login, @cc_list),
+  "$unprivileged_user_login correctly added to the CC list"
+);
+ok(!grep($_ eq $permanent_user, @cc_list),
+  "$permanent_user not in the CC list for 'first comp' by default");
 
 # File a second bug, and make sure users in the default CC list are added.
 file_bug_in_product($sel, "Kill me!");
-$sel->select_ok("version", "label=0.1a");
+$sel->select_ok("version",   "label=0.1a");
 $sel->select_ok("component", "label=second comp");
 $sel->type_ok("short_desc", "check default CC list");
-$sel->type_ok("comment", "is the CC list populated correctly?");
+$sel->type_ok("comment",    "is the CC list populated correctly?");
 $sel->click_ok("commit");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->is_text_present_ok('has been added to the database', 'Bug created');
 @cc_list = $sel->get_select_options("cc");
-ok(grep($_ eq $permanent_user, @cc_list), "$permanent_user in the CC list for 'second comp' by default");
+ok(grep($_ eq $permanent_user, @cc_list),
+  "$permanent_user in the CC list for 'second comp' by default");
 
 # Edit product properties and set votes_to_confirm to 0, which has
 # the side-effect to disable auto-confirmation (new behavior compared
@@ -197,67 +218,78 @@ ok(grep($_ eq $permanent_user, @cc_list), "$permanent_user in the CC list for 's
 
 edit_product($sel, "Kill me!");
 $sel->type_ok("product", "Kill me nicely");
-$sel->type_ok("description", "I will disappear very soon. Do not add bugs to it (except for testing).");
+$sel->type_ok("description",
+  "I will disappear very soon. Do not add bugs to it (except for testing).");
 $sel->select_ok("defaultmilestone", "label=0.2");
 if ($config->{test_extensions}) {
-    $sel->type_ok("votesperuser", "2");
-    $sel->type_ok("maxvotesperbug", 5);
-    $sel->type_ok("votestoconfirm", "0");
+  $sel->type_ok("votesperuser",   "2");
+  $sel->type_ok("maxvotesperbug", 5);
+  $sel->type_ok("votestoconfirm", "0");
 }
 $sel->click_ok('//input[@type="submit" and @value="Save Changes"]');
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Updating Product 'Kill me nicely'");
-$sel->is_text_present_ok("Updated product name from 'Kill me!' to 'Kill me nicely'");
+$sel->is_text_present_ok(
+  "Updated product name from 'Kill me!' to 'Kill me nicely'");
 $sel->is_text_present_ok("Updated description");
 $sel->is_text_present_ok("Updated default milestone");
 if ($config->{test_extensions}) {
-    $sel->is_text_present_ok("Updated votes per user");
-    $sel->is_text_present_ok("Updated maximum votes per bug");
-    $sel->is_text_present_ok("Updated number of votes needed to confirm a bug");
-    $text = trim($sel->get_text("bugzilla-body"));
-    # We use .{1} in place of the right arrow character, which fails otherwise.
-    ok($text =~ /Checking unconfirmed bugs in this product for any which now have sufficient votes\.{3} .{1}there were none/,
-       "No bugs confirmed by popular votes (votestoconfirm = 0 disables auto-confirmation)");
-
-    # Now set votestoconfirm to 2, vote for a bug, and then set
-    # this attribute back to 1, to trigger auto-confirmation.
-
-    $sel->click_ok("link=Kill me nicely");
-    $sel->wait_for_page_to_load_ok(WAIT_TIME);
-    $sel->title_is("Edit Product 'Kill me nicely'", "Display properties of Kill me nicely");
-    $sel->type_ok("votestoconfirm", 2);
-    $sel->click_ok('//input[@type="submit" and @value="Save Changes"]');
-    $sel->wait_for_page_to_load_ok(WAIT_TIME);
-    $sel->title_is("Updating Product 'Kill me nicely'");
-    $sel->is_text_present_ok("Updated number of votes needed to confirm a bug");
-
-    go_to_bug($sel, $bug1_id);
-    $sel->click_ok("link=vote");
-    $sel->wait_for_page_to_load_ok(WAIT_TIME);
-    $sel->title_is("Change Votes");
-    $sel->type_ok("bug_$bug1_id", 1);
-    $sel->click_ok("change");
-    $sel->wait_for_page_to_load_ok(WAIT_TIME);
-    $sel->title_is("Change Votes");
-    $sel->is_text_present_ok("The changes to your votes have been saved");
-
-    edit_product($sel, "Kill me nicely");
-    $sel->type_ok("votestoconfirm", 1);
-    $sel->click_ok('//input[@type="submit" and @value="Save Changes"]');
-    $sel->wait_for_page_to_load_ok(WAIT_TIME);
-    $sel->title_is("Updating Product 'Kill me nicely'");
-    $sel->is_text_present_ok("Updated number of votes needed to confirm a bug");
-    $text = trim($sel->get_text("bugzilla-body"));
-    ok($text =~ /Bug $bug1_id confirmed by number of votes/, "Bug $bug1_id is confirmed by popular votes");
+  $sel->is_text_present_ok("Updated votes per user");
+  $sel->is_text_present_ok("Updated maximum votes per bug");
+  $sel->is_text_present_ok("Updated number of votes needed to confirm a bug");
+  $text = trim($sel->get_text("bugzilla-body"));
+
+  # We use .{1} in place of the right arrow character, which fails otherwise.
+  ok(
+    $text
+      =~ /Checking unconfirmed bugs in this product for any which now have sufficient votes\.{3} .{1}there were none/,
+    "No bugs confirmed by popular votes (votestoconfirm = 0 disables auto-confirmation)"
+  );
+
+  # Now set votestoconfirm to 2, vote for a bug, and then set
+  # this attribute back to 1, to trigger auto-confirmation.
+
+  $sel->click_ok("link=Kill me nicely");
+  $sel->wait_for_page_to_load_ok(WAIT_TIME);
+  $sel->title_is("Edit Product 'Kill me nicely'",
+    "Display properties of Kill me nicely");
+  $sel->type_ok("votestoconfirm", 2);
+  $sel->click_ok('//input[@type="submit" and @value="Save Changes"]');
+  $sel->wait_for_page_to_load_ok(WAIT_TIME);
+  $sel->title_is("Updating Product 'Kill me nicely'");
+  $sel->is_text_present_ok("Updated number of votes needed to confirm a bug");
+
+  go_to_bug($sel, $bug1_id);
+  $sel->click_ok("link=vote");
+  $sel->wait_for_page_to_load_ok(WAIT_TIME);
+  $sel->title_is("Change Votes");
+  $sel->type_ok("bug_$bug1_id", 1);
+  $sel->click_ok("change");
+  $sel->wait_for_page_to_load_ok(WAIT_TIME);
+  $sel->title_is("Change Votes");
+  $sel->is_text_present_ok("The changes to your votes have been saved");
+
+  edit_product($sel, "Kill me nicely");
+  $sel->type_ok("votestoconfirm", 1);
+  $sel->click_ok('//input[@type="submit" and @value="Save Changes"]');
+  $sel->wait_for_page_to_load_ok(WAIT_TIME);
+  $sel->title_is("Updating Product 'Kill me nicely'");
+  $sel->is_text_present_ok("Updated number of votes needed to confirm a bug");
+  $text = trim($sel->get_text("bugzilla-body"));
+  ok(
+    $text =~ /Bug $bug1_id confirmed by number of votes/,
+    "Bug $bug1_id is confirmed by popular votes"
+  );
 }
 
 # Edit the bug.
 
 go_to_bug($sel, $bug1_id);
-$sel->selected_label_is("product", "Kill me nicely");
-$sel->selected_label_is("bug_status", "CONFIRMED") if $config->{test_extensions};
+$sel->selected_label_is("product",    "Kill me nicely");
+$sel->selected_label_is("bug_status", "CONFIRMED")
+  if $config->{test_extensions};
 $sel->select_ok("target_milestone", "label=pre-0.1");
-$sel->select_ok("component", "label=second comp");
+$sel->select_ok("component",        "label=second comp");
 $sel->click_ok("commit");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->is_text_present_ok("Changes submitted for bug $bug1_id");
@@ -265,7 +297,8 @@ $sel->click_ok("link=bug $bug1_id");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_like(qr/$bug1_id /);
 @cc_list = $sel->get_select_options("cc");
-ok(grep($_ eq $permanent_user, @cc_list), "User $permanent_user automatically added to the CC list");
+ok(grep($_ eq $permanent_user, @cc_list),
+  "User $permanent_user automatically added to the CC list");
 
 # Delete the milestone the bug belongs to. This should retarget the bug
 # to the default milestone.
@@ -274,17 +307,24 @@ edit_product($sel, "Kill me nicely");
 $sel->click_ok("link=Edit milestones:");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Select milestone of product 'Kill me nicely'");
-$sel->click_ok('//a[contains(@href,"/editmilestones.cgi?action=del&product=Kill%20me%20nicely&milestone=pre-0.1")]');
+$sel->click_ok(
+  '//a[contains(@href,"/editmilestones.cgi?action=del&product=Kill%20me%20nicely&milestone=pre-0.1")]'
+);
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Delete Milestone of Product 'Kill me nicely'");
 $text = trim($sel->get_text("bugzilla-body"));
 ok($text =~ /There is 1 bug entered for this milestone/, "Warning displayed");
-ok($text =~ /Do you really want to delete this milestone\?/, "Requesting confirmation");
+ok($text =~ /Do you really want to delete this milestone\?/,
+  "Requesting confirmation");
 $sel->click_ok("delete");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Milestone Deleted");
 $text = trim($sel->get_text("message"));
-ok($text =~ /Bugs targetted to this milestone have been retargetted to the default milestone/, "Bug retargetted");
+ok(
+  $text
+    =~ /Bugs targetted to this milestone have been retargetted to the default milestone/,
+  "Bug retargetted"
+);
 
 # Try deleting the version used by the bug. This action must be rejected.
 
@@ -294,21 +334,27 @@ $sel->title_is("Edit Product 'Kill me nicely'");
 $sel->click_ok("//a[contains(text(),'Edit\nversions:')]");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Select version of product 'Kill me nicely'");
-$sel->click_ok("//a[contains(\@href, '/editversions.cgi?action=del&product=Kill%20me%20nicely&version=0.1a')]");
+$sel->click_ok(
+  "//a[contains(\@href, '/editversions.cgi?action=del&product=Kill%20me%20nicely&version=0.1a')]"
+);
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Delete Version of Product 'Kill me nicely'");
 $text = trim($sel->get_text("bugzilla-body"));
-ok($text =~ /Sorry, there are 2 bugs outstanding for this version/, "Rejecting version deletion");
+ok($text =~ /Sorry, there are 2 bugs outstanding for this version/,
+  "Rejecting version deletion");
 $sel->go_back_ok();
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 
 # Delete an unused version. The action must succeed.
 
-$sel->click_ok('//a[contains(@href,"/editversions.cgi?action=del&product=Kill%20me%20nicely&version=0.1")]');
+$sel->click_ok(
+  '//a[contains(@href,"/editversions.cgi?action=del&product=Kill%20me%20nicely&version=0.1")]'
+);
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Delete Version of Product 'Kill me nicely'");
 $text = trim($sel->get_text("bugzilla-body"));
-ok($text =~ /Do you really want to delete this version\?/, "Requesting confirmation");
+ok($text =~ /Do you really want to delete this version\?/,
+  "Requesting confirmation");
 $sel->click_ok("delete");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Version Deleted");
@@ -321,26 +367,33 @@ $sel->title_is("Edit Product 'Kill me nicely'");
 $sel->click_ok("link=Edit components:");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Select component of product 'Kill me nicely'");
-$sel->click_ok("//a[contains(\@href, '/editcomponents.cgi?action=del&product=Kill%20me%20nicely&component=second%20comp')]");
+$sel->click_ok(
+  "//a[contains(\@href, '/editcomponents.cgi?action=del&product=Kill%20me%20nicely&component=second%20comp')]"
+);
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Delete component 'second comp' from 'Kill me nicely' product");
 $text = trim($sel->get_text("bugzilla-body"));
 ok($text =~ /There are 2 bugs entered for this component/, "Warning displayed");
-ok($text =~ /Do you really want to delete this component\?/, "Requesting confirmation");
+ok($text =~ /Do you really want to delete this component\?/,
+  "Requesting confirmation");
 $sel->click_ok("delete");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Component Deleted");
 $text = trim($sel->get_text("bugzilla-body"));
-ok($text =~ /The component second comp has been deleted/, "Component deletion confirmed");
-ok($text =~ /All bugs being in this component and all references to them have also been deleted/,
-   "Bug deletion confirmed");
+ok($text =~ /The component second comp has been deleted/,
+  "Component deletion confirmed");
+ok(
+  $text
+    =~ /All bugs being in this component and all references to them have also been deleted/,
+  "Bug deletion confirmed"
+);
 
 # Only one value for component, version and milestone available. They should
 # be selected by default.
 
 file_bug_in_product($sel, "Kill me nicely");
 $sel->type_ok("short_desc", "bye bye everybody!");
-$sel->type_ok("comment", "I'm dead :(");
+$sel->type_ok("comment",    "I'm dead :(");
 $sel->click_ok("commit");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 
@@ -350,12 +403,15 @@ go_to_admin($sel);
 $sel->click_ok("link=Products");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Select product");
-$sel->click_ok("//a[contains(\@href,'/editproducts.cgi?action=del&product=Kill%20me%20nicely')]");
+$sel->click_ok(
+  "//a[contains(\@href,'/editproducts.cgi?action=del&product=Kill%20me%20nicely')]"
+);
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Delete Product 'Kill me nicely'");
 $text = trim($sel->get_text("bugzilla-body"));
 ok($text =~ /There is 1 bug entered for this product/, "Warning displayed");
-ok($text =~ /Do you really want to delete this product\?/, "Confirmation request displayed");
+ok($text =~ /Do you really want to delete this product\?/,
+  "Confirmation request displayed");
 $sel->click_ok("delete");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Product Deleted");
index ae527b32a88356fa141879f0dda38530fea425e7..0c67f65c9b4c0f36bafe400b4247776c73db258e 100644 (file)
@@ -22,14 +22,16 @@ my ($sel, $config) = get_selenium();
 # one could not be improved a bit.
 
 foreach my $user (qw(admin unprivileged canconfirm)) {
-    log_in($sel, $config, $user);
-    file_bug_in_product($sel, "TestProduct");
-    $sel->type_ok("short_desc", "Bug created by Selenium",
-                  "Enter bug summary");
-    $sel->type_ok("comment", "--- Bug created by Selenium ---",
-                  "Enter bug description");
-    $sel->click_ok("commit", undef, "Submit bug data to post_bug.cgi");
-    $sel->wait_for_page_to_load_ok(WAIT_TIME);
-    $sel->is_text_present_ok('has been added to the database', 'Bug created');
-    logout($sel);
+  log_in($sel, $config, $user);
+  file_bug_in_product($sel, "TestProduct");
+  $sel->type_ok("short_desc", "Bug created by Selenium", "Enter bug summary");
+  $sel->type_ok(
+    "comment",
+    "--- Bug created by Selenium ---",
+    "Enter bug description"
+  );
+  $sel->click_ok("commit", undef, "Submit bug data to post_bug.cgi");
+  $sel->wait_for_page_to_load_ok(WAIT_TIME);
+  $sel->is_text_present_ok('has been added to the database', 'Bug created');
+  logout($sel);
 }
index 7b880051ffce53d7382892bc122d8ad53220d64c..34b47e24da438c0a94cad90d1228e828a474e3ea 100644 (file)
@@ -27,7 +27,7 @@ $sel->title_is("Administer Flag Types");
 $sel->click_ok("link=Create Flag Type for Bugs");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Create Flag Type for Bugs");
-$sel->type_ok("name", "SeleniumBugFlag1Test");
+$sel->type_ok("name",        "SeleniumBugFlag1Test");
 $sel->type_ok("description", "bugflag1");
 $sel->select_ok("product", "label=TestProduct");
 $sel->click_ok("categoryAction-include");
@@ -48,45 +48,65 @@ $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Create Flag Type for Bugs");
 my @inclusion = $sel->get_select_options("inclusion_to_remove");
 ok(scalar @inclusion == 2, "The inclusion list contains 2 elements");
-ok(grep($_ eq "QA-Selenium-TEST:__Any__", @inclusion), "QA-Selenium-TEST:__Any__ is in the inclusion list");
-ok(grep($_ eq "TestProduct:__Any__", @inclusion), "TestProduct:__Any__ is in the inclusion list");
+ok(
+  grep($_ eq "QA-Selenium-TEST:__Any__", @inclusion),
+  "QA-Selenium-TEST:__Any__ is in the inclusion list"
+);
+ok(
+  grep($_ eq "TestProduct:__Any__", @inclusion),
+  "TestProduct:__Any__ is in the inclusion list"
+);
 my @exclusion = $sel->get_select_options("exclusion_to_remove");
 ok(scalar @exclusion == 1, "The exclusion list contains 1 element");
-ok($exclusion[0] eq "QA-Selenium-TEST:__Any__", "QA-Selenium-TEST:__Any__ is in the exclusion list");
+ok(
+  $exclusion[0] eq "QA-Selenium-TEST:__Any__",
+  "QA-Selenium-TEST:__Any__ is in the exclusion list"
+);
 $sel->type_ok("sortkey", "900");
-$sel->value_is("cc_list", "");
-$sel->value_is("is_active", "on");
-$sel->value_is("is_requestable", "on");
-$sel->value_is("is_requesteeble", "on");
+$sel->value_is("cc_list",          "");
+$sel->value_is("is_active",        "on");
+$sel->value_is("is_requestable",   "on");
+$sel->value_is("is_requesteeble",  "on");
 $sel->value_is("is_multiplicable", "on");
-$sel->select_ok("grant_group", "label=admin");
+$sel->select_ok("grant_group",   "label=admin");
 $sel->select_ok("request_group", "label=(no group)");
 $sel->click_ok("save");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Flag Type 'SeleniumBugFlag1Test' Created");
-$sel->is_text_present_ok("The flag type SeleniumBugFlag1Test has been created.");
+$sel->is_text_present_ok(
+  "The flag type SeleniumBugFlag1Test has been created.");
 my $flagtype_url = $sel->get_attribute('link=SeleniumBugFlag1Test@href');
 $flagtype_url =~ /id=(\d+)$/;
 my $flagtype1_id = $1;
 
 # Clone the flag type, but set the request group to 'editbugs' and the sortkey to 950.
 
-$sel->click_ok("//a[contains(\@href,'/editflagtypes.cgi?action=copy&id=$flagtype1_id')]");
+$sel->click_ok(
+  "//a[contains(\@href,'/editflagtypes.cgi?action=copy&id=$flagtype1_id')]");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Create Flag Type for Bugs Based on SeleniumBugFlag1Test");
-$sel->type_ok("name", "SeleniumBugFlag2Test");
+$sel->type_ok("name",        "SeleniumBugFlag2Test");
 $sel->type_ok("description", "bugflag2");
 @inclusion = $sel->get_select_options("inclusion_to_remove");
 ok(scalar @inclusion == 2, "The inclusion list contains 2 elements");
-ok(grep($_ eq "QA-Selenium-TEST:__Any__", @inclusion), "QA-Selenium-TEST:__Any__ is in the inclusion list");
-ok(grep($_ eq "TestProduct:__Any__", @inclusion), "TestProduct:__Any__ is in the inclusion list");
+ok(
+  grep($_ eq "QA-Selenium-TEST:__Any__", @inclusion),
+  "QA-Selenium-TEST:__Any__ is in the inclusion list"
+);
+ok(
+  grep($_ eq "TestProduct:__Any__", @inclusion),
+  "TestProduct:__Any__ is in the inclusion list"
+);
 @exclusion = $sel->get_select_options("exclusion_to_remove");
 ok(scalar @exclusion == 1, "The exclusion list contains 1 element");
-ok($exclusion[0] eq "QA-Selenium-TEST:__Any__", "QA-Selenium-TEST:__Any__ is in the exclusion list");
+ok(
+  $exclusion[0] eq "QA-Selenium-TEST:__Any__",
+  "QA-Selenium-TEST:__Any__ is in the exclusion list"
+);
 $sel->type_ok("sortkey", "950");
-$sel->value_is("is_active", "on");
-$sel->value_is("is_requestable", "on");
-$sel->value_is("is_requesteeble", "on");
+$sel->value_is("is_active",        "on");
+$sel->value_is("is_requestable",   "on");
+$sel->value_is("is_requesteeble",  "on");
 $sel->value_is("is_multiplicable", "on");
 $sel->type_ok("cc_list", $config->{canconfirm_user_login});
 $sel->selected_label_is("grant_group", "admin");
@@ -94,20 +114,22 @@ $sel->select_ok("request_group", "label=editbugs");
 $sel->click_ok("save");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Flag Type 'SeleniumBugFlag2Test' Created");
-$sel->is_text_present_ok("The flag type SeleniumBugFlag2Test has been created.");
+$sel->is_text_present_ok(
+  "The flag type SeleniumBugFlag2Test has been created.");
 $flagtype_url = $sel->get_attribute('link=SeleniumBugFlag2Test@href');
 $flagtype_url =~ /id=(\d+)$/;
 my $flagtype2_id = $1;
 
 # Clone the first flag type again, but with different attributes.
 
-$sel->click_ok("//a[contains(\@href,'/editflagtypes.cgi?action=copy&id=$flagtype1_id')]");
+$sel->click_ok(
+  "//a[contains(\@href,'/editflagtypes.cgi?action=copy&id=$flagtype1_id')]");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Create Flag Type for Bugs Based on SeleniumBugFlag1Test");
-$sel->type_ok("name", "SeleniumBugFlag3Test");
+$sel->type_ok("name",        "SeleniumBugFlag3Test");
 $sel->type_ok("description", "bugflag3");
-$sel->type_ok("sortkey", "980");
-$sel->value_is("is_active", "on");
+$sel->type_ok("sortkey",     "980");
+$sel->value_is("is_active",      "on");
 $sel->value_is("is_requestable", "on");
 $sel->uncheck_ok("is_requesteeble");
 $sel->uncheck_ok("is_multiplicable");
@@ -117,7 +139,8 @@ $sel->selected_label_is("request_group", "(no group)");
 $sel->click_ok("save");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Flag Type 'SeleniumBugFlag3Test' Created");
-$sel->is_text_present_ok("The flag type SeleniumBugFlag3Test has been created.");
+$sel->is_text_present_ok(
+  "The flag type SeleniumBugFlag3Test has been created.");
 $flagtype_url = $sel->get_attribute('link=SeleniumBugFlag3Test@href');
 $flagtype_url =~ /id=(\d+)$/;
 my $flagtype3_id = $1;
@@ -127,7 +150,7 @@ my $flagtype3_id = $1;
 $sel->click_ok("link=Create Flag Type For Attachments");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Create Flag Type for Attachments");
-$sel->type_ok("name", "SeleniumAttachmentFlag1Test");
+$sel->type_ok("name",        "SeleniumAttachmentFlag1Test");
 $sel->type_ok("description", "attachmentflag1");
 $sel->select_ok("product", "label=TestProduct");
 $sel->click_ok("categoryAction-include");
@@ -140,55 +163,68 @@ $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Create Flag Type for Attachments");
 @inclusion = $sel->get_select_options("inclusion_to_remove");
 ok(scalar @inclusion == 1, "The inclusion list contains 1 element");
-ok($inclusion[0] eq "TestProduct:__Any__", "TestProduct:__Any__ is in the exclusion list");
+ok(
+  $inclusion[0] eq "TestProduct:__Any__",
+  "TestProduct:__Any__ is in the exclusion list"
+);
 $sel->type_ok("sortkey", "700");
 $sel->value_is("cc_list", "");
-$sel->select_ok("grant_group", "label=editbugs");
+$sel->select_ok("grant_group",   "label=editbugs");
 $sel->select_ok("request_group", "label=canconfirm");
 $sel->click_ok("save");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Flag Type 'SeleniumAttachmentFlag1Test' Created");
-$sel->is_text_present_ok("The flag type SeleniumAttachmentFlag1Test has been created.");
+$sel->is_text_present_ok(
+  "The flag type SeleniumAttachmentFlag1Test has been created.");
 $flagtype_url = $sel->get_attribute('link=SeleniumAttachmentFlag1Test@href');
 $flagtype_url =~ /id=(\d+)$/;
 my $aflagtype1_id = $1;
 
 # Clone the flag type.
 
-$sel->click_ok("//a[contains(\@href,'/editflagtypes.cgi?action=copy&id=$aflagtype1_id')]");
+$sel->click_ok(
+  "//a[contains(\@href,'/editflagtypes.cgi?action=copy&id=$aflagtype1_id')]");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
-$sel->title_is("Create Flag Type for Attachments Based on SeleniumAttachmentFlag1Test");
-$sel->type_ok("name", "SeleniumAttachmentFlag2Test");
+$sel->title_is(
+  "Create Flag Type for Attachments Based on SeleniumAttachmentFlag1Test");
+$sel->type_ok("name",        "SeleniumAttachmentFlag2Test");
 $sel->type_ok("description", "attachmentflag2");
 @inclusion = $sel->get_select_options("inclusion_to_remove");
 ok(scalar @inclusion == 1, "The inclusion list contains 1 element");
-ok($inclusion[0] eq "TestProduct:__Any__", "TestProduct:__Any__ is in the exclusion list");
+ok(
+  $inclusion[0] eq "TestProduct:__Any__",
+  "TestProduct:__Any__ is in the exclusion list"
+);
 $sel->type_ok("sortkey", "750");
 $sel->type_ok("cc_list", $config->{admin_user_login});
 $sel->uncheck_ok("is_multiplicable");
-$sel->select_ok("grant_group", "label=(no group)");
+$sel->select_ok("grant_group",   "label=(no group)");
 $sel->select_ok("request_group", "label=(no group)");
 $sel->click_ok("save");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Flag Type 'SeleniumAttachmentFlag2Test' Created");
-$sel->is_text_present_ok("The flag type SeleniumAttachmentFlag2Test has been created.");
+$sel->is_text_present_ok(
+  "The flag type SeleniumAttachmentFlag2Test has been created.");
 $flagtype_url = $sel->get_attribute('link=SeleniumAttachmentFlag2Test@href');
 $flagtype_url =~ /id=(\d+)$/;
 my $aflagtype2_id = $1;
 
 # Clone the flag type again, and set it as inactive.
 
-$sel->click_ok("//a[contains(\@href,'/editflagtypes.cgi?action=copy&id=$aflagtype1_id')]");
+$sel->click_ok(
+  "//a[contains(\@href,'/editflagtypes.cgi?action=copy&id=$aflagtype1_id')]");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
-$sel->title_is("Create Flag Type for Attachments Based on SeleniumAttachmentFlag1Test");
-$sel->type_ok("name", "SeleniumAttachmentFlag3Test");
+$sel->title_is(
+  "Create Flag Type for Attachments Based on SeleniumAttachmentFlag1Test");
+$sel->type_ok("name",        "SeleniumAttachmentFlag3Test");
 $sel->type_ok("description", "attachmentflag3");
-$sel->type_ok("sortkey", "800");
+$sel->type_ok("sortkey",     "800");
 $sel->uncheck_ok("is_active");
 $sel->click_ok("save");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Flag Type 'SeleniumAttachmentFlag3Test' Created");
-$sel->is_text_present_ok("The flag type SeleniumAttachmentFlag3Test has been created.");
+$sel->is_text_present_ok(
+  "The flag type SeleniumAttachmentFlag3Test has been created.");
 $flagtype_url = $sel->get_attribute('link=SeleniumAttachmentFlag3Test@href');
 $flagtype_url =~ /id=(\d+)$/;
 my $aflagtype3_id = $1;
@@ -197,13 +233,15 @@ my $aflagtype3_id = $1;
 
 file_bug_in_product($sel, 'TestProduct');
 $sel->type_ok("short_desc", "test flags");
-$sel->type_ok("comment", "this bug is used by Selenium to test flags");
+$sel->type_ok("comment",    "this bug is used by Selenium to test flags");
+
 # Restrict the bug to the Master group. That's important for subsequent tests!
 $sel->check_ok('//input[@name="groups" and @value="Master"]');
 $sel->click_ok("commit");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 my $bug1_id = $sel->get_value('//input[@name="id" and @type="hidden"]');
-$sel->is_text_present_ok('has been added to the database', "Bug $bug1_id created");
+$sel->is_text_present_ok('has been added to the database',
+  "Bug $bug1_id created");
 
 # All 3 bug flag types must be available; we are in the TestProduct product.
 
@@ -211,16 +249,21 @@ $sel->click_ok("link=Bug $bug1_id");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_like(qr/^$bug1_id .* test flags/);
 $sel->is_text_present_ok("SeleniumBugFlag1Test");
+
 # We specify //select or //input, just to be sure. This is not required, though.
 $sel->is_element_present_ok("//select[\@id='flag_type-$flagtype1_id']");
 $sel->is_element_present_ok("//input[\@id='requestee_type-$flagtype1_id']");
+
 # If fields are of the correct type above, we assume this is still true below.
 $sel->is_text_present_ok("SeleniumBugFlag2Test");
 $sel->is_element_present_ok("flag_type-$flagtype2_id");
 $sel->is_element_present_ok("requestee_type-$flagtype2_id");
 $sel->is_text_present_ok("SeleniumBugFlag3Test");
 $sel->is_element_present_ok("flag_type-$flagtype3_id");
-ok(!$sel->is_element_present("requestee_type-$flagtype3_id"), "SeleniumBugFlag3Test is not specifically requestable");
+ok(
+  !$sel->is_element_present("requestee_type-$flagtype3_id"),
+  "SeleniumBugFlag3Test is not specifically requestable"
+);
 
 # This is intentional to generate "flagmail". Some flags have a CC list
 # associated with them, some others don't. This is to catch crashes due to
@@ -251,7 +294,10 @@ $flag3_1_id =~ s/flag-//;
 
 $sel->is_text_present_ok("addl. SeleniumBugFlag1Test");
 $sel->is_text_present_ok("addl. SeleniumBugFlag2Test");
-ok(!$sel->is_text_present("addl. SeleniumBugFlag3Test"), "SeleniumBugFlag3Test is not multiplicable");
+ok(
+  !$sel->is_text_present("addl. SeleniumBugFlag3Test"),
+  "SeleniumBugFlag3Test is not multiplicable"
+);
 $sel->select_ok("flag_type-$flagtype1_id", "label=+");
 $sel->select_ok("flag_type-$flagtype2_id", "label=-");
 $sel->click_ok("commit");
@@ -267,7 +313,8 @@ $sel->title_like(qr/^$bug1_id /);
 $sel->select_ok("flag_type-$flagtype1_id", "label=?");
 $sel->type_ok("requestee_type-$flagtype1_id", $config->{admin_user_login});
 $sel->select_ok("flag_type-$flagtype2_id", "label=?");
-$sel->type_ok("requestee_type-$flagtype2_id", $config->{unprivileged_user_login});
+$sel->type_ok("requestee_type-$flagtype2_id",
+  $config->{unprivileged_user_login});
 $sel->click_ok("commit");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Flag Requestee Not Authorized");
@@ -304,7 +351,10 @@ $sel->type_ok('//input[@name="description"]', "patch, v1");
 $sel->check_ok('//input[@name="ispatch"]');
 $sel->is_text_present_ok("SeleniumAttachmentFlag1Test");
 $sel->is_text_present_ok("SeleniumAttachmentFlag2Test");
-ok(!$sel->is_text_present("SeleniumAttachmentFlag3Test"), "Inactive SeleniumAttachmentFlag3Test flag type not displayed");
+ok(
+  !$sel->is_text_present("SeleniumAttachmentFlag3Test"),
+  "Inactive SeleniumAttachmentFlag3Test flag type not displayed"
+);
 
 # Let's generate some "flagmail", first with no requestee.
 
@@ -323,20 +373,24 @@ my $attachment1_id = $1;
 
 # Now create another attachment, and set requestees.
 
-$sel->click_ok("//a[contains(text(),'Create\n Another Attachment to Bug $bug1_id')]");
+$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->attach_file('//input[@name="data"]', $config->{attachment_file});
 $sel->type_ok('//input[@name="description"]', "patch, v2");
 $sel->check_ok('//input[@name="ispatch"]');
+
 # Mark the previous attachment as obsolete.
 $sel->check_ok($attachment1_id);
 $sel->select_ok("flag_type-$aflagtype1_id", "label=?");
 $sel->type_ok("requestee_type-$aflagtype1_id", $config->{admin_user_login});
 $sel->select_ok("flag_type-$aflagtype2_id", "label=?");
+
 # The requestee is not in the Master group, and so he cannot view the bug.
 # He must be silently skipped from the requestee field.
-$sel->type_ok("requestee_type-$aflagtype2_id", $config->{unprivileged_user_login});
+$sel->type_ok("requestee_type-$aflagtype2_id",
+  $config->{unprivileged_user_login});
 $sel->type_ok("comment", "second patch, with requestee");
 $sel->click_ok("create");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
@@ -347,13 +401,15 @@ my $attachment2_id = $1;
 
 # Create a third attachment, but we now set the MIME type manually.
 
-$sel->click_ok("//a[contains(text(),'Create\n Another Attachment to Bug $bug1_id')]");
+$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->attach_file('//input[@name="data"]', $config->{attachment_file});
 $sel->type_ok('//input[@name="description"]', "patch, v3");
 $sel->click_ok('//input[@name="contenttypemethod" and @value="list"]');
-$sel->select_ok('//select[@name="contenttypeselection"]', "label=plain text (text/plain)");
+$sel->select_ok('//select[@name="contenttypeselection"]',
+  "label=plain text (text/plain)");
 $sel->select_ok("flag_type-$aflagtype1_id", "label=+");
 $sel->type_ok("comment", "one +, the other one blank");
 $sel->click_ok("create");
@@ -368,9 +424,14 @@ my $attachment3_id = $1;
 $sel->click_ok("link=bug $bug1_id");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_like(qr/^$bug1_id /);
-$sel->is_text_present_ok("$config->{admin_user_nick}: SeleniumAttachmentFlag1Test? ($config->{admin_user_nick})");
-$sel->is_text_present_ok("$config->{admin_user_nick}: SeleniumAttachmentFlag2Test?");
-$sel->is_text_present_ok("$config->{admin_user_nick}: SeleniumAttachmentFlag1Test+");
+$sel->is_text_present_ok(
+  "$config->{admin_user_nick}: SeleniumAttachmentFlag1Test? ($config->{admin_user_nick})"
+);
+$sel->is_text_present_ok(
+  "$config->{admin_user_nick}: SeleniumAttachmentFlag2Test?");
+$sel->is_text_present_ok(
+  "$config->{admin_user_nick}: SeleniumAttachmentFlag1Test+");
+
 # We marked the first attachment as obsolete, so it should have no flag on it.
 $sel->is_text_present_ok("no flags");
 
@@ -386,6 +447,7 @@ logout($sel);
 
 log_in($sel, $config, 'unprivileged');
 go_to_bug($sel, $bug1_id);
+
 # No privs are required to clear this flag.
 $sel->select_ok("flag-$flag3_1_id", "value=X");
 $sel->click_ok("commit");
@@ -399,7 +461,8 @@ $sel->title_like(qr/^$bug1_id /);
 # should be displayed besides the currently set "+".
 
 my @flag_states = $sel->get_select_options("flag-$flag2_1_id");
-ok(scalar(@flag_states) == 1 && $flag_states[0] eq '+', "Single flag state '+' available");
+ok(scalar(@flag_states) == 1 && $flag_states[0] eq '+',
+  "Single flag state '+' available");
 
 # Powerless users cannot set the flag to +, but setting it to ? is allowed.
 
@@ -409,11 +472,14 @@ ok(grep($_ eq '?', @flag_states), "Flag state '?' available");
 
 # A powerless user cannot edit someone else's attachment flags.
 
-$sel->click_ok("//a[contains(\@href,'/attachment.cgi?id=$attachment2_id&action=edit')]");
+$sel->click_ok(
+  "//a[contains(\@href,'/attachment.cgi?id=$attachment2_id&action=edit')]");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_like(qr/^Attachment $attachment2_id Details for Bug $bug1_id/);
-$sel->is_element_present_ok('//select[@title="attachmentflag2"][@disabled]',
-   "Attachment flags are not editable by a powerless user");
+$sel->is_element_present_ok(
+  '//select[@title="attachmentflag2"][@disabled]',
+  "Attachment flags are not editable by a powerless user"
+);
 
 # Add an attachment and set flags on it.
 
@@ -425,12 +491,16 @@ $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Create New Attachment for Bug #$bug1_id");
 $sel->attach_file('//input[@name="data"]', $config->{attachment_file});
 $sel->type_ok('//input[@name="description"]', "patch, v4");
+
 # This somehow fails with the current script but works when testing manually
 # $sel->value_is('//input[@name="ispatch"]', "on");
 
 # canconfirm/editbugs privs are required to edit this flag.
 
-ok(!$sel->is_editable("flag_type-$aflagtype1_id"), "Flag type non editable by powerless users");
+ok(
+  !$sel->is_editable("flag_type-$aflagtype1_id"),
+  "Flag type non editable by powerless users"
+);
 
 # No privs are required to edit this flag.
 
@@ -442,7 +512,8 @@ $sel->is_text_present_ok('regexp:Attachment #\d+ to bug \d+ created');
 $sel->click_ok("link=bug $bug1_id");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_like(qr/^$bug1_id/);
-$sel->is_text_present_ok("$config->{unprivileged_user_nick}: SeleniumAttachmentFlag2Test+");
+$sel->is_text_present_ok(
+  "$config->{unprivileged_user_nick}: SeleniumAttachmentFlag2Test+");
 logout($sel);
 
 # Final tests as an admin. He has editbugs privs, so he can edit
@@ -450,13 +521,15 @@ logout($sel);
 
 log_in($sel, $config, 'admin');
 go_to_bug($sel, $bug1_id);
-$sel->click_ok("//a[contains(\@href,'/attachment.cgi?id=${attachment3_id}&action=edit')]");
+$sel->click_ok(
+  "//a[contains(\@href,'/attachment.cgi?id=${attachment3_id}&action=edit')]");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_like(qr/^Attachment $attachment3_id Details for Bug $bug1_id/);
 $sel->select_ok('//select[@title="attachmentflag1"]', "label=+");
 $sel->click_ok("update");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
-$sel->is_text_present_ok("Changes to attachment $attachment3_id of bug $bug1_id submitted");
+$sel->is_text_present_ok(
+  "Changes to attachment $attachment3_id of bug $bug1_id submitted");
 
 # It's time to delete all created flag types.
 
@@ -465,19 +538,26 @@ $sel->click_ok("link=Flags");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Administer Flag Types");
 
-foreach my $flagtype ([$flagtype1_id, "SeleniumBugFlag1Test"], [$flagtype2_id, "SeleniumBugFlag2Test"],
-                      [$flagtype3_id, "SeleniumBugFlag3Test"], [$aflagtype1_id, "SeleniumAttachmentFlag1Test"],
-                      [$aflagtype2_id, "SeleniumAttachmentFlag2Test"], [$aflagtype3_id, "SeleniumAttachmentFlag3Test"])
+foreach my $flagtype (
+  [$flagtype1_id,  "SeleniumBugFlag1Test"],
+  [$flagtype2_id,  "SeleniumBugFlag2Test"],
+  [$flagtype3_id,  "SeleniumBugFlag3Test"],
+  [$aflagtype1_id, "SeleniumAttachmentFlag1Test"],
+  [$aflagtype2_id, "SeleniumAttachmentFlag2Test"],
+  [$aflagtype3_id, "SeleniumAttachmentFlag3Test"]
+  )
 {
-    my $flag_id = $flagtype->[0];
-    my $flag_name = $flagtype->[1];
-    $sel->click_ok("//a[contains(\@href,'/editflagtypes.cgi?action=confirmdelete&id=$flag_id')]");
-    $sel->wait_for_page_to_load_ok(WAIT_TIME);
-    $sel->title_is("Confirm Deletion of Flag Type '$flag_name'");
-    $sel->click_ok("link=Yes, delete");
-    $sel->wait_for_page_to_load_ok(WAIT_TIME);
-    $sel->title_is("Flag Type '$flag_name' Deleted");
-    my $msg = trim($sel->get_text("message"));
-    ok($msg eq "The flag type $flag_name has been deleted.", "Flag type $flag_name deleted");
+  my $flag_id   = $flagtype->[0];
+  my $flag_name = $flagtype->[1];
+  $sel->click_ok(
+    "//a[contains(\@href,'/editflagtypes.cgi?action=confirmdelete&id=$flag_id')]");
+  $sel->wait_for_page_to_load_ok(WAIT_TIME);
+  $sel->title_is("Confirm Deletion of Flag Type '$flag_name'");
+  $sel->click_ok("link=Yes, delete");
+  $sel->wait_for_page_to_load_ok(WAIT_TIME);
+  $sel->title_is("Flag Type '$flag_name' Deleted");
+  my $msg = trim($sel->get_text("message"));
+  ok($msg eq "The flag type $flag_name has been deleted.",
+    "Flag type $flag_name deleted");
 }
 logout($sel);
index c84d18015cf7882d65a7200eb886ec348c88269d..bb23ac00a59f2485a8ee637b92aca9c19711e918 100644 (file)
@@ -32,7 +32,7 @@ $sel->title_is("Administer Flag Types");
 $sel->click_ok("link=Create Flag Type for Bugs");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Create Flag Type for Bugs");
-$sel->type_ok("name", "selenium");
+$sel->type_ok("name",        "selenium");
 $sel->type_ok("description", "Available in TestProduct and Another Product/c1");
 $sel->add_selection_ok("inclusion_to_remove", "label=__Any__:__Any__");
 $sel->click_ok("categoryAction-removeInclusion");
@@ -43,7 +43,7 @@ $sel->selected_label_is("component", "__Any__");
 $sel->click_ok("categoryAction-include");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Create Flag Type for Bugs");
-$sel->select_ok("product", "label=Another Product");
+$sel->select_ok("product",   "label=Another Product");
 $sel->select_ok("component", "label=c1");
 $sel->click_ok("categoryAction-include");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
@@ -55,11 +55,11 @@ $sel->title_is("Create Flag Type for Bugs");
 # catch it, not this one (which will be unique for now, so no worry to find it).
 
 $sel->type_ok("sortkey", 100);
-$sel->value_is("is_active", "on");
+$sel->value_is("is_active",      "on");
 $sel->value_is("is_requestable", "on");
 $sel->click_ok("is_multiplicable");
 $sel->value_is("is_multiplicable", "off");
-$sel->select_ok("grant_group", "label=editbugs");
+$sel->select_ok("grant_group",   "label=editbugs");
 $sel->select_ok("request_group", "label=canconfirm");
 $sel->click_ok("save");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
@@ -81,7 +81,7 @@ $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->click_ok("link=Create Flag Type For Attachments");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Create Flag Type for Attachments");
-$sel->type_ok("name", "selenium_review");
+$sel->type_ok("name",        "selenium_review");
 $sel->type_ok("description", "Review flag used by Selenium");
 $sel->add_selection_ok("inclusion_to_remove", "label=__Any__:__Any__");
 $sel->click_ok("categoryAction-removeInclusion");
@@ -92,11 +92,11 @@ $sel->click_ok("categoryAction-include");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Create Flag Type for Attachments");
 $sel->type_ok("sortkey", 100);
-$sel->value_is("is_active", "on");
+$sel->value_is("is_active",      "on");
 $sel->value_is("is_requestable", "on");
 $sel->click_ok("is_multiplicable");
 $sel->value_is("is_multiplicable", "off");
-$sel->selected_label_is("grant_group", "(no group)");
+$sel->selected_label_is("grant_group",   "(no group)");
 $sel->selected_label_is("request_group", "(no group)");
 $sel->click_ok("save");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
@@ -118,17 +118,17 @@ $sel->go_back_ok();
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->click_ok("link=Create Flag Type For Attachments");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
-$sel->type_ok("name", "selenium_review");
+$sel->type_ok("name",        "selenium_review");
 $sel->type_ok("description", "Another review flag used by Selenium");
 $sel->select_ok("product", "label=Another Product");
 $sel->click_ok("categoryAction-include");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Create Flag Type for Attachments");
 $sel->type_ok("sortkey", 50);
-$sel->value_is("is_active", "on");
-$sel->value_is("is_requestable", "on");
+$sel->value_is("is_active",        "on");
+$sel->value_is("is_requestable",   "on");
 $sel->value_is("is_multiplicable", "on");
-$sel->select_ok("grant_group", "label=editbugs");
+$sel->select_ok("grant_group",   "label=editbugs");
 $sel->select_ok("request_group", "label=canconfirm");
 $sel->click_ok("save");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
@@ -147,14 +147,19 @@ my $aflagtype2_id = $1;
 file_bug_in_product($sel, 'TestProduct');
 $sel->click_ok('//input[@value="Set bug flags"]');
 $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("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->attach_file('//input[@name="data"]', $config->{attachment_file});
 $sel->type_ok('//input[@name="description"]', "small patch");
+
 # This somehow fails with the current script but works when testing manually
 # $sel->value_is('//input[@name="ispatch"]', "on");
-ok(!$sel->is_element_present("flag_type-$aflagtype1_id"), "Flag type $aflagtype1_id not available in TestProduct");
+ok(
+  !$sel->is_element_present("flag_type-$aflagtype1_id"),
+  "Flag type $aflagtype1_id not available in TestProduct"
+);
 $sel->select_ok("flag_type-$aflagtype2_id", "label=-");
 $sel->click_ok("commit");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
@@ -167,7 +172,8 @@ $sel->click_ok("link=Bug $bug1_id");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_like(qr/^$bug1_id /);
 $sel->is_text_present_ok("$config->{admin_user_nick}: selenium");
-my $flag1_id = $sel->get_attribute('//select[@title="Available in TestProduct and Another Product/c1"]@id');
+my $flag1_id = $sel->get_attribute(
+  '//select[@title="Available in TestProduct and Another Product/c1"]@id');
 $flag1_id =~ s/flag-//;
 $sel->selected_label_is("flag-$flag1_id", "+");
 $sel->is_text_present_ok("$config->{admin_user_nick}: selenium_review-");
@@ -176,7 +182,8 @@ $sel->is_text_present_ok("$config->{admin_user_nick}: selenium_review-");
 # Both the bug and attachment flags should survive.
 
 $sel->select_ok("product", "label=Another Product");
-$sel->type_ok("comment", "Moving to Another Product / c1. The flag should be preserved.");
+$sel->type_ok("comment",
+  "Moving to Another Product / c1. The flag should be preserved.");
 $sel->click_ok("commit");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Verify New Product Details...");
@@ -201,8 +208,12 @@ $sel->is_text_present_ok("Changes submitted for bug $bug1_id");
 $sel->click_ok("link=bug $bug1_id");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_like(qr/^$bug1_id /);
-ok(!$sel->is_element_present("flag-$flag1_id"), "The selenium bug flag didn't survive");
-ok(!$sel->is_element_present("flag_type-$flagtype1_id"), "The selenium flag type doesn't exist");
+ok(
+  !$sel->is_element_present("flag-$flag1_id"),
+  "The selenium bug flag didn't survive"
+);
+ok(!$sel->is_element_present("flag_type-$flagtype1_id"),
+  "The selenium flag type doesn't exist");
 $sel->is_text_present_ok("$config->{admin_user_nick}: selenium_review-");
 
 # File a bug in 'Another Product / c2' and assign it
@@ -212,12 +223,14 @@ file_bug_in_product($sel, 'Another Product');
 $sel->click_ok('//input[@value="Set bug flags"]');
 $sel->select_ok("component", "label=c2");
 $sel->type_ok("assigned_to", $config->{unprivileged_user_login});
-ok(!$sel->is_editable("flag_type-$flagtype1_id"), "The selenium bug flag type is displayed but not selectable");
+ok(!$sel->is_editable("flag_type-$flagtype1_id"),
+  "The selenium bug flag type is displayed but not selectable");
 $sel->select_ok("component", "label=c1");
-$sel->is_editable_ok("flag_type-$flagtype1_id", "The selenium bug flag type is not selectable");
+$sel->is_editable_ok("flag_type-$flagtype1_id",
+  "The selenium bug flag type is not selectable");
 $sel->select_ok("flag_type-$flagtype1_id", "label=?");
 $sel->type_ok("short_desc", "Create a new selenium flag for c2");
-$sel->type_ok("comment", ".");
+$sel->type_ok("comment",    ".");
 $sel->click_ok("commit");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->is_text_present_ok('has been added to the database', 'Bug created');
@@ -229,7 +242,8 @@ $sel->click_ok("link=Bug $bug2_id");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_like(qr/^$bug2_id /);
 $sel->is_text_present_ok("$config->{admin_user_nick}: selenium");
-my $flag2_id = $sel->get_attribute('//select[@title="Available in TestProduct and Another Product/c1"]@id');
+my $flag2_id = $sel->get_attribute(
+  '//select[@title="Available in TestProduct and Another Product/c1"]@id');
 $flag2_id =~ s/flag-//;
 $sel->selected_label_is("flag-$flag2_id", '?');
 
@@ -243,22 +257,22 @@ $sel->title_is("Administer Flag Types");
 $sel->click_ok("link=Create Flag Type for Bugs");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Create Flag Type for Bugs");
-$sel->type_ok("name", "selenium");
+$sel->type_ok("name",        "selenium");
 $sel->type_ok("description", "Another flag with the selenium name");
 $sel->add_selection_ok("inclusion_to_remove", "label=__Any__:__Any__");
 $sel->click_ok("categoryAction-removeInclusion");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Create Flag Type for Bugs");
-$sel->select_ok("product", "label=Another Product");
+$sel->select_ok("product",   "label=Another Product");
 $sel->select_ok("component", "label=c2");
 $sel->click_ok("categoryAction-include");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Create Flag Type for Bugs");
 $sel->type_ok("sortkey", 50);
-$sel->value_is("is_active", "on");
-$sel->value_is("is_requestable", "on");
+$sel->value_is("is_active",        "on");
+$sel->value_is("is_requestable",   "on");
 $sel->value_is("is_multiplicable", "on");
-$sel->selected_label_is("grant_group", "(no group)");
+$sel->selected_label_is("grant_group",   "(no group)");
 $sel->selected_label_is("request_group", "(no group)");
 $sel->click_ok("save");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
@@ -284,7 +298,8 @@ $sel->click_ok("link=bug $bug2_id");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_like(qr/^$bug2_id /);
 $sel->selected_label_is("flag-$flag2_id", '?');
-ok(!$sel->is_element_present("flag_type-$flagtype1_id"), "Flag type not available in c2");
+ok(!$sel->is_element_present("flag_type-$flagtype1_id"),
+  "Flag type not available in c2");
 $sel->is_element_present_ok("flag_type-$flagtype2_id");
 logout($sel);
 
@@ -305,7 +320,8 @@ $sel->selected_label_is("flag-$flag2_id", "+");
 # as the flag setter is not in the editbugs group.
 
 $sel->select_ok("product", "label=TestProduct");
-$sel->type_ok("comment", "selenium flag will be lost. I don't have editbugs privs.");
+$sel->type_ok("comment",
+  "selenium flag will be lost. I don't have editbugs privs.");
 $sel->click_ok("commit");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Verify New Product Details...");
@@ -316,8 +332,12 @@ $sel->click_ok("link=bug $bug2_id");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_like(qr/^$bug2_id /);
 ok(!$sel->is_element_present("flag-$flag2_id"), "Flag $flag2_id deleted");
-ok(!$sel->is_editable("flag_type-$flagtype1_id"), "Flag type 'selenium' not editable by powerless users");
-ok(!$sel->is_element_present("flag_type-$flagtype2_id"), "Flag type not available in c1");
+ok(
+  !$sel->is_editable("flag_type-$flagtype1_id"),
+  "Flag type 'selenium' not editable by powerless users"
+);
+ok(!$sel->is_element_present("flag_type-$flagtype2_id"),
+  "Flag type not available in c1");
 logout($sel);
 
 # Time to delete created flag types.
@@ -328,18 +348,24 @@ $sel->click_ok("link=Flags");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Administer Flag Types");
 
-foreach my $flagtype ([$flagtype1_id, "selenium"], [$flagtype2_id, "selenium"],
-                      [$aflagtype1_id, "selenium_review"], [$aflagtype2_id, "selenium_review"])
+foreach my $flagtype (
+  [$flagtype1_id,  "selenium"],
+  [$flagtype2_id,  "selenium"],
+  [$aflagtype1_id, "selenium_review"],
+  [$aflagtype2_id, "selenium_review"]
+  )
 {
-    my $flag_id = $flagtype->[0];
-    my $flag_name = $flagtype->[1];
-    $sel->click_ok("//a[contains(\@href,'/editflagtypes.cgi?action=confirmdelete&id=$flag_id')]");
-    $sel->wait_for_page_to_load_ok(WAIT_TIME);
-    $sel->title_is("Confirm Deletion of Flag Type '$flag_name'");
-    $sel->click_ok("link=Yes, delete");
-    $sel->wait_for_page_to_load_ok(WAIT_TIME);
-    $sel->title_is("Flag Type '$flag_name' Deleted");
-    my $msg = trim($sel->get_text("message"));
-    ok($msg eq "The flag type $flag_name has been deleted.", "Flag type $flag_name deleted");
+  my $flag_id   = $flagtype->[0];
+  my $flag_name = $flagtype->[1];
+  $sel->click_ok(
+    "//a[contains(\@href,'/editflagtypes.cgi?action=confirmdelete&id=$flag_id')]");
+  $sel->wait_for_page_to_load_ok(WAIT_TIME);
+  $sel->title_is("Confirm Deletion of Flag Type '$flag_name'");
+  $sel->click_ok("link=Yes, delete");
+  $sel->wait_for_page_to_load_ok(WAIT_TIME);
+  $sel->title_is("Flag Type '$flag_name' Deleted");
+  my $msg = trim($sel->get_text("message"));
+  ok($msg eq "The flag type $flag_name has been deleted.",
+    "Flag type $flag_name deleted");
 }
 logout($sel);
index 5d8fcbfda7dd3eefabc4e85d92c2c78e0fbafff6..d8a07ea10b614487825810c1f7130ac9b15a3990 100644 (file)
@@ -25,8 +25,8 @@ $sel->title_is("Edit Groups");
 $sel->click_ok("link=Add Group");
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_is("Add group");
-$sel->type_ok("name", "Selenium-test");
-$sel->type_ok("desc", "Test group for Selenium");
+$sel->type_ok("name",  "Selenium-test");
+$sel->type_ok("desc",  "Test group for Selenium");
 $sel->type_ok("owner", $config->{'admin_user_login'});
 $sel->check_ok("isactive");
 $sel->uncheck_ok("insertnew");
@@ -43,7 +43,7 @@ $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_is("Edit Group Controls for TestProduct");
 $sel->is_text_present_ok("Selenium-test");
 $sel->select_ok("membercontrol_${group_id}", "label=Shown");
-$sel->select_ok("othercontrol_${group_id}", "label=Mandatory");
+$sel->select_ok("othercontrol_${group_id}",  "label=Mandatory");
 $sel->click_ok("submit");
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_is("Update group access controls for TestProduct");
@@ -52,17 +52,18 @@ $sel->title_is("Update group access controls for TestProduct");
 
 file_bug_in_product($sel, "TestProduct");
 $sel->is_text_present_ok("Test group for Selenium");
-$sel->value_is("group_${group_id}", "off"); # Must be OFF (else that's a bug)
+$sel->value_is("group_${group_id}", "off");    # Must be OFF (else that's a bug)
 $sel->check_ok("group_${group_id}");
 $sel->type_ok("short_desc", "bug restricted to the Selenium group");
-$sel->type_ok("comment", "should be invisible");
+$sel->type_ok("comment",    "should be invisible");
 $sel->selected_label_is("component", "TestComponent");
 $sel->click_ok("commit");
 $sel->wait_for_page_to_load(WAIT_TIME);
 my $bug1_id = $sel->get_value('//input[@name="id" and @type="hidden"]');
-$sel->is_text_present_ok('has been added to the database', "Bug $bug1_id created");
+$sel->is_text_present_ok('has been added to the database',
+  "Bug $bug1_id created");
 $sel->is_text_present_ok("Test group for Selenium");
-$sel->value_is("group_${group_id}", "on"); # Must be ON
+$sel->value_is("group_${group_id}", "on");     # Must be ON
 
 # Look for this new bug and add it to the new "Selenium bugs" saved search.
 
@@ -88,7 +89,8 @@ $sel->click_ok("link=Selenium bugs");
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_is("Bug List: Selenium bugs");
 $sel->is_text_present_ok("One bug found");
-$sel->is_element_present_ok("b$bug1_id", undef, "Bug $bug1_id restricted to the bug group");
+$sel->is_element_present_ok("b$bug1_id", undef,
+  "Bug $bug1_id restricted to the bug group");
 
 # No longer use Selenium-test as a bug group.
 
@@ -111,13 +113,17 @@ $sel->is_text_present_ok("The group will no longer be used for bugs");
 file_bug_in_product($sel, "TestProduct");
 $sel->selected_label_is("component", "TestComponent");
 $sel->type_ok("short_desc", "bug restricted to the Selenium group");
-$sel->type_ok("comment", "should be *visible* when created (the group is disabled)");
-ok(!$sel->is_text_present("Test group for Selenium"), "Selenium-test group unavailable");
-ok(!$sel->is_element_present("group_${group_id}"), "Selenium-test checkbox not present");
+$sel->type_ok("comment",
+  "should be *visible* when created (the group is disabled)");
+ok(!$sel->is_text_present("Test group for Selenium"),
+  "Selenium-test group unavailable");
+ok(!$sel->is_element_present("group_${group_id}"),
+  "Selenium-test checkbox not present");
 $sel->click_ok("commit");
 $sel->wait_for_page_to_load(WAIT_TIME);
 my $bug2_id = $sel->get_value("//input[\@name='id' and \@type='hidden']");
-$sel->is_text_present_ok('has been added to the database', "Bug $bug2_id created");
+$sel->is_text_present_ok('has been added to the database',
+  "Bug $bug2_id created");
 
 # Make sure the new bug doesn't appear in the "Selenium bugs" saved search.
 
@@ -125,8 +131,12 @@ $sel->click_ok("link=Selenium bugs");
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_is("Bug List: Selenium bugs");
 $sel->is_text_present_ok("One bug found");
-$sel->is_element_present_ok("b$bug1_id", undef, "Bug $bug1_id restricted to the bug group");
-ok(!$sel->is_element_present("b$bug2_id"), "Bug $bug2_id NOT restricted to the bug group");
+$sel->is_element_present_ok("b$bug1_id", undef,
+  "Bug $bug1_id restricted to the bug group");
+ok(
+  !$sel->is_element_present("b$bug2_id"),
+  "Bug $bug2_id NOT restricted to the bug group"
+);
 
 # Re-enable the Selenium-test group as bug group. This doesn't affect
 # already filed bugs as this group is not mandatory.
@@ -151,8 +161,12 @@ $sel->click_ok("link=Selenium bugs");
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_is("Bug List: Selenium bugs");
 $sel->is_text_present_ok("One bug found");
-$sel->is_element_present_ok("b$bug1_id", undef, "Bug $bug1_id restricted to the bug group");
-ok(!$sel->is_element_present("b$bug2_id"), "Bug $bug2_id NOT restricted to the bug group");
+$sel->is_element_present_ok("b$bug1_id", undef,
+  "Bug $bug1_id restricted to the bug group");
+ok(
+  !$sel->is_element_present("b$bug2_id"),
+  "Bug $bug2_id NOT restricted to the bug group"
+);
 
 # Make the Selenium-test group mandatory for TestProduct.
 
@@ -168,37 +182,49 @@ $sel->is_text_present_ok("the group is newly mandatory and will be added");
 $sel->click_ok("update");
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_is("Update group access controls for TestProduct");
-$sel->is_text_present_ok('regexp:Adding bugs to group \'Selenium-test\' which is\W+mandatory for this product');
+$sel->is_text_present_ok(
+  'regexp:Adding bugs to group \'Selenium-test\' which is\W+mandatory for this product'
+);
 
 # All bugs being in TestProduct must now be restricted to the bug group.
 
 $sel->click_ok("link=Selenium bugs");
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_is("Bug List: Selenium bugs");
-$sel->is_element_present_ok("b$bug1_id", undef, "Bug $bug1_id restricted to the bug group");
-$sel->is_element_present_ok("b$bug2_id", undef, "Bug $bug2_id restricted to the bug group");
+$sel->is_element_present_ok("b$bug1_id", undef,
+  "Bug $bug1_id restricted to the bug group");
+$sel->is_element_present_ok("b$bug2_id", undef,
+  "Bug $bug2_id restricted to the bug group");
 
 # File a new bug, which must automatically be restricted to the bug group.
 
 file_bug_in_product($sel, "TestProduct");
 $sel->selected_label_is("component", "TestComponent");
 $sel->type_ok("short_desc", "Selenium-test group mandatory");
-$sel->type_ok("comment", "group enabled");
-ok(!$sel->is_text_present("Test group for Selenium"), "Selenium-test group not available");
-ok(!$sel->is_element_present("group_${group_id}"), "Selenium-test checkbox not present (mandatory group)");
+$sel->type_ok("comment",    "group enabled");
+ok(!$sel->is_text_present("Test group for Selenium"),
+  "Selenium-test group not available");
+ok(
+  !$sel->is_element_present("group_${group_id}"),
+  "Selenium-test checkbox not present (mandatory group)"
+);
 $sel->click_ok("commit");
 $sel->wait_for_page_to_load(WAIT_TIME);
 my $bug3_id = $sel->get_value("//input[\@name='id' and \@type='hidden']");
-$sel->is_text_present_ok('has been added to the database', "Bug $bug3_id created");
+$sel->is_text_present_ok('has been added to the database',
+  "Bug $bug3_id created");
 
 # Make sure all three bugs are listed as being restricted to the bug group.
 
 $sel->click_ok("link=Selenium bugs");
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_is("Bug List: Selenium bugs");
-$sel->is_element_present_ok("b$bug1_id", undef, "Bug $bug1_id restricted to the bug group");
-$sel->is_element_present_ok("b$bug2_id", undef, "Bug $bug2_id restricted to the bug group");
-$sel->is_element_present_ok("b$bug3_id", undef, "Bug $bug3_id restricted to the bug group");
+$sel->is_element_present_ok("b$bug1_id", undef,
+  "Bug $bug1_id restricted to the bug group");
+$sel->is_element_present_ok("b$bug2_id", undef,
+  "Bug $bug2_id restricted to the bug group");
+$sel->is_element_present_ok("b$bug3_id", undef,
+  "Bug $bug3_id restricted to the bug group");
 
 # Turn off the Selenium-test group again.
 
@@ -221,23 +247,32 @@ $sel->is_text_present_ok("The group will no longer be used for bugs");
 file_bug_in_product($sel, "TestProduct");
 $sel->selected_label_is("component", "TestComponent");
 $sel->type_ok("short_desc", "bug restricted to the Selenium-test group");
-$sel->type_ok("comment", "group disabled");
-ok(!$sel->is_text_present("Test group for Selenium"), "Selenium-test group not available");
-ok(!$sel->is_element_present("group_${group_id}"), "Selenium-test checkbox not present");
+$sel->type_ok("comment",    "group disabled");
+ok(!$sel->is_text_present("Test group for Selenium"),
+  "Selenium-test group not available");
+ok(!$sel->is_element_present("group_${group_id}"),
+  "Selenium-test checkbox not present");
 $sel->click_ok("commit");
 $sel->wait_for_page_to_load(WAIT_TIME);
 my $bug4_id = $sel->get_value("//input[\@name='id' and \@type='hidden']");
-$sel->is_text_present_ok('has been added to the database', "Bug $bug4_id created");
+$sel->is_text_present_ok('has been added to the database',
+  "Bug $bug4_id created");
 
 # The last bug must not be in the list.
 
 $sel->click_ok("link=Selenium bugs");
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_is("Bug List: Selenium bugs");
-$sel->is_element_present_ok("b$bug1_id", undef, "Bug $bug1_id restricted to the bug group");
-$sel->is_element_present_ok("b$bug2_id", undef, "Bug $bug2_id restricted to the bug group");
-$sel->is_element_present_ok("b$bug3_id", undef, "Bug $bug3_id restricted to the bug group");
-ok(!$sel->is_element_present("b$bug4_id"), "Bug $bug4_id NOT restricted to the bug group");
+$sel->is_element_present_ok("b$bug1_id", undef,
+  "Bug $bug1_id restricted to the bug group");
+$sel->is_element_present_ok("b$bug2_id", undef,
+  "Bug $bug2_id restricted to the bug group");
+$sel->is_element_present_ok("b$bug3_id", undef,
+  "Bug $bug3_id restricted to the bug group");
+ok(
+  !$sel->is_element_present("b$bug4_id"),
+  "Bug $bug4_id NOT restricted to the bug group"
+);
 
 # Re-enable the mandatory group. All bugs should be restricted to this bug group automatically.
 
@@ -260,10 +295,14 @@ $sel->is_text_present_ok("The group will now be used for bugs");
 $sel->click_ok("link=Selenium bugs");
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_is("Bug List: Selenium bugs");
-$sel->is_element_present_ok("b$bug1_id", undef, "Bug $bug1_id restricted to the bug group");
-$sel->is_element_present_ok("b$bug2_id", undef, "Bug $bug2_id restricted to the bug group");
-$sel->is_element_present_ok("b$bug3_id", undef, "Bug $bug3_id restricted to the bug group");
-$sel->is_element_present_ok("b$bug4_id", undef, "Bug $bug4_id restricted to the bug group");
+$sel->is_element_present_ok("b$bug1_id", undef,
+  "Bug $bug1_id restricted to the bug group");
+$sel->is_element_present_ok("b$bug2_id", undef,
+  "Bug $bug2_id restricted to the bug group");
+$sel->is_element_present_ok("b$bug3_id", undef,
+  "Bug $bug3_id restricted to the bug group");
+$sel->is_element_present_ok("b$bug4_id", undef,
+  "Bug $bug4_id restricted to the bug group");
 
 # Try to remove the Selenium-test group from TestProduct, but DON'T do it!
 # We just want to make sure a warning is displayed about this removal.
@@ -275,11 +314,12 @@ $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_is("Edit Group Controls for TestProduct");
 $sel->is_text_present_ok("Selenium-test");
 $sel->select_ok("membercontrol_${group_id}", "NA");
-$sel->select_ok("othercontrol_${group_id}", "NA");
+$sel->select_ok("othercontrol_${group_id}",  "NA");
 $sel->click_ok("submit");
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_is("Confirm Group Control Change for product 'TestProduct'");
-$sel->is_text_present_ok("the group is no longer applicable and will be removed");
+$sel->is_text_present_ok(
+  "the group is no longer applicable and will be removed");
 
 # Delete the Selenium-test group.
 
@@ -287,7 +327,8 @@ go_to_admin($sel);
 $sel->click_ok("link=Groups");
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_is("Edit Groups");
-$sel->click_ok("//a[contains(\@href,'/editgroups.cgi?action=del&group=${group_id}')]");
+$sel->click_ok(
+  "//a[contains(\@href,'/editgroups.cgi?action=del&group=${group_id}')]");
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_is("Delete group");
 $sel->is_text_present_ok("Do you really want to delete this group?");
@@ -301,7 +342,8 @@ $sel->click_ok("delete");
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_is("Cannot Delete Group");
 my $error_msg = trim($sel->get_text("error_msg"));
-ok($error_msg =~ /^The Selenium-test group cannot be deleted/, "Group is in use - not deletable");
+ok($error_msg =~ /^The Selenium-test group cannot be deleted/,
+  "Group is in use - not deletable");
 $sel->go_back_ok();
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->check("removebugs");
index e093cb43784976f1e3e69d58a822278ea9c5f3a0..ffbb59927edec35f5d8784e3d2f6f34069a97d06 100644 (file)
@@ -29,18 +29,18 @@ $sel->title_is("Select keyword");
 
 # If keywords already exist, delete them to not disturb the test.
 
-my $page = $sel->get_body_text();
+my $page     = $sel->get_body_text();
 my @keywords = $page =~ m/(key-selenium-\w+)/gi;
 
 foreach my $keyword (@keywords) {
-    my $url = $sel->get_attribute("link=$keyword\@href");
-    $url =~ s/action=edit/action=del/;
-    $sel->click_ok("//a[\@href='$url']");
-    $sel->wait_for_page_to_load(WAIT_TIME);
-    $sel->title_is("Delete Keyword");
-    $sel->click_ok("delete");
-    $sel->wait_for_page_to_load(WAIT_TIME);
-    $sel->title_is("Keyword Deleted");
+  my $url = $sel->get_attribute("link=$keyword\@href");
+  $url =~ s/action=edit/action=del/;
+  $sel->click_ok("//a[\@href='$url']");
+  $sel->wait_for_page_to_load(WAIT_TIME);
+  $sel->title_is("Delete Keyword");
+  $sel->click_ok("delete");
+  $sel->wait_for_page_to_load(WAIT_TIME);
+  $sel->title_is("Keyword Deleted");
 }
 
 # Now let's create our first keyword.
@@ -52,7 +52,7 @@ $sel->title_is("Select keyword");
 $sel->click_ok("link=Add a new keyword");
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_is("Add keyword");
-$sel->type_ok("name", "key-selenium-kone");
+$sel->type_ok("name",        "key-selenium-kone");
 $sel->type_ok("description", "Hopefully an ice cream");
 $sel->click_ok("create");
 $sel->wait_for_page_to_load(WAIT_TIME);
@@ -63,19 +63,20 @@ $sel->title_is("New Keyword Created");
 $sel->click_ok("link=Add a new keyword");
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_is("Add keyword");
-$sel->type_ok("name", "key-selenium-kone");
+$sel->type_ok("name",        "key-selenium-kone");
 $sel->type_ok("description", "FIX ME!");
 $sel->click_ok("create");
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_is("Keyword Already Exists");
 my $error_msg = trim($sel->get_text("error_msg"));
-ok($error_msg eq 'A keyword with the name key-selenium-kone already exists.', 'Already created keyword');
+ok($error_msg eq 'A keyword with the name key-selenium-kone already exists.',
+  'Already created keyword');
 $sel->go_back_ok();
 $sel->wait_for_page_to_load(WAIT_TIME);
 
 # Create a second keyword.
 
-$sel->type_ok("name", "key-selenium-ktwo");
+$sel->type_ok("name",        "key-selenium-ktwo");
 $sel->type_ok("description", "FIX ME!");
 $sel->click_ok("create");
 $sel->wait_for_page_to_load(WAIT_TIME);
@@ -86,13 +87,14 @@ $sel->title_is("New Keyword Created");
 $sel->click_ok("link=key-selenium-ktwo");
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_is("Edit keyword");
-$sel->type_ok("name", "key-selenium-kone");
+$sel->type_ok("name",        "key-selenium-kone");
 $sel->type_ok("description", "the second keyword");
 $sel->click_ok("update");
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_is("Keyword Already Exists");
 $error_msg = trim($sel->get_text("error_msg"));
-ok($error_msg eq 'A keyword with the name key-selenium-kone already exists.', 'Already created keyword');
+ok($error_msg eq 'A keyword with the name key-selenium-kone already exists.',
+  'Already created keyword');
 $sel->go_back_ok();
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_is("Edit keyword");
@@ -104,6 +106,7 @@ $sel->title_is("Keyword Updated");
 # Add keywords to bugs
 
 go_to_bug($sel, $test_bug_1);
+
 # If another script is playing with keywords too, don't mess with it.
 my $kw1 = $sel->get_text("keywords");
 $sel->type_ok("keywords", "$kw1, key-selenium-kone");
@@ -133,6 +136,7 @@ $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_is("Search for bugs");
 $sel->remove_all_selections("product");
 $sel->remove_all_selections("bug_status");
+
 # Try with a different case than the one in the DB.
 $sel->type_ok("keywords", "key-selenium-ktWO");
 $sel->click_ok("Search");
@@ -145,6 +149,7 @@ $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_is("Search for bugs");
 $sel->remove_all_selections("product");
 $sel->remove_all_selections("bug_status");
+
 # Bugzilla doesn't allow substrings for keywords.
 $sel->type_ok("keywords", "selen");
 $sel->click_ok("Search");
@@ -160,7 +165,8 @@ $sel->is_text_present_ok("key-selenium-kone");
 $sel->is_text_present_ok("Hopefully an ice cream");
 $sel->is_text_present_ok("key-selenium-ktwo");
 $sel->is_text_present_ok("the second keyword");
-$sel->click_ok('//a[contains(@href,"/buglist.cgi?keywords=key-selenium-kone")]');
+$sel->click_ok(
+  '//a[contains(@href,"/buglist.cgi?keywords=key-selenium-kone")]');
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_is("Bug List");
 $sel->is_element_present_ok("link=$test_bug_1");
@@ -168,7 +174,8 @@ $sel->is_element_present_ok("link=$test_bug_2");
 $sel->is_text_present_ok("2 bugs found");
 $sel->go_back_ok();
 $sel->wait_for_page_to_load(WAIT_TIME);
-$sel->click_ok('//a[contains(@href,"/buglist.cgi?keywords=key-selenium-ktwo")]');
+$sel->click_ok(
+  '//a[contains(@href,"/buglist.cgi?keywords=key-selenium-ktwo")]');
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_is("Bug List");
 $sel->is_element_present_ok("link=$test_bug_2");
index 45bf1408f5a2a8c87e819b7f1cfc275b9ed3ae01..2d8cc421784a443bfc9a9ef111522eec237668fb 100644 (file)
@@ -23,8 +23,9 @@ my ($sel, $config) = get_selenium();
 
 $sel->open_ok("/$config->{bugzilla_installation}/editparams.cgi");
 $sel->title_is("Log in to Bugzilla");
+
 # The login and password are hardcoded here, because this account doesn't exist.
-$sel->type_ok("Bugzilla_login", 'guest@foo.com');
+$sel->type_ok("Bugzilla_login",    'guest@foo.com');
 $sel->type_ok("Bugzilla_password", 'foo-bar-baz');
 $sel->click_ok("log_in");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
index e55bd5ca422586f20d850df9b968b0da7014bc3d..a7860879d03916233cafcc60caffb4dbb7f5146b 100644 (file)
@@ -18,25 +18,33 @@ my ($sel, $config) = get_selenium();
 # 1st step: turn on usetargetmilestone, musthavemilestoneonaccept and letsubmitterchoosemilestone.
 
 log_in($sel, $config, 'admin');
-set_parameters($sel, {'Bug Fields'          => {'usetargetmilestone-on'          => undef},
-                      'Bug Change Policies' => {'musthavemilestoneonaccept-on'   => undef,
-                                                'letsubmitterchoosemilestone-on' => undef},
-                     }
-              );
+set_parameters(
+  $sel,
+  {
+    'Bug Fields'          => {'usetargetmilestone-on' => undef},
+    'Bug Change Policies' => {
+      'musthavemilestoneonaccept-on'   => undef,
+      'letsubmitterchoosemilestone-on' => undef
+    },
+  }
+);
 
 # 2nd step: Add the milestone "2.0" (with sortkey = 10) to the TestProduct product.
 
 edit_product($sel, "TestProduct");
-$sel->click_ok("link=Edit milestones:", undef, "Go to the Edit milestones page");
+$sel->click_ok("link=Edit milestones:", undef,
+  "Go to the Edit milestones page");
 $sel->wait_for_page_to_load(WAIT_TIME);
-$sel->title_is("Select milestone of product 'TestProduct'", "Display milestones");
+$sel->title_is("Select milestone of product 'TestProduct'",
+  "Display milestones");
 $sel->click_ok("link=Add", undef, "Go add a new milestone");
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_is("Add Milestone to Product 'TestProduct'", "Enter new milestone");
 $sel->type_ok("milestone", "2.0", "Set its name to 2.0");
-$sel->type_ok("sortkey", "10", "Set its sortkey to 10");
+$sel->type_ok("sortkey",   "10",  "Set its sortkey to 10");
 $sel->click_ok("create", undef, "Submit data");
 $sel->wait_for_page_to_load(WAIT_TIME);
+
 # If the milestone already exists, that's not a big deal. So no special action
 # is required in this case.
 $sel->title_is("Milestone Created", "Milestone Created");
@@ -44,26 +52,45 @@ $sel->title_is("Milestone Created", "Milestone Created");
 # 3rd step: file a new bug, leaving the milestone alone (should fall back to the default one).
 
 file_bug_in_product($sel, "TestProduct");
-$sel->selected_label_is("component", "TestComponent", "Component already selected (no other component defined)");
-$sel->selected_label_is("target_milestone", "---", "Default milestone selected");
-$sel->selected_label_is("version", "unspecified", "Version already selected (no other version defined)");
-$sel->type_ok("short_desc", "Target Milestone left to default", "Enter bug summary");
-$sel->type_ok("comment", "Created by Selenium to test 'musthavemilestoneonaccept'", "Enter bug description");
+$sel->selected_label_is("component", "TestComponent",
+  "Component already selected (no other component defined)");
+$sel->selected_label_is("target_milestone", "---",
+  "Default milestone selected");
+$sel->selected_label_is("version", "unspecified",
+  "Version already selected (no other version defined)");
+$sel->type_ok(
+  "short_desc",
+  "Target Milestone left to default",
+  "Enter bug summary"
+);
+$sel->type_ok(
+  "comment",
+  "Created by Selenium to test 'musthavemilestoneonaccept'",
+  "Enter bug description"
+);
 $sel->click_ok("commit", undef, "Commit bug data to post_bug.cgi");
 $sel->wait_for_page_to_load(WAIT_TIME);
 my $bug1_id = $sel->get_value("//input[\@name='id' and \@type='hidden']");
-$sel->is_text_present_ok('has been added to the database', "Bug $bug1_id created");
+$sel->is_text_present_ok('has been added to the database',
+  "Bug $bug1_id created");
 
 # 4th step: edit the bug (test musthavemilestoneonaccept ON).
 
-$sel->select_ok("bug_status", "label=IN_PROGRESS", "Change bug status to IN_PROGRESS");
+$sel->select_ok("bug_status", "label=IN_PROGRESS",
+  "Change bug status to IN_PROGRESS");
 $sel->click_ok("commit", undef, "Save changes");
 $sel->wait_for_page_to_load(WAIT_TIME);
-$sel->title_is("Milestone Required", "Change rejected: musthavemilestoneonaccept is on but the milestone selected is the default one");
-$sel->is_text_present_ok("You must select a target milestone", undef, "Display error message");
+$sel->title_is(
+  "Milestone Required",
+  "Change rejected: musthavemilestoneonaccept is on but the milestone selected is the default one"
+);
+$sel->is_text_present_ok("You must select a target milestone",
+  undef, "Display error message");
+
 # We cannot use go_back_ok() because we just left post_bug.cgi where data has been submitted using POST.
 go_to_bug($sel, $bug1_id);
-$sel->select_ok("target_milestone", "label=2.0", "Select a non-default milestone");
+$sel->select_ok("target_milestone", "label=2.0",
+  "Select a non-default milestone");
 $sel->click_ok("commit", undef, "Save changes (2nd attempt)");
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->is_text_present_ok("Changes submitted for bug $bug1_id");
@@ -72,14 +99,25 @@ $sel->is_text_present_ok("Changes submitted for bug $bug1_id");
 
 file_bug_in_product($sel, "TestProduct");
 $sel->select_ok("target_milestone", "label=2.0", "Set the milestone to 2.0");
-$sel->selected_label_is("component", "TestComponent", "Component already selected (no other component defined)");
-$sel->selected_label_is("version", "unspecified", "Version already selected (no other version defined)");
-$sel->type_ok("short_desc", "Target Milestone set to non-default", "Enter bug summary");
-$sel->type_ok("comment", "Created by Selenium to test 'musthavemilestoneonaccept'", "Enter bug description");
+$sel->selected_label_is("component", "TestComponent",
+  "Component already selected (no other component defined)");
+$sel->selected_label_is("version", "unspecified",
+  "Version already selected (no other version defined)");
+$sel->type_ok(
+  "short_desc",
+  "Target Milestone set to non-default",
+  "Enter bug summary"
+);
+$sel->type_ok(
+  "comment",
+  "Created by Selenium to test 'musthavemilestoneonaccept'",
+  "Enter bug description"
+);
 $sel->click_ok("commit", undef, "Commit bug data to post_bug.cgi");
 $sel->wait_for_page_to_load(WAIT_TIME);
 my $bug2_id = $sel->get_value("//input[\@name='id' and \@type='hidden']");
-$sel->is_text_present_ok('has been added to the database', "Bug $bug2_id created");
+$sel->is_text_present_ok('has been added to the database',
+  "Bug $bug2_id created");
 
 # 6th step: edit the bug (test musthavemilestoneonaccept ON).
 
@@ -115,7 +153,8 @@ $sel->click_ok("create");
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_is("Invalid Milestone Sortkey");
 my $error_msg = trim($sel->get_text("error_msg"));
-ok($error_msg =~ /^The sortkey '99999999999999999' is not in the range/, "Invalid sortkey");
+ok($error_msg =~ /^The sortkey '99999999999999999' is not in the range/,
+  "Invalid sortkey");
 $sel->go_back_ok();
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->type_ok("sortkey", "-polu7A");
@@ -124,7 +163,8 @@ $sel->click_ok("create");
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_is("Invalid Milestone Sortkey");
 $error_msg = trim($sel->get_text("error_msg"));
-ok($error_msg =~ /^The sortkey '-polu7A' is not in the range/, "Invalid sortkey");
+ok($error_msg =~ /^The sortkey '-polu7A' is not in the range/,
+  "Invalid sortkey");
 $sel->go_back_ok();
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->click_ok("link='TestProduct'");
@@ -133,7 +173,8 @@ $sel->title_is("Select milestone of product 'TestProduct'");
 $sel->click_ok("link=Delete");
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_is("Delete Milestone of Product 'TestProduct'");
-$sel->is_text_present_ok("When you delete this milestone", undef, "Warn the user about bugs being affected");
+$sel->is_text_present_ok("When you delete this milestone",
+  undef, "Warn the user about bugs being affected");
 $sel->click_ok("delete");
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_is("Milestone Deleted");
@@ -142,19 +183,30 @@ $sel->title_is("Milestone Deleted");
 
 $sel->open_ok("/$config->{bugzilla_installation}/show_bug.cgi?id=$bug1_id");
 $sel->title_like(qr/^$bug1_id/);
-$sel->is_text_present_ok('regexp:Target Milestone:\W+---', undef, "Milestone has fallen back to the default milestone");
+$sel->is_text_present_ok('regexp:Target Milestone:\W+---',
+  undef, "Milestone has fallen back to the default milestone");
 
 # 9th step: file another bug.
 
 file_bug_in_product($sel, "TestProduct");
-$sel->selected_label_is("target_milestone", "---", "Default milestone selected");
+$sel->selected_label_is("target_milestone", "---",
+  "Default milestone selected");
 $sel->selected_label_is("component", "TestComponent");
-$sel->type_ok("short_desc", "Only one Target Milestone available", "Enter bug summary");
-$sel->type_ok("comment", "Created by Selenium to test 'musthavemilestoneonaccept'", "Enter bug description");
+$sel->type_ok(
+  "short_desc",
+  "Only one Target Milestone available",
+  "Enter bug summary"
+);
+$sel->type_ok(
+  "comment",
+  "Created by Selenium to test 'musthavemilestoneonaccept'",
+  "Enter bug description"
+);
 $sel->click_ok("commit", undef, "Commit bug data to post_bug.cgi");
 $sel->wait_for_page_to_load(WAIT_TIME);
 my $bug3_id = $sel->get_value("//input[\@name='id' and \@type='hidden']");
-$sel->is_text_present_ok('has been added to the database', "Bug $bug3_id created");
+$sel->is_text_present_ok('has been added to the database',
+  "Bug $bug3_id created");
 
 # 10th step: musthavemilestoneonaccept must have no effect as there is
 #            no other milestone available besides the default one.
@@ -166,5 +218,6 @@ $sel->is_text_present_ok("Changes submitted for bug $bug3_id");
 
 # 11th step: turn musthavemilestoneonaccept back to OFF.
 
-set_parameters($sel, {'Bug Change Policies' => {'musthavemilestoneonaccept-off' => undef}});
+set_parameters($sel,
+  {'Bug Change Policies' => {'musthavemilestoneonaccept-off' => undef}});
 logout($sel);
index f0754ca2286d68f9c02e2a17054322613b94dd2d..3c5de56e6918c908584c0fc07654fe9af735a3a4 100644 (file)
@@ -21,16 +21,22 @@ my ($sel, $config) = get_selenium(CHROME_MODE);
 # we can view and delete attachments.
 
 log_in($sel, $config, 'admin');
-set_parameters($sel, { "Group Security" => {"insidergroup" => {type => "select", value => "admin"}},
-                       "Attachments"    => {"allow_attachment_display-on" => undef,
-                                            "allow_attachment_deletion-on" => undef}
-                     });
+set_parameters(
+  $sel,
+  {
+    "Group Security" => {"insidergroup" => {type => "select", value => "admin"}},
+    "Attachments"    => {
+      "allow_attachment_display-on"  => undef,
+      "allow_attachment_deletion-on" => undef
+    }
+  }
+);
 
 # First create a new bug with a private attachment.
 
 file_bug_in_product($sel, "TestProduct");
 $sel->type_ok("short_desc", "Some comments are private");
-$sel->type_ok("comment", "and some attachments too, like this one.");
+$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->attach_file('//input[@name="data"]', $config->{attachment_file});
@@ -42,7 +48,8 @@ $sel->is_text_present_ok('has been added to the database', 'Bug created');
 my $bug1_id = $sel->get_value('//input[@name="id" and @type="hidden"]');
 $sel->is_text_present_ok("private attachment, v1 (");
 $sel->is_text_present_ok("and some attachments too, like this one.");
-$sel->is_checked_ok('//a[@id="comment_link_0"]/../..//div//input[@type="checkbox"]');
+$sel->is_checked_ok(
+  '//a[@id="comment_link_0"]/../..//div//input[@type="checkbox"]');
 
 # Now attach a public patch to the existing bug.
 
@@ -52,6 +59,7 @@ $sel->title_is("Create New Attachment for Bug #$bug1_id");
 $sel->attach_file('//input[@name="data"]', $config->{attachment_file});
 $sel->type_ok('//input[@name="description"]', "public attachment, v2");
 $sel->check_ok('//input[@name="ispatch"]');
+
 # The existing attachment name must be displayed, to mark it as obsolete.
 $sel->is_text_present_ok("private attachment, v1");
 $sel->type_ok("comment", "this patch is public. Everyone can see it.");
@@ -73,31 +81,40 @@ $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_like(qr/^$bug1_id/);
 $sel->is_text_present_ok("public attachment, v2");
 $sel->is_text_present_ok("this patch is public. Everyone can see it.");
-ok(!$sel->is_checked('//a[@id="comment_link_1"]/../..//div//input[@type="checkbox"]'), "Public attachment is visible");
+ok(
+  !$sel->is_checked(
+    '//a[@id="comment_link_1"]/../..//div//input[@type="checkbox"]'),
+  "Public attachment is visible"
+);
 logout($sel);
 
 # A logged out user cannot see the private attachment, only the public one.
 # Same for a user with no privs.
 
 foreach my $user ('', 'unprivileged') {
-    log_in($sel, $config, $user) if $user;
-    go_to_bug($sel, $bug1_id);
-    ok(!$sel->is_text_present("private attachment, v1"), "Private attachment not visible");
-    $sel->is_text_present_ok("public attachment, v2");
-    ok(!$sel->is_text_present("and some attachments too, like this one"), "Private comment not visible");
-    $sel->is_text_present_ok("this patch is public. Everyone can see it.");
+  log_in($sel, $config, $user) if $user;
+  go_to_bug($sel, $bug1_id);
+  ok(!$sel->is_text_present("private attachment, v1"),
+    "Private attachment not visible");
+  $sel->is_text_present_ok("public attachment, v2");
+  ok(!$sel->is_text_present("and some attachments too, like this one"),
+    "Private comment not visible");
+  $sel->is_text_present_ok("this patch is public. Everyone can see it.");
 }
 
 # A powerless user can comment on attachments he doesn't own.
 
-$sel->click_ok('//a[contains(@href,"/attachment.cgi?id=' . $attachment1_id . '&action=edit")]');
+$sel->click_ok('//a[contains(@href,"/attachment.cgi?id='
+    . $attachment1_id
+    . '&action=edit")]');
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_like(qr/^Attachment $attachment1_id Details for Bug $bug1_id/);
 $sel->is_text_present_ok("created by QA Admin");
 $sel->type_ok("comment", "This attachment is not mine.");
 $sel->click_ok("update");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
-$sel->is_text_present_ok("Changes to attachment $attachment1_id of bug $bug1_id submitted");
+$sel->is_text_present_ok(
+  "Changes to attachment $attachment1_id of bug $bug1_id submitted");
 $sel->click_ok("link=bug $bug1_id");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_like(qr/^$bug1_id/);
@@ -111,14 +128,17 @@ $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Create New Attachment for Bug #$bug1_id");
 $sel->attach_file('//input[@name="data"]', $config->{attachment_file});
 $sel->check_ok('//input[@name="ispatch"]');
+
 # The user doesn't have editbugs privs.
 $sel->is_text_present_ok("[no attachments can be made obsolete]");
-$sel->type_ok('//input[@name="description"]', "My patch, which I should see, always");
+$sel->type_ok('//input[@name="description"]',
+  "My patch, which I should see, always");
 $sel->type_ok("comment", "This is my patch!");
 $sel->click_ok("create");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->is_text_present_ok('regexp:Attachment #\d+ to bug \d+ created');
-$alink = $sel->get_attribute('//a[@title="My patch, which I should see, always"]@href');
+$alink = $sel->get_attribute(
+  '//a[@title="My patch, which I should see, always"]@href');
 $alink =~ /id=(\d+)/;
 my $attachment2_id = $1;
 $sel->click_ok("link=bug $bug1_id");
@@ -132,29 +152,40 @@ logout($sel);
 
 log_in($sel, $config, 'admin');
 go_to_bug($sel, $bug1_id);
-$sel->click_ok('//a[contains(@href,"/attachment.cgi?id=' . $attachment2_id . '&action=edit")]');
+$sel->click_ok('//a[contains(@href,"/attachment.cgi?id='
+    . $attachment2_id
+    . '&action=edit")]');
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_like(qr/^Attachment $attachment2_id Details for Bug $bug1_id/);
 $sel->check_ok("isprivate");
 $sel->type_ok("comment", "Making the powerless user's patch private.");
 $sel->click_ok("update");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
-$sel->is_text_present_ok("Changes to attachment $attachment2_id of bug $bug1_id submitted");
+$sel->is_text_present_ok(
+  "Changes to attachment $attachment2_id of bug $bug1_id submitted");
 $sel->click_ok("link=bug $bug1_id");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_like(qr/^$bug1_id/);
 $sel->is_text_present_ok("My patch, which I should see, always (");
-$sel->is_checked_ok('//a[@id="comment_link_4"]/../..//div//input[@type="checkbox"]');
+$sel->is_checked_ok(
+  '//a[@id="comment_link_4"]/../..//div//input[@type="checkbox"]');
 $sel->is_text_present_ok("Making the powerless user's patch private.");
 logout($sel);
 
 # A logged out user cannot see private attachments.
 
 go_to_bug($sel, $bug1_id);
-ok(!$sel->is_text_present("private attachment, v1"), "Private attachment not visible to logged out users");
-ok(!$sel->is_text_present("My patch, which I should see, always ("), "Private attachment not visible to logged out users");
+ok(
+  !$sel->is_text_present("private attachment, v1"),
+  "Private attachment not visible to logged out users"
+);
+ok(
+  !$sel->is_text_present("My patch, which I should see, always ("),
+  "Private attachment not visible to logged out users"
+);
 $sel->is_text_present_ok("This is my patch!");
-ok(!$sel->is_text_present("Making the powerless user's patch private"), "Private comment not visible to logged out users");
+ok(!$sel->is_text_present("Making the powerless user's patch private"),
+  "Private comment not visible to logged out users");
 
 # A powerless user can only see private attachments he owns.
 
@@ -163,6 +194,7 @@ go_to_bug($sel, $bug1_id);
 $sel->is_text_present_ok("My patch, which I should see, always (");
 $sel->click_ok("link=My patch, which I should see, always");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
+
 # No title displayed while viewing an attachment.
 $sel->title_is("");
 $sel->go_back_ok();
@@ -173,7 +205,9 @@ logout($sel);
 
 log_in($sel, $config, 'admin');
 go_to_bug($sel, $bug1_id);
-$sel->click_ok('//a[contains(@href,"/attachment.cgi?id=' . $attachment2_id . '&action=edit")]');
+$sel->click_ok('//a[contains(@href,"/attachment.cgi?id='
+    . $attachment2_id
+    . '&action=edit")]');
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_like(qr/^Attachment $attachment2_id Details for Bug $bug1_id/);
 $sel->click_ok("link=Delete");
@@ -183,7 +217,8 @@ $sel->is_text_present_ok("Do you really want to delete this attachment?");
 $sel->type_ok("reason", "deleted by Selenium");
 $sel->click_ok("delete");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
-$sel->is_text_present_ok("Changes to attachment $attachment2_id of bug $bug1_id submitted");
+$sel->is_text_present_ok(
+  "Changes to attachment $attachment2_id of bug $bug1_id submitted");
 $sel->click_ok("link=bug $bug1_id");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_like(qr/^$bug1_id/);
@@ -191,10 +226,14 @@ $sel->is_text_present_ok("deleted by Selenium");
 $sel->click_ok("link=attachment $attachment2_id");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Attachment Removed");
-$sel->is_text_present_ok("The attachment you are attempting to access has been removed");
-
-set_parameters($sel, {
-    "Group Security" => {"insidergroup" => { type => "select",
-                                             value => "QA-Selenium-TEST" }},
-});
+$sel->is_text_present_ok(
+  "The attachment you are attempting to access has been removed");
+
+set_parameters(
+  $sel,
+  {
+    "Group Security" =>
+      {"insidergroup" => {type => "select", value => "QA-Selenium-TEST"}},
+  }
+);
 logout($sel);
index 3795e2edcc579dabdb0abbfc0542aeed848d627e..65ff14e3be2e86bb046e7b22dddd6a2964b047e1 100644 (file)
@@ -18,28 +18,38 @@ my ($sel, $config) = get_selenium();
 # First make sure the 'My QA query' saved search is gone.
 
 log_in($sel, $config, 'admin');
-if($sel->is_text_present("My QA query")) {
-    $sel->open_ok("/$config->{bugzilla_installation}/buglist.cgi?cmdtype=dorem&remaction=forget&namedcmd=My%20QA%20query",
-                  undef, "Make sure the 'My QA query' saved search isn't present");
-    # We bypass the UI to delete the saved search, and so Bugzilla should complain about the missing token.
-    $sel->title_is("Suspicious Action");
-    $sel->is_text_present_ok("It looks like you didn't come from the right page");
-    $sel->click_ok("confirm");
-    $sel->wait_for_page_to_load_ok(WAIT_TIME);
-    $sel->title_is("Search is gone");
-    my $text = trim($sel->get_text("message"));
-    ok($text =~ /OK, the My QA query search is gone/, "Removed the 'My QA query' saved search");
+if ($sel->is_text_present("My QA query")) {
+  $sel->open_ok(
+    "/$config->{bugzilla_installation}/buglist.cgi?cmdtype=dorem&remaction=forget&namedcmd=My%20QA%20query",
+    undef, "Make sure the 'My QA query' saved search isn't present"
+  );
+
+# We bypass the UI to delete the saved search, and so Bugzilla should complain about the missing token.
+  $sel->title_is("Suspicious Action");
+  $sel->is_text_present_ok("It looks like you didn't come from the right page");
+  $sel->click_ok("confirm");
+  $sel->wait_for_page_to_load_ok(WAIT_TIME);
+  $sel->title_is("Search is gone");
+  my $text = trim($sel->get_text("message"));
+  ok(
+    $text =~ /OK, the My QA query search is gone/,
+    "Removed the 'My QA query' saved search"
+  );
 }
 
 # Enable the QA contact field and file a new bug restricted to the 'Master' group
 # with a powerless user as the QA contact. He should only be able to access the
 # bug if the QA contact field is enabled, else he looses this privilege.
 
-set_parameters($sel, { "Bug Fields" => {"useqacontact-on" => undef} });
+set_parameters($sel, {"Bug Fields" => {"useqacontact-on" => undef}});
 file_bug_in_product($sel, 'TestProduct');
-$sel->type_ok("qa_contact", $config->{unprivileged_user_login}, "Set the powerless user as QA contact");
+$sel->type_ok(
+  "qa_contact",
+  $config->{unprivileged_user_login},
+  "Set the powerless user as QA contact"
+);
 $sel->type_ok("short_desc", "Test for QA contact");
-$sel->type_ok("comment", "This is a test to check QA contact privs.");
+$sel->type_ok("comment",    "This is a test to check QA contact privs.");
 $sel->check_ok('//input[@name="groups" and @value="Master"]');
 $sel->click_ok("commit");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
@@ -55,7 +65,11 @@ $sel->add_selection_ok("product", "TestProduct");
 $sel->remove_all_selections("bug_status");
 $sel->select_ok("f1", "label=QA Contact");
 $sel->select_ok("o1", "label=is equal to");
-$sel->type_ok("v1", $config->{unprivileged_user_login}, "Look for the powerless user as QA contact");
+$sel->type_ok(
+  "v1",
+  $config->{unprivileged_user_login},
+  "Look for the powerless user as QA contact"
+);
 $sel->click_ok("Search");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Bug List");
@@ -66,7 +80,8 @@ $sel->click_ok("remember");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Search created");
 my $text = trim($sel->get_text("message"));
-ok($text =~ /OK, you have a new search named My QA query/, "New saved search 'My QA query'");
+ok($text =~ /OK, you have a new search named My QA query/,
+  "New saved search 'My QA query'");
 $sel->click_ok("link=My QA query");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Bug List: My QA query");
@@ -77,7 +92,7 @@ $sel->is_text_present_ok("Test for QA contact");
 # ("work" doesn't mean you should still see all bugs, depending on your role
 # and privs!)
 
-set_parameters($sel, { "Bug Fields" => {"useqacontact-off" => undef} });
+set_parameters($sel, {"Bug Fields" => {"useqacontact-off" => undef}});
 $sel->click_ok("link=My QA query");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Bug List: My QA query");
@@ -86,6 +101,7 @@ $sel->is_element_present_ok("b$bug1_id", undef, "Bug $bug1_id is on the list");
 $sel->click_ok("link=$bug1_id");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_like(qr/^$bug1_id /);
+
 # The 'QA Contact' label must not be displayed.
 ok(!$sel->is_element_present('//label[@for="qa_contact"]'));
 logout($sel);
@@ -103,12 +119,21 @@ $sel->is_text_present_ok("You are not authorized to access bug");
 # powerless user, as the QA contact field is disabled.
 # Don't use it log_in() as we want to follow this specific link.
 
-$sel->click_ok("//a[contains(text(),'log\n    in to an account')]", undef, "Log in");
+$sel->click_ok("//a[contains(text(),'log\n    in to an account')]",
+  undef, "Log in");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Log in to Bugzilla");
 $sel->is_text_present_ok("I need an email address and password to continue.");
-$sel->type_ok("Bugzilla_login", $config->{unprivileged_user_login}, "Enter login name");
-$sel->type_ok("Bugzilla_password", $config->{unprivileged_user_passwd}, "Enter password");
+$sel->type_ok(
+  "Bugzilla_login",
+  $config->{unprivileged_user_login},
+  "Enter login name"
+);
+$sel->type_ok(
+  "Bugzilla_password",
+  $config->{unprivileged_user_passwd},
+  "Enter password"
+);
 $sel->click_ok("log_in", undef, "Submit credentials");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Access Denied");
@@ -118,7 +143,7 @@ logout($sel);
 # Re-enable the QA contact field.
 
 log_in($sel, $config, 'admin');
-set_parameters($sel, { "Bug Fields" => {"useqacontact-on" => undef} });
+set_parameters($sel, {"Bug Fields" => {"useqacontact-on" => undef}});
 logout($sel);
 
 # Log in as the powerless user. As the QA contact field is enabled again,
@@ -132,7 +157,7 @@ $sel->title_is("User Preferences");
 $sel->click_ok("link=General Preferences");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("User Preferences");
-$sel->select_ok("state_addselfcc", "value=never");
+$sel->select_ok("state_addselfcc",        "value=never");
 $sel->select_ok("post_bug_submit_action", "value=same_bug");
 $sel->click_ok("update");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
@@ -144,7 +169,11 @@ $sel->add_selection_ok("product", "TestProduct");
 $sel->remove_all_selections_ok("bug_status");
 $sel->select_ok("f1", "label=QA Contact");
 $sel->select_ok("o1", "label=is equal to");
-$sel->type_ok("v1", $config->{unprivileged_user_login}, "Look for the powerless user as QA contact");
+$sel->type_ok(
+  "v1",
+  $config->{unprivileged_user_login},
+  "Look for the powerless user as QA contact"
+);
 $sel->click_ok("Search");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Bug List");
@@ -155,7 +184,11 @@ $sel->click_ok("link=$bug1_id");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_like(qr/$bug1_id /);
 $sel->click_ok("bz_qa_contact_edit_action");
-$sel->value_is("qa_contact", $config->{unprivileged_user_login}, "The powerless user is the current QA contact");
+$sel->value_is(
+  "qa_contact",
+  $config->{unprivileged_user_login},
+  "The powerless user is the current QA contact"
+);
 $sel->check_ok("set_default_qa_contact");
 $sel->click_ok("commit");
 
index 1cfd5b42f6bac9987fdc6e3ef108699ca94c1481..f8d2629f9d8b05d018938d339dd17f3719975529 100644 (file)
@@ -18,61 +18,65 @@ my ($sel, $config) = get_selenium();
 # Turn on 'requirelogin'.
 
 log_in($sel, $config, 'admin');
-set_parameters($sel, { "User Authentication" => {"requirelogin-on" => undef} });
+set_parameters($sel, {"User Authentication" => {"requirelogin-on" => undef}});
 logout($sel);
 
 # We try to access each page. None of the ones listed below should
 # let you view it without being logged in.
 
 my @pages = qw(admin attachment buglist chart colchange describecomponents
-               describekeywords duplicates editclassifications editcomponents
-               editfields editflagtypes editgroups editkeywords editmilestones
-               editparams editproducts editsettings editusers editvalues
-               editversions editwhines editworkflow enter_bug long_list page
-               post_bug process_bug query quips report reports request
-               sanitycheck search_plugin show_activity show_bug showattachment
-               showdependencygraph showdependencytree summarize_time
-               userprefs votes xml);
+  describekeywords duplicates editclassifications editcomponents
+  editfields editflagtypes editgroups editkeywords editmilestones
+  editparams editproducts editsettings editusers editvalues
+  editversions editwhines editworkflow enter_bug long_list page
+  post_bug process_bug query quips report reports request
+  sanitycheck search_plugin show_activity show_bug showattachment
+  showdependencygraph showdependencytree summarize_time
+  userprefs votes xml);
 
 foreach my $page (@pages) {
-    $sel->open_ok("/$config->{bugzilla_installation}/${page}.cgi");
-    if ($page ne 'votes' || $config->{test_extensions}) {
-        $sel->title_is("Log in to Bugzilla");
-    }
-    else {
-        $sel->title_is("Extension Disabled");
-    }
+  $sel->open_ok("/$config->{bugzilla_installation}/${page}.cgi");
+  if ($page ne 'votes' || $config->{test_extensions}) {
+    $sel->title_is("Log in to Bugzilla");
+  }
+  else {
+    $sel->title_is("Extension Disabled");
+  }
 }
 
 # Those have parameters passed to the page, so we put them here separately.
 
-@pages = ("query.cgi?format=report-table", "query.cgi?format=report-graph",
-          "votes.cgi?action=show_user", "votes.cgi?action=show_bug");
+@pages = (
+  "query.cgi?format=report-table", "query.cgi?format=report-graph",
+  "votes.cgi?action=show_user",    "votes.cgi?action=show_bug"
+);
 
 foreach my $page (@pages) {
-    $sel->open_ok("/$config->{bugzilla_installation}/$page");
-    if ($page !~ /^votes/ || $config->{test_extensions}) {
-        $sel->title_is("Log in to Bugzilla");
-    }
-    else {
-        $sel->title_is("Extension Disabled");
-    }
+  $sel->open_ok("/$config->{bugzilla_installation}/$page");
+  if ($page !~ /^votes/ || $config->{test_extensions}) {
+    $sel->title_is("Log in to Bugzilla");
+  }
+  else {
+    $sel->title_is("Extension Disabled");
+  }
 }
 
 # These pages should still be accessible.
 
-@pages = ("config.cgi", "createaccount.cgi", "index.cgi", "relogin.cgi",
-          "token.cgi?a=reqpw&loginname=" . $config->{unprivileged_user_login});
+@pages = (
+  "config.cgi", "createaccount.cgi", "index.cgi", "relogin.cgi",
+  "token.cgi?a=reqpw&loginname=" . $config->{unprivileged_user_login}
+);
 
 foreach my $page (@pages) {
-    $sel->open_ok("/$config->{bugzilla_installation}/$page");
-    $sel->title_isnt("Log in to Bugzilla");
+  $sel->open_ok("/$config->{bugzilla_installation}/$page");
+  $sel->title_isnt("Log in to Bugzilla");
 }
 
 # Turn off 'requirelogin'.
 
 log_in($sel, $config, 'admin');
-set_parameters($sel, { "User Authentication" => {"requirelogin-off" => undef} });
+set_parameters($sel, {"User Authentication" => {"requirelogin-off" => undef}});
 logout($sel);
 
 # Make sure we can access random pages again.
index 06ab5735528a4d2deab2594a22f1b0c8d70a72d4..2a3bbe1de2d8d9dfb1921dc1990fdd3576b4b89a 100644 (file)
@@ -20,27 +20,33 @@ go_to_admin($sel);
 $sel->click_ok("link=Sanity Check", undef, "Go to Sanity Check (no parameter)");
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_is("Sanity Check", "Display sanitycheck.cgi");
-$sel->is_text_present_ok("Sanity check completed.", undef, "Page displayed correctly");
+$sel->is_text_present_ok("Sanity check completed.",
+  undef, "Page displayed correctly");
 
-my @args = qw(rebuildvotecache createmissinggroupcontrolmapentries repair_creation_date
-              repair_bugs_fulltext remove_invalid_bug_references repair_bugs_fulltext
-              remove_invalid_attach_references remove_old_whine_targets rescanallBugMail);
+my @args
+  = qw(rebuildvotecache createmissinggroupcontrolmapentries repair_creation_date
+  repair_bugs_fulltext remove_invalid_bug_references repair_bugs_fulltext
+  remove_invalid_attach_references remove_old_whine_targets rescanallBugMail);
 
 foreach my $arg (@args) {
-    $sel->open_ok("/$config->{bugzilla_installation}/sanitycheck.cgi?$arg=1");
-    $sel->title_is("Suspicious Action", "Calling sanitycheck.cgi with no token triggers a confirmation page");
-    $sel->click_ok("confirm", "Confirm the action");
-    $sel->wait_for_page_to_load(WAIT_TIME);
-    $sel->title_is("Sanity Check", "Calling sanitycheck.cgi with $arg=1");
-    if ($arg eq 'rescanallBugMail') {
-        # sanitycheck.cgi always stops after looking for unsent bugmail. So we cannot rely on
-        # "Sanity check completed." to determine if an error has been thrown or not.
-        $sel->is_text_present_ok("found with possibly unsent mail", undef, "Look for unsent bugmail");
-        ok(!$sel->is_text_present("Software error"), "No error thrown");
-    }
-    else {
-        $sel->is_text_present_ok("Sanity check completed.", undef, "Page displayed correctly");
-    }
+  $sel->open_ok("/$config->{bugzilla_installation}/sanitycheck.cgi?$arg=1");
+  $sel->title_is("Suspicious Action",
+    "Calling sanitycheck.cgi with no token triggers a confirmation page");
+  $sel->click_ok("confirm", "Confirm the action");
+  $sel->wait_for_page_to_load(WAIT_TIME);
+  $sel->title_is("Sanity Check", "Calling sanitycheck.cgi with $arg=1");
+  if ($arg eq 'rescanallBugMail') {
+
+# sanitycheck.cgi always stops after looking for unsent bugmail. So we cannot rely on
+# "Sanity check completed." to determine if an error has been thrown or not.
+    $sel->is_text_present_ok("found with possibly unsent mail",
+      undef, "Look for unsent bugmail");
+    ok(!$sel->is_text_present("Software error"), "No error thrown");
+  }
+  else {
+    $sel->is_text_present_ok("Sanity check completed.",
+      undef, "Page displayed correctly");
+  }
 }
 
 logout($sel);
index 91ccd261710445e1720fc7bfeb2bf567b2682a24..920385b1926462b9cc7a638f224cea1e38d5d25f 100644 (file)
@@ -25,12 +25,15 @@ $sel->click_ok("link=Saved Searches");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("User Preferences");
 
-if($sel->is_text_present("SavedSearchTEST1")) {
-    # There is no other way to identify this link (as they are all named "Forget").
-    $sel->click_ok('//a[contains(@href,"/buglist.cgi?cmdtype=dorem&remaction=forget&namedcmd=SavedSearchTEST1")]');
-    $sel->wait_for_page_to_load_ok(WAIT_TIME);
-    $sel->title_is("Search is gone");
-    $sel->is_text_present_ok("OK, the SavedSearchTEST1 search is gone.");
+if ($sel->is_text_present("SavedSearchTEST1")) {
+
+  # There is no other way to identify this link (as they are all named "Forget").
+  $sel->click_ok(
+    '//a[contains(@href,"/buglist.cgi?cmdtype=dorem&remaction=forget&namedcmd=SavedSearchTEST1")]'
+  );
+  $sel->wait_for_page_to_load_ok(WAIT_TIME);
+  $sel->title_is("Search is gone");
+  $sel->is_text_present_ok("OK, the SavedSearchTEST1 search is gone.");
 }
 
 # Create a new saved search.
@@ -45,7 +48,10 @@ $sel->click_ok("remember");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Search created");
 my $text = trim($sel->get_text("message"));
-ok($text =~ /OK, you have a new search named SavedSearchTEST1./, "New search named SavedSearchTEST1 has been created");
+ok(
+  $text =~ /OK, you have a new search named SavedSearchTEST1./,
+  "New search named SavedSearchTEST1 has been created"
+);
 $sel->click_ok("link=SavedSearchTEST1");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Bug List: SavedSearchTEST1");
@@ -61,12 +67,14 @@ $sel->title_is("User Preferences");
 
 $sel->is_text_present_ok("SavedSearchTEST1");
 $sel->uncheck_ok('//input[@type="checkbox" and @alt="SavedSearchTEST1"]');
+
 # $sel->value_is("//input[\@type='checkbox' and \@alt='SavedSearchTEST1']", "off");
 $sel->click_ok("update");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("User Preferences");
 $text = trim($sel->get_text("message"));
-ok($text =~ /The changes to your saved searches have been saved./, "Saved searches changes have been saved");
+ok($text =~ /The changes to your saved searches have been saved./,
+  "Saved searches changes have been saved");
 
 # Modify the saved search. Said otherwise, we should still be able to save
 # a new search with exactly the same name.
@@ -76,14 +84,21 @@ $sel->type_ok("short_desc", "bilboa");
 $sel->click_ok("Search");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Bug List");
+
 # As we said, this saved search should no longer be displayed in the Search Bar.
-ok(!$sel->is_text_present("SavedSearchTEST1"), "SavedSearchTEST1 is not present in the Search Bar");
+ok(
+  !$sel->is_text_present("SavedSearchTEST1"),
+  "SavedSearchTEST1 is not present in the Search Bar"
+);
 $sel->type_ok("save_newqueryname", "SavedSearchTEST1");
 $sel->click_ok("remember");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Search updated");
 $text = trim($sel->get_text("message"));
-ok($text =~ /Your search named SavedSearchTEST1 has been updated./, "Saved searche SavedSearchTEST1 has been updated.");
+ok(
+  $text =~ /Your search named SavedSearchTEST1 has been updated./,
+  "Saved searche SavedSearchTEST1 has been updated."
+);
 
 # Make sure our new criteria has been saved (let's edit the saved search).
 # As the saved search is no longer displayed in the Search Bar, we have to go
@@ -97,7 +112,9 @@ $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("User Preferences");
 
 $sel->is_text_present_ok("SavedSearchTEST1");
-$sel->click_ok('//a[contains(@href,"/buglist.cgi?cmdtype=dorem&remaction=run&namedcmd=SavedSearchTEST1")]');
+$sel->click_ok(
+  '//a[contains(@href,"/buglist.cgi?cmdtype=dorem&remaction=run&namedcmd=SavedSearchTEST1")]'
+);
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Bug List: SavedSearchTEST1");
 $sel->click_ok("link=Edit Search");
@@ -110,5 +127,6 @@ $sel->click_ok("link=Forget Search 'SavedSearchTEST1'");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Search is gone");
 $text = trim($sel->get_text("message"));
-ok($text =~ /OK, the SavedSearchTEST1 search is gone./, "The SavedSearchTEST1 search is gone.");
+ok($text =~ /OK, the SavedSearchTEST1 search is gone./,
+  "The SavedSearchTEST1 search is gone.");
 logout($sel);
index d479cc2637ebaef2bf03467b4989a5237b27f4e1..2a79934652da5ba688bbba92c2957eb20da44fec 100644 (file)
@@ -20,7 +20,8 @@ my ($sel, $config) = get_selenium();
 
 go_to_home($sel, $config);
 open_advanced_search_page($sel);
-$sel->type_ok("short_desc", "ois£jdfm#sd%fasd!fm", "Type a non-existent string in the bug summary field");
+$sel->type_ok("short_desc", "ois£jdfm#sd%fasd!fm",
+  "Type a non-existent string in the bug summary field");
 $sel->click_ok("Search");
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_is("Bug List");
@@ -28,7 +29,9 @@ $sel->is_text_present_ok("Zarro Boogs found");
 
 # Display all available columns. Look for all bugs assigned to a user who doesn't exist.
 
-$sel->open_ok("/$config->{bugzilla_installation}/buglist.cgi?quicksearch=%40xx45ft&columnlist=all");
+$sel->open_ok(
+  "/$config->{bugzilla_installation}/buglist.cgi?quicksearch=%40xx45ft&columnlist=all"
+);
 $sel->title_like(qr/^Bug List:/);
 $sel->is_text_present_ok("Zarro Boogs found");
 
@@ -38,12 +41,12 @@ log_in($sel, $config, 'canconfirm');
 file_bug_in_product($sel, "TestProduct");
 my $bug_summary = "Update this summary with this bug ID";
 $sel->type_ok("short_desc", $bug_summary);
-$sel->type_ok("comment", "I'm supposed to appear in the coming buglist.");
+$sel->type_ok("comment",    "I'm supposed to appear in the coming buglist.");
 my $bug1_id = create_bug($sel, $bug_summary);
 $sel->click_ok("editme_action");
 $bug_summary .= ": my ID is $bug1_id";
 $sel->type_ok("short_desc", $bug_summary);
-$sel->type_ok("comment", "Updating bug summary....");
+$sel->type_ok("comment",    "Updating bug summary....");
 $sel->click_ok("commit");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->is_text_present_ok("Changes submitted for bug $bug1_id");
@@ -67,5 +70,6 @@ $sel->click_ok("Search");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Bug List");
 $sel->is_text_present_ok("One bug found");
-$sel->is_text_present_ok("Update this summary with this bug ID: my ID is $bug1_id");
+$sel->is_text_present_ok(
+  "Update this summary with this bug ID: my ID is $bug1_id");
 logout($sel);
index 97089cdac07cf613051475355d8929d11857dc0b..7e975eccabc46cc85ba2e28d630964b2f4c8d420 100644 (file)
@@ -14,7 +14,7 @@ use Test::More "no_plan";
 use QA::Util;
 
 my ($sel, $config) = get_selenium(CHROME_MODE);
-my $urlbase = $config->{bugzilla_installation};
+my $urlbase    = $config->{bugzilla_installation};
 my $admin_user = $config->{admin_user_login};
 
 # Let's create a bug and attachment to play with.
@@ -23,7 +23,7 @@ log_in($sel, $config, 'admin');
 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("comment",    "This bug will be used to test security fixes.");
 $sel->attach_file('//input[@name="data"]', $config->{attachment_file});
 $sel->type_ok('//input[@name="description"]', "simple patch, v1");
 my $bug1_id = create_bug($sel, $bug_summary);
@@ -35,7 +35,8 @@ my $bug1_id = create_bug($sel, $bug_summary);
 
 # No alternate host for attachments; cookies will be accessible.
 
-set_parameters($sel, { "Attachments" => {"allow_attachment_display-on" => undef } });
+set_parameters($sel,
+  {"Attachments" => {"allow_attachment_display-on" => undef}});
 
 go_to_bug($sel, $bug1_id);
 $sel->click_ok("link=simple patch, v1");
@@ -45,7 +46,8 @@ my @cookies = split(/[\s;]+/, $sel->get_cookie());
 my $nb_cookies = scalar @cookies;
 ok($nb_cookies, "Found $nb_cookies cookies:\n" . join("\n", @cookies));
 ok(!$sel->is_cookie_present("Bugzilla_login"), "Bugzilla_login not accessible");
-ok(!$sel->is_cookie_present("Bugzilla_logincookie"), "Bugzilla_logincookie not accessible");
+ok(!$sel->is_cookie_present("Bugzilla_logincookie"),
+  "Bugzilla_logincookie not accessible");
 $sel->go_back_ok();
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_like(qr/^$bug1_id /);
@@ -85,25 +87,30 @@ my $editbugs_cookie = $sel->get_value("token");
 
 # Using our own unused token is fine.
 
-$sel->open_ok("/$urlbase/userprefs.cgi?tab=settings&dosave=1&display_quips=off&token=$editbugs_cookie");
+$sel->open_ok(
+  "/$urlbase/userprefs.cgi?tab=settings&dosave=1&display_quips=off&token=$editbugs_cookie"
+);
 $sel->title_is("User Preferences");
-$sel->is_text_present_ok("The changes to your general preferences have been saved");
+$sel->is_text_present_ok(
+  "The changes to your general preferences have been saved");
 
 # Reusing a token must fail. They must all trigger the Suspicious Action warning.
 
-my @args = ("", "token=", "token=i123x", "token=$admin_cookie", "token=$editbugs_cookie");
+my @args = ("", "token=", "token=i123x", "token=$admin_cookie",
+  "token=$editbugs_cookie");
 
 foreach my $arg (@args) {
-    $sel->open_ok("/$urlbase/userprefs.cgi?tab=settings&dosave=1&display_quips=off&$arg");
-    $sel->title_is("Suspicious Action");
-
-    if ($arg eq "token=$admin_cookie") {
-        $sel->is_text_present_ok("Generated by: QA Admin <$admin_user>");
-        $sel->is_text_present_ok("This token has not been generated by you");
-    }
-    else {
-        $sel->is_text_present_ok("It looks like you didn't come from the right page");
-    }
+  $sel->open_ok(
+    "/$urlbase/userprefs.cgi?tab=settings&dosave=1&display_quips=off&$arg");
+  $sel->title_is("Suspicious Action");
+
+  if ($arg eq "token=$admin_cookie") {
+    $sel->is_text_present_ok("Generated by: QA Admin <$admin_user>");
+    $sel->is_text_present_ok("This token has not been generated by you");
+  }
+  else {
+    $sel->is_text_present_ok("It looks like you didn't come from the right page");
+  }
 }
 logout($sel);
 
@@ -116,8 +123,8 @@ file_bug_in_product($sel, "TestProduct");
 $sel->type_ok("alias", "secret_qa_bug_" . ($bug1_id + 1));
 my $bug_summary2 = "Private QA Bug";
 $sel->type_ok("short_desc", $bug_summary2);
-$sel->type_ok("comment", "This private bug is used to test security fixes.");
-$sel->type_ok("dependson", $bug1_id);
+$sel->type_ok("comment",    "This private bug is used to test security fixes.");
+$sel->type_ok("dependson",  $bug1_id);
 $sel->check_ok('//input[@name="groups" and @value="Master"]');
 my $bug2_id = create_bug($sel, $bug_summary2);
 
@@ -127,12 +134,14 @@ logout($sel);
 
 log_in($sel, $config, 'editbugs');
 go_to_bug($sel, $bug1_id);
-ok(!$sel->is_text_present("secret_qa_bug_$bug2_id"), "The alias 'secret_qa_bug_$bug2_id' is not visible for unauthorized users");
+ok(!$sel->is_text_present("secret_qa_bug_$bug2_id"),
+  "The alias 'secret_qa_bug_$bug2_id' is not visible for unauthorized users");
 $sel->is_text_present_ok($bug2_id);
 logout($sel);
 
 go_to_bug($sel, $bug1_id);
-ok(!$sel->is_text_present("secret_qa_bug_$bug2_id"), "The alias 'secret_qa_bug_$bug2_id' is not visible for logged out users");
+ok(!$sel->is_text_present("secret_qa_bug_$bug2_id"),
+  "The alias 'secret_qa_bug_$bug2_id' is not visible for logged out users");
 $sel->is_text_present_ok($bug2_id);
 
 #######################################################################
@@ -143,7 +152,8 @@ $sel->is_text_present_ok($bug2_id);
 #######################################################################
 
 log_in($sel, $config, 'admin');
-set_parameters($sel, { "Attachments" => {"allow_attachment_display-off" => undef} });
+set_parameters($sel,
+  {"Attachments" => {"allow_attachment_display-off" => undef}});
 
 # Attachments are not viewable.
 
@@ -151,8 +161,10 @@ go_to_bug($sel, $bug1_id);
 $sel->click_ok("link=Details");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_like(qr/Attachment \d+ Details for Bug $bug1_id/);
-$sel->is_text_present_ok("The attachment is not viewable in your browser due to security restrictions");
+$sel->is_text_present_ok(
+  "The attachment is not viewable in your browser due to security restrictions");
 $sel->click_ok("link=View");
+
 # Wait 1 second to give the browser a chance to display the attachment.
 # Do not use wait_for_page_to_load_ok() as the File Saver will never go away.
 sleep(1);
@@ -161,7 +173,8 @@ ok(!$sel->is_text_present('@@'), "Patch not displayed");
 
 # Enable viewing attachments.
 
-set_parameters($sel, { "Attachments" => {"allow_attachment_display-on" => undef} });
+set_parameters($sel,
+  {"Attachments" => {"allow_attachment_display-on" => undef}});
 
 go_to_bug($sel, $bug1_id);
 $sel->click_ok('link=simple patch, v1');
index 89fcc9925ad6b5e157deecc5f305c40405a23855..29653b4f2cd6a8ff6db3ca8e82d68fd13fc29d16 100644 (file)
@@ -18,7 +18,13 @@ my ($sel, $config) = get_selenium();
 # Set the querysharegroup param to be the canconfirm group.
 
 log_in($sel, $config, 'admin');
-set_parameters($sel, { "Group Security" => {"querysharegroup" => {type => "select", value => "canconfirm"}} });
+set_parameters(
+  $sel,
+  {
+    "Group Security" =>
+      {"querysharegroup" => {type => "select", value => "canconfirm"}}
+  }
+);
 
 # Create new saved search and call it 'Shared Selenium buglist'.
 
@@ -31,7 +37,10 @@ $sel->click_ok("remember");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Search created");
 my $text = trim($sel->get_text("message"));
-ok($text =~ /OK, you have a new search named Shared Selenium buglist./, "New search named 'Shared Selenium buglist' has been created");
+ok(
+  $text =~ /OK, you have a new search named Shared Selenium buglist./,
+  "New search named 'Shared Selenium buglist' has been created"
+);
 
 # Retrieve the newly created saved search's internal ID and make sure it's displayed
 # in the Search Bar by default.
@@ -42,7 +51,8 @@ $sel->title_is("User Preferences");
 $sel->click_ok("link=Saved Searches");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("User Preferences");
-my $ssname = $sel->get_attribute('//input[@type="checkbox" and @alt="Shared Selenium buglist"]@name');
+my $ssname = $sel->get_attribute(
+  '//input[@type="checkbox" and @alt="Shared Selenium buglist"]@name');
 $ssname =~ /(?:link_in_footer_(\d+))/;
 my $saved_search1_id = $1;
 $sel->is_checked_ok("link_in_footer_$saved_search1_id");
@@ -50,7 +60,8 @@ $sel->is_checked_ok("link_in_footer_$saved_search1_id");
 # As an admin, the "Add to Search Bar" checkbox must be displayed, but unchecked by default.
 
 $sel->select_ok("share_$saved_search1_id", "label=canconfirm");
-ok(!$sel->is_checked("force_$saved_search1_id"), "Shared search not displayed in other users' Search Bar by default");
+ok(!$sel->is_checked("force_$saved_search1_id"),
+  "Shared search not displayed in other users' Search Bar by default");
 $sel->click_ok("force_$saved_search1_id");
 $sel->click_ok("update");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
@@ -66,8 +77,10 @@ $sel->is_text_present_ok("Shared Selenium buglist");
 $sel->click_ok("link=Shared Selenium buglist");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Bug List: Shared Selenium buglist");
+
 # You cannot delete other users' saved searches.
-ok(!$sel->is_text_present("Forget Search 'Shared Selenium buglist'"), "'Forget...' link not available");
+ok(!$sel->is_text_present("Forget Search 'Shared Selenium buglist'"),
+  "'Forget...' link not available");
 
 # The name of the sharer must appear in the "Saved Searches" section.
 
@@ -86,12 +99,16 @@ $sel->click_ok("link_in_footer_$saved_search1_id");
 $sel->click_ok("update");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("User Preferences");
+
 # Go to a page where the query name is unlikely to appear in the main page.
 $sel->click_ok("link=Permissions");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("User Preferences");
 $sel->click_ok("quicksearch_top");
-ok(!$sel->is_text_present("Shared Selenium buglist"), "Shared query no longer displayed in the Search Bar");
+ok(
+  !$sel->is_text_present("Shared Selenium buglist"),
+  "Shared query no longer displayed in the Search Bar"
+);
 
 # Create your own saved search, and share it with the canconfirm group.
 
@@ -104,7 +121,10 @@ $sel->click_ok("remember");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Search created");
 $text = trim($sel->get_text("message"));
-ok($text =~ /OK, you have a new search named helpwanted./, "New search named helpwanted has been created");
+ok(
+  $text =~ /OK, you have a new search named helpwanted./,
+  "New search named helpwanted has been created"
+);
 
 $sel->click_ok("link=Preferences");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
@@ -112,9 +132,11 @@ $sel->title_is("User Preferences");
 $sel->click_ok("link=Saved Searches");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("User Preferences");
-$ssname = $sel->get_attribute('//input[@type="checkbox" and @alt="helpwanted"]@name');
+$ssname
+  = $sel->get_attribute('//input[@type="checkbox" and @alt="helpwanted"]@name');
 $ssname =~ /(?:link_in_footer_(\d+))/;
 my $saved_search2_id = $1;
+
 # Our own saved searches are displayed in the Search Bar by default.
 $sel->is_checked_ok("link_in_footer_$saved_search2_id");
 $sel->select_ok("share_$saved_search2_id", "label=canconfirm");
@@ -129,7 +151,10 @@ logout($sel);
 
 log_in($sel, $config, 'admin');
 $sel->click_ok("quicksearch_top");
-ok(!$sel->is_text_present("helpwanted"), "No 'helpwanted' shared search displayed");
+ok(
+  !$sel->is_text_present("helpwanted"),
+  "No 'helpwanted' shared search displayed"
+);
 $sel->click_ok("link=Preferences");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("User Preferences");
@@ -140,11 +165,15 @@ $sel->click_ok("quicksearch_top");
 $sel->is_text_present_ok("helpwanted");
 $sel->is_text_present_ok($config->{canconfirm_user_login});
 
-ok(!$sel->is_checked("link_in_footer_$saved_search2_id"), "Shared query available but not displayed");
+ok(
+  !$sel->is_checked("link_in_footer_$saved_search2_id"),
+  "Shared query available but not displayed"
+);
 $sel->click_ok("link_in_footer_$saved_search2_id");
 $sel->click_ok("update");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("User Preferences");
+
 # This query is now available from the Search Bar.
 $sel->click_ok("link=helpwanted");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
@@ -158,13 +187,19 @@ $sel->title_is("User Preferences");
 $sel->click_ok("link=Saved Searches");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("User Preferences");
+
 # There is no better way to identify the link
-$sel->click_ok('//a[contains(@href,"/buglist.cgi?cmdtype=dorem&remaction=forget&namedcmd=Shared%20Selenium%20buglist")]',
-               undef, "Deleting the 'Shared Selenium buglist' search");
+$sel->click_ok(
+  '//a[contains(@href,"/buglist.cgi?cmdtype=dorem&remaction=forget&namedcmd=Shared%20Selenium%20buglist")]',
+  undef, "Deleting the 'Shared Selenium buglist' search"
+);
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Search is gone");
 $text = trim($sel->get_text("message"));
-ok($text =~ /OK, the Shared Selenium buglist search is gone./, "The 'Shared Selenium buglist' search is gone");
+ok(
+  $text =~ /OK, the Shared Selenium buglist search is gone./,
+  "The 'Shared Selenium buglist' search is gone"
+);
 logout($sel);
 
 # Make sure that the 'helpwanted' query is not shared with the QA_Selenium_TEST
@@ -172,7 +207,8 @@ logout($sel);
 
 log_in($sel, $config, 'QA_Selenium_TEST');
 $sel->click_ok("quicksearch_top");
-ok(!$sel->is_text_present("helpwanted"), "The 'helpwanted' query is not displayed in the Search Bar");
+ok(!$sel->is_text_present("helpwanted"),
+  "The 'helpwanted' query is not displayed in the Search Bar");
 $sel->click_ok("link=Preferences");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("User Preferences");
@@ -180,7 +216,8 @@ $sel->click_ok("link=Saved Searches");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("User Preferences");
 $sel->click_ok("quicksearch_top");
-ok(!$sel->is_text_present("helpwanted"), "The 'helpwanted' query is not shared with this user");
+ok(!$sel->is_text_present("helpwanted"),
+  "The 'helpwanted' query is not shared with this user");
 logout($sel);
 
 # Now remove the 'helpwanted' saved search.
@@ -193,11 +230,17 @@ $sel->click_ok("link=Saved Searches");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("User Preferences");
 $sel->click_ok("quicksearch_top");
-ok(!$sel->is_text_present("Shared Selenium buglist"), "The 'Shared Selenium buglist' is no longer available");
-$sel->click_ok('//a[contains(@href,"/buglist.cgi?cmdtype=dorem&remaction=forget&namedcmd=helpwanted")]',
-               undef, "Deleting the 'helpwanted' search");
+ok(
+  !$sel->is_text_present("Shared Selenium buglist"),
+  "The 'Shared Selenium buglist' is no longer available"
+);
+$sel->click_ok(
+  '//a[contains(@href,"/buglist.cgi?cmdtype=dorem&remaction=forget&namedcmd=helpwanted")]',
+  undef, "Deleting the 'helpwanted' search"
+);
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Search is gone");
 $text = trim($sel->get_text("message"));
-ok($text =~ /OK, the helpwanted search is gone./, "The 'helpwanted' search is gone");
+ok($text =~ /OK, the helpwanted search is gone./,
+  "The 'helpwanted' search is gone");
 logout($sel);
index ecc806980da89ee8d7b1608a357cf46fc20dcd60..84ba5083121c6389502d64866fd463ecf47b1e7e 100644 (file)
@@ -16,7 +16,7 @@ use QA::Util;
 my ($sel, $config) = get_selenium();
 
 log_in($sel, $config, 'admin');
-set_parameters($sel, { "Bug Fields" => {"useclassification-on" => undef} });
+set_parameters($sel, {"Bug Fields" => {"useclassification-on" => undef}});
 
 # Do not use file_bug_in_product() because our goal here is not to file
 # a bug but to check what is present in the UI, and also to make sure
@@ -31,7 +31,10 @@ $sel->title_is("Enter Bug");
 $sel->click_ok("link=Other Products", undef, "Choose full product list");
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_is("Enter Bug");
-ok(!$sel->is_text_present("QA-Selenium-TEST"), "The QA-Selenium-TEST product is not displayed");
+ok(
+  !$sel->is_text_present("QA-Selenium-TEST"),
+  "The QA-Selenium-TEST product is not displayed"
+);
 logout($sel);
 
 # Same steps, but for a member of the "QA‑Selenium‑TEST" group.
@@ -42,16 +45,18 @@ $sel->click_ok('//*[@class="link-file"]//a');
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Enter A Bug");
 if ($sel->is_text_present('None of the above; my bug is in')) {
-    $sel->click_ok('advanced_link');
-    $sel->wait_for_page_to_load_ok(WAIT_TIME);
-    $sel->title_is("Enter Bug");
+  $sel->click_ok('advanced_link');
+  $sel->wait_for_page_to_load_ok(WAIT_TIME);
+  $sel->title_is("Enter Bug");
 }
 $sel->click_ok('link=Other Products');
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
+
 # For some unknown reason, Selenium doesn't like hyphens in links.
 # $sel->is_text_present_ok("QA-Selenium-TEST");
 # $sel->click_ok("link=QA-Selenium-TEST");
-$sel->click_ok('//div[@id="choose_product"]//a[contains(@href, "QA-Selenium-TEST")]');
+$sel->click_ok(
+  '//div[@id="choose_product"]//a[contains(@href, "QA-Selenium-TEST")]');
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->is_text_present_ok("Product: QA-Selenium-TEST");
 logout($sel);
index 2252b2317bf32b126fba6b74e8daf7aa4025eaa5..2942c9857a9365fb0859d759214fc0e40c9de765 100644 (file)
@@ -55,7 +55,8 @@ $sel->click_ok("remember");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Search created");
 my $text = trim($sel->get_text("message"));
-ok($text =~ /you have a new search named sw-x77v/, 'Saved search correctly saved');
+ok($text =~ /you have a new search named sw-x77v/,
+  'Saved search correctly saved');
 
 # Make sure the saved query works.
 
@@ -69,12 +70,15 @@ $sel->is_text_present_ok("2 bugs found");
 # is off.
 
 set_parameters($sel, {'Bug Fields' => {'usestatuswhiteboard-off' => undef}});
+
 # Show detailed bug information panel on advanced search
-ok($sel->create_cookie('TUI=information_query=1'), 'Show detailed bug information');
+ok($sel->create_cookie('TUI=information_query=1'),
+  'Show detailed bug information');
 $sel->click_ok('//*[@class="link-search"]//a');
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Search for bugs");
-ok(!$sel->is_text_present("Whiteboard:"), "Whiteboard label no longer displayed");
+ok(!$sel->is_text_present("Whiteboard:"),
+  "Whiteboard label no longer displayed");
 $sel->open_ok("/$config->{bugzilla_installation}/show_bug.cgi?id=$test_bug_1");
 $sel->title_like(qr/^$test_bug_1\b/);
 ok(!$sel->is_element_present('//label[@for="status_whiteboard"]'));
index 9ef93c32db9347ca873d3fd03aef98211df34dd7..1e29da42f374ed7ebd7436164c82acc46f47c219 100644 (file)
@@ -18,7 +18,7 @@ my ($sel, $config) = get_selenium();
 # Turn on the usevisibilitygroups param so that some users are invisible.
 
 log_in($sel, $config, 'admin');
-set_parameters($sel, { "Group Security" => {"usevisibilitygroups-on" => undef} });
+set_parameters($sel, {"Group Security" => {"usevisibilitygroups-on" => undef}});
 
 # You can see all users from editusers.cgi, but once you leave this page,
 # usual group visibility restrictions apply and the "powerless" user cannot
@@ -39,17 +39,25 @@ $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Begin sudo session");
 $sel->value_is("target_login", $config->{unprivileged_user_login});
 $sel->type_ok("reason", "Selenium test about sudo sessions");
-$sel->type_ok("current_password", $config->{admin_user_passwd}, "Enter admin password");
+$sel->type_ok(
+  "current_password",
+  $config->{admin_user_passwd},
+  "Enter admin password"
+);
 $sel->click_ok('//input[@value="Begin Session"]');
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Match Failed");
 my $error_msg = trim($sel->get_text("error_msg"));
-ok($error_msg eq "$config->{unprivileged_user_login} does not exist or you are not allowed to see that user.",
-   "Cannot impersonate users you cannot see");
+ok(
+  $error_msg eq
+    "$config->{unprivileged_user_login} does not exist or you are not allowed to see that user.",
+  "Cannot impersonate users you cannot see"
+);
 
 # Turn off the usevisibilitygroups param so that all users are visible again.
 
-set_parameters($sel, { "Group Security" => {"usevisibilitygroups-off" => undef} });
+set_parameters($sel,
+  {"Group Security" => {"usevisibilitygroups-off" => undef}});
 
 # The "powerless" user can now be sudo'ed.
 
@@ -67,12 +75,19 @@ $sel->click_ok("link=Impersonate this user");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Begin sudo session");
 $sel->value_is("target_login", $config->{unprivileged_user_login});
-$sel->type_ok("current_password", $config->{admin_user_passwd}, "Enter admin password");
+$sel->type_ok(
+  "current_password",
+  $config->{admin_user_passwd},
+  "Enter admin password"
+);
 $sel->click_ok('//input[@value="Begin Session"]');
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Sudo session started");
 my $text = trim($sel->get_text("message"));
-ok($text =~ /The sudo session has been started/, "The sudo session has been started");
+ok(
+  $text =~ /The sudo session has been started/,
+  "The sudo session has been started"
+);
 
 # Make sure this user is not an admin and has no privs at all, and that
 # he cannot access editusers.cgi (despite the sudoer can).
@@ -84,19 +99,24 @@ $sel->click_ok("link=Permissions");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("User Preferences");
 $sel->is_text_present_ok("There are no permission bits set on your account");
+
 # We access the page directly as there is no link pointing to it.
 $sel->open_ok("/$config->{bugzilla_installation}/editusers.cgi");
 $sel->title_is("Authorization Required");
 $error_msg = trim($sel->get_text("error_msg"));
-ok($error_msg =~ /^Sorry, you aren't a member of the 'editusers' group/, "Not a member of the editusers group");
-$sel->click_ok("link=End sudo session impersonating " . $config->{unprivileged_user_login});
+ok($error_msg =~ /^Sorry, you aren't a member of the 'editusers' group/,
+  "Not a member of the editusers group");
+$sel->click_ok(
+  "link=End sudo session impersonating " . $config->{unprivileged_user_login});
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Sudo session complete");
 $sel->is_text_present_ok("The sudo session has been ended");
 
 # Try to access the sudo page directly, with no credentials.
 
-$sel->open_ok("/$config->{bugzilla_installation}/relogin.cgi?action=begin-sudo&target_login=$config->{admin_user_login}");
+$sel->open_ok(
+  "/$config->{bugzilla_installation}/relogin.cgi?action=begin-sudo&target_login=$config->{admin_user_login}"
+);
 $sel->title_is("Password Required");
 
 # The link should populate the target_login field correctly.
@@ -107,12 +127,20 @@ $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Begin sudo session");
 $sel->value_is("target_login", $config->{admin_user_login});
 $sel->type_ok("reason", "Selenium hack");
-$sel->type_ok("current_password", $config->{admin_user_passwd}, "Enter admin password");
+$sel->type_ok(
+  "current_password",
+  $config->{admin_user_passwd},
+  "Enter admin password"
+);
 $sel->click_ok('//input[@value="Begin Session"]');
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("User Protected");
 $error_msg = trim($sel->get_text("error_msg"));
-ok($error_msg =~ /^The user $config->{admin_user_login} may not be impersonated by sudoers/, "Cannot impersonate administrators");
+ok(
+  $error_msg
+    =~ /^The user $config->{admin_user_login} may not be impersonated by sudoers/,
+  "Cannot impersonate administrators"
+);
 
 # Now try to sudo a non-existing user account, with no password.
 
@@ -126,13 +154,23 @@ $sel->title_is("Password Required");
 
 # Same as above, but with your password.
 
-$sel->open_ok("/$config->{bugzilla_installation}/relogin.cgi?action=prepare-sudo&target_login=foo\@bar.com");
+$sel->open_ok(
+  "/$config->{bugzilla_installation}/relogin.cgi?action=prepare-sudo&target_login=foo\@bar.com"
+);
 $sel->title_is("Begin sudo session");
 $sel->value_is("target_login", 'foo@bar.com');
-$sel->type_ok("current_password", $config->{admin_user_passwd}, "Enter admin password");
+$sel->type_ok(
+  "current_password",
+  $config->{admin_user_passwd},
+  "Enter admin password"
+);
 $sel->click_ok('//input[@value="Begin Session"]');
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Match Failed");
 $error_msg = trim($sel->get_text("error_msg"));
-ok($error_msg eq 'foo@bar.com does not exist or you are not allowed to see that user.', "Cannot impersonate non-existing accounts");
+ok(
+  $error_msg eq
+    'foo@bar.com does not exist or you are not allowed to see that user.',
+  "Cannot impersonate non-existing accounts"
+);
 logout($sel);
index 7067e775f82e959e7a6fcdcef1e8d8a04d770c05..9a67fe61ffa747a7486776830b53f8fe5cd30b45 100644 (file)
@@ -20,7 +20,7 @@ my $test_bug_1 = $config->{test_bug_1};
 # Enable target milestones.
 
 log_in($sel, $config, 'admin');
-set_parameters($sel, { "Bug Fields" => {"usetargetmilestone-on" => undef} });
+set_parameters($sel, {"Bug Fields" => {"usetargetmilestone-on" => undef}});
 
 # Create a new milestone to the 'TestProduct' product.
 
@@ -32,7 +32,7 @@ $sel->click_ok("link=Add");
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_is("Add Milestone to Product 'TestProduct'");
 $sel->type_ok("milestone", "TM1");
-$sel->type_ok("sortkey", "10");
+$sel->type_ok("sortkey",   "10");
 $sel->click_ok("create");
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_is("Milestone Created");
@@ -51,7 +51,7 @@ $sel->is_text_present_ok("Changes submitted for bug $test_bug_1");
 open_advanced_search_page($sel);
 $sel->is_text_present_ok("Target Milestone:");
 $sel->remove_all_selections_ok("product");
-$sel->add_selection_ok("product", "label=TestProduct");
+$sel->add_selection_ok("product",          "label=TestProduct");
 $sel->add_selection_ok("target_milestone", "label=TM1");
 $sel->click_ok("Search");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
@@ -62,16 +62,22 @@ $sel->click_ok("remember");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Search created");
 my $text = trim($sel->get_text("message"));
-ok($text =~ /OK, you have a new search named selenium_m0./, "New search named selenium_m0 has been created");
+ok(
+  $text =~ /OK, you have a new search named selenium_m0./,
+  "New search named selenium_m0 has been created"
+);
 
 # Turn off milestones and check that the milestone field no longer appears in bugs.
 
-set_parameters($sel, { "Bug Fields" => {"usetargetmilestone-off" => undef} });
+set_parameters($sel, {"Bug Fields" => {"usetargetmilestone-off" => undef}});
 
 $sel->click_ok('//*[@class="link-search"]//a');
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Search for bugs");
-ok(!$sel->is_text_present("Target Milestone:"), "The target milestone field is no longer displayed");
+ok(
+  !$sel->is_text_present("Target Milestone:"),
+  "The target milestone field is no longer displayed"
+);
 
 go_to_bug($sel, $test_bug_1);
 ok(!$sel->is_element_present('//label[@for="target_milestone"]'));
@@ -86,23 +92,29 @@ $sel->click_ok("link=Forget Search 'selenium_m0'");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Search is gone");
 $text = trim($sel->get_text("message"));
-ok($text =~ /OK, the selenium_m0 search is gone./, "The selenium_m0 search is gone");
+ok($text =~ /OK, the selenium_m0 search is gone./,
+  "The selenium_m0 search is gone");
 
 # Re-enable the usetargetmilestone parameter and delete the created
 # milestone from the Testproduct product.
 
-set_parameters($sel, { "Bug Fields" => {"usetargetmilestone-on" => undef} });
+set_parameters($sel, {"Bug Fields" => {"usetargetmilestone-on" => undef}});
 
 edit_product($sel, "TestProduct");
 $sel->click_ok("link=Edit milestones:");
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_is("Select milestone of product 'TestProduct'");
-$sel->click_ok('//a[contains(@href,"/editmilestones.cgi?action=del&product=TestProduct&milestone=TM1")]',
-               undef, "Deleting the TM1 milestone");
+$sel->click_ok(
+  '//a[contains(@href,"/editmilestones.cgi?action=del&product=TestProduct&milestone=TM1")]',
+  undef, "Deleting the TM1 milestone"
+);
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Delete Milestone of Product 'TestProduct'");
 $text = trim($sel->get_body_text());
-ok($text =~ /There is 1 bug entered for this milestone/, "Warning displayed about 1 bug targetted to TM1");
+ok(
+  $text =~ /There is 1 bug entered for this milestone/,
+  "Warning displayed about 1 bug targetted to TM1"
+);
 $sel->click_ok("delete");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Milestone Deleted");
index 504c864f2d7d91a80b85a63091cbc5975f473bf3..646f6ea66ea5c5733036c5e2f23d04be51794c73 100644 (file)
@@ -20,17 +20,24 @@ my $test_bug_1 = $config->{test_bug_1};
 # Set the timetracking group to "editbugs", which is the default value for this parameter.
 
 log_in($sel, $config, 'admin');
-set_parameters($sel, { "Group Security" => {"timetrackinggroup" => {type => "select", value => "editbugs"}} });
+set_parameters(
+  $sel,
+  {
+    "Group Security" =>
+      {"timetrackinggroup" => {type => "select", value => "editbugs"}}
+  }
+);
 
 # Add some Hours Worked to a bug so that we are sure at least one bug
 # will be present in our buglist below.
 
 go_to_bug($sel, $test_bug_1);
 $sel->type_ok("work_time", 2.6);
-$sel->type_ok("comment", "I did some work");
+$sel->type_ok("comment",   "I did some work");
 $sel->click_ok("commit");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->is_text_present_ok("Changes submitted for bug $test_bug_1");
+
 # Make sure the correct bug is redisplayed.
 $sel->click_ok("link=bug $test_bug_1");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
@@ -43,7 +50,8 @@ $sel->is_text_present_ok("Hours Worked: 2.6");
 $sel->open_ok("/$config->{bugzilla_installation}/summarize_time.cgi");
 $sel->title_is("No Bugs Selected");
 my $error_msg = trim($sel->get_text("error_msg"));
-ok($error_msg =~ /You apparently didn't choose any bugs to view/, "No data displayed");
+ok($error_msg =~ /You apparently didn't choose any bugs to view/,
+  "No data displayed");
 
 # Search for bugs which have some value in the Hours Worked field.
 
@@ -65,7 +73,7 @@ $sel->title_like(qr/^Time Summary \(\d+ bugs selected\)/);
 $sel->check_ok("monthly");
 $sel->check_ok("detailed");
 $sel->type_ok("start_date", "2009-01-01");
-$sel->type_ok("end_date", "2009-04-30");
+$sel->type_ok("end_date",   "2009-04-30");
 $sel->click_ok("summarize");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_like(qr/^Time Summary \(\d+ bugs selected\)/);
index de1224f735d9704cd925d6146e731efcb278a4b5..a5df2d928f0e840418b33e20c9b9e55fb90d18e8 100644 (file)
@@ -17,7 +17,8 @@ use constant PASSWORD => 'uChoopoh1che';
 my ($sel, $config) = get_selenium();
 
 log_in($sel, $config, 'admin');
-set_parameters($sel, { "Administrative Policies" => {"allowuserdeletion-on" => undef} });
+set_parameters($sel,
+  {"Administrative Policies" => {"allowuserdeletion-on" => undef}});
 
 # First delete test users, if not deleted correctly during a previous run.
 
@@ -44,7 +45,8 @@ $sel->click_ok("link=Add Group");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Add group");
 $sel->type_ok("name", "Slave");
-$sel->type_ok("desc", "Members of the Master group are also members of this group");
+$sel->type_ok("desc",
+  "Members of the Master group are also members of this group");
 $sel->type_ok("owner", $config->{'admin_user_login'});
 $sel->uncheck_ok("isactive");
 ok(!$sel->is_checked("insertnew"), "Group not added to products by default");
@@ -66,9 +68,9 @@ $sel->title_is('Search users');
 $sel->click_ok('link=add a new user');
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is('Add user');
-$sel->type_ok('login', 'master@selenium.bugzilla.org');
-$sel->type_ok('name', 'master-user');
-$sel->type_ok('password', PASSWORD, 'Enter password');
+$sel->type_ok('login',        'master@selenium.bugzilla.org');
+$sel->type_ok('name',         'master-user');
+$sel->type_ok('password',     PASSWORD, 'Enter password');
 $sel->type_ok('disabledtext', 'Not for common usage');
 $sel->click_ok('add');
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
@@ -82,9 +84,9 @@ $sel->is_text_present_ok('The account has been added to the Master group');
 $sel->click_ok("//a[contains(text(),'add\n    a new user')]");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is('Add user');
-$sel->type_ok('login', 'slave@selenium.bugzilla.org');
-$sel->type_ok('name', 'slave-user');
-$sel->type_ok('password', PASSWORD, 'Enter password');
+$sel->type_ok('login',        'slave@selenium.bugzilla.org');
+$sel->type_ok('name',         'slave-user');
+$sel->type_ok('password',     PASSWORD, 'Enter password');
 $sel->type_ok('disabledtext', 'Not for common usage');
 $sel->click_ok('add');
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
@@ -98,9 +100,9 @@ $sel->is_text_present_ok('The account has been added to the Slave group');
 $sel->click_ok("//a[contains(text(),'add\n    a new user')]");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is('Add user');
-$sel->type_ok('login', 'reg@selenium.bugzilla.org');
-$sel->type_ok('name', 'reg-user');
-$sel->type_ok('password', PASSWORD, 'Enter password');
+$sel->type_ok('login',        'reg@selenium.bugzilla.org');
+$sel->type_ok('name',         'reg-user');
+$sel->type_ok('password',     PASSWORD, 'Enter password');
 $sel->type_ok('disabledtext', 'Not for common usage');
 $sel->click_ok('add');
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
@@ -112,25 +114,31 @@ $sel->click_ok('link=find other users');
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is('Search users');
 $sel->check_ok('grouprestrict');
-$sel->select_ok('groupid', 'label=Master');
+$sel->select_ok('groupid',   'label=Master');
 $sel->select_ok('matchtype', 'value=substr');
 $sel->click_ok('search');
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
-$sel->is_text_present_ok('master@selenium.bugzilla.org', 'master-user in Master group');
-ok(!$sel->is_text_present('slave@selenium.bugzilla.org'), 'slave-user not in Master group');
-ok(!$sel->is_text_present('reg@selenium.bugzilla.org'), 'reg-user not in Master group');
+$sel->is_text_present_ok('master@selenium.bugzilla.org',
+  'master-user in Master group');
+ok(!$sel->is_text_present('slave@selenium.bugzilla.org'),
+  'slave-user not in Master group');
+ok(!$sel->is_text_present('reg@selenium.bugzilla.org'),
+  'reg-user not in Master group');
 
 $sel->click_ok('link=find other users');
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is('Search users');
 $sel->check_ok('grouprestrict');
-$sel->select_ok('groupid', 'label=Slave');
+$sel->select_ok('groupid',   'label=Slave');
 $sel->select_ok('matchtype', 'value=substr');
 $sel->click_ok('search');
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
-$sel->is_text_present_ok('master@selenium.bugzilla.org', 'master-user in Slave group');
-$sel->is_text_present_ok('slave@selenium.bugzilla.org', 'slave-user in Slave group');
-ok(!$sel->is_text_present('reg@selenium.bugzilla.org'), 'reg-user not in Slave group');
+$sel->is_text_present_ok('master@selenium.bugzilla.org',
+  'master-user in Slave group');
+$sel->is_text_present_ok('slave@selenium.bugzilla.org',
+  'slave-user in Slave group');
+ok(!$sel->is_text_present('reg@selenium.bugzilla.org'),
+  'reg-user not in Slave group');
 
 # Add a regular expression to the Slave group.
 
@@ -153,25 +161,31 @@ $sel->click_ok("link=Users");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is('Search users');
 $sel->check_ok('grouprestrict');
-$sel->select_ok('groupid', 'label=Master');
+$sel->select_ok('groupid',   'label=Master');
 $sel->select_ok('matchtype', 'value=substr');
 $sel->click_ok('search');
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
-$sel->is_text_present_ok('master@selenium.bugzilla.org', 'master-user in Master group');
-ok(!$sel->is_text_present('slave@selenium.bugzilla.org'), 'slave-user not in Master group');
-ok(!$sel->is_text_present('reg@selenium.bugzilla.org'), 'reg-user not in Master group');
+$sel->is_text_present_ok('master@selenium.bugzilla.org',
+  'master-user in Master group');
+ok(!$sel->is_text_present('slave@selenium.bugzilla.org'),
+  'slave-user not in Master group');
+ok(!$sel->is_text_present('reg@selenium.bugzilla.org'),
+  'reg-user not in Master group');
 
 $sel->click_ok('link=find other users');
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is('Search users');
 $sel->check_ok('grouprestrict');
-$sel->select_ok('groupid', 'label=Slave');
+$sel->select_ok('groupid',   'label=Slave');
 $sel->select_ok('matchtype', 'value=substr');
 $sel->click_ok('search');
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
-$sel->is_text_present_ok('master@selenium.bugzilla.org', 'master-user in Slave group');
-$sel->is_text_present_ok('slave@selenium.bugzilla.org', 'slave-user in Slave group');
-$sel->is_text_present_ok('reg@selenium.bugzilla.org', 'reg-user in Slave group');
+$sel->is_text_present_ok('master@selenium.bugzilla.org',
+  'master-user in Slave group');
+$sel->is_text_present_ok('slave@selenium.bugzilla.org',
+  'slave-user in Slave group');
+$sel->is_text_present_ok('reg@selenium.bugzilla.org',
+  'reg-user in Slave group');
 
 # Remove created users and groups.
 
@@ -180,52 +194,54 @@ cleanup_groups($sel, $slave_gid);
 logout($sel);
 
 sub cleanup_users {
-    my $sel = shift;
-
-    go_to_admin($sel);
-    $sel->click_ok("link=Users");
+  my $sel = shift;
+
+  go_to_admin($sel);
+  $sel->click_ok("link=Users");
+  $sel->wait_for_page_to_load_ok(WAIT_TIME);
+  $sel->title_is("Search users");
+  $sel->type_ok('matchstr', '(master|slave|reg)@selenium.bugzilla.org');
+  $sel->select_ok('matchtype', 'value=regexp');
+  $sel->click_ok("search");
+  $sel->wait_for_page_to_load_ok(WAIT_TIME);
+  $sel->title_is("Select user");
+
+  foreach my $user ('master', 'slave', 'reg') {
+    my $login = $user . '@selenium.bugzilla.org';
+    next unless $sel->is_text_present($login);
+
+    $sel->click_ok("link=$login");
+    $sel->wait_for_page_to_load_ok(WAIT_TIME);
+    $sel->title_is("Edit user ${user}-user <$login>");
+    $sel->click_ok("delete");
     $sel->wait_for_page_to_load_ok(WAIT_TIME);
-    $sel->title_is("Search users");
-    $sel->type_ok('matchstr', '(master|slave|reg)@selenium.bugzilla.org');
-    $sel->select_ok('matchtype', 'value=regexp');
-    $sel->click_ok("search");
+    $sel->title_is("Confirm deletion of user $login");
+    ok(!$sel->is_text_present('You cannot delete this user account'),
+      'The user can be safely deleted');
+    $sel->click_ok("delete");
+    $sel->wait_for_page_to_load_ok(WAIT_TIME);
+    $sel->title_is("User $login deleted");
+    $sel->click_ok('link=show the user list again');
     $sel->wait_for_page_to_load_ok(WAIT_TIME);
-    $sel->title_is("Select user");
-
-    foreach my $user ('master', 'slave', 'reg') {
-        my $login = $user . '@selenium.bugzilla.org';
-        next unless $sel->is_text_present($login);
-
-        $sel->click_ok("link=$login");
-        $sel->wait_for_page_to_load_ok(WAIT_TIME);
-        $sel->title_is("Edit user ${user}-user <$login>");
-        $sel->click_ok("delete");
-        $sel->wait_for_page_to_load_ok(WAIT_TIME);
-        $sel->title_is("Confirm deletion of user $login");
-        ok(!$sel->is_text_present('You cannot delete this user account'), 'The user can be safely deleted');
-        $sel->click_ok("delete");
-        $sel->wait_for_page_to_load_ok(WAIT_TIME);
-        $sel->title_is("User $login deleted");
-        $sel->click_ok('link=show the user list again');
-        $sel->wait_for_page_to_load_ok(WAIT_TIME);
-        $sel->title_is('Select user');
-    }
+    $sel->title_is('Select user');
+  }
 }
 
 sub cleanup_groups {
-    my ($sel, $slave_gid) = @_;
-
-    go_to_admin($sel);
-    $sel->click_ok("link=Groups");
-    $sel->wait_for_page_to_load(WAIT_TIME);
-    $sel->title_is("Edit Groups");
-    $sel->click_ok("//a[contains(\@href,'/editgroups.cgi?action=del&group=$slave_gid')]");
-    $sel->wait_for_page_to_load(WAIT_TIME);
-    $sel->title_is("Delete group");
-    $sel->is_text_present_ok("Do you really want to delete this group?");
-    ok(!$sel->is_element_present("removeusers"), 'No direct members in this group');
-    $sel->click_ok("delete");
-    $sel->wait_for_page_to_load(WAIT_TIME);
-    $sel->title_is("Group Deleted");
-    $sel->is_text_present_ok("The group Slave has been deleted.");
+  my ($sel, $slave_gid) = @_;
+
+  go_to_admin($sel);
+  $sel->click_ok("link=Groups");
+  $sel->wait_for_page_to_load(WAIT_TIME);
+  $sel->title_is("Edit Groups");
+  $sel->click_ok(
+    "//a[contains(\@href,'/editgroups.cgi?action=del&group=$slave_gid')]");
+  $sel->wait_for_page_to_load(WAIT_TIME);
+  $sel->title_is("Delete group");
+  $sel->is_text_present_ok("Do you really want to delete this group?");
+  ok(!$sel->is_element_present("removeusers"), 'No direct members in this group');
+  $sel->click_ok("delete");
+  $sel->wait_for_page_to_load(WAIT_TIME);
+  $sel->title_is("Group Deleted");
+  $sel->is_text_present_ok("The group Slave has been deleted.");
 }
index 3b7b71ed5290dccba6d3d1a75fc75b157ccd4754..b2dc25e196b6c3f781f45e8cd7f99a2c1cc4fd0f 100644 (file)
@@ -19,11 +19,17 @@ my $test_bug_1 = $config->{test_bug_1};
 
 
 log_in($sel, $config, 'tweakparams');
-set_parameters($sel, { "User Matching"  => {"usemenuforusers-off" => undef,
-                                            "maxusermatches"      => {type => 'text', value => '0'},
-                                            "confirmuniqueusermatch-on" => undef},
-                       "Group Security" => {"usevisibilitygroups-off" => undef}
-                     });
+set_parameters(
+  $sel,
+  {
+    "User Matching" => {
+      "usemenuforusers-off"       => undef,
+      "maxusermatches"            => {type => 'text', value => '0'},
+      "confirmuniqueusermatch-on" => undef
+    },
+    "Group Security" => {"usevisibilitygroups-off" => undef}
+  }
+);
 
 go_to_bug($sel, $test_bug_1);
 $sel->click_ok("cc_edit_area_showhide");
@@ -35,7 +41,8 @@ $sel->type_ok("newcc", $config->{unprivileged_user_login_truncated});
 $sel->click_ok("commit");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Confirm Match");
-$sel->is_text_present_ok("$config->{unprivileged_user_login_truncated} matched");
+$sel->is_text_present_ok(
+  "$config->{unprivileged_user_login_truncated} matched");
 $sel->go_back_ok();
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_like(qr/^$test_bug_1/);
@@ -75,7 +82,8 @@ $sel->is_text_present_ok("*$config->{common_email} matched:");
 
 # Now restrict 'maxusermatches'.
 
-set_parameters($sel, { "User Matching" => {"maxusermatches" => {type => 'text', value => '1'}} });
+set_parameters($sel,
+  {"User Matching" => {"maxusermatches" => {type => 'text', value => '1'}}});
 
 go_to_bug($sel, $test_bug_1);
 $sel->click_ok("cc_edit_area_showhide");
@@ -103,9 +111,13 @@ $sel->is_text_present_ok("Changes submitted for bug $test_bug_1");
 
 # Now turn on group visibility. It involves important security checks.
 
-set_parameters($sel, { "User Matching"  => {"maxusermatches" => {type => 'text', value => '2'}},
-                       "Group Security" => {"usevisibilitygroups-on" => undef}
-                     });
+set_parameters(
+  $sel,
+  {
+    "User Matching" => {"maxusermatches" => {type => 'text', value => '2'}},
+    "Group Security" => {"usevisibilitygroups-on" => undef}
+  }
+);
 
 # By default, groups are not visible to themselves, so we have to enable this.
 # The tweakparams user has not enough privs to do it himself.
@@ -121,11 +133,11 @@ $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_is("Change Group: tweakparams");
 
 my @groups = $sel->get_select_options("visible_from_add");
-if (grep {$_ eq 'tweakparams'} @groups) {
-    $sel->add_selection_ok("visible_from_add", "label=tweakparams");
-    $sel->click_ok('//input[@value="Update Group"]');
-    $sel->wait_for_page_to_load_ok(WAIT_TIME);
-    $sel->title_is("Change Group: tweakparams");
+if (grep { $_ eq 'tweakparams' } @groups) {
+  $sel->add_selection_ok("visible_from_add", "label=tweakparams");
+  $sel->click_ok('//input[@value="Update Group"]');
+  $sel->wait_for_page_to_load_ok(WAIT_TIME);
+  $sel->title_is("Change Group: tweakparams");
 }
 logout($sel);
 log_in($sel, $config, 'tweakparams');
@@ -139,7 +151,8 @@ $sel->type_ok("newcc", $config->{unprivileged_user_login_truncated});
 $sel->click_ok("commit");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Match Failed");
-$sel->is_text_present_ok("$config->{unprivileged_user_login_truncated} did not match anything");
+$sel->is_text_present_ok(
+  "$config->{unprivileged_user_login_truncated} did not match anything");
 $sel->go_back_ok();
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_like(qr/^$test_bug_1/);
@@ -152,7 +165,8 @@ $sel->type_ok("newcc", $config->{common_email});
 $sel->click_ok("commit");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Confirm Match");
-$sel->is_text_present_ok("$config->{common_email} matched more than the maximum of 2 users");
+$sel->is_text_present_ok(
+  "$config->{common_email} matched more than the maximum of 2 users");
 $sel->go_back_ok();
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_like(qr/^$test_bug_1/);
@@ -168,21 +182,39 @@ $sel->is_text_present_ok("<$config->{tweakparams_user_login}>");
 
 # Now test user menus. It must NOT display users we are not allowed to see.
 
-set_parameters($sel, { "User Matching" => {"usemenuforusers-on" => undef} });
+set_parameters($sel, {"User Matching" => {"usemenuforusers-on" => undef}});
 
 go_to_bug($sel, $test_bug_1);
 $sel->click_ok("cc_edit_area_showhide");
 my @cc = $sel->get_select_options("newcc");
-ok(!grep($_ =~ /$config->{unprivileged_user_login}/, @cc), "$config->{unprivileged_user_login} is not visible");
-ok(!grep($_ =~ /$config->{canconfirm_user_login}/, @cc), "$config->{canconfirm_user_login} is not visible");
-ok(grep($_ =~ /$config->{admin_user_login}/, @cc), "$config->{admin_user_login} is visible");
-ok(grep($_ =~ /$config->{tweakparams_user_login}/, @cc), "$config->{tweakparams_user_login} is visible");
+ok(
+  !grep($_ =~ /$config->{unprivileged_user_login}/, @cc),
+  "$config->{unprivileged_user_login} is not visible"
+);
+ok(
+  !grep($_ =~ /$config->{canconfirm_user_login}/, @cc),
+  "$config->{canconfirm_user_login} is not visible"
+);
+ok(
+  grep($_ =~ /$config->{admin_user_login}/, @cc),
+  "$config->{admin_user_login} is visible"
+);
+ok(
+  grep($_ =~ /$config->{tweakparams_user_login}/, @cc),
+  "$config->{tweakparams_user_login} is visible"
+);
 
 # Reset paramters.
 
-set_parameters($sel, { "User Matching"  => {"usemenuforusers-off" => undef,
-                                            "maxusermatches"      => {type => 'text', value => '0'},
-                                            "confirmuniqueusermatch-off" => undef},
-                       "Group Security" => {"usevisibilitygroups-off" => undef}
-                     });
+set_parameters(
+  $sel,
+  {
+    "User Matching" => {
+      "usemenuforusers-off"        => undef,
+      "maxusermatches"             => {type => 'text', value => '0'},
+      "confirmuniqueusermatch-off" => undef
+    },
+    "Group Security" => {"usevisibilitygroups-off" => undef}
+  }
+);
 logout($sel);
index d9e0562c1faeb0c1c8fc20756775fec1640bc5bf..de311533f23b03e284fd44ca5007538581f594f8 100644 (file)
@@ -44,11 +44,16 @@ $sel->title_is("User Preferences");
 $sel->click_ok("link=General Preferences");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("User Preferences");
-ok(!$sel->is_element_present("skin"), "The 'skin' user preference is not present");
+ok(!$sel->is_element_present("skin"),
+  "The 'skin' user preference is not present");
 $sel->select_ok("state_addselfcc", "label=Site Default (Never)");
-$sel->select_ok("post_bug_submit_action", "label=Site Default (Show the updated bug)");
+$sel->select_ok("post_bug_submit_action",
+  "label=Site Default (Show the updated bug)");
 $sel->select_ok("per_bug_queries", "label=Site Default (On)");
-ok(!$sel->is_element_present("zoom_textareas"), "The 'zoom_textareas' user preference is not present");
+ok(
+  !$sel->is_element_present("zoom_textareas"),
+  "The 'zoom_textareas' user preference is not present"
+);
 $sel->click_ok("update");
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_is("User Preferences");
@@ -58,11 +63,12 @@ $sel->title_is("User Preferences");
 file_bug_in_product($sel, 'TestProduct');
 $sel->value_is("cc", "");
 $sel->type_ok("short_desc", "First bug created");
-$sel->type_ok("comment", "I'm not in the CC list.");
+$sel->type_ok("comment",    "I'm not in the CC list.");
 $sel->click_ok("commit");
 $sel->wait_for_page_to_load(WAIT_TIME);
 my $bug1_id = $sel->get_value('//input[@name="id" and @type="hidden"]');
-$sel->is_text_present_ok('has been added to the database', "Bug $bug1_id created");
+$sel->is_text_present_ok('has been added to the database',
+  "Bug $bug1_id created");
 $sel->value_is("addselfcc", "off");
 $sel->select_ok("bug_status", "label=IN_PROGRESS");
 $sel->click_ok("commit");
@@ -70,18 +76,19 @@ $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->is_text_present_ok("Changes submitted for bug $bug1_id");
 $sel->click_ok("editme_action");
 $sel->value_is("short_desc", "First bug created");
-$sel->value_is("addselfcc", "off");
+$sel->value_is("addselfcc",  "off");
 
 # Tag the bug.
 
 $sel->select_ok("lob_action", "label=Add");
 $sel->type_ok("lob_newqueryname", "sel-tmp");
-$sel->type_ok("bug_ids", $bug1_id);
+$sel->type_ok("bug_ids",          $bug1_id);
 $sel->click_ok("commit_list_of_bugs");
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_is("Tag Updated");
 my $text = trim($sel->get_text("message"));
-ok($text =~ /The 'sel-tmp' tag has been added to bug $bug1_id/, "Bug added to 'sel-tmp' tag");
+ok($text =~ /The 'sel-tmp' tag has been added to bug $bug1_id/,
+  "Bug added to 'sel-tmp' tag");
 $sel->click_ok("link=sel-tmp");
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->is_text_present_ok("Tags: sel-tmp");
@@ -92,23 +99,25 @@ $sel->is_text_present_ok("One bug found");
 file_bug_in_product($sel, 'TestProduct');
 $sel->value_is("cc", "");
 $sel->type_ok("short_desc", "My second bug");
-$sel->type_ok("comment", "Still not in the CC list");
+$sel->type_ok("comment",    "Still not in the CC list");
 $sel->click_ok("commit");
 $sel->wait_for_page_to_load(WAIT_TIME);
 my $bug2_id = $sel->get_value('//input[@name="id" and @type="hidden"]');
-$sel->is_text_present_ok('has been added to the database', "Bug $bug2_id created");
+$sel->is_text_present_ok('has been added to the database',
+  "Bug $bug2_id created");
 $sel->value_is("addselfcc", "off");
 
 # Add another bug to the tag.
 
-$sel->select_ok("lob_action", "label=Add");
+$sel->select_ok("lob_action",       "label=Add");
 $sel->select_ok("lob_oldqueryname", "label=sel-tmp");
 $sel->type_ok("bug_ids", $bug2_id);
 $sel->click_ok("commit_list_of_bugs");
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_is("Tag Updated");
 $text = trim($sel->get_text("message"));
-ok($text =~ /The 'sel-tmp' tag has been added to bug $bug2_id/, "Bug added to 'sel-tmp' tag");
+ok($text =~ /The 'sel-tmp' tag has been added to bug $bug2_id/,
+  "Bug added to 'sel-tmp' tag");
 $sel->click_ok("link=sel-tmp");
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_is("Bug List");
@@ -128,21 +137,23 @@ $sel->is_text_present_ok("The next bug I should see is this one.");
 
 # Remove the tag from all bugs.
 
-$sel->open_ok("/$config->{bugzilla_installation}/buglist.cgi?tag=sel-tmp", undef, "List 'sel-tmp' bugs");
+$sel->open_ok("/$config->{bugzilla_installation}/buglist.cgi?tag=sel-tmp",
+  undef, "List 'sel-tmp' bugs");
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_is("Bug List");
 $sel->is_text_present_ok("Tags: sel-tmp");
 $sel->click_ok("link=$bug1_id");
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_like(qr/^$bug1_id /);
-$sel->select_ok("lob_action", "label=Remove");
+$sel->select_ok("lob_action",       "label=Remove");
 $sel->select_ok("lob_oldqueryname", "label=sel-tmp");
 $sel->type_ok("bug_ids", $bug1_id);
 $sel->click_ok("commit_list_of_bugs");
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_is("Tag Updated");
 $text = trim($sel->get_text("message"));
-ok($text =~ /The 'sel-tmp' tag has been removed from bug $bug1_id/, "Bug removed from 'sel-tmp' tag");
+ok($text =~ /The 'sel-tmp' tag has been removed from bug $bug1_id/,
+  "Bug removed from 'sel-tmp' tag");
 $sel->click_ok("link=sel-tmp");
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_is("Bug List");
@@ -150,14 +161,15 @@ $sel->is_text_present_ok("Tags: sel-tmp");
 $sel->click_ok("link=$bug2_id");
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_like(qr/^$bug2_id /);
-$sel->select_ok("lob_action", "label=Remove");
+$sel->select_ok("lob_action",       "label=Remove");
 $sel->select_ok("lob_oldqueryname", "label=sel-tmp");
 $sel->type_ok("bug_ids", $bug2_id);
 $sel->click_ok("commit_list_of_bugs");
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_is("Tag Updated");
 $text = trim($sel->get_text("message"));
-ok($text =~ /The 'sel-tmp' tag has been removed from bug $bug2_id/, "Bug removed from 'sel-tmp' tag");
+ok($text =~ /The 'sel-tmp' tag has been removed from bug $bug2_id/,
+  "Bug removed from 'sel-tmp' tag");
 $sel->click_ok("link=sel-tmp");
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_is("Bug List");
@@ -174,18 +186,31 @@ $sel->title_is("User Preferences");
 $sel->click_ok("link=General Preferences");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("User Preferences");
-ok(!$sel->is_element_present("skin"), "The 'skin' user preference is not present");
-$sel->select_ok("state_addselfcc", "label=Always");
+ok(!$sel->is_element_present("skin"),
+  "The 'skin' user preference is not present");
+$sel->select_ok("state_addselfcc",        "label=Always");
 $sel->select_ok("post_bug_submit_action", "label=Show next bug in my list");
-$sel->select_ok("per_bug_queries", "label=Off");
-ok(!$sel->is_element_present("zoom_textareas"), "The 'zoom_textareas' user preference is not present");
+$sel->select_ok("per_bug_queries",        "label=Off");
+ok(
+  !$sel->is_element_present("zoom_textareas"),
+  "The 'zoom_textareas' user preference is not present"
+);
 $sel->click_ok("update");
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_is("User Preferences");
 
-ok(!$sel->is_element_present("lob_action"), "Element 1/3 for tags is not displayed");
-ok(!$sel->is_element_present("lob_newqueryname"), "Element 2/3 for tags is not displayed");
-ok(!$sel->is_element_present("commit_list_of_bugs"), "Element 3/3 for tags is not displayed");
+ok(
+  !$sel->is_element_present("lob_action"),
+  "Element 1/3 for tags is not displayed"
+);
+ok(
+  !$sel->is_element_present("lob_newqueryname"),
+  "Element 2/3 for tags is not displayed"
+);
+ok(
+  !$sel->is_element_present("commit_list_of_bugs"),
+  "Element 3/3 for tags is not displayed"
+);
 
 # Create a new search named 'my_list'.
 
@@ -205,7 +230,10 @@ $sel->click_ok("remember");
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_is("Search created");
 $text = trim($sel->get_text("message"));
-ok($text =~ /OK, you have a new search named my_list./, "New saved search 'my_list' has been created");
+ok(
+  $text =~ /OK, you have a new search named my_list./,
+  "New saved search 'my_list' has been created"
+);
 
 # Editing bugs should follow user preferences.
 
@@ -216,12 +244,15 @@ $sel->click_ok("link=$bug1_id");
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_like(qr/^$bug1_id .* First bug created/);
 $sel->value_is("addselfcc", "on");
-$sel->type_ok("comment", "I should be CC'ed and then I should see the next bug.");
+$sel->type_ok("comment",
+  "I should be CC'ed and then I should see the next bug.");
 $sel->click_ok("commit");
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->is_text_present_ok("Changes submitted for bug $bug1_id");
 $sel->is_text_present_ok("The next bug in your list is bug $bug2_id");
-ok(!$sel->is_text_present("I should see the next bug"), "The updated bug is no longer displayed");
+ok(!$sel->is_text_present("I should see the next bug"),
+  "The updated bug is no longer displayed");
+
 # The user has no privs, so the short_desc field is not present.
 $sel->is_text_present_ok("My second bug");
 $sel->value_is("addselfcc", "on");
@@ -239,5 +270,8 @@ $sel->click_ok("link=Forget Search 'my_list'");
 $sel->wait_for_page_to_load(WAIT_TIME);
 $sel->title_is("Search is gone");
 $text = trim($sel->get_text("message"));
-ok($text =~ /OK, the my_list search is gone/, "The saved search 'my_list' has been deleted");
+ok(
+  $text =~ /OK, the my_list search is gone/,
+  "The saved search 'my_list' has been deleted"
+);
 logout($sel);
index 72b205b25a6fbffbab04b6570d69184d299ffd51..4c9acbfefcc0a52b7adc25a2ade4e99c7125e434 100644 (file)
@@ -18,7 +18,8 @@ my $test_bug_1 = $config->{test_bug_1};
 
 # When being logged out, the 'Commit' button should not be displayed.
 
-$sel->open_ok("/$config->{bugzilla_installation}/index.cgi?logout=1", undef, "Log out (if required)");
+$sel->open_ok("/$config->{bugzilla_installation}/index.cgi?logout=1",
+  undef, "Log out (if required)");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Logged Out");
 go_to_bug($sel, $test_bug_1);
@@ -31,11 +32,12 @@ log_in($sel, $config, 'unprivileged');
 file_bug_in_product($sel, 'TestProduct');
 ok(!$sel->is_editable("assigned_to"), "The assignee field is not editable");
 $sel->type_ok("short_desc", "Greetings from a powerless user");
-$sel->type_ok("comment", "File a bug with an empty CC list");
+$sel->type_ok("comment",    "File a bug with an empty CC list");
 $sel->click_ok("commit");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 my $bug1_id = $sel->get_value("//input[\@name='id' and \@type='hidden']");
-$sel->is_text_present_ok('has been added to the database', "Bug $bug1_id created");
+$sel->is_text_present_ok('has been added to the database',
+  "Bug $bug1_id created");
 logout($sel);
 
 # Some checks while being logged out.
@@ -43,8 +45,11 @@ logout($sel);
 go_to_bug($sel, $bug1_id);
 ok(!$sel->is_element_present("commit"), "Button 'Commit' not available");
 my $text = trim($sel->get_text("//fieldset"));
-ok($text =~ /You need to log in before you can comment on or make changes to this bug./,
-   "Addl. comment box not displayed");
+ok(
+  $text
+    =~ /You need to log in before you can comment on or make changes to this bug./,
+  "Addl. comment box not displayed"
+);
 
 # Don't call log_in() here. We explicitly want to use the "log in" link
 # in the addl. comment box.
@@ -53,8 +58,16 @@ $sel->click_ok("link=log in");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Log in to Bugzilla");
 $sel->is_text_present_ok("I need an email address and password to continue.");
-$sel->type_ok("Bugzilla_login", $config->{unprivileged_user_login}, "Enter login name");
-$sel->type_ok("Bugzilla_password", $config->{unprivileged_user_passwd}, "Enter password");
+$sel->type_ok(
+  "Bugzilla_login",
+  $config->{unprivileged_user_login},
+  "Enter login name"
+);
+$sel->type_ok(
+  "Bugzilla_password",
+  $config->{unprivileged_user_passwd},
+  "Enter password"
+);
 $sel->click_ok("log_in", undef, "Submit credentials");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_like(qr/^$bug1_id/, "Display bug $bug1_id");
@@ -62,7 +75,13 @@ $sel->title_like(qr/^$bug1_id/, "Display bug $bug1_id");
 # Neither the (edit) link nor the hidden form must exist, at all.
 # But the 'Commit' button does exist.
 
-ok(!$sel->is_element_present("bz_assignee_edit_action"), "No (edit) link displayed for the assignee");
-ok(!$sel->is_element_present("assigned_to"), "No hidden assignee field available");
+ok(
+  !$sel->is_element_present("bz_assignee_edit_action"),
+  "No (edit) link displayed for the assignee"
+);
+ok(
+  !$sel->is_element_present("assigned_to"),
+  "No hidden assignee field available"
+);
 $sel->is_element_present_ok("commit");
 logout($sel);
index d91ad352665656237908a028c29feee5db3f2a62..5ba59a36089993850839b9f066186c1a450d0745 100644 (file)
@@ -16,25 +16,30 @@ use QA::Util;
 my ($sel, $config) = get_selenium();
 
 unless ($config->{test_extensions}) {
-    ok(1, "this installation doesn't test extensions. Skipping test_votes.t completely.");
-    exit;
+  ok(1,
+    "this installation doesn't test extensions. Skipping test_votes.t completely.");
+  exit;
 }
 
 log_in($sel, $config, 'admin');
-set_parameters($sel, { "Bug Fields"              => {"useclassification-off" => undef},
-                       "Administrative Policies" => {"allowbugdeletion-on"   => undef}
-                     });
+set_parameters(
+  $sel,
+  {
+    "Bug Fields"              => {"useclassification-off" => undef},
+    "Administrative Policies" => {"allowbugdeletion-on"   => undef}
+  }
+);
 
 # Create a new product, so that we can safely play with vote settings.
 
 add_product($sel);
-$sel->type_ok("product", "Eureka");
-$sel->type_ok("description", "A great new product");
-$sel->type_ok("votesperuser", 10);
+$sel->type_ok("product",        "Eureka");
+$sel->type_ok("description",    "A great new product");
+$sel->type_ok("votesperuser",   10);
 $sel->type_ok("maxvotesperbug", 5);
 $sel->type_ok("votestoconfirm", 3);
-$sel->select_ok("security_group_id", "label=core-security");
-$sel->select_ok("default_op_sys_id", "Unspecified");
+$sel->select_ok("security_group_id",   "label=core-security");
+$sel->select_ok("default_op_sys_id",   "Unspecified");
 $sel->select_ok("default_platform_id", "Unspecified");
 $sel->click_ok('//input[@type="submit" and @value="Add"]');
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
@@ -42,9 +47,13 @@ $sel->title_is("Product Created");
 $sel->click_ok("link=add at least one component");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Add component to the Eureka product");
-$sel->type_ok("component", "Pegasus");
+$sel->type_ok("component",   "Pegasus");
 $sel->type_ok("description", "A constellation in the north hemisphere.");
-$sel->type_ok("initialowner", $config->{permanent_user}, "Setting the default owner");
+$sel->type_ok(
+  "initialowner",
+  $config->{permanent_user},
+  "Setting the default owner"
+);
 $sel->uncheck_ok("watch_user_auto");
 $sel->type_ok("watch_user", "pegasus\@eureka.bugs");
 $sel->check_ok("watch_user_auto");
@@ -52,15 +61,17 @@ $sel->click_ok("create");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Component Created");
 my $text = trim($sel->get_text("message"));
-ok($text =~ qr/The component Pegasus has been created/, "Component 'Pegasus' created");
+ok($text =~ qr/The component Pegasus has been created/,
+  "Component 'Pegasus' created");
 
 # Create a new bug with the CONFIRMED status.
 
 file_bug_in_product($sel, 'Eureka');
+
 # CONFIRMED must be the default bug status for users with editbugs privs.
 $sel->selected_label_is("bug_status", "CONFIRMED");
 $sel->type_ok("short_desc", "Aries");
-$sel->type_ok("comment", "1st constellation");
+$sel->type_ok("comment",    "1st constellation");
 $sel->click_ok("commit");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->is_text_present_ok('has been added to the database');
@@ -71,26 +82,32 @@ my $bug1_id = $sel->get_value('//input[@name="id" and @type="hidden"]');
 $sel->click_ok("link=vote");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Change Votes");
+
 # No comment :-/
 my $full_text = trim($sel->get_body_text());
+
 # OK, this is not the most robust regexp, but that's better than nothing.
-ok($full_text =~ /only 5 votes allowed per bug in this product/,
-   "Notice about the number of votes allowed per bug displayed");
+ok(
+  $full_text =~ /only 5 votes allowed per bug in this product/,
+  "Notice about the number of votes allowed per bug displayed"
+);
 $sel->type_ok("bug_$bug1_id", 4);
 $sel->click_ok("change");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Change Votes");
 $full_text = trim($sel->get_body_text());
+
 # OK, we may get a false positive if another product has the exact same numbers,
 # but I have no better idea to check this information.
-ok($full_text =~ /4 votes used out of 10 allowed/, "Display the number of votes used");
+ok($full_text =~ /4 votes used out of 10 allowed/,
+  "Display the number of votes used");
 
 # File a new bug, now as UNCONFIRMED. We will confirm it by popular votes.
 
 file_bug_in_product($sel, 'Eureka');
 $sel->select_ok("bug_status", "UNCONFIRMED");
 $sel->type_ok("short_desc", "Taurus");
-$sel->type_ok("comment", "2nd constellation");
+$sel->type_ok("comment",    "2nd constellation");
 $sel->click_ok("commit");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->is_text_present_ok('has been added to the database');
@@ -113,7 +130,7 @@ $sel->is_text_present_ok("Bug $bug2_id confirmed by number of votes");
 file_bug_in_product($sel, 'Eureka');
 $sel->select_ok("bug_status", "UNCONFIRMED");
 $sel->type_ok("short_desc", "Gemini");
-$sel->type_ok("comment", "3rd constellation");
+$sel->type_ok("comment",    "3rd constellation");
 $sel->click_ok("commit");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->is_text_present_ok('has been added to the database');
@@ -131,14 +148,18 @@ $sel->type_ok("bug_$bug3_id", 2);
 $sel->click_ok("change");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Change Votes");
+
 # Illegal change: max is 5 votes per bug!
 $sel->type_ok("bug_$bug2_id", 15);
 $sel->click_ok("change");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Illegal Vote");
 $text = trim($sel->get_text("error_msg"));
-ok($text =~ /You may only use at most 5 votes for a single bug in the Eureka product, but you are trying to use 15/,
-   "Too many votes per bug");
+ok(
+  $text
+    =~ /You may only use at most 5 votes for a single bug in the Eureka product, but you are trying to use 15/,
+  "Too many votes per bug"
+);
 
 # FIXME: We cannot use go_back_ok() here, because Firefox complains about
 #        POST data not being stored in its cache. As a workaround, we go to
@@ -156,8 +177,11 @@ $sel->click_ok("change");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Illegal Vote");
 $text = trim($sel->get_text("error_msg"));
-ok($text =~ /You tried to use 12 votes in the Eureka product, which exceeds the maximum of 10 votes for this product/,
-   "Too many votes for this product");
+ok(
+  $text
+    =~ /You tried to use 12 votes in the Eureka product, which exceeds the maximum of 10 votes for this product/,
+  "Too many votes for this product"
+);
 
 # Decrease the confirmation threshold so that $bug3 becomes confirmed.
 
@@ -168,7 +192,7 @@ $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Updating Product 'Eureka'");
 $full_text = trim($sel->get_body_text());
 ok($full_text =~ /Updated number of votes needed to confirm a bug from 3 to 2/,
-   "Confirming the new number of votes to confirm");
+  "Confirming the new number of votes to confirm");
 $sel->is_text_present_ok("Bug $bug3_id confirmed by number of votes");
 
 # Decrease the number of votes per bug so that $bug2 is updated.
@@ -181,9 +205,11 @@ $sel->click_ok('//input[@type="submit" and @value="Save Changes"]');
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Updating Product 'Eureka'");
 $full_text = trim($sel->get_body_text());
-ok($full_text =~ /Updated maximum votes per bug from 5 to 4/, "Confirming the new number of votes per bug");
-$sel->is_text_present_ok("removed votes for bug $bug2_id from " . $config->{admin_user_login}, undef,
-                         "Removed votes from the admin");
+ok($full_text =~ /Updated maximum votes per bug from 5 to 4/,
+  "Confirming the new number of votes per bug");
+$sel->is_text_present_ok(
+  "removed votes for bug $bug2_id from " . $config->{admin_user_login},
+  undef, "Removed votes from the admin");
 
 # Go check that $bug2 has been correctly updated.
 
@@ -202,7 +228,10 @@ $sel->click_ok('//input[@type="submit" and @value="Save Changes"]');
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Updating Product 'Eureka'");
 $full_text = trim($sel->get_body_text());
-ok($full_text =~ /Updated votes per user from 10 to 5/, "Confirming the new number of votes per user");
+ok(
+  $full_text =~ /Updated votes per user from 10 to 5/,
+  "Confirming the new number of votes per user"
+);
 $sel->is_text_present_ok("removed votes for bug");
 
 # Go check that $bug3 has been correctly updated.
@@ -221,14 +250,16 @@ $sel->click_ok('//input[@type="submit" and @value="Save Changes"]');
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Updating Product 'Eureka'");
 $full_text = trim($sel->get_body_text());
-ok($full_text =~ /The product no longer allows the UNCONFIRMED status/, "Disable UNCONFIRMED");
+ok($full_text =~ /The product no longer allows the UNCONFIRMED status/,
+  "Disable UNCONFIRMED");
 
 # File a new bug. UNCONFIRMED must not be listed as a valid bug status.
 
 file_bug_in_product($sel, "Eureka");
-ok(!scalar(grep {$_ eq "UNCONFIRMED"} $sel->get_select_options("bug_status")), "UNCONFIRMED not listed");
+ok(!scalar(grep { $_ eq "UNCONFIRMED" } $sel->get_select_options("bug_status")),
+  "UNCONFIRMED not listed");
 $sel->type_ok("short_desc", "Cancer");
-$sel->type_ok("comment", "4th constellation");
+$sel->type_ok("comment",    "4th constellation");
 $sel->click_ok("commit");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->is_text_present_ok('has been added to the database');
@@ -240,12 +271,15 @@ go_to_admin($sel);
 $sel->click_ok("link=Products");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Select product");
-$sel->click_ok('//a[contains(@href,"/editproducts.cgi?action=del&product=Eureka")]');
+$sel->click_ok(
+  '//a[contains(@href,"/editproducts.cgi?action=del&product=Eureka")]');
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Delete Product 'Eureka'");
 $full_text = trim($sel->get_body_text());
-ok($full_text =~ /There are 4 bugs entered for this product/, "Display warning about existing bugs");
-ok($full_text =~ /Pegasus: A constellation in the north hemisphere/, "Display product description");
+ok($full_text =~ /There are 4 bugs entered for this product/,
+  "Display warning about existing bugs");
+ok($full_text =~ /Pegasus: A constellation in the north hemisphere/,
+  "Display product description");
 $sel->click_ok("delete");
 $sel->wait_for_page_to_load_ok(WAIT_TIME);
 $sel->title_is("Product Deleted");
index 382e5bf99be98e298a58d887409ded10c1168716..8b4759c424baa8a2c0fc974fce3ae23448769da3 100644 (file)
@@ -13,215 +13,250 @@ use MIME::Base64 qw(encode_base64 decode_base64);
 use Test::More tests => 187;
 my ($config, $xmlrpc, $jsonrpc, $jsonrpc_get) = get_rpc_clients();
 
-use constant INVALID_BUG_ID => -1;
+use constant INVALID_BUG_ID    => -1;
 use constant INVALID_BUG_ALIAS => random_string(20);
-use constant PRIVS_USER => 'QA_Selenium_TEST';
+use constant PRIVS_USER        => 'QA_Selenium_TEST';
 
 sub attach {
-    my ($id, $override) = @_;
-    my %fields = (
-        ids  => [$id],
-        data => 'data-' . random_string(100),
-        file_name => 'file_name-' . random_string(60),
-        summary => 'summary-' . random_string(100),
-        content_type => 'text/plain',
-        comment => 'comment-' . random_string(100),
-    );
+  my ($id, $override) = @_;
+  my %fields = (
+    ids          => [$id],
+    data         => 'data-' . random_string(100),
+    file_name    => 'file_name-' . random_string(60),
+    summary      => 'summary-' . random_string(100),
+    content_type => 'text/plain',
+    comment      => 'comment-' . random_string(100),
+  );
 
-    foreach my $key (keys %{ $override || {} }) {
-        my $value = $override->{$key};
-        if (defined $value) {
-            $fields{$key} = $value;
-        }
-        else {
-            delete $fields{$key};
-        }
+  foreach my $key (keys %{$override || {}}) {
+    my $value = $override->{$key};
+    if (defined $value) {
+      $fields{$key} = $value;
+    }
+    else {
+      delete $fields{$key};
     }
-    return \%fields;
+  }
+  return \%fields;
 }
 
-my ($public_bug, $private_bug) =
-    $xmlrpc->bz_create_test_bugs('private');
-my $public_id = $public_bug->{id};
+my ($public_bug, $private_bug) = $xmlrpc->bz_create_test_bugs('private');
+my $public_id  = $public_bug->{id};
 my $private_id = $private_bug->{id};
 
 my @tests = (
-    # Permissions
-    { args  => attach($public_id),
-      error => 'You must log in',
-      test  => 'Logged-out user cannot add an attachment to a public bug',
-    },
-    { args  => attach($private_id),
-      error => "You must log in",
-      test  => 'Logged-out user cannot add an attachment to a private bug',
-    },
-    { user  => 'editbugs',
-      args  => attach($private_id),
-      error => "not authorized to access",
-      test  => "Editbugs user can't add an attachment to a private bug",
-    },
-
-    # Test ID parameter
-    { user  => 'unprivileged',
-      args  => attach(undef, { ids => undef }),
-      error => 'a ids argument',
-      test  => 'Failing to pass the "ids" param fails',
-    },
-    { user  => 'unprivileged',
-      args  => attach(INVALID_BUG_ID),
-      error => "It does not seem like bug number",
-      test  => 'Passing invalid bug id returns error "Invalid Bug ID"',
-    },
-    { user  => 'unprivileged',
-      args  => attach(''),
-      error => "You must enter a valid bug number",
-      test  => 'Passing empty bug id returns error "Invalid Bug ID"',
-    },
-    { user  => 'unprivileged',
-      args  => attach(INVALID_BUG_ALIAS),
-      error => "nor an alias to a bug",
-      test  => 'Passing invalid bug alias returns error "Invalid Bug Alias"',
-    },
-
-    # Test Comment parameter
-    { user  => 'unprivileged',
-      args  => attach($public_id, { data => undef }),
-      error => 'a data argument',
-      test  => 'Failing to pass the "data" parameter fails',
-    },
-    { user  => 'unprivileged',
-      args  => attach($public_id, { data => '' }),
-      error => "The file you are trying to attach is empty",
-      test  => 'Passing empty data fails',
-    },
-    { user  => 'unprivileged',
-      args  => attach($public_id, { data => random_string(300_000) }),
-      error => "Attachments cannot be more than",
-      test  => "Passing an attachment that's too large fails",
-    },
-
-    # Test the private parameter
-    { user  => 'unprivileged',
-      args  => attach($public_id, { is_private => 1 }),
-      error => 'attachments as private',
-      test  => 'Unprivileged user cannot add a private attachment'
-    },
-
-    # Content-type
-    { user  => 'unprivileged',
-      args  => attach($public_id, { content_type => 'foo/bar' }),
-      error => "Valid types must be of the form",
-      test  => "Well-formed but invalid content type fails",
-    },
-    { user  => 'unprivileged',
-      args  => attach($public_id, { content_type => undef }),
-      error => 'Valid types must be of the form',
-      test  => "Failing to pass content_type fails",
-    },
-    { user  => 'unprivileged',
-      args  => attach($public_id, { content_type => '' }),
-      error => 'Valid types must be of the form',
-      test  => "Empty content type fails",
-    },
-
-    # Summary
-    { user  => 'unprivileged',
-      args  => attach($public_id, { summary => undef }),
-      error => 'You must enter a description for the attachment',
-      test  => "Failing to pass summary fails",
-    },
-    { user  => 'unprivileged',
-      args  => attach($public_id, { summary => '' }),
-      error => 'You must enter a description for the attachment',
-      test  => "Empty summary fails",
-    },
-
-    # Filename
-    { user  => 'unprivileged',
-      args  => attach($public_id, { file_name => undef }),
-      error => 'You did not specify a file to attach',
-      test  => "Failing to pass file_name fails",
-    },
-    { user  => 'unprivileged',
-      args  => attach($public_id, { file_name => '' }),
-      error => 'You did not specify a file to attach',
-      test  => "Empty file_name fails",
-    },
-
-    # Success tests
-    { user => 'unprivileged',
-      args => attach($public_id),
-      test => 'Unprivileged user can add an attachment to a public bug',
-    },
-    { user => 'unprivileged',
-      args => attach($public_id, { is_patch => 1, content_type => undef }),
-      test => 'Attaching a patch with no content type works',
-    },
-    { user => 'unprivileged',
-      args => attach($public_id, { is_patch => 1,
-                     content_type => 'application/octet-stream' }),
-      test => 'Attaching a patch with a bad content_type works',
-    },
-    { user => PRIVS_USER,
-      args => attach($private_id),
-      test => 'Privileged user can add an attachment to a private bug',
-    },
-    { user => PRIVS_USER,
-      args => attach($public_id, { is_private => 1 }),
-      test => 'Insidergroup user can add a private attachment',
-    },
+
+  # Permissions
+  {
+    args  => attach($public_id),
+    error => 'You must log in',
+    test  => 'Logged-out user cannot add an attachment to a public bug',
+  },
+  {
+    args  => attach($private_id),
+    error => "You must log in",
+    test  => 'Logged-out user cannot add an attachment to a private bug',
+  },
+  {
+    user  => 'editbugs',
+    args  => attach($private_id),
+    error => "not authorized to access",
+    test  => "Editbugs user can't add an attachment to a private bug",
+  },
+
+  # Test ID parameter
+  {
+    user  => 'unprivileged',
+    args  => attach(undef, {ids => undef}),
+    error => 'a ids argument',
+    test  => 'Failing to pass the "ids" param fails',
+  },
+  {
+    user  => 'unprivileged',
+    args  => attach(INVALID_BUG_ID),
+    error => "It does not seem like bug number",
+    test  => 'Passing invalid bug id returns error "Invalid Bug ID"',
+  },
+  {
+    user  => 'unprivileged',
+    args  => attach(''),
+    error => "You must enter a valid bug number",
+    test  => 'Passing empty bug id returns error "Invalid Bug ID"',
+  },
+  {
+    user  => 'unprivileged',
+    args  => attach(INVALID_BUG_ALIAS),
+    error => "nor an alias to a bug",
+    test  => 'Passing invalid bug alias returns error "Invalid Bug Alias"',
+  },
+
+  # Test Comment parameter
+  {
+    user  => 'unprivileged',
+    args  => attach($public_id, {data => undef}),
+    error => 'a data argument',
+    test  => 'Failing to pass the "data" parameter fails',
+  },
+  {
+    user  => 'unprivileged',
+    args  => attach($public_id, {data => ''}),
+    error => "The file you are trying to attach is empty",
+    test  => 'Passing empty data fails',
+  },
+  {
+    user  => 'unprivileged',
+    args  => attach($public_id, {data => random_string(300_000)}),
+    error => "Attachments cannot be more than",
+    test  => "Passing an attachment that's too large fails",
+  },
+
+  # Test the private parameter
+  {
+    user  => 'unprivileged',
+    args  => attach($public_id, {is_private => 1}),
+    error => 'attachments as private',
+    test  => 'Unprivileged user cannot add a private attachment'
+  },
+
+  # Content-type
+  {
+    user  => 'unprivileged',
+    args  => attach($public_id, {content_type => 'foo/bar'}),
+    error => "Valid types must be of the form",
+    test  => "Well-formed but invalid content type fails",
+  },
+  {
+    user  => 'unprivileged',
+    args  => attach($public_id, {content_type => undef}),
+    error => 'Valid types must be of the form',
+    test  => "Failing to pass content_type fails",
+  },
+  {
+    user  => 'unprivileged',
+    args  => attach($public_id, {content_type => ''}),
+    error => 'Valid types must be of the form',
+    test  => "Empty content type fails",
+  },
+
+  # Summary
+  {
+    user  => 'unprivileged',
+    args  => attach($public_id, {summary => undef}),
+    error => 'You must enter a description for the attachment',
+    test  => "Failing to pass summary fails",
+  },
+  {
+    user  => 'unprivileged',
+    args  => attach($public_id, {summary => ''}),
+    error => 'You must enter a description for the attachment',
+    test  => "Empty summary fails",
+  },
+
+  # Filename
+  {
+    user  => 'unprivileged',
+    args  => attach($public_id, {file_name => undef}),
+    error => 'You did not specify a file to attach',
+    test  => "Failing to pass file_name fails",
+  },
+  {
+    user  => 'unprivileged',
+    args  => attach($public_id, {file_name => ''}),
+    error => 'You did not specify a file to attach',
+    test  => "Empty file_name fails",
+  },
+
+  # Success tests
+  {
+    user => 'unprivileged',
+    args => attach($public_id),
+    test => 'Unprivileged user can add an attachment to a public bug',
+  },
+  {
+    user => 'unprivileged',
+    args => attach($public_id, {is_patch => 1, content_type => undef}),
+    test => 'Attaching a patch with no content type works',
+  },
+  {
+    user => 'unprivileged',
+    args => attach(
+      $public_id, {is_patch => 1, content_type => 'application/octet-stream'}
+    ),
+    test => 'Attaching a patch with a bad content_type works',
+  },
+  {
+    user => PRIVS_USER,
+    args => attach($private_id),
+    test => 'Privileged user can add an attachment to a private bug',
+  },
+  {
+    user => PRIVS_USER,
+    args => attach($public_id, {is_private => 1}),
+    test => 'Insidergroup user can add a private attachment',
+  },
 );
 
-$jsonrpc_get->bz_call_fail('Bug.add_attachment', attach($public_id),
-    'must use HTTP POST', 'add_attachment fails over GET');
+$jsonrpc_get->bz_call_fail(
+  'Bug.add_attachment', attach($public_id),
+  'must use HTTP POST', 'add_attachment fails over GET'
+);
 
 foreach my $rpc ($jsonrpc, $xmlrpc) {
-    $rpc->bz_run_tests(tests => \@tests, method => 'Bug.add_attachment',
-                       post_success => \&post_success, pre_call => \&pre_call);
+  $rpc->bz_run_tests(
+    tests        => \@tests,
+    method       => 'Bug.add_attachment',
+    post_success => \&post_success,
+    pre_call     => \&pre_call
+  );
 }
 
 # We have to encode data manually when using JSON-RPC, else it fails.
 sub pre_call {
-    my ($t, $rpc) = @_;
-    return if !$rpc->isa('QA::RPC::JSONRPC');
-    return if !defined $t->{args}->{data};
+  my ($t, $rpc) = @_;
+  return if !$rpc->isa('QA::RPC::JSONRPC');
+  return if !defined $t->{args}->{data};
 
-    $t->{args}->{data} = encode_base64($t->{args}->{data}, '');
+  $t->{args}->{data} = encode_base64($t->{args}->{data}, '');
 }
 
 sub post_success {
-    my ($call, $t, $rpc) = @_;
-
-    my $ids = [ keys %{ $call->result->{attachments} } ];
-    $call = $rpc->bz_call_success("Bug.attachments", {attachment_ids => $ids});
-    my $attachments = $call->result->{attachments};
-
-    foreach my $id (keys %$attachments) {
-        my $attachment = $attachments->{$id};
-        if ($t->{args}->{is_private}) {
-            ok($attachment->{is_private},
-               $rpc->TYPE . ": Attachment $id is private");
-        }
-        else {
-            ok(!$attachment->{is_private},
-               $rpc->TYPE . ": Attachment $id is NOT private");
-        }
-
-        if ($t->{args}->{is_patch}) {
-            is($attachment->{content_type}, 'text/plain',
-               $rpc->TYPE . ": Patch $id content type is text/plain");
-        }
-        else {
-            is($attachment->{content_type}, $t->{args}->{content_type},
-               $rpc->TYPE . ": Attachment $id content type is correct");
-        }
-
-        if ($rpc->isa('QA::RPC::JSONRPC')) {
-            # We encoded data in pre_call(), so we have to restore it to its original content.
-            $t->{args}->{data} = decode_base64($t->{args}->{data});
-            $attachment->{data} = decode_base64($attachment->{data});
-        }
-        is($attachment->{data}, $t->{args}->{data},
-           $rpc->TYPE . ": Attachment $id data is correct");
+  my ($call, $t, $rpc) = @_;
+
+  my $ids = [keys %{$call->result->{attachments}}];
+  $call = $rpc->bz_call_success("Bug.attachments", {attachment_ids => $ids});
+  my $attachments = $call->result->{attachments};
+
+  foreach my $id (keys %$attachments) {
+    my $attachment = $attachments->{$id};
+    if ($t->{args}->{is_private}) {
+      ok($attachment->{is_private}, $rpc->TYPE . ": Attachment $id is private");
+    }
+    else {
+      ok(!$attachment->{is_private}, $rpc->TYPE . ": Attachment $id is NOT private");
+    }
+
+    if ($t->{args}->{is_patch}) {
+      is($attachment->{content_type},
+        'text/plain', $rpc->TYPE . ": Patch $id content type is text/plain");
     }
+    else {
+      is(
+        $attachment->{content_type},
+        $t->{args}->{content_type},
+        $rpc->TYPE . ": Attachment $id content type is correct"
+      );
+    }
+
+    if ($rpc->isa('QA::RPC::JSONRPC')) {
+
+    # We encoded data in pre_call(), so we have to restore it to its original content.
+      $t->{args}->{data} = decode_base64($t->{args}->{data});
+      $attachment->{data} = decode_base64($attachment->{data});
+    }
+    is(
+      $attachment->{data},
+      $t->{args}->{data},
+      $rpc->TYPE . ": Attachment $id data is correct"
+    );
+  }
 }
index dafd088fbdea54f5b0a03d95cacb069c54754ad8..a7b95caeba3153e19d2fcfcf4ca576fa1e72929c 100644 (file)
@@ -16,153 +16,182 @@ use QA::Util;
 use Test::More tests => 141;
 my ($config, $xmlrpc, $jsonrpc, $jsonrpc_get) = get_rpc_clients();
 
-use constant INVALID_BUG_ID => -1;
+use constant INVALID_BUG_ID    => -1;
 use constant INVALID_BUG_ALIAS => 'aaaaaaa12345';
-use constant PRIVS_USER => 'QA_Selenium_TEST';
+use constant PRIVS_USER        => 'QA_Selenium_TEST';
 use constant TIMETRACKING_USER => 'admin';
 
-use constant TEST_COMMENT => '--- Test Comment From QA Tests ---';
+use constant TEST_COMMENT     => '--- Test Comment From QA Tests ---';
 use constant TOO_LONG_COMMENT => 'a' x 100000;
 
 my @tests = (
-    # Permissions
-    { args  => { id => 'public_bug', comment => TEST_COMMENT },
-      error => 'You must log in',
-      test  => 'Logged-out user cannot comment on a public bug',
-    },
-    { args  => { id => 'private_bug', comment => TEST_COMMENT },
-      error => "You must log in",
-      test  => 'Logged-out user cannot comment on a private bug',
-    },
-    { user  => 'unprivileged',
-      args  => { id => 'private_bug', comment => TEST_COMMENT },
-      error => "not authorized to access",
-      test  => "Unprivileged user can't comment on a private bug",
-    },
-
-    # Test ID parameter
-    { user  => 'unprivileged',
-      args  => { comment => TEST_COMMENT },
-      error => 'a id argument',
-      test  => 'Failing to pass the "id" param fails',
-    },
-    { user  => 'unprivileged',
-      args  => { id => INVALID_BUG_ID, comment => TEST_COMMENT },
-      error => "It does not seem like bug number",
-      test  => 'Passing invalid bug id returns error "Invalid Bug ID"',
-    },
-    { user  => 'unprivileged',
-      args  => { id => '', comment => TEST_COMMENT },
-      error => "You must enter a valid bug number",
-      test  => 'Passing empty bug id param returns error "Invalid Bug ID"',
-    },
-    { user  => 'unprivileged',
-      args  => { id => INVALID_BUG_ALIAS, comment => TEST_COMMENT },
-      error => "nor an alias to a bug",
-      test  => 'Passing invalid bug alias returns error "Invalid Bug Alias"',
-    },
-
-    # Test Comment parameter
-    { user  => 'unprivileged',
-      args  => { id => 'public_bug' },
-      error => 'a comment argument',
-      test  => 'Failing to pass the "comment" parameter fails',
-    },
-    { user  => 'unprivileged',
-      args  => { id => 'public_bug', comment => '' },
-      error => "a comment argument",
-      test  => 'Passing an empty comment fails',
-    },
-    { user  => 'unprivileged',
-      args  => { id => 'public_bug', comment => ' ' },
-      error => 'a comment argument',
-      test  => 'Passing only a space for comment fails',
-    },
-    { user  => 'unprivileged',
-      args  => { id => 'public_bug', comment => " \t\n\n\r\n\r\n\r " },
-      error => 'a comment argument',
-      test  => 'Passing only whitespace (including newlines) fails',
-    },
-    { user  => 'unprivileged',
-      args  => { id => 'public_bug', comment => TOO_LONG_COMMENT },
-      error => "cannot be longer than",
-      test  => "Passing a comment that's too long fails",
-    },
-
-    # Testing the "private" parameter happens in the tests for Bug.comments
-
-    # Test work_time parameter
-    # FIXME: Should be testing permissions on the work_time parameter,
-    #        but we currently have no way to verify whether or not time was
-    #        added to the bug, and there's no error thrown if you lack perms.
-    { user  => 'admin',
-      args  => { id => 'public_bug', comment => TEST_COMMENT,
-                 work_time => 'aaa' },
-      error => "is not a numeric value",
-      test  => "Passing a non-numeric work_time fails",
-    },
-    { user  => 'admin',
-      args  => { id => 'public_bug', comment => TEST_COMMENT,
-                 work_time => '1234567890' },
-      error => 'more than the maximum',
-      test  => 'Passing too large of a work_time fails',
-    },
-    { user  => 'admin',
-      args  => { id => 'public_bug', comment => '',
-                 work_time => '1.0' },
-      error => 'a comment argument',
-      test  => 'Passing a work_time with an empty comment fails',
-    },
-
-    # Success tests
-    { user => 'unprivileged',
-      args => { id => 'public_bug', comment => TEST_COMMENT },
-      test => 'Unprivileged user can add a comment to a public bug',
-    },
-    { user => 'unprivileged',
-      args => { id => 'public_bug', comment => " \n" . TEST_COMMENT },
-      test => 'Can add a comment to a bug where the first line is whitespace',
-    },
-    { user => 'QA_Selenium_TEST',
-      args => { id => 'private_bug', comment => TEST_COMMENT },
-      test => 'Privileged user can add a comment to a private bug',
-      check_privacy => 1,
-    },
-    { user => 'QA_Selenium_TEST',
-      args => { id => 'public_bug', comment => TEST_COMMENT,
-                is_private => 1 },
-      test => 'Insidergroup user can add a private comment',
-      check_privacy => 1,
-    },
-    { user => 'admin',
-      args => { id => 'public_bug', comment => TEST_COMMENT,
-                work_time => '1.5' },
-      test => 'Timetracking user can add work_time to a bug',
-    },
-    # FIXME: Need to verify that the comment added actually has work_time.
+
+  # Permissions
+  {
+    args  => {id => 'public_bug', comment => TEST_COMMENT},
+    error => 'You must log in',
+    test  => 'Logged-out user cannot comment on a public bug',
+  },
+  {
+    args  => {id => 'private_bug', comment => TEST_COMMENT},
+    error => "You must log in",
+    test  => 'Logged-out user cannot comment on a private bug',
+  },
+  {
+    user  => 'unprivileged',
+    args  => {id => 'private_bug', comment => TEST_COMMENT},
+    error => "not authorized to access",
+    test  => "Unprivileged user can't comment on a private bug",
+  },
+
+  # Test ID parameter
+  {
+    user  => 'unprivileged',
+    args  => {comment => TEST_COMMENT},
+    error => 'a id argument',
+    test  => 'Failing to pass the "id" param fails',
+  },
+  {
+    user  => 'unprivileged',
+    args  => {id => INVALID_BUG_ID, comment => TEST_COMMENT},
+    error => "It does not seem like bug number",
+    test  => 'Passing invalid bug id returns error "Invalid Bug ID"',
+  },
+  {
+    user  => 'unprivileged',
+    args  => {id => '', comment => TEST_COMMENT},
+    error => "You must enter a valid bug number",
+    test  => 'Passing empty bug id param returns error "Invalid Bug ID"',
+  },
+  {
+    user  => 'unprivileged',
+    args  => {id => INVALID_BUG_ALIAS, comment => TEST_COMMENT},
+    error => "nor an alias to a bug",
+    test  => 'Passing invalid bug alias returns error "Invalid Bug Alias"',
+  },
+
+  # Test Comment parameter
+  {
+    user  => 'unprivileged',
+    args  => {id => 'public_bug'},
+    error => 'a comment argument',
+    test  => 'Failing to pass the "comment" parameter fails',
+  },
+  {
+    user  => 'unprivileged',
+    args  => {id => 'public_bug', comment => ''},
+    error => "a comment argument",
+    test  => 'Passing an empty comment fails',
+  },
+  {
+    user  => 'unprivileged',
+    args  => {id => 'public_bug', comment => ' '},
+    error => 'a comment argument',
+    test  => 'Passing only a space for comment fails',
+  },
+  {
+    user  => 'unprivileged',
+    args  => {id => 'public_bug', comment => " \t\n\n\r\n\r\n\r "},
+    error => 'a comment argument',
+    test  => 'Passing only whitespace (including newlines) fails',
+  },
+  {
+    user  => 'unprivileged',
+    args  => {id => 'public_bug', comment => TOO_LONG_COMMENT},
+    error => "cannot be longer than",
+    test  => "Passing a comment that's too long fails",
+  },
+
+  # Testing the "private" parameter happens in the tests for Bug.comments
+
+  # Test work_time parameter
+  # FIXME: Should be testing permissions on the work_time parameter,
+  #        but we currently have no way to verify whether or not time was
+  #        added to the bug, and there's no error thrown if you lack perms.
+  {
+    user  => 'admin',
+    args  => {id => 'public_bug', comment => TEST_COMMENT, work_time => 'aaa'},
+    error => "is not a numeric value",
+    test  => "Passing a non-numeric work_time fails",
+  },
+  {
+    user => 'admin',
+    args =>
+      {id => 'public_bug', comment => TEST_COMMENT, work_time => '1234567890'},
+    error => 'more than the maximum',
+    test  => 'Passing too large of a work_time fails',
+  },
+  {
+    user  => 'admin',
+    args  => {id => 'public_bug', comment => '', work_time => '1.0'},
+    error => 'a comment argument',
+    test  => 'Passing a work_time with an empty comment fails',
+  },
+
+  # Success tests
+  {
+    user => 'unprivileged',
+    args => {id => 'public_bug', comment => TEST_COMMENT},
+    test => 'Unprivileged user can add a comment to a public bug',
+  },
+  {
+    user => 'unprivileged',
+    args => {id => 'public_bug', comment => " \n" . TEST_COMMENT},
+    test => 'Can add a comment to a bug where the first line is whitespace',
+  },
+  {
+    user          => 'QA_Selenium_TEST',
+    args          => {id => 'private_bug', comment => TEST_COMMENT},
+    test          => 'Privileged user can add a comment to a private bug',
+    check_privacy => 1,
+  },
+  {
+    user          => 'QA_Selenium_TEST',
+    args          => {id => 'public_bug', comment => TEST_COMMENT, is_private => 1},
+    test          => 'Insidergroup user can add a private comment',
+    check_privacy => 1,
+  },
+  {
+    user => 'admin',
+    args => {id => 'public_bug', comment => TEST_COMMENT, work_time => '1.5'},
+    test => 'Timetracking user can add work_time to a bug',
+  },
+
+  # FIXME: Need to verify that the comment added actually has work_time.
 );
 
-$jsonrpc_get->bz_call_fail('Bug.add_comment',
-    { id => 'public_bug', comment => TEST_COMMENT },
-    'must use HTTP POST', 'add_comment fails over GET');
+$jsonrpc_get->bz_call_fail(
+  'Bug.add_comment',
+  {id => 'public_bug', comment => TEST_COMMENT},
+  'must use HTTP POST',
+  'add_comment fails over GET'
+);
 
 foreach my $rpc ($jsonrpc, $xmlrpc) {
-    $rpc->bz_run_tests(tests => \@tests, method => 'Bug.add_comment',
-                       post_success => \&post_success);
+  $rpc->bz_run_tests(
+    tests        => \@tests,
+    method       => 'Bug.add_comment',
+    post_success => \&post_success
+  );
 }
 
 sub post_success {
-    my ($call, $t, $rpc) = @_;
-    return unless $t->{check_privacy};
-
-    my $comment_id = $call->result->{id};
-    my $result = $rpc->bz_call_success('Bug.comments', {comment_ids => [$comment_id]});
-    if ($t->{args}->{is_private}) {
-        ok($result->result->{comments}->{$comment_id}->{is_private},
-           $rpc->TYPE . ": Comment $comment_id is private");
-    }
-    else {
-        ok(!$result->result->{comments}->{$comment_id}->{is_private},
-           $rpc->TYPE . ": Comment $comment_id is NOT private");
-    }
+  my ($call, $t, $rpc) = @_;
+  return unless $t->{check_privacy};
+
+  my $comment_id = $call->result->{id};
+  my $result
+    = $rpc->bz_call_success('Bug.comments', {comment_ids => [$comment_id]});
+  if ($t->{args}->{is_private}) {
+    ok(
+      $result->result->{comments}->{$comment_id}->{is_private},
+      $rpc->TYPE . ": Comment $comment_id is private"
+    );
+  }
+  else {
+    ok(
+      !$result->result->{comments}->{$comment_id}->{is_private},
+      $rpc->TYPE . ": Comment $comment_id is NOT private"
+    );
+  }
 }
index daa5032a352ea3ac4598c299748a339b71fa9cc7..cd2e6bfa4a12f7d48802f932095c638539d54f4d 100644 (file)
@@ -23,36 +23,41 @@ my ($config, @clients) = get_rpc_clients();
 our %attachments;
 
 sub post_bug_success {
-    my ($call, $t) = @_;
-
-    my $bugs = $call->result->{bugs};
-    is(scalar keys %$bugs, 1, "Got exactly one bug")
-        or diag(Dumper($call->result));
-
-    my $bug_attachments = (values %$bugs)[0];
-    # Collect attachment ids
-    foreach my $alias (qw(public_bug private_bug)) {
-        foreach my $is_private (0, 1) {
-            my $find_desc = "${alias}_${is_private}";
-            my $attachment = first { $_->{summary} eq $find_desc }
-                                   reverse @$bug_attachments;
-            if ($attachment) {
-                $attachments{$find_desc} = $attachment->{id};
-            }
-        }
+  my ($call, $t) = @_;
+
+  my $bugs = $call->result->{bugs};
+  is(scalar keys %$bugs, 1, "Got exactly one bug") or diag(Dumper($call->result));
+
+  my $bug_attachments = (values %$bugs)[0];
+
+  # Collect attachment ids
+  foreach my $alias (qw(public_bug private_bug)) {
+    foreach my $is_private (0, 1) {
+      my $find_desc = "${alias}_${is_private}";
+      my $attachment = first { $_->{summary} eq $find_desc }
+      reverse @$bug_attachments;
+      if ($attachment) {
+        $attachments{$find_desc} = $attachment->{id};
+      }
     }
+  }
 }
 
 foreach my $rpc (@clients) {
-    $rpc->bz_run_tests(tests => STANDARD_BUG_TESTS, method => 'Bug.attachments',
-                       post_success => \&post_bug_success);
+  $rpc->bz_run_tests(
+    tests        => STANDARD_BUG_TESTS,
+    method       => 'Bug.attachments',
+    post_success => \&post_bug_success
+  );
 }
 
 foreach my $alias (qw(public_bug private_bug)) {
-    foreach my $is_private (0, 1) {
-        ok($attachments{"${alias}_${is_private}"},
-           "Found attachment id for ${alias}_${is_private}");
-    }
+  foreach my $is_private (0, 1) {
+    ok(
+      $attachments{"${alias}_${is_private}"},
+      "Found attachment id for ${alias}_${is_private}"
+    );
+  }
 }
 
 ####################
@@ -69,83 +74,99 @@ close($fh);
 # format of each return value is correct.
 
 my @tests = (
-    # Logged-out user
-    { args => { attachment_ids => [$attachments{'public_bug_0'}] },
-      test => 'Logged-out user can access public attachment on public'
-              . '  bug by id',
-    },
-    { args  => { attachment_ids => [$attachments{'public_bug_1'}] },
-      test  => 'Logged-out user cannot access private attachment on public bug',
-      error => 'Sorry, you are not authorized',
-    },
-    { args  => { attachment_ids => [$attachments{'private_bug_0'}] },
-      test  => 'Logged-out user cannot access attachments by id on private bug',
-      error => 'You are not authorized to access',
-    },
-    { args  => { attachment_ids => [$attachments{'private_bug_1'}] },
-      test  => 'Logged-out user cannot access private attachment on '
-               . ' private bug',
-      error => 'You are not authorized to access',
-    },
-
-    # Logged-in, unprivileged user.
-    { user => 'unprivileged',
-      args => { attachment_ids => [$attachments{'public_bug_0'}] },
-      test => 'Logged-in user can see a public attachment on a public bug by id',
-    },
-    { user  => 'unprivileged',
-      args  => { attachment_ids => [$attachments{'public_bug_1'}] },
-      test  => 'Logged-in user cannot access private attachment on public bug',
-      error => 'Sorry, you are not authorized',
-    },
-    { user  => 'unprivileged',
-      args  => { attachment_ids => [$attachments{'private_bug_0'}] },
-      test  => 'Logged-in user cannot access attachments by id on private bug',
-      error => "You are not authorized to access",
-    },
-    { user  => 'unprivileged',
-      args  => { attachment_ids => [$attachments{'private_bug_1'}] },
-      test  => 'Logged-in user cannot access private attachment on private bug',
-      error => "You are not authorized to access",
-    },
-
-    # User who can see private bugs and private attachments
-    { user => PRIVATE_BUG_USER,
-      args => { attachment_ids => [$attachments{'public_bug_1'}] },
-      test => PRIVATE_BUG_USER . ' can see private attachment on public bug',
-    },
-    { user  => PRIVATE_BUG_USER,
-      args  => { attachment_ids => [$attachments{'private_bug_1'}] },
-      test  => PRIVATE_BUG_USER . ' can see private attachment on private bug',
-    },
+
+  # Logged-out user
+  {
+    args => {attachment_ids => [$attachments{'public_bug_0'}]},
+    test => 'Logged-out user can access public attachment on public'
+      . '  bug by id',
+  },
+  {
+    args  => {attachment_ids => [$attachments{'public_bug_1'}]},
+    test  => 'Logged-out user cannot access private attachment on public bug',
+    error => 'Sorry, you are not authorized',
+  },
+  {
+    args  => {attachment_ids => [$attachments{'private_bug_0'}]},
+    test  => 'Logged-out user cannot access attachments by id on private bug',
+    error => 'You are not authorized to access',
+  },
+  {
+    args => {attachment_ids => [$attachments{'private_bug_1'}]},
+    test => 'Logged-out user cannot access private attachment on ' . ' private bug',
+    error => 'You are not authorized to access',
+  },
+
+  # Logged-in, unprivileged user.
+  {
+    user => 'unprivileged',
+    args => {attachment_ids => [$attachments{'public_bug_0'}]},
+    test => 'Logged-in user can see a public attachment on a public bug by id',
+  },
+  {
+    user  => 'unprivileged',
+    args  => {attachment_ids => [$attachments{'public_bug_1'}]},
+    test  => 'Logged-in user cannot access private attachment on public bug',
+    error => 'Sorry, you are not authorized',
+  },
+  {
+    user  => 'unprivileged',
+    args  => {attachment_ids => [$attachments{'private_bug_0'}]},
+    test  => 'Logged-in user cannot access attachments by id on private bug',
+    error => "You are not authorized to access",
+  },
+  {
+    user  => 'unprivileged',
+    args  => {attachment_ids => [$attachments{'private_bug_1'}]},
+    test  => 'Logged-in user cannot access private attachment on private bug',
+    error => "You are not authorized to access",
+  },
+
+  # User who can see private bugs and private attachments
+  {
+    user => PRIVATE_BUG_USER,
+    args => {attachment_ids => [$attachments{'public_bug_1'}]},
+    test => PRIVATE_BUG_USER . ' can see private attachment on public bug',
+  },
+  {
+    user => PRIVATE_BUG_USER,
+    args => {attachment_ids => [$attachments{'private_bug_1'}]},
+    test => PRIVATE_BUG_USER . ' can see private attachment on private bug',
+  },
 );
 
 sub post_success {
-    my ($call, $t, $rpc) = @_;
-    is(scalar keys %{ $call->result->{attachments} }, 1,
-       "Got exactly one attachment");
-    my $attachment = (values %{ $call->result->{attachments} })[0];
-
-    cmp_ok($attachment->{last_change_time}, '=~', $rpc->DATETIME_REGEX,
-           "last_change_time is in the right format");
-    cmp_ok($attachment->{creation_time}, '=~', $rpc->DATETIME_REGEX,
-           "creation_time is in the right format");
-    is($attachment->{is_obsolete}, 0, 'is_obsolete is 0');
-    cmp_ok($attachment->{bug_id}, '=~', qr/^\d+$/, "bug_id is an integer");
-    cmp_ok($attachment->{id}, '=~', qr/^\d+$/, "id is an integer");
-    is($attachment->{content_type}, 'application/x-perl',
-       "content_type is correct");
-    cmp_ok($attachment->{file_name}, '=~', qr/^\w+\.pl$/,
-           "filename is in the expected format");
-    is($attachment->{creator}, $config->{QA_Selenium_TEST_user_login},
-       "creator is the correct user");
-    my $data = $attachment->{data};
-    $data = decode_base64($data) if $rpc->isa('QA::RPC::JSONRPC');
-    is($data, $content, 'data is correct');
-    is($attachment->{size}, length($data), "size matches data's size");
+  my ($call, $t, $rpc) = @_;
+  is(scalar keys %{$call->result->{attachments}}, 1,
+    "Got exactly one attachment");
+  my $attachment = (values %{$call->result->{attachments}})[0];
+
+  cmp_ok($attachment->{last_change_time},
+    '=~', $rpc->DATETIME_REGEX, "last_change_time is in the right format");
+  cmp_ok($attachment->{creation_time},
+    '=~', $rpc->DATETIME_REGEX, "creation_time is in the right format");
+  is($attachment->{is_obsolete}, 0, 'is_obsolete is 0');
+  cmp_ok($attachment->{bug_id}, '=~', qr/^\d+$/, "bug_id is an integer");
+  cmp_ok($attachment->{id},     '=~', qr/^\d+$/, "id is an integer");
+  is($attachment->{content_type}, 'application/x-perl',
+    "content_type is correct");
+  cmp_ok($attachment->{file_name},
+    '=~', qr/^\w+\.pl$/, "filename is in the expected format");
+  is(
+    $attachment->{creator},
+    $config->{QA_Selenium_TEST_user_login},
+    "creator is the correct user"
+  );
+  my $data = $attachment->{data};
+  $data = decode_base64($data) if $rpc->isa('QA::RPC::JSONRPC');
+  is($data,               $content,      'data is correct');
+  is($attachment->{size}, length($data), "size matches data's size");
 }
 
 foreach my $rpc (@clients) {
-    $rpc->bz_run_tests(method => 'Bug.attachments', tests => \@tests,
-                       post_success => \&post_success);
+  $rpc->bz_run_tests(
+    method       => 'Bug.attachments',
+    tests        => \@tests,
+    post_success => \&post_success
+  );
 }
index ccc0c6d34291afb19aca82f2e13729130060f1f5..f3f834f8514cd4eeeac7786875583fbcfeb10cf3 100644 (file)
@@ -21,46 +21,50 @@ my ($config, @clients) = get_rpc_clients();
 # These gets populated when we call Bug.add_comment.
 our $creation_time;
 our %comments = (
-    public_comment_public_bug  => 0,
-    public_comment_private_bug  => 0,
-    private_comment_public_bug  => 0,
-    private_comment_private_bug => 0,
+  public_comment_public_bug   => 0,
+  public_comment_private_bug  => 0,
+  private_comment_public_bug  => 0,
+  private_comment_private_bug => 0,
 );
 
 sub test_comments {
-    my ($comments_returned, $call, $t, $rpc) = @_;
+  my ($comments_returned, $call, $t, $rpc) = @_;
 
-    my $comment = $comments_returned->[0];
-    ok($comment->{bug_id}, "bug_id exists");
-    # FIXME: At some point we should test attachment_id here.
+  my $comment = $comments_returned->[0];
+  ok($comment->{bug_id}, "bug_id exists");
 
-    if ($t->{args}->{comment_ids}) {
-        my $expected_id = $t->{args}->{comment_ids}->[0];
-        is($comment->{id}, $expected_id, "comment id is correct");
+  # FIXME: At some point we should test attachment_id here.
 
-        my %reverse_map = reverse %comments;
-        my $expected_text = $reverse_map{$expected_id};
-        is($comment->{text}, $expected_text, "comment has the correct text");
+  if ($t->{args}->{comment_ids}) {
+    my $expected_id = $t->{args}->{comment_ids}->[0];
+    is($comment->{id}, $expected_id, "comment id is correct");
 
-        my $priv_login = $rpc->bz_config->{PRIVATE_BUG_USER . '_user_login'};
-        is($comment->{creator}, $priv_login, "comment creator is correct");
+    my %reverse_map   = reverse %comments;
+    my $expected_text = $reverse_map{$expected_id};
+    is($comment->{text}, $expected_text, "comment has the correct text");
 
+    my $priv_login = $rpc->bz_config->{PRIVATE_BUG_USER . '_user_login'};
+    is($comment->{creator}, $priv_login, "comment creator is correct");
 
-        my $creation_day;
-        if ($rpc->isa('QA::RPC::XMLRPC')) {
-            $creation_day = $creation_time->ymd('');
-        }
-        else {
-            $creation_day = $creation_time->ymd;
-        }
-        like($comment->{time}, qr/^\Q${creation_day}\ET\d\d:\d\d:\d\d/,
-             "comment time has the right format");
+
+    my $creation_day;
+    if ($rpc->isa('QA::RPC::XMLRPC')) {
+      $creation_day = $creation_time->ymd('');
     }
     else {
-        foreach my $field (qw(id text creator time)) {
-            ok(defined $comment->{$field}, "$field is defined");
-        }
+      $creation_day = $creation_time->ymd;
+    }
+    like(
+      $comment->{time},
+      qr/^\Q${creation_day}\ET\d\d:\d\d:\d\d/,
+      "comment time has the right format"
+    );
+  }
+  else {
+    foreach my $field (qw(id text creator time)) {
+      ok(defined $comment->{$field}, "$field is defined");
     }
+  }
 }
 
 ################
@@ -68,16 +72,19 @@ sub test_comments {
 ################
 
 sub post_bug_success {
-    my ($call, $t) = @_;
-    my @bugs = values %{ $call->result->{bugs} };
-    is(scalar @bugs, 1, "Got exactly one bug");
-    my @comments = map { @{ $_->{comments} } } @bugs;
-    test_comments(\@comments, @_);
+  my ($call, $t) = @_;
+  my @bugs = values %{$call->result->{bugs}};
+  is(scalar @bugs, 1, "Got exactly one bug");
+  my @comments = map { @{$_->{comments}} } @bugs;
+  test_comments(\@comments, @_);
 }
 
 foreach my $rpc (@clients) {
-    $rpc->bz_run_tests(tests => STANDARD_BUG_TESTS, method => 'Bug.comments',
-                       post_success => \&post_bug_success);
+  $rpc->bz_run_tests(
+    tests        => STANDARD_BUG_TESTS,
+    method       => 'Bug.comments',
+    post_success => \&post_bug_success
+  );
 }
 
 ####################
@@ -87,89 +94,110 @@ foreach my $rpc (@clients) {
 # First, create comments using add_comment.
 my @add_comment_tests;
 foreach my $key (keys %comments) {
-    $key =~ /^([a-z]+)_comment_(\w+)$/;
-    my $is_private = ($1 eq 'private' ? 1 : 0);
-    my $bug_alias = $2;
-    push(@add_comment_tests, { args => { id => $bug_alias, comment => $key,
-                                         private => $is_private },
-                               test => "Add comment: $key",
-                               user => PRIVATE_BUG_USER });
+  $key =~ /^([a-z]+)_comment_(\w+)$/;
+  my $is_private = ($1 eq 'private' ? 1 : 0);
+  my $bug_alias = $2;
+  push(
+    @add_comment_tests,
+    {
+      args => {id => $bug_alias, comment => $key, private => $is_private},
+      test => "Add comment: $key",
+      user => PRIVATE_BUG_USER
+    }
+  );
 }
 
 # Set the comment id for each comment that we add, so we can test getting
 # them back, later.
 sub post_add {
-    my ($call, $t) = @_;
-    my $key = $t->{args}->{comment};
-    $comments{$key} = $call->result->{id};
+  my ($call, $t) = @_;
+  my $key = $t->{args}->{comment};
+  $comments{$key} = $call->result->{id};
 }
 
 $creation_time = DateTime->now();
+
 # We only need to create these comments once, with one of the interfaces.
 $clients[0]->bz_run_tests(
-    tests => \@add_comment_tests, method => 'Bug.add_comment',
-    post_success => \&post_add);
+  tests        => \@add_comment_tests,
+  method       => 'Bug.add_comment',
+  post_success => \&post_add
+);
 
 # Now check access on each private and public comment
 
 my @comment_tests = (
-    # Logged-out user
-    { args => { comment_ids => [$comments{'public_comment_public_bug'}] },
-      test => 'Logged-out user can access public comment on public bug by id',
-    },
-    { args  => { comment_ids => [$comments{'private_comment_public_bug'}] },
-      test  => 'Logged-out user cannot access private comment on public bug',
-      error => 'is private',
-    },
-    { args  => { comment_ids => [$comments{'public_comment_private_bug'}] },
-      test  => 'Logged-out user cannot access comments by id on private bug',
-      error => 'You are not authorized to access',
-    },
-    { args  => { comment_ids => [$comments{'private_comment_private_bug'}] },
-      test  => 'Logged-out user cannot access private comment on private bug',
-      error => 'You are not authorized to access',
-    },
-
-    # Logged-in, unprivileged user.
-    { user => 'unprivileged',
-      args => { comment_ids => [$comments{'public_comment_public_bug'}] },
-      test => 'Logged-in user can see a public comment on a public bug by id',
-    },
-    { user  => 'unprivileged',
-      args  => { comment_ids => [$comments{'private_comment_public_bug'}] },
-      test  => 'Logged-in user cannot access private comment on public bug',
-      error => 'is private',
-    },
-    { user  => 'unprivileged',
-      args  => { comment_ids => [$comments{'public_comment_private_bug'}] },
-      test  => 'Logged-in user cannot access comments by id on private bug',
-      error => "You are not authorized to access",
-    },
-    { user  => 'unprivileged',
-      args  => { comment_ids => [$comments{'private_comment_private_bug'}] },
-      test  => 'Logged-in user cannot access private comment on private bug',
-      error => "You are not authorized to access",
-    },
-
-    # User who can see private bugs and private comments
-    { user => PRIVATE_BUG_USER,
-      args => { comment_ids => [$comments{'private_comment_public_bug'}] },
-      test => PRIVATE_BUG_USER . ' can see private comment on public bug',
-    },
-    { user  => PRIVATE_BUG_USER,
-      args  => { comment_ids => [$comments{'private_comment_private_bug'}] },
-      test  => PRIVATE_BUG_USER . ' can see private comment on private bug',
-    },
+
+  # Logged-out user
+  {
+    args => {comment_ids => [$comments{'public_comment_public_bug'}]},
+    test => 'Logged-out user can access public comment on public bug by id',
+  },
+  {
+    args  => {comment_ids => [$comments{'private_comment_public_bug'}]},
+    test  => 'Logged-out user cannot access private comment on public bug',
+    error => 'is private',
+  },
+  {
+    args  => {comment_ids => [$comments{'public_comment_private_bug'}]},
+    test  => 'Logged-out user cannot access comments by id on private bug',
+    error => 'You are not authorized to access',
+  },
+  {
+    args  => {comment_ids => [$comments{'private_comment_private_bug'}]},
+    test  => 'Logged-out user cannot access private comment on private bug',
+    error => 'You are not authorized to access',
+  },
+
+  # Logged-in, unprivileged user.
+  {
+    user => 'unprivileged',
+    args => {comment_ids => [$comments{'public_comment_public_bug'}]},
+    test => 'Logged-in user can see a public comment on a public bug by id',
+  },
+  {
+    user  => 'unprivileged',
+    args  => {comment_ids => [$comments{'private_comment_public_bug'}]},
+    test  => 'Logged-in user cannot access private comment on public bug',
+    error => 'is private',
+  },
+  {
+    user  => 'unprivileged',
+    args  => {comment_ids => [$comments{'public_comment_private_bug'}]},
+    test  => 'Logged-in user cannot access comments by id on private bug',
+    error => "You are not authorized to access",
+  },
+  {
+    user  => 'unprivileged',
+    args  => {comment_ids => [$comments{'private_comment_private_bug'}]},
+    test  => 'Logged-in user cannot access private comment on private bug',
+    error => "You are not authorized to access",
+  },
+
+  # User who can see private bugs and private comments
+  {
+    user => PRIVATE_BUG_USER,
+    args => {comment_ids => [$comments{'private_comment_public_bug'}]},
+    test => PRIVATE_BUG_USER . ' can see private comment on public bug',
+  },
+  {
+    user => PRIVATE_BUG_USER,
+    args => {comment_ids => [$comments{'private_comment_private_bug'}]},
+    test => PRIVATE_BUG_USER . ' can see private comment on private bug',
+  },
 );
 
 sub post_comments {
-    my ($call) = @_;
-    my @comments = values %{ $call->result->{comments} };
-    is(scalar @comments, 1, "Got exactly one comment");
-    test_comments(\@comments, @_);
+  my ($call) = @_;
+  my @comments = values %{$call->result->{comments}};
+  is(scalar @comments, 1, "Got exactly one comment");
+  test_comments(\@comments, @_);
 }
 
 foreach my $rpc (@clients) {
-    $rpc->bz_run_tests(tests => \@comment_tests, method => 'Bug.comments',
-                       post_success => \&post_comments);
+  $rpc->bz_run_tests(
+    tests        => \@comment_tests,
+    method       => 'Bug.comments',
+    post_success => \&post_comments
+  );
 }
index 8bab088af566e591a39045e748f879410f6f8091..34a03778ac487e11f4976c0ad77e1da0fe8c7a76 100644 (file)
@@ -28,212 +28,215 @@ my $bug_fields = create_bug_fields($config);
 # hash to contain all the possible $bug_fields values that
 # can be passed to createBug()
 my $fields = {
-    summary => {
-        undefined => {
-            faultstring => 'You must enter a summary for this bug',
-            value       => undef
-        },
-    },
-
-    product => {
-        undefined => { faultstring => 'You must select/enter a product.', value => undef },
-        invalid =>
-            { faultstring => 'does not exist', value => 'does-not-exist' },
-    },
-
-    component => {
-        undefined => {
-            faultstring => 'you must first choose a component',
-            value       => undef
-        },
-        invalid => {
-            faultstring => "There is no component named 'does-not-exist'",
-            value => 'does-not-exist'
-        },
-    },
-
-    version => {
-        undefined =>
-            { faultstring => 'You must select/enter a version.', value => undef },
-        invalid => {
-            faultstring => "There is no version named 'does-not-exist' in the",
-            value       => 'does-not-exist'
-        },
-    },
-    platform => {
-        undefined =>
-            { faultstring => 'You must select/enter a Hardware.',
-              value => '' },
-        invalid => {
-            faultstring => "There is no Hardware named 'does-not-exist'.",
-            value       => 'does-not-exist'
-        },
-    },
-
-    status => {
-        invalid => {
-            faultstring => "There is no status named 'does-not-exist'",
-            value       => 'does-not-exist'
-        },
-    },
-
-    severity => {
-        undefined =>
-            { faultstring => 'You must select/enter a Severity.',
-              value => '' },
-        invalid => {
-            faultstring => "There is no Severity named 'does-not-exist'.",
-            value       => 'does-not-exist'
-        },
-    },
-
-    priority => {
-        undefined =>
-            { faultstring => 'You must select/enter a Priority.',
-              value => '' },
-        invalid => {
-            faultstring => "There is no Priority named 'does-not-exist'.",
-            value       => 'does-not-exist'
-        },
-    },
-
-    op_sys => {
-        undefined => {
-            faultstring => 'You must select/enter a OS.',
-            value       => ''
-        },
-        invalid => {
-            faultstring => "There is no OS named 'does-not-exist'.",
-            value       => 'does-not-exist'
-        },
-    },
-
-    cc => {
-        invalid => {
-            faultstring => 'not a valid username',
-            value       => ['nonuserATbugillaDOTorg']
-        },
-    },
-
-    assigned_to => {
-        invalid => {
-            faultstring => "There is no user named 'does-not-exist'",
-            value       => 'does-not-exist'
-        },
-    },
-    qa_contact => {
-        invalid => {
-            faultstring => "There is no user named 'does-not-exist'",
-            value       => 'does-not-exist'
-        },
-    },
-    alias => {
-        long => {
-            faultstring => 'Bug aliases cannot be longer than 20 characters',
-            value       => 'MyyyyyyyyyyyyyyyyyyBugggggggggggggggggggggg'
-        },
-        existing => {
-            faultstring => 'already taken the alias',
-            value       => 'public_bug'
-        },
-        numeric => {
-            faultstring => 'aliases cannot be merely numbers',
-            value       => '12345'
-        },
-        commma_or_space_separated => {
-            faultstring => 'contains one or more commas or spaces',
-            value       => 'Bug 12345'
-        },
-
-    },
-    groups => {
-        non_existent => {
-            faultstring => 'either this group does not exist, or you are not allowed to restrict bugs to this group',
-            value => [random_string(20)],
-        },
-    },
-    comment_is_private => {
-        invalid => {
-             faultstring => 'you are not allowed to.+comments.+private',
-             value => 1,
-        }
-    },
+  summary => {
+    undefined =>
+      {faultstring => 'You must enter a summary for this bug', value => undef},
+  },
+
+  product => {
+    undefined =>
+      {faultstring => 'You must select/enter a product.', value => undef},
+    invalid => {faultstring => 'does not exist', value => 'does-not-exist'},
+  },
+
+  component => {
+    undefined =>
+      {faultstring => 'you must first choose a component', value => undef},
+    invalid => {
+      faultstring => "There is no component named 'does-not-exist'",
+      value       => 'does-not-exist'
+    },
+  },
+
+  version => {
+    undefined =>
+      {faultstring => 'You must select/enter a version.', value => undef},
+    invalid => {
+      faultstring => "There is no version named 'does-not-exist' in the",
+      value       => 'does-not-exist'
+    },
+  },
+  platform => {
+    undefined => {faultstring => 'You must select/enter a Hardware.', value => ''},
+    invalid   => {
+      faultstring => "There is no Hardware named 'does-not-exist'.",
+      value       => 'does-not-exist'
+    },
+  },
+
+  status => {
+    invalid => {
+      faultstring => "There is no status named 'does-not-exist'",
+      value       => 'does-not-exist'
+    },
+  },
+
+  severity => {
+    undefined => {faultstring => 'You must select/enter a Severity.', value => ''},
+    invalid   => {
+      faultstring => "There is no Severity named 'does-not-exist'.",
+      value       => 'does-not-exist'
+    },
+  },
+
+  priority => {
+    undefined => {faultstring => 'You must select/enter a Priority.', value => ''},
+    invalid   => {
+      faultstring => "There is no Priority named 'does-not-exist'.",
+      value       => 'does-not-exist'
+    },
+  },
+
+  op_sys => {
+    undefined => {faultstring => 'You must select/enter a OS.', value => ''},
+    invalid   => {
+      faultstring => "There is no OS named 'does-not-exist'.",
+      value       => 'does-not-exist'
+    },
+  },
+
+  cc => {
+    invalid =>
+      {faultstring => 'not a valid username', value => ['nonuserATbugillaDOTorg']},
+  },
+
+  assigned_to => {
+    invalid => {
+      faultstring => "There is no user named 'does-not-exist'",
+      value       => 'does-not-exist'
+    },
+  },
+  qa_contact => {
+    invalid => {
+      faultstring => "There is no user named 'does-not-exist'",
+      value       => 'does-not-exist'
+    },
+  },
+  alias => {
+    long => {
+      faultstring => 'Bug aliases cannot be longer than 20 characters',
+      value       => 'MyyyyyyyyyyyyyyyyyyBugggggggggggggggggggggg'
+    },
+    existing => {faultstring => 'already taken the alias', value => 'public_bug'},
+    numeric =>
+      {faultstring => 'aliases cannot be merely numbers', value => '12345'},
+    commma_or_space_separated => {
+      faultstring => 'contains one or more commas or spaces',
+      value       => 'Bug 12345'
+    },
+
+  },
+  groups => {
+    non_existent => {
+      faultstring =>
+        'either this group does not exist, or you are not allowed to restrict bugs to this group',
+      value => [random_string(20)],
+    },
+  },
+  comment_is_private => {
+    invalid =>
+      {faultstring => 'you are not allowed to.+comments.+private', value => 1,}
+  },
 };
 
-$jsonrpc_get->bz_call_fail('Bug.create', $bug_fields,
-    'must use HTTP POST', 'create fails over GET');
+$jsonrpc_get->bz_call_fail(
+  'Bug.create', $bug_fields,
+  'must use HTTP POST',
+  'create fails over GET'
+);
 
 my @tests = (
-    { args  => $bug_fields,
-      error => "You must log in",
-      test  => "Cannot file bugs as a logged-out user",
-    },
-    { user => PRIVATE_BUG_USER,
-      args => { %$bug_fields, product => 'QA-Selenium-TEST',
-                component => 'QA-Selenium-TEST',
-                target_milestone => 'QAMilestone',
-                version => 'QAVersion',
-                groups => ['QA-Selenium-TEST'],
-                # These are set here because we can't actually set them,
-                # and we need the values to be correct for post_success.
-                qa_contact => $config->{PRIVATE_BUG_USER . '_user_login'},
-                status => 'UNCONFIRMED' },
-      test => "Authorized user can file a bug against a group",
-    },
-    { user => PRIVATE_BUG_USER,
-      args => { %$bug_fields, comment_is_private => 1,
-                # These are here because PRIVATE_BUG_USER can't set them
-                # and we need their values to be correct for post_success.
-                assigned_to => $config->{'permanent_user'},
-                qa_contact => '',
-                status => 'UNCONFIRMED' },
-      test => "Insider can create a private description"
-    },
-    { user => 'editbugs',
-      args => $bug_fields,
-      test => "Creating a bug with standard values succeeds",
-    },
+  {
+    args  => $bug_fields,
+    error => "You must log in",
+    test  => "Cannot file bugs as a logged-out user",
+  },
+  {
+    user => PRIVATE_BUG_USER,
+    args => {
+      %$bug_fields,
+      product          => 'QA-Selenium-TEST',
+      component        => 'QA-Selenium-TEST',
+      target_milestone => 'QAMilestone',
+      version          => 'QAVersion',
+      groups           => ['QA-Selenium-TEST'],
+
+      # These are set here because we can't actually set them,
+      # and we need the values to be correct for post_success.
+      qa_contact => $config->{PRIVATE_BUG_USER . '_user_login'},
+      status     => 'UNCONFIRMED'
+    },
+    test => "Authorized user can file a bug against a group",
+  },
+  {
+    user => PRIVATE_BUG_USER,
+    args => {
+      %$bug_fields,
+      comment_is_private => 1,
+
+      # These are here because PRIVATE_BUG_USER can't set them
+      # and we need their values to be correct for post_success.
+      assigned_to => $config->{'permanent_user'},
+      qa_contact  => '',
+      status      => 'UNCONFIRMED'
+    },
+    test => "Insider can create a private description"
+  },
+  {
+    user => 'editbugs',
+    args => $bug_fields,
+    test => "Creating a bug with standard values succeeds",
+  },
 );
 
 # Convert the $fields tests into standard bz_run_tests format.
 foreach my $field (sort keys %$fields) {
-    my $test_values = $fields->{$field};
-    foreach my $test_name (sort keys %$test_values) {
-        my $input_fields = dclone($bug_fields);
-        my $check_value = $test_values->{$test_name}->{value};
-        my $error       = $test_values->{$test_name}->{faultstring};
-        $input_fields->{$field} = $check_value;
-        my $test = { user => 'editbugs', args => $input_fields,
-                     error => $error,
-                     test => "$field $test_name: fails as expected" };
-        push(@tests, $test);
-    }
+  my $test_values = $fields->{$field};
+  foreach my $test_name (sort keys %$test_values) {
+    my $input_fields = dclone($bug_fields);
+    my $check_value  = $test_values->{$test_name}->{value};
+    my $error        = $test_values->{$test_name}->{faultstring};
+    $input_fields->{$field} = $check_value;
+    my $test = {
+      user  => 'editbugs',
+      args  => $input_fields,
+      error => $error,
+      test  => "$field $test_name: fails as expected"
+    };
+    push(@tests, $test);
+  }
 }
 
 sub post_success {
-    my ($call, $t, $rpc) = @_;
+  my ($call, $t, $rpc) = @_;
 
-    my $id = $call->result->{id};
-    ok($id, $rpc->TYPE . ": Result has an id: $id");
+  my $id = $call->result->{id};
+  ok($id, $rpc->TYPE . ": Result has an id: $id");
 
-    my $get_call = $rpc->bz_call_success('Bug.get', { ids => [$id] });
-    my $bug = $get_call->result->{bugs}->[0];
+  my $get_call = $rpc->bz_call_success('Bug.get', {ids => [$id]});
+  my $bug = $get_call->result->{bugs}->[0];
 
-    my $expect = dclone $t->{args};
+  my $expect = dclone $t->{args};
 
-    my $comment_is_private = delete $expect->{comment_is_private};
-    $expect->{creator} = $rpc->bz_config->{$t->{user} . '_user_login'};
+  my $comment_is_private = delete $expect->{comment_is_private};
+  $expect->{creator} = $rpc->bz_config->{$t->{user} . '_user_login'};
 
-    my @fields = keys %$expect;
-    $rpc->bz_test_bug(\@fields, $bug, $expect, $t);
+  my @fields = keys %$expect;
+  $rpc->bz_test_bug(\@fields, $bug, $expect, $t);
 
-    my $comment_call = $rpc->bz_call_success('Bug.comments', { ids => [$id] });
-    my $comment = $comment_call->result->{bugs}->{$id}->{comments}->[0];
-    is($comment->{is_private} ? 1 : 0, $comment_is_private ? 1 : 0,
-       $rpc->TYPE . ": comment privacy is correct");
+  my $comment_call = $rpc->bz_call_success('Bug.comments', {ids => [$id]});
+  my $comment = $comment_call->result->{bugs}->{$id}->{comments}->[0];
+  is(
+    $comment->{is_private} ? 1 : 0,
+    $comment_is_private    ? 1 : 0,
+    $rpc->TYPE . ": comment privacy is correct"
+  );
 }
 
 foreach my $rpc ($jsonrpc, $xmlrpc) {
-    $rpc->bz_run_tests(tests => \@tests, method => 'Bug.create',
-                       post_success => \&post_success);
+  $rpc->bz_run_tests(
+    tests        => \@tests,
+    method       => 'Bug.create',
+    post_success => \&post_success
+  );
 }
index be565521feb5304bf1974a46a8f44c031753d5ca..110ed5741d0dd13f1eec2bcdbeffe36af781feff 100644 (file)
@@ -17,203 +17,218 @@ my ($config, @clients) = get_rpc_clients();
 plan tests => ($config->{test_extensions} ? 1338 : 1320);
 
 use constant INVALID_FIELD_NAME => 'invalid_field';
-use constant INVALID_FIELD_ID => -1;
-sub GLOBAL_GENERAL_FIELDS {
-    my @fields = qw(
-        attach_data.thedata
-        attachments.description
-        attachments.filename
-        attachments.isobsolete
-        attachments.ispatch
-        attachments.isprivate
-        attachments.mimetype
-        attachments.submitter
-
-        flagtypes.name
-        requestees.login_name
-        setters.login_name
-
-        alias
-        assigned_to
-        blocked
-        bug_file_loc
-        bug_group
-        bug_id
-        cc
-        cclist_accessible
-        classification
-        commenter
-        content
-        creation_ts
-        days_elapsed
-        delta_ts
-        dependson
-        everconfirmed
-        keywords
-        longdesc
-        longdescs.isprivate
-        owner_idle_time
-        product
-        qa_contact
-        reporter
-        reporter_accessible
-        see_also
-        short_desc
-        status_whiteboard
-
-        deadline
-        estimated_time
-        percentage_complete
-        remaining_time
-        work_time
-    );
-    push(@fields, 'votes') if QA::Util::get_config()->{test_extensions};
+use constant INVALID_FIELD_ID   => -1;
 
-    return @fields;
+sub GLOBAL_GENERAL_FIELDS {
+  my @fields = qw(
+    attach_data.thedata
+    attachments.description
+    attachments.filename
+    attachments.isobsolete
+    attachments.ispatch
+    attachments.isprivate
+    attachments.mimetype
+    attachments.submitter
+
+    flagtypes.name
+    requestees.login_name
+    setters.login_name
+
+    alias
+    assigned_to
+    blocked
+    bug_file_loc
+    bug_group
+    bug_id
+    cc
+    cclist_accessible
+    classification
+    commenter
+    content
+    creation_ts
+    days_elapsed
+    delta_ts
+    dependson
+    everconfirmed
+    keywords
+    longdesc
+    longdescs.isprivate
+    owner_idle_time
+    product
+    qa_contact
+    reporter
+    reporter_accessible
+    see_also
+    short_desc
+    status_whiteboard
+
+    deadline
+    estimated_time
+    percentage_complete
+    remaining_time
+    work_time
+  );
+  push(@fields, 'votes') if QA::Util::get_config()->{test_extensions};
+
+  return @fields;
 }
 
 use constant STANDARD_SELECT_FIELDS =>
-    qw(bug_severity bug_status op_sys priority rep_platform resolution);
+  qw(bug_severity bug_status op_sys priority rep_platform resolution);
 
-use constant ALL_SELECT_FIELDS => (STANDARD_SELECT_FIELDS,
-    qw(cf_qa_status cf_single_select));
+use constant ALL_SELECT_FIELDS =>
+  (STANDARD_SELECT_FIELDS, qw(cf_qa_status cf_single_select));
 use constant PRODUCT_FIELDS => qw(version target_milestone component);
-use constant ALL_FIELDS => (GLOBAL_GENERAL_FIELDS, ALL_SELECT_FIELDS,
-                            PRODUCT_FIELDS);
+use constant ALL_FIELDS =>
+  (GLOBAL_GENERAL_FIELDS, ALL_SELECT_FIELDS, PRODUCT_FIELDS);
 use constant MANDATORY_FIELDS => qw(short_desc product version component);
 
 use constant PUBLIC_PRODUCT  => 'Another Product';
 use constant PRIVATE_PRODUCT => 'QA-Selenium-TEST';
 
 sub get_field {
-    my ($fields, $field) = @_;
-    return first { $_->{name} eq $field } @$fields;
+  my ($fields, $field) = @_;
+  return first { $_->{name} eq $field } @$fields;
 }
 
 sub get_products_from_field {
-    my $field = shift;
-    my %products;
-    foreach my $value (@{ $field->{values} }) {
-        foreach my $vis_value (@{ $value->{visibility_values} }) {
-            $products{$vis_value} = 1;
-        }
+  my $field = shift;
+  my %products;
+  foreach my $value (@{$field->{values}}) {
+    foreach my $vis_value (@{$value->{visibility_values}}) {
+      $products{$vis_value} = 1;
     }
-    return \%products;
+  }
+  return \%products;
 }
 
 our %field_ids;
 foreach my $rpc (@clients) {
-    my $call = $rpc->bz_call_success('Bug.fields');
-    my $fields = $call->result->{fields};
-    foreach my $field (ALL_FIELDS) {
-        my $field_data = get_field($fields, $field);
-        ok($field_data, "$field is in the returned result")
-            or diag(Dumper($fields));
-        $field_ids{$field} = $field_data->{id};
-
-        if (grep($_ eq $field, MANDATORY_FIELDS)) {
-            ok($field_data->{is_mandatory}, "$field is mandatory");
-        }
-        else {
-            ok(!$field_data->{is_mandatory}, "$field is not mandatory");
-        }
+  my $call   = $rpc->bz_call_success('Bug.fields');
+  my $fields = $call->result->{fields};
+  foreach my $field (ALL_FIELDS) {
+    my $field_data = get_field($fields, $field);
+    ok($field_data, "$field is in the returned result") or diag(Dumper($fields));
+    $field_ids{$field} = $field_data->{id};
+
+    if (grep($_ eq $field, MANDATORY_FIELDS)) {
+      ok($field_data->{is_mandatory}, "$field is mandatory");
     }
-
-    foreach my $field (ALL_SELECT_FIELDS, PRODUCT_FIELDS) {
-        my $field_data = get_field($fields, $field);
-        ok(defined $field_data->{visibility_values},
-           "$field has visibility_values defined");
-        my $field_vis_undefs = grep { !defined $_ }
-                                    @{ $field_data->{visibility_values} };
-        is($field_vis_undefs, 0, "$field.visibility_values has no undefs")
-          or diag(Dumper($field_data->{visibility_values}));
-
-        ok(defined $field_data->{values},
-           "$field has 'values' defined");
-        my $num_values = scalar @{ $field_data->{values} };
-        ok($num_values, "$field has $num_values values");
-        # The first bug status is a fake one and has no name, so we choose the 2nd item.
-        my $first_value = $field_data->{values}->[1];
-        ok(defined $first_value->{name}, 'The first value has a name')
-            or diag(Dumper($field_data->{values}));
-        # The sortkey for milestones can be negative.
-        cmp_ok($first_value->{sortkey}, '=~', qr/^-?\d+$/,
-               "The first value has a numeric sortkey");
-
-        ok(defined $first_value->{visibility_values},
-           "$field has visibilty_values defined on its first value")
-            or diag(Dumper($field_data->{values}));
-        my @value_visibility_values = map { @{ $_->{visibility_values} } }
-                                      @{ $field_data->{values} };
-        my $undefs = grep { !defined $_ } @value_visibility_values;
-        is($undefs, 0,
-           "$field.values.visibility_values has no undefs");
+    else {
+      ok(!$field_data->{is_mandatory}, "$field is not mandatory");
     }
+  }
 
-    foreach my $field (PRODUCT_FIELDS) {
-        my $field_data = get_field($fields, $field);
-        is($field_data->{value_field}, 'product',
-           "The value_field for $field is 'product'");
-        my $products = get_products_from_field($field_data);
-        ok($products->{+PUBLIC_PRODUCT},
-           "$field values are returned for the public product");
-        ok(!$products->{+PRIVATE_PRODUCT},
-           "No $field values are returned for the private product");
-    }
+  foreach my $field (ALL_SELECT_FIELDS, PRODUCT_FIELDS) {
+    my $field_data = get_field($fields, $field);
+    ok(
+      defined $field_data->{visibility_values},
+      "$field has visibility_values defined"
+    );
+    my $field_vis_undefs = grep { !defined $_ } @{$field_data->{visibility_values}};
+    is($field_vis_undefs, 0, "$field.visibility_values has no undefs")
+      or diag(Dumper($field_data->{visibility_values}));
+
+    ok(defined $field_data->{values}, "$field has 'values' defined");
+    my $num_values = scalar @{$field_data->{values}};
+    ok($num_values, "$field has $num_values values");
+
+    # The first bug status is a fake one and has no name, so we choose the 2nd item.
+    my $first_value = $field_data->{values}->[1];
+    ok(defined $first_value->{name}, 'The first value has a name')
+      or diag(Dumper($field_data->{values}));
+
+    # The sortkey for milestones can be negative.
+    cmp_ok($first_value->{sortkey},
+      '=~', qr/^-?\d+$/, "The first value has a numeric sortkey");
+
+    ok(defined $first_value->{visibility_values},
+      "$field has visibilty_values defined on its first value")
+      or diag(Dumper($field_data->{values}));
+    my @value_visibility_values
+      = map { @{$_->{visibility_values}} } @{$field_data->{values}};
+    my $undefs = grep { !defined $_ } @value_visibility_values;
+    is($undefs, 0, "$field.values.visibility_values has no undefs");
+  }
+
+  foreach my $field (PRODUCT_FIELDS) {
+    my $field_data = get_field($fields, $field);
+    is($field_data->{value_field},
+      'product', "The value_field for $field is 'product'");
+    my $products = get_products_from_field($field_data);
+    ok($products->{+PUBLIC_PRODUCT},
+      "$field values are returned for the public product");
+    ok(!$products->{+PRIVATE_PRODUCT},
+      "No $field values are returned for the private product");
+  }
 }
 
 my @all_tests = (
-    { args => { ids   => [values %field_ids],
-                names => [ALL_FIELDS] },
-                test => 'Getting all fields by name and id simultaneously',
-                count => scalar ALL_FIELDS
-    },
-    { args  => { names => [INVALID_FIELD_NAME] },
-      error => "There is no field named",
-      test  => 'Invalid field name'
-    },
-    { args  => { ids => [INVALID_FIELD_ID] },
-      error => 'must be numeric',
-      test  => 'Invalid field id'
-    },
-    { user  => 'QA_Selenium_TEST',
-      args  => { names => [PRODUCT_FIELDS] },
-      test  => 'Getting product-specific fields as a privileged user',
-      count => scalar PRODUCT_FIELDS,
-      product_private_values => 1
-    },
+  {
+    args  => {ids => [values %field_ids], names => [ALL_FIELDS]},
+    test  => 'Getting all fields by name and id simultaneously',
+    count => scalar ALL_FIELDS
+  },
+  {
+    args  => {names => [INVALID_FIELD_NAME]},
+    error => "There is no field named",
+    test  => 'Invalid field name'
+  },
+  {
+    args  => {ids => [INVALID_FIELD_ID]},
+    error => 'must be numeric',
+    test  => 'Invalid field id'
+  },
+  {
+    user  => 'QA_Selenium_TEST',
+    args  => {names => [PRODUCT_FIELDS]},
+    test  => 'Getting product-specific fields as a privileged user',
+    count => scalar PRODUCT_FIELDS,
+    product_private_values => 1
+  },
 );
 
 foreach my $field (ALL_FIELDS) {
-    push(@all_tests,
-         { args => { names => [$field] },
-           test => "Logged-out users can get the $field field by name" });
-    push(@all_tests,
-         { args => { ids => [$field_ids{$field}] },
-           test => "Logged-out users can get the $field by id" });
+  push(
+    @all_tests,
+    {
+      args => {names => [$field]},
+      test => "Logged-out users can get the $field field by name"
+    }
+  );
+  push(
+    @all_tests,
+    {
+      args => {ids => [$field_ids{$field}]},
+      test => "Logged-out users can get the $field by id"
+    }
+  );
 }
 
 sub post_success {
-    my ($call, $t) = @_;
-    my $fields = $call->result->{fields};
-    my $count = $t->{count};
-    $count = 1 if !defined $count;
-    is(scalar @$fields, $count, "Exactly $count field(s) returned");
-
-    if ($t->{product_private_values}) {
-        foreach my $field (@$fields) {
-            my $name = $field->{name};
-            my $field_data = get_field($fields, $name);
-            my $products = get_products_from_field($field_data);
-            ok($products->{+PUBLIC_PRODUCT},
-               "$name values are returned for the public product");
-            ok($products->{+PRIVATE_PRODUCT},
-               "$name values are returned for the private product");
-        }
+  my ($call, $t) = @_;
+  my $fields = $call->result->{fields};
+  my $count  = $t->{count};
+  $count = 1 if !defined $count;
+  is(scalar @$fields, $count, "Exactly $count field(s) returned");
+
+  if ($t->{product_private_values}) {
+    foreach my $field (@$fields) {
+      my $name       = $field->{name};
+      my $field_data = get_field($fields, $name);
+      my $products   = get_products_from_field($field_data);
+      ok($products->{+PUBLIC_PRODUCT},
+        "$name values are returned for the public product");
+      ok($products->{+PRIVATE_PRODUCT},
+        "$name values are returned for the private product");
     }
+  }
 }
 
 foreach my $rpc (@clients) {
-    $rpc->bz_run_tests(tests => \@all_tests,  method => 'Bug.fields',
-                       post_success => \&post_success);
+  $rpc->bz_run_tests(
+    tests        => \@all_tests,
+    method       => 'Bug.fields',
+    post_success => \&post_success
+  );
 }
index cad5c38935503748b1f66c40c6554c8dea74faf6..c87346c0828cca9163f992eb7c05ddfdcc6eb7b8 100644 (file)
@@ -23,124 +23,147 @@ my $xmlrpc = $clients[0];
 our $creation_time = DateTime->now();
 our ($public_bug, $private_bug) = $xmlrpc->bz_create_test_bugs('private');
 my $private_id = $private_bug->{id};
-my $public_id = $public_bug->{id};
+my $public_id  = $public_bug->{id};
 
-my $base_url = $config->{browser_url} . "/"
-              . $config->{bugzilla_installation} . '/';
+my $base_url
+  = $config->{browser_url} . "/" . $config->{bugzilla_installation} . '/';
 
 # Set a few fields on the private bug, including setting up
 # a dependency relationship.
 $xmlrpc->bz_log_in(PRIVATE_BUG_USER);
-$xmlrpc->bz_call_success('Bug.update', {
-    ids => [$private_id],
-    blocks => { set => [$public_id] },
-    dupe_of => $public_id,
+$xmlrpc->bz_call_success(
+  'Bug.update',
+  {
+    ids                   => [$private_id],
+    blocks                => {set => [$public_id]},
+    dupe_of               => $public_id,
     is_creator_accessible => 0,
-    keywords => { set => ['test-keyword-1', 'test-keyword-2'] },
-    see_also => { add => ["${base_url}show_bug.cgi?id=$public_id",
-                          "https://bugzilla-dev.allizom.org/show_bug.cgi?id=123456"] },
-    cf_qa_status => ['in progress', 'verified'],
+    keywords              => {set => ['test-keyword-1', 'test-keyword-2']},
+    see_also              => {
+      add => [
+        "${base_url}show_bug.cgi?id=$public_id",
+        "https://bugzilla-dev.allizom.org/show_bug.cgi?id=123456"
+      ]
+    },
+    cf_qa_status     => ['in progress', 'verified'],
     cf_single_select => 'two',
-}, 'Update the private bug');
+  },
+  'Update the private bug'
+);
 $xmlrpc->bz_call_success('User.logout');
 
-$private_bug->{blocks} = [$public_id];
-$private_bug->{dupe_of} = $public_id;
-$private_bug->{status} = 'RESOLVED';
-$private_bug->{is_open} = 0;
-$private_bug->{resolution} = 'DUPLICATE';
+$private_bug->{blocks}                = [$public_id];
+$private_bug->{dupe_of}               = $public_id;
+$private_bug->{status}                = 'RESOLVED';
+$private_bug->{is_open}               = 0;
+$private_bug->{resolution}            = 'DUPLICATE';
 $private_bug->{is_creator_accessible} = 0;
-$private_bug->{is_cc_accessible} = 1;
-$private_bug->{keywords} = ['test-keyword-1', 'test-keyword-2'];
-$private_bug->{see_also} = ["${base_url}show_bug.cgi?id=$public_id",
-                            "https://bugzilla-dev.allizom.org/show_bug.cgi?id=123456"];
+$private_bug->{is_cc_accessible}      = 1;
+$private_bug->{keywords}              = ['test-keyword-1', 'test-keyword-2'];
+$private_bug->{see_also}              = [
+  "${base_url}show_bug.cgi?id=$public_id",
+  "https://bugzilla-dev.allizom.org/show_bug.cgi?id=123456"
+];
 $private_bug->{cf_qa_status} = ['in progress', 'verified'];
 $private_bug->{cf_single_select} = 'two';
 
-$public_bug->{depends_on} = [$private_id];
-$public_bug->{dupe_of} = undef;
-$public_bug->{resolution} = '';
-$public_bug->{is_open} = 1;
+$public_bug->{depends_on}            = [$private_id];
+$public_bug->{dupe_of}               = undef;
+$public_bug->{resolution}            = '';
+$public_bug->{is_open}               = 1;
 $public_bug->{is_creator_accessible} = 1;
-$public_bug->{is_cc_accessible} = 1;
-$public_bug->{keywords} = [];
+$public_bug->{is_cc_accessible}      = 1;
+$public_bug->{keywords}              = [];
+
 # Local Bugzilla bugs are automatically updated.
-$public_bug->{see_also} = ["${base_url}show_bug.cgi?id=$private_id"];
-$public_bug->{cf_qa_status} = [];
+$public_bug->{see_also}         = ["${base_url}show_bug.cgi?id=$private_id"];
+$public_bug->{cf_qa_status}     = [];
 $public_bug->{cf_single_select} = '---';
 
 # Fill in the timetracking fields on the public bug.
 $xmlrpc->bz_log_in('admin');
-$xmlrpc->bz_call_success('Bug.update', {
-    ids => [$public_id],
-    deadline => '2038-01-01',
+$xmlrpc->bz_call_success(
+  'Bug.update',
+  {
+    ids            => [$public_id],
+    deadline       => '2038-01-01',
     estimated_time => '10.0',
     remaining_time => '5.0',
-});
+  }
+);
 $xmlrpc->bz_call_success('User.logout');
 
 # Populate other fields.
-$public_bug->{classification} = 'Unclassified';
+$public_bug->{classification}  = 'Unclassified';
 $private_bug->{classification} = 'Unclassified';
-$private_bug->{groups} = ['QA-Selenium-TEST'];
-$public_bug->{groups} = [];
+$private_bug->{groups}         = ['QA-Selenium-TEST'];
+$public_bug->{groups}          = [];
 
 # The user filing $private_bug doesn't have permission to set the status
 # or qa_contact, so they differ from normal $public_bug values.
 $private_bug->{qa_contact} = $config->{PRIVATE_BUG_USER . '_user_login'};
 
 sub post_success {
-    my ($call, $t, $rpc) = @_;
-
-    is(scalar @{ $call->result->{bugs} }, 1, "Got exactly one bug");
-    my $bug = $call->result->{bugs}->[0];
-
-    if ($t->{user} && $t->{user} eq 'admin') {
-        ok(exists $bug->{estimated_time} && exists $bug->{remaining_time},
-           'Admin correctly gets time-tracking fields');
-        is($bug->{deadline}, '2038-01-01', 'deadline is correct');
-        cmp_ok($bug->{estimated_time}, '==', '10.0',
-               'estimated_time is correct');
-        cmp_ok($bug->{remaining_time}, '==', '5.0',
-               'remaining_time is correct');
-    }
-    else {
-        ok(!exists $bug->{estimated_time} && !exists $bug->{remaining_time},
-           'Time-tracking fields are not returned to non-privileged users');
-    }
-
-    if ($t->{user}) {
-        ok($bug->{update_token}, 'Update token returned for logged-in user');
-    }
-    else {
-        ok(!exists $bug->{update_token},
-           'Update token not returned for logged-out users');
-    }
-
-    my $expect = $bug->{id} == $private_bug->{id} ? $private_bug : $public_bug;
-
-    my @fields = sort keys %$expect;
-    push(@fields, 'creation_time', 'last_change_time');
-
-    $rpc->bz_test_bug(\@fields, $bug, $expect, $t, $creation_time);
+  my ($call, $t, $rpc) = @_;
+
+  is(scalar @{$call->result->{bugs}}, 1, "Got exactly one bug");
+  my $bug = $call->result->{bugs}->[0];
+
+  if ($t->{user} && $t->{user} eq 'admin') {
+    ok(exists $bug->{estimated_time} && exists $bug->{remaining_time},
+      'Admin correctly gets time-tracking fields');
+    is($bug->{deadline}, '2038-01-01', 'deadline is correct');
+    cmp_ok($bug->{estimated_time}, '==', '10.0', 'estimated_time is correct');
+    cmp_ok($bug->{remaining_time}, '==', '5.0',  'remaining_time is correct');
+  }
+  else {
+    ok(
+      !exists $bug->{estimated_time} && !exists $bug->{remaining_time},
+      'Time-tracking fields are not returned to non-privileged users'
+    );
+  }
+
+  if ($t->{user}) {
+    ok($bug->{update_token}, 'Update token returned for logged-in user');
+  }
+  else {
+    ok(!exists $bug->{update_token},
+      'Update token not returned for logged-out users');
+  }
+
+  my $expect = $bug->{id} == $private_bug->{id} ? $private_bug : $public_bug;
+
+  my @fields = sort keys %$expect;
+  push(@fields, 'creation_time', 'last_change_time');
+
+  $rpc->bz_test_bug(\@fields, $bug, $expect, $t, $creation_time);
 }
 
 my @tests = (
-    @{ bug_tests($public_id, $private_id) },
-    { args => { ids => [$public_id],
-                include_fields => ['id', 'summary', 'groups'] },
-      test => 'include_fields',
+  @{bug_tests($public_id, $private_id)},
+  {
+    args => {ids => [$public_id], include_fields => ['id', 'summary', 'groups']},
+    test => 'include_fields',
+  },
+  {
+    args =>
+      {ids => [$public_id], exclude_fields => ['assigned_to', 'cf_qa_status']},
+    test => 'exclude_fields'
+  },
+  {
+    args => {
+      ids            => [$public_id],
+      include_fields => ['id', 'summary', 'groups'],
+      exclude_fields => ['summary']
     },
-    { args => { ids => [$public_id],
-                exclude_fields => ['assigned_to', 'cf_qa_status'] },
-      test => 'exclude_fields' },
-    { args => { ids => [$public_id],
-                include_fields => ['id', 'summary', 'groups'],
-                exclude_fields => ['summary'] },
-      test => 'exclude_fields overrides include_fields' },
+    test => 'exclude_fields overrides include_fields'
+  },
 );
 
 foreach my $rpc (@clients) {
-    $rpc->bz_run_tests(tests => \@tests,  method => 'Bug.get',
-                       post_success => \&post_success);
+  $rpc->bz_run_tests(
+    tests        => \@tests,
+    method       => 'Bug.get',
+    post_success => \&post_success
+  );
 }
index d66249b2c575c32120e7ea4c1d27a213993e5ee2..9fbe00fbde4ba471fcd2f2f145c073fc34f70709 100644 (file)
@@ -23,124 +23,144 @@ my $xmlrpc = $clients[0];
 our $creation_time = DateTime->now();
 our ($public_bug, $private_bug) = $xmlrpc->bz_create_test_bugs('private');
 my $private_id = $private_bug->{id};
-my $public_id = $public_bug->{id};
+my $public_id  = $public_bug->{id};
 
-my $base_url = $config->{browser_url} . "/"
-              . $config->{bugzilla_installation} . '/';
+my $base_url
+  = $config->{browser_url} . "/" . $config->{bugzilla_installation} . '/';
 
 # Set a few fields on the private bug, including setting up
 # a dependency relationship.
 $xmlrpc->bz_log_in(PRIVATE_BUG_USER);
-$xmlrpc->bz_call_success('Bug.update', {
-    ids => [$private_id],
-    blocks => { set => [$public_id] },
-    dupe_of => $public_id,
+$xmlrpc->bz_call_success(
+  'Bug.update',
+  {
+    ids                   => [$private_id],
+    blocks                => {set => [$public_id]},
+    dupe_of               => $public_id,
     is_creator_accessible => 0,
-    keywords => { set => ['test-keyword-1', 'test-keyword-2'] },
-    see_also => { add => ["${base_url}show_bug.cgi?id=$public_id"] },
-    cf_qa_status => ['in progress', 'verified'],
-    cf_single_select => 'two',
-}, 'Update the private bug');
+    keywords              => {set => ['test-keyword-1', 'test-keyword-2']},
+    see_also              => {add => ["${base_url}show_bug.cgi?id=$public_id"]},
+    cf_qa_status          => ['in progress', 'verified'],
+    cf_single_select      => 'two',
+  },
+  'Update the private bug'
+);
 $xmlrpc->bz_call_success('User.logout');
 
-$private_bug->{blocks} = [$public_id];
-$private_bug->{dupe_of} = $public_id;
-$private_bug->{status} = 'RESOLVED';
-$private_bug->{is_open} = 0;
-$private_bug->{resolution} = 'DUPLICATE';
+$private_bug->{blocks}                = [$public_id];
+$private_bug->{dupe_of}               = $public_id;
+$private_bug->{status}                = 'RESOLVED';
+$private_bug->{is_open}               = 0;
+$private_bug->{resolution}            = 'DUPLICATE';
 $private_bug->{is_creator_accessible} = 0;
-$private_bug->{is_cc_accessible} = 1;
-$private_bug->{keywords} = ['test-keyword-1', 'test-keyword-2'];
-$private_bug->{see_also} = ["${base_url}show_bug.cgi?id=$public_id"];
-$private_bug->{cf_qa_status} = ['in progress', 'verified'];
+$private_bug->{is_cc_accessible}      = 1;
+$private_bug->{keywords}              = ['test-keyword-1', 'test-keyword-2'];
+$private_bug->{see_also}         = ["${base_url}show_bug.cgi?id=$public_id"];
+$private_bug->{cf_qa_status}     = ['in progress', 'verified'];
 $private_bug->{cf_single_select} = 'two';
 
-$public_bug->{depends_on} = [$private_id];
-$public_bug->{dupe_of} = undef;
-$public_bug->{resolution} = '';
-$public_bug->{is_open} = 1;
+$public_bug->{depends_on}            = [$private_id];
+$public_bug->{dupe_of}               = undef;
+$public_bug->{resolution}            = '';
+$public_bug->{is_open}               = 1;
 $public_bug->{is_creator_accessible} = 1;
-$public_bug->{is_cc_accessible} = 1;
-$public_bug->{keywords} = [];
-$public_bug->{see_also} = ["${base_url}show_bug.cgi?id=$private_id"];
-$public_bug->{cf_qa_status} = [];
+$public_bug->{is_cc_accessible}      = 1;
+$public_bug->{keywords}              = [];
+$public_bug->{see_also}         = ["${base_url}show_bug.cgi?id=$private_id"];
+$public_bug->{cf_qa_status}     = [];
 $public_bug->{cf_single_select} = '---';
 
 # Fill in the timetracking fields on the public bug.
 $xmlrpc->bz_log_in('admin');
-$xmlrpc->bz_call_success('Bug.update', {
-    ids => [$public_id],
-    deadline => '2038-01-01',
+$xmlrpc->bz_call_success(
+  'Bug.update',
+  {
+    ids            => [$public_id],
+    deadline       => '2038-01-01',
     estimated_time => '10.0',
     remaining_time => '5.0',
-});
+  }
+);
 $xmlrpc->bz_call_success('User.logout');
 
 # Populate other fields.
-$public_bug->{classification} = 'Unclassified';
+$public_bug->{classification}  = 'Unclassified';
 $private_bug->{classification} = 'Unclassified';
-$private_bug->{groups} = ['QA-Selenium-TEST'];
-$public_bug->{groups} = [];
+$private_bug->{groups}         = ['QA-Selenium-TEST'];
+$public_bug->{groups}          = [];
 
 # The user filing $private_bug doesn't have permission to set the status
 # or qa_contact, so they differ from normal $public_bug values.
 $private_bug->{qa_contact} = $config->{PRIVATE_BUG_USER . '_user_login'};
 
 sub post_success {
-    my ($call, $t, $rpc) = @_;
-
-    is(scalar @{ $call->result->{bugs} }, 1, "Got exactly one bug");
-    my $bug = $call->result->{bugs}->[0];
-
-    if ($t->{user} && $t->{user} eq 'admin') {
-        ok(exists $bug->{estimated_time} && exists $bug->{remaining_time}
-           && exists $bug->{deadline},
-           'Admin correctly gets time-tracking fields');
-
-        is($bug->{deadline}, '2038-01-01', 'deadline is correct');
-        cmp_ok($bug->{estimated_time}, '==', '10.0',
-               'estimated_time is correct');
-        cmp_ok($bug->{remaining_time}, '==', '5.0',
-               'remaining_time is correct');
-    }
-    else {
-        ok(!exists $bug->{estimated_time} && !exists $bug->{remaining_time}
-           && !exists $bug->{deadline},
-           'Time-tracking fields are not returned to non-privileged users');
-    }
-
-    if ($t->{user}) {
-        ok($bug->{update_token}, 'Update token returned for logged-in user');
-    }
-    else {
-        ok(!exists $bug->{update_token},
-           'Update token not returned for logged-out users');
-    }
-
-    my $expect = $bug->{id} == $private_bug->{id} ? $private_bug : $public_bug;
-
-    my @fields = sort keys %$expect;
-    push(@fields, 'creation_time', 'last_change_time');
-
-    $rpc->bz_test_bug(\@fields, $bug, $expect, $t, $creation_time);
+  my ($call, $t, $rpc) = @_;
+
+  is(scalar @{$call->result->{bugs}}, 1, "Got exactly one bug");
+  my $bug = $call->result->{bugs}->[0];
+
+  if ($t->{user} && $t->{user} eq 'admin') {
+    ok(
+      exists $bug->{estimated_time}
+        && exists $bug->{remaining_time}
+        && exists $bug->{deadline},
+      'Admin correctly gets time-tracking fields'
+    );
+
+    is($bug->{deadline}, '2038-01-01', 'deadline is correct');
+    cmp_ok($bug->{estimated_time}, '==', '10.0', 'estimated_time is correct');
+    cmp_ok($bug->{remaining_time}, '==', '5.0',  'remaining_time is correct');
+  }
+  else {
+    ok(
+      !exists $bug->{estimated_time}
+        && !exists $bug->{remaining_time}
+        && !exists $bug->{deadline},
+      'Time-tracking fields are not returned to non-privileged users'
+    );
+  }
+
+  if ($t->{user}) {
+    ok($bug->{update_token}, 'Update token returned for logged-in user');
+  }
+  else {
+    ok(!exists $bug->{update_token},
+      'Update token not returned for logged-out users');
+  }
+
+  my $expect = $bug->{id} == $private_bug->{id} ? $private_bug : $public_bug;
+
+  my @fields = sort keys %$expect;
+  push(@fields, 'creation_time', 'last_change_time');
+
+  $rpc->bz_test_bug(\@fields, $bug, $expect, $t, $creation_time);
 }
 
 my @tests = (
-    @{ bug_tests($public_id, $private_id) },
-    { args => { ids => [$public_id],
-                include_fields => ['id', 'summary', 'groups'] },
-      test => 'include_fields',
+  @{bug_tests($public_id, $private_id)},
+  {
+    args => {ids => [$public_id], include_fields => ['id', 'summary', 'groups']},
+    test => 'include_fields',
+  },
+  {
+    args =>
+      {ids => [$public_id], exclude_fields => ['assigned_to', 'cf_qa_status']},
+    test => 'exclude_fields'
+  },
+  {
+    args => {
+      ids            => [$public_id],
+      include_fields => ['id', 'summary', 'groups'],
+      exclude_fields => ['summary']
     },
-    { args => { ids => [$public_id],
-                exclude_fields => ['assigned_to', 'cf_qa_status'] },
-      test => 'exclude_fields' },
-    { args => { ids => [$public_id],
-                include_fields => ['id', 'summary', 'groups'],
-                exclude_fields => ['summary'] },
-      test => 'exclude_fields overrides include_fields' },
+    test => 'exclude_fields overrides include_fields'
+  },
 );
 
 foreach my $rpc (@clients) {
-    $rpc->bz_run_tests(tests => \@tests,  method => 'Bug.get',
-                       post_success => \&post_success);
+  $rpc->bz_run_tests(
+    tests        => \@tests,
+    method       => 'Bug.get',
+    post_success => \&post_success
+  );
 }
index 7451fe450476db7d3c50d257788e262bcbed31fd..7accacfd6f8aeba69debc2d72945503bcc2a38b2 100644 (file)
@@ -18,12 +18,15 @@ use Test::More tests => 114;
 my ($config, @clients) = get_rpc_clients();
 
 sub post_success {
-    my ($call, $t) = @_;
-    is(scalar @{ $call->result->{bugs} }, 1, "Got exactly one bug");
-    isa_ok($call->result->{bugs}->[0]->{history}, 'ARRAY', "Bug's history");
+  my ($call, $t) = @_;
+  is(scalar @{$call->result->{bugs}}, 1, "Got exactly one bug");
+  isa_ok($call->result->{bugs}->[0]->{history}, 'ARRAY', "Bug's history");
 }
 
 foreach my $rpc (@clients) {
-    $rpc->bz_run_tests(tests => STANDARD_BUG_TESTS,
-                       method => 'Bug.history', post_success => \&post_success);
+  $rpc->bz_run_tests(
+    tests        => STANDARD_BUG_TESTS,
+    method       => 'Bug.history',
+    post_success => \&post_success
+  );
 }
index 29f444708cedcd7e8b7ea5e2f4107cd6c3e1aaea..303868517ece018e4fe2c4eda57b01ca7e86e0af 100644 (file)
@@ -19,82 +19,92 @@ my ($config, @clients) = get_rpc_clients();
 use constant INVALID_PRODUCT_ID => -1;
 use constant INVALID_FIELD_NAME => 'invalid_field';
 use constant GLOBAL_FIELDS =>
-    qw(bug_severity bug_status op_sys priority rep_platform resolution
-       cf_qa_status cf_single_select);
+  qw(bug_severity bug_status op_sys priority rep_platform resolution
+  cf_qa_status cf_single_select);
 use constant PRODUCT_FIELDS => qw(version target_milestone component);
 
 
-my $products = $clients[0]->bz_get_products();
-my $public_product = $products->{'Another Product'};
+my $products        = $clients[0]->bz_get_products();
+my $public_product  = $products->{'Another Product'};
 my $private_product = $products->{'QA-Selenium-TEST'};
 
 my @all_tests;
 
 for my $field (GLOBAL_FIELDS) {
-    push(@all_tests,
-         { args => { field => $field },
-           test => "Logged-out user can get $field values" });
+  push(@all_tests,
+    {args => {field => $field}, test => "Logged-out user can get $field values"});
 }
 
 for my $field (PRODUCT_FIELDS) {
-    my @tests = (
-        { args  => { field => $field },
-          error => "argument was not set",
-          test  => "$field can't be accessed without a value for 'product'",
-        },
-        { args  => { product_id => INVALID_PRODUCT_ID, field => $field },
-          error => "does not exist",
-          test  => "$field cannot be accessed with an invalid product id",
-        },
-
-        { args  => { product_id => $private_product, field => $field },
-          error => "you don't have access",
-          test => "Logged-out user cannot access $field in private product"
-        },
-        { args  => { product_id => $public_product, field => $field },
-          test  => "Logged-out user can access $field in a public product",
-        },
-
-        { user  => 'unprivileged',
-          args  => { product_id => $private_product, field => $field },
-          error => "you don't have access",
-          test  => "Unprivileged user cannot access $field in private product",
-        },
-        { user => 'unprivileged',
-          args => { product_id => $public_product, field => $field },
-          test => "Logged-in user can access $field in public product",
-        },
-
-        { user => 'QA_Selenium_TEST',
-          args => { product_id => $private_product, field  => $field },
-          test => "Privileged user can access $field in a private product",
-        },
-    );
-
-    push(@all_tests, @tests);
-}
+  my @tests = (
+    {
+      args  => {field => $field},
+      error => "argument was not set",
+      test  => "$field can't be accessed without a value for 'product'",
+    },
+    {
+      args  => {product_id => INVALID_PRODUCT_ID, field => $field},
+      error => "does not exist",
+      test  => "$field cannot be accessed with an invalid product id",
+    },
 
-my @extra_tests = (
-    { args  => { product_id => $private_product, },
-      error => "requires a field argument",
-      test  =>  "Passing product_id without 'field' throws an error",
+    {
+      args  => {product_id => $private_product, field => $field},
+      error => "you don't have access",
+      test  => "Logged-out user cannot access $field in private product"
+    },
+    {
+      args => {product_id => $public_product, field => $field},
+      test => "Logged-out user can access $field in a public product",
+    },
+
+    {
+      user  => 'unprivileged',
+      args  => {product_id => $private_product, field => $field},
+      error => "you don't have access",
+      test  => "Unprivileged user cannot access $field in private product",
     },
-    { args  => { field => INVALID_FIELD_NAME },
-      error => "Can't use " . INVALID_FIELD_NAME . " as a field name",
-      test  => 'Invalid field name'
+    {
+      user => 'unprivileged',
+      args => {product_id => $public_product, field => $field},
+      test => "Logged-in user can access $field in public product",
     },
+
+    {
+      user => 'QA_Selenium_TEST',
+      args => {product_id => $private_product, field => $field},
+      test => "Privileged user can access $field in a private product",
+    },
+  );
+
+  push(@all_tests, @tests);
+}
+
+my @extra_tests = (
+  {
+    args  => {product_id => $private_product,},
+    error => "requires a field argument",
+    test  => "Passing product_id without 'field' throws an error",
+  },
+  {
+    args  => {field => INVALID_FIELD_NAME},
+    error => "Can't use " . INVALID_FIELD_NAME . " as a field name",
+    test  => 'Invalid field name'
+  },
 );
 
 push(@all_tests, @extra_tests);
 
 sub post_success {
-    my ($call) = @_;
+  my ($call) = @_;
 
-    cmp_ok(scalar @{ $call->result->{'values'} }, '>', 0,
-           'Got one or more values');
+  cmp_ok(scalar @{$call->result->{'values'}}, '>', 0, 'Got one or more values');
 }
 
 foreach my $rpc (@clients) {
-    $rpc->bz_run_tests(tests => \@all_tests,  method => 'Bug.legal_values',
-                       post_success => \&post_success);
+  $rpc->bz_run_tests(
+    tests        => \@all_tests,
+    method       => 'Bug.legal_values',
+    post_success => \&post_success
+  );
 }
index 6a4933c5a380084d76bce31bbafc92e19100d363..7b6d7dadedf14d3fe975db1a171d430a9afd363e 100644 (file)
@@ -25,161 +25,207 @@ my ($public_bug, $private_bug) = $clients[0]->bz_create_test_bugs('private');
 
 my @tests;
 foreach my $field (keys %$public_bug) {
-    next if ($field eq 'cc' or $field eq 'description');
-    my $test = { args => { $field => $public_bug->{$field} },
-                 test => "Search by $field" };
-    if ( grep($_ eq $field, qw(alias whiteboard summary)) ) {
-        $test->{exactly} = 1; $test->{bugs} = 1;
-    }
-    push(@tests, $test);
+  next if ($field eq 'cc' or $field eq 'description');
+  my $test
+    = {args => {$field => $public_bug->{$field}}, test => "Search by $field"};
+  if (grep($_ eq $field, qw(alias whiteboard summary))) {
+    $test->{exactly} = 1;
+    $test->{bugs}    = 1;
+  }
+  push(@tests, $test);
 }
 
 
-push(@tests, (
-    { args  => { offset => 1 },
+push(
+  @tests,
+  (
+    {
+      args  => {offset => 1},
       test  => "Offset without limit fails",
       error => 'requires a limit argument',
     },
 
-    { args => { alias => $private_bug->{alias} },
+    {
+      args => {alias => $private_bug->{alias}},
       test => 'Logged-out cannot find a private_bug by alias',
       bugs => 0,
     },
 
-    { args => { creation_time => '19700101T00:00:00' },
+    {
+      args => {creation_time => '19700101T00:00:00'},
       test => 'Get all bugs by creation time',
     },
-    { args => { creation_time => '20380101T00:00:00' },
+    {
+      args => {creation_time => '20380101T00:00:00'},
       test => 'Get no bugs, by creation time',
       bugs => 0,
     },
-    { args => { last_change_time => '19700101T00:00:00' },
+    {
+      args => {last_change_time => '19700101T00:00:00'},
       test => 'Get all bugs by last_change_time',
     },
-    { args => { last_change_time => '20380101T00:00:00' },
+    {
+      args => {last_change_time => '20380101T00:00:00'},
       test => 'Get no bugs by last_change_time',
       bugs => 0,
     },
 
-    { args => { reporter => $config->{editbugs_user_login} },
+    {
+      args => {reporter => $config->{editbugs_user_login}},
       test => 'Search by reporter',
     },
-    { args => { resolution => '---' },
-      test => 'Search for empty resolution',
-    },
-    { args => { resolution => 'NO_SUCH_RESOLUTION' },
+    {args => {resolution => '---'}, test => 'Search for empty resolution',},
+    {
+      args => {resolution => 'NO_SUCH_RESOLUTION'},
       test => 'Search for invalid resolution',
       bugs => 0,
     },
-    { args => { summary => substr($public_bug->{summary}, 0, 50) },
-      test => 'Search by partial summary',
-      bugs => 1, exactly => 1
+    {
+      args    => {summary => substr($public_bug->{summary}, 0, 50)},
+      test    => 'Search by partial summary',
+      bugs    => 1,
+      exactly => 1
     },
-    { args => { summary => random_string() . ' ' . random_string() },
+    {
+      args => {summary => random_string() . ' ' . random_string()},
       test => 'Summary search that returns no results',
       bugs => 0,
     },
-    { args => { summary => [split(/\s/, $public_bug->{summary})] },
+    {
+      args => {summary => [split(/\s/, $public_bug->{summary})]},
       test => 'Summary search using multiple terms',
     },
 
-    { args => { whiteboard => substr($public_bug->{whiteboard}, 0, 50) },
-      test => 'Search by partial whiteboard',
-      bugs => 1, exactly => 1,
+    {
+      args    => {whiteboard => substr($public_bug->{whiteboard}, 0, 50)},
+      test    => 'Search by partial whiteboard',
+      bugs    => 1,
+      exactly => 1,
     },
-    { args => { whiteboard => random_string(100) },
+    {
+      args => {whiteboard => random_string(100)},
       test => 'Whiteboard search that returns no results',
       bugs => 0,
     },
-    { args => { whiteboard => [split(/\s/, $public_bug->{whiteboard})] },
-      test => 'Whiteboard search using multiple terms',
-      bugs => 1, exactly => 1,
+    {
+      args    => {whiteboard => [split(/\s/, $public_bug->{whiteboard})]},
+      test    => 'Whiteboard search using multiple terms',
+      bugs    => 1,
+      exactly => 1,
     },
 
-    { args => { product => $public_bug->{product},
-                component => $public_bug->{component},
-                last_change_time => '19700101T00:00:00' },
+    {
+      args => {
+        product          => $public_bug->{product},
+        component        => $public_bug->{component},
+        last_change_time => '19700101T00:00:00'
+      },
       test => 'Search by multiple arguments',
     },
 
     # Logged-in user who can see private bugs
-    { user => PRIVATE_BUG_USER,
-      args => { alias => [$public_bug->{alias}, $private_bug->{alias}] },
-      test => 'Search using two aliases (including one private)',
-      bugs => 2, exactly => 1,
-    },
-    { user => PRIVATE_BUG_USER,
-      args => { product => [$public_bug->{product}, $private_bug->{product}],
-                limit => 1 },
-      test => 'Limit 1',
-      bugs => 1, exactly => 1,
-    },
-    { user => PRIVATE_BUG_USER,
-      args => { product => [$public_bug->{product}, $private_bug->{product}],
-                limit => 1, offset => 1 },
-      test => 'Limit 1 Offset 1',
-      bugs => 1, exactly => 1,
+    {
+      user    => PRIVATE_BUG_USER,
+      args    => {alias => [$public_bug->{alias}, $private_bug->{alias}]},
+      test    => 'Search using two aliases (including one private)',
+      bugs    => 2,
+      exactly => 1,
+    },
+    {
+      user => PRIVATE_BUG_USER,
+      args =>
+        {product => [$public_bug->{product}, $private_bug->{product}], limit => 1},
+      test    => 'Limit 1',
+      bugs    => 1,
+      exactly => 1,
+    },
+    {
+      user => PRIVATE_BUG_USER,
+      args => {
+        product => [$public_bug->{product}, $private_bug->{product}],
+        limit   => 1,
+        offset  => 1
+      },
+      test    => 'Limit 1 Offset 1',
+      bugs    => 1,
+      exactly => 1,
     },
 
     # include_fields ane exclude_fields
-    { args => { id => $public_bug->{id},
-                include_fields => ['id', 'alias', 'summary', 'groups'] },
+    {
+      args => {
+        id             => $public_bug->{id},
+        include_fields => ['id', 'alias', 'summary', 'groups']
+      },
       test => 'include_fields',
     },
-    { args => { id => $public_bug->{id},
-                exclude_fields => ['assigned_to', 'cf_qa_status'] },
-      test => 'exclude_fields' },
-    { args => { id => $public_bug->{id},
-                include_fields => ['id', 'alias', 'summary', 'groups'],
-                exclude_fields => ['summary'] },
-      test => 'exclude_fields overrides include_fields' },
-));
-
-push(@tests,
-    { args => { votes => 1 },
-      test => 'Search by votes',
-      bugs => -1, # We don't care how many it returns, for now.
-    }) if $config->{test_extensions};
+    {
+      args =>
+        {id => $public_bug->{id}, exclude_fields => ['assigned_to', 'cf_qa_status']},
+      test => 'exclude_fields'
+    },
+    {
+      args => {
+        id             => $public_bug->{id},
+        include_fields => ['id', 'alias', 'summary', 'groups'],
+        exclude_fields => ['summary']
+      },
+      test => 'exclude_fields overrides include_fields'
+    },
+  )
+);
+
+push(
+  @tests,
+  {
+    args => {votes => 1},
+    test => 'Search by votes',
+    bugs => -1,                  # We don't care how many it returns, for now.
+  }
+) if $config->{test_extensions};
 
 sub post_success {
-    my ($call, $t) = @_;
-    my $bugs = $call->result->{bugs};
-    my $expected_count = $t->{bugs};
-    $expected_count = 1 if !defined $expected_count;
-    if ($expected_count) {
-        my $operator = $t->{exactly} ? '==' : '>=';
-        cmp_ok(scalar @$bugs, $operator, $expected_count,
-               'The right number of bugs are returned');
-        unless ($t->{user} and $t->{user} eq PRIVATE_BUG_USER) {
-            ok(!grep($_->{alias} && $_->{alias} eq $private_bug->{alias}, @$bugs),
-               'Result does not contain the private bug');
-        }
+  my ($call, $t) = @_;
+  my $bugs           = $call->result->{bugs};
+  my $expected_count = $t->{bugs};
+  $expected_count = 1 if !defined $expected_count;
+  if ($expected_count) {
+    my $operator = $t->{exactly} ? '==' : '>=';
+    cmp_ok(scalar @$bugs,
+      $operator, $expected_count, 'The right number of bugs are returned');
+    unless ($t->{user} and $t->{user} eq PRIVATE_BUG_USER) {
+      ok(!grep($_->{alias} && $_->{alias} eq $private_bug->{alias}, @$bugs),
+        'Result does not contain the private bug');
+    }
 
-        my @include = @{ $t->{args}->{include_fields} || [] };
-        my @exclude = @{ $t->{args}->{exclude_fields} || [] };
-        if (@include or @exclude) {
-            my @check_fields = uniq (keys %$public_bug, @include);
-            foreach my $field (sort @check_fields) {
-                next if $field eq 'description';
-                if ((@include and !grep { $_ eq $field } @include )
-                    or (@exclude and grep { $_ eq $field } @exclude))
-                {
-                    ok(!exists $bugs->[0]->{$field}, "$field is not included")
-                      or diag Dumper($bugs);
-                }
-                else {
-                    ok(exists $bugs->[0]->{$field}, "$field is included");
-                }
-            }
+    my @include = @{$t->{args}->{include_fields} || []};
+    my @exclude = @{$t->{args}->{exclude_fields} || []};
+    if (@include or @exclude) {
+      my @check_fields = uniq(keys %$public_bug, @include);
+      foreach my $field (sort @check_fields) {
+        next if $field eq 'description';
+        if ( (@include and !grep { $_ eq $field } @include)
+          or (@exclude and grep { $_ eq $field } @exclude))
+        {
+          ok(!exists $bugs->[0]->{$field}, "$field is not included")
+            or diag Dumper($bugs);
         }
-
-    }
-    else {
-        is(scalar @$bugs, 0, 'No bugs returned');
+        else {
+          ok(exists $bugs->[0]->{$field}, "$field is included");
+        }
+      }
     }
+
+  }
+  else {
+    is(scalar @$bugs, 0, 'No bugs returned');
+  }
 }
 
 foreach my $rpc (@clients) {
-    $rpc->bz_run_tests(tests => \@tests,
-                       method => 'Bug.search', post_success => \&post_success);
+  $rpc->bz_run_tests(
+    tests        => \@tests,
+    method       => 'Bug.search',
+    post_success => \&post_success
+  );
 }
index 95af809e058503c939ec6b0e5590c941f1997d44..2d82170cbe2c86b643527dd946c6821b518c5df2 100644 (file)
@@ -23,585 +23,763 @@ use constant NONEXISTANT_BUG => 12_000_000;
 # We have to generate different values for each RPC client, so we
 # have a function to generate the tests for each client.
 sub get_tests {
-    my ($config, $rpc) = @_;
-
-    # update doesn't support logged-out users.
-    my @tests = grep { $_->{user} } @{ STANDARD_BUG_TESTS() };
-
-    my ($public_bug, $second_bug) = $rpc->bz_create_test_bugs();
-    my ($public_id, $second_id) = ($public_bug->{id}, $second_bug->{id});
-
-    my $comment_call = $rpc->bz_call_success(
-        'Bug.comments', { ids => [$public_id, $second_id] });
-    $public_bug->{comment} =
-        $comment_call->result->{bugs}->{$public_id}->{comments}->[0];
-    $second_bug->{comment} =
-        $comment_call->result->{bugs}->{$second_id}->{comments}->[0];
-
-    push(@tests, (
-        { args  => { ids => [$public_id] },
-          error => 'You must log in',
-          test  => 'Logged-out users cannot call update' },
-
-        # FIXME: We need a permissions test for canedit, but it's so uncommonly
-        #        used that it's not a high priority.
-    ));
-
-    my %valid = valid_values($config, $public_bug, $second_bug);
-    my $valid_value_tests = valid_values_to_tests(\%valid, $public_bug);
-    push(@tests, @$valid_value_tests);
-
-    my %invalid = invalid_values($public_bug, $second_bug);
-    my $invalid_value_tests = invalid_values_to_tests(\%invalid, $public_bug);
-    push(@tests, @$invalid_value_tests);
-
-    return \@tests;
+  my ($config, $rpc) = @_;
+
+  # update doesn't support logged-out users.
+  my @tests = grep { $_->{user} } @{STANDARD_BUG_TESTS()};
+
+  my ($public_bug, $second_bug) = $rpc->bz_create_test_bugs();
+  my ($public_id, $second_id) = ($public_bug->{id}, $second_bug->{id});
+
+  my $comment_call
+    = $rpc->bz_call_success('Bug.comments', {ids => [$public_id, $second_id]});
+  $public_bug->{comment}
+    = $comment_call->result->{bugs}->{$public_id}->{comments}->[0];
+  $second_bug->{comment}
+    = $comment_call->result->{bugs}->{$second_id}->{comments}->[0];
+
+  push(
+    @tests,
+    (
+      {
+        args  => {ids => [$public_id]},
+        error => 'You must log in',
+        test  => 'Logged-out users cannot call update'
+      },
+
+      # FIXME: We need a permissions test for canedit, but it's so uncommonly
+      #        used that it's not a high priority.
+    )
+  );
+
+  my %valid = valid_values($config, $public_bug, $second_bug);
+  my $valid_value_tests = valid_values_to_tests(\%valid, $public_bug);
+  push(@tests, @$valid_value_tests);
+
+  my %invalid = invalid_values($public_bug, $second_bug);
+  my $invalid_value_tests = invalid_values_to_tests(\%invalid, $public_bug);
+  push(@tests, @$invalid_value_tests);
+
+  return \@tests;
 }
 
 sub valid_values {
-    my ($config, $public_bug, $second_bug) = @_;
-
-    my $admin = $config->{'admin_user_login'};
-    my $second_id = $second_bug->{id};
-    my $comment_id = $public_bug->{comment}->{id};
-    my $bug_uri = $config->{browser_url} . '/'
-                  . $config->{bugzilla_installation} . '/show_bug.cgi?id=';
-
-    my %values = (
-        alias => [
-            { value => random_string(20) },
-        ],
-        assigned_to => [
-            { value => $config->{'unprivileged_user_login'} }
-        ],
-        blocks => [
-            { value => { set => [$second_id] },
-              added => $second_id,
-              test  => 'set to second bug' },
-            { value => { remove => [$second_id] },
-              added => '', removed => $second_id,
-              test  =>  'remove second bug' },
-            { value => { add => [$second_id] },
-              added => $second_id, removed => '',
-              test  => 'add second bug' },
-            { value => { set => [] },
-              added => '', removed => $second_id,
-              test  => 'set to nothing' },
-        ],
-
-        cc => [
-            { value => { add => [$admin] },
-              added => $admin, removed => '',
-              test  => 'add admin' },
-            { value => { remove => [$admin] },
-              added => '', removed => $admin,
-              test  =>  'remove admin' },
-            { value => { remove => [$admin] },
-              test  => "removing user who isn't on the list works",
-              no_changes => 1 },
-        ],
-
-        is_cc_accessible => [
-            { value => 0, test => 'set to 0' },
-            { value => 1, test => 'set to 1' },
-        ],
-
-        comment => [
-            { value => { body => random_string(100) }, test => 'public' },
-            { value => { body => random_string(100), is_private => 1 },
-              user  => PRIVATE_BUG_USER, test => 'private' },
-        ],
-
-        comment_is_private => [
-            { value => { $comment_id => 1 },
-              user  => PRIVATE_BUG_USER, test => 'make description private' },
-            { value => { $comment_id => 0 },
-              user  => PRIVATE_BUG_USER, test => 'make description public' },
-        ],
-
-        component => [
-            { value => 'c2' }
-        ],
-
-        deadline => [
-            { value => '2037-01-01' },
-            { value => '', removed => '2037-01-01', test => 'remove' },
-        ],
-
-        dupe_of => [
-            { value => $second_id },
-        ],
-
-        estimated_time => [
-            { value => '10.0' },
-            { value => '0.0', removed => '10.0', test => 'set to zero' },
-        ],
-
-        groups => [
-            { value => { add => ['Master'] },
-              user => 'admin', added => 'Master', test => 'add Master' },
-            { value => { remove => ['Master'] },
-              user => 'admin', added => '', removed => 'Master',
-              test => 'remove Master' },
-        ],
-
-        keywords => [
-            { value => { add => ['test-keyword-1'] },
-              test => 'add one', added => 'test-keyword-1' },
-            { value => { set => ['test-keyword-1', 'test-keyword-2'] },
-              test  => 'set two', added => 'test-keyword-2' },
-            { value => { remove => ['test-keyword-1'] },
-              removed => 'test-keyword-1', added => '',
-              test  => 'remove one' },
-            { value => { set => [] },
-              removed => 'test-keyword-2', added => '',
-              test  => 'set to empty' },
-            { value => { remove => ['test-keyword-2'] },
-              test  => 'removing removed keyword does nothing',
-              no_changes => 1 },
-        ],
-
-        op_sys => [
-            { value => 'All' },
-        ],
-
-        platform => [
-            { value => 'All' },
-        ],
-
-        priority => [
-            { value => 'Normal' },
-        ],
-
-        product => [
-            { value => 'C2 Forever',
-              extra => {
-                component => 'Helium', version => 'unspecified',
-                target_milestone => '---',
-              },
-              test  => 'move to C2 Forever'
-            },
-            # This also tests that the extra fields transfer over properly
-            # when they have identical names in both products.
-            { value => $public_bug->{product},
-              extra => { component => $public_bug->{component} },
-              test  => 'move back to original product' },
-        ],
-
-        qa_contact => [
-            { value => $admin },
-            { value => '', test => 'set blank', removed => $admin },
-            # Reset to the original so that reset_qa_contact can also be tested.
-            { value => $public_bug->{qa_contact} },
-        ],
-
-        remaining_time => [
-            { value => '1000.50' },
-            { value => 0 },
-        ],
-
-        reset_assigned_to => [
-            { value => 1, field => 'assigned_to',
-              added => $config->{permanent_user} },
-        ],
-
-        reset_qa_contact => [
-            { value => 1, field => 'qa_contact', added => '' },
-        ],
-
-        resolution => [
-            { value => 'FIXED', extra => { status => 'RESOLVED' },
-              test => 'to RESOLVED FIXED' },
-            { value => 'INVALID', test => 'just resolution' },
-        ],
-
-        see_also => [
-            { value => { add => [$bug_uri . $second_id] },
-              added => $bug_uri . $second_id, removed => '',
-              test => 'add local bug URI' },
-            { value => { remove => [$bug_uri . $second_id] },
-              removed => $bug_uri . $second_id, added => '',
-              test => 'remove local bug URI' },
-            { value => { remove => ['https://bugzilla-dev.allizom.org/show_bug.cgi?id=1'] },
-              no_changes => 1,
-              test => 'removing non-existent URI works' },
-            { value => { add => [''] },
-              no_changes => 1,
-              test  => 'adding an empty string to see_also does nothing' },
-            { value => { add => [undef] },
-              no_changes => 1,
-              test  => 'adding a null to see_also does nothing' },
-        ],
-
-        status => [
-            # At this point, due to previous tests, the status is RESOLVED,
-            # so changing to CONFIRMED is our only real option if we want to
-            # test a simple open status.
-            { value => 'CONFIRMED' },
-        ],
-
-        severity => [
-            { value => 'critical' },
-        ],
-
-        summary => [
-            { value => random_string(100) },
-        ],
-
-        target_milestone => [
-            { value => 'AnotherMS2' },
-        ],
-
-        url => [
-            { value => 'http://' . random_string(20) . '/' },
-        ],
-
-        version => [
-            { value => 'Another2' },
-        ],
-
-        whiteboard => [
-            { value => random_string(1000) },
-        ],
-
-        work_time => [
-            # FIXME: work_time really needs to start showing up in the changes hash.
-            { value => '1.2', no_changes => 1 },
-            { value => '-1.2', test => 'negative value', no_changes => 1 },
-        ],
-    );
-
-    $values{depends_on} = $values{blocks};
-    $values{is_creator_accessible} = $values{is_cc_accessible};
-
-    return %values;
-};
+  my ($config, $public_bug, $second_bug) = @_;
+
+  my $admin      = $config->{'admin_user_login'};
+  my $second_id  = $second_bug->{id};
+  my $comment_id = $public_bug->{comment}->{id};
+  my $bug_uri
+    = $config->{browser_url} . '/'
+    . $config->{bugzilla_installation}
+    . '/show_bug.cgi?id=';
+
+  my %values = (
+    alias       => [{value => random_string(20)},],
+    assigned_to => [{value => $config->{'unprivileged_user_login'}}],
+    blocks      => [
+      {
+        value => {set => [$second_id]},
+        added => $second_id,
+        test  => 'set to second bug'
+      },
+      {
+        value   => {remove => [$second_id]},
+        added   => '',
+        removed => $second_id,
+        test    => 'remove second bug'
+      },
+      {
+        value   => {add => [$second_id]},
+        added   => $second_id,
+        removed => '',
+        test    => 'add second bug'
+      },
+      {
+        value   => {set => []},
+        added   => '',
+        removed => $second_id,
+        test    => 'set to nothing'
+      },
+    ],
+
+    cc => [
+      {
+        value   => {add => [$admin]},
+        added   => $admin,
+        removed => '',
+        test    => 'add admin'
+      },
+      {
+        value   => {remove => [$admin]},
+        added   => '',
+        removed => $admin,
+        test    => 'remove admin'
+      },
+      {
+        value      => {remove => [$admin]},
+        test       => "removing user who isn't on the list works",
+        no_changes => 1
+      },
+    ],
+
+    is_cc_accessible =>
+      [{value => 0, test => 'set to 0'}, {value => 1, test => 'set to 1'},],
+
+    comment => [
+      {value => {body => random_string(100)}, test => 'public'},
+      {
+        value => {body => random_string(100), is_private => 1},
+        user  => PRIVATE_BUG_USER,
+        test  => 'private'
+      },
+    ],
+
+    comment_is_private => [
+      {
+        value => {$comment_id => 1},
+        user  => PRIVATE_BUG_USER,
+        test  => 'make description private'
+      },
+      {
+        value => {$comment_id => 0},
+        user  => PRIVATE_BUG_USER,
+        test  => 'make description public'
+      },
+    ],
+
+    component => [{value => 'c2'}],
+
+    deadline => [
+      {value => '2037-01-01'},
+      {value => '', removed => '2037-01-01', test => 'remove'},
+    ],
+
+    dupe_of => [{value => $second_id},],
+
+    estimated_time => [
+      {value => '10.0'},
+      {value => '0.0', removed => '10.0', test => 'set to zero'},
+    ],
+
+    groups => [
+      {
+        value => {add => ['Master']},
+        user  => 'admin',
+        added => 'Master',
+        test  => 'add Master'
+      },
+      {
+        value   => {remove => ['Master']},
+        user    => 'admin',
+        added   => '',
+        removed => 'Master',
+        test    => 'remove Master'
+      },
+    ],
+
+    keywords => [
+      {
+        value => {add => ['test-keyword-1']},
+        test  => 'add one',
+        added => 'test-keyword-1'
+      },
+      {
+        value => {set => ['test-keyword-1', 'test-keyword-2']},
+        test  => 'set two',
+        added => 'test-keyword-2'
+      },
+      {
+        value   => {remove => ['test-keyword-1']},
+        removed => 'test-keyword-1',
+        added   => '',
+        test    => 'remove one'
+      },
+      {
+        value   => {set => []},
+        removed => 'test-keyword-2',
+        added   => '',
+        test    => 'set to empty'
+      },
+      {
+        value      => {remove => ['test-keyword-2']},
+        test       => 'removing removed keyword does nothing',
+        no_changes => 1
+      },
+    ],
+
+    op_sys => [{value => 'All'},],
+
+    platform => [{value => 'All'},],
+
+    priority => [{value => 'Normal'},],
+
+    product => [
+      {
+        value => 'C2 Forever',
+        extra =>
+          {component => 'Helium', version => 'unspecified', target_milestone => '---',},
+        test => 'move to C2 Forever'
+      },
+
+      # This also tests that the extra fields transfer over properly
+      # when they have identical names in both products.
+      {
+        value => $public_bug->{product},
+        extra => {component => $public_bug->{component}},
+        test  => 'move back to original product'
+      },
+    ],
+
+    qa_contact => [
+      {value => $admin}, {value => '', test => 'set blank', removed => $admin},
+
+      # Reset to the original so that reset_qa_contact can also be tested.
+      {value => $public_bug->{qa_contact}},
+    ],
+
+    remaining_time => [{value => '1000.50'}, {value => 0},],
+
+    reset_assigned_to =>
+      [{value => 1, field => 'assigned_to', added => $config->{permanent_user}},],
+
+    reset_qa_contact => [{value => 1, field => 'qa_contact', added => ''},],
+
+    resolution => [
+      {
+        value => 'FIXED',
+        extra => {status => 'RESOLVED'},
+        test  => 'to RESOLVED FIXED'
+      },
+      {value => 'INVALID', test => 'just resolution'},
+    ],
+
+    see_also => [
+      {
+        value   => {add => [$bug_uri . $second_id]},
+        added   => $bug_uri . $second_id,
+        removed => '',
+        test    => 'add local bug URI'
+      },
+      {
+        value   => {remove => [$bug_uri . $second_id]},
+        removed => $bug_uri . $second_id,
+        added   => '',
+        test    => 'remove local bug URI'
+      },
+      {
+        value => {remove => ['https://bugzilla-dev.allizom.org/show_bug.cgi?id=1']},
+        no_changes => 1,
+        test       => 'removing non-existent URI works'
+      },
+      {
+        value      => {add => ['']},
+        no_changes => 1,
+        test       => 'adding an empty string to see_also does nothing'
+      },
+      {
+        value      => {add => [undef]},
+        no_changes => 1,
+        test       => 'adding a null to see_also does nothing'
+      },
+    ],
+
+    status => [
+
+      # At this point, due to previous tests, the status is RESOLVED,
+      # so changing to CONFIRMED is our only real option if we want to
+      # test a simple open status.
+      {value => 'CONFIRMED'},
+    ],
+
+    severity => [{value => 'critical'},],
+
+    summary => [{value => random_string(100)},],
+
+    target_milestone => [{value => 'AnotherMS2'},],
+
+    url => [{value => 'http://' . random_string(20) . '/'},],
+
+    version => [{value => 'Another2'},],
+
+    whiteboard => [{value => random_string(1000)},],
+
+    work_time => [
+
+      # FIXME: work_time really needs to start showing up in the changes hash.
+      {value => '1.2', no_changes => 1},
+      {value => '-1.2', test => 'negative value', no_changes => 1},
+    ],
+  );
+
+  $values{depends_on}            = $values{blocks};
+  $values{is_creator_accessible} = $values{is_cc_accessible};
+
+  return %values;
+}
 
 sub valid_values_to_tests {
-    my ($valid_values, $public_bug) = @_;
-
-    my @tests;
-    foreach my $field (sort keys %$valid_values) {
-        my @tests_valid = @{ $valid_values->{$field} };
-        foreach my $item (@tests_valid) {
-            my $desc = $item->{test} || 'valid value';
-            my %args = (
-                ids => [$public_bug->{id}],
-                $field => $item->{value},
-                %{ $item->{extra} || {} },
-            );
-            my %test = ( user => 'editbugs', args => \%args, field => $field,
-                         test => "$field: $desc" );
-            foreach my $item_field (qw(no_changes added removed field user)) {
-                next if !exists $item->{$item_field};
-                $test{$item_field} = $item->{$item_field};
-            }
-            push(@tests, \%test);
-        }
+  my ($valid_values, $public_bug) = @_;
+
+  my @tests;
+  foreach my $field (sort keys %$valid_values) {
+    my @tests_valid = @{$valid_values->{$field}};
+    foreach my $item (@tests_valid) {
+      my $desc = $item->{test} || 'valid value';
+      my %args = (
+        ids    => [$public_bug->{id}],
+        $field => $item->{value},
+        %{$item->{extra} || {}},
+      );
+      my %test = (
+        user  => 'editbugs',
+        args  => \%args,
+        field => $field,
+        test  => "$field: $desc"
+      );
+      foreach my $item_field (qw(no_changes added removed field user)) {
+        next if !exists $item->{$item_field};
+        $test{$item_field} = $item->{$item_field};
+      }
+      push(@tests, \%test);
     }
+  }
 
-    return \@tests;
+  return \@tests;
 }
 
 sub invalid_values {
-    my ($public_bug, $second_bug) = @_;
-
-    my $public_id = $public_bug->{id};
-    my $second_id = $second_bug->{id};
-
-    my $comment_id = $public_bug->{comment}->{id};
-    my $second_comment_id = $second_bug->{comment}->{id};
-
-    my %values = (
-        alias => [
-            { value => random_string(41),
-              error => 'aliases cannot be longer than',
-              test  => 'alias cannot be too long' },
-            { value => $second_bug->{alias},
-              error => 'has already taken the alias',
-              test  => 'duplicate alias fails' },
-            { value => 123456,
-              error => 'at least one letter',
-              test  => 'numeric alias fails' },
-            { value => random_string(20), ids => [$public_id, $second_id],
-              error => 'aliases when modifying multiple',
-              test  => 'setting alias on multiple bugs fails' },
-        ],
-
-        assigned_to => [
-            { value => random_string(20),
-              error => 'There is no user named',
-              test  => 'changing assigned_to to invalid user fails' },
-            # FIXME: Also check strict_isolation at some point in the future, perhaps.
-        ],
-
-        blocks => [
-            { value => { add => [NONEXISTANT_BUG] },
-              error => 'does not exist',
-              test  => 'Non-existent bug number fails in deps' },
-            { value => { add => [$public_id] },
-              error => 'block itself or depend on itself',
-              test  => "can't add this bug itself in a dep field" },
-            # FIXME: Could use strict_isolation checks at some point.
-            # FIXME: Could use a dependency_loop_multi test.
-        ],
-
-        cc => [
-            { value => { add => [random_string(20)] },
-              error => 'There is no user named',
-              test  => 'adding invalid user to cc fails' },
-            { value => { remove => [random_string(20)] },
-              error => 'There is no user named',
-              test  => 'removing invalid user from cc fails' },
-        ],
-
-        comment => [
-            { value => { body => random_string(100_000) },
-              error => 'cannot be longer',
-              test  => 'comment too long' },
-            { value => { body => random_string(100), is_private => 1 },
-              error => 'comments or attachments as private',
-              test  => 'normal user cannot add private comments' },
-        ],
-
-        comment_is_private => [
-            { value => { $comment_id => 1 },
-              error => 'comments or attachments as private',
-              test  => 'normal user cannot make a comment private' },
-            { value => { $second_comment_id => 1 },
-              error => 'You tried to modify the privacy of comment',
-              user  => PRIVATE_BUG_USER,
-              test  => 'cannot change privacy on a comment on another bug' },
-        ],
-
-        component => [
-            { value => '',
-              error => 'you must first choose a component',
-              test  => 'empty component fails' },
-            { value => random_string(20),
-              error => 'There is no component named',
-              test  => 'invalid component fails' },
-        ],
-
-        deadline => [
-            { value => random_string(20),
-              error => 'is not a legal date',
-              test  => 'Non-date fails in deadline' },
-            { value => '2037',
-              error => 'is not a legal date',
-              test  => 'year alone fails in deadline' },
-        ],
-
-        dupe_of => [
-            { value => undef,
-              error => 'dup_id was not defined',
-              test  => 'undefined dupe_of fails' },
-            { value => NONEXISTANT_BUG,
-              error => 'does not exist',
-              test  => 'Cannot dup to a nonexistant bug' },
-            { value => $public_id,
-              error => 'as a duplicate of itself',
-              test  => 'Cannot dup bug to itself' },
-        ],
-
-        estimated_time => [
-            { value => -1,
-              error => 'less than the minimum allowable value',
-              test  => 'negative estimated_time fails' },
-            { value => 100_000_000,
-              error => 'more than the maximum allowable value',
-              test  => 'too-large estimated_time fails' },
-            { value => random_string(20),
-              error => 'is not a numeric value',
-              test  => 'non-numeric estimated_time fails' },
-            # We use PRIVATE_BUG_USER because he can modify the bug, but
-            # can't change time-tracking fields.
-            { value => '100', user => PRIVATE_BUG_USER,
-              error => 'only a user with the required permissions',
-              test  => 'non-timetracker can not set estimated_time' },
-        ],
-
-        groups => [
-            { value => { add => ['Master'] },
-              error => 'either this group does not exist, or you are not allowed to restrict bugs to this group',
-              test  => "adding group we don't have access to but is valid fails" },
-            { value => { add => ['QA-Selenium-TEST'] },
-              error => 'either this group does not exist, or you are not allowed to restrict bugs to this group',
-              test  => 'adding valid group that is not in this product fails' },
-            { value => { add => [random_string(20)] },
-              error => 'either this group does not exist, or you are not allowed to restrict bugs to this group',
-              test  => 'adding non-existent group fails' },
-            { value => { remove => [random_string(20)] },
-              error => 'either this group does not exist, or you are not allowed to remove bugs from this group',
-              test => 'removing non-existent group fails' },
-        ],
-
-        keywords => [
-            { value => { add => [random_string(20)] },
-              error => 'The legal keyword names are listed here',
-              test  => 'adding invalid keyword fails' },
-            { value => { remove => [random_string(20)] },
-              error => 'The legal keyword names are listed here',
-              test  => 'removing invalid keyword fails' },
-            { value => { set => [random_string(20)] },
-              error => 'The legal keyword names are listed here',
-              test  => 'setting invalid keyword fails' },
-        ],
-
-        op_sys => [
-            { value => random_string(20),
-              error => 'There is no',
-              test  => 'invalid op_sys fails' },
-            { value => '',
-              error => 'You must select/enter',
-              test => 'blank op_sys fails' },
-        ],
-
-        product => [
-            { value => random_string(60),
-              error => "does not exist or you aren't authorized",
-              test  => 'invalid product fails' },
-            { value => '',
-              error => 'You must select/enter a product',
-              test  => 'moving to blank product fails' },
-            { value => 'TestProduct',
-              error => 'There is no component named',
-              test  => 'moving products without other fields fails' },
-            { value => 'QA-Selenium-TEST',
-              extra => { component => 'QA-Selenium-TEST' },
-              error => "does not exist or you aren't authorized",
-              test  => 'moving to inaccessible product fails' },
-            { value => 'QA Entry Only',
-              error => "does not exist or you aren't authorized",
-              test  => 'moving to product where ENTRY is denied fails' },
-        ],
-
-        qa_contact => [
-            { value => random_string(20),
-              error => 'There is no user named',
-              test  => 'changing qa_contact to invalid user fails' },
-        ],
-
-        remaining_time => [
-            { value => -1,
-              error => 'less than the minimum allowable value',
-              test  => 'negative remaining_time fails' },
-            { value => 100_000_000,
-              error => 'more than the maximum allowable value',
-              test  => 'too-large remaining_time fails' },
-            { value => random_string(20),
-              error => 'is not a numeric value',
-              test  => 'non-numeric remaining_time fails' },
-            # We use PRIVATE_BUG_USER because he can modify the bug, but
-            # can't change time-tracking fields.
-            { value => '100', user => PRIVATE_BUG_USER,
-              error => 'only a user with the required permissions',
-              test  => 'non-timetracker can not set remaining_time' },
-        ],
-
-        # We do all the failing resolution tests on the second bug,
-        # because we want to be sure that we're starting from an open
-        # status.
-        resolution => [
-            { value => random_string(20), ids => [$second_id],
-              extra => { status => 'RESOLVED' },
-              error => 'There is no Resolution named',
-              test  => 'invalid resolution fails' },
-            { value => 'FIXED', ids => [$second_id],
-              error => 'You cannot set a resolution for open bugs',
-              test  => 'setting resolution on open bug fails' },
-            { value => 'DUPLICATE', ids => [$second_id],
-              extra => { status => 'RESOLVED' },
-              error => 'id to mark this bug as a duplicate',
-              test  => 'setting DUPLICATE without dup_id fails' },
-            { value => '', ids => [$second_id],
-              extra => { status => 'RESOLVED' },
-              error => 'A valid resolution is required',
-              test => 'blank resolution fails with closed status' },
-        ],
-
-        see_also => [
-            { value => { add => [random_string(20)] },
-              error => 'It does not seem like bug number nor an alias to a bug.',
-              test  => 'random string fails in see_also' },
-            { value => { add => ['https://bugzilla-dev.allizom.org/'] },
-              error => 'See Also URLs should point to one of',
-              test  => 'no show_bug.cgi in see_also URI' },
-        ],
-
-        status => [
-            { value => random_string(20),
-              error => 'There is no status named',
-              test  => 'invalid status fails' },
-            { value => '',
-              error => 'You must select/enter a status',
-              test => 'blank status fails' },
-            # We use the second bug for this because we can guarantee that
-            # it is open.
-            { value => 'VERIFIED', ids => [$second_id],
-              extra => { resolution => 'FIXED' },
-              error => 'You are not allowed to change the bug status from',
-              test  => 'invalid transition fails' },
-        ],
-
-        summary => [
-            { value => random_string(300),
-              error => 'The text you entered in the Summary field is too long',
-              test  => 'too-long summary fails' },
-            { value => '',
-              error => 'You must enter a summary for this bug',
-              test  => 'blank summary fails' },
-        ],
-
-        work_time => [
-            { value => 100_000_000,
-              error => 'more than the maximum allowable value',
-              test  => 'too-large work_time fails' },
-            { value => random_string(20),
-              error => 'is not a numeric value',
-              test  => 'non-numeric work_time fails' },
-            # We use PRIVATE_BUG_USER because he can modify the bug, but
-            # can't change time-tracking fields.
-            { value => '10', user => PRIVATE_BUG_USER,
-              error => 'only a user with the required permissions',
-              test  => 'non-timetracker can not set work_time' },
-        ],
-    );
-
-    $values{depends_on} = $values{blocks};
-
-    foreach my $field (qw(platform priority severity target_milestone version))
-    {
-        my $tests = dclone($values{op_sys});
-        foreach my $test (@$tests) {
-            $test->{test} =~ s/op_sys/$field/g;
-        }
-        $values{$field} = $tests;
+  my ($public_bug, $second_bug) = @_;
+
+  my $public_id = $public_bug->{id};
+  my $second_id = $second_bug->{id};
+
+  my $comment_id        = $public_bug->{comment}->{id};
+  my $second_comment_id = $second_bug->{comment}->{id};
+
+  my %values = (
+    alias => [
+      {
+        value => random_string(41),
+        error => 'aliases cannot be longer than',
+        test  => 'alias cannot be too long'
+      },
+      {
+        value => $second_bug->{alias},
+        error => 'has already taken the alias',
+        test  => 'duplicate alias fails'
+      },
+      {
+        value => 123456,
+        error => 'at least one letter',
+        test  => 'numeric alias fails'
+      },
+      {
+        value => random_string(20),
+        ids   => [$public_id, $second_id],
+        error => 'aliases when modifying multiple',
+        test  => 'setting alias on multiple bugs fails'
+      },
+    ],
+
+    assigned_to => [
+      {
+        value => random_string(20),
+        error => 'There is no user named',
+        test  => 'changing assigned_to to invalid user fails'
+      },
+
+      # FIXME: Also check strict_isolation at some point in the future, perhaps.
+    ],
+
+    blocks => [
+      {
+        value => {add => [NONEXISTANT_BUG]},
+        error => 'does not exist',
+        test  => 'Non-existent bug number fails in deps'
+      },
+      {
+        value => {add => [$public_id]},
+        error => 'block itself or depend on itself',
+        test  => "can't add this bug itself in a dep field"
+      },
+
+      # FIXME: Could use strict_isolation checks at some point.
+      # FIXME: Could use a dependency_loop_multi test.
+    ],
+
+    cc => [
+      {
+        value => {add => [random_string(20)]},
+        error => 'There is no user named',
+        test  => 'adding invalid user to cc fails'
+      },
+      {
+        value => {remove => [random_string(20)]},
+        error => 'There is no user named',
+        test  => 'removing invalid user from cc fails'
+      },
+    ],
+
+    comment => [
+      {
+        value => {body => random_string(100_000)},
+        error => 'cannot be longer',
+        test  => 'comment too long'
+      },
+      {
+        value => {body => random_string(100), is_private => 1},
+        error => 'comments or attachments as private',
+        test  => 'normal user cannot add private comments'
+      },
+    ],
+
+    comment_is_private => [
+      {
+        value => {$comment_id => 1},
+        error => 'comments or attachments as private',
+        test  => 'normal user cannot make a comment private'
+      },
+      {
+        value => {$second_comment_id => 1},
+        error => 'You tried to modify the privacy of comment',
+        user  => PRIVATE_BUG_USER,
+        test  => 'cannot change privacy on a comment on another bug'
+      },
+    ],
+
+    component => [
+      {
+        value => '',
+        error => 'you must first choose a component',
+        test  => 'empty component fails'
+      },
+      {
+        value => random_string(20),
+        error => 'There is no component named',
+        test  => 'invalid component fails'
+      },
+    ],
+
+    deadline => [
+      {
+        value => random_string(20),
+        error => 'is not a legal date',
+        test  => 'Non-date fails in deadline'
+      },
+      {
+        value => '2037',
+        error => 'is not a legal date',
+        test  => 'year alone fails in deadline'
+      },
+    ],
+
+    dupe_of => [
+      {
+        value => undef,
+        error => 'dup_id was not defined',
+        test  => 'undefined dupe_of fails'
+      },
+      {
+        value => NONEXISTANT_BUG,
+        error => 'does not exist',
+        test  => 'Cannot dup to a nonexistant bug'
+      },
+      {
+        value => $public_id,
+        error => 'as a duplicate of itself',
+        test  => 'Cannot dup bug to itself'
+      },
+    ],
+
+    estimated_time => [
+      {
+        value => -1,
+        error => 'less than the minimum allowable value',
+        test  => 'negative estimated_time fails'
+      },
+      {
+        value => 100_000_000,
+        error => 'more than the maximum allowable value',
+        test  => 'too-large estimated_time fails'
+      },
+      {
+        value => random_string(20),
+        error => 'is not a numeric value',
+        test  => 'non-numeric estimated_time fails'
+      },
+
+      # We use PRIVATE_BUG_USER because he can modify the bug, but
+      # can't change time-tracking fields.
+      {
+        value => '100',
+        user  => PRIVATE_BUG_USER,
+        error => 'only a user with the required permissions',
+        test  => 'non-timetracker can not set estimated_time'
+      },
+    ],
+
+    groups => [
+      {
+        value => {add => ['Master']},
+        error =>
+          'either this group does not exist, or you are not allowed to restrict bugs to this group',
+        test => "adding group we don't have access to but is valid fails"
+      },
+      {
+        value => {add => ['QA-Selenium-TEST']},
+        error =>
+          'either this group does not exist, or you are not allowed to restrict bugs to this group',
+        test => 'adding valid group that is not in this product fails'
+      },
+      {
+        value => {add => [random_string(20)]},
+        error =>
+          'either this group does not exist, or you are not allowed to restrict bugs to this group',
+        test => 'adding non-existent group fails'
+      },
+      {
+        value => {remove => [random_string(20)]},
+        error =>
+          'either this group does not exist, or you are not allowed to remove bugs from this group',
+        test => 'removing non-existent group fails'
+      },
+    ],
+
+    keywords => [
+      {
+        value => {add => [random_string(20)]},
+        error => 'The legal keyword names are listed here',
+        test  => 'adding invalid keyword fails'
+      },
+      {
+        value => {remove => [random_string(20)]},
+        error => 'The legal keyword names are listed here',
+        test  => 'removing invalid keyword fails'
+      },
+      {
+        value => {set => [random_string(20)]},
+        error => 'The legal keyword names are listed here',
+        test  => 'setting invalid keyword fails'
+      },
+    ],
+
+    op_sys => [
+      {
+        value => random_string(20),
+        error => 'There is no',
+        test  => 'invalid op_sys fails'
+      },
+      {value => '', error => 'You must select/enter', test => 'blank op_sys fails'},
+    ],
+
+    product => [
+      {
+        value => random_string(60),
+        error => "does not exist or you aren't authorized",
+        test  => 'invalid product fails'
+      },
+      {
+        value => '',
+        error => 'You must select/enter a product',
+        test  => 'moving to blank product fails'
+      },
+      {
+        value => 'TestProduct',
+        error => 'There is no component named',
+        test  => 'moving products without other fields fails'
+      },
+      {
+        value => 'QA-Selenium-TEST',
+        extra => {component => 'QA-Selenium-TEST'},
+        error => "does not exist or you aren't authorized",
+        test  => 'moving to inaccessible product fails'
+      },
+      {
+        value => 'QA Entry Only',
+        error => "does not exist or you aren't authorized",
+        test  => 'moving to product where ENTRY is denied fails'
+      },
+    ],
+
+    qa_contact => [
+      {
+        value => random_string(20),
+        error => 'There is no user named',
+        test  => 'changing qa_contact to invalid user fails'
+      },
+    ],
+
+    remaining_time => [
+      {
+        value => -1,
+        error => 'less than the minimum allowable value',
+        test  => 'negative remaining_time fails'
+      },
+      {
+        value => 100_000_000,
+        error => 'more than the maximum allowable value',
+        test  => 'too-large remaining_time fails'
+      },
+      {
+        value => random_string(20),
+        error => 'is not a numeric value',
+        test  => 'non-numeric remaining_time fails'
+      },
+
+      # We use PRIVATE_BUG_USER because he can modify the bug, but
+      # can't change time-tracking fields.
+      {
+        value => '100',
+        user  => PRIVATE_BUG_USER,
+        error => 'only a user with the required permissions',
+        test  => 'non-timetracker can not set remaining_time'
+      },
+    ],
+
+    # We do all the failing resolution tests on the second bug,
+    # because we want to be sure that we're starting from an open
+    # status.
+    resolution => [
+      {
+        value => random_string(20),
+        ids   => [$second_id],
+        extra => {status => 'RESOLVED'},
+        error => 'There is no Resolution named',
+        test  => 'invalid resolution fails'
+      },
+      {
+        value => 'FIXED',
+        ids   => [$second_id],
+        error => 'You cannot set a resolution for open bugs',
+        test  => 'setting resolution on open bug fails'
+      },
+      {
+        value => 'DUPLICATE',
+        ids   => [$second_id],
+        extra => {status => 'RESOLVED'},
+        error => 'id to mark this bug as a duplicate',
+        test  => 'setting DUPLICATE without dup_id fails'
+      },
+      {
+        value => '',
+        ids   => [$second_id],
+        extra => {status => 'RESOLVED'},
+        error => 'A valid resolution is required',
+        test  => 'blank resolution fails with closed status'
+      },
+    ],
+
+    see_also => [
+      {
+        value => {add => [random_string(20)]},
+        error => 'It does not seem like bug number nor an alias to a bug.',
+        test  => 'random string fails in see_also'
+      },
+      {
+        value => {add => ['https://bugzilla-dev.allizom.org/']},
+        error => 'See Also URLs should point to one of',
+        test  => 'no show_bug.cgi in see_also URI'
+      },
+    ],
+
+    status => [
+      {
+        value => random_string(20),
+        error => 'There is no status named',
+        test  => 'invalid status fails'
+      },
+      {
+        value => '',
+        error => 'You must select/enter a status',
+        test  => 'blank status fails'
+      },
+
+      # We use the second bug for this because we can guarantee that
+      # it is open.
+      {
+        value => 'VERIFIED',
+        ids   => [$second_id],
+        extra => {resolution => 'FIXED'},
+        error => 'You are not allowed to change the bug status from',
+        test  => 'invalid transition fails'
+      },
+    ],
+
+    summary => [
+      {
+        value => random_string(300),
+        error => 'The text you entered in the Summary field is too long',
+        test  => 'too-long summary fails'
+      },
+      {
+        value => '',
+        error => 'You must enter a summary for this bug',
+        test  => 'blank summary fails'
+      },
+    ],
+
+    work_time => [
+      {
+        value => 100_000_000,
+        error => 'more than the maximum allowable value',
+        test  => 'too-large work_time fails'
+      },
+      {
+        value => random_string(20),
+        error => 'is not a numeric value',
+        test  => 'non-numeric work_time fails'
+      },
+
+      # We use PRIVATE_BUG_USER because he can modify the bug, but
+      # can't change time-tracking fields.
+      {
+        value => '10',
+        user  => PRIVATE_BUG_USER,
+        error => 'only a user with the required permissions',
+        test  => 'non-timetracker can not set work_time'
+      },
+    ],
+  );
+
+  $values{depends_on} = $values{blocks};
+
+  foreach my $field (qw(platform priority severity target_milestone version)) {
+    my $tests = dclone($values{op_sys});
+    foreach my $test (@$tests) {
+      $test->{test} =~ s/op_sys/$field/g;
     }
+    $values{$field} = $tests;
+  }
 
-    return %values;
+  return %values;
 }
 
 sub invalid_values_to_tests {
-    my ($invalid_values, $public_bug) = @_;
-
-    my @tests;
-    foreach my $field (sort keys %$invalid_values) {
-        my @tests_invalid = @{ $invalid_values->{$field} };
-        foreach my $item (@tests_invalid) {
-            my %args = (
-                ids => $item->{ids} || [$public_bug->{id}],
-                $field => $item->{value},
-                %{ $item->{extra} || {} },
-            );
-            push(@tests, { user => $item->{user} || 'editbugs',
-                           args => \%args,
-                           error => $item->{error},
-                           test => $item->{test} });
+  my ($invalid_values, $public_bug) = @_;
+
+  my @tests;
+  foreach my $field (sort keys %$invalid_values) {
+    my @tests_invalid = @{$invalid_values->{$field}};
+    foreach my $item (@tests_invalid) {
+      my %args = (
+        ids => $item->{ids} || [$public_bug->{id}],
+        $field => $item->{value},
+        %{$item->{extra} || {}},
+      );
+      push(
+        @tests,
+        {
+          user  => $item->{user} || 'editbugs',
+          args  => \%args,
+          error => $item->{error},
+          test  => $item->{test}
         }
+      );
     }
+  }
 
-    return \@tests;
+  return \@tests;
 }
 
 ###############
@@ -610,74 +788,78 @@ sub invalid_values_to_tests {
 
 my ($config, $xmlrpc, $jsonrpc, $jsonrpc_get) = get_rpc_clients();
 
-$jsonrpc_get->bz_call_fail('Bug.update',
-    { ids => ['public_bug'] },
-    'must use HTTP POST', 'update fails over GET');
+$jsonrpc_get->bz_call_fail(
+  'Bug.update',
+  {ids => ['public_bug']},
+  'must use HTTP POST',
+  'update fails over GET'
+);
 
 sub post_success {
-    my ($call, $t, $rpc) = @_;
-    return if $t->{no_changes};
-    my $field = $t->{field};
-    return if !$field;
-
-    my @bugs = @{ $call->result->{bugs} };
-    foreach my $bug (@bugs) {
-        if ($field =~ /^comment/) {
-            _check_comment($bug, $field, $t, $rpc);
-        }
-        else {
-            _check_changes($bug, $field, $t);
-        }
+  my ($call, $t, $rpc) = @_;
+  return if $t->{no_changes};
+  my $field = $t->{field};
+  return if !$field;
+
+  my @bugs = @{$call->result->{bugs}};
+  foreach my $bug (@bugs) {
+    if ($field =~ /^comment/) {
+      _check_comment($bug, $field, $t, $rpc);
+    }
+    else {
+      _check_changes($bug, $field, $t);
     }
+  }
 }
 
 sub _check_changes {
-    my ($bug, $field, $t) = @_;
+  my ($bug, $field, $t) = @_;
 
-    my $changes = $bug->{changes}->{$field};
-    ok(defined $changes, "$field was changed")
-      or diag Dumper($bug, $t);
+  my $changes = $bug->{changes}->{$field};
+  ok(defined $changes, "$field was changed") or diag Dumper($bug, $t);
 
-    my $new_value = $t->{added};
-    $new_value = $t->{args}->{$field} if !defined $new_value;
-    _test_value($changes->{added}, $new_value, $field, 'added');
+  my $new_value = $t->{added};
+  $new_value = $t->{args}->{$field} if !defined $new_value;
+  _test_value($changes->{added}, $new_value, $field, 'added');
 
-    if (defined $t->{removed}) {
-        _test_value($changes->{removed}, $t->{removed}, $field, 'removed');
-    }
+  if (defined $t->{removed}) {
+    _test_value($changes->{removed}, $t->{removed}, $field, 'removed');
+  }
 }
 
 sub _test_value {
-    my ($got, $expected, $field, $type) = @_;
-    if ($field eq 'estimated_time' or $field eq 'remaining_time') {
-        cmp_ok($got, '==', $expected, "$field: $type is correct");
-    }
-    else {
-        is($got, $expected, "$field: $type is correct");
-    }
+  my ($got, $expected, $field, $type) = @_;
+  if ($field eq 'estimated_time' or $field eq 'remaining_time') {
+    cmp_ok($got, '==', $expected, "$field: $type is correct");
+  }
+  else {
+    is($got, $expected, "$field: $type is correct");
+  }
 }
 
 sub _check_comment {
-    my ($bug, $field, $t, $rpc) = @_;
-    my $bug_id = $bug->{id};
-    my $call = $rpc->bz_call_success('Bug.comments', { ids => [$bug_id] });
-    my $comments = $call->result->{bugs}->{$bug_id}->{comments};
-
-    if ($field eq 'comment_is_private') {
-        my $first_private = $comments->[0]->{is_private};
-        my ($expected) = values %{ $t->{args}->{comment_is_private} };
-        cmp_ok($first_private, '==', $expected,
-               'description privacy is correct');
-    }
-    else {
-        my $last_comment = $comments->[-1];
-        my $expected = $t->{args}->{comment}->{body};
-        is($last_comment->{text}, $expected, 'comment added correctly');
-    }
+  my ($bug, $field, $t, $rpc) = @_;
+  my $bug_id   = $bug->{id};
+  my $call     = $rpc->bz_call_success('Bug.comments', {ids => [$bug_id]});
+  my $comments = $call->result->{bugs}->{$bug_id}->{comments};
+
+  if ($field eq 'comment_is_private') {
+    my $first_private = $comments->[0]->{is_private};
+    my ($expected) = values %{$t->{args}->{comment_is_private}};
+    cmp_ok($first_private, '==', $expected, 'description privacy is correct');
+  }
+  else {
+    my $last_comment = $comments->[-1];
+    my $expected     = $t->{args}->{comment}->{body};
+    is($last_comment->{text}, $expected, 'comment added correctly');
+  }
 
 }
 
 foreach my $rpc ($jsonrpc, $xmlrpc) {
-    $rpc->bz_run_tests(tests => get_tests($config, $rpc),
-        method => 'Bug.update', post_success => \&post_success);
+  $rpc->bz_run_tests(
+    tests        => get_tests($config, $rpc),
+    method       => 'Bug.update',
+    post_success => \&post_success
+  );
 }
index 0af0e78d5b58d33d01bec4a4e7189539edd06700..9fd1613e8ca99f4aea93460c35c4f2cc5e8c48d8 100644 (file)
@@ -20,63 +20,80 @@ my ($config, $xmlrpc, $jsonrpc, $jsonrpc_get) = get_rpc_clients();
 my $bug_url = 'https://bugzilla-dev.allizom.org/show_bug.cgi?id=100';
 
 # update_see_also doesn't support logged-out users.
-my @tests = grep { $_->{user} } @{ STANDARD_BUG_TESTS() };
+my @tests = grep { $_->{user} } @{STANDARD_BUG_TESTS()};
 foreach my $t (@tests) {
-    $t->{args}->{add} = $t->{args}->{remove} = [];
+  $t->{args}->{add} = $t->{args}->{remove} = [];
 }
 
-push(@tests, (
-    { user  => 'unprivileged',
-      args  => { ids => ['public_bug'], add => [$bug_url] },
+push(
+  @tests,
+  (
+    {
+      user  => 'unprivileged',
+      args  => {ids => ['public_bug'], add => [$bug_url]},
       error => 'only the assignee or reporter of the bug, or a user',
       test  => 'Unprivileged user cannot add a URL to a bug',
     },
 
-    { user  => 'admin',
-      args  => { ids => ['public_bug'], add => ['asdfasdfasdf'] },
+    {
+      user  => 'admin',
+      args  => {ids => ['public_bug'], add => ['asdfasdfasdf']},
       error => 'ASDF',
       test  => 'Admin cannot add an invalid URL',
     },
-    { user => 'admin',
-      args => { ids => ['public_bug'], remove => ['asdfasdfasdf'] },
+    {
+      user => 'admin',
+      args => {ids => ['public_bug'], remove => ['asdfasdfasdf']},
       test => 'Invalid URL silently ignored',
     },
 
-    { user => 'admin',
-      args => { ids => ['public_bug'], add => [$bug_url] },
+    {
+      user => 'admin',
+      args => {ids => ['public_bug'], add => [$bug_url]},
       test => 'Admin can add a URL to a public bug',
     },
-    { user  => 'unprivileged',
-      args  => { ids => ['public_bug'], remove => [$bug_url] },
+    {
+      user  => 'unprivileged',
+      args  => {ids => ['public_bug'], remove => [$bug_url]},
       error => 'only the assignee or reporter of the bug, or a user',
       test  => 'Unprivileged user cannot remove a URL from a bug',
     },
-    { user => 'admin',
-      args => { ids => ['public_bug'], remove => [$bug_url] },
+    {
+      user => 'admin',
+      args => {ids => ['public_bug'], remove => [$bug_url]},
       test => 'Admin can remove a URL from a public bug',
     },
 
-    { user => PRIVATE_BUG_USER,
-      args => { ids => ['private_bug'], add => [$bug_url] },
+    {
+      user => PRIVATE_BUG_USER,
+      args => {ids => ['private_bug'], add => [$bug_url]},
       test => PRIVATE_BUG_USER . ' can add a URL to a private bug',
     },
-    { user => PRIVATE_BUG_USER,
-      args => { ids => ['private_bug'], remove => [$bug_url] },
+    {
+      user => PRIVATE_BUG_USER,
+      args => {ids => ['private_bug'], remove => [$bug_url]},
       test => PRIVATE_BUG_USER . ' can remove a URL from a private bug',
     },
 
-));
+  )
+);
 
 sub post_success {
-    my ($call, $t) = @_;
-    isa_ok($call->result->{changes}, 'HASH', "Changes");
+  my ($call, $t) = @_;
+  isa_ok($call->result->{changes}, 'HASH', "Changes");
 }
 
-$jsonrpc_get->bz_call_fail('Bug.update_see_also',
-    { ids => ['public_bug'], add => [$bug_url] },
-    'must use HTTP POST', 'update_see_also fails over GET');
+$jsonrpc_get->bz_call_fail(
+  'Bug.update_see_also',
+  {ids => ['public_bug'], add => [$bug_url]},
+  'must use HTTP POST',
+  'update_see_also fails over GET'
+);
 
 foreach my $rpc ($jsonrpc, $xmlrpc) {
-    $rpc->bz_run_tests(tests => \@tests, method => 'Bug.update_see_also',
-                       post_success => \&post_success);
+  $rpc->bz_run_tests(
+    tests        => \@tests,
+    method       => 'Bug.update_see_also',
+    post_success => \&post_success
+  );
 }
index 6d40e308877de5b795a51fb5546d6b6b3eb31d23..f51afa09776cc3de9168734c41c023294b799589 100644 (file)
@@ -17,29 +17,30 @@ use QA::Util;
 my ($config, @clients) = get_rpc_clients();
 
 foreach my $rpc (@clients) {
-    my $vers_call = $rpc->bz_call_success('Bugzilla.version');
-    my $version = $vers_call->result->{version};
-    ok($version, "Bugzilla.version returns $version");
+  my $vers_call = $rpc->bz_call_success('Bugzilla.version');
+  my $version   = $vers_call->result->{version};
+  ok($version, "Bugzilla.version returns $version");
 
-    my $tz_call = $rpc->bz_call_success('Bugzilla.timezone');
-    my $tz = $tz_call->result->{timezone};
-    ok($tz, "Bugzilla.timezone retuns $tz");
+  my $tz_call = $rpc->bz_call_success('Bugzilla.timezone');
+  my $tz      = $tz_call->result->{timezone};
+  ok($tz, "Bugzilla.timezone retuns $tz");
 
-    my $ext_call = $rpc->bz_call_success('Bugzilla.extensions');
-    my $extensions = $ext_call->result->{extensions};
-    isa_ok($extensions, 'HASH', 'extensions');
+  my $ext_call   = $rpc->bz_call_success('Bugzilla.extensions');
+  my $extensions = $ext_call->result->{extensions};
+  isa_ok($extensions, 'HASH', 'extensions');
 
-    # There is always at least the QA extension enabled.
-    my $cmp = $config->{test_extensions} ? '>' : '==';
-    my @ext_names = keys %$extensions;
-    my $desc = scalar(@ext_names) . ' extension(s) returned: ' . join(', ', @ext_names);
-    cmp_ok(scalar(@ext_names), $cmp, 1, $desc);
-    ok(grep($_ eq 'QA', @ext_names), 'The QA extension is enabled');
+  # There is always at least the QA extension enabled.
+  my $cmp = $config->{test_extensions} ? '>' : '==';
+  my @ext_names = keys %$extensions;
+  my $desc
+    = scalar(@ext_names) . ' extension(s) returned: ' . join(', ', @ext_names);
+  cmp_ok(scalar(@ext_names), $cmp, 1, $desc);
+  ok(grep($_ eq 'QA', @ext_names), 'The QA extension is enabled');
 
-    my $time_call = $rpc->bz_call_success('Bugzilla.time');
-    my $time_result = $time_call->result;
-    foreach my $type (qw(db_time web_time)) {
-        cmp_ok($time_result->{$type}, '=~', $rpc->DATETIME_REGEX,
-               "Bugzilla.time returns a datetime for $type");
-    }
+  my $time_call   = $rpc->bz_call_success('Bugzilla.time');
+  my $time_result = $time_call->result;
+  foreach my $type (qw(db_time web_time)) {
+    cmp_ok($time_result->{$type}, '=~', $rpc->DATETIME_REGEX,
+      "Bugzilla.time returns a datetime for $type");
+  }
 }
index e2c0a725d4dd809fd4930e2954563c47914ded94..8622621a13332b071d36aa3f881e2dd848a91503 100644 (file)
@@ -18,80 +18,103 @@ use QA::Util;
 use constant DESCRIPTION => 'Group created by Group.create';
 
 sub post_success {
-    my $call = shift;
-    my $gid = $call->result->{id};
-    ok($gid, "Got a non-zero group ID: $gid");
+  my $call = shift;
+  my $gid  = $call->result->{id};
+  ok($gid, "Got a non-zero group ID: $gid");
 }
 
 my ($config, $xmlrpc, $jsonrpc, $jsonrpc_get) = get_rpc_clients();
 
 my @tests = (
-    { args  => { name => random_string(20), description => DESCRIPTION },
-      error => 'You must log in',
-      test  => 'Logged-out user cannot call Group.create',
-    },
-    { user  => 'unprivileged',
-      args  => { name => random_string(20), description => DESCRIPTION },
-      error => 'you are not authorized',
-      test  => 'Unprivileged user cannot call Group.create',
-    },
-    { user  => 'admin',
-      args  => { description => DESCRIPTION },
-      error => 'You must enter a name',
-      test  => 'Missing name to Group.create',
-    },
-    { user  => 'admin',
-      args  => { name => random_string(20) },
-      error => 'You must enter a description',
-      test  => 'Missing description to Group.create',
-    },
-    { user  => 'admin',
-      args  => { name => '', description => DESCRIPTION },
-      error => 'You must enter a name',
-      test  => 'Name to Group.create cannot be empty',
-    },
-    { user  => 'admin',
-      args  => { name => random_string(20), description => '' },
-      error => 'You must enter a description',
-      test  => 'Description to Group.create cannot be empty',
-    },
-    { user  => 'admin',
-      args  => { name => 'canconfirm', description => DESCRIPTION },
-      error => 'already exists',
-      test  => 'Name to Group.create already exists',
-    },
-    { user  => 'admin',
-      args  => { name => 'caNConFIrm', description => DESCRIPTION },
-      error => 'already exists',
-      test  => 'Name to Group.create already exists but with a different case',
-    },
-    { user  => 'admin',
-      args  => { name => random_string(20), description => DESCRIPTION,
-                 user_regexp => '\\'},
-      error => 'The regular expression you entered is invalid',
-      test  => 'The regular expression passed to Group.create is invalid',
-    },
+  {
+    args  => {name => random_string(20), description => DESCRIPTION},
+    error => 'You must log in',
+    test  => 'Logged-out user cannot call Group.create',
+  },
+  {
+    user  => 'unprivileged',
+    args  => {name => random_string(20), description => DESCRIPTION},
+    error => 'you are not authorized',
+    test  => 'Unprivileged user cannot call Group.create',
+  },
+  {
+    user  => 'admin',
+    args  => {description => DESCRIPTION},
+    error => 'You must enter a name',
+    test  => 'Missing name to Group.create',
+  },
+  {
+    user  => 'admin',
+    args  => {name => random_string(20)},
+    error => 'You must enter a description',
+    test  => 'Missing description to Group.create',
+  },
+  {
+    user  => 'admin',
+    args  => {name => '', description => DESCRIPTION},
+    error => 'You must enter a name',
+    test  => 'Name to Group.create cannot be empty',
+  },
+  {
+    user  => 'admin',
+    args  => {name => random_string(20), description => ''},
+    error => 'You must enter a description',
+    test  => 'Description to Group.create cannot be empty',
+  },
+  {
+    user  => 'admin',
+    args  => {name => 'canconfirm', description => DESCRIPTION},
+    error => 'already exists',
+    test  => 'Name to Group.create already exists',
+  },
+  {
+    user  => 'admin',
+    args  => {name => 'caNConFIrm', description => DESCRIPTION},
+    error => 'already exists',
+    test  => 'Name to Group.create already exists but with a different case',
+  },
+  {
+    user => 'admin',
+    args =>
+      {name => random_string(20), description => DESCRIPTION, user_regexp => '\\'},
+    error => 'The regular expression you entered is invalid',
+    test  => 'The regular expression passed to Group.create is invalid',
+  },
 );
 
-$jsonrpc_get->bz_call_fail('Group.create',
-    { name => random_string(20), description => 'Created with JSON-RPC via GET' },
-    'must use HTTP POST', 'Group.create fails over GET');
+$jsonrpc_get->bz_call_fail(
+  'Group.create',
+  {name => random_string(20), description => 'Created with JSON-RPC via GET'},
+  'must use HTTP POST',
+  'Group.create fails over GET'
+);
 
 foreach my $rpc ($xmlrpc, $jsonrpc) {
-    # Tests which work must be called from here,
-    # to avoid creating twice the same group.
-    my @all_tests = (@tests,
-        { user  => 'admin',
-          args  => { name => random_string(20), description => DESCRIPTION },
-          test  => 'Passing the name and description only works',
-        },
-        { user  => 'admin',
-          args  => { name => random_string(20), description => DESCRIPTION,
-                     user_regexp => '\@foo.com$', is_active => 1,
-                     icon_url => 'https://www.bugzilla.org/favicon.ico' },
-          test  => 'Passing all arguments works',
-        },
-    );
-    $rpc->bz_run_tests(tests => \@all_tests, method => 'Group.create',
-                       post_success => \&post_success);
+
+  # Tests which work must be called from here,
+  # to avoid creating twice the same group.
+  my @all_tests = (
+    @tests,
+    {
+      user => 'admin',
+      args => {name => random_string(20), description => DESCRIPTION},
+      test => 'Passing the name and description only works',
+    },
+    {
+      user => 'admin',
+      args => {
+        name        => random_string(20),
+        description => DESCRIPTION,
+        user_regexp => '\@foo.com$',
+        is_active   => 1,
+        icon_url    => 'https://www.bugzilla.org/favicon.ico'
+      },
+      test => 'Passing all arguments works',
+    },
+  );
+  $rpc->bz_run_tests(
+    tests        => \@all_tests,
+    method       => 'Group.create',
+    post_success => \&post_success
+  );
 }
index 53b23aaf20e141577d0b266c213a06ea1e03bdd0..8aa72a145fdabb91a89eb598852489526155bf6b 100644 (file)
@@ -12,19 +12,26 @@ use Test::More tests => 85;
 use QA::Util;
 my $jsonrpc_get = QA::Util::get_jsonrpc_client('GET');
 
-my @chars = (0..9, 'A'..'Z', 'a'..'z', '_[].');
+my @chars = (0 .. 9, 'A' .. 'Z', 'a' .. 'z', '_[].');
 
 our @tests = (
-    { args => { callback => join('', @chars) },
-      test => 'callback accepts all legal characters.' },
+  {
+    args => {callback => join('', @chars)},
+    test => 'callback accepts all legal characters.'
+  },
 );
-foreach my $char (qw(! ~ ` @ $ % ^ & * - + = { } ; : ' " < > / ? |),
-                  '(', ')', '\\', '#', ',')
+foreach
+  my $char (qw(! ~ ` @ $ % ^ & * - + = { } ; : ' " < > / ? |), '(', ')', '\\',
+  '#', ',')
 {
-    push(@tests,
-         { args  => { callback => "a$char" },
-           error => "as your 'callback' parameter",
-           test  => "$char is not valid in callback" });
+  push(
+    @tests,
+    {
+      args  => {callback => "a$char"},
+      error => "as your 'callback' parameter",
+      test  => "$char is not valid in callback"
+    }
+  );
 }
 
 $jsonrpc_get->bz_run_tests(method => 'Bugzilla.version', tests => \@tests);
index 1ced652765e1d6c749d718ca5c8adb01e4ccf8ba..7d44f08ae12b4faef06197813db9d0a1f38a95d4 100644 (file)
@@ -20,7 +20,7 @@ use Test::More tests => 134;
 use QA::Util;
 my ($config, @clients) = get_rpc_clients();
 
-my $products = $clients[0]->bz_get_products();
+my $products  = $clients[0]->bz_get_products();
 my $public    = $products->{'Another Product'};
 my $private   = $products->{'QA-Selenium-TEST'};
 my $no_entry  = $products->{'QA Entry Only'};
@@ -29,81 +29,79 @@ my $no_search = $products->{'QA Search Only'};
 my %id_map = reverse %$products;
 
 my $tests = {
-    'QA_Selenium_TEST' => {
-        selectable => [$public, $private, $no_entry, $no_search],
-        enterable  => [$public, $private, $no_entry, $no_search],
-        accessible => [$public, $private, $no_entry, $no_search],
-    },
-    'unprivileged' => {
-        selectable => [$public, $no_entry],
-        not_selectable => $no_search,
-        enterable  => [$public, $no_search],
-        not_enterable => $no_entry,
-        accessible => [$public, $no_entry, $no_search],
-        not_accessible => $private,
-    },
-    '' => {
-        selectable => [$public, $no_entry],
-        not_selectable => $no_search,
-        enterable  => [$public, $no_search],
-        not_enterable => $no_entry,
-        accessible => [$public, $no_entry, $no_search],
-        not_accessible => $private,
-    },
+  'QA_Selenium_TEST' => {
+    selectable => [$public, $private, $no_entry, $no_search],
+    enterable  => [$public, $private, $no_entry, $no_search],
+    accessible => [$public, $private, $no_entry, $no_search],
+  },
+  'unprivileged' => {
+    selectable     => [$public, $no_entry],
+    not_selectable => $no_search,
+    enterable      => [$public, $no_search],
+    not_enterable  => $no_entry,
+    accessible     => [$public, $no_entry, $no_search],
+    not_accessible => $private,
+  },
+  '' => {
+    selectable     => [$public, $no_entry],
+    not_selectable => $no_search,
+    enterable      => [$public, $no_search],
+    not_enterable  => $no_entry,
+    accessible     => [$public, $no_entry, $no_search],
+    not_accessible => $private,
+  },
 };
 
 foreach my $rpc (@clients) {
-    foreach my $user (keys %$tests) {
-        my @selectable = @{ $tests->{$user}->{selectable} };
-        my @enterable  = @{ $tests->{$user}->{enterable} };
-        my @accessible = @{ $tests->{$user}->{accessible} };
-        my $not_selectable = $tests->{$user}->{not_selectable};
-        my $not_enterable  = $tests->{$user}->{not_enterable};
-        my $not_accessible = $tests->{$user}->{not_accessible};
+  foreach my $user (keys %$tests) {
+    my @selectable     = @{$tests->{$user}->{selectable}};
+    my @enterable      = @{$tests->{$user}->{enterable}};
+    my @accessible     = @{$tests->{$user}->{accessible}};
+    my $not_selectable = $tests->{$user}->{not_selectable};
+    my $not_enterable  = $tests->{$user}->{not_enterable};
+    my $not_accessible = $tests->{$user}->{not_accessible};
 
-        $rpc->bz_log_in($user) if $user;
-        $user ||= "Logged-out user";
+    $rpc->bz_log_in($user) if $user;
+    $user ||= "Logged-out user";
 
-        my $select_call =
-            $rpc->bz_call_success('Product.get_selectable_products');
-        my $select_ids = $select_call->result->{ids};
-        foreach my $id (@selectable) {
-            ok(grep($_ == $id, @$select_ids),
-               "$user can select " . $id_map{$id});
-        }
-        if ($not_selectable) {
-            ok(!grep($_ == $not_selectable, @$select_ids),
-               "$user cannot select " . $id_map{$not_selectable});
-        }
-
-        my $enter_call =
-            $rpc->bz_call_success('Product.get_enterable_products');
-        my $enter_ids = $enter_call->result->{ids};
-        foreach my $id (@enterable) {
-            ok(grep($_ == $id, @$enter_ids), "$user can enter " . $id_map{$id});
-        }
-        if ($not_enterable) {
-            ok(!grep($_ == $not_enterable, @$enter_ids),
-               "$user cannot enter " . $id_map{$not_enterable});
-        }
+    my $select_call = $rpc->bz_call_success('Product.get_selectable_products');
+    my $select_ids  = $select_call->result->{ids};
+    foreach my $id (@selectable) {
+      ok(grep($_ == $id, @$select_ids), "$user can select " . $id_map{$id});
+    }
+    if ($not_selectable) {
+      ok(
+        !grep($_ == $not_selectable, @$select_ids),
+        "$user cannot select " . $id_map{$not_selectable}
+      );
+    }
 
-        my $access_call =
-            $rpc->bz_call_success('Product.get_accessible_products');
-        my $get_call = $rpc->bz_call_success('Product.get',
-                                             { ids => \@accessible });
-        my $products = $get_call->result->{products};
-        my $expected_count = scalar @accessible;
-        cmp_ok(scalar @$products, '==', $expected_count,
-           "Product.get gets all $expected_count accessible products"
-           . " for $user.");
-        if ($not_accessible) {
-            my $no_access_call = $rpc->bz_call_success(
-                'Product.get', { ids => [$not_accessible] });
-            ok(!scalar @{ $no_access_call->result->{products} },
-               "$user gets 0 products when asking for "
-               . $id_map{$not_accessible});
-        }
+    my $enter_call = $rpc->bz_call_success('Product.get_enterable_products');
+    my $enter_ids  = $enter_call->result->{ids};
+    foreach my $id (@enterable) {
+      ok(grep($_ == $id, @$enter_ids), "$user can enter " . $id_map{$id});
+    }
+    if ($not_enterable) {
+      ok(
+        !grep($_ == $not_enterable, @$enter_ids),
+        "$user cannot enter " . $id_map{$not_enterable}
+      );
+    }
 
-        $rpc->bz_call_success('User.logout') if $user ne "Logged-out user";
+    my $access_call = $rpc->bz_call_success('Product.get_accessible_products');
+    my $get_call    = $rpc->bz_call_success('Product.get', {ids => \@accessible});
+    my $products    = $get_call->result->{products};
+    my $expected_count = scalar @accessible;
+    cmp_ok(scalar @$products,
+      '==', $expected_count,
+      "Product.get gets all $expected_count accessible products" . " for $user.");
+    if ($not_accessible) {
+      my $no_access_call
+        = $rpc->bz_call_success('Product.get', {ids => [$not_accessible]});
+      ok(!scalar @{$no_access_call->result->{products}},
+        "$user gets 0 products when asking for " . $id_map{$not_accessible});
     }
+
+    $rpc->bz_call_success('User.logout') if $user ne "Logged-out user";
+  }
 }
index 3b8fe78b1758e2cf646c60d2ab5ca58075c971c6..01b3ea4d5e092ec136372480686f2fb511cc03c3 100644 (file)
@@ -15,149 +15,226 @@ use lib qw(lib ../../lib ../../local/lib/perl5);
 use Test::More tests => 121;
 use QA::Util;
 
-use constant DESCRIPTION => 'Product created by Product.create';
+use constant DESCRIPTION  => 'Product created by Product.create';
 use constant PROD_VERSION => 'unspecified';
 
 sub post_success {
-    my ($call, $test, $self) = @_;
-    my $args = $test->{args};
-    my $prod_id = $call->result->{id};
-    ok($prod_id, "Got a non-zero product ID: $prod_id");
+  my ($call, $test, $self) = @_;
+  my $args    = $test->{args};
+  my $prod_id = $call->result->{id};
+  ok($prod_id, "Got a non-zero product ID: $prod_id");
 
-    $call = $self->bz_call_success("Product.get", {ids => [$prod_id]});
-    my $product = $call->result->{products}->[0];
-    my $prod_name = $product->{name};
-    my $is_active = defined $args->{is_open} ? $args->{is_open} : 1;
-    ok($product->{is_active} == $is_active,
-       "Product $prod_name has the correct value for is_active/is_open: $is_active");
-    my $has_unco = defined $args->{has_unconfirmed} ? $args->{has_unconfirmed} : 1;
-    ok($product->{has_unconfirmed} == $has_unco,
-       "Product $prod_name has the correct value for has_unconfirmed: $has_unco");
+  $call = $self->bz_call_success("Product.get", {ids => [$prod_id]});
+  my $product   = $call->result->{products}->[0];
+  my $prod_name = $product->{name};
+  my $is_active = defined $args->{is_open} ? $args->{is_open} : 1;
+  ok($product->{is_active} == $is_active,
+    "Product $prod_name has the correct value for is_active/is_open: $is_active");
+  my $has_unco = defined $args->{has_unconfirmed} ? $args->{has_unconfirmed} : 1;
+  ok($product->{has_unconfirmed} == $has_unco,
+    "Product $prod_name has the correct value for has_unconfirmed: $has_unco");
 }
 
 my ($config, $xmlrpc, $jsonrpc, $jsonrpc_get) = get_rpc_clients();
 
 my @tests = (
-    { args  => { name => random_string(20), version => PROD_VERSION,
-                 description => DESCRIPTION },
-      error => 'You must log in',
-      test  => 'Logged-out user cannot call Product.create',
+  {
+    args => {
+      name        => random_string(20),
+      version     => PROD_VERSION,
+      description => DESCRIPTION
     },
-    { user  => 'unprivileged',
-      args  => { name => random_string(20), version => PROD_VERSION,
-                 description => DESCRIPTION },
-      error => 'you are not authorized',
-      test  => 'Unprivileged user cannot call Product.create',
+    error => 'You must log in',
+    test  => 'Logged-out user cannot call Product.create',
+  },
+  {
+    user => 'unprivileged',
+    args => {
+      name        => random_string(20),
+      version     => PROD_VERSION,
+      description => DESCRIPTION
     },
-    { user  => 'admin',
-      args  => { version => PROD_VERSION, description => DESCRIPTION },
-      error => 'You must enter a name',
-      test  => 'Missing name to Product.create',
+    error => 'you are not authorized',
+    test  => 'Unprivileged user cannot call Product.create',
+  },
+  {
+    user  => 'admin',
+    args  => {version => PROD_VERSION, description => DESCRIPTION},
+    error => 'You must enter a name',
+    test  => 'Missing name to Product.create',
+  },
+  {
+    user  => 'admin',
+    args  => {name => random_string(20), version => PROD_VERSION},
+    error => 'You must enter a description',
+    test  => 'Missing description to Product.create',
+  },
+  {
+    user  => 'admin',
+    args  => {name => random_string(20), description => DESCRIPTION},
+    error => 'You must enter a valid version',
+    test  => 'Missing version to Product.create',
+  },
+  {
+    user  => 'admin',
+    args  => {name => '', version => PROD_VERSION, description => DESCRIPTION},
+    error => 'You must enter a name',
+    test  => 'Name to Product.create cannot be empty',
+  },
+  {
+    user => 'admin',
+    args => {name => random_string(20), version => PROD_VERSION, description => ''},
+    error => 'You must enter a description',
+    test  => 'Description to Product.create cannot be empty',
+  },
+  {
+    user  => 'admin',
+    args  => {name => random_string(20), version => '', description => DESCRIPTION},
+    error => 'You must enter a valid version',
+    test  => 'Version to Product.create cannot be empty',
+  },
+  {
+    user => 'admin',
+    args => {
+      name        => random_string(20000),
+      version     => PROD_VERSION,
+      description => DESCRIPTION
     },
-    { user  => 'admin',
-      args  => { name => random_string(20), version => PROD_VERSION },
-      error => 'You must enter a description',
-      test  => 'Missing description to Product.create',
+    error => 'The name of a product is limited',
+    test  => 'Name to Product.create too long',
+  },
+  {
+    user => 'admin',
+    args => {
+      name        => 'Another Product',
+      version     => PROD_VERSION,
+      description => DESCRIPTION
     },
-    { user  => 'admin',
-      args  => { name => random_string(20), description => DESCRIPTION },
-      error => 'You must enter a valid version',
-      test  => 'Missing version to Product.create',
-    },
-    { user  => 'admin',
-      args  => { name => '', version => PROD_VERSION, description => DESCRIPTION },
-      error => 'You must enter a name',
-      test  => 'Name to Product.create cannot be empty',
-    },
-    { user  => 'admin',
-      args  => { name => random_string(20), version => PROD_VERSION, description => '' },
-      error => 'You must enter a description',
-      test  => 'Description to Product.create cannot be empty',
-    },
-    { user  => 'admin',
-      args  => { name => random_string(20), version => '', description => DESCRIPTION },
-      error => 'You must enter a valid version',
-      test  => 'Version to Product.create cannot be empty',
-    },
-    { user  => 'admin',
-      args  => { name => random_string(20000), version => PROD_VERSION,
-                 description => DESCRIPTION },
-      error => 'The name of a product is limited',
-      test  => 'Name to Product.create too long',
-    },
-    { user  => 'admin',
-      args  => { name => 'Another Product', version => PROD_VERSION,
-                 description => DESCRIPTION },
-      error => 'already exists',
-      test  => 'Name to Product.create already exists',
-    },
-    { user  => 'admin',
-      args  => { name => 'aNoThEr Product', version => PROD_VERSION,
-                 description => DESCRIPTION },
-      error => 'differs from existing product',
-      test  => 'Name to Product.create already exists but with a different case',
+    error => 'already exists',
+    test  => 'Name to Product.create already exists',
+  },
+  {
+    user => 'admin',
+    args => {
+      name        => 'aNoThEr Product',
+      version     => PROD_VERSION,
+      description => DESCRIPTION
     },
+    error => 'differs from existing product',
+    test  => 'Name to Product.create already exists but with a different case',
+  },
 );
 
 # FIXME: Should be: if (classifications enabled).
 #        But there is currently now way to query the value of a parameter via WS.
 if (0) {
-    push(@tests,
-        { user  => 'admin',
-          args  => { name => random_string(20), version => PROD_VERSION,
-                     description => DESCRIPTION, has_unconfirmed => 1,
-                     classification => '', default_milestone => '2.0',
-                     is_open => 1, create_series => 1 },
-          error => 'You must select/enter a classification',
-          test  => 'Passing an empty classification to Product.create fails',
-        },
-        { user  => 'admin',
-          args  => { name => random_string(20), version => PROD_VERSION,
-                     description => DESCRIPTION, has_unconfirmed => 1,
-                     classification => random_string(10), default_milestone => '2.0',
-                     is_open => 1, create_series => 1 },
-          error => 'You must select/enter a classification',
-          test  => 'Passing an invalid classification to Product.create fails',
-        },
-    )
+  push(
+    @tests,
+    {
+      user => 'admin',
+      args => {
+        name              => random_string(20),
+        version           => PROD_VERSION,
+        description       => DESCRIPTION,
+        has_unconfirmed   => 1,
+        classification    => '',
+        default_milestone => '2.0',
+        is_open           => 1,
+        create_series     => 1
+      },
+      error => 'You must select/enter a classification',
+      test  => 'Passing an empty classification to Product.create fails',
+    },
+    {
+      user => 'admin',
+      args => {
+        name              => random_string(20),
+        version           => PROD_VERSION,
+        description       => DESCRIPTION,
+        has_unconfirmed   => 1,
+        classification    => random_string(10),
+        default_milestone => '2.0',
+        is_open           => 1,
+        create_series     => 1
+      },
+      error => 'You must select/enter a classification',
+      test  => 'Passing an invalid classification to Product.create fails',
+    },
+  );
 }
 
-$jsonrpc_get->bz_call_fail('Product.create',
-    { name => random_string(20), version => PROD_VERSION,
-      description => 'Created with JSON-RPC via GET' },
-    'must use HTTP POST', 'Product.create fails over GET');
+$jsonrpc_get->bz_call_fail(
+  'Product.create',
+  {
+    name        => random_string(20),
+    version     => PROD_VERSION,
+    description => 'Created with JSON-RPC via GET'
+  },
+  'must use HTTP POST',
+  'Product.create fails over GET'
+);
 
 foreach my $rpc ($xmlrpc, $jsonrpc) {
-    # Tests which work must be called from here,
-    # to avoid creating twice the same product.
-    my @all_tests = (@tests,
-        { user  => 'admin',
-          args  => { name => random_string(20), version => PROD_VERSION,
-                     description => DESCRIPTION },
-          test  => 'Passing the name, description and version only works',
-        },
-        { user  => 'admin',
-          args  => { name => random_string(20), version => PROD_VERSION,
-                     description => DESCRIPTION, has_unconfirmed => 1,
-                     classification => 'Class2_QA', default_milestone => '2.0',
-                     is_open => 1, create_series => 1 },
-          test  => 'Passing all arguments works',
-        },
-        { user  => 'admin',
-          args  => { name => random_string(20), version => PROD_VERSION,
-                     description => DESCRIPTION, has_unconfirmed => 0,
-                     classification => 'Class2_QA', default_milestone => '2.0',
-                     is_open => 0, create_series => 0 },
-          test  => 'Passing null values works',
-        },
-        { user  => 'admin',
-          args  => { name => random_string(20), version => PROD_VERSION,
-                     description => DESCRIPTION, has_unconfirmed => 1,
-                     classification => 'Class2_QA', default_milestone => '',
-                     is_open => 1, create_series => 1 },
-          test  => 'Passing an empty default milestone works (falls back to "---")',
-        },
-    );
-    $rpc->bz_run_tests(tests => \@all_tests, method => 'Product.create',
-                       post_success => \&post_success);
+
+  # Tests which work must be called from here,
+  # to avoid creating twice the same product.
+  my @all_tests = (
+    @tests,
+    {
+      user => 'admin',
+      args => {
+        name        => random_string(20),
+        version     => PROD_VERSION,
+        description => DESCRIPTION
+      },
+      test => 'Passing the name, description and version only works',
+    },
+    {
+      user => 'admin',
+      args => {
+        name              => random_string(20),
+        version           => PROD_VERSION,
+        description       => DESCRIPTION,
+        has_unconfirmed   => 1,
+        classification    => 'Class2_QA',
+        default_milestone => '2.0',
+        is_open           => 1,
+        create_series     => 1
+      },
+      test => 'Passing all arguments works',
+    },
+    {
+      user => 'admin',
+      args => {
+        name              => random_string(20),
+        version           => PROD_VERSION,
+        description       => DESCRIPTION,
+        has_unconfirmed   => 0,
+        classification    => 'Class2_QA',
+        default_milestone => '2.0',
+        is_open           => 0,
+        create_series     => 0
+      },
+      test => 'Passing null values works',
+    },
+    {
+      user => 'admin',
+      args => {
+        name              => random_string(20),
+        version           => PROD_VERSION,
+        description       => DESCRIPTION,
+        has_unconfirmed   => 1,
+        classification    => 'Class2_QA',
+        default_milestone => '',
+        is_open           => 1,
+        create_series     => 1
+      },
+      test => 'Passing an empty default milestone works (falls back to "---")',
+    },
+  );
+  $rpc->bz_run_tests(
+    tests        => \@all_tests,
+    method       => 'Product.create',
+    post_success => \&post_success
+  );
 }
index 7f445ced7ddc9fdd5abbf51b93f5eb9fbf2df051..bd46ae4005f939074d75197f5ad138336942f528 100644 (file)
@@ -20,7 +20,7 @@ use Test::More tests => 134;
 use QA::Util;
 my ($config, @clients) = get_rpc_clients();
 
-my $products = $clients[0]->bz_get_products();
+my $products  = $clients[0]->bz_get_products();
 my $public    = $products->{'Another Product'};
 my $private   = $products->{'QA-Selenium-TEST'};
 my $no_entry  = $products->{'QA Entry Only'};
@@ -29,81 +29,79 @@ my $no_search = $products->{'QA Search Only'};
 my %id_map = reverse %$products;
 
 my $tests = {
-    'QA_Selenium_TEST' => {
-        selectable => [$public, $private, $no_entry, $no_search],
-        enterable  => [$public, $private, $no_entry, $no_search],
-        accessible => [$public, $private, $no_entry, $no_search],
-    },
-    'unprivileged' => {
-        selectable => [$public, $no_entry],
-        not_selectable => $no_search,
-        enterable  => [$public, $no_search],
-        not_enterable => $no_entry,
-        accessible => [$public, $no_entry, $no_search],
-        not_accessible => $private,
-    },
-    '' => {
-        selectable => [$public, $no_entry],
-        not_selectable => $no_search,
-        enterable  => [$public, $no_search],
-        not_enterable => $no_entry,
-        accessible => [$public, $no_entry, $no_search],
-        not_accessible => $private,
-    },
+  'QA_Selenium_TEST' => {
+    selectable => [$public, $private, $no_entry, $no_search],
+    enterable  => [$public, $private, $no_entry, $no_search],
+    accessible => [$public, $private, $no_entry, $no_search],
+  },
+  'unprivileged' => {
+    selectable     => [$public, $no_entry],
+    not_selectable => $no_search,
+    enterable      => [$public, $no_search],
+    not_enterable  => $no_entry,
+    accessible     => [$public, $no_entry, $no_search],
+    not_accessible => $private,
+  },
+  '' => {
+    selectable     => [$public, $no_entry],
+    not_selectable => $no_search,
+    enterable      => [$public, $no_search],
+    not_enterable  => $no_entry,
+    accessible     => [$public, $no_entry, $no_search],
+    not_accessible => $private,
+  },
 };
 
 foreach my $rpc (@clients) {
-    foreach my $user (keys %$tests) {
-        my @selectable = @{ $tests->{$user}->{selectable} };
-        my @enterable  = @{ $tests->{$user}->{enterable} };
-        my @accessible = @{ $tests->{$user}->{accessible} };
-        my $not_selectable = $tests->{$user}->{not_selectable};
-        my $not_enterable  = $tests->{$user}->{not_enterable};
-        my $not_accessible = $tests->{$user}->{not_accessible};
+  foreach my $user (keys %$tests) {
+    my @selectable     = @{$tests->{$user}->{selectable}};
+    my @enterable      = @{$tests->{$user}->{enterable}};
+    my @accessible     = @{$tests->{$user}->{accessible}};
+    my $not_selectable = $tests->{$user}->{not_selectable};
+    my $not_enterable  = $tests->{$user}->{not_enterable};
+    my $not_accessible = $tests->{$user}->{not_accessible};
 
-        $rpc->bz_log_in($user) if $user;
-        $user ||= "Logged-out user";
+    $rpc->bz_log_in($user) if $user;
+    $user ||= "Logged-out user";
 
-        my $select_call =
-            $rpc->bz_call_success('Product.get_selectable_products');
-        my $select_ids = $select_call->result->{ids};
-        foreach my $id (@selectable) {
-            ok(grep($_ == $id, @$select_ids),
-               "$user can select " . $id_map{$id});
-        }
-        if ($not_selectable) {
-            ok(!grep($_ == $not_selectable, @$select_ids),
-               "$user cannot select " . $id_map{$not_selectable});
-        }
-
-        my $enter_call =
-            $rpc->bz_call_success('Product.get_enterable_products');
-        my $enter_ids = $enter_call->result->{ids};
-        foreach my $id (@enterable) {
-            ok(grep($_ == $id, @$enter_ids), "$user can enter " . $id_map{$id});
-        }
-        if ($not_enterable) {
-            ok(!grep($_ == $not_enterable, @$enter_ids),
-               "$user cannot enter " . $id_map{$not_enterable});
-        }
+    my $select_call = $rpc->bz_call_success('Product.get_selectable_products');
+    my $select_ids  = $select_call->result->{ids};
+    foreach my $id (@selectable) {
+      ok(grep($_ == $id, @$select_ids), "$user can select " . $id_map{$id});
+    }
+    if ($not_selectable) {
+      ok(
+        !grep($_ == $not_selectable, @$select_ids),
+        "$user cannot select " . $id_map{$not_selectable}
+      );
+    }
 
-        my $access_call =
-            $rpc->bz_call_success('Product.get_accessible_products');
-        my $get_call = $rpc->bz_call_success('Product.get',
-                                             { ids => \@accessible });
-        my $products = $get_call->result->{products};
-        my $expected_count = scalar @accessible;
-        cmp_ok(scalar @$products, '==', $expected_count,
-           "Product.get gets all $expected_count accessible products"
-           . " for $user.");
-        if ($not_accessible) {
-            my $no_access_call = $rpc->bz_call_success(
-                'Product.get', { ids => [$not_accessible] });
-            ok(!scalar @{ $no_access_call->result->{products} },
-               "$user gets 0 products when asking for "
-               . $id_map{$not_accessible});
-        }
+    my $enter_call = $rpc->bz_call_success('Product.get_enterable_products');
+    my $enter_ids  = $enter_call->result->{ids};
+    foreach my $id (@enterable) {
+      ok(grep($_ == $id, @$enter_ids), "$user can enter " . $id_map{$id});
+    }
+    if ($not_enterable) {
+      ok(
+        !grep($_ == $not_enterable, @$enter_ids),
+        "$user cannot enter " . $id_map{$not_enterable}
+      );
+    }
 
-        $rpc->bz_call_success('User.logout') if $user ne "Logged-out user";
+    my $access_call = $rpc->bz_call_success('Product.get_accessible_products');
+    my $get_call    = $rpc->bz_call_success('Product.get', {ids => \@accessible});
+    my $products    = $get_call->result->{products};
+    my $expected_count = scalar @accessible;
+    cmp_ok(scalar @$products,
+      '==', $expected_count,
+      "Product.get gets all $expected_count accessible products" . " for $user.");
+    if ($not_accessible) {
+      my $no_access_call
+        = $rpc->bz_call_success('Product.get', {ids => [$not_accessible]});
+      ok(!scalar @{$no_access_call->result->{products}},
+        "$user gets 0 products when asking for " . $id_map{$not_accessible});
     }
+
+    $rpc->bz_call_success('User.logout') if $user ne "Logged-out user";
+  }
 }
index 34b7a4896408286dcfd33e8383f710a467941e67..33b042a51a0445dca89599ad6ec22ce21a0e3f20 100644 (file)
@@ -25,90 +25,116 @@ use constant PASSWORD_TOO_SHORT => 'a';
 use constant INVALID_EMAIL => '()[]\;:,<>@webservice.test';
 
 sub new_login {
-    return 'created_' . random_string(@_) . '@webservice.test';
+  return 'created_' . random_string(@_) . '@webservice.test';
 }
 
 sub post_success {
-    my ($call) = @_;
-    ok($call->result->{id}, "Got a non-zero user id");
+  my ($call) = @_;
+  ok($call->result->{id}, "Got a non-zero user id");
 }
 
-$jsonrpc_get->bz_call_fail('User.create',
-    { email => new_login(), full_name => NEW_FULLNAME,
-      password => '*' },
-    'must use HTTP POST', 'User.create fails over GET');
+$jsonrpc_get->bz_call_fail(
+  'User.create',
+  {email => new_login(), full_name => NEW_FULLNAME, password => '*'},
+  'must use HTTP POST',
+  'User.create fails over GET'
+);
 
 # We have to wrap @tests in the foreach, because we want a different
 # login for each user, separately for each RPC client. (You can't create
 # two users with the same username, and XML-RPC would otherwise try to
 # create the same users that JSON-RPC created.)
 foreach my $rpc ($jsonrpc, $xmlrpc) {
-    my @tests = (
-        # Permissions checks
-        { args  => { email    => new_login(), full_name => NEW_FULLNAME,
-                     password => NEW_PASSWORD },
-          error => "you are not authorized",
-          test  => 'Logged-out user cannot call User.create',
-        },
-        { user  => 'unprivileged',
-          args  => { email    => new_login(), full_name => NEW_FULLNAME,
-                     password => NEW_PASSWORD },
-          error => "you are not authorized",
-          test  => 'Unprivileged user cannot call User.create',
-        },
+  my @tests = (
 
-        # Login name checks.
-        { user  => 'admin',
-          args  => { full_name => NEW_FULLNAME, password => NEW_PASSWORD },
-          error => "argument was not set",
-          test  => 'Leaving out email argument fails',
-        },
-        { user  => 'admin',
-          args  => { email    => '', full_name => NEW_FULLNAME,
-                     password => NEW_PASSWORD },
-          error => "argument was not set",
-          test  => "Passing an empty email argument fails",
-        },
-        { user  => 'admin',
-          args  => { email    => INVALID_EMAIL, full_name => NEW_FULLNAME,
-                     password => NEW_PASSWORD },
-          error =>  "didn't pass our syntax checking",
-          test  => 'Invalid email address fails',
-        },
-        { user  => 'admin',
-          args  => { email    => new_login(128), full_name => NEW_FULLNAME,
-          password => NEW_PASSWORD },
-          error =>  "didn't pass our syntax checking",
-          test  => 'Too long (> 127 chars) email address fails',
-        },
-        { user  => 'admin',
-          args  => { email     => $config->{unprivileged_user_login},
-                     full_name => NEW_FULLNAME, password => NEW_PASSWORD },
-          error =>  "There is already an account",
-          test  => 'Trying to use an existing login name fails',
-        },
+    # Permissions checks
+    {
+      args =>
+        {email => new_login(), full_name => NEW_FULLNAME, password => NEW_PASSWORD},
+      error => "you are not authorized",
+      test  => 'Logged-out user cannot call User.create',
+    },
+    {
+      user => 'unprivileged',
+      args =>
+        {email => new_login(), full_name => NEW_FULLNAME, password => NEW_PASSWORD},
+      error => "you are not authorized",
+      test  => 'Unprivileged user cannot call User.create',
+    },
 
-        { user  => 'admin',
-          args  => { email    => new_login(), full_name => NEW_FULLNAME,
-                     password => PASSWORD_TOO_SHORT },
-          error => 'The password does not meet our security requirements for the following reason: too short',
-          test  => 'Password Too Short fails',
-        },
-        { user => 'admin',
-          args => { email    => new_login(), full_name => NEW_FULLNAME,
-                    password => NEW_PASSWORD },
-          test => 'Creating a user with all arguments and correct privileges',
-        },
-        { user => 'admin',
-          args => { email => new_login(), password => NEW_PASSWORD },
-          test => 'Leaving out fullname works',
-        },
-        { user => 'admin',
-          args => { email => new_login(), full_name => NEW_FULLNAME },
-          test => 'Leaving out password works',
-        },
-    );
+    # Login name checks.
+    {
+      user  => 'admin',
+      args  => {full_name => NEW_FULLNAME, password => NEW_PASSWORD},
+      error => "argument was not set",
+      test  => 'Leaving out email argument fails',
+    },
+    {
+      user  => 'admin',
+      args  => {email => '', full_name => NEW_FULLNAME, password => NEW_PASSWORD},
+      error => "argument was not set",
+      test  => "Passing an empty email argument fails",
+    },
+    {
+      user => 'admin',
+      args =>
+        {email => INVALID_EMAIL, full_name => NEW_FULLNAME, password => NEW_PASSWORD},
+      error => "didn't pass our syntax checking",
+      test  => 'Invalid email address fails',
+    },
+    {
+      user => 'admin',
+      args => {
+        email     => new_login(128),
+        full_name => NEW_FULLNAME,
+        password  => NEW_PASSWORD
+      },
+      error => "didn't pass our syntax checking",
+      test  => 'Too long (> 127 chars) email address fails',
+    },
+    {
+      user => 'admin',
+      args => {
+        email     => $config->{unprivileged_user_login},
+        full_name => NEW_FULLNAME,
+        password  => NEW_PASSWORD
+      },
+      error => "There is already an account",
+      test  => 'Trying to use an existing login name fails',
+    },
 
-    $rpc->bz_run_tests(tests => \@tests, method => 'User.create',
-                       post_success => \&post_success);
+    {
+      user => 'admin',
+      args => {
+        email     => new_login(),
+        full_name => NEW_FULLNAME,
+        password  => PASSWORD_TOO_SHORT
+      },
+      error =>
+        'The password does not meet our security requirements for the following reason: too short',
+      test => 'Password Too Short fails',
+    },
+    {
+      user => 'admin',
+      args =>
+        {email => new_login(), full_name => NEW_FULLNAME, password => NEW_PASSWORD},
+      test => 'Creating a user with all arguments and correct privileges',
+    },
+    {
+      user => 'admin',
+      args => {email => new_login(), password => NEW_PASSWORD},
+      test => 'Leaving out fullname works',
+    },
+    {
+      user => 'admin',
+      args => {email => new_login(), full_name => NEW_FULLNAME},
+      test => 'Leaving out password works',
+    },
+  );
+
+  $rpc->bz_run_tests(
+    tests        => \@tests,
+    method       => 'User.create',
+    post_success => \&post_success
+  );
 }
index 32f25f256a7ccf27507188d9910b22837ad7b701..6053f348f08bbf3c6e484f1dcbee36f8de049914 100644 (file)
@@ -17,202 +17,254 @@ use QA::Tests qw(PRIVATE_BUG_USER);
 use Test::More tests => 330;
 our ($config, @clients) = get_rpc_clients();
 
-my $get_user = $config->{'unprivileged_user_login'};
+my $get_user        = $config->{'unprivileged_user_login'};
 my $canconfirm_user = $config->{'canconfirm_user_login'};
-my $priv_user = $config->{PRIVATE_BUG_USER . '_user_login'};
-my $disabled = $config->{'disabled_user_login'};
-my $disabled_match = substr($disabled, 0, length($disabled) - 1);
+my $priv_user       = $config->{PRIVATE_BUG_USER . '_user_login'};
+my $disabled        = $config->{'disabled_user_login'};
+my $disabled_match  = substr($disabled, 0, length($disabled) - 1);
 
 # These are the basic tests. There are tests for include_fields
 # and exclude_field below.
 
 my @tests = (
-    { args => { names => [$get_user] },
-      test => "Logged-out user can get unprivileged user by name"
-    },
-    { args  => { match => [$get_user] },
-      test  => 'Logged-out user cannot use the match argument',
-      error => 'Logged-out users cannot use',
-    },
-    { args  => { ids => [1] },
-      test  => 'Logged-out users cannot use the "ids" argument',
-      error => 'Logged-out users cannot use',
-    },
+  {
+    args => {names => [$get_user]},
+    test => "Logged-out user can get unprivileged user by name"
+  },
+  {
+    args  => {match => [$get_user]},
+    test  => 'Logged-out user cannot use the match argument',
+    error => 'Logged-out users cannot use',
+  },
+  {
+    args  => {ids => [1]},
+    test  => 'Logged-out users cannot use the "ids" argument',
+    error => 'Logged-out users cannot use',
+  },
 
-    # match & names
-    { user => 'unprivileged',
-      args => { names => [$get_user] },
-      test => "Unprivileged user can get himself",
-    },
-    { user => 'unprivileged',
-      args => { match => [$get_user] },
-      test => 'Logged-in user can use the match argument',
-    },
-    { user => 'unprivileged',
-      args => { match => [$get_user], names => [$get_user] },
-      test => 'Specifying the same thing in "match" and "names"',
-    },
+  # match & names
+  {
+    user => 'unprivileged',
+    args => {names => [$get_user]},
+    test => "Unprivileged user can get himself",
+  },
+  {
+    user => 'unprivileged',
+    args => {match => [$get_user]},
+    test => 'Logged-in user can use the match argument',
+  },
+  {
+    user => 'unprivileged',
+    args => {match => [$get_user], names => [$get_user]},
+    test => 'Specifying the same thing in "match" and "names"',
+  },
 
-    # include_disabled
-    { user => 'unprivileged',
-      args => { match => [$get_user, $disabled_match] },
-      test => 'Disabled users are not normally returned'
-    },
-    { user => 'unprivileged',
-      args => { match => [$disabled_match], include_disabled => 1 },
-      test => 'Specifying include_disabled returns disabled users'
-    },
-    { user => 'unprivileged',
-      args => { match => [$disabled] },
-      test => 'Full match on a disabled user returns that user',
-    },
+  # include_disabled
+  {
+    user => 'unprivileged',
+    args => {match => [$get_user, $disabled_match]},
+    test => 'Disabled users are not normally returned'
+  },
+  {
+    user => 'unprivileged',
+    args => {match => [$disabled_match], include_disabled => 1},
+    test => 'Specifying include_disabled returns disabled users'
+  },
+  {
+    user => 'unprivileged',
+    args => {match => [$disabled]},
+    test => 'Full match on a disabled user returns that user',
+  },
 
-    # groups and group_ids
-    { args  => { groups => ['QA-Selenium-TEST'] },
-      test  => 'Specifying just groups fails',
-      error => 'one of the following parameters',
-    },
-    { args => { group_ids => [1] },
-      test => 'Specifying just group ids fails',
-      error => 'one of the following parameters',
-    },
-    { args => { names => [$get_user, $priv_user], groups => ['QA-Selenium-TEST'] },
-      test => 'Limiting the return value to a group while being logged out fails',
-      error => 'The group you specified, QA-Selenium-TEST, is not valid here',
-    },
-    { user => 'unprivileged',
-      args => { names => [$get_user, $priv_user], groups => ['missing_group'] },
-      test => 'Limiting the return value to a group which does not exist fails',
-      error => 'The group you specified, missing_group, is not valid here',
-    },
-    { user => 'unprivileged',
-      args => { names => [$get_user, $priv_user], groups => ['QA-Selenium-TEST'] },
-      test => 'Limiting the return value to a group you do not belong to fails',
-      error => 'The group you specified, QA-Selenium-TEST, is not valid here',
-    },
-    { user => 'editbugs',
-      args => { names => [$get_user, $priv_user], groups => ['Master', 'editbugs'] },
-      test => 'Limiting the return value to some groups you do not belong to fails',
-      error => 'The group you specified, Master, is not valid here',
-    },
-    { user => 'admin',
-      args => { names => [$canconfirm_user], groups => ['canconfirm', 'editbugs'] },
-      test => 'Limiting the return value to groups you belong to',
-    },
+  # groups and group_ids
+  {
+    args  => {groups => ['QA-Selenium-TEST']},
+    test  => 'Specifying just groups fails',
+    error => 'one of the following parameters',
+  },
+  {
+    args  => {group_ids => [1]},
+    test  => 'Specifying just group ids fails',
+    error => 'one of the following parameters',
+  },
+  {
+    args  => {names => [$get_user, $priv_user], groups => ['QA-Selenium-TEST']},
+    test  => 'Limiting the return value to a group while being logged out fails',
+    error => 'The group you specified, QA-Selenium-TEST, is not valid here',
+  },
+  {
+    user  => 'unprivileged',
+    args  => {names => [$get_user, $priv_user], groups => ['missing_group']},
+    test  => 'Limiting the return value to a group which does not exist fails',
+    error => 'The group you specified, missing_group, is not valid here',
+  },
+  {
+    user  => 'unprivileged',
+    args  => {names => [$get_user, $priv_user], groups => ['QA-Selenium-TEST']},
+    test  => 'Limiting the return value to a group you do not belong to fails',
+    error => 'The group you specified, QA-Selenium-TEST, is not valid here',
+  },
+  {
+    user  => 'editbugs',
+    args  => {names => [$get_user, $priv_user], groups => ['Master', 'editbugs']},
+    test  => 'Limiting the return value to some groups you do not belong to fails',
+    error => 'The group you specified, Master, is not valid here',
+  },
+  {
+    user => 'admin',
+    args => {names => [$canconfirm_user], groups => ['canconfirm', 'editbugs']},
+    test => 'Limiting the return value to groups you belong to',
+  },
 
-    # groups returned
-    { user => 'admin',
-      args => { names => [$get_user] },
-      test => 'Admin can get user',
-    },
-    { user => 'admin',
-      args => { names => [$canconfirm_user] },
-      test => 'Admin can get user',
-    },
-    { user => 'canconfirm',
-      args => { names => [$canconfirm_user] },
-      test => 'Privileged user can get himself',
-    },
-    { user => 'editbugs',
-      args => { names => [$canconfirm_user] },
-      test => 'Privileged user can get another user',
-    },
+  # groups returned
+  {
+    user => 'admin',
+    args => {names => [$get_user]},
+    test => 'Admin can get user',
+  },
+  {
+    user => 'admin',
+    args => {names => [$canconfirm_user]},
+    test => 'Admin can get user',
+  },
+  {
+    user => 'canconfirm',
+    args => {names => [$canconfirm_user]},
+    test => 'Privileged user can get himself',
+  },
+  {
+    user => 'editbugs',
+    args => {names => [$canconfirm_user]},
+    test => 'Privileged user can get another user',
+  },
 );
 
 sub post_success {
-    my ($call, $t) = @_;
+  my ($call, $t) = @_;
 
-    my $result = $call->result;
-    is(scalar @{ $result->{users} }, 1, "Got exactly one user");
-    my $item = $result->{users}->[0];
-    my $user = $t->{user} || '';
+  my $result = $call->result;
+  is(scalar @{$result->{users}}, 1, "Got exactly one user");
+  my $item = $result->{users}->[0];
+  my $user = $t->{user} || '';
 
-    if ($user eq 'admin') {
-        ok(exists $item->{email} && exists $item->{can_login}
-           && exists $item->{email_enabled} && exists $item->{login_denied_text},
-           'Admin correctly gets all user fields');
-    }
-    elsif ($user) {
-        ok(exists $item->{email} && exists $item->{can_login},
-           'Logged-in user correctly gets email and can_login');
-        ok(!exists $item->{email_enabled}
-           && !exists $item->{login_denied_text},
-           "Non-admin user doesn't get email_enabled and login_denied_text");
-    }
-    else {
-        my @item_keys = sort keys %$item;
-        is_deeply(\@item_keys, ['id', 'name', 'nick', 'real_name'],
-            'Only id, name, nick and real_name are returned to logged-out users');
-        return;
-    }
+  if ($user eq 'admin') {
+    ok(
+      exists $item->{email}
+        && exists $item->{can_login}
+        && exists $item->{email_enabled}
+        && exists $item->{login_denied_text},
+      'Admin correctly gets all user fields'
+    );
+  }
+  elsif ($user) {
+    ok(
+      exists $item->{email} && exists $item->{can_login},
+      'Logged-in user correctly gets email and can_login'
+    );
+    ok(
+      !exists $item->{email_enabled} && !exists $item->{login_denied_text},
+      "Non-admin user doesn't get email_enabled and login_denied_text"
+    );
+  }
+  else {
+    my @item_keys = sort keys %$item;
+    is_deeply(
+      \@item_keys,
+      ['id', 'name', 'nick', 'real_name'],
+      'Only id, name, nick and real_name are returned to logged-out users'
+    );
+    return;
+  }
 
-    my $username = $config->{"${user}_user_login"};
-    # FIXME: We have no way to create a saved search or a saved report from
-    #        the WebService, so we cannot test that the correct data is returned
-    #        if the user is accessing his own account.
-    if ($username eq $item->{name}) {
-        ok(exists $item->{saved_searches},
-           'Users can get the list of saved searches and reports for their own account');
-    }
-    else {
-        ok(!exists $item->{saved_searches},
-           "Users cannot get the list of saved searches and reports from someone else's acccount");
-    }
+  my $username = $config->{"${user}_user_login"};
+
+  # FIXME: We have no way to create a saved search or a saved report from
+  #        the WebService, so we cannot test that the correct data is returned
+  #        if the user is accessing his own account.
+  if ($username eq $item->{name}) {
+    ok(exists $item->{saved_searches},
+      'Users can get the list of saved searches and reports for their own account');
+  }
+  else {
+    ok(
+      !exists $item->{saved_searches},
+      "Users cannot get the list of saved searches and reports from someone else's acccount"
+    );
+  }
 
-    my @groups = map { $_->{name} } @{$item->{groups}};
-    # Admins can see all groups a user belongs to (assuming they inherited
-    # membership for all groups). Same for a user querying his own account.
-    if ($username eq $item->{name} || $user eq 'admin') {
-        if ($username eq $get_user) {
-            ok(!scalar @groups, "The unprivileged user doesn't belong to any group");
-        }
-        elsif ($username eq $canconfirm_user) {
-            ok(grep($_ eq 'canconfirm', @groups), "Group 'canconfirm' returned");
-        }
+  my @groups = map { $_->{name} } @{$item->{groups}};
+
+  # Admins can see all groups a user belongs to (assuming they inherited
+  # membership for all groups). Same for a user querying his own account.
+  if ($username eq $item->{name} || $user eq 'admin') {
+    if ($username eq $get_user) {
+      ok(!scalar @groups, "The unprivileged user doesn't belong to any group");
     }
-    else {
-        ok(!scalar @groups, "No groups are visible to users without bless privs");
+    elsif ($username eq $canconfirm_user) {
+      ok(grep($_ eq 'canconfirm', @groups), "Group 'canconfirm' returned");
     }
+  }
+  else {
+    ok(!scalar @groups, "No groups are visible to users without bless privs");
+  }
 }
 
 foreach my $rpc (@clients) {
-    $rpc->bz_run_tests(tests => \@tests, method => 'User.get',
-                       post_success => \&post_success);
-
-    #############################
-    # Include and Exclude Tests #
-    #############################
-
-    my $include_nothing = $rpc->bz_call_success('User.get', {
-        names => [$get_user], include_fields => ['asdfasdfsdf'],
-    }, 'User.get including only invalid fields');
-    is(scalar keys %{ $include_nothing->result->{users}->[0] }, 0,
-       'No fields returned for user');
-
-    my $include_one = $rpc->bz_call_success('User.get', {
-        names => [$get_user], include_fields => ['id'],
-    }, 'User.get including only id');
-    is(scalar keys %{ $include_one->result->{users}->[0] }, 1,
-       'Only one field returned for user');
-
-    my $exclude_none = $rpc->bz_call_success('User.get', {
-        names => [$get_user], exclude_fields => ['asdfasdfsdf'],
-    }, 'User.get excluding only invalid fields');
-    is(scalar keys %{ $exclude_none->result->{users}->[0] }, 4,
-       'All fields returned for user');
-
-    my $exclude_one = $rpc->bz_call_success('User.get', {
-        names => [$get_user], exclude_fields => ['id'],
-    }, 'User.get excluding id');
-    is(scalar keys %{ $exclude_one->result->{users}->[0] }, 3,
-       'Only three fields returned for user');
-
-    my $override = $rpc->bz_call_success('User.get', {
-        names => [$get_user], include_fields => ['id', 'name'],
-        exclude_fields => ['id']
-    }, 'User.get with both include and exclude');
-    is(scalar keys %{ $override->result->{users}->[0] }, 1,
-       'Only one field returned');
-    ok(exists $override->result->{users}->[0]->{name},
-       '...and that field is the "name" field');
+  $rpc->bz_run_tests(
+    tests        => \@tests,
+    method       => 'User.get',
+    post_success => \&post_success
+  );
+
+  #############################
+  # Include and Exclude Tests #
+  #############################
+
+  my $include_nothing = $rpc->bz_call_success(
+    'User.get',
+    {names => [$get_user], include_fields => ['asdfasdfsdf'],},
+    'User.get including only invalid fields'
+  );
+  is(scalar keys %{$include_nothing->result->{users}->[0]},
+    0, 'No fields returned for user');
+
+  my $include_one = $rpc->bz_call_success(
+    'User.get',
+    {names => [$get_user], include_fields => ['id'],},
+    'User.get including only id'
+  );
+  is(scalar keys %{$include_one->result->{users}->[0]},
+    1, 'Only one field returned for user');
+
+  my $exclude_none = $rpc->bz_call_success(
+    'User.get',
+    {names => [$get_user], exclude_fields => ['asdfasdfsdf'],},
+    'User.get excluding only invalid fields'
+  );
+  is(scalar keys %{$exclude_none->result->{users}->[0]},
+    4, 'All fields returned for user');
+
+  my $exclude_one = $rpc->bz_call_success(
+    'User.get',
+    {names => [$get_user], exclude_fields => ['id'],},
+    'User.get excluding id'
+  );
+  is(scalar keys %{$exclude_one->result->{users}->[0]},
+    3, 'Only three fields returned for user');
+
+  my $override = $rpc->bz_call_success(
+    'User.get',
+    {
+      names          => [$get_user],
+      include_fields => ['id', 'name'],
+      exclude_fields => ['id']
+    },
+    'User.get with both include and exclude'
+  );
+  is(scalar keys %{$override->result->{users}->[0]}, 1,
+    'Only one field returned');
+  ok(
+    exists $override->result->{users}->[0]->{name},
+    '...and that field is the "name" field'
+  );
 }
index a6abec88e857cce25689283d86e886fc81c2dda7..8c86ac0e8db3b5d3eb49f167e1216da8a8d53f8f 100644 (file)
@@ -19,106 +19,115 @@ my ($config, @clients) = get_rpc_clients();
 
 use constant INVALID_EMAIL => '@invalid_user@';
 
-my $user = $config->{unprivileged_user_login};
-my $pass = $config->{unprivileged_user_passwd};
+my $user  = $config->{unprivileged_user_login};
+my $pass  = $config->{unprivileged_user_passwd};
 my $error = "The username or password you entered is not valid";
 
 my @tests = (
-    { user => 'unprivileged',
-      test => "Unprivileged user can log in successfully",
-    },
+  {user => 'unprivileged', test => "Unprivileged user can log in successfully",},
 
-    { args  => { login => $user, password => '' },
-      error => $error,
-      test  => "Empty password can't log in",
-    },
-    { args  => { login => '', password => $pass },
-      error => $error,
-      test  => "Empty login can't log in",
-    },
-    { args  => { login => $user },
-      error => "requires a password argument",
-      test  => "Undef password can't log in",
-    },
-    { args  => { password => $pass },
-      error => "requires a login argument",
-      test  => "Undef login can't log in",
-    },
+  {
+    args  => {login => $user, password => ''},
+    error => $error,
+    test  => "Empty password can't log in",
+  },
+  {
+    args  => {login => '', password => $pass},
+    error => $error,
+    test  => "Empty login can't log in",
+  },
+  {
+    args  => {login => $user},
+    error => "requires a password argument",
+    test  => "Undef password can't log in",
+  },
+  {
+    args  => {password => $pass},
+    error => "requires a login argument",
+    test  => "Undef login can't log in",
+  },
 
-    { args  => { login => INVALID_EMAIL, password => $pass },
-      error => $error,
-      test  => "Invalid email can't log in",
-    },
-    { args  => { login => $user, password => '*' },
-      error => $error,
-      test  => "Invalid password can't log in",
-    },
+  {
+    args  => {login => INVALID_EMAIL, password => $pass},
+    error => $error,
+    test  => "Invalid email can't log in",
+  },
+  {
+    args  => {login => $user, password => '*'},
+    error => $error,
+    test  => "Invalid password can't log in",
+  },
 
-    { args  => { login    => $config->{disabled_user_login},
-                 password => $config->{disabled_user_passwd} },
-      error => "!!This is the text!!",
-      test  => "Can't log in with a disabled account",
-    },
-    { args  => { login => $config->{disabled_user_login}, password => '*' },
-      error => $error,
-      test  => "Logging in with invalid password doesn't show disabledtext",
+  {
+    args => {
+      login    => $config->{disabled_user_login},
+      password => $config->{disabled_user_passwd}
     },
+    error => "!!This is the text!!",
+    test  => "Can't log in with a disabled account",
+  },
+  {
+    args  => {login => $config->{disabled_user_login}, password => '*'},
+    error => $error,
+    test  => "Logging in with invalid password doesn't show disabledtext",
+  },
 );
 
 sub _login_args {
-    my $args = shift;
-    my %fixed_args = %$args;
-    $fixed_args{Bugzilla_login} = delete $fixed_args{login};
-    $fixed_args{Bugzilla_password} = delete $fixed_args{password};
-    return \%fixed_args;
+  my $args       = shift;
+  my %fixed_args = %$args;
+  $fixed_args{Bugzilla_login}    = delete $fixed_args{login};
+  $fixed_args{Bugzilla_password} = delete $fixed_args{password};
+  return \%fixed_args;
 }
 
 foreach my $rpc (@clients) {
-    if ($rpc->bz_get_mode) {
-        $rpc->bz_call_fail('User.logout', undef, 'must use HTTP POST',
-                           'User.logout fails when called via GET');
-    }
+  if ($rpc->bz_get_mode) {
+    $rpc->bz_call_fail(
+      'User.logout', undef,
+      'must use HTTP POST',
+      'User.logout fails when called via GET'
+    );
+  }
 
-    foreach my $t (@tests) {
-        if ($t->{user}) {
-            my $username = $config->{$t->{user} . '_user_login'};
-            my $password = $config->{$t->{user} . '_user_passwd'};
+  foreach my $t (@tests) {
+    if ($t->{user}) {
+      my $username = $config->{$t->{user} . '_user_login'};
+      my $password = $config->{$t->{user} . '_user_passwd'};
 
-            if ($rpc->bz_get_mode) {
-                $rpc->bz_call_fail('User.login',
-                    { login => $username, password => $password },
-                    'must use HTTP POST', $t->{test} . ' (fails on GET)');
-            }
-            else {
-                $rpc->bz_log_in($t->{user});
-                ok($rpc->{_bz_credentials}->{token}, 'Login token returned');
-                $rpc->bz_call_success('User.logout');
-            }
+      if ($rpc->bz_get_mode) {
+        $rpc->bz_call_fail(
+          'User.login',
+          {login => $username, password => $password},
+          'must use HTTP POST',
+          $t->{test} . ' (fails on GET)'
+        );
+      }
+      else {
+        $rpc->bz_log_in($t->{user});
+        ok($rpc->{_bz_credentials}->{token}, 'Login token returned');
+        $rpc->bz_call_success('User.logout');
+      }
 
-            if ($t->{error}) {
-                $rpc->bz_call_fail('Bugzilla.version',
-                    { Bugzilla_login => $username,
-                      Bugzilla_password => $password });
-            }
-            else {
-                $rpc->bz_call_success('Bugzilla.version',
-                    { Bugzilla_login => $username,
-                      Bugzilla_password => $password });
-            }
-        }
-        else {
-            # Under GET, there's no reason to have extra failing tests.
-            if (!$rpc->bz_get_mode) {
-                $rpc->bz_call_fail('User.login', $t->{args}, $t->{error},
-                                   $t->{test});
-            }
-            if (defined $t->{args}->{login}
-                and defined $t->{args}->{password})
-            {
-                my $fixed_args = _login_args($t->{args});
-                $rpc->bz_call_fail('Bugzilla.version', $fixed_args,
-                    $t->{error}, "Bugzilla_login: " . $t->{test});
-            }
-        }
+      if ($t->{error}) {
+        $rpc->bz_call_fail('Bugzilla.version',
+          {Bugzilla_login => $username, Bugzilla_password => $password});
+      }
+      else {
+        $rpc->bz_call_success('Bugzilla.version',
+          {Bugzilla_login => $username, Bugzilla_password => $password});
+      }
+    }
+    else {
+      # Under GET, there's no reason to have extra failing tests.
+      if (!$rpc->bz_get_mode) {
+        $rpc->bz_call_fail('User.login', $t->{args}, $t->{error}, $t->{test});
+      }
+      if (defined $t->{args}->{login} and defined $t->{args}->{password}) {
+        my $fixed_args = _login_args($t->{args});
+        $rpc->bz_call_fail('Bugzilla.version', $fixed_args, $t->{error},
+          "Bugzilla_login: " . $t->{test});
+      }
     }
+  }
 }
index e9392bab5b9dcae78c86fb30f64603e86098ad3d..10b5714b20c8ce4b84bb2fefbb084d9b2a10d9d5 100644 (file)
@@ -20,40 +20,45 @@ my ($config, $xmlrpc, $jsonrpc, $jsonrpc_get) = get_rpc_clients();
 use constant INVALID_EMAIL => '()[]\;:,<>@webservice.test';
 
 sub new_login {
-    return 'requested_' . random_string() . '@webservice.test';
+  return 'requested_' . random_string() . '@webservice.test';
 }
 
-$jsonrpc_get->bz_call_fail('User.offer_account_by_email',
-    { email => new_login() },
-    'must use HTTP POST', 'offer_account_by_email fails over GET');
+$jsonrpc_get->bz_call_fail(
+  'User.offer_account_by_email',
+  {email => new_login()},
+  'must use HTTP POST',
+  'offer_account_by_email fails over GET'
+);
 
 # Have to wrap @tests in the foreach so that new_login returns something
 # different each time.
 foreach my $rpc ($jsonrpc, $xmlrpc) {
-    my @tests = (
-        # Login name checks.
-        { args  => { },
-          error => "argument was not set",
-          test  => 'Leaving out email argument fails',
-        },
-        { args  => { email => '' },
-          error => "argument was not set",
-          test  => "Passing an empty email argument fails",
-        },
-        { args  => { email => INVALID_EMAIL },
-          error => "didn't pass our syntax checking",
-          test  => 'Invalid email address fails',
-        },
-        { args  => { email => $config->{unprivileged_user_login} },
-          error => "There is already an account",
-          test  => 'Trying to use an existing login name fails',
-        },
-
-        { args => { email => new_login() },
-          test => 'Valid, non-existing email passes.',
-        },
-    );
-
-    $rpc->bz_run_tests(tests => \@tests,
-                       method => 'User.offer_account_by_email');
+  my @tests = (
+
+    # Login name checks.
+    {
+      args  => {},
+      error => "argument was not set",
+      test  => 'Leaving out email argument fails',
+    },
+    {
+      args  => {email => ''},
+      error => "argument was not set",
+      test  => "Passing an empty email argument fails",
+    },
+    {
+      args  => {email => INVALID_EMAIL},
+      error => "didn't pass our syntax checking",
+      test  => 'Invalid email address fails',
+    },
+    {
+      args  => {email => $config->{unprivileged_user_login}},
+      error => "There is already an account",
+      test  => 'Trying to use an existing login name fails',
+    },
+
+    {args => {email => new_login()}, test => 'Valid, non-existing email passes.',},
+  );
+
+  $rpc->bz_run_tests(tests => \@tests, method => 'User.offer_account_by_email');
 }
index 3d8d82bf4dcc942f2bb7463937797463cd04374b..ae609d5ba0efa400db7e99f573676efbd114e93b 100644 (file)
@@ -18,58 +18,59 @@ use lib qw(. lib local/lib/perl5 t);
 use Config;
 use Support::Files;
 use Test::More;
-BEGIN {
-    if ($ENV{CI}) {
-        plan skip_all => 'Not running compile tests in CI.';
-        exit;
-    }
-    plan tests => @Support::Files::testitems + @Support::Files::test_files;
 
-    use_ok('Bugzilla::Constants');
-    use_ok('Bugzilla::Install::Requirements');
-    use_ok('Bugzilla');
+BEGIN {
+  if ($ENV{CI}) {
+    plan skip_all => 'Not running compile tests in CI.';
+    exit;
+  }
+  plan tests => @Support::Files::testitems + @Support::Files::test_files;
+
+  use_ok('Bugzilla::Constants');
+  use_ok('Bugzilla::Install::Requirements');
+  use_ok('Bugzilla');
 }
 Bugzilla->usage_mode(USAGE_MODE_TEST);
 
 sub compile_file {
-    my ($file) = @_;
-
-    # Don't allow CPAN.pm to modify the global @INC, which the version
-    # shipped with Perl 5.8.8 does. (It gets loaded by
-    # Bugzilla::Install::CPAN.)
-    local @INC = @INC;
-
-    if ($file =~ /extensions/) {
-        skip "$file: extensions not tested",  1;
-        return;
-    }
-
-    if ($file =~ s/\.pm$//) {
-        $file =~ s{/}{::}g;
-        use_ok($file);
-        return;
-    }
-
-    open(my $fh, $file);
-    my $bang = <$fh>;
-    close $fh;
-
-    my $T = "";
-    if ($bang =~ m/#!\S*perl\s+-.*T/) {
-        $T = "T";
-    }
-
-    my $libs = '-It ';
-    if ($ENV{PERL5LIB}) {
-       $libs .= join " ", map { "-I\"$_\"" } split /$Config{path_sep}/, $ENV{PERL5LIB};
-    }
-    my $perl = qq{"$^X"};
-    my $output = `$perl $libs -c$T -MSupport::Systemexec $file 2>&1`;
-    chomp($output);
-    my $return_val = $?;
-    $output =~ s/^\Q$file\E syntax OK$//ms;
-    diag($output) if $output;
-    ok(!$return_val, $file) or diag('--ERROR');
+  my ($file) = @_;
+
+  # Don't allow CPAN.pm to modify the global @INC, which the version
+  # shipped with Perl 5.8.8 does. (It gets loaded by
+  # Bugzilla::Install::CPAN.)
+  local @INC = @INC;
+
+  if ($file =~ /extensions/) {
+    skip "$file: extensions not tested", 1;
+    return;
+  }
+
+  if ($file =~ s/\.pm$//) {
+    $file =~ s{/}{::}g;
+    use_ok($file);
+    return;
+  }
+
+  open(my $fh, $file);
+  my $bang = <$fh>;
+  close $fh;
+
+  my $T = "";
+  if ($bang =~ m/#!\S*perl\s+-.*T/) {
+    $T = "T";
+  }
+
+  my $libs = '-It ';
+  if ($ENV{PERL5LIB}) {
+    $libs .= join " ", map {"-I\"$_\""} split /$Config{path_sep}/, $ENV{PERL5LIB};
+  }
+  my $perl   = qq{"$^X"};
+  my $output = `$perl $libs -c$T -MSupport::Systemexec $file 2>&1`;
+  chomp($output);
+  my $return_val = $?;
+  $output =~ s/^\Q$file\E syntax OK$//ms;
+  diag($output) if $output;
+  ok(!$return_val, $file) or diag('--ERROR');
 }
 
 my @testitems = (@Support::Files::testitems, @Support::Files::test_files);
@@ -77,28 +78,28 @@ my $file_features = map_files_to_features();
 
 # Test the scripts by compiling them
 foreach my $file (@testitems) {
-    # These were already compiled, above.
-    next if ($file eq 'Bugzilla.pm'
-             or $file eq 'Bugzilla/Constants.pm'
-             or $file eq 'Bugzilla/Install/Requirements.pm');
-    SKIP: {
-        if ($file eq 'mod_perl.pl') {
-            skip 'mod_perl.pl cannot be compiled from the command line', 1;
-        }
-        my $feature = $file_features->{$file};
-        if ($feature and !Bugzilla->feature($feature)) {
-            skip "$file: $feature not enabled", 1;
-        }
-
-        # Check that we have a DBI module to support the DB, if this
-        # is a database module (but not Schema)
-        if ($file =~ m{Bugzilla/DB/([^/]+)\.pm$}
-            and $file ne "Bugzilla/DB/Schema.pm")
-        {
-            my $module = lc($1);
-            Bugzilla->feature($module) or skip "$file: Driver for $module not installed", 1;
-        }
-
-        compile_file($file);
+
+  # These were already compiled, above.
+  next
+    if ($file eq 'Bugzilla.pm'
+    or $file eq 'Bugzilla/Constants.pm'
+    or $file eq 'Bugzilla/Install/Requirements.pm');
+SKIP: {
+    if ($file eq 'mod_perl.pl') {
+      skip 'mod_perl.pl cannot be compiled from the command line', 1;
     }
+    my $feature = $file_features->{$file};
+    if ($feature and !Bugzilla->feature($feature)) {
+      skip "$file: $feature not enabled", 1;
+    }
+
+    # Check that we have a DBI module to support the DB, if this
+    # is a database module (but not Schema)
+    if ($file =~ m{Bugzilla/DB/([^/]+)\.pm$} and $file ne "Bugzilla/DB/Schema.pm") {
+      my $module = lc($1);
+      Bugzilla->feature($module) or skip "$file: Driver for $module not installed", 1;
+    }
+
+    compile_file($file);
+  }
 }
index 80d7cf2b97dc2e5e1d3d5be58dc1f5efdbd0e9c1..b2a9d5751f7cfa3199f1c43329366a665cdc63db 100644 (file)
@@ -18,169 +18,185 @@ use lib qw(. lib local/lib/perl5 t);
 
 use Support::Files;
 
-use Test::More tests => (scalar(@Support::Files::testitems)
-                         + scalar(@Support::Files::test_files)) * 6;
+use Test::More tests =>
+  (scalar(@Support::Files::testitems) + scalar(@Support::Files::test_files))
+  * 6;
 
 my @testitems = (@Support::Files::test_files, @Support::Files::testitems);
 my @require_taint = qw(email_in.pl importxml.pl mod_perl.pl whine.pl);
 
 foreach my $file (@testitems) {
-    $file =~ s/\s.*$//; # nuke everything after the first space (#comment)
-    next if (!$file); # skip null entries
-    if (! open (FILE, $file)) {
-        ok(0,"could not open $file --WARNING");
+  $file =~ s/\s.*$//;    # nuke everything after the first space (#comment)
+  next if (!$file);      # skip null entries
+  if (!open(FILE, $file)) {
+    ok(0, "could not open $file --WARNING");
+  }
+  my $file_line1 = <FILE>;
+  close(FILE);
+
+  $file =~ m/.*\.(.*)/;
+  my $ext = $1;
+
+  if ($file_line1 !~ m/^#\!/) {
+    ok(1, "$file does not have a shebang");
+  }
+  else {
+    my $flags;
+    if (!defined $ext || $ext eq 'pl' || $ext eq 'psgi') {
+
+      # standalone programs aren't taint checked yet
+      if (grep { $file eq $_ } @require_taint) {
+        $flags = 'T';
+      }
+      else {
+        $flags = '';
+      }
     }
-    my $file_line1 = <FILE>;
-    close (FILE);
-
-    $file =~ m/.*\.(.*)/;
-    my $ext = $1;
-
-    if ($file_line1 !~ m/^#\!/) {
-        ok(1,"$file does not have a shebang");
-    } else {
-        my $flags;
-        if (!defined $ext || $ext eq 'pl' || $ext eq 'psgi') {
-            # standalone programs aren't taint checked yet
-            if (grep { $file eq $_ } @require_taint) {
-                $flags = 'T';
-            }
-            else {
-                $flags = '';
-            }
-        } elsif ($ext eq "pm") {
-            ok(0, "$file is a module, but has a shebang");
-            next;
-        } elsif ($ext eq "cgi") {
-            # cgi files must be taint checked
-            $flags = 'T';
-        } elsif ($ext eq 't') {
-            $flags = '';
-        } else {
-            ok(0, "$file has shebang but unknown extension");
-            next;
-        }
-
-        if ($file_line1 =~ m#^\#\!/usr/bin/perl(?:\s-(\w+))?$#) {
-            my $file_flags = $1 || '';
-            if ($flags eq $file_flags) {
-                ok(1, "$file uses standard perl location" . ($flags ? " and -$flags flag" : ""));
-            }
-            elsif ($flags) {
-                ok(0, "$file is MISSING -$flags flag --WARNING");
-            }
-            else {
-                ok(0, "$file has unexpected -$file_flags flag --WARNING");
-            }
-        } else {
-            ok(0,"$file uses non-standard perl location");
-        }
+    elsif ($ext eq "pm") {
+      ok(0, "$file is a module, but has a shebang");
+      next;
     }
-}
+    elsif ($ext eq "cgi") {
 
-foreach my $file (@testitems) {
-    my $found_use_perl = 0;
-    my $found_use_strict = 0;
-    my $found_use_warnings = 0;
-    my $found_modern_perl = 0;
-    my $found_mojo = 0;
-
-    $file =~ s/\s.*$//; # nuke everything after the first space (#comment)
-    next if (!$file); # skip null entries
-    if (! open (FILE, $file)) {
-        ok(0,"could not open $file --WARNING");
-        next;
+      # cgi files must be taint checked
+      $flags = 'T';
     }
-    while (my $file_line = <FILE>) {
-        $found_modern_perl = 1 if $file_line =~ m/^use\s*(?:Moo|Role::Tiny)/;
-        $found_mojo = 1 if $file_line =~ m/^use\s(?:Mojo(?:licious::Lite|::Base)\b)/;
-        $found_use_perl = 1 if $file_line =~ m/^\s*use 5.10.1/;
-        $found_use_strict = 1 if $file_line =~ m/^\s*use strict/;
-        $found_use_warnings = 1 if $file_line =~ m/^\s*use warnings/;
-        if ($found_modern_perl || $found_mojo) {
-            $found_use_strict = 1;
-            $found_use_warnings = 1;
-        }
-        if ($found_mojo) {
-            $found_use_perl = 1;
-        }
-        last if ($found_use_perl && $found_use_strict && $found_use_warnings);
+    elsif ($ext eq 't') {
+      $flags = '';
     }
-    close (FILE);
-    if ($found_use_perl) {
-        ok(1,"$file requires Perl 5.10.1");
-    } else {
-        ok(0,"$file DOES NOT require Perl 5.10.1 --WARNING");
+    else {
+      ok(0, "$file has shebang but unknown extension");
+      next;
     }
 
-    if ($found_use_strict) {
-        ok(1,"$file uses strict");
-    } else {
-        ok(0,"$file DOES NOT use strict --WARNING");
+    if ($file_line1 =~ m#^\#\!/usr/bin/perl(?:\s-(\w+))?$#) {
+      my $file_flags = $1 || '';
+      if ($flags eq $file_flags) {
+        ok(1,
+          "$file uses standard perl location" . ($flags ? " and -$flags flag" : ""));
+      }
+      elsif ($flags) {
+        ok(0, "$file is MISSING -$flags flag --WARNING");
+      }
+      else {
+        ok(0, "$file has unexpected -$file_flags flag --WARNING");
+      }
+    }
+    else {
+      ok(0, "$file uses non-standard perl location");
     }
+  }
+}
 
-    if ($found_use_warnings) {
-        ok(1,"$file uses warnings");
-    } else {
-        ok(0,"$file DOES NOT use warnings --WARNING");
+foreach my $file (@testitems) {
+  my $found_use_perl     = 0;
+  my $found_use_strict   = 0;
+  my $found_use_warnings = 0;
+  my $found_modern_perl  = 0;
+  my $found_mojo         = 0;
+
+  $file =~ s/\s.*$//;    # nuke everything after the first space (#comment)
+  next if (!$file);      # skip null entries
+  if (!open(FILE, $file)) {
+    ok(0, "could not open $file --WARNING");
+    next;
+  }
+  while (my $file_line = <FILE>) {
+    $found_modern_perl = 1 if $file_line =~ m/^use\s*(?:Moo|Role::Tiny)/;
+    $found_mojo = 1 if $file_line =~ m/^use\s(?:Mojo(?:licious::Lite|::Base)\b)/;
+    $found_use_perl     = 1 if $file_line =~ m/^\s*use 5.10.1/;
+    $found_use_strict   = 1 if $file_line =~ m/^\s*use strict/;
+    $found_use_warnings = 1 if $file_line =~ m/^\s*use warnings/;
+    if ($found_modern_perl || $found_mojo) {
+      $found_use_strict   = 1;
+      $found_use_warnings = 1;
+    }
+    if ($found_mojo) {
+      $found_use_perl = 1;
     }
+    last if ($found_use_perl && $found_use_strict && $found_use_warnings);
+  }
+  close(FILE);
+  if ($found_use_perl) {
+    ok(1, "$file requires Perl 5.10.1");
+  }
+  else {
+    ok(0, "$file DOES NOT require Perl 5.10.1 --WARNING");
+  }
+
+  if ($found_use_strict) {
+    ok(1, "$file uses strict");
+  }
+  else {
+    ok(0, "$file DOES NOT use strict --WARNING");
+  }
+
+  if ($found_use_warnings) {
+    ok(1, "$file uses warnings");
+  }
+  else {
+    ok(0, "$file DOES NOT use warnings --WARNING");
+  }
 }
 
 # Check to see that all error messages use tags (for l10n reasons.)
 foreach my $file (@testitems) {
-    $file =~ s/\s.*$//; # nuke everything after the first space (#comment)
-    next if (!$file); # skip null entries
-    if (! open (FILE, $file)) {
-        ok(0,"could not open $file --WARNING");
-        next;
-    }
-    my $lineno = 0;
-    my $error = 0;
-
-    while (!$error && (my $file_line = <FILE>)) {
-        $lineno++;
-        if ($file_line =~ /Throw.*Error\("(.*?)"/) {
-            if ($1 =~ /\s/) {
-                ok(0,"$file has a Throw*Error call on line $lineno
-                      which doesn't use a tag --ERROR");
-                $error = 1;
-            }
-        }
+  $file =~ s/\s.*$//;    # nuke everything after the first space (#comment)
+  next if (!$file);      # skip null entries
+  if (!open(FILE, $file)) {
+    ok(0, "could not open $file --WARNING");
+    next;
+  }
+  my $lineno = 0;
+  my $error  = 0;
+
+  while (!$error && (my $file_line = <FILE>)) {
+    $lineno++;
+    if ($file_line =~ /Throw.*Error\("(.*?)"/) {
+      if ($1 =~ /\s/) {
+        ok(
+          0, "$file has a Throw*Error call on line $lineno
+                      which doesn't use a tag --ERROR"
+        );
+        $error = 1;
+      }
     }
+  }
 
-    ok(1,"$file uses Throw*Error calls correctly") if !$error;
+  ok(1, "$file uses Throw*Error calls correctly") if !$error;
 
-    close(FILE);
+  close(FILE);
 }
 
 # Forbird the { foo => $cgi->param() } syntax, for security reasons.
 foreach my $file (@testitems) {
-    $file =~ s/\s.*$//; # nuke everything after the first space (#comment)
-    next unless $file; # skip null entries
-    if (!open(FILE, $file)) {
-        ok(0, "could not open $file --WARNING");
-        next;
-    }
-    my $lineno = 0;
-    my @unsafe_args;
-
-    while (my $file_line = <FILE>) {
-        $lineno++;
-        $file_line =~ s/^\s*(.+)\s*$/$1/; # Remove leading and trailing whitespaces.
-        if ($file_line =~ /^[^#]+=> \$cgi\->param/) {
-            push(@unsafe_args, "$file_line on line $lineno");
-        }
-    }
-
-    if (@unsafe_args) {
-        ok(0, "$file incorrectly passes a CGI argument to a hash --ERROR\n" .
-              join("\n", @unsafe_args));
+  $file =~ s/\s.*$//;    # nuke everything after the first space (#comment)
+  next unless $file;     # skip null entries
+  if (!open(FILE, $file)) {
+    ok(0, "could not open $file --WARNING");
+    next;
+  }
+  my $lineno = 0;
+  my @unsafe_args;
+
+  while (my $file_line = <FILE>) {
+    $lineno++;
+    $file_line =~ s/^\s*(.+)\s*$/$1/;    # Remove leading and trailing whitespaces.
+    if ($file_line =~ /^[^#]+=> \$cgi\->param/) {
+      push(@unsafe_args, "$file_line on line $lineno");
     }
-    else {
-        ok(1, "$file has no vulnerable hash syntax");
-    }
-
-    close(FILE);
+  }
+
+  if (@unsafe_args) {
+    ok(0,
+      "$file incorrectly passes a CGI argument to a hash --ERROR\n"
+        . join("\n", @unsafe_args));
+  }
+  else {
+    ok(1, "$file has no vulnerable hash syntax");
+  }
+
+  close(FILE);
 }
 
 exit 0;
index 909f1a231d9285b59e701026965549118cd52161..61e895bf2f9ca97450db07d76e8ce0a89ce9f4d0 100644 (file)
@@ -22,20 +22,22 @@ use CGI qw(-no_debug);
 
 use File::Spec;
 use Template;
-use Test::More tests => ( scalar(@referenced_files) + 2 * $num_actual_files );
+use Test::More tests => (scalar(@referenced_files) + 2 * $num_actual_files);
 
 # Capture the TESTOUT from Test::More or Test::Builder for printing errors.
 # This will handle verbosity for us automatically.
 my $fh;
 {
-    no warnings qw(unopened);  # Don't complain about non-existent filehandles
-    if (-e \*Test::More::TESTOUT) {
-        $fh = \*Test::More::TESTOUT;
-    } elsif (-e \*Test::Builder::TESTOUT) {
-        $fh = \*Test::Builder::TESTOUT;
-    } else {
-        $fh = \*STDOUT;
-    }
+  no warnings qw(unopened);    # Don't complain about non-existent filehandles
+  if (-e \*Test::More::TESTOUT) {
+    $fh = \*Test::More::TESTOUT;
+  }
+  elsif (-e \*Test::Builder::TESTOUT) {
+    $fh = \*Test::Builder::TESTOUT;
+  }
+  else {
+    $fh = \*STDOUT;
+  }
 }
 
 # Check to make sure all templates that are referenced in Bugzilla
@@ -44,80 +46,89 @@ my $fh;
 # fall back to English if necessary.
 
 foreach my $file (@referenced_files) {
-    my $found = 0;
-    foreach my $path (@english_default_include_paths) {
-        my $pathfile = File::Spec->catfile($path, $file);
-        if (-e $pathfile) {
-            $found = 1;
-            last;
-        }
+  my $found = 0;
+  foreach my $path (@english_default_include_paths) {
+    my $pathfile = File::Spec->catfile($path, $file);
+    if (-e $pathfile) {
+      $found = 1;
+      last;
     }
+  }
 
-    ok($found, "$file found");
+  ok($found, "$file found");
 }
 
 foreach my $include_path (@include_paths) {
-    # Processes all the templates to make sure they have good syntax
-    my $provider = Template::Provider->new(
-    {
-        INCLUDE_PATH => $include_path ,
-        # Need to define filters used in the codebase, they don't
-        # actually have to function in this test, just be defined.
-        # See Template.pm for the actual codebase definitions.
-
-        # Initialize templates (f.e. by loading plugins like Hook).
-        PRE_PROCESS => "global/variables.none.tmpl",
-
-        FILTERS =>
-        {
-            html_linebreak => sub { return $_; },
-            js        => sub { return $_ } ,
-            base64   => sub { return $_ } ,
-            url_quote => sub { return $_ } ,
-            css_class_quote => sub { return $_ } ,
-            xml       => sub { return $_ } ,
-            quoteUrls => sub { return $_ } ,
-            bug_link => [ sub { return sub { return $_; } }, 1] ,
-            csv       => sub { return $_ } ,
-            unitconvert => sub { return $_ },
-            time      => sub { return $_ } ,
-            wrap_comment => sub { return $_ },
-            none      => sub { return $_ } ,
-            ics       => [ sub { return sub { return $_; } }, 1] ,
-            markdown => sub { return $_ } ,
+
+  # Processes all the templates to make sure they have good syntax
+  my $provider = Template::Provider->new({
+    INCLUDE_PATH => $include_path,
+
+    # Need to define filters used in the codebase, they don't
+    # actually have to function in this test, just be defined.
+    # See Template.pm for the actual codebase definitions.
+
+    # Initialize templates (f.e. by loading plugins like Hook).
+    PRE_PROCESS => "global/variables.none.tmpl",
+
+    FILTERS => {
+      html_linebreak  => sub { return $_; },
+      js              => sub { return $_ },
+      base64          => sub { return $_ },
+      url_quote       => sub { return $_ },
+      css_class_quote => sub { return $_ },
+      xml             => sub { return $_ },
+      quoteUrls       => sub { return $_ },
+      bug_link        => [
+        sub {
+          return sub { return $_; }
+        },
+        1
+      ],
+      csv          => sub { return $_ },
+      unitconvert  => sub { return $_ },
+      time         => sub { return $_ },
+      wrap_comment => sub { return $_ },
+      none         => sub { return $_ },
+      ics          => [
+        sub {
+          return sub { return $_; }
         },
+        1
+      ],
+      markdown => sub { return $_ },
+    },
+  });
+
+  foreach my $file (@{$actual_files{$include_path}}) {
+    my $path = File::Spec->catfile($include_path, $file);
+
+    # These are actual files, so there's no need to check for existence.
+
+    my ($data, $err) = $provider->fetch($file);
+
+    if (!$err) {
+      ok(1, "$path syntax ok");
+    }
+    else {
+      ok(0, "$path has bad syntax --ERROR");
+      print $fh $data . "\n";
+    }
+
+    # Make sure no forbidden constructs are present.
+    local $/;
+    open(FILE, '<', $path) or die "Can't open $file: $!\n";
+    $data = <FILE>;
+    close(FILE);
+
+    # Forbid single quotes to delimit URLs, see bug 926085.
+    if ($data =~ /href=\\?'/) {
+      ok(0, "$path contains blacklisted constructs: href='...'");
     }
-    );
-
-    foreach my $file (@{$actual_files{$include_path}}) {
-        my $path = File::Spec->catfile($include_path, $file);
-
-        # These are actual files, so there's no need to check for existence.
-
-        my ($data, $err) = $provider->fetch($file);
-
-        if (!$err) {
-            ok(1, "$path syntax ok");
-        }
-        else {
-            ok(0, "$path has bad syntax --ERROR");
-            print $fh $data . "\n";
-        }
-
-        # Make sure no forbidden constructs are present.
-        local $/;
-        open(FILE, '<', $path) or die "Can't open $file: $!\n";
-        $data = <FILE>;
-        close (FILE);
-
-        # Forbid single quotes to delimit URLs, see bug 926085.
-        if ($data =~ /href=\\?'/) {
-            ok(0, "$path contains blacklisted constructs: href='...'");
-        }
-        else {
-            ok(1, "$path contains no blacklisted constructs");
-        }
+    else {
+      ok(1, "$path contains no blacklisted constructs");
     }
+  }
 }
 
 exit 0;
index be13890bb930ee0ddf4885b02a2546c70e966d54..492e3bee100915eb8edb73cb39ea7ee1f4efa1bb 100644 (file)
@@ -19,49 +19,57 @@ use Support::Files;
 use Support::Templates;
 
 use File::Spec;
-use Test::More tests => (scalar(@Support::Files::testitems)
-                         + scalar(@Support::Files::test_files)
-                         + $Support::Templates::num_actual_files) * 3;
+use Test::More tests => (
+      scalar(@Support::Files::testitems)
+    + scalar(@Support::Files::test_files)
+    + $Support::Templates::num_actual_files)
+  * 3;
 
 my @testitems = (@Support::Files::testitems, @Support::Files::test_files);
 for my $path (@Support::Templates::include_paths) {
-   push(@testitems, map(File::Spec->catfile($path, $_),
-                        Support::Templates::find_actual_files($path)));
+  push(
+    @testitems,
+    map(File::Spec->catfile($path, $_),
+      Support::Templates::find_actual_files($path))
+  );
 }
 
 my %results;
 
 foreach my $file (@testitems) {
-    open (FILE, "$file");
-    my @contents = <FILE>;
-    if (grep /\t/, @contents) {
-        ok(0, "$file contains tabs --WARNING");
-    } else {
-        ok(1, "$file has no tabs");
-    }
-    close (FILE);
+  open(FILE, "$file");
+  my @contents = <FILE>;
+  if (grep /\t/, @contents) {
+    ok(0, "$file contains tabs --WARNING");
+  }
+  else {
+    ok(1, "$file has no tabs");
+  }
+  close(FILE);
 }
 
 foreach my $file (@testitems) {
-    open (FILE, "$file");
-    my @contents = <FILE>;
-    if (grep /\r/, @contents) {
-        ok(0, "$file contains non-OS-conformant line endings --WARNING");
-    } else {
-        ok(1, "All line endings of $file are OS conformant");
-    }
-    close (FILE);
+  open(FILE, "$file");
+  my @contents = <FILE>;
+  if (grep /\r/, @contents) {
+    ok(0, "$file contains non-OS-conformant line endings --WARNING");
+  }
+  else {
+    ok(1, "All line endings of $file are OS conformant");
+  }
+  close(FILE);
 }
 
 foreach my $file (@testitems) {
-    open (FILE, "$file");
-    my $first_line = <FILE>;
-    if ($first_line =~ /\xef\xbb\xbf/) {
-        ok(0, "$file contains Byte Order Mark --WARNING");
-    } else {
-        ok(1, "$file is free of a Byte Order Mark");
-    }
-    close (FILE);
+  open(FILE, "$file");
+  my $first_line = <FILE>;
+  if ($first_line =~ /\xef\xbb\xbf/) {
+    ok(0, "$file contains Byte Order Mark --WARNING");
+  }
+  else {
+    ok(1, "$file is free of a Byte Order Mark");
+  }
+  close(FILE);
 }
 
 exit 0;
index a7e7c6d7242bdfa067399134552e5ce47d872e99..c7644995713b14d868979664f5cb0ca3d2dadef8 100644 (file)
@@ -19,73 +19,77 @@ use Support::Files;
 
 # -1 because 006spellcheck.t must not be checked.
 use Test::More tests => scalar(@Support::Files::testitems)
-                        + scalar(@Support::Files::test_files) - 1;
+  + scalar(@Support::Files::test_files) - 1;
 
 # Capture the TESTOUT from Test::More or Test::Builder for printing errors.
 # This will handle verbosity for us automatically.
 my $fh;
 {
-    no warnings qw(unopened);  # Don't complain about non-existent filehandles
-    if (-e \*Test::More::TESTOUT) {
-        $fh = \*Test::More::TESTOUT;
-    } elsif (-e \*Test::Builder::TESTOUT) {
-        $fh = \*Test::Builder::TESTOUT;
-    } else {
-        $fh = \*STDOUT;
-    }
+  no warnings qw(unopened);    # Don't complain about non-existent filehandles
+  if (-e \*Test::More::TESTOUT) {
+    $fh = \*Test::More::TESTOUT;
+  }
+  elsif (-e \*Test::Builder::TESTOUT) {
+    $fh = \*Test::Builder::TESTOUT;
+  }
+  else {
+    $fh = \*STDOUT;
+  }
 }
 
 my @testitems = (@Support::Files::testitems, @Support::Files::test_files);
 
 #add the words to check here:
 my @evilwords = qw(
-    anyways
-    appearence
-    arbitary
-    cancelled
-    critera
-    databasa
-    dependan
-    existance
-    existant
-    paramater
-    refered
-    repsentation
-    retreive
-    suported
-    varsion
+  anyways
+  appearence
+  arbitary
+  cancelled
+  critera
+  databasa
+  dependan
+  existance
+  existant
+  paramater
+  refered
+  repsentation
+  retreive
+  suported
+  varsion
 );
 
 my $evilwordsregexp = join('|', @evilwords);
 
 foreach my $file (@testitems) {
-    $file =~ s/\s.*$//; # nuke everything after the first space (#comment)
-    next if (!$file); # skip null entries
-    # Do not try to validate this file as it obviously contains a list
-    # of wrongly spelled words.
-    next if ($file eq 't/006spellcheck.t');
-
-    if (open (FILE, $file)) { # open the file for reading
-
-        my $found_word = '';
-
-        while (my $file_line = <FILE>) { # and go through the file line by line
-            if ($file_line =~ /($evilwordsregexp)/i) { # found an evil word
-                $found_word = $1;
-                last;
-            }
-        }
-
-        close (FILE);
-
-        if ($found_word) {
-            ok(0,"$file: found SPELLING ERROR $found_word --WARNING");
-        } else {
-            ok(1,"$file does not contain registered spelling errors");
-        }
-    } else {
-        ok(0,"could not open $file for spellcheck --WARNING");
+  $file =~ s/\s.*$//;    # nuke everything after the first space (#comment)
+  next if (!$file);      # skip null entries
+       # Do not try to validate this file as it obviously contains a list
+       # of wrongly spelled words.
+  next if ($file eq 't/006spellcheck.t');
+
+  if (open(FILE, $file)) {    # open the file for reading
+
+    my $found_word = '';
+
+    while (my $file_line = <FILE>) {    # and go through the file line by line
+      if ($file_line =~ /($evilwordsregexp)/i) {    # found an evil word
+        $found_word = $1;
+        last;
+      }
+    }
+
+    close(FILE);
+
+    if ($found_word) {
+      ok(0, "$file: found SPELLING ERROR $found_word --WARNING");
+    }
+    else {
+      ok(1, "$file does not contain registered spelling errors");
     }
+  }
+  else {
+    ok(0, "could not open $file for spellcheck --WARNING");
+  }
 }
 
 exit 0;
index b6d23bc32e6657d790f82ace1cd2ac5c0aed03b6..e25c66fe9bac2e956ccddb62d4ca5d4d2dd0b693 100644 (file)
@@ -19,8 +19,8 @@ use Test::More tests => 17;
 use DateTime;
 
 BEGIN {
-    use_ok('Bugzilla');
-    use_ok('Bugzilla::Util');
+  use_ok('Bugzilla');
+  use_ok('Bugzilla::Util');
 }
 
 # We need to override user preferences so we can get an expected value when
@@ -29,38 +29,57 @@ Bugzilla->user->{'settings'}->{'timezone'}->{'value'} = "local";
 
 # We need to know the local timezone for the date chosen in our tests.
 # Below, tests are run against Nov. 24, 2002.
-my $tz = Bugzilla->local_timezone->short_name_for_datetime(DateTime->new(year => 2002, month => 11, day => 24));
+my $tz = Bugzilla->local_timezone->short_name_for_datetime(
+  DateTime->new(year => 2002, month => 11, day => 24));
 
 # we don't test the taint functions since that's going to take some more work.
 # XXX: test taint functions
 
 #html_quote():
-is(html_quote("<lala&@>"),"&lt;lala&amp;&#64;&gt;",'html_quote');
+is(html_quote("<lala&@>"), "&lt;lala&amp;&#64;&gt;", 'html_quote');
 
 #url_quote():
-is(url_quote("<lala&>gaa\"'[]{\\"),"%3Clala%26%3Egaa%22%27%5B%5D%7B%5C",'url_quote');
+is(url_quote("<lala&>gaa\"'[]{\\"),
+  "%3Clala%26%3Egaa%22%27%5B%5D%7B%5C", 'url_quote');
 
 #trim():
-is(trim(" fg<*\$%>+=~~ "),'fg<*$%>+=~~','trim()');
+is(trim(" fg<*\$%>+=~~ "), 'fg<*$%>+=~~', 'trim()');
 
 #format_time();
-is(format_time("2002.11.24 00:05"), "2002-11-24 00:05 $tz",'format_time("2002.11.24 00:05") is ' . format_time("2002.11.24 00:05"));
-is(format_time("2002.11.24 00:05:56"), "2002-11-24 00:05:56 $tz",'format_time("2002.11.24 00:05:56")');
-is(format_time("2002.11.24 00:05:56", "%Y-%m-%d %R"), '2002-11-24 00:05', 'format_time("2002.11.24 00:05:56", "%Y-%m-%d %R") (with no timezone)');
-is(format_time("2002.11.24 00:05:56", "%Y-%m-%d %R %Z"), "2002-11-24 00:05 $tz", 'format_time("2002.11.24 00:05:56", "%Y-%m-%d %R %Z") (with timezone)');
+is(
+  format_time("2002.11.24 00:05"),
+  "2002-11-24 00:05 $tz",
+  'format_time("2002.11.24 00:05") is ' . format_time("2002.11.24 00:05")
+);
+is(
+  format_time("2002.11.24 00:05:56"),
+  "2002-11-24 00:05:56 $tz",
+  'format_time("2002.11.24 00:05:56")'
+);
+is(
+  format_time("2002.11.24 00:05:56", "%Y-%m-%d %R"),
+  '2002-11-24 00:05',
+  'format_time("2002.11.24 00:05:56", "%Y-%m-%d %R") (with no timezone)'
+);
+is(
+  format_time("2002.11.24 00:05:56", "%Y-%m-%d %R %Z"),
+  "2002-11-24 00:05 $tz",
+  'format_time("2002.11.24 00:05:56", "%Y-%m-%d %R %Z") (with timezone)'
+);
 
 # email_filter
 my %email_strings = (
-    'somebody@somewhere.com' => 'somebody',
-    'Somebody <somebody@somewhere.com>' => 'Somebody <somebody>',
-    'One Person <one@person.com>, Two Person <two@person.com>'
-        => 'One Person <one>, Two Person <two>',
-    'This string contains somebody@somewhere.com and also this@that.com'
-        => 'This string contains somebody and also this',
+  'somebody@somewhere.com'            => 'somebody',
+  'Somebody <somebody@somewhere.com>' => 'Somebody <somebody>',
+  'One Person <one@person.com>, Two Person <two@person.com>' =>
+    'One Person <one>, Two Person <two>',
+  'This string contains somebody@somewhere.com and also this@that.com' =>
+    'This string contains somebody and also this',
 );
+
 foreach my $input (keys %email_strings) {
-    is(Bugzilla::Util::email_filter($input), $email_strings{$input},
-       "email_filter('$input')");
+  is(Bugzilla::Util::email_filter($input),
+    $email_strings{$input}, "email_filter('$input')");
 }
 
 # validate_email_syntax. We need to override some parameters.
@@ -68,14 +87,18 @@ my $params = Bugzilla->params;
 $params->{emailregexp} = '.*';
 $params->{emailsuffix} = '';
 my $ascii_email = 'admin@company.com';
+
 # U+0430 returns the Cyrillic "а", which looks similar to the ASCII "a".
 my $utf8_email = "\N{U+0430}dmin\@company.com";
-ok(validate_email_syntax($ascii_email), 'correctly formatted ASCII-only email address is valid');
-ok(!validate_email_syntax($utf8_email), 'correctly formatted email address with non-ASCII characters is rejected');
+ok(validate_email_syntax($ascii_email),
+  'correctly formatted ASCII-only email address is valid');
+ok(!validate_email_syntax($utf8_email),
+  'correctly formatted email address with non-ASCII characters is rejected');
 
 # diff_arrays():
 my @old_array = qw(alpha beta alpha gamma gamma beta alpha delta epsilon gamma);
 my @new_array = qw(alpha alpha beta gamma epsilon delta beta delta);
+
 # The order is not relevant when comparing both arrays for matching items,
 # i.e. (foo bar) and (bar foo) are the same arrays (same items).
 # But when returning data, we try to respect the initial order.
@@ -83,5 +106,6 @@ my @new_array = qw(alpha alpha beta gamma epsilon delta beta delta);
 # Removed (in this order): gamma alpha gamma.
 # Added (in this order): delta
 my ($removed, $added) = diff_arrays(\@old_array, \@new_array);
-is_deeply($removed, [qw(gamma alpha gamma)], 'diff_array(\@old, \@new) (check removal)');
+is_deeply($removed, [qw(gamma alpha gamma)],
+  'diff_array(\@old, \@new) (check removal)');
 is_deeply($added, [qw(delta)], 'diff_array(\@old, \@new) (check addition)');
index d86e6c7a65d6df7a0211fa3a29bee36bf9dd3fce..6c9924020d04151bb2374813db917add14da4437 100644 (file)
@@ -29,196 +29,200 @@ use Cwd;
 
 # Undefine the record separator so we can read in whole files at once
 my $oldrecsep = $/;
-my $topdir = cwd;
+my $topdir    = cwd;
 $/ = undef;
 our %safe;
 
 foreach my $path (@Support::Templates::include_paths) {
-    $path =~ s|\\|/|g if ON_WINDOWS;  # convert \ to / in path if on windows
-    $path =~ m|template/([^/]+)/([^/]+)|;
-    my $lang = $1;
-    my $flavor = $2;
-
-    chdir $topdir; # absolute path
-    my @testitems = Support::Templates::find_actual_files($path);
-    chdir $topdir; # absolute path
-
-    next unless @testitems;
-
-    # Some people require this, others don't. No-one knows why.
-    chdir $path; # relative path
-
-    # We load a %safe list of acceptable exceptions.
-    if (-r "filterexceptions.pl") {
-        do "filterexceptions.pl";
-        if (ON_WINDOWS) {
-          # filterexceptions.pl uses / separated paths, while
-          # find_actual_files returns \ separated ones on Windows.
-          # Here, we convert the filter exception hash to use \.
-          foreach my $file (keys %safe) {
-            my $orig_file = $file;
-            $file =~ s|/|\\|g;
-            if ($file ne $orig_file) {
-              $safe{$file} = $safe{$orig_file};
-              delete $safe{$orig_file};
-            }
-          }
+  $path =~ s|\\|/|g if ON_WINDOWS;    # convert \ to / in path if on windows
+  $path =~ m|template/([^/]+)/([^/]+)|;
+  my $lang   = $1;
+  my $flavor = $2;
+
+  chdir $topdir;                      # absolute path
+  my @testitems = Support::Templates::find_actual_files($path);
+  chdir $topdir;                      # absolute path
+
+  next unless @testitems;
+
+  # Some people require this, others don't. No-one knows why.
+  chdir $path;                        # relative path
+
+  # We load a %safe list of acceptable exceptions.
+  if (-r "filterexceptions.pl") {
+    do "filterexceptions.pl";
+    if (ON_WINDOWS) {
+
+      # filterexceptions.pl uses / separated paths, while
+      # find_actual_files returns \ separated ones on Windows.
+      # Here, we convert the filter exception hash to use \.
+      foreach my $file (keys %safe) {
+        my $orig_file = $file;
+        $file =~ s|/|\\|g;
+        if ($file ne $orig_file) {
+          $safe{$file} = $safe{$orig_file};
+          delete $safe{$orig_file};
         }
+      }
     }
-
-    # We preprocess the %safe hash of lists into a hash of hashes. This allows
-    # us to flag which members were not found, and report that as a warning,
-    # thereby keeping the lists clean.
-    foreach my $file (keys %safe) {
-        if (ref $safe{$file} eq 'ARRAY') {
-            my $list = $safe{$file};
-            $safe{$file} = {};
-            foreach my $directive (@$list) {
-                $safe{$file}{$directive} = 0;
-            }
-        }
+  }
+
+  # We preprocess the %safe hash of lists into a hash of hashes. This allows
+  # us to flag which members were not found, and report that as a warning,
+  # thereby keeping the lists clean.
+  foreach my $file (keys %safe) {
+    if (ref $safe{$file} eq 'ARRAY') {
+      my $list = $safe{$file};
+      $safe{$file} = {};
+      foreach my $directive (@$list) {
+        $safe{$file}{$directive} = 0;
+      }
     }
+  }
 
-    foreach my $file (@testitems) {
-        # There are some files we don't check, because there is no need to
-        # filter their contents due to their content-type.
-        if ($file =~ /\.(pm|txt|rst|png)\.tmpl$/) {
-            ok(1, "($lang/$flavor) $file is filter-safe");
-            next;
-        }
+  foreach my $file (@testitems) {
 
-        # Read the entire file into a string
-        open (FILE, "<$file") || die "Can't open $file: $!\n";
-        my $slurp = <FILE>;
-        close (FILE);
+    # There are some files we don't check, because there is no need to
+    # filter their contents due to their content-type.
+    if ($file =~ /\.(pm|txt|rst|png)\.tmpl$/) {
+      ok(1, "($lang/$flavor) $file is filter-safe");
+      next;
+    }
 
-        my @unfiltered;
+    # Read the entire file into a string
+    open(FILE, "<$file") || die "Can't open $file: $!\n";
+    my $slurp = <FILE>;
+    close(FILE);
 
-        # /g means we execute this loop for every match
-        # /s means we ignore linefeeds in the regexp matches
-        while ($slurp =~ /\[%(?:-|\+|~|=)?(.*?)(?:-|\+|~|=)?%\]/gs) {
-            my $directive = $1;
+    my @unfiltered;
 
-            my @lineno = ($` =~ m/\n/gs);
-            my $lineno = scalar(@lineno) + 1;
+    # /g means we execute this loop for every match
+    # /s means we ignore linefeeds in the regexp matches
+    while ($slurp =~ /\[%(?:-|\+|~|=)?(.*?)(?:-|\+|~|=)?%\]/gs) {
+      my $directive = $1;
 
-            if (!directive_ok($file, $directive)) {
+      my @lineno = ($` =~ m/\n/gs);
+      my $lineno = scalar(@lineno) + 1;
 
-              # This intentionally makes no effort to eliminate duplicates; to do
-              # so would merely make it more likely that the user would not
-              # escape all instances when attempting to correct an error.
-              push(@unfiltered, "$lineno:$directive");
-            }
-        }
+      if (!directive_ok($file, $directive)) {
 
-        my $fullpath = File::Spec->catfile($path, $file);
+        # This intentionally makes no effort to eliminate duplicates; to do
+        # so would merely make it more likely that the user would not
+        # escape all instances when attempting to correct an error.
+        push(@unfiltered, "$lineno:$directive");
+      }
+    }
 
-        if (@unfiltered) {
-            my $uflist = join("\n  ", @unfiltered);
-            ok(0, "($lang/$flavor) $fullpath has unfiltered directives:\n  $uflist\n--ERROR");
-        }
-        else {
-            # Find any members of the exclusion list which were not found
-            my @notfound;
-            foreach my $directive (keys %{$safe{$file}}) {
-                push(@notfound, $directive) if ($safe{$file}{$directive} == 0);
-            }
-
-            if (@notfound) {
-                my $nflist = join("\n  ", @notfound);
-                ok(0, "($lang/$flavor) $fullpath - filterexceptions.pl has extra members:\n  $nflist\n" .
-                                                                  "--WARNING");
-            }
-            else {
-                # Don't use the full path here - it's too long and unwieldy.
-                ok(1, "($lang/$flavor) $file is filter-safe");
-            }
-        }
+    my $fullpath = File::Spec->catfile($path, $file);
+
+    if (@unfiltered) {
+      my $uflist = join("\n  ", @unfiltered);
+      ok(0,
+        "($lang/$flavor) $fullpath has unfiltered directives:\n  $uflist\n--ERROR");
     }
+    else {
+      # Find any members of the exclusion list which were not found
+      my @notfound;
+      foreach my $directive (keys %{$safe{$file}}) {
+        push(@notfound, $directive) if ($safe{$file}{$directive} == 0);
+      }
+
+      if (@notfound) {
+        my $nflist = join("\n  ", @notfound);
+        ok(0,
+          "($lang/$flavor) $fullpath - filterexceptions.pl has extra members:\n  $nflist\n"
+            . "--WARNING");
+      }
+      else {
+        # Don't use the full path here - it's too long and unwieldy.
+        ok(1, "($lang/$flavor) $file is filter-safe");
+      }
+    }
+  }
 }
 
 sub directive_ok {
-    my ($file, $directive) = @_;
+  my ($file, $directive) = @_;
 
-    # Comments
-    return 1 if $directive =~ /^#/;
+  # Comments
+  return 1 if $directive =~ /^#/;
 
-    # Remove any leading/trailing whitespace.
-    $directive =~ s/^\s*//;
-    $directive =~ s/\s*$//;
+  # Remove any leading/trailing whitespace.
+  $directive =~ s/^\s*//;
+  $directive =~ s/\s*$//;
 
-    # Ignore blocks explicitly marked as ok
-    return 1 if $directive =~ /\b## no-008filter\b/;
+  # Ignore blocks explicitly marked as ok
+  return 1 if $directive =~ /\b## no-008filter\b/;
 
-    # Empty directives are ok; they are usually line break helpers
-    return 1 if $directive eq '';
+  # Empty directives are ok; they are usually line break helpers
+  return 1 if $directive eq '';
 
-    # Make sure we're not looking for ./ in the $safe hash
-    $file =~ s#^\./##;
+  # Make sure we're not looking for ./ in the $safe hash
+  $file =~ s#^\./##;
 
-    # Exclude those on the nofilter list
-    if (defined($safe{$file}{$directive})) {
-        $safe{$file}{$directive}++;
-        return 1;
-    };
+  # Exclude those on the nofilter list
+  if (defined($safe{$file}{$directive})) {
+    $safe{$file}{$directive}++;
+    return 1;
+  }
 
-    # Directives
-    return 1 if $directive =~ /^(IF|END|UNLESS|FOREACH|PROCESS|INCLUDE|
+  # Directives
+  return 1 if $directive =~ /^(IF|END|UNLESS|FOREACH|PROCESS|INCLUDE|
                                  BLOCK|USE|ELSE|NEXT|LAST|DEFAULT|FLUSH|
                                  ELSIF|SET|SWITCH|CASE|WHILE|RETURN|STOP|
                                  TRY|CATCH|FINAL|THROW|CLEAR|MACRO|FILTER|
                                  RAWPERL|PERL|CALL|WRAPPER)/x;
 
-    # ? :
-    if ($directive =~ /.+\?(.+):(.+)/) {
-        return 1 if directive_ok($file, $1) && directive_ok($file, $2);
-    }
+  # ? :
+  if ($directive =~ /.+\?(.+):(.+)/) {
+    return 1 if directive_ok($file, $1) && directive_ok($file, $2);
+  }
 
-    # + - * /
-    return 1 if $directive =~ /[+\-*\/]/;
+  # + - * /
+  return 1 if $directive =~ /[+\-*\/]/;
 
-    # Numbers
-    return 1 if $directive =~ /^[0-9]+$/;
+  # Numbers
+  return 1 if $directive =~ /^[0-9]+$/;
 
-    # Simple assignments
-    return 1 if $directive =~ /^[\w\.\$\{\}]+\s+=\s+/;
+  # Simple assignments
+  return 1 if $directive =~ /^[\w\.\$\{\}]+\s+=\s+/;
 
-    # Conditional literals with either sort of quotes
-    # There must be no $ in the string for it to be a literal
-    return 1 if $directive =~ /^(["'])[^\$]*[^\\]\1/;
-    return 1 if $directive =~ /^(["'])\1/;
+  # Conditional literals with either sort of quotes
+  # There must be no $ in the string for it to be a literal
+  return 1 if $directive =~ /^(["'])[^\$]*[^\\]\1/;
+  return 1 if $directive =~ /^(["'])\1/;
 
-    # Special values always used for numbers
-    return 1 if $directive =~ /^[ijkn]$/;
-    return 1 if $directive =~ /^count$/;
+  # Special values always used for numbers
+  return 1 if $directive =~ /^[ijkn]$/;
+  return 1 if $directive =~ /^count$/;
 
-    # Params
-    return 1 if $directive =~ /^Param\(/;
+  # Params
+  return 1 if $directive =~ /^Param\(/;
 
-    # Hooks
-    return 1 if $directive =~ /^Hook.process\(/;
+  # Hooks
+  return 1 if $directive =~ /^Hook.process\(/;
 
-    # Other functions guaranteed to return OK output
-    return 1 if $directive =~ /^(time2str|url)\(/;
+  # Other functions guaranteed to return OK output
+  return 1 if $directive =~ /^(time2str|url)\(/;
 
-    # Safe Template Toolkit virtual methods
-    return 1 if $directive =~ /\.(length$|size$|push\(|unshift\(|delete\()/;
+  # Safe Template Toolkit virtual methods
+  return 1 if $directive =~ /\.(length$|size$|push\(|unshift\(|delete\()/;
 
-    # Special Template Toolkit loop variable
-    return 1 if $directive =~ /^loop\.(index|count)$/;
+  # Special Template Toolkit loop variable
+  return 1 if $directive =~ /^loop\.(index|count)$/;
 
-    # Branding terms
-    return 1 if $directive =~ /^terms\./;
+  # Branding terms
+  return 1 if $directive =~ /^terms\./;
 
-    # Things which are already filtered
-    # Note: If a single directive prints two things, and only one is
-    # filtered, we may not catch that case.
-    return 1 if $directive =~ /FILTER\ (html|csv|js|base64|css_class_quote|ics|
+  # Things which are already filtered
+  # Note: If a single directive prints two things, and only one is
+  # filtered, we may not catch that case.
+  return 1 if $directive =~ /FILTER\ (html|csv|js|base64|css_class_quote|ics|
                                         quoteUrls|time|uri|xml|lower|html_light|
                                         obsolete|inactive|closed|unitconvert|
                                         txt|html_linebreak|none|json|null|id|
                                         markdown)\b/x;
-    return 0;
+  return 0;
 }
 
 $/ = $oldrecsep;
index ebfd995076d77d5001872aa837a3d867e83795ff..48a60151362683a001a0958dda1f015345e5c7fb 100644 (file)
@@ -32,48 +32,52 @@ use Test::More tests => ($Support::Templates::num_actual_files);
 # Find all the templates
 my @testitems;
 for my $path (@Support::Templates::include_paths) {
-    push(@testitems, map(File::Spec->catfile($path, $_),
-                         Support::Templates::find_actual_files($path)));
+  push(
+    @testitems,
+    map(File::Spec->catfile($path, $_),
+      Support::Templates::find_actual_files($path))
+  );
 }
 
 foreach my $file (@testitems) {
-    my @errors;
-
-    # Read the entire file into a string
-    local $/;
-    open (FILE, "<$file") || die "Can't open $file: $!\n";
-    my $slurp = <FILE>;
-    close (FILE);
-
-    # /g means we execute this loop for every match
-    # /s means we ignore linefeeds in the regexp matches
-    # This extracts everything which is _not_ a directive.
-    while ($slurp =~ /%\](.*?)(\[%|$)/gs) {
-        my $text = $1;
-
-        my @lineno = ($` =~ m/\n/gs);
-        my $lineno = scalar(@lineno) + 1;
-
-        # "a bug", "bug", "bugs"
-        if (grep /(a?[\s>]bugs?[\s.:;,<])/i, $text) {
-            # Exclude variable assignment.
-            unless (grep /bugs =/, $text) {
-                push(@errors, [$lineno, $text]);
-                next;
-            }
-        }
+  my @errors;
+
+  # Read the entire file into a string
+  local $/;
+  open(FILE, "<$file") || die "Can't open $file: $!\n";
+  my $slurp = <FILE>;
+  close(FILE);
+
+  # /g means we execute this loop for every match
+  # /s means we ignore linefeeds in the regexp matches
+  # This extracts everything which is _not_ a directive.
+  while ($slurp =~ /%\](.*?)(\[%|$)/gs) {
+    my $text = $1;
+
+    my @lineno = ($` =~ m/\n/gs);
+    my $lineno = scalar(@lineno) + 1;
+
+    # "a bug", "bug", "bugs"
+    if (grep /(a?[\s>]bugs?[\s.:;,<])/i, $text) {
+
+      # Exclude variable assignment.
+      unless (grep /bugs =/, $text) {
+        push(@errors, [$lineno, $text]);
+        next;
+      }
     }
+  }
 
-    if (scalar(@errors)) {
-      ok(0, "$file contains invalid bare words (e.g. 'bug') --WARNING");
+  if (scalar(@errors)) {
+    ok(0, "$file contains invalid bare words (e.g. 'bug') --WARNING");
 
-      foreach my $error (@errors) {
-        print "$error->[0]: $error->[1]\n";
-      }
-    }
-    else {
-      ok(1, "$file has no invalid barewords");
+    foreach my $error (@errors) {
+      print "$error->[0]: $error->[1]\n";
     }
+  }
+  else {
+    ok(1, "$file has no invalid barewords");
+  }
 }
 
 exit 0;
index 777d42ed1f8eed224040bb6555109d92450cec0b..ed64756893c34140663759074b4fa5d747497fe8 100644 (file)
@@ -30,7 +30,8 @@ use constant MODULE_REGEX => qr/
     ['"]?
     ([\w:\.\\]+)
 /x;
-use constant BASE_REGEX => qr/^use (?:base|parent) (?:-norequire, )?qw\(([^\)]+)/;
+use constant BASE_REGEX =>
+  qr/^use (?:base|parent) (?:-norequire, )?qw\(([^\)]+)/;
 
 # Extract all Perl modules.
 foreach my $file (@Support::Files::testitems) {
@@ -42,46 +43,47 @@ foreach my $file (@Support::Files::testitems) {
 }
 
 foreach my $module (keys %mods) {
-    my $reading = 1;
-    my @use;
-
-    open(SOURCE, $mods{$module});
-    while (my $line = <SOURCE>) {
-      last if ($line =~ /^__END__/);
-      if ($line =~ /^=cut/) {
-        $reading = 1;
-        next;
-      }
-      next unless $reading;
-      if ($line =~ /^=(head|over|item|back|pod|begin|end|for)/) {
-        $reading = 0;
-        next;
-      }
-      if ($line =~ /^package\s+([^;]);/) {
-        $module = $1;
-      }
-      elsif ($line =~ BASE_REGEX or $line =~ MODULE_REGEX) {
-        my $used_string = $1;
-        # "use base"/"use parent" can have multiple modules
-        my @used_array = split(/\s+/, $used_string);
-        foreach my $used (@used_array) {
-            next if $used !~ /^Bugzilla/;
-            $used =~ s#/#::#g;
-            $used =~ s#\.pm$##;
-            $used =~ s#\$module#[^:]+#;
-            $used =~ s#\${[^}]+}#[^:]+#;
-            $used =~ s#[" ]##g;
-            push(@use, grep(/^\Q$used\E$/, keys %mods));
-        }
-      }
+  my $reading = 1;
+  my @use;
+
+  open(SOURCE, $mods{$module});
+  while (my $line = <SOURCE>) {
+    last if ($line =~ /^__END__/);
+    if ($line =~ /^=cut/) {
+      $reading = 1;
+      next;
+    }
+    next unless $reading;
+    if ($line =~ /^=(head|over|item|back|pod|begin|end|for)/) {
+      $reading = 0;
+      next;
     }
-    close (SOURCE);
+    if ($line =~ /^package\s+([^;]);/) {
+      $module = $1;
+    }
+    elsif ($line =~ BASE_REGEX or $line =~ MODULE_REGEX) {
+      my $used_string = $1;
 
-    foreach my $u (@use) {
-      if (!grep {$_ eq $u} @{$deps{$module}}) {
-        push(@{$deps{$module}}, $u);
+      # "use base"/"use parent" can have multiple modules
+      my @used_array = split(/\s+/, $used_string);
+      foreach my $used (@used_array) {
+        next if $used !~ /^Bugzilla/;
+        $used =~ s#/#::#g;
+        $used =~ s#\.pm$##;
+        $used =~ s#\$module#[^:]+#;
+        $used =~ s#\${[^}]+}#[^:]+#;
+        $used =~ s#[" ]##g;
+        push(@use, grep(/^\Q$used\E$/, keys %mods));
       }
     }
+  }
+  close(SOURCE);
+
+  foreach my $u (@use) {
+    if (!grep { $_ eq $u } @{$deps{$module}}) {
+      push(@{$deps{$module}}, $u);
+    }
+  }
 }
 
 sub creates_loop {
index 4f5fa87f72e85645ef6ae10eb8aa07db4489cc8c..3c6eb200f88b43186effd23ecdc5f276886340f3 100644 (file)
@@ -24,29 +24,33 @@ use Test::More tests => scalar(@Support::Files::testitems);
 # This will handle verbosity for us automatically.
 my $fh;
 {
-    no warnings 'unopened';
-    if (-e \*Test::More::TESTOUT) {
-        $fh = \*Test::More::TESTOUT;
-    } elsif (-e \*Test::Builder::TESTOUT) {
-        $fh = \*Test::Builder::TESTOUT;
-    } else {
-        $fh = \*STDOUT;
-    }
+  no warnings 'unopened';
+  if (-e \*Test::More::TESTOUT) {
+    $fh = \*Test::More::TESTOUT;
+  }
+  elsif (-e \*Test::Builder::TESTOUT) {
+    $fh = \*Test::Builder::TESTOUT;
+  }
+  else {
+    $fh = \*STDOUT;
+  }
 }
 
 my @testitems = @Support::Files::testitems;
 
 foreach my $file (@testitems) {
-    $file =~ s/\s.*$//; # nuke everything after the first space (#comment)
-    next if (!$file); # skip null entries
-    my $error_count = podchecker($file, $fh);
-    if ($error_count < 0) {
-        ok(1,"$file does not contain any POD");
-    } elsif ($error_count == 0) {
-        ok(1,"$file has correct POD syntax");
-    } else {
-        ok(0,"$file has incorrect POD syntax --ERROR");
-    }
+  $file =~ s/\s.*$//;    # nuke everything after the first space (#comment)
+  next if (!$file);      # skip null entries
+  my $error_count = podchecker($file, $fh);
+  if ($error_count < 0) {
+    ok(1, "$file does not contain any POD");
+  }
+  elsif ($error_count == 0) {
+    ok(1, "$file has correct POD syntax");
+  }
+  else {
+    ok(0, "$file has incorrect POD syntax --ERROR");
+  }
 }
 
 exit 0;
index af7a27eb295dba9593b83305c17505a3c4c0bc61..4a5d9e0a58a4a1054976918a5e4f2f2ff0271cc6 100644 (file)
@@ -6,7 +6,6 @@
 # defined by the Mozilla Public License, v. 2.0.
 
 
-
 ##################
 #Bugzilla Test 12#
 ######Errors######
@@ -32,11 +31,11 @@ push @{$Errors{code}{template_error}{used_in}{'Bugzilla/Error.pm'}}, 0;
 
 # Define files to test. Each file would have a list of error messages, if any.
 my %test_templates = ();
-my %test_modules = ();
+my %test_modules   = ();
 
 # Find all modules
 foreach my $module (@Support::Files::testitems) {
-    $test_modules{$module} = ();
+  $test_modules{$module} = ();
 }
 
 # Find all error templates
@@ -44,20 +43,20 @@ foreach my $module (@Support::Files::testitems) {
 # hairy. But let us do it only once.
 
 foreach my $include_path (@include_paths) {
-    foreach my $path (@{$actual_files{$include_path}}) {
-        my $file = File::Spec->catfile($include_path, $path);
-        $file =~ s/\s.*$//; # nuke everything after the first space
-        $file =~ s|\\|/|g if ON_WINDOWS;  # convert \ to / in path if on windows
-        $test_templates{$file} = ()
-            if $file =~ m#global/(code|user)-error(?:-errors)?\.html\.tmpl#;
-
-        # Make sure the extension is not disabled
-        if ($file =~ m#^(extensions/[^/]+/)#) {
-            $test_templates{$file} = ()
-                if ! -e "${1}disabled"
-                && $file =~ m#global/(code|user)-error-errors\.html\.tmpl#;
-        }
+  foreach my $path (@{$actual_files{$include_path}}) {
+    my $file = File::Spec->catfile($include_path, $path);
+    $file =~ s/\s.*$//;    # nuke everything after the first space
+    $file =~ s|\\|/|g if ON_WINDOWS;    # convert \ to / in path if on windows
+    $test_templates{$file} = ()
+      if $file =~ m#global/(code|user)-error(?:-errors)?\.html\.tmpl#;
+
+    # Make sure the extension is not disabled
+    if ($file =~ m#^(extensions/[^/]+/)#) {
+      $test_templates{$file} = ()
+        if !-e "${1}disabled"
+        && $file =~ m#global/(code|user)-error-errors\.html\.tmpl#;
     }
+  }
 }
 
 # Count the tests. The +1 is for checking the WS_ERROR_CODE errors.
@@ -69,112 +68,115 @@ plan tests => $tests;
 
 # Collect all errors defined in templates
 foreach my $file (keys %test_templates) {
-    $file =~ m|template/([^/]+).*/global/([^/]+)-error(?:-errors)?\.html\.tmpl|;
-    my $lang = $1;
-    my $errtype = $2;
-
-    if (! open (TMPL, $file)) {
-        Register(\%test_templates, $file, "could not open file --WARNING");
-        next;
-    }
-
-    my $lineno=0;
-    while (my $line = <TMPL>) {
-        $lineno++;
-        if ($line =~ /\[%\s[A-Z]+\s*error\s*==\s*"(.+)"\s*%\]/) {
-            my $errtag = $1;
-            if ($errtag =~ /\s/) {
-                Register(\%test_templates, $file,
-                "has an error definition \"$errtag\" at line $lineno with "
-                . "space(s) embedded --ERROR");
-            }
-            else {
-                push @{$Errors{$errtype}{$errtag}{defined_in}{$lang}{$file}}, $lineno;
-            }
-        }
+  $file =~ m|template/([^/]+).*/global/([^/]+)-error(?:-errors)?\.html\.tmpl|;
+  my $lang    = $1;
+  my $errtype = $2;
+
+  if (!open(TMPL, $file)) {
+    Register(\%test_templates, $file, "could not open file --WARNING");
+    next;
+  }
+
+  my $lineno = 0;
+  while (my $line = <TMPL>) {
+    $lineno++;
+    if ($line =~ /\[%\s[A-Z]+\s*error\s*==\s*"(.+)"\s*%\]/) {
+      my $errtag = $1;
+      if ($errtag =~ /\s/) {
+        Register(\%test_templates, $file,
+              "has an error definition \"$errtag\" at line $lineno with "
+            . "space(s) embedded --ERROR");
+      }
+      else {
+        push @{$Errors{$errtype}{$errtag}{defined_in}{$lang}{$file}}, $lineno;
+      }
     }
-    close(TMPL);
+  }
+  close(TMPL);
 }
 
 # Collect all used errors from cgi/pm files
 foreach my $file (keys %test_modules) {
-    $file =~ s/\s.*$//; # nuke everything after the first space (#comment)
-    next if (!$file); # skip null entries
-    if (! open (TMPL, $file)) {
-        Register(\%test_modules, $file, "could not open file --WARNING");
-        next;
-    }
-
-    my $lineno = 0;
-    while (my $line = <TMPL>) {
-        last if $line =~ /^__END__/; # skip the POD (at least in
-                                        # Bugzilla/Error.pm)
-        $lineno++;
-        if ($line =~
-/^[^#]*\b(Throw(Code|User)Error|(user_)?error\s+=>)\s*\(?\s*["'](.*?)['"]/) {
-            my $errtype;
-            # If it's a normal ThrowCode/UserError
-            if ($2) {
-                $errtype = lc($2);
-            }
-            # If it's an AUTH_ERROR tag
-            else {
-                $errtype = $3 ? 'user' : 'code';
-            }
-            my $errtag = $4;
-            push @{$Errors{$errtype}{$errtag}{used_in}{$file}}, $lineno;
-        }
+  $file =~ s/\s.*$//;    # nuke everything after the first space (#comment)
+  next if (!$file);      # skip null entries
+  if (!open(TMPL, $file)) {
+    Register(\%test_modules, $file, "could not open file --WARNING");
+    next;
+  }
+
+  my $lineno = 0;
+  while (my $line = <TMPL>) {
+    last if $line =~ /^__END__/;    # skip the POD (at least in
+                                    # Bugzilla/Error.pm)
+    $lineno++;
+    if ($line
+      =~ /^[^#]*\b(Throw(Code|User)Error|(user_)?error\s+=>)\s*\(?\s*["'](.*?)['"]/)
+    {
+      my $errtype;
+
+      # If it's a normal ThrowCode/UserError
+      if ($2) {
+        $errtype = lc($2);
+      }
+
+      # If it's an AUTH_ERROR tag
+      else {
+        $errtype = $3 ? 'user' : 'code';
+      }
+      my $errtag = $4;
+      push @{$Errors{$errtype}{$errtag}{used_in}{$file}}, $lineno;
     }
+  }
 
-    close(TMPL);
+  close(TMPL);
 }
 
 # Now let us start the checks
 
 foreach my $errtype (keys %Errors) {
-    foreach my $errtag (keys %{$Errors{$errtype}}) {
-        # Check for undefined tags
-        if (!defined $Errors{$errtype}{$errtag}{defined_in}) {
-            UsedIn($errtype, $errtag, "any");
+  foreach my $errtag (keys %{$Errors{$errtype}}) {
+
+    # Check for undefined tags
+    if (!defined $Errors{$errtype}{$errtag}{defined_in}) {
+      UsedIn($errtype, $errtag, "any");
+    }
+    else {
+      # Check for all languages!!!
+      my @langs = ();
+      foreach my $lang (@languages) {
+        if (!defined $Errors{$errtype}{$errtag}{defined_in}{$lang}) {
+          push @langs, $lang;
         }
-        else {
-            # Check for all languages!!!
-            my @langs = ();
-            foreach my $lang (@languages) {
-                if (!defined $Errors{$errtype}{$errtag}{defined_in}{$lang}) {
-                    push @langs, $lang;
-                }
-            }
-            if (scalar @langs) {
-                UsedIn($errtype, $errtag, join(', ',@langs));
-            }
-
-            # Now check for tag usage in all DEFINED languages
-            foreach my $lang (keys %{$Errors{$errtype}{$errtag}{defined_in}}) {
-                if (!defined $Errors{$errtype}{$errtag}{used_in}) {
-                    DefinedIn($errtype, $errtag, $lang);
-                }
-            }
+      }
+      if (scalar @langs) {
+        UsedIn($errtype, $errtag, join(', ', @langs));
+      }
+
+      # Now check for tag usage in all DEFINED languages
+      foreach my $lang (keys %{$Errors{$errtype}{$errtag}{defined_in}}) {
+        if (!defined $Errors{$errtype}{$errtag}{used_in}) {
+          DefinedIn($errtype, $errtag, $lang);
         }
+      }
     }
+  }
 }
 
 # And make sure that everything defined in WS_ERROR_CODE
 # is actually a valid error.
 foreach my $err_name (keys %{WS_ERROR_CODE()}) {
-    if (!defined $Errors{'code'}{$err_name}
-        && !defined $Errors{'user'}{$err_name})
-    {
-        Register(\%test_modules, 'WS_ERROR_CODE',
-            "Error tag '$err_name' is used in WS_ERROR_CODE in"
-            . " Bugzilla/WebService/Constants.pm"
-            . " but not defined in any template, and not used in any code.");
-    }
+  if (!defined $Errors{'code'}{$err_name} && !defined $Errors{'user'}{$err_name})
+  {
+    Register(\%test_modules, 'WS_ERROR_CODE',
+          "Error tag '$err_name' is used in WS_ERROR_CODE in"
+        . " Bugzilla/WebService/Constants.pm"
+        . " but not defined in any template, and not used in any code.");
+  }
 }
 
 # Now report modules results
 foreach my $file (sort keys %test_modules) {
-    Report($file, @{$test_modules{$file}});
+  Report($file, @{$test_modules{$file}});
 }
 
 # And report WS_ERROR_CODE results
@@ -182,56 +184,67 @@ Report('WS_ERROR_CODE', @{$test_modules{'WS_ERROR_CODE'}});
 
 # Now report templates results
 foreach my $file (sort keys %test_templates) {
-    Report($file, @{$test_templates{$file}});
+  Report($file, @{$test_templates{$file}});
 }
 
 sub Register {
-    my ($hash, $file, $message, $warning) = @_;
-    # If set to 1, $warning will avoid the test to fail.
-    $warning ||= 0;
-    push(@{$hash->{$file}}, {'message' => $message, 'warning' => $warning});
+  my ($hash, $file, $message, $warning) = @_;
+
+  # If set to 1, $warning will avoid the test to fail.
+  $warning ||= 0;
+  push(@{$hash->{$file}}, {'message' => $message, 'warning' => $warning});
 }
 
 sub Report {
-    my ($file, @errors) = @_;
-    if (scalar @errors) {
-        # Do we only have warnings to report or also real errors?
-        my @real_errors = grep {$_->{'warning'} == 0} @errors;
-        # Extract error messages.
-        @errors = map {$_->{'message'}} @errors;
-        if (scalar(@real_errors)) {
-            ok(0, "$file has ". scalar(@errors) ." error(s):\n" . join("\n", @errors));
-        }
-        else {
-            ok(1, "--WARNING $file has " . scalar(@errors) .
-                  " unused error tag(s):\n" . join("\n", @errors));
-        }
+  my ($file, @errors) = @_;
+  if (scalar @errors) {
+
+    # Do we only have warnings to report or also real errors?
+    my @real_errors = grep { $_->{'warning'} == 0 } @errors;
+
+    # Extract error messages.
+    @errors = map { $_->{'message'} } @errors;
+    if (scalar(@real_errors)) {
+      ok(0, "$file has " . scalar(@errors) . " error(s):\n" . join("\n", @errors));
     }
     else {
-        # This is used for both code and template files, so let's use
-        # file-independent phrase
-        ok(1, "$file uses error tags correctly");
+      ok(1,
+            "--WARNING $file has "
+          . scalar(@errors)
+          . " unused error tag(s):\n"
+          . join("\n", @errors));
     }
+  }
+  else {
+    # This is used for both code and template files, so let's use
+    # file-independent phrase
+    ok(1, "$file uses error tags correctly");
+  }
 }
 
 sub UsedIn {
-    my ($errtype, $errtag, $lang) = @_;
-    $lang = $lang || "any";
-    foreach my $file (keys %{$Errors{$errtype}{$errtag}{used_in}}) {
-        Register(\%test_modules, $file,
-            "$errtype error tag '$errtag' is used at line(s) ("
-            . join (',', @{$Errors{$errtype}{$errtag}{used_in}{$file}})
-            . ") but not defined for language(s): $lang");
-    }
+  my ($errtype, $errtag, $lang) = @_;
+  $lang = $lang || "any";
+  foreach my $file (keys %{$Errors{$errtype}{$errtag}{used_in}}) {
+    Register(\%test_modules, $file,
+          "$errtype error tag '$errtag' is used at line(s) ("
+        . join(',', @{$Errors{$errtype}{$errtag}{used_in}{$file}})
+        . ") but not defined for language(s): $lang");
+  }
 }
+
 sub DefinedIn {
-    my ($errtype, $errtag, $lang) = @_;
-    foreach my $file (keys %{$Errors{$errtype}{$errtag}{defined_in}{$lang}}) {
-        Register(\%test_templates, $file,
-            "$errtype error tag '$errtag' is defined at line(s) ("
-            . join (',', @{$Errors{$errtype}{$errtag}{defined_in}{$lang}{$file}})
-            . ") but is not used anywhere", 1);
-    }
+  my ($errtype, $errtag, $lang) = @_;
+  foreach my $file (keys %{$Errors{$errtype}{$errtag}{defined_in}{$lang}}) {
+    Register(
+      \%test_templates,
+      $file,
+      "$errtype error tag '$errtag' is defined at line(s) ("
+        . join(',', @{$Errors{$errtype}{$errtag}{defined_in}{$lang}{$file}})
+        . ") but is not used anywhere",
+      1
+    );
+  }
 }
 
 exit 0;
index 5f6230a7d71b65e3680fea4707a8d32826e21290..2959626fa56e45407a90f6d9ec36155ec358db36 100644 (file)
@@ -15,20 +15,20 @@ use Crypt::OpenPGP;
 my $pubring = new Crypt::OpenPGP::KeyRing(Data => PUBLIC_KEY());
 my $pgp = new Crypt::OpenPGP(PubRing => $pubring);
 {
-    local $SIG{ALRM} = sub { fail("stuck in a loop"); exit; };
-    alarm(120);
-    my $encrypted = $pgp->encrypt(
-        Data       => "hello, world",
-        Recipients => "@",
-        Cipher     => 'CAST5',
-        Armour     => 0
-    );
-    alarm(0);
+  local $SIG{ALRM} = sub { fail("stuck in a loop"); exit; };
+  alarm(120);
+  my $encrypted = $pgp->encrypt(
+    Data       => "hello, world",
+    Recipients => "@",
+    Cipher     => 'CAST5',
+    Armour     => 0
+  );
+  alarm(0);
 }
 pass("didn't get stuck in a loop");
 
 sub PUBLIC_KEY {
-    return <<'KEY';
+  return <<'KEY';
 -----BEGIN PGP PUBLIC KEY BLOCK-----
 Version: GnuPG v1.4.9 (GNU/Linux)
 
index a692ea589e34f9711d1fdc57da9f77ea0d346cc7..12b662e5e306112d40a230e334b95f27e646ec25 100644 (file)
@@ -13,13 +13,13 @@ use Test::More tests => 2;
 use Crypt::OpenPGP::Util;
 
 {
-    local $SIG{ALRM} = sub {
-        fail("getting random bytes froze program");
-        exit;
-    };
-    alarm(60);
-    my $bytes = Crypt::OpenPGP::Util::get_random_bytes(32);
-    alarm(0);
-    pass("getting random bytes didn't freeze program");
-    is(length $bytes, 32, "got 32 bytes");
+  local $SIG{ALRM} = sub {
+    fail("getting random bytes froze program");
+    exit;
+  };
+  alarm(60);
+  my $bytes = Crypt::OpenPGP::Util::get_random_bytes(32);
+  alarm(0);
+  pass("getting random bytes didn't freeze program");
+  is(length $bytes, 32, "got 32 bytes");
 }
index fe7ce9b533edb8b475e129e878630ee540c93cdf..718947377b8c3734ab9c338fcce102768e1d5714 100644 (file)
@@ -12,12 +12,28 @@ use autodie;
 use Test::More 1.302;
 use ok 'Bugzilla::Config::Auth';
 
-ok(length(Bugzilla::Config::Auth::_check_passwdqc_min("undef, 24, 11, 8, 7")) == 0, "default value is valid");
-ok(length(Bugzilla::Config::Auth::_check_passwdqc_min("underf, 24, 11, 8, 7")) != 0, "underf is not valid");
-is(Bugzilla::Config::Auth::_check_passwdqc_min("undef, 24, 25, 8, 7"), "Int2 is larger than Int1 (24)",  "25 can't come after 24");
-ok(length(Bugzilla::Config::Auth::_check_passwdqc_min("")) != 0, "empty string is invalid");
-ok(length(Bugzilla::Config::Auth::_check_passwdqc_min("24")) != 0, "24 is invalid");
-ok(length(Bugzilla::Config::Auth::_check_passwdqc_min("-24")) != 0, "-24 is invalid");
-ok(length(Bugzilla::Config::Auth::_check_passwdqc_min("10, 10, 10, 10, 0")) != 0, "10, 10, 10, 10, 0 is invalid");
+ok(
+  length(Bugzilla::Config::Auth::_check_passwdqc_min("undef, 24, 11, 8, 7")) == 0,
+  "default value is valid"
+);
+ok(
+  length(Bugzilla::Config::Auth::_check_passwdqc_min("underf, 24, 11, 8, 7"))
+    != 0,
+  "underf is not valid"
+);
+is(
+  Bugzilla::Config::Auth::_check_passwdqc_min("undef, 24, 25, 8, 7"),
+  "Int2 is larger than Int1 (24)",
+  "25 can't come after 24"
+);
+ok(length(Bugzilla::Config::Auth::_check_passwdqc_min("")) != 0,
+  "empty string is invalid");
+ok(length(Bugzilla::Config::Auth::_check_passwdqc_min("24")) != 0,
+  "24 is invalid");
+ok(length(Bugzilla::Config::Auth::_check_passwdqc_min("-24")) != 0,
+  "-24 is invalid");
+ok(
+  length(Bugzilla::Config::Auth::_check_passwdqc_min("10, 10, 10, 10, 0")) != 0,
+  "10, 10, 10, 10, 0 is invalid");
 
 done_testing;
index 4b0bb81779333d894cb6ea1172cba92c36d65dd7..2c06cb9f496c003afa4667c093837545a2ea12d5 100644 (file)
@@ -22,51 +22,50 @@ Bugzilla->error_mode(ERROR_MODE_DIE);
 my $user = Bugzilla::User->check({id => 1});
 Bugzilla->set_user($user);
 
-my $bug_1 = Bugzilla::Bug->create(
-    {
-        short_desc   => 'A test bug',
-        product      => 'Firefox',
-        component    => 'General',,
-        bug_severity => 'normal',
-        groups       => [],
-        op_sys       => 'Unspecified',
-        rep_platform => 'Unspecified',
-        version      => 'Trunk',
-        keywords     => [],
-        cc           => [],
-        comment      => 'This is a brand new bug',
-        assigned_to  => 'nobody@mozilla.org',
-    }
-);
+my $bug_1 = Bugzilla::Bug->create({
+  short_desc => 'A test bug',
+  product    => 'Firefox',
+  component  => 'General',
+  ,
+  bug_severity => 'normal',
+  groups       => [],
+  op_sys       => 'Unspecified',
+  rep_platform => 'Unspecified',
+  version      => 'Trunk',
+  keywords     => [],
+  cc           => [],
+  comment      => 'This is a brand new bug',
+  assigned_to  => 'nobody@mozilla.org',
+});
 ok($bug_1->id, "got a new bug");
 
-my $urlbase = Bugzilla->localconfig->{urlbase};
+my $urlbase  = Bugzilla->localconfig->{urlbase};
 my $bug_1_id = $bug_1->id;
-my $bug_2 = Bugzilla::Bug->create(
-    {
-        short_desc   => 'A bug that references another bug',
-        product      => 'Firefox',
-        component    => 'General',,
-        bug_severity => 'normal',
-        groups       => [],
-        op_sys       => 'Unspecified',
-        rep_platform => 'Unspecified',
-        version      => 'Trunk',
-        keywords     => [],
-        cc           => [],
-        comment      => "This is related to ${urlbase}show_bug.cgi?id=$bug_1_id",
-        assigned_to  => 'nobody@mozilla.org',
-    }
-);
+my $bug_2    = Bugzilla::Bug->create({
+  short_desc => 'A bug that references another bug',
+  product    => 'Firefox',
+  component  => 'General',
+  ,
+  bug_severity => 'normal',
+  groups       => [],
+  op_sys       => 'Unspecified',
+  rep_platform => 'Unspecified',
+  version      => 'Trunk',
+  keywords     => [],
+  cc           => [],
+  comment      => "This is related to ${urlbase}show_bug.cgi?id=$bug_1_id",
+  assigned_to  => 'nobody@mozilla.org',
+});
 
 my $bug_2_id = $bug_2->id;
 
 Bugzilla::Template::quoteUrls(
-    $bug_2->comments->[0]->body, undef, undef, undef,
-    sub {
-        my $bug_id = $_[0];
-        is($bug_id, $bug_1_id, "found Bug $bug_1_id on Bug $bug_2_id");
-    }
+  $bug_2->comments->[0]->body,
+  undef, undef, undef,
+  sub {
+    my $bug_id = $_[0];
+    is($bug_id, $bug_1_id, "found Bug $bug_1_id on Bug $bug_2_id");
+  }
 );
 
 done_testing;
index 83bea60be547848960dcf801de93556560b44c5c..f3dd449bb5c8493283ccef821f625ddd71c6ed9e 100644 (file)
@@ -6,8 +6,12 @@ use autodie;
 use constant DRIVER => 'Test::Selenium::Remote::Driver';
 
 use Test::More 1.302;
+
 #use constant DRIVER => 'Test::Selenium::Chrome';
-BEGIN { plan skip_all => "these tests only run in CI" unless $ENV{CI} && $ENV{CIRCLE_JOB} eq 'test_bmo' };
+BEGIN {
+  plan skip_all => "these tests only run in CI"
+    unless $ENV{CI} && $ENV{CIRCLE_JOB} eq 'test_bmo';
+}
 
 use ok DRIVER;
 
@@ -16,245 +20,248 @@ my $ADMIN_PW_OLD = $ENV{BZ_TEST_ADMIN_PASS} // 'Te6Oovohch';
 my $ADMIN_PW_NEW = $ENV{BZ_TEST_ADMIN_NEWPASS} // 'she7Ka8t';
 
 my @require_env = qw(
-    BZ_BASE_URL
-    BZ_TEST_NEWBIE
-    BZ_TEST_NEWBIE_PASS
+  BZ_BASE_URL
+  BZ_TEST_NEWBIE
+  BZ_TEST_NEWBIE_PASS
 );
 
 if (DRIVER =~ /Remote/) {
-    push @require_env, qw( TWD_HOST TWD_PORT );
+  push @require_env, qw( TWD_HOST TWD_PORT );
 }
-my @missing_env = grep { ! exists $ENV{$_} } @require_env;
+my @missing_env = grep { !exists $ENV{$_} } @require_env;
 BAIL_OUT("Missing env: @missing_env") if @missing_env;
 
 eval {
-    my $sel = DRIVER->new(base_url => $ENV{BZ_BASE_URL});
-    $sel->set_implicit_wait_timeout(600);
-
-    login_ok($sel, $ADMIN_LOGIN, $ADMIN_PW_OLD);
-
-    change_password($sel, $ADMIN_PW_OLD, 'Ju9shiePhie6', 'zeeKuj0leib7');
-    $sel->title_is("Passwords Don't Match");
-    $sel->body_text_contains('The two passwords you entered did not match.');
-
-    change_password($sel, $ADMIN_PW_OLD . "x", "newpassword2", "newpassword2");
-    $sel->title_is("Incorrect Old Password");
-
-    change_password($sel, $ADMIN_PW_OLD, "password", "password");
-    $sel->title_is("Password Fails Requirements");
-
-    change_password($sel, $ADMIN_PW_OLD, $ADMIN_PW_NEW, $ADMIN_PW_NEW);
-    $sel->title_is("User Preferences");
-    logout_ok($sel);
-
-    login_ok($sel, $ADMIN_LOGIN, $ADMIN_PW_NEW);
-
-    # we don't protect against password re-use
-    change_password($sel, $ADMIN_PW_NEW, $ADMIN_PW_OLD, $ADMIN_PW_OLD);
-    $sel->title_is("User Preferences");
-    logout_ok($sel);
-
-    login_ok($sel, $ENV{BZ_TEST_NEWBIE}, $ENV{BZ_TEST_NEWBIE_PASS});
-
-    $sel->get_ok("/editusers.cgi");
-    $sel->title_is("Authorization Required");
-    logout_ok($sel);
-
-    login_ok($sel, $ADMIN_LOGIN, $ADMIN_PW_OLD);
-
-    toggle_require_password_change($sel, $ENV{BZ_TEST_NEWBIE});
-    logout_ok($sel);
-
-    login($sel, $ENV{BZ_TEST_NEWBIE}, $ENV{BZ_TEST_NEWBIE_PASS});
-    $sel->title_is('Password change required');
-    click_and_type($sel, "old_password", $ENV{BZ_TEST_NEWBIE_PASS});
-    click_and_type($sel, "new_password1", "password");
-    click_and_type($sel, "new_password2", "password");
-    submit($sel, '//input[@id="submit"]');
-    $sel->title_is('Password Fails Requirements');
-
-    $sel->go_back_ok();
-    $sel->title_is('Password change required');
-    click_and_type($sel, "old_password", $ENV{BZ_TEST_NEWBIE_PASS});
-    click_and_type($sel, "new_password1", "!!" . $ENV{BZ_TEST_NEWBIE_PASS});
-    click_and_type($sel, "new_password2", "!!" . $ENV{BZ_TEST_NEWBIE_PASS});
-    submit($sel, '//input[@id="submit"]');
-    $sel->title_is('Password Changed');
-    change_password(
-        $sel,
-        "!!" . $ENV{BZ_TEST_NEWBIE_PASS},
-        $ENV{BZ_TEST_NEWBIE_PASS},
-        $ENV{BZ_TEST_NEWBIE_PASS}
-    );
-    $sel->title_is("User Preferences");
-
-    $sel->get_ok("/userprefs.cgi?tab=account");
-    $sel->title_is("User Preferences");
-    click_link($sel, "I forgot my password");
-    $sel->body_text_contains(
-        ["A token for changing your password has been emailed to you.",
-         "Follow the instructions in that email to change your password."],
-    );
-    my $token = get_token();
-    ok($token, "got a token from resetting password");
-    $sel->get_ok("/token.cgi?t=$token&a=cfmpw");
-    $sel->title_is('Change Password');
-    click_and_type($sel, "password", "nopandas");
-    click_and_type($sel, "matchpassword", "nopandas");
-    submit($sel, '//input[@id="update"]');
-    $sel->title_is('Password Fails Requirements');
-    $sel->go_back_ok();
-    $sel->title_is('Change Password');
-    click_and_type($sel, "password", '??' . $ENV{BZ_TEST_NEWBIE_PASS});
-    click_and_type($sel, "matchpassword", '??' . $ENV{BZ_TEST_NEWBIE_PASS});
-    submit($sel, '//input[@id="update"]');
-    $sel->title_is('Password Changed');
-    $sel->get_ok("/token.cgi?t=$token&a=cfmpw");
-    $sel->title_is('Token Does Not Exist');
-    $sel->get_ok("/login");
-    $sel->title_is('Log in to Bugzilla');
-    login_ok($sel, $ENV{BZ_TEST_NEWBIE}, "??" . $ENV{BZ_TEST_NEWBIE_PASS});
-    change_password(
-        $sel,
-        "??" . $ENV{BZ_TEST_NEWBIE_PASS},
-        $ENV{BZ_TEST_NEWBIE_PASS},
-        $ENV{BZ_TEST_NEWBIE_PASS}
-    );
-    $sel->title_is("User Preferences");
-
-    logout_ok($sel);
-    open my $fh, '>', '/app/data/mailer.testfile';
-    close $fh;
-
-    $sel->get('/createaccount.cgi');
-    $sel->title_is('Create a new Bugzilla account');
-    click_and_type($sel, 'login', $ENV{BZ_TEST_NEWBIE2});
-    $sel->find_element('//input[@id="etiquette"]', 'xpath')->click();
-    submit($sel, '//input[@value="Create Account"]');
-    $sel->title_is("Request for new user account '$ENV{BZ_TEST_NEWBIE2}' submitted");
-    my ($create_token) = search_mailer_testfile(
-        qr{/token\.cgi\?t=([^&]+)&a=request_new_account}xs
-    );
-    $sel->get("/token.cgi?t=$create_token&a=request_new_account");
-    click_and_type($sel, 'passwd1', $ENV{BZ_TEST_NEWBIE2_PASS});
-    click_and_type($sel, 'passwd2', $ENV{BZ_TEST_NEWBIE2_PASS});
-    submit($sel, '//input[@value="Create"]');
-
-    $sel->title_is('Bugzilla Main Page');
-    $sel->body_text_contains(
-        ["The user account $ENV{BZ_TEST_NEWBIE2} has been created",
-         "successfully"]
-    );
+  my $sel = DRIVER->new(base_url => $ENV{BZ_BASE_URL});
+  $sel->set_implicit_wait_timeout(600);
+
+  login_ok($sel, $ADMIN_LOGIN, $ADMIN_PW_OLD);
+
+  change_password($sel, $ADMIN_PW_OLD, 'Ju9shiePhie6', 'zeeKuj0leib7');
+  $sel->title_is("Passwords Don't Match");
+  $sel->body_text_contains('The two passwords you entered did not match.');
+
+  change_password($sel, $ADMIN_PW_OLD . "x", "newpassword2", "newpassword2");
+  $sel->title_is("Incorrect Old Password");
+
+  change_password($sel, $ADMIN_PW_OLD, "password", "password");
+  $sel->title_is("Password Fails Requirements");
+
+  change_password($sel, $ADMIN_PW_OLD, $ADMIN_PW_NEW, $ADMIN_PW_NEW);
+  $sel->title_is("User Preferences");
+  logout_ok($sel);
+
+  login_ok($sel, $ADMIN_LOGIN, $ADMIN_PW_NEW);
+
+  # we don't protect against password re-use
+  change_password($sel, $ADMIN_PW_NEW, $ADMIN_PW_OLD, $ADMIN_PW_OLD);
+  $sel->title_is("User Preferences");
+  logout_ok($sel);
+
+  login_ok($sel, $ENV{BZ_TEST_NEWBIE}, $ENV{BZ_TEST_NEWBIE_PASS});
+
+  $sel->get_ok("/editusers.cgi");
+  $sel->title_is("Authorization Required");
+  logout_ok($sel);
+
+  login_ok($sel, $ADMIN_LOGIN, $ADMIN_PW_OLD);
+
+  toggle_require_password_change($sel, $ENV{BZ_TEST_NEWBIE});
+  logout_ok($sel);
+
+  login($sel, $ENV{BZ_TEST_NEWBIE}, $ENV{BZ_TEST_NEWBIE_PASS});
+  $sel->title_is('Password change required');
+  click_and_type($sel, "old_password",  $ENV{BZ_TEST_NEWBIE_PASS});
+  click_and_type($sel, "new_password1", "password");
+  click_and_type($sel, "new_password2", "password");
+  submit($sel, '//input[@id="submit"]');
+  $sel->title_is('Password Fails Requirements');
+
+  $sel->go_back_ok();
+  $sel->title_is('Password change required');
+  click_and_type($sel, "old_password",  $ENV{BZ_TEST_NEWBIE_PASS});
+  click_and_type($sel, "new_password1", "!!" . $ENV{BZ_TEST_NEWBIE_PASS});
+  click_and_type($sel, "new_password2", "!!" . $ENV{BZ_TEST_NEWBIE_PASS});
+  submit($sel, '//input[@id="submit"]');
+  $sel->title_is('Password Changed');
+  change_password(
+    $sel,
+    "!!" . $ENV{BZ_TEST_NEWBIE_PASS},
+    $ENV{BZ_TEST_NEWBIE_PASS},
+    $ENV{BZ_TEST_NEWBIE_PASS}
+  );
+  $sel->title_is("User Preferences");
+
+  $sel->get_ok("/userprefs.cgi?tab=account");
+  $sel->title_is("User Preferences");
+  click_link($sel, "I forgot my password");
+  $sel->body_text_contains(
+    [
+      "A token for changing your password has been emailed to you.",
+      "Follow the instructions in that email to change your password."
+    ],
+  );
+  my $token = get_token();
+  ok($token, "got a token from resetting password");
+  $sel->get_ok("/token.cgi?t=$token&a=cfmpw");
+  $sel->title_is('Change Password');
+  click_and_type($sel, "password",      "nopandas");
+  click_and_type($sel, "matchpassword", "nopandas");
+  submit($sel, '//input[@id="update"]');
+  $sel->title_is('Password Fails Requirements');
+  $sel->go_back_ok();
+  $sel->title_is('Change Password');
+  click_and_type($sel, "password",      '??' . $ENV{BZ_TEST_NEWBIE_PASS});
+  click_and_type($sel, "matchpassword", '??' . $ENV{BZ_TEST_NEWBIE_PASS});
+  submit($sel, '//input[@id="update"]');
+  $sel->title_is('Password Changed');
+  $sel->get_ok("/token.cgi?t=$token&a=cfmpw");
+  $sel->title_is('Token Does Not Exist');
+  $sel->get_ok("/login");
+  $sel->title_is('Log in to Bugzilla');
+  login_ok($sel, $ENV{BZ_TEST_NEWBIE}, "??" . $ENV{BZ_TEST_NEWBIE_PASS});
+  change_password(
+    $sel,
+    "??" . $ENV{BZ_TEST_NEWBIE_PASS},
+    $ENV{BZ_TEST_NEWBIE_PASS},
+    $ENV{BZ_TEST_NEWBIE_PASS}
+  );
+  $sel->title_is("User Preferences");
+
+  logout_ok($sel);
+  open my $fh, '>', '/app/data/mailer.testfile';
+  close $fh;
+
+  $sel->get('/createaccount.cgi');
+  $sel->title_is('Create a new Bugzilla account');
+  click_and_type($sel, 'login', $ENV{BZ_TEST_NEWBIE2});
+  $sel->find_element('//input[@id="etiquette"]', 'xpath')->click();
+  submit($sel, '//input[@value="Create Account"]');
+  $sel->title_is(
+    "Request for new user account '$ENV{BZ_TEST_NEWBIE2}' submitted");
+  my ($create_token)
+    = search_mailer_testfile(qr{/token\.cgi\?t=([^&]+)&a=request_new_account}xs);
+  $sel->get("/token.cgi?t=$create_token&a=request_new_account");
+  click_and_type($sel, 'passwd1', $ENV{BZ_TEST_NEWBIE2_PASS});
+  click_and_type($sel, 'passwd2', $ENV{BZ_TEST_NEWBIE2_PASS});
+  submit($sel, '//input[@value="Create"]');
+
+  $sel->title_is('Bugzilla Main Page');
+  $sel->body_text_contains([
+    "The user account $ENV{BZ_TEST_NEWBIE2} has been created", "successfully"
+  ]);
 };
 if ($@) {
-    fail("got exception $@");
+  fail("got exception $@");
 }
 done_testing();
 
 sub submit {
-    my ($sel, $xpath) = @_;
-    $sel->find_element($xpath, 'xpath')->submit();
+  my ($sel, $xpath) = @_;
+  $sel->find_element($xpath, 'xpath')->submit();
 }
 
 sub get_token {
-    my $token;
-    my $count = 0;
-    do {
-        sleep 1 if $count++;
-        open my $fh, '<', '/app/data/mailer.testfile';
-        my $content = do {
-            local $/ = undef;
-            <$fh>;
-        };
-        ($token) = $content =~ m!/token\.cgi\?t=3D([^&]+)&a=3Dcfmpw!s;
-        close $fh;
-    } until $token || $count > 60;
-    return $token;
+  my $token;
+  my $count = 0;
+  do {
+    sleep 1 if $count++;
+    open my $fh, '<', '/app/data/mailer.testfile';
+    my $content = do {
+      local $/ = undef;
+      <$fh>;
+    };
+    ($token) = $content =~ m!/token\.cgi\?t=3D([^&]+)&a=3Dcfmpw!s;
+    close $fh;
+  } until $token || $count > 60;
+  return $token;
 }
 
 sub search_mailer_testfile {
-    my ($regexp) = @_;
-    my $content = "";
-    my @result;
-    my $count = 0;
-    do {
-        sleep 1 if $count++;
-        open my $fh, '<', '/app/data/mailer.testfile';
-        $content .= do {
-            local $/ = undef;
-            <$fh>;
-        };
-        close $fh;
-        my $decoded = $content;
-        $decoded =~ s/\r\n/\n/gs;
-        $decoded =~ s/=\n//gs;
-        $decoded =~ s/=([[:xdigit:]]{2})/chr(hex($1))/ges;
-        @result = $decoded =~ $regexp;
-    } until @result || $count > 60;
-    return @result;
+  my ($regexp) = @_;
+  my $content = "";
+  my @result;
+  my $count = 0;
+  do {
+    sleep 1 if $count++;
+    open my $fh, '<', '/app/data/mailer.testfile';
+    $content .= do {
+      local $/ = undef;
+      <$fh>;
+    };
+    close $fh;
+    my $decoded = $content;
+    $decoded =~ s/\r\n/\n/gs;
+    $decoded =~ s/=\n//gs;
+    $decoded =~ s/=([[:xdigit:]]{2})/chr(hex($1))/ges;
+    @result = $decoded =~ $regexp;
+  } until @result || $count > 60;
+  return @result;
 }
 
 sub click_and_type {
-    my ($sel, $name, $text) = @_;
+  my ($sel, $name, $text) = @_;
 
-    eval {
-        my $el = $sel->find_element(qq{//*[\@id="bugzilla-body"]//input[\@name="$name"]}, 'xpath');
-        $el->click();
-        $sel->send_keys_to_active_element($text);
-        pass("found $name and typed $text");
-    };
-    if ($@) {
-        fail("failed to find $name");
-    }
+  eval {
+    my $el
+      = $sel->find_element(qq{//*[\@id="bugzilla-body"]//input[\@name="$name"]},
+      'xpath');
+    $el->click();
+    $sel->send_keys_to_active_element($text);
+    pass("found $name and typed $text");
+  };
+  if ($@) {
+    fail("failed to find $name");
+  }
 }
 
 sub click_link {
-    my ($sel, $text) = @_;
-    my $el = $sel->find_element($text, 'link_text');
-    $el->click();
+  my ($sel, $text) = @_;
+  my $el = $sel->find_element($text, 'link_text');
+  $el->click();
 }
 
 sub change_password {
-    my ($sel, $old, $new1, $new2) = @_;
-    $sel->get_ok("/userprefs.cgi?tab=account");
-    $sel->title_is("User Preferences");
-    click_and_type($sel, "old_password", $old);
-    click_and_type($sel, "new_password1", $new1);
-    click_and_type($sel, "new_password2", $new2);
-    submit($sel, '//input[@value="Submit Changes"]');
+  my ($sel, $old, $new1, $new2) = @_;
+  $sel->get_ok("/userprefs.cgi?tab=account");
+  $sel->title_is("User Preferences");
+  click_and_type($sel, "old_password",  $old);
+  click_and_type($sel, "new_password1", $new1);
+  click_and_type($sel, "new_password2", $new2);
+  submit($sel, '//input[@value="Submit Changes"]');
 }
 
 sub toggle_require_password_change {
-    my ($sel, $login) = @_;
-    $sel->get_ok("/editusers.cgi");
-    $sel->title_is("Search users");
-    click_and_type($sel, 'matchstr', $login);
-    submit($sel, '//input[@id="search"]');
-    $sel->title_is("Select user");
-    click_link($sel, $login);
-    $sel->find_element('//input[@id="password_change_required"]')->click;
-    submit($sel, '//input[@id="update"]');
-    $sel->title_is("User $login updated");
+  my ($sel, $login) = @_;
+  $sel->get_ok("/editusers.cgi");
+  $sel->title_is("Search users");
+  click_and_type($sel, 'matchstr', $login);
+  submit($sel, '//input[@id="search"]');
+  $sel->title_is("Select user");
+  click_link($sel, $login);
+  $sel->find_element('//input[@id="password_change_required"]')->click;
+  submit($sel, '//input[@id="update"]');
+  $sel->title_is("User $login updated");
 }
 
 sub login {
-    my ($sel, $login, $password) = @_;
+  my ($sel, $login, $password) = @_;
 
-    $sel->get_ok("/login");
-    $sel->title_is("Log in to Bugzilla");
-    click_and_type($sel, 'Bugzilla_login', $login);
-    click_and_type($sel, 'Bugzilla_password', $password);
-    submit($sel, '//*[@id="bugzilla-body"]//input[@name="GoAheadAndLogIn"]');
+  $sel->get_ok("/login");
+  $sel->title_is("Log in to Bugzilla");
+  click_and_type($sel, 'Bugzilla_login',    $login);
+  click_and_type($sel, 'Bugzilla_password', $password);
+  submit($sel, '//*[@id="bugzilla-body"]//input[@name="GoAheadAndLogIn"]');
 }
 
 sub login_ok {
-    my ($sel) = @_;
-    login(@_);
-    $sel->title_is('Bugzilla Main Page');
+  my ($sel) = @_;
+  login(@_);
+  $sel->title_is('Bugzilla Main Page');
 }
 
 sub logout_ok {
-    my ($sel) = @_;
-    $sel->get_ok('/index.cgi?logout=1');
-    $sel->title_is("Logged Out");
+  my ($sel) = @_;
+  $sel->get_ok('/index.cgi?logout=1');
+  $sel->title_is("Logged Out");
 }
index 6e37cc0df47333bb0d6799e868a1a7fb45e2d9ab..182f8c8e6aab6dfd4702062757e8952e01eaf110 100644 (file)
@@ -14,4 +14,4 @@ use Test::More;
 my $ok = eval { require Test::Perl::Critic::Progressive };
 plan skip_all => 'T::P::C::Progressive required for this test' unless $ok;
 
-Test::Perl::Critic::Progressive::progressive_critic_ok();
\ No newline at end of file
+Test::Perl::Critic::Progressive::progressive_critic_ok();
diff --git a/t/css.t b/t/css.t
index 1d08ce154422bde4a144a41f8d2a0883ca02bb93..35fa17df06e5d0781e453e2adff79d4d35ac690a 100644 (file)
--- a/t/css.t
+++ b/t/css.t
@@ -17,21 +17,22 @@ use Test::More;
 my $root = cwd();
 
 find(
-    {
-        wanted => sub {
-            if (/\.css$/) {
-                my $css_file = $File::Find::name;
-                my $content = path($_)->slurp;
-                while ($content =~ m{url\(["']?([^\?\)"']+)(?:\?.+)?['"]?\)}g) {
-                    my $file = $1;
-                    my $file_rel_root = File::Spec->abs2rel(realpath(File::Spec->rel2abs($file)), $root);
+  {
+    wanted => sub {
+      if (/\.css$/) {
+        my $css_file = $File::Find::name;
+        my $content  = path($_)->slurp;
+        while ($content =~ m{url\(["']?([^\?\)"']+)(?:\?.+)?['"]?\)}g) {
+          my $file = $1;
+          my $file_rel_root
+            = File::Spec->abs2rel(realpath(File::Spec->rel2abs($file)), $root);
 
-                    ok(-f $file, "$css_file references $file ($file_rel_root)");
-                }
-            }
-        },
+          ok(-f $file, "$css_file references $file ($file_rel_root)");
+        }
+      }
     },
-    'skins'
+  },
+  'skins'
 );
 
 done_testing;
index c42e26fc1d33ac7006687ff80faf087dffe955f8..9db43d330c2c40ea734768e517b350fcf6f0fe6f 100644 (file)
@@ -15,61 +15,61 @@ use Test::More;
 
 use ok 'Bugzilla::DaemonControl', qw(catch_signal);
 
-my $loop = IO::Async::Loop->new;
+my $loop            = IO::Async::Loop->new;
 my $signal_test_out = '';
-my $signal_test = IO::Async::Process->new(
-    code => sub {
-        my $f = catch_signal("TERM", 42);
-        say $f->isa('Future') ? "I have a Future" : '';
-        my $val = $f->get;
-        say "Got $val from TERM";
-        sleep 30;
-        say "I Failed My Mission";
-    },
-    stdout => { into => \$signal_test_out },
-    on_finish => sub {
-        $loop->stop;
-    },
-    on_exception => sub {
-        diag "@_";
-        fail("got exception");
-        $loop->stop;
-    }
+my $signal_test     = IO::Async::Process->new(
+  code => sub {
+    my $f = catch_signal("TERM", 42);
+    say $f->isa('Future') ? "I have a Future" : '';
+    my $val = $f->get;
+    say "Got $val from TERM";
+    sleep 30;
+    say "I Failed My Mission";
+  },
+  stdout    => {into => \$signal_test_out},
+  on_finish => sub {
+    $loop->stop;
+  },
+  on_exception => sub {
+    diag "@_";
+    fail("got exception");
+    $loop->stop;
+  }
 );
 diag "starting signal test";
 $loop->add($signal_test);
-ok( $signal_test->is_running, "signal test is running");
+ok($signal_test->is_running, "signal test is running");
 
 my $send_first_term = IO::Async::Timer::Countdown->new(
-    delay => 5,
-    on_expire => sub {
-        diag "sending first TERM";
-        ok($signal_test->is_running, "signal test is still running");
-        $signal_test->kill('TERM');
-    }
+  delay     => 5,
+  on_expire => sub {
+    diag "sending first TERM";
+    ok($signal_test->is_running, "signal test is still running");
+    $signal_test->kill('TERM');
+  }
 );
 
 $send_first_term->start;
 $loop->add($send_first_term);
 
 my $send_second_term = IO::Async::Timer::Countdown->new(
-    delay => 10,
-    on_expire => sub {
-        diag "sending second TERM";
-        ok($signal_test->is_running, "signal test is still running");
-        $signal_test->kill('TERM');
-    }
+  delay     => 10,
+  on_expire => sub {
+    diag "sending second TERM";
+    ok($signal_test->is_running, "signal test is still running");
+    $signal_test->kill('TERM');
+  }
 );
 $send_second_term->start;
 
 $loop->add($send_second_term);
 
 my $timeout = IO::Async::Timer::Countdown->new(
-    delay => 60,
-    on_expire => sub {
-        fail("test ran for too long");
-        $loop->stop;
-    },
+  delay     => 60,
+  on_expire => sub {
+    fail("test ran for too long");
+    $loop->stop;
+  },
 );
 $timeout->start;
 
@@ -79,7 +79,15 @@ $loop->run;
 
 diag $signal_test_out;
 like($signal_test_out, qr/I have a Future/, "catch_signal() returned a future");
-like($signal_test_out, qr/Got 42 from TERM/, "catch_signal() returned the right value when done");
-unlike($signal_test_out, qr/I Failed My Mission/, "catch_signal() only happened once");
+like(
+  $signal_test_out,
+  qr/Got 42 from TERM/,
+  "catch_signal() returned the right value when done"
+);
+unlike(
+  $signal_test_out,
+  qr/I Failed My Mission/,
+  "catch_signal() only happened once"
+);
 
-done_testing();
\ No newline at end of file
+done_testing();
index 3c8cd055b2af80cff477f5e9cc319b67fc4151bc..6b361ae61f0812c51aa32b98681cf25183d77259 100644 (file)
@@ -14,16 +14,16 @@ use IO::Handle;
 use Test::More;
 
 my $dockerfile = 'Dockerfile';
-my $ci_config = '.circleci/config.yml';
+my $ci_config  = '.circleci/config.yml';
 
 my $base;
 open my $dockerfile_fh, '<', $dockerfile;
 while (my $line = readline $dockerfile_fh) {
-    chomp $line;
-    if ($line =~ /^FROM\s+(\S+)/ms) {
-        $base = $1;
-        last;
-    }
+  chomp $line;
+  if ($line =~ /^FROM\s+(\S+)/ms) {
+    $base = $1;
+    last;
+  }
 }
 close $dockerfile_fh;
 
@@ -40,13 +40,13 @@ my $regex = qr{
 
 open my $ci_config_fh, '<', $ci_config;
 while (my $line = readline $ci_config_fh) {
-    chomp $line;
-    if ($line =~ /($regex)/ms) {
-        my $ln = $ci_config_fh->input_line_number;
-        fail("found docker image $1, expected $base in $ci_config line $ln");
-    }
-    pass("Forbidden version not found");
+  chomp $line;
+  if ($line =~ /($regex)/ms) {
+    my $ln = $ci_config_fh->input_line_number;
+    fail("found docker image $1, expected $base in $ci_config line $ln");
+  }
+  pass("Forbidden version not found");
 }
 close $ci_config_fh;
 
-done_testing;
\ No newline at end of file
+done_testing;
index 7063cf366596efa3e99cced06ae6ea6a9b761081..2b1b4a777fcadcadb63f492002ce2524175d16ef 100644 (file)
@@ -14,32 +14,17 @@ use Test::More;
 binmode STDOUT, ':encoding(utf-8)';
 
 my @expect = (
-    ['dhanesh95'],
-    ['kentuckyfriedtakahe', 'k17e'],
-    ['emceeaich'],
-    ['seban'],
-    ['emceeaich'],
-    ['glob'],
-    ['briansmith', 'bsmith'],
-    ['bz'],
-    ['dkl-test'],
-    ['dylan'],
-    ['7'],
-    ['bwinton'],
-    ['canuckistani'],
-    ['GaryChen', 'PYChen', 'gchen', '陳柏宇'],
-    ['gfx'],
-    ['ted.mielczarek'],
-    [],
-    ['tb-l10n'],
-    ['Gavin'],
-    ['прозвище'],
+  ['dhanesh95'], ['kentuckyfriedtakahe', 'k17e'], ['emceeaich'], ['seban'],
+  ['emceeaich'], ['glob'], ['briansmith', 'bsmith'], ['bz'], ['dkl-test'],
+  ['dylan'], ['7'], ['bwinton'], ['canuckistani'],
+  ['GaryChen', 'PYChen', 'gchen', '陳柏宇'], ['gfx'], ['ted.mielczarek'], [],
+  ['tb-l10n'], ['Gavin'], ['прозвище'],
 
 );
 
 while (<DATA>) {
-    my @nicks = extract_nicks($_);
-    is_deeply(\@nicks, shift @expect);
+  my @nicks = extract_nicks($_);
+  is_deeply(\@nicks, shift @expect);
 }
 
 done_testing;
index 30d3098d4658fd4060f16b611121975912398118..9579b0c39884d8bc25daeadfd43ea8e0cec0e2c0 100644 (file)
@@ -12,13 +12,14 @@ use Bugzilla::Util qw(generate_random_password);
 use Bugzilla::Token qw(issue_hash_sig check_hash_sig);
 use Test::More;
 
-my $localconfig = { site_wide_secret => generate_random_password(256) };
+my $localconfig = {site_wide_secret => generate_random_password(256)};
 {
-    package Bugzilla;
-    sub localconfig { $localconfig }
+
+  package Bugzilla;
+  sub localconfig {$localconfig}
 }
 
 my $sig = issue_hash_sig("hero", "batman");
 ok(check_hash_sig("hero", $sig, "batman"), "sig for batman checks out");
 
-done_testing();
\ No newline at end of file
+done_testing();
index 83e0dc0516df5770848296328625511140951aa4..ca31fcdc02695c249841b576c676e9e3945bde81 100644 (file)
@@ -13,34 +13,30 @@ use Test2::V0;
 
 my $parser = Bugzilla->markdown_parser;
 
-is(
-    $parser->render_html('# header'),
-    "<h1>header</h1>\n",
-    'Simple header'
-);
+is($parser->render_html('# header'), "<h1>header</h1>\n", 'Simple header');
 
 is(
-    $parser->render_html('`code snippet`'),
-    "<p><code>code snippet</code></p>\n",
-    'Simple code snippet'
+  $parser->render_html('`code snippet`'),
+  "<p><code>code snippet</code></p>\n",
+  'Simple code snippet'
 );
 
 is(
-    $parser->render_html('http://bmo-web.vm'),
-    "<p><a href=\"http://bmo-web.vm\">http://bmo-web.vm</a></p>\n",
-    'Autolink extension'
+  $parser->render_html('http://bmo-web.vm'),
+  "<p><a href=\"http://bmo-web.vm\">http://bmo-web.vm</a></p>\n",
+  'Autolink extension'
 );
 
 is(
-    $parser->render_html('<script>hijack()</script>'),
-    "&lt;script>hijack()&lt;/script>\n",
-    'Tagfilter extension'
+  $parser->render_html('<script>hijack()</script>'),
+  "&lt;script>hijack()&lt;/script>\n",
+  'Tagfilter extension'
 );
 
 is(
-    $parser->render_html('~~strikethrough~~'),
-    "<p><del>strikethrough</del></p>\n",
-    'Strikethrough extension'
+  $parser->render_html('~~strikethrough~~'),
+  "<p><del>strikethrough</del></p>\n",
+  'Strikethrough extension'
 );
 
 my $table_markdown = <<'MARKDOWN';
@@ -66,10 +62,6 @@ my $table_html = <<'HTML';
 </table>
 HTML
 
-is(
-    $parser->render_html($table_markdown),
-    $table_html,
-    'Table extension'
-);
+is($parser->render_html($table_markdown), $table_html, 'Table extension');
 
 done_testing;
index 54ceef10061147fb87210e3bfa91f97c6d7cf01d..e031a749bf01124701ddaa23fdbfd474e45eae37 100644 (file)
@@ -16,30 +16,30 @@ use ok 'Bugzilla::Test::MockDB';
 use ok 'Bugzilla::Test::Util', qw(create_user);
 
 try {
-    Bugzilla::Test::MockDB->import();
-    pass('made fake in-memory db');
+  Bugzilla::Test::MockDB->import();
+  pass('made fake in-memory db');
 }
 catch {
-    diag $_;
-    fail('made fake in-memory db');
+  diag $_;
+  fail('made fake in-memory db');
 };
 
 try {
-    create_user('bob@pants.gov', '*');
-    ok( Bugzilla::User->new({name => 'bob@pants.gov'})->id, 'create a user' );
+  create_user('bob@pants.gov', '*');
+  ok(Bugzilla::User->new({name => 'bob@pants.gov'})->id, 'create a user');
 }
 catch {
-    fail('create a user');
+  fail('create a user');
 };
 
 try {
-    my $rob = create_user('rob@pants.gov', '*');
-    Bugzilla::User->check({id => $rob->id});
-    pass('rob@pants.gov checks out');
+  my $rob = create_user('rob@pants.gov', '*');
+  Bugzilla::User->check({id => $rob->id});
+  pass('rob@pants.gov checks out');
 }
 catch {
-    diag $_;
-    fail('rob@pants.gov fails');
+  diag $_;
+  fail('rob@pants.gov fails');
 };
 
 done_testing;
index 7c2318130cdbe3957d316fc6ee8c513ae8f93807..4b8097c6a999dbb9bbb8264420f6582a17f3bcbb 100644 (file)
@@ -12,10 +12,10 @@ use lib qw( . lib local/lib/perl5 );
 use Test::More;
 use Test2::Tools::Mock qw(mock);
 use Bugzilla::Test::MockParams (
-    phabricator_auth_callback_url => 'http://pants.gov/',
-);
+  phabricator_auth_callback_url => 'http://pants.gov/',);
 
-is(Bugzilla->params->{phabricator_auth_callback_url}, 'http://pants.gov/', 'import default params');
+is(Bugzilla->params->{phabricator_auth_callback_url},
+  'http://pants.gov/', 'import default params');
 
 Bugzilla::Test::MockParams->import(phabricator_api_key => 'FAKE-KEY');
 
index 3858025a7ad52e47079401b7b72bc596f0a4c0ba..68c7d4d87aca772329f464cbd230f74d0d8bcdd1 100644 (file)
@@ -11,23 +11,24 @@ use 5.10.1;
 use lib qw( . lib local/lib/perl5 );
 
 BEGIN {
-    $ENV{LOG4PERL_CONFIG_FILE}     = 'log4perl-t.conf';
-    # There's a plugin called Hostage that makes the application require specific Host: headers.
-    # we disable that for these tests.
-    $ENV{BUGZILLA_DISABLE_HOSTAGE} = 1;
+  $ENV{LOG4PERL_CONFIG_FILE} = 'log4perl-t.conf';
+
+# There's a plugin called Hostage that makes the application require specific Host: headers.
+# we disable that for these tests.
+  $ENV{BUGZILLA_DISABLE_HOSTAGE} = 1;
 }
 
 # this provides a default urlbase.
 # Most localconfig options the other Bugzilla::Test::Mock* modules take care for us.
-use Bugzilla::Test::MockLocalconfig ( urlbase => 'http://bmo-web.vm' );
+use Bugzilla::Test::MockLocalconfig (urlbase => 'http://bmo-web.vm');
 
 # This configures an in-memory sqlite database.
 use Bugzilla::Test::MockDB;
 
 # This redirects reads and writes from the config file (data/params)
 use Bugzilla::Test::MockParams (
-    phabricator_enabled => 1,
-    announcehtml        => '<div id="announcement">Mojo::Test is awesome</div>',
+  phabricator_enabled => 1,
+  announcehtml        => '<div id="announcement">Mojo::Test is awesome</div>',
 );
 
 # Util provides a few functions more making mock data in the DB.
@@ -38,7 +39,7 @@ use Test2::Tools::Mock;
 use Test::Mojo;
 
 my $api_user = create_user('api@mozilla.org', '*');
-my $api_key  = issue_api_key('api@mozilla.org')->api_key;
+my $api_key = issue_api_key('api@mozilla.org')->api_key;
 
 # Mojo::Test loads the application and provides methods for
 # testing requests without having to run a server.
@@ -55,22 +56,24 @@ $t->get_ok('/__lbheartbeat__')->status_is(200)->content_is('httpd OK');
 
 # we can use json_is or json_like to check APIs.
 # The first pair to json_like is a JSON pointer (RFC 6901)
-$t->get_ok('/bzapi/configuration')->status_is(200)->json_like( '/announcement' => qr/Mojo::Test is awesome/ );
+$t->get_ok('/bzapi/configuration')->status_is(200)
+  ->json_like('/announcement' => qr/Mojo::Test is awesome/);
 
 # for web requests, you use text_like (or text_is) with CSS selectors.
-$t->get_ok('/')->status_is(200)->text_like( '#announcement' => qr/Mojo::Test is awesome/ );
+$t->get_ok('/')->status_is(200)
+  ->text_like('#announcement' => qr/Mojo::Test is awesome/);
 
 # Chaining is not magical, you can break up longer lines
 # by calling methods on $t, as below.
-$t->get_ok('/rest/whoami' => { 'X-Bugzilla-API-Key' => $api_key });
+$t->get_ok('/rest/whoami' => {'X-Bugzilla-API-Key' => $api_key});
 $t->status_is(200);
 $t->json_is('/name' => $api_user->login);
-$t->json_is('/id' => $api_user->id);
+$t->json_is('/id'   => $api_user->id);
 
 # Each time you call $t->get_ok, post_ok, etc the previous request is cleared.
 $t->get_ok('/rest/whoami');
 $t->status_is(401);
 $t->json_is('/name' => undef);
-$t->json_is('/id' => undef);
+$t->json_is('/id'   => undef);
 
 done_testing;
index a963999f002827f39c836a46770b167af80b4f4e..cafda8165014c82ce73ebce020f2a755a84500aa 100644 (file)
@@ -33,7 +33,8 @@ create_user($oauth_login, $oauth_password);
 # Create a new OAuth2 client used for testing
 my $oauth_client = create_oauth_client('Shiny New OAuth Client', ['user:read']);
 ok $oauth_client->{id}, 'New client id (' . $oauth_client->{id} . ')';
-ok $oauth_client->{secret}, 'New client secret (' . $oauth_client->{secret} . ')';
+ok $oauth_client->{secret},
+  'New client secret (' . $oauth_client->{secret} . ')';
 
 my $t = Test::Mojo->new('Bugzilla::Quantum');
 
@@ -126,8 +127,8 @@ $t->get_ok('/api/user/profile')->status_is(401);
 # 2. Passing a Bearer header containing the access token, the server should
 # allow us to get data about our user
 $t->get_ok('/api/user/profile' =>
-    {Authorization => 'Bearer ' . $access_data->{access_token}})
-  ->status_is(200)->json_is('/login' => $oauth_login);
+    {Authorization => 'Bearer ' . $access_data->{access_token}})->status_is(200)
+  ->json_is('/login' => $oauth_login);
 
 done_testing;
 
index 66f8e5d290529f7624c8b3663e7119ac0fa02808..6b5d8bfd6325092ae8cc91ca1b6038d2dc7e4ddc 100644 (file)
@@ -15,12 +15,12 @@ use Capture::Tiny qw(capture_merged);
 use Bugzilla::Test::MockParams;
 
 BEGIN {
-    $ENV{LOCALCONFIG_ENV} = 'BMO';
-    $ENV{BMO_db_driver} = 'sqlite';
-    $ENV{BMO_db_name} = ':memory:';
-};
+  $ENV{LOCALCONFIG_ENV} = 'BMO';
+  $ENV{BMO_db_driver}   = 'sqlite';
+  $ENV{BMO_db_name}     = ':memory:';
+}
 use Bugzilla;
-BEGIN { Bugzilla->extensions };
+BEGIN { Bugzilla->extensions }
 
 
 isa_ok(Bugzilla->dbh, 'Bugzilla::DB::Sqlite');
@@ -29,61 +29,82 @@ use ok 'Bugzilla::Install';
 use ok 'Bugzilla::Install::DB';
 
 my $lives_ok = sub {
-    my ($desc, $code) = @_;
-    my $output;
-    try {
-        $output = capture_merged { $code->() };
-        pass($desc);
-    } catch {
-        diag $_;
-        fail($desc);
-    } finally {
-        diag "OUTPUT: $output" if $output;
-    };
+  my ($desc, $code) = @_;
+  my $output;
+  try {
+    $output = capture_merged { $code->() };
+    pass($desc);
+  }
+  catch {
+    diag $_;
+    fail($desc);
+  }
+  finally {
+    diag "OUTPUT: $output" if $output;
+  };
 };
 
 my $output = '';
-$lives_ok->('bz_setup_database' => sub {
-     Bugzilla->dbh->bz_setup_database
-});
+$lives_ok->(
+  'bz_setup_database' => sub {
+    Bugzilla->dbh->bz_setup_database;
+  }
+);
+
+$lives_ok->(
+  'bz_populate_enum_tables' => sub {
 
-$lives_ok->('bz_populate_enum_tables' => sub {
     # Populate the tables that hold the values for the <select> fields.
     Bugzilla->dbh->bz_populate_enum_tables();
-});
+  }
+);
 
-$lives_ok->('update_fielddefs_definition' => sub {
+$lives_ok->(
+  'update_fielddefs_definition' => sub {
     Bugzilla::Install::DB::update_fielddefs_definition();
-});
+  }
+);
 
-$lives_ok->('populate_field_definitions' => sub {
+$lives_ok->(
+  'populate_field_definitions' => sub {
     Bugzilla::Field::populate_field_definitions();
-});
+  }
+);
 
-$lives_ok->('init_workflow' => sub {
+$lives_ok->(
+  'init_workflow' => sub {
     Bugzilla::Install::init_workflow();
-});
+  }
+);
 
-$lives_ok->('update_table_definitions' => sub {
+$lives_ok->(
+  'update_table_definitions' => sub {
     Bugzilla::Install::DB->update_table_definitions({});
-});
+  }
+);
 
-$lives_ok->('update_system_groups' => sub {
+$lives_ok->(
+  'update_system_groups' => sub {
     Bugzilla::Install::update_system_groups();
-});
+  }
+);
 
 # "Log In" as the fake superuser who can do everything.
 Bugzilla->set_user(Bugzilla::User->super_user);
 
-$lives_ok->('update_settings' => sub {
+$lives_ok->(
+  'update_settings' => sub {
     Bugzilla::Install::update_settings();
-});
+  }
+);
 
 SKIP: {
-    skip 'default product cannot be created without default assignee', 1;
-    $lives_ok->('create_default_product' => sub {
-        Bugzilla::Install::create_default_product();
-    });
+  skip 'default product cannot be created without default assignee', 1;
+  $lives_ok->(
+    'create_default_product' => sub {
+      Bugzilla::Install::create_default_product();
+    }
+  );
 }
 
 done_testing;
index bd77f5b2098eb8959ed6150d322463f4758dff1b..5ae1a606acf429c050d22f2f2e8d67fe1b17b7be 100644 (file)
@@ -36,7 +36,8 @@ use Test::More;
 
 my %switches;
 GetOptions(\%switches, 'operators=s', 'top-operators=s', 'long',
-                       'add-custom-fields', 'help|h') || die $@;
+  'add-custom-fields', 'help|h')
+  || die $@;
 
 pod2usage(verbose => 1) if $switches{'help'};