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/user_offer_account_by_email.t | 63 +++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 xt/webservice/user_offer_account_by_email.t (limited to 'xt/webservice/user_offer_account_by_email.t') diff --git a/xt/webservice/user_offer_account_by_email.t b/xt/webservice/user_offer_account_by_email.t new file mode 100644 index 000000000..785932167 --- /dev/null +++ b/xt/webservice/user_offer_account_by_email.t @@ -0,0 +1,63 @@ +# 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 User.offer_account_by_email() # +######################################################### + +use 5.10.1; +use strict; +use warnings; + +use FindBin qw($RealBin); +use lib "$RealBin/../lib"; + +use QA::Util; +use Test::More tests => 29; +my ($config, $xmlrpc, $jsonrpc, $jsonrpc_get) = get_rpc_clients(); + +# These are the characters that are actually invalid per RFC. +use constant INVALID_EMAIL => '()[]\;:,<>@webservice.test'; + +sub new_login { + 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'); + +# 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'); +} -- cgit v1.2.3-24-g4f1b