diff options
Diffstat (limited to 'qa/t/webservice_group_create.t')
-rw-r--r-- | qa/t/webservice_group_create.t | 157 |
1 files changed, 90 insertions, 67 deletions
diff --git a/qa/t/webservice_group_create.t b/qa/t/webservice_group_create.t index e2c0a725d..8622621a1 100644 --- a/qa/t/webservice_group_create.t +++ b/qa/t/webservice_group_create.t @@ -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 + ); } |