The docco in
IfStatements very reasonably says
allows | 'X' allows 'Y' is true if web/topic 'X' exists and allows access mode 'Y' for the current user. Web access rights are only checked if there is no topic called 'X'. |
unfortuanatly, the change in [[
Item5500]] to the topic creator does not work.
It feels like a case of
For want of a Unit test, the feature was lost as i added:
Fn_IF::test_ALLOWS_and_EXISTS
%IF{"'TemporaryIFTestWebIF.NonExitantLazyFox' allows 'change'" then="1" else="0"}%: '0' at /home/sven/src/twiki/twiki/branches/TWikiRelease04x02/lib/Unit/TestCase.pm line 151
Unit::TestCase::assert_str_equals('Fn_IF=HASH(0xea31f0)', 1, 0, '%IF{"\'TemporaryIFTestWebIF.NonExitantLazyFox\' allows \'chan...') called at /home/sven/src/twiki/twiki/branches/TWikiRelease04x02/test/unit/Fn_IF.pm line 714
Fn_IF::test_ALLOWS_and_EXISTS('Fn_IF=HASH(0xea31f0)') called at /home/sven/src/twiki/twiki/branches/TWikiRelease04x02/lib/Unit/TestRunner.pm line 49
Unit::TestRunner::__ANON__() called at /home/sven/src/twiki/twiki/branches/TWikiRelease04x02/lib/CPAN/lib/Error.pm line 379
eval {...} called at /home/sven/src/twiki/twiki/branches/TWikiRelease04x02/lib/CPAN/lib/Error.pm line 371
Error::subs::try('CODE(0x175e360)', 'HASH(0x1b40cb0)') called at /home/sven/src/twiki/twiki/branches/TWikiRelease04x02/lib/Unit/TestRunner.pm line 55
Unit::TestRunner::start('Unit::TestRunner=HASH(0x604fd0)', 'Fn_IF.pm') called
and so, I'll be fuxing that for 4.2.1
--
TWiki:Main/SvenDowideit - 04 Apr 2008
This is complicated by the non-specification of what %IF{'NonExistant' ... is evaluating. Is it a web, or is it a topic? especially if neither exist.
my fix changes that from for some reason assuming it is a web, to assuming its a non-existant topic in the current session's web, thus enabling testing as I do above, where I specify the web and topic.
this will require the following test to change.
push(@tests, {
test => "'NotAHopeInHellPal' allows 'view'",
expect => "0"
});
the fix is:
Index: lib/TWiki/If/Node.pm
===================================================================
--- lib/TWiki/If/Node.pm (revision 158)
+++ lib/TWiki/If/Node.pm (working copy)
@@ -62,13 +62,16 @@
$session->{webName}, $str);
my $ok = 0;
if ($session->{store}->topicExists($web, $topic)) {
+ #try the non-precise name as an existant topic first.
$ok = $session->security->checkAccessPermission(
uc($mode), $session->{user}, undef, undef, $topic, $web);
} elsif ($session->{store}->webExists($str)) {
$ok = $session->security->checkAccessPermission(
uc($mode), $session->{user}, undef, undef, undef, $str);
+ } elsif ($session->{store}->webExists($web)) {
+ #not an existing topic or web - assume any lone name is a topic without a web specified
+ $ok = $session->security->checkAccessPermission(
+ uc($mode), $session->{user}, undef, undef, $topic, $web);
} else {
$ok = 0;
}
return $ok ? 1 : 0;
}
Index: twikiplugins/UnitTestContrib/test/unit/Fn_IF.pm
===================================================================
--- twikiplugins/UnitTestContrib/test/unit/Fn_IF.pm (revision 16607)
+++ twikiplugins/UnitTestContrib/test/unit/Fn_IF.pm (working copy)
@@ -672,6 +672,18 @@
expect => "1"
});
push(@tests, {
+ test => '\''.$this->{test_web}.'.NonExitantLazyFox\' allows \'change\'',
+ expect => "1"
+ });
+ push(@tests, {
+ test => '\'NonExistantWeb.WebHome\' allows \'change\'',
+ expect => "0"
+ });
+ push(@tests, {
+ test => '\'NonExistantWeb.NonExitantLazyFox\' allows \'change\'',
+ expect => "0"
+ });
+ push(@tests, {
test => "istopic 'LazyFox'",
expect => "0"
});
What do you think Crawford?
--
TWiki:Main.SvenDowideit - 04 Apr 2008
I agree it should be interpreted as a topic. That's the TWiki naming standard, and%IF should be consistent. Your fix is correct, IMHO.
--
TWiki:Main.CrawfordCurrie - 05 Apr 2008