mirror of
https://gitlab.com/davical-project/davical.git
synced 2026-08-29 18:26:05 +00:00
Allow tests to provide configuration over rides
Written to provide scope for Apache2 config overrides as well (I think I'll need these to add Kerberos testing...)
This commit is contained in:
parent
3da860e5d5
commit
569b20d92f
1
testing/.gitignore
vendored
Normal file
1
testing/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
regression-conf.php.dynamic.per-test
|
||||
@ -90,6 +90,14 @@ my $request_id_file = "$save_location/$case.request_id";
|
||||
open(my $REQUEST_ID_FILE, "> $request_id_file")
|
||||
|| die "Failed to open $request_id_file for writing";
|
||||
|
||||
# Allow for application configuration per test file. Ensure the file we
|
||||
# manage is empty in case the previous test was aborted.
|
||||
my $dynamic_app_conf_file = 'regression-conf.php.dynamic.per-test';
|
||||
if (-f $dynamic_app_conf_file) {
|
||||
unlink $dynamic_app_conf_file
|
||||
|| die "Failed to remove $dynamic_app_conf_file\n";
|
||||
}
|
||||
|
||||
my $datafile = $testdef;
|
||||
$datafile =~ s{\.test$}{};
|
||||
push @arguments, "--header", 'X-DAViCal-Testcase: '.$datafile;
|
||||
@ -98,13 +106,14 @@ $datafile .= '.data';
|
||||
my $state = "";
|
||||
my $data_binary;
|
||||
|
||||
my $sql_variable = "";
|
||||
my $sql_variable = "";
|
||||
my $sql_statement = "";
|
||||
my $sql_values = {};
|
||||
my $perl_code = "";
|
||||
my $sql_values = {};
|
||||
my $queries = ();
|
||||
my $app_conf = "";
|
||||
my $queries = ();
|
||||
my $replacements = ();
|
||||
my $line_number = 0;
|
||||
my $line_number = 0;
|
||||
|
||||
|
||||
open( TEST, '<', $testdef ) or die "Can't open '$testdef'";
|
||||
@ -119,7 +128,7 @@ while( <TEST> ) {
|
||||
}
|
||||
|
||||
if ( $state ne "" ) {
|
||||
$line =~ /^BEGIN(DATA|PERL)/ && do {
|
||||
$line =~ /^BEGIN(?!:)/ && do {
|
||||
print "Found a new BEGIN line, while still processing a previous one. Line number: $line_number\n";
|
||||
exit 0;
|
||||
};
|
||||
@ -141,6 +150,9 @@ while( <TEST> ) {
|
||||
exit 0;
|
||||
}
|
||||
}
|
||||
elsif ( $state eq "APPCONF" ) {
|
||||
write_app_conf($app_conf);
|
||||
}
|
||||
$state = "";
|
||||
}
|
||||
elsif ( $state eq "DATA" ) {
|
||||
@ -152,6 +164,9 @@ while( <TEST> ) {
|
||||
elsif ( $state eq "PERL" ) {
|
||||
$perl_code .= $line;
|
||||
}
|
||||
elsif ( $state eq "APPCONF" ) {
|
||||
$app_conf .= $line;
|
||||
}
|
||||
next;
|
||||
}
|
||||
|
||||
@ -226,6 +241,11 @@ while( <TEST> ) {
|
||||
$state = "PERL";
|
||||
};
|
||||
|
||||
$line =~ /^BEGINAPPCONF\s*$/ && do {
|
||||
$app_conf = "";
|
||||
$state = "APPCONF";
|
||||
};
|
||||
|
||||
$line =~ /^(?:BEGIN)?GETSQL\s*=\s*(\S.*)$/ && do {
|
||||
$sql_variable = $1;
|
||||
$sql_statement = "";
|
||||
@ -237,6 +257,26 @@ while( <TEST> ) {
|
||||
$state = "DOSQL";
|
||||
};
|
||||
|
||||
$line =~ /^\s*APPCONF\s*=\s*(\S.*)$/ && do {
|
||||
my $basename = $1;
|
||||
my $test_app_conf_file;
|
||||
|
||||
if ( -e "tests/$suite/$basename.appconf" ) {
|
||||
$test_app_conf_file="tests/$suite/$basename.appconf";
|
||||
}
|
||||
elsif ( -e "tests/$suite/$basename" ) {
|
||||
$test_app_conf_file="tests/$suite/$basename";
|
||||
}
|
||||
|
||||
if (! defined $test_app_conf_file) {
|
||||
die "Can't find app conf file $basename or $basename.appconf";
|
||||
}
|
||||
|
||||
copy $test_app_conf_file, $dynamic_app_conf_file
|
||||
|| die "Failed to copy $test_app_conf_file to $dynamic_app_conf_file: $!\n";
|
||||
};
|
||||
|
||||
|
||||
$line =~ /^REPLACE\s*=\s*(\S)(.*)$/ && do {
|
||||
my $separator = $1;
|
||||
$2 =~ /^([^$separator]*)$separator([^$separator]*)$separator$/ && do {
|
||||
@ -506,6 +546,22 @@ sub webui_login {
|
||||
return $mech;
|
||||
}
|
||||
|
||||
=item write_app_conf()
|
||||
|
||||
Write per test configuration entries to the DAViCal regression test server
|
||||
configuration.
|
||||
|
||||
=cut
|
||||
|
||||
sub write_app_conf {
|
||||
my $content = shift;
|
||||
|
||||
# We may wany to append extra content to a common file.
|
||||
open(my $FILE, ">> $dynamic_app_conf_file")
|
||||
|| die "Failed to open $dynamic_app_conf_file for writing";
|
||||
print $FILE $content;
|
||||
}
|
||||
|
||||
|
||||
sub usage {
|
||||
print <<EOERROR ;
|
||||
@ -556,6 +612,16 @@ BEGINPERL
|
||||
my \$variable = 'foo';
|
||||
ENDPERL
|
||||
|
||||
# Dynamically add content to the DAViCal configuration file for this test.
|
||||
# Allows ad-hoc config changes for tests. See also APPCONF. If APPCONF isn't
|
||||
# used, then you must start this with "<?php" as below. If APPCONF is used,
|
||||
# then it must start with "<?php".
|
||||
BEGINAPPCONF
|
||||
<?php
|
||||
|
||||
\$valid_php = "in here";
|
||||
ENDAPPCONF
|
||||
|
||||
REPLACE=/pattern/replacement/
|
||||
=================================================
|
||||
|
||||
@ -566,6 +632,10 @@ HEAD Whether to include the headers in the recorded response
|
||||
VERBOSE Whether to provide the full request / response headers.
|
||||
DATA The name of a different test in this suite to use data from.
|
||||
REPLACE A perl regex replacement to post-process the result through.
|
||||
APPCONF A file that will be insert into the DAViCal config file. This is
|
||||
inserted first, before any content in BEGINAPPCONF/ENDAPPCONF to
|
||||
allow a common config file for a set of tests, but also to allow
|
||||
for individual test overrides.
|
||||
|
||||
Additionally, if a file 'tests/<testsuite>/<testname>.data' exists
|
||||
the contents of that file will be sent in the body of the request.
|
||||
|
||||
@ -69,4 +69,6 @@
|
||||
'cal._domainkey.caldav' => 'v=DKIM1; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArTRqr/W5wSlxDKthes0Bz2fIkukLOu0tNIbxO9GpsjgaE3juPnl9XlkMxvkGQ5k7NTy2yRIYDFqDzT150MiMLsIbOnXlOZVizlM8MXe65do6BNCnjNZRNj30pEHirhJsQf0eEc9+AY1qDbC2axqd1Nf8MNl0bJ58O0ZCPnzdDNxsWp16midWoj0uceonpg1qxp7kYD2CC5/WcrsBHc8Lt3y2N9X4pamAvd0fAfVXYrzLSVvmc1b09yEq3weT4R4Jiizjb7UPPZCyarDDOUKfjcBsPCJtBDv7al6easoCUvHviJKy48bmcFcgnyL1FfKVdIaKlyb3nLj9dFTFm/tdTQIDAQAB',
|
||||
);
|
||||
|
||||
// Allow dynamic configuration of application by tests.
|
||||
include 'regression-conf.php.dynamic.per-test';
|
||||
?>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user