From 9b6ec1f545da1cc4088ddf9cc117747954e58e65 Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Fri, 26 Feb 2016 17:57:55 +0000 Subject: Bug 1069799 - move the QA repository into the main repository r=LpSolit --- xt/webservice/bug_update_see_also.t | 86 +++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 xt/webservice/bug_update_see_also.t (limited to 'xt/webservice/bug_update_see_also.t') diff --git a/xt/webservice/bug_update_see_also.t b/xt/webservice/bug_update_see_also.t new file mode 100644 index 000000000..79c3b5ea8 --- /dev/null +++ b/xt/webservice/bug_update_see_also.t @@ -0,0 +1,86 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This Source Code Form is "Incompatible With Secondary Licenses", as +# defined by the Mozilla Public License, v. 2.0. + +################################################# +# Test for xmlrpc call to Bug.update_see_also() # +################################################# + +use 5.10.1; +use strict; +use warnings; + +use FindBin qw($RealBin); +use lib "$RealBin/../lib"; + +use QA::Util; +use QA::Tests qw(PRIVATE_BUG_USER STANDARD_BUG_TESTS); +use Test::More tests => 117; +my ($config, $xmlrpc, $jsonrpc, $jsonrpc_get) = get_rpc_clients(); + +my $bug_url = 'http://landfill.bugzilla.org/bugzilla-tip/show_bug.cgi?id=100'; + +# update_see_also doesn't support logged-out users. +my @tests = grep { $_->{user} } @{ STANDARD_BUG_TESTS() }; +foreach my $t (@tests) { + $t->{args}->{add} = $t->{args}->{remove} = []; +} + +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'] }, + error => 'asdf', + test => 'Admin cannot add an invalid URL', + }, + { user => 'admin', + args => { ids => ['public_bug'], remove => ['asdfasdfasdf'] }, + test => 'Invalid URL silently ignored', + }, + + { 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] }, + 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] }, + test => 'Admin can remove a URL from a public bug', + }, + + { 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] }, + 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"); +} + +$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); +} -- cgit v1.2.3-24-g4f1b