summaryrefslogtreecommitdiffstats
path: root/t/srs.t
blob: 824d8e96bbaca562f6ae364983dea28a42d1dc1e (plain)
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
use strict;
use warnings;

use Test::More;# tests => 8;

BEGIN {
    use_ok 'Spline::Srs', qw(
        check_exclude
        srs_forward
        srs_reverse
    ) or BAIL_OUT;
}

# Testing ignores
is(check_exclude('test@example.com', 'example.com'), 1, 'Ignore matching domain');
is(check_exclude('test@example.de', 'example.com'), 0, 'Do not ignore non-matching domain');
is(check_exclude('test@test.example.com', 'example.com'), 0, 'Do not ignore sub-domain');
is(check_exclude('test@test.example.com', '.example.com'), 1, 'Ignore sub-domain if requested');

# SRS Forward
my $result = srs_forward('alex@example.com');
isnt($result, undef, 'Not undef');
like($result, qr/^SRS0[+=-]/, 'SRS0 Prefix');
like($result, qr/\@spline\.inf\.fu-berlin\.de$/, 'Rewrite to spline-Domain');

# SRS Reverse
is(Spline::Srs::srs_forward('alex@domain.invalid'), 'SRS0=7tXNg=SJ=domain.invalid=alex@spline.inf.fu-berlin.de', 'Forward');
is(Spline::Srs::srs_reverse('SRS0=7tXNg=SJ=domain.invalid=alex@spline.inf.fu-berlin.de'), 'alex@domain.invalid', 'Reverse');

done_testing;

# vim: set et ts=4: