[Rt-commit] rt branch, 4.0/sanity-check-url-config, updated. rt-3.9.7-1131-g9dc1eca
Shawn Moore
sartak at bestpractical.com
Tue Dec 28 20:10:58 EST 2010
The branch, 4.0/sanity-check-url-config has been updated
via 9dc1eca1511d46e4ac71fa089b0dee1777ea0809 (commit)
from a6a2c93f569bc742c214cb0824b6111d3b22898b (commit)
Summary of changes:
lib/RT/Config.pm | 19 +++++++++++++++++++
t/api/web-config.t | 26 +++++++++++++++++++++++++-
2 files changed, 44 insertions(+), 1 deletions(-)
- Log -----------------------------------------------------------------
commit 9dc1eca1511d46e4ac71fa089b0dee1777ea0809
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Tue Dec 28 20:10:35 2010 -0500
Validate WebBaseURL
Still need to validate that it is the combination of the other
options, but getting there
diff --git a/lib/RT/Config.pm b/lib/RT/Config.pm
index d402129..fb483ab 100644
--- a/lib/RT/Config.pm
+++ b/lib/RT/Config.pm
@@ -598,6 +598,25 @@ our %META = (
}
},
},
+ WebBaseURL => {
+ PostLoadCheck => sub {
+ my $self = shift;
+ my $value = shift;
+
+ if (!$value) {
+ $RT::Logger->error("You must set the WebBaseURL config option");
+ return;
+ }
+
+ if ($value !~ m{^\w+://}) {
+ $RT::Logger->error("The WebDomain config option must contain a scheme");
+ }
+
+ if ($value =~ m{/$}) {
+ $RT::Logger->error("The WebDomain config option requires no trailing slash");
+ }
+ },
+ },
);
my %OPTIONS = ();
diff --git a/t/api/web-config.t b/t/api/web-config.t
index 390eb94..e156320 100644
--- a/t/api/web-config.t
+++ b/t/api/web-config.t
@@ -1,7 +1,7 @@
use strict;
use warnings;
use RT;
-use RT::Test nodb => 1, tests => 34;
+use RT::Test nodb => 1, tests => 46;
sub warnings_from {
my $option = shift;
@@ -86,3 +86,27 @@ like($w[0], qr{The WebPort config option must be an integer});
# reinstate a valid WebDomain for other tests
is(warnings_from(WebPort => 443), 0);
+# WebBaseURL
+is(warnings_from(WebBaseURL => 'http://rt.example.com/rt'), 0);
+is(warnings_from(WebBaseURL => 'xtp://rt.example.com/rt'), 0, 'nonstandard schema is okay');
+is(warnings_from(WebBaseURL => 'http://rt.example.com:8888/rt'), 0, 'nonstandard port is okay');
+
+ at w = warnings_from(WebBaseURL => '');
+is(@w, 1);
+like($w[0], qr{You must set the WebBaseURL config option});
+
+ at w = warnings_from(WebBaseURL => 'rt.example.com');
+is(@w, 1);
+like($w[0], qr{The WebDomain config option must contain a scheme});
+
+ at w = warnings_from(WebBaseURL => 'http://rt.example.com/');
+is(@w, 1);
+like($w[0], qr{The WebDomain config option requires no trailing slash});
+
+ at w = warnings_from(WebBaseURL => 'http://rt.example.com/rt/');
+is(@w, 1);
+like($w[0], qr{The WebDomain config option requires no trailing slash});
+
+# reinstate a valid WebDomain for other tests
+is(warnings_from(WebBaseURL => 'http://rt.example.com/rt'), 0);
+
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list