[Rt-commit] rt branch, 4.0/sanity-check-url-config, updated. rt-3.9.7-1135-g7479cd2
Shawn Moore
sartak at bestpractical.com
Tue Dec 28 20:54:53 EST 2010
The branch, 4.0/sanity-check-url-config has been updated
via 7479cd2f3e421114b0dcaa15c57800a2cc10f818 (commit)
from cecdd645659565a2a3e3187793fbc05da1ead2c6 (commit)
Summary of changes:
lib/RT/Config.pm | 19 +++++++++++++++++++
t/api/web-config.t | 34 +++++++++++++++++++++++++++++++++-
2 files changed, 52 insertions(+), 1 deletions(-)
- Log -----------------------------------------------------------------
commit 7479cd2f3e421114b0dcaa15c57800a2cc10f818
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Tue Dec 28 20:54:40 2010 -0500
Validate WebURL
diff --git a/lib/RT/Config.pm b/lib/RT/Config.pm
index 17b12bc..dfdf59a 100644
--- a/lib/RT/Config.pm
+++ b/lib/RT/Config.pm
@@ -621,6 +621,25 @@ our %META = (
}
},
},
+ WebURL => {
+ PostLoadCheck => sub {
+ my $self = shift;
+ my $value = shift;
+
+ if (!$value) {
+ $RT::Logger->error("You must set the WebURL config option");
+ return;
+ }
+
+ if ($value !~ m{^\w+://}) {
+ $RT::Logger->error("The WebURL config option must contain a scheme");
+ }
+
+ if ($value !~ m{/$}) {
+ $RT::Logger->error("The WebURL config option requires a trailing slash");
+ }
+ },
+ },
);
my %OPTIONS = ();
diff --git a/t/api/web-config.t b/t/api/web-config.t
index aa0356a..8037ad5 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 => 65;
+use RT::Test nodb => 1, tests => 83;
sub warnings_from {
my $option = shift;
@@ -143,3 +143,35 @@ like($w[1], qr{The WebBaseURL config option must not contain a path \(/rt/ir/\)}
# reinstate a valid WebBaseURL for other tests
is(warnings_from(WebBaseURL => 'http://rt.example.com'), 0);
+# WebURL
+is(warnings_from(WebURL => 'http://rt.example.com/'), 0);
+is(warnings_from(WebURL => 'http://example.com/rt/'), 0);
+is(warnings_from(WebURL => 'http://example.com/rt/ir/'), 0);
+is(warnings_from(WebURL => 'xtp://rt.example.com/'), 0, 'nonstandard schema is okay?');
+is(warnings_from(WebURL => 'http://rt.example.com:8888/'), 0, 'nonstandard port is okay');
+is(warnings_from(WebURL => 'https://rt.example.com:8888/'), 0, 'nonstandard port with https is okay');
+
+ at w = warnings_from(WebURL => '');
+is(@w, 1);
+like($w[0], qr{You must set the WebURL config option});
+
+ at w = warnings_from(WebURL => 'rt.example.com');
+is(@w, 2);
+like($w[0], qr{The WebURL config option must contain a scheme});
+like($w[1], qr{The WebURL config option requires a trailing slash});
+
+ at w = warnings_from(WebURL => 'http://rt.example.com');
+is(@w, 1);
+like($w[0], qr{The WebURL config option requires a trailing slash});
+
+ at w = warnings_from(WebURL => 'http://rt.example.com/rt');
+is(@w, 1);
+like($w[0], qr{The WebURL config option requires a trailing slash});
+
+ at w = warnings_from(WebURL => 'http://rt.example.com/rt/ir');
+is(@w, 1);
+like($w[0], qr{The WebURL config option requires a trailing slash});
+
+# reinstate a valid WebURL for other tests
+is(warnings_from(WebURL => 'http://rt.example.com/rt/'), 0);
+
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list