Edgewall Software
Modify

Opened 7 years ago

Closed 7 years ago

#12625 closed defect (fixed)

Checking permissions will fail unless trac.wiki.web_ui is imported

Reported by: Ryan J Ollos Owned by: Ryan J Ollos
Priority: normal Milestone: 1.2.1
Component: wiki system Version:
Severity: normal Keywords:
Cc: Branch:
Release Notes:
API Changes:

ReadonlyWikiPolicy is excluded from default permission policies in EnvironmentStub.

Internal Changes:

Description

If trac.wiki.web_ui isn't imported, a statement such as self.assertTrue('WIKI_VIEW' in self.req.perm) will fail with traceback:

E..
======================================================================
ERROR: test_trac_1_0_permission_policies (__main__.TestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./test_case.py", line 16, in test_trac_1_0_permission_policies
    self.assertTrue('WIKI_VIEW' in self.req.perm)
  File "/Users/rjollos/Documents/Workspace/trac-dev/teo-rjollos.git/trac/perm.py", line 586, in has_permission
    return self._has_permission(action, resource)
  File "/Users/rjollos/Documents/Workspace/trac-dev/teo-rjollos.git/trac/perm.py", line 600, in _has_permission
    check_permission(action, perm.username, resource, perm)
  File "/Users/rjollos/Documents/Workspace/trac-dev/teo-rjollos.git/trac/perm.py", line 495, in check_permission
    for policy in self.policies:
  File "/Users/rjollos/Documents/Workspace/trac-dev/teo-rjollos.git/trac/config.py", line 915, in __get__
    option=tag.code("[%s] %s" % (self.section, self.name))))
ConfigurationError: Cannot find implementation(s) of the <code>IPermissionPolicy</code> interface named <code>ReadonlyWikiPolicy</code>. Please check that the Component is enabled or update the option <code>[trac] permission_policies</code> in trac.ini.

----------------------------------------------------------------------
Ran 3 tests in 0.043s

FAILED (errors=1)

This might be confusing to developers. Maybe we should have the following in the EnvironmentStub initializer:

self.env.config.set('trac', 'permission_policies', 'DefaultPermissionPolicy, LegacyAttachmentPolicy')

or even:

self.env.config.set('trac', 'permission_policies', 'DefaultPermissionPolicy)

Or we could add an import to EnvironmentStub:

import trac.wiki.web_ui

test_case.py is a minimal test module that demonstrates the behavior.

Attachments (1)

test_case.py (1.4 KB ) - added by Ryan J Ollos 7 years ago.

Download all attachments as: .zip

Change History (5)

by Ryan J Ollos, 7 years ago

Attachment: test_case.py added

comment:1 by Ryan J Ollos, 7 years ago

Initially I observed the behavior in DiscussionPlugin, so added [th 16007/discussionplugin/1.2/tracdiscussion/tests/__init__.py]. However, the statement appears to no longer be necessary, probably due to a change in the modules that are imported resulting in a transitive import of trac.wiki.web_ui.

comment:2 by Ryan J Ollos, 7 years ago

Owner: set to Ryan J Ollos
Status: newassigned

comment:3 by Ryan J Ollos, 7 years ago

All tests pass with the following proposed change:

  • trac/test.py

    diff --git a/trac/test.py b/trac/test.py
    index a002aab..3bc2724 100755
    a b class EnvironmentStub(Environment):  
    380380        for name_or_class in disable or ():
    381381            config_key = self._component_name(name_or_class)
    382382            self.config.set('components', config_key, 'disabled')
     383        self.config.set('trac', 'permission_policies',
     384                        'DefaultPermissionPolicy, LegacyAttachmentPolicy')
    383385
    384386        # -- logging
    385387        from trac.log import logger_handler_factory

comment:4 by Ryan J Ollos, 7 years ago

API Changes: modified (diff)
Resolution: fixed
Status: assignedclosed

Committed to 1.2-stable in r15270, merged to trunk in r15271.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Ryan J Ollos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Ryan J Ollos to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.