File: upstream-tests

package info (click to toggle)
php-net-sieve 1.4.7-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 352 kB
  • sloc: php: 960; xml: 591; sh: 82; makefile: 4
file content (102 lines) | stat: -rwxr-xr-x 2,217 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
98
99
100
101
102
#!/bin/bash

set -ue
PATH="/usr/bin:/bin"
export PATH

TESTDIR=( Net_Sieve-*/tests )
if [ ! -d "$TESTDIR" ]; then
    echo "Missing test directory" >&2
    exit 1
fi

username="user"
password="$(xxd -l16 -p </dev/urandom)"
port=14190

# Cf. Net_Sieve-*/tests/config.php.dist
cat >"$TESTDIR/config.php" <<-EOF
	<?php
	define('HOST', 'localhost');
	define('PORT', $port);
	define('USERNAME', '$username');
	define('PASSWORD', '$password');
EOF


home="$AUTOPKGTEST_TMP/home"
dovecot_dir="$AUTOPKGTEST_TMP/dovecot"
run_dir="$dovecot_dir/run"
mkdir -m0700 -- "$home" "$dovecot_dir"

cat >"$dovecot_dir/config" <<-EOF
	dovecot_config_version = 2.4.0
	dovecot_storage_version = 2.4.0
	log_path = $dovecot_dir/dovecot.log
	mail_home = $home
	mail_driver = maildir
	mail_path = %{home}/mail
	mail_inbox_path = %{home}/mail/inbox
	mailbox_list_index = yes

	ssl = no
	listen = 127.0.0.1, 127.0.1.1, ::1
	namespace inbox {
	    inbox = yes
	}

	# https://doc.dovecot.org/latest/core/config/rootless.html#rootless-installation
	base_dir = ${dovecot_dir}/run
	default_internal_user  = $(id -un)
	default_internal_group = $(id -gn)
	default_login_user     = $(id -un)

	service anvil {
	    chroot =
	}
	service stats {
	    chroot =
	}

	passdb passwd-file {
		passdb_default_password_scheme = plain
		auth_username_format = %{user | username}
		passwd_file_path = $dovecot_dir/users
	}
	userdb passwd-file {
		auth_username_format = %{user | username}
		passwd_file_path = $dovecot_dir/users
	}

	protocols {
		sieve = yes
	}
	service managesieve-login {
	    chroot =
	    inet_listener sieve {
	        port = $port
	    }
	}
EOF

cleanup() {
    local pid
    if ! doveadm -c "$dovecot_dir/config" stop; then
        pid="$(< "$run_dir/master.pid")"
        kill -TERM "$pid" || printf "kill(1) exited with status %d\\n" "$?" >&2
    fi
    rm -rf -- "$dovecot_dir" "$home"
}

/usr/sbin/dovecot -c "$dovecot_dir/config"
trap cleanup EXIT INT TERM

printf "%s:%s::::%s:\\n" "$username" "$password" "$home" >"$dovecot_dir/users"

sleep 1

phpunit_cachedir="$AUTOPKGTEST_TMP/phpunit.cache.d"
install -m0700 -d -- "$phpunit_cachedir"
phpunit --cache-directory "$phpunit_cachedir" \
        --fail-on-skipped \
        "$TESTDIR"