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 "fcm-add-trac-env". |
---|
21 | #------------------------------------------------------------------------------- |
---|
22 | . $(dirname $0)/test_header |
---|
23 | #------------------------------------------------------------------------------- |
---|
24 | if ! which trac-admin 1>/dev/null 2>/dev/null; then |
---|
25 | skip_all 'trac-admin not available' |
---|
26 | fi |
---|
27 | tests 28 |
---|
28 | #------------------------------------------------------------------------------- |
---|
29 | set -e |
---|
30 | mkdir -p etc srv/{svn,trac} |
---|
31 | # Configuration |
---|
32 | export FCM_CONF_PATH="$PWD/etc" |
---|
33 | ADMIN_USERS='holly ivy' |
---|
34 | cat >'etc/admin.cfg' <<__CONF__ |
---|
35 | svn_live_dir=$PWD/srv/svn |
---|
36 | trac_admin_users=$ADMIN_USERS |
---|
37 | trac_live_dir=$PWD/srv/trac |
---|
38 | __CONF__ |
---|
39 | # Create some Subversion repositories |
---|
40 | for NAME in bus lorry taxi; do |
---|
41 | svnadmin create "srv/svn/$NAME" |
---|
42 | done |
---|
43 | set +e |
---|
44 | #------------------------------------------------------------------------------- |
---|
45 | for NAME in bus car lorry taxi; do |
---|
46 | TEST_KEY="$TEST_KEY_BASE-$NAME" |
---|
47 | # Command OK |
---|
48 | run_pass "$TEST_KEY" "$FCM_HOME/sbin/fcm-add-trac-env" "$NAME" |
---|
49 | # Trac environment directory exists |
---|
50 | run_pass "$TEST_KEY-d" test -d "$PWD/srv/trac/$NAME" |
---|
51 | # Admin users are set |
---|
52 | trac-admin "$PWD/srv/trac/$NAME" 'permission' 'export' "$TEST_KEY-d-perms" |
---|
53 | # For some reason, the "echo" for the next test is lost in the ether unless |
---|
54 | # we have an "echo" here. |
---|
55 | echo |
---|
56 | for ADMIN_USER in $ADMIN_USERS; do |
---|
57 | file_grep "$TEST_KEY-d-perms-$ADMIN_USER" \ |
---|
58 | "$ADMIN_USER,admin" "$TEST_KEY-d-perms" |
---|
59 | done |
---|
60 | file_grep "$TEST_KEY-d-perms-owner" "owner,TRAC_ADMIN" "$TEST_KEY-d-perms" |
---|
61 | file_grep "$TEST_KEY-d-perms-admin" "admin,TRAC_ADMIN" "$TEST_KEY-d-perms" |
---|
62 | # Subversion repository paths in place |
---|
63 | if [[ -d "srv/svn/$NAME" ]]; then |
---|
64 | file_grep "$TEST_KEY-repository_dir" \ |
---|
65 | "dir=$PWD/srv/svn/$NAME" \ |
---|
66 | "$PWD/srv/trac/$NAME/conf/trac.ini" |
---|
67 | fi |
---|
68 | done |
---|
69 | |
---|
70 | TEST_KEY="$TEST_KEY_BASE-intertrac" |
---|
71 | file_cmp "$TEST_KEY" "$PWD/srv/trac/intertrac.ini" <<'__CONF__' |
---|
72 | [intertrac] |
---|
73 | bus.title=bus |
---|
74 | bus.url=https://localhost/trac/bus |
---|
75 | bus.compat=false |
---|
76 | car.title=car |
---|
77 | car.url=https://localhost/trac/car |
---|
78 | car.compat=false |
---|
79 | lorry.title=lorry |
---|
80 | lorry.url=https://localhost/trac/lorry |
---|
81 | lorry.compat=false |
---|
82 | taxi.title=taxi |
---|
83 | taxi.url=https://localhost/trac/taxi |
---|
84 | taxi.compat=false |
---|
85 | __CONF__ |
---|
86 | #------------------------------------------------------------------------------- |
---|
87 | exit |
---|