1. Olemis Lang
  2. bloodhound-mq

Commits

Olemis Lang  committed 79caa32

BH Multiproduct #388 : Test environment setup for QCT vs TICKET_CREATE

  • Participants
  • Parent commits 06e7b99
  • Branches t388_product_isolation

Comments (0)

Files changed (2)

File series

View file
 #t669/t669_r1525378_product_edit.diff
 t669/t669_r1525378_product_edit.tests.diff
 t667/t667_r1526822_error_mainnav.tests.diff
+t388/t388_r1529237_ticket_perms_qct.tests.diff
 #t667/t667_r1526822_error_mainnav.diff
 t387/t387_r1524640_no_r5994.diff

File t388/t388_r1529237_ticket_perms_qct.tests.diff

View file
+# HG changeset patch
+# Parent bbd025d36203053b47bc279a8766bba5e7ecfd19
+BH Multiproduct #388 : Test cases for TICKET_CREATE permission and QCT
+
+diff -r bbd025d36203 bloodhound_multiproduct/tests/functional/admin.py
+--- a/bloodhound_multiproduct/tests/functional/admin.py	Tue Oct 08 02:08:34 2013 -0500
++++ b/bloodhound_multiproduct/tests/functional/admin.py	Tue Oct 08 03:04:23 2013 -0500
+@@ -27,7 +27,7 @@
+ 
+ from multiproduct.env import ProductEnvironment
+ 
+-from tests.functional import MultiproductFunctionalTestCase
++from tests.functional import MultiproductFunctionalTestCase, util
+ 
+ #----------------
+ # Functional test cases for admin web UI & CLI
+@@ -41,20 +41,38 @@
+         tester = self._tester
+         prefix = tester.create_product()
+ 
+-        # FIXME : Do not cheat and retrieve perms list by scrapping web UI
+-        env = self._testenv.get_trac_environment()
+-        penv = ProductEnvironment(env, prefix)
+-        actions = PermissionSystem(penv).get_user_permissions('anonymous')
+-
+         # Revoke all permissions for 'anonymous'
+-        self._testenv._tracadmin('permission', 'remove', 'anonymous', *actions,
+-                                 product=prefix)
++        util.clear_user_perms(self._testenv, 'anonymous', prefix)
+         with tester.as_user(None):
+             with self.in_product(prefix) as (ptestenv, ptester):
+                 ptester.go_to_front()
+             tc.notfind(functional.internal_error)
+ 
+ 
++class RegressionTestBhTicket388(MultiproductFunctionalTestCase,
++                                functional.FunctionalTwillTestCaseSetup):
++    def runTest(self):
++        """User can create and see issues only for one product
++        """
++        tester = self._tester
++
++        p1 = tester.create_product()
++        p2 = tester.create_product()
++        for prefix in (None, p1, p2):
++            # Revoke all permissions for 'anonymous' and 'authenticated'
++            util.clear_user_perms(self._testenv, 'anonymous', prefix)
++            util.clear_user_perms(self._testenv, 'authenticated', prefix)
++        
++        # Grant 'user' with WIKI_VIEW in global scope
++        testenv._tracadmin('permission', 'remove', 'user', *actions,
++                           product=None)
++        # Grant 'user' with TICKET_CREATE in product p1
++        testenv._tracadmin('permission', 'remove', 'user', *actions,
++                           product=None)
++
++        # TODO: Assertions
++
++
+ def functionalSuite(suite=None):
+     if not suite:
+         import tests.functional
+diff -r bbd025d36203 bloodhound_multiproduct/tests/functional/util.py
+--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
++++ b/bloodhound_multiproduct/tests/functional/util.py	Tue Oct 08 03:04:23 2013 -0500
+@@ -0,0 +1,37 @@
++# -*- coding: utf-8 -*-
++#
++#  Licensed to the Apache Software Foundation (ASF) under one
++#  or more contributor license agreements.  See the NOTICE file
++#  distributed with this work for additional information
++#  regarding copyright ownership.  The ASF licenses this file
++#  to you under the Apache License, Version 2.0 (the
++#  "License"); you may not use this file except in compliance
++#  with the License.  You may obtain a copy of the License at
++#
++#   http://www.apache.org/licenses/LICENSE-2.0
++#
++#  Unless required by applicable law or agreed to in writing,
++#  software distributed under the License is distributed on an
++#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
++#  KIND, either express or implied.  See the License for the
++#  specific language governing permissions and limitations
++#  under the License.
++
++"""Utilities used in functional tests
++"""
++
++__all__ = 'clear_user_perms',
++
++def clear_user_perms(testenv, user, product_id=None, exclude=None):
++    exclude = exclude or ()
++    # FIXME : Do not cheat and retrieve perms list by scrapping web UI
++    env = testenv.get_trac_environment()
++    if product_id:
++        env = ProductEnvironment(env, product_id)
++    actions = (p for p in PermissionSystem(env).get_user_permissions(user)
++                 if p not in exclude)
++
++    testenv._tracadmin('permission', 'remove', user, *actions,
++                       product=product_id)
++    
++