File: 34-secure.t

package info (click to toggle)
libmediawiki-bot-perl 5.007000-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 656 kB
  • sloc: perl: 1,992; makefile: 5
file content (39 lines) | stat: -rw-r--r-- 1,103 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use strict;
use warnings;
use Test::Is qw(extended);
use Test::RequiresInternet 'test.wikipedia.org' => 443;
use Test::More tests => 1;

use MediaWiki::Bot qw(:constants);
my $t = __FILE__;

my $username = $ENV{'PWPUsername'};
my $password = $ENV{'PWPPassword'};
my $login_data;
if (defined($username) and defined($password)) {
    $login_data = { username => $username, password => $password };
}

my $agent = "MediaWiki::Bot tests (https://metacpan.org/MediaWiki::Bot; $t)";
my $bot   = MediaWiki::Bot->new({
    agent       => $agent,
    host        => 'test.wikipedia.org',
    protocol    => 'https',
    login_data  => $login_data,
});

my $rand   = rand();
my $page   = 'User:Mike.lifeguard/34-secure.t';
my $status = $bot->edit({
    page    => $page,
    text    => $rand,
    summary => $agent,
});
SKIP: {
    skip 'You are blocked, cannot use editing tests', 1
        if defined $bot->{error}->{code}
        and ($bot->{error}->{code} == ERR_API or $bot->{error}->{code} == ERR_CAPTCHA);

    my $is = $bot->get_text($page);
    is($is, $rand, 'Edited via secure server successfully');
}