[Rt-commit] rt branch, 4.0/sanity-check-url-config, updated. rt-3.9.7-1129-gb04468b
Shawn Moore
sartak at bestpractical.com
Tue Dec 28 19:19:56 EST 2010
The branch, 4.0/sanity-check-url-config has been updated
via b04468be8ffa4178c7476f1b6c5f8d1414e794f6 (commit)
from b95abf852c1bd5cac77dc9d94faf16647f888e5f (commit)
Summary of changes:
lib/RT/Config.pm | 21 +++++++++++++++++++++
t/api/web-config.t | 30 +++++++++++++++++++++++++++++-
2 files changed, 50 insertions(+), 1 deletions(-)
- Log -----------------------------------------------------------------
commit b04468be8ffa4178c7476f1b6c5f8d1414e794f6
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Tue Dec 28 19:18:54 2010 -0500
Validate WebDomain
diff --git a/lib/RT/Config.pm b/lib/RT/Config.pm
index 265d706..d7ed5c1 100644
--- a/lib/RT/Config.pm
+++ b/lib/RT/Config.pm
@@ -562,6 +562,27 @@ our %META = (
}
},
},
+ WebDomain => {
+ PostLoadCheck => sub {
+ my $self = shift;
+ my $value = shift;
+
+ if (!$value) {
+ $RT::Logger->error("You must set the WebDomain config option");
+ return;
+ }
+
+ if ($value =~ m{^(\w+://)}) {
+ $RT::Logger->error("The WebDomain config option must not contain a scheme ($1)");
+ return;
+ }
+
+ if ($value =~ m{(/.*)}) {
+ $RT::Logger->error("The WebDomain config option must not contain a path ($1)");
+ return;
+ }
+ },
+ },
);
my %OPTIONS = ();
diff --git a/t/api/web-config.t b/t/api/web-config.t
index c91d1fa..316a4a9 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 => 11;
+use RT::Test nodb => 1, tests => 24;
sub warnings_from {
my $option = shift;
@@ -18,6 +18,7 @@ sub warnings_from {
return @warnings;
}
+# WebPath
is(warnings_from(WebPath => ''), 0);
is(warnings_from(WebPath => '/foo'), 0);
@@ -38,3 +39,30 @@ like($w[1], qr/The WebPath config option requires a leading slash/);
is(@w, 1);
like($w[0], qr{For the WebPath config option, use the empty string instead of /});
+# reinstate a valid WebPath for other tests
+is(warnings_from(WebPath => '/rt'), 0);
+
+# WebDomain
+is(warnings_from(WebDomain => 'example.com'), 0);
+is(warnings_from(WebDomain => 'rt.example.com'), 0);
+is(warnings_from(WebDomain => 'localhost'), 0);
+
+ at w = warnings_from(WebDomain => '');
+is(@w, 1);
+like($w[0], qr{You must set the WebDomain config option});
+
+ at w = warnings_from(WebDomain => 'http://rt.example.com');
+is(@w, 1);
+like($w[0], qr{The WebDomain config option must not contain a scheme \(http://\)});
+
+ at w = warnings_from(WebDomain => 'https://rt.example.com');
+is(@w, 1);
+like($w[0], qr{The WebDomain config option must not contain a scheme \(https://\)});
+
+ at w = warnings_from(WebDomain => 'rt.example.com/path');
+is(@w, 1);
+like($w[0], qr{The WebDomain config option must not contain a path \(/path\)});
+
+# reinstate a valid WebDomain for other tests
+is(warnings_from(WebDomain => 'rt.example.com'), 0);
+
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list