From 974d7d3924c0a78e66c6d470fdd57e7e0d6e42d9 Mon Sep 17 00:00:00 2001 From: Andrew Ruthven Date: Sun, 25 Feb 2024 12:23:09 +1300 Subject: [PATCH] Check that all UI pages load without PHP warnings or deprecation messages --- testing/dav_test | 11 +++ testing/gitlab_ci_script.sh | 5 ++ .../tests/webui/0003-load-all-pages.result | 81 +++++++++++++++++++ testing/tests/webui/0003-load-all-pages.test | 53 ++++++++++++ ...edit.result => 0004-principal-edit.result} | 0 ...pal-edit.test => 0004-principal-edit.test} | 0 6 files changed, 150 insertions(+) create mode 100644 testing/tests/webui/0003-load-all-pages.result create mode 100644 testing/tests/webui/0003-load-all-pages.test rename testing/tests/webui/{0003-principal-edit.result => 0004-principal-edit.result} (100%) rename testing/tests/webui/{0003-principal-edit.test => 0004-principal-edit.test} (100%) diff --git a/testing/dav_test b/testing/dav_test index fc6cd48a..403b4d16 100755 --- a/testing/dav_test +++ b/testing/dav_test @@ -24,6 +24,7 @@ my $suite; my $case; my $helpmeplease = 0; my $testmode = 'DAVICAL'; +my $save_location = "/var/log/davical"; # Hash for eval'd Perl code to store long lived variables in my %evaled; @@ -67,6 +68,16 @@ if ( !defined($testdef) ) { die "You need to run this from the testing directory!\n" unless -d "tests"; +# Heuristics to work out if we should make $save_location elsewhere. We want +# /var/log/davical for the CI rig, but within the test directories for localo +# runs. Do we? +if ($ENV{USER} ne 'testrunner') { + $save_location = "tests/$suite/results/"; +} elsif (! -w $save_location) { + warn "$save_location isn't writable, using local location"; + $save_location = "tests/$suite/results/"; +} + my $datafile = $testdef; $datafile =~ s{\.test$}{}; push @arguments, "--header", 'X-DAViCal-Testcase: '.$datafile; diff --git a/testing/gitlab_ci_script.sh b/testing/gitlab_ci_script.sh index db0ccb93..a3b8102d 100755 --- a/testing/gitlab_ci_script.sh +++ b/testing/gitlab_ci_script.sh @@ -158,6 +158,11 @@ cp $davical_repo_path/testing/*.php /usr/share/davical/testing/ mkdir -p /var/log/davical chown www-data /var/log/davical +# Allow the testrunner user to write and read /var/log/davical . +# - Write for saving the output of some tests if they fail +chgrp adm /var/log/davical +chmod 775 /var/log/davical + ### ### Setup DAViCal config files ### diff --git a/testing/tests/webui/0003-load-all-pages.result b/testing/tests/webui/0003-load-all-pages.result new file mode 100644 index 00000000..921dd840 --- /dev/null +++ b/testing/tests/webui/0003-load-all-pages.result @@ -0,0 +1,81 @@ +1..80 +ok 1 - Fetch first page +ok 2 - Not logged in +ok 3 - Login to site +ok 4 - Logged in +ok 5 - Fetch page - http://mycaldav/admin.php?action=browse&t=external +ok 6 - Page has HTTP status 200 - http://mycaldav/admin.php?action=browse&t=external +ok 7 - Page free of Dreprecated warnings - http://mycaldav/admin.php?action=browse&t=external +ok 8 - Page free of Warning warnings - http://mycaldav/admin.php?action=browse&t=external +ok 9 - Fetch page - http://mycaldav/admin.php?action=browse&t=principal&active=f +ok 10 - Page has HTTP status 200 - http://mycaldav/admin.php?action=browse&t=principal&active=f +ok 11 - Page free of Dreprecated warnings - http://mycaldav/admin.php?action=browse&t=principal&active=f +ok 12 - Page free of Warning warnings - http://mycaldav/admin.php?action=browse&t=principal&active=f +ok 13 - Fetch page - http://mycaldav/admin.php?action=browse&t=principal&type=1 +ok 14 - Page has HTTP status 200 - http://mycaldav/admin.php?action=browse&t=principal&type=1 +ok 15 - Page free of Dreprecated warnings - http://mycaldav/admin.php?action=browse&t=principal&type=1 +ok 16 - Page free of Warning warnings - http://mycaldav/admin.php?action=browse&t=principal&type=1 +ok 17 - Fetch page - http://mycaldav/admin.php?action=browse&t=principal&type=1 +ok 18 - Page has HTTP status 200 - http://mycaldav/admin.php?action=browse&t=principal&type=1 +ok 19 - Page free of Dreprecated warnings - http://mycaldav/admin.php?action=browse&t=principal&type=1 +ok 20 - Page free of Warning warnings - http://mycaldav/admin.php?action=browse&t=principal&type=1 +ok 21 - Fetch page - http://mycaldav/admin.php?action=browse&t=principal&type=1 +ok 22 - Page has HTTP status 200 - http://mycaldav/admin.php?action=browse&t=principal&type=1 +ok 23 - Page free of Dreprecated warnings - http://mycaldav/admin.php?action=browse&t=principal&type=1 +ok 24 - Page free of Warning warnings - http://mycaldav/admin.php?action=browse&t=principal&type=1 +ok 25 - Fetch page - http://mycaldav/admin.php?action=browse&t=principal&type=2 +ok 26 - Page has HTTP status 200 - http://mycaldav/admin.php?action=browse&t=principal&type=2 +ok 27 - Page free of Dreprecated warnings - http://mycaldav/admin.php?action=browse&t=principal&type=2 +ok 28 - Page free of Warning warnings - http://mycaldav/admin.php?action=browse&t=principal&type=2 +ok 29 - Fetch page - http://mycaldav/admin.php?action=browse&t=principal&type=3 +ok 30 - Page has HTTP status 200 - http://mycaldav/admin.php?action=browse&t=principal&type=3 +ok 31 - Page free of Dreprecated warnings - http://mycaldav/admin.php?action=browse&t=principal&type=3 +ok 32 - Page free of Warning warnings - http://mycaldav/admin.php?action=browse&t=principal&type=3 +ok 33 - Fetch page - http://mycaldav/admin.php?action=browse&t=principal&type=4 +ok 34 - Page has HTTP status 200 - http://mycaldav/admin.php?action=browse&t=principal&type=4 +ok 35 - Page free of Dreprecated warnings - http://mycaldav/admin.php?action=browse&t=principal&type=4 +ok 36 - Page free of Warning warnings - http://mycaldav/admin.php?action=browse&t=principal&type=4 +ok 37 - Fetch page - http://mycaldav/admin.php?action=edit&t=principal +ok 38 - Page has HTTP status 200 - http://mycaldav/admin.php?action=edit&t=principal +ok 39 - Page free of Dreprecated warnings - http://mycaldav/admin.php?action=edit&t=principal +ok 40 - Page free of Warning warnings - http://mycaldav/admin.php?action=edit&t=principal +ok 41 - Fetch page - http://mycaldav/admin.php?action=edit&t=principal&id=1 +ok 42 - Page has HTTP status 200 - http://mycaldav/admin.php?action=edit&t=principal&id=1 +ok 43 - Page free of Dreprecated warnings - http://mycaldav/admin.php?action=edit&t=principal&id=1 +ok 44 - Page free of Warning warnings - http://mycaldav/admin.php?action=edit&t=principal&id=1 +ok 45 - Fetch page - http://mycaldav/davical.css +ok 46 - Page has HTTP status 200 - http://mycaldav/davical.css +ok 47 - Page free of Dreprecated warnings - http://mycaldav/davical.css +ok 48 - Page free of Warning warnings - http://mycaldav/davical.css +ok 49 - Fetch page - http://mycaldav/help.php +ok 50 - Page has HTTP status 200 - http://mycaldav/help.php +ok 51 - Page free of Dreprecated warnings - http://mycaldav/help.php +ok 52 - Page free of Warning warnings - http://mycaldav/help.php +ok 53 - Fetch page - http://mycaldav/iSchedule.php +ok 54 - Page has HTTP status 200 - http://mycaldav/iSchedule.php +ok 55 - Page free of Dreprecated warnings - http://mycaldav/iSchedule.php +ok 56 - Page free of Warning warnings - http://mycaldav/iSchedule.php +ok 57 - Fetch page - http://mycaldav/index.php +ok 58 - Page has HTTP status 200 - http://mycaldav/index.php +ok 59 - Page free of Dreprecated warnings - http://mycaldav/index.php +ok 60 - Page free of Warning warnings - http://mycaldav/index.php +ok 61 - Fetch page - http://mycaldav/index.php +ok 62 - Page has HTTP status 200 - http://mycaldav/index.php +ok 63 - Page free of Dreprecated warnings - http://mycaldav/index.php +ok 64 - Page free of Warning warnings - http://mycaldav/index.php +ok 65 - Fetch page - http://mycaldav/setup.php +ok 66 - Page has HTTP status 200 - http://mycaldav/setup.php +ok 67 - Page free of Dreprecated warnings - http://mycaldav/setup.php +ok 68 - Page free of Warning warnings - http://mycaldav/setup.php +ok 69 - Fetch page - http://mycaldav/tools.php +ok 70 - Page has HTTP status 200 - http://mycaldav/tools.php +ok 71 - Page free of Dreprecated warnings - http://mycaldav/tools.php +ok 72 - Page free of Warning warnings - http://mycaldav/tools.php +ok 73 - Fetch page - http://mycaldav/upgrade.php +ok 74 - Page has HTTP status 200 - http://mycaldav/upgrade.php +ok 75 - Page free of Dreprecated warnings - http://mycaldav/upgrade.php +ok 76 - Page free of Warning warnings - http://mycaldav/upgrade.php +ok 77 - Fetch page - http://mycaldav/index.php?logout +ok 78 - Page has HTTP status 200 - http://mycaldav/index.php?logout +ok 79 - Page free of Dreprecated warnings - http://mycaldav/index.php?logout +ok 80 - Page free of Warning warnings - http://mycaldav/index.php?logout diff --git a/testing/tests/webui/0003-load-all-pages.test b/testing/tests/webui/0003-load-all-pages.test new file mode 100644 index 00000000..42623ec5 --- /dev/null +++ b/testing/tests/webui/0003-load-all-pages.test @@ -0,0 +1,53 @@ +MODE=TAP,80 + +BEGINPERL + +my $mech = webui_login( + username => 'admin', + password => 'nimda', + url => "http://$webhost", +); + +for my $link (sort { $a->url cmp $b->url } $mech->links()) { + my $url = $link->url(); + + # Only consider local pages. + next unless $url =~ m,^/,; + + # Don't logout... + next if $url =~ m,logout$,; + + check_url($url); +} + +# Finally check logout... +check_url("/index.php?logout"); + +sub check_url { + my $url = shift; + + my $failed = 0; + $url = "http://$webhost$url"; + + $mech->get_ok($url, "Fetch page - $url") + || do { $failed = 1 }; + ok($mech->response->code == 200, "Page has HTTP status 200 - $url") + || do { + diag("HTTP Status: " . $mech->status()); + $failed = 1; + }; + $mech->content_lacks('Deprecated:', + "Page free of Dreprecated warnings - $url") + || do { $failed = 1 }; + $mech->content_lacks('Warning:', + "Page free of Warning warnings - $url") + || do { $failed = 1 }; + + if ($failed) { + $url =~ s,[/:],_,g; + diag("Saved content of $url to $save_location/$case-$url"); + $mech->save_content("$save_location/$case-$url", binmode => ':utf8'); + } +} + +ENDPERL diff --git a/testing/tests/webui/0003-principal-edit.result b/testing/tests/webui/0004-principal-edit.result similarity index 100% rename from testing/tests/webui/0003-principal-edit.result rename to testing/tests/webui/0004-principal-edit.result diff --git a/testing/tests/webui/0003-principal-edit.test b/testing/tests/webui/0004-principal-edit.test similarity index 100% rename from testing/tests/webui/0003-principal-edit.test rename to testing/tests/webui/0004-principal-edit.test