File: 02-denychanges.t

package info (click to toggle)
libsvn-hooks-perl 1.36-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 380 kB
  • sloc: perl: 1,365; makefile: 7
file content (97 lines) | stat: -rwxr-xr-x 1,730 bytes parent folder | download
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# -*- cperl -*-

use strict;
use warnings;
use lib 't';
use Test::More;

require "test-functions.pl";

if (can_svn()) {
    plan tests => 10;
}
else {
    plan skip_all => 'Cannot find or use svn commands.';
}

my $t    = reset_repo();
my $wc   = catdir($t, 'wc');
my $file = catfile($wc, 'file');

set_hook(<<'EOS');
use SVN::Hooks::DenyChanges;
EOS

set_conf(<<'EOS');
DENY_ADDITION('string');
EOS

work_nok('conf: no regex', 'DENY_CHANGES: all arguments must be qr/Regexp/', <<"EOS");
echo txt >$file
svn add -q --no-auto-props $file
svn ci -mx $file
EOS

set_conf(<<'EOS');
DENY_ADDITION(qr/add/, qr/addmore/);
DENY_DELETION(qr/del/);
DENY_UPDATE  (qr/upd/);
EOS

my $add = catfile($wc, 'add');
my $addmore = catfile($wc, 'addmore');
my $del = catfile($wc, 'del');
my $upd = catfile($wc, 'upd');

work_nok('deny add', 'Cannot add:', <<"EOS");
echo txt >$add
svn add -q --no-auto-props $add
svn ci -mx $add
EOS

work_nok('deny second arg', 'Cannot add:', <<"EOS");
echo txt >$addmore
svn add -q --no-auto-props $addmore
svn ci -mx $addmore
EOS

work_ok('add del upd', <<"EOS");
echo txt >$del
echo txt >$upd
svn add -q --no-auto-props $del $upd
svn ci -mx $del $upd
EOS

work_nok('deny del', 'Cannot delete:', <<"EOS");
svn rm -q $del
svn ci -mx $del
EOS

work_nok('deny upd', 'Cannot update:', <<"EOS");
echo adsf >$upd
svn ci -mx $upd
EOS

work_ok('update f', <<"EOS");
echo adsf >$file
svn ci -mx $file
EOS

work_ok('del f', <<"EOS");
svn del -q $file
svn ci -mx $file
EOS

# Grok the author name
ok(my $author = get_author($t), 'grok author');

set_conf(<<"EOS");
DENY_ADDITION(qr/add/);
DENY_EXCEPT_USERS('$author');
EOS

work_ok('except user', <<"EOS");
echo txt >$add
svn add -q --no-auto-props $add
svn ci -mx $add
EOS