Software Freedom Law Center

root/trunk/antimatter/tim/Bot-BasicBot-Pluggable/t/02module_auth.t

Revision 53, 1.3 kB (checked in by bkuhn, 10 months ago)
  • Added SFLC's internally developed tim bot released under AGPLv3
Line 
1 #!/usr/bin/perl
2 use warnings;
3 use strict;
4 use lib qw(./lib);
5
6 use Test::More no_plan => 1;
7
8 use Bot::BasicBot::Pluggable;
9 use Bot::BasicBot::Pluggable::Module::Auth;
10
11 our $store;
12 no warnings 'redefine';
13 sub Bot::BasicBot::Pluggable::Module::store {
14   $store ||= Bot::BasicBot::Pluggable::Store->new;
15 }
16
17 ok(my $auth = Bot::BasicBot::Pluggable::Module::Auth->new(), "created auth module");
18
19 ok(!$auth->authed('bob'), "bob not authed yet");
20 ok(command("!auth admin muppet"), "sent bad login");
21 ok(!$auth->authed('bob'), "bob not authed yet");
22 ok(command("!auth admin julia"), "sent good login");
23 ok($auth->authed('bob'), "bob authed now");
24
25 ok(command("!adduser bob bob"), "added bob user");
26 ok(command("!auth bob fred"), "not logged in as bob");
27 ok(!$auth->authed('bob'), "not still authed");
28 ok(command("!auth bob bob"), "logged in as bob");
29 ok($auth->authed('bob'), "still authed");
30
31 ok(command("!deluser admin"), "deleted admin user");
32 ok(command("!auth admin julia"), "tried login");
33 ok(!$auth->authed('bob'), "not authed");
34
35 ok(command("!auth bob bob"), "logged in as bob");
36 ok(command("!passwd bob dave"), "changed password");
37 ok(command("!auth bob dave"), "tried login");
38 ok($auth->authed('bob'), "authed");
39
40 sub command {
41   my $body = shift;
42   my $response = $auth->said( {
43     address => 1, body => $body, who => 'bob'
44   }, 1 );
45   #warn "$response\n";
46   return $response;
47 }
Note: See TracBrowser for help on using the browser.

SFLC Main Page

[frdm] Support SFLC