New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
04-svnperms.t in vendors/FCM-2017.10.0/t/svn-hooks – NEMO

source: vendors/FCM-2017.10.0/t/svn-hooks/04-svnperms.t @ 13688

Last change on this file since 13688 was 10672, checked in by nicolasmartin, 5 years ago

Reimport latest FCM release

File size: 4.9 KB
Line 
1#!/bin/bash
2#-------------------------------------------------------------------------------
3# (C) British Crown Copyright 2006-17 Met Office.
4#
5# This file is part of FCM, tools for managing and building source code.
6#
7# FCM is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# FCM is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with FCM. If not, see <http://www.gnu.org/licenses/>.
19#-------------------------------------------------------------------------------
20# Basic tests for "pre-commit".
21#-------------------------------------------------------------------------------
22. $(dirname $0)/test_header
23FCM_SVN_HOOK_ADMIN_EMAIL='your.admin.team'
24. $TEST_SOURCE_DIR/test_header_more
25
26svn mkdir --parents $REPOS_URL/foo/trunk -m "create foo trunk"
27svn mkdir --parents $REPOS_URL/foo/branches -m "create foo branches"
28svn mkdir --parents $REPOS_URL/bar/trunk -m "create bar trunk"
29svn mkdir --parents $REPOS_URL/bar/branches -m "create bar branches"
30
31test_tidy() {
32    rm -f \
33        "$REPOS_PATH/hooks/pre-commit-custom" \
34        "$REPOS_PATH/hooks/pre-commit-size-threshold.conf" \
35        "$REPOS_PATH/hooks/commit.conf" \
36        "$REPOS_PATH/hooks/svnperms.conf" \
37        "$REPOS_PATH/log/pre-commit.log" \
38        README \
39        bin/svnperms.py \
40        file1 \
41        file2 \
42        file3 \
43        file4 \
44        mail.out \
45        pre-commit-custom.out \
46        svnperms.py.out
47}
48#-------------------------------------------------------------------------------
49tests 9
50#-------------------------------------------------------------------------------
51cp -p "$FCM_HOME/etc/svn-hooks/pre-commit" "$REPOS_PATH/hooks/"
52sed -i "/set -eu/a\
53echo \$2 >$PWD/txn" "$REPOS_PATH/hooks/pre-commit"
54#-------------------------------------------------------------------------------
55cp "$FCM_HOME/sbin/svnperms.py" "$REPOS_PATH/hooks/"
56REPOS_SHORTNAME=$(basename $REPOS_PATH)
57cat >"$REPOS_PATH/hooks/svnperms.conf" <<__CONF__
58[$REPOS_SHORTNAME groups]
59admin = barry bazzy quxxy xyzzy wibbley
60users = wibbley wobbley wubbley $LOGNAME
61
62[$REPOS_SHORTNAME]
63.* = @admin(add,remove,update)
64
65foo/trunk/.* = @admin(add,remove,update)
66foo/branches/[^/]+/.* = *(add,remove,update)
67foo/tags/[^/]+/.* = @admin(add,remove,update)
68
69bar/trunk/.* = @users(add,remove,update)
70bar/branches/[^/]+/.* = @users(add,remove,update)
71bar/tags/[^/]+/.* = @admin(add,remove,update)
72
73[something_else_svn groups]
74admin = $LOGNAME whoever
75somepeople = bla blubb blabla
76
77[something_else_svn]
78foo/trunk/.* = @admin(add,remove,update)
79foo/branches/[^/]+/.* = @somepeople(add,remove,update)
80foo/tags/[^/]+/.* = @admin(add,remove,update)
81__CONF__
82touch file1
83#-------------------------------------------------------------------------------
84TEST_KEY="$TEST_KEY_BASE-trunk-fail"
85run_fail "$TEST_KEY" \
86    svn import --no-auth-cache -q -m'test' file1 "$REPOS_URL/foo/trunk/file1"
87file_grep "$TEST_KEY.foo-trunk.err" \
88    "error: you don't have enough permissions for this transaction:" \
89    "$TEST_KEY.err"
90#-------------------------------------------------------------------------------
91TEST_KEY="$TEST_KEY_BASE-trunk-fail-custom-err-message"
92echo "
93[message]
94permerrors_prefix = Bad User!" >>"$REPOS_PATH/hooks/svnperms.conf"
95run_fail "$TEST_KEY" \
96    svn import --no-auth-cache -q -m'test' file1 "$REPOS_URL/foo/trunk/file1"
97file_grep "$TEST_KEY.foo-trunk.err" "Bad User!" "$TEST_KEY.err"
98#-------------------------------------------------------------------------------
99TEST_KEY="$TEST_KEY_BASE-trunk-fail-custom-err-message-repos"
100echo "
101[$REPOS_SHORTNAME message]
102permerrors_prefix = FCM police notified" >>"$REPOS_PATH/hooks/svnperms.conf"
103run_fail "$TEST_KEY" \
104    svn import --no-auth-cache -q -m'test' file1 "$REPOS_URL/foo/trunk/file1"
105file_grep "$TEST_KEY.foo-trunk.err" "FCM police notified" "$TEST_KEY.err"
106#-------------------------------------------------------------------------------
107TEST_KEY="$TEST_KEY_BASE-branch-pass-all"
108run_pass "$TEST_KEY" \
109    svn mkdir --parents --no-auth-cache -q -m 'test' \
110    "$REPOS_URL/foo/branches/dev/$LOGNAME/"$(date +%s.%N)
111#-------------------------------------------------------------------------------
112TEST_KEY="$TEST_KEY_BASE-trunk-pass"
113run_pass "$TEST_KEY" \
114    svn import --no-auth-cache -q -m'test' file1 "$REPOS_URL/bar/trunk/file1"
115#-------------------------------------------------------------------------------
116TEST_KEY="$TEST_KEY_BASE-branch-pass-group"
117run_pass "$TEST_KEY" \
118    svn mkdir --parents --no-auth-cache -q -m 'test' \
119    "$REPOS_URL/bar/branches/dev/$LOGNAME/"$(date +%s.%N)
120#-------------------------------------------------------------------------------
121exit
Note: See TracBrowser for help on using the repository browser.