Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Projets publics
Sympa
Commits
1d3acd86
Commit
1d3acd86
authored
Mar 05, 2020
by
IKEDA Soji
Browse files
Adding tests
parent
ef76342a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Makefile.am
View file @
1d3acd86
...
@@ -35,6 +35,7 @@ check_SCRIPTS = \
...
@@ -35,6 +35,7 @@ check_SCRIPTS = \
t/Message_smime.t
\
t/Message_smime.t
\
t/Message_urlize.t
\
t/Message_urlize.t
\
t/Regexps.t
\
t/Regexps.t
\
t/Scenario.t
\
t/Tools_Data.t
\
t/Tools_Data.t
\
t/Tools_File.t
\
t/Tools_File.t
\
t/Tools_Password.t
\
t/Tools_Password.t
\
...
...
t/Scenario.t
0 → 100644
View file @
1d3acd86
# -*- indent-tabs-mode: nil; -*-
# vim:ft=perl:et:sw=4
use
lib
qw(t/stub)
;
use
strict
;
use
warnings
;
use
English
qw(-no_match_vars)
;
use
File::
Path
qw(make_path rmtree)
;
use
Test::
More
;
BEGIN
{
use_ok
('
Sympa::Scenario
');
}
%
Conf::
Conf
=
(
domain
=>
'
lists.example.com
',
# mandatory
listmaster
=>
'
dude@example.com
',
# mandatory
etc
=>
'
t/tmp/etc
',
);
my
$domain
=
$
Conf::
Conf
{'
domain
'};
my
$list
=
bless
{
name
=>
'
listname
',
domain
=>
$domain
,
dir
=>
Sympa::Constants::
EXPLDIR
()
.
'
/listname
',
admin
=>
{
status
=>
'
open
'}
}
=>
'
Sympa::List
';
make_path
$
Conf::
Conf
{'
etc
'}
.
'
/scenari
'
or
die
$ERRNO
;
my
$scenario
;
# Nonexisting scenarios.
$scenario
=
Sympa::
Scenario
->
new
(
$domain
,
'
create_list
',
name
=>
'
none
');
is
((
$scenario
->
authz
('
smtp
',
{})
||
{})
->
{
action
},
'
reject
');
$scenario
=
Sympa::
Scenario
->
new
(
$list
,
'
visibility
',
name
=>
'
none
');
is
((
$scenario
->
authz
('
smtp
',
{})
||
{})
->
{
action
},
'
reject
');
# ToDo: compile()
# GH issue #860: Crash by bad syntax of regexp
open
my
$fh
,
'
>
',
$
Conf::
Conf
{'
etc
'}
.
'
/scenari/send.bad_regexp
';
print
$fh
<<'EOF';
match([sender],/[custom_vars->sender_whitelist]/) smtp,dkim,md5,smime -> do_it
EOF
close
$fh
;
$scenario
=
Sympa::
Scenario
->
new
(
$list
,
'
send
',
name
=>
'
bad_regexp
');
is
((
$scenario
->
authz
('
smtp
',
{})
||
{})
->
{
action
},
'
reject
',
'
bad regexp syntax
');
# ... and legitimate case
open
my
$fh
,
'
>
',
$
Conf::
Conf
{'
etc
'}
.
'
/scenari/send.good_regexp
';
print
$fh
<<'EOF';
match([sender],/[domain]/) smtp,dkim,md5,smime -> do_it
EOF
close
$fh
;
$scenario
=
Sympa::
Scenario
->
new
(
$list
,
'
send
',
name
=>
'
good_regexp
');
is
(
(
$scenario
->
authz
('
smtp
',
{
sender
=>
'
me@lists.example.com
'})
||
{})
->
{
action
},
'
do_it
',
'
good regexp
'
);
rmtree
'
t/tmp
'
or
die
$ERRNO
;
done_testing
();
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment