• Do not register here on develop.twiki.org, login with your twiki.org account.
• Use View topic Item7848 for generic doc work for TWiki-6.1.1. Use View topic Item7851 for doc work on extensions that are not part of a release. More... Close
• Anything you create or change in standard webs (Main, TWiki, Sandbox etc) will be automatically reverted on every SVN update.
Does this site look broken?. Use the LitterTray web for test cases.

Item7824: Unit tests: StoreTests.pm dies with AccessControlException

Item Form Data

AppliesTo: Component: Priority: CurrentState: WaitingFor: TargetRelease ReleasedIn
Engine   Low Closed TWiki:Main.HaraldJoerg minor 6.1.0

Edit Form Data

Reported By:
Applies To:
Current State:
Waiting For:
Target Release:
Released In:


Recently, running the test suite fails in StoreTests.pm:
AccessControlException: Access to CHANGE TestStoreWeb.WebPreferences for BaseUserMapping_666 is denied. access not allowed on topic

Apart from stopping the test suite at this point, this leaves the TestStoreWeb alive. This web is not reaped when unit tests are invoked with -clean.

The problem arises when in the unit tests a web is created with _default as its template web (and might affect other unit tests as well). Here's why:

  • Unless otherwise specified, unit tests run under the default user.
  • In several tests in StoreTests.pm, TWiki::Store::createWeb is called without providing an $opts parameter. This should be just just fine.
  • In TWiki::Store::createWeb, $opts->{EXCLUDETOPIC} and $opts->{EXCLUDETOPIC} are evaluated. This initializes $opts as a reference to an empty hash (Perl's infamous "autovivification").
  • Later on, there's a if ($opts) branch which is always executed since due to the autovivification $opts will always evaluate to a true value
    • In that branch, WebPreferences is about to be written, which is not allowed for the default user due to access control in _default.WebPreferences

The autovivification is an unintentional consequence of the implementation of TWiki:Codev/CreateWebExcludeTopic. Perhaps running unit tests as default user is somewhat strange if webs are to be created, nevertheless I suggest to fix TWiki/Store.pm: Since Rev. 30354, the test if ($opts) is always true which is a flaw. Replacing it with if (scalar keys %$opts) establishes the correct semantics of "run the branch if there are keys in =%$opts=".

-- TWiki:Main/HaraldJoerg - 2017-10-14

Summary Unit tests: StoreTests.pm dies with AccessControlException
ReportedBy TWiki:Main.HaraldJoerg

SVN Range TWiki-6.0.2-trunk, Thu, 17 Aug 2017, build 30353 - ...
AppliesTo Engine

Priority Low
CurrentState Closed
WaitingFor TWiki:Main.HaraldJoerg
Checkins TWikirev:30396 TWikirev:30397
TargetRelease minor
ReleasedIn 6.1.0
Edit | Attach | Watch | Print version | History: r5 < r4 < r3 < r2 < r1 | Backlinks | Raw View |  Raw edit | More topic actions
Topic revision: r5 - 2018-07-17 - PeterThoeny
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback