root/t/80remote-adm.t

Revision 303:6f57b7328cb8, 2.6 KB (checked in by Anselm Lingnau <anselm@…>, 9 months ago)

The Great Renaming: Change all command names to 'pl-*' and directory to '.pl'.
The idea behind this is to emphasise that the software is called ?*Project*
Lancelot? as opposed to plain ?Lancelot?. There is apparently a KDE tool that
goes by the name of ?Lancelot?, and we want to make clear that this is separate
and different. Also, Project Lancelot has been around for a lot longer!

Line 
1#!/usr/bin/perl -w
2# Test remote administration capability
3
4use strict;
5
6BEGIN { chdir 't' if -d 't' }
7use lib '../lib';
8
9use Test::More tests => 2;
10use Test::File::Contents;
11
12use Lancelot::SMTPTest qw/run_program/;
13
14use File::Path;
15use Lancelot::DB;
16
17my $smtpport = 4712;            # for now
18my $dir = "../smtp-test";
19
20my $listname = 'pl-testlist@example.com';
21
22rmtree("$ENV{HOME}/.pl/$listname", 0);
23
24my $db = new Lancelot::DB $listname, { create => 1 };
25$db->set_config('list.name', 'Pl-testlist');
26$db->set_config('smtp.server', 'localhost');
27$db->set_config('smtp.port', $smtpport);
28$db->set_config('mail.workflow.admin', 'admin');
29$db->set_config('mail.delimiter', '+');
30$db->add_address('hugo@example.com');
31
32my @cmd = ('../blib/script/pl-incoming', '--verbose=STDERR:all=debug', $listname);
33
34# First try sending an administrative request to a non-administrator
35
36my $message = <<'END';
37Delivered-To: pl-testlist+admin@example.com
38Return-Path: hugo@example.com
39From: hugo@example.com
40To: pl-testlist+admin@example.com
41Subject: remote admin test
42Message-ID: <ra-1@example.com>
43
44list
45END
46
47run_program("lrr-na", \@cmd, $message, $dir);
48
49file_contents_is("$dir/msg.lrr-na.0", <<'END', "list request reply (not admin)");
50SMTP-From: pl-testlist+owner@example.com
51SMTP-To: hugo@example.com
52From: Pl-testlist Management <pl-testlist+owner@example.com>
53To: hugo@example.com
54Subject: Unauthorised administrative request (remote admin test)
55In-Reply-To: <ra-1@example.com>
56
57You tried to send an administrative request to the list but we do not
58have you down as a list administrator. Your message has been ignored.
59
60Do not hesitate to contact us if you have any questions.
61
62The Pl-testlist Management Team
63
64END
65
66# Now try it as an administrator
67
68$db->set_address_options('hugo@example.com', { admin => 1 });
69
70run_program("lrr", \@cmd, $message, $dir);
71
72file_contents_eq_or_diff("$dir/msg.lrr.0", <<'END', "list request reply", { style => 'Unified' });
73SMTP-From: pl-testlist+owner@example.com
74SMTP-To: hugo@example.com
75From: Pl-testlist Management <pl-testlist+owner@example.com>
76To: hugo@example.com
77Subject: Results of your administrative request (remote admin test)
78In-Reply-To: <ra-1@example.com>
79
80Thank you for your administrative request. Here are the results:
81
82.. list
83SA---- hugo@example.com
84
85(Lines beginning with ".." echo your commands. Lines beginning with
86"I:" contain informational messages, and lines beginning with "E:"
87contain error messages. If an error message appears, the operation
88in question will not have been performed.)
89
90Do not hesitate to contact us if you have any questions.
91
92The Pl-testlist Management Team
93
94END
Note: See TracBrowser for help on using the browser.