Example #1
0
    def quick_create_ticket(self, summary=None, info=None):
        """Create a new (random) ticket in the test environment via quick
        create ticket shortcut. Returns the new ticket number.

        :param summary:
            may optionally be set to the desired summary
        :param info:
            may optionally be set to a dictionary of field value pairs for
            populating the ticket.  Fields are populated afterwards by
            navigating to ticket page, thereby ``info['summary']``overrides
            ``summary``.

        `summary` and `description` default to randomly-generated values.
        """
        self.go_to_front()
        tc.notfind(internal_error)

        if summary == None:
            summary = random_sentence(4)
        tc.formvalue('qct-form', 'field_summary', summary)
        tc.formvalue('qct-form', 'field_description', random_page())
        self._post_create_ticket()

        if info:
            # Second pass to update ticket fields
            tc.url(self.url + '/ticket/%s' % (self.ticketcount + 1))
            tc.notfind(internal_error)
            for field, value in info.items():
                tc.formvalue('inplace-propertyform', 'field_%s' % field, value)
            tc.submit('submit')

        return self.ticketcount
Example #2
0
    def quick_create_ticket(self, summary=None, info=None):
        """Create a new (random) ticket in the test environment via quick
        create ticket shortcut. Returns the new ticket number.

        :param summary:
            may optionally be set to the desired summary
        :param info:
            may optionally be set to a dictionary of field value pairs for
            populating the ticket.  Fields are populated afterwards by
            navigating to ticket page, thereby ``info['summary']``overrides
            ``summary``.

        `summary` and `description` default to randomly-generated values.
        """
        self.go_to_front()
        tc.notfind(internal_error)

        if summary == None:
            summary = random_sentence(4)
        tc.formvalue('qct-form', 'field_summary', summary)
        tc.formvalue('qct-form', 'field_description', random_page())
        self._post_create_ticket()

        if info:
            # Second pass to update ticket fields
            tc.url(self.url + '/ticket/%s' % (self.ticketcount + 1))
            tc.notfind(internal_error)
            for field, value in info.items():
                tc.formvalue('inplace-propertyform', 'field_%s' % field, value)
            tc.submit('submit')

        return self.ticketcount
Example #3
0
    def attach_file_to_ticket(self,
                              ticketid,
                              data=None,
                              tempfilename=None,
                              description=None,
                              replace=False):
        """Attaches a file to the given ticket id, with random data if none is
        provided.  Assumes the ticket exists.
        """
        if data is None:
            data = random_page()
        if description is None:
            description = random_sentence()
        if tempfilename is None:
            tempfilename = random_word()

        self.go_to_ticket(ticketid)
        # set the value to what it already is, so that twill will know we
        # want this form.
        tc.formvalue('attachfile', 'action', 'new')
        tc.submit()
        tc.url(self.url + "/attachment/ticket/" \
               "%s/\\?action=new&attachfilebutton=Attach\\+file" % ticketid)
        fp = StringIO(data)
        tc.formfile('attachment', 'attachment', tempfilename, fp=fp)
        tc.formvalue('attachment', 'description', description)
        if replace:
            tc.formvalue('attachment', 'replace', True)
        tc.submit()
        tc.url(self.url + '/attachment/ticket/%s/$' % ticketid)
        return tempfilename
Example #4
0
 def _make_tickets(self, num):
     self.tickets = []
     for i in xrange(num):
         ticket = insert_ticket(self.env,
                                reporter='someone',
                                summary=random_sentence())
         self.tickets.append(ticket)
Example #5
0
    def create_ticket(self, summary=None, info=None):
        """Create a new (random) ticket in the test environment.  Returns
        the new ticket number.

        :param summary:
            may optionally be set to the desired summary
        :param info:
            may optionally be set to a dictionary of field value pairs for
            populating the ticket.  ``info['summary']`` overrides summary.

        `summary` and `description` default to randomly-generated values.
        """
        self.go_to_front()
        tc.follow(r"\bNew Ticket\b")
        tc.notfind(internal_error)
        if summary is None:
            summary = random_sentence(5)
        tc.formvalue('propertyform', 'field_summary', summary)
        tc.formvalue('propertyform', 'field_description', random_page())
        if info:
            for field, value in info.items():
                tc.formvalue('propertyform', 'field_%s' % field, value)
        tc.submit('submit')
        # we should be looking at the newly created ticket
        tc.url(self.url + '/ticket/%s' % (self.ticketcount + 1))
        tc.notfind(internal_error)
        # Increment self.ticketcount /after/ we've verified that the ticket
        # was created so a failure does not trigger spurious later
        # failures.
        self.ticketcount += 1

        return self.ticketcount
Example #6
0
    def create_ticket(self, summary=None, info=None):
        """Create a new (random) ticket in the test environment.  Returns
        the new ticket number.

        :param summary:
            may optionally be set to the desired summary
        :param info:
            may optionally be set to a dictionary of field value pairs for
            populating the ticket.  ``info['summary']`` overrides summary.

        `summary` and `description` default to randomly-generated values.
        """
        # [BLOODHOUND] New Ticket => More fields (in create ticket menu)
        self.go_to_newticket()

        tc.notfind(internal_error)
        if summary == None:
            summary = random_sentence(4)
        tc.formvalue('propertyform', 'field_summary', summary)
        tc.formvalue('propertyform', 'field_description', random_page())
        if info:
            for field, value in info.items():
                tc.formvalue('propertyform', 'field_%s' % field, value)

        # [BLOODHOUND] no actual button to submit /newticket `propertyform`
        tc.submit()

        self._post_create_ticket()
        return self.ticketcount
Example #7
0
    def attach_file_to_ticket(self, ticketid, data=None, tempfilename=None,
                              description=None, replace=False,
                              content_type=None):
        """Attaches a file to the given ticket id, with random data if none is
        provided.  Assumes the ticket exists.
        """
        if data is None:
            data = random_page()
        if description is None:
            description = random_sentence()
        if tempfilename is None:
            tempfilename = random_word()

        self.go_to_ticket(ticketid)
        # set the value to what it already is, so that twill will know we
        # want this form.
        tc.formvalue('attachfile', 'action', 'new')
        tc.submit()
        tc.url(self.url + "/attachment/ticket/" \
               "%s/\\?action=new&attachfilebutton=Attach\\+file" % ticketid)
        fp = StringIO(data)
        tc.formfile('attachment', 'attachment', tempfilename,
                    content_type=content_type, fp=fp)
        tc.formvalue('attachment', 'description', description)
        if replace:
            tc.formvalue('attachment', 'replace', True)
        tc.submit()
        tc.url(self.url + '/attachment/ticket/%s/$' % ticketid)
        return tempfilename
Example #8
0
    def _attach_file_to_resource(self, realm, name, data=None,
                                 filename=None, description=None,
                                 replace=False, content_type=None):
        """Attaches a file to a resource. Assumes the resource exists and
           has already been navigated to."""

        if data is None:
            data = random_page()
        if description is None:
            description = random_sentence()
        if filename is None:
            filename = random_word()

        tc.submit('attachfilebutton', 'attachfile')
        tc.url(self.url + '/attachment/%s/%s/\\?action=new&'
                          'attachfilebutton=Attach\\+file$' % (realm, name))
        fp = StringIO(data)
        tc.formfile('attachment', 'attachment', filename,
                    content_type=content_type, fp=fp)
        tc.formvalue('attachment', 'description', description)
        if replace:
            tc.formvalue('attachment', 'replace', True)
        tc.submit()
        tc.url(self.url + '/attachment/%s/%s/$' % (realm, name))

        return filename
Example #9
0
    def create_ticket(self, summary=None, info=None):
        """Create a new (random) ticket in the test environment.  Returns
        the new ticket number.

        :param summary:
            may optionally be set to the desired summary
        :param info:
            may optionally be set to a dictionary of field value pairs for
            populating the ticket.  ``info['summary']`` overrides summary.

        `summary` and `description` default to randomly-generated values.
        """
        self.go_to_front()
        tc.follow(r"\bNew Ticket\b")
        tc.notfind(internal_error)
        if summary is None:
            summary = random_sentence(5)
        tc.formvalue('propertyform', 'field_summary', summary)
        tc.formvalue('propertyform', 'field_description', random_page())
        if info:
            for field, value in info.items():
                tc.formvalue('propertyform', 'field_%s' % field, value)
        tc.submit('submit')
        # we should be looking at the newly created ticket
        tc.url(self.url + '/ticket/%s' % (self.ticketcount + 1))
        tc.notfind(internal_error)
        # Increment self.ticketcount /after/ we've verified that the ticket
        # was created so a failure does not trigger spurious later
        # failures.
        self.ticketcount += 1

        return self.ticketcount
Example #10
0
    def create_ticket(self, summary=None, info=None):
        """Create a new (random) ticket in the test environment.  Returns
        the new ticket number.

        :param summary:
            may optionally be set to the desired summary
        :param info:
            may optionally be set to a dictionary of field value pairs for
            populating the ticket.  ``info['summary']`` overrides summary.

        `summary` and `description` default to randomly-generated values.
        """
        # [BLOODHOUND] New Ticket => More fields (in create ticket menu)
        self.go_to_newticket()

        tc.notfind(internal_error)
        if summary == None:
            summary = random_sentence(4)
        tc.formvalue('propertyform', 'field_summary', summary)
        tc.formvalue('propertyform', 'field_description', random_page())
        if info:
            for field, value in info.items():
                tc.formvalue('propertyform', 'field_%s' % field, value)

        # [BLOODHOUND] no actual button to submit /newticket `propertyform`
        tc.submit()

        self._post_create_ticket()
        return self.ticketcount
Example #11
0
    def _attach_file_to_resource(self,
                                 realm,
                                 name,
                                 data=None,
                                 filename=None,
                                 description=None,
                                 replace=False,
                                 content_type=None):
        """Attaches a file to a resource. Assumes the resource exists and
           has already been navigated to."""

        if data is None:
            data = random_page()
        if description is None:
            description = random_sentence()
        if filename is None:
            filename = random_word()

        tc.submit('attachfilebutton', 'attachfile')
        tc.url(self.url + r'/attachment/%s/%s/\?action=new$' % (realm, name))
        fp = io.BytesIO(data)
        tc.formfile('attachment',
                    'attachment',
                    filename,
                    content_type=content_type,
                    fp=fp)
        tc.formvalue('attachment', 'description', description)
        if replace:
            tc.formvalue('attachment', 'replace', True)
        tc.submit()
        tc.url(self.url + r'/attachment/%s/%s/$' % (realm, name))

        return filename
Example #12
0
 def _make_tickets(self, num):
     self.tickets = []
     for i in xrange(0, num):
         ticket = Ticket(self.env)
         ticket['reporter'] = 'someone'
         ticket['summary'] = random_sentence()
         ticket.insert()
         self.tickets.append(ticket)
Example #13
0
 def _make_tickets(self, num):
     self.tickets = []
     for i in xrange(0, num):
         ticket = Ticket(self.env)
         ticket['reporter'] = 'someone'
         ticket['summary'] = random_sentence()
         ticket.insert()
         self.tickets.append(ticket)
Example #14
0
 def test_add_notice_is_unique(self):
     req = Request(abs_href=Href('http://example.org/trac.cgi'),
                   href=Href('/trac.cgi'), base_path='/trac.cgi',
                   path_info='',
                   add_redirect_listener=lambda listener: None)
     Chrome(self.env).prepare_request(req)
     message = random_sentence(5)
     add_notice(req, message)
     add_notice(req, message)
     self.assertEqual(1, len(req.chrome['notices']))
Example #15
0
 def add_comment(self, ticketid, comment=None):
     """Adds a comment to the given ticket ID, assumes ticket exists."""
     self.go_to_ticket(ticketid)
     if comment is None:
         comment = random_sentence()
     tc.formvalue('propertyform', 'comment', comment)
     tc.submit("submit")
     # Verify we're where we're supposed to be.
     tc.url(self.url + '/ticket/%s#comment:.*' % ticketid)
     return comment
Example #16
0
 def setUp(self):
     self.env = EnvironmentStub()
     self.mmodule = MilestoneModule(self.env)
     self.terms = ['MilestoneAlpha', 'MilestoneBeta', 'MilestoneGamma']
     for term in self.terms + [' '.join(self.terms)]:
         m = Milestone(self.env)
         m.name = term
         m.due = datetime_now(utc)
         m.description = random_sentence()
         m.insert()
Example #17
0
 def test_add_notice_is_unique(self):
     req = Request(abs_href=Href('http://example.org/trac.cgi'),
                   href=Href('/trac.cgi'),
                   base_path='/trac.cgi',
                   path_info='',
                   add_redirect_listener=lambda listener: None)
     Chrome(self.env).prepare_request(req)
     message = random_sentence(5)
     add_notice(req, message)
     add_notice(req, message)
     self.assertEqual(1, len(req.chrome['notices']))
Example #18
0
 def add_comment(self, ticketid, comment=None):
     """Adds a comment to the given ticket ID, assumes ticket exists."""
     self.go_to_ticket(ticketid)
     if comment is None:
         comment = random_sentence()
     tc.formvalue('propertyform', 'comment', comment)
     tc.submit("submit")
     # Verify we're where we're supposed to be.
     # The fragment is stripped since Python 2.7.1, see:
     # http://trac.edgewall.org/ticket/9990#comment:18
     tc.url(self.url + '/ticket/%s(?:#comment:.*)?$' % ticketid)
     return comment
Example #19
0
 def add_comment(self, ticketid, comment=None):
     """Adds a comment to the given ticket ID, assumes ticket exists."""
     self.go_to_ticket(ticketid)
     if comment is None:
         comment = random_sentence()
     tc.formvalue('propertyform', 'comment', comment)
     tc.submit("submit")
     # Verify we're where we're supposed to be.
     # The fragment is stripped since Python 2.7.1, see:
     # http://trac.edgewall.org/ticket/9990#comment:18
     tc.url(self.url + '/ticket/%s(?:#comment:.*)?$' % ticketid)
     return comment
Example #20
0
 def setUp(self):
     self.env = EnvironmentStub(default_data=True)
     self.req = Mock(args={}, chrome={'notices': []}, href=self.env.href,
                     lc_time=locale_en, method=None, perm=MockPerm(),
                     session={}, tz=utc)
     self.mmodule = MilestoneModule(self.env)
     self.terms = ['MilestoneAlpha', 'MilestoneBeta', 'MilestoneGamma']
     for term in self.terms + [' '.join(self.terms)]:
         m = Milestone(self.env)
         m.name = term
         m.due = datetime.now(utc)
         m.description = random_sentence()
         m.insert()
Example #21
0
    def edit_wiki_page(self, name, content=None, comment=None):
        """Edits a wiki page, with random content is none is provided.
        and a random comment if none is provided. Returns the content.
        """
        if content is None:
            content = random_page()
        if comment is None:
            comment = random_sentence()
        self.go_to_wiki(name)
        tc.submit(formname='modifypage')
        tc.formvalue('edit', 'text', content)
        tc.formvalue('edit', 'comment', comment)
        tc.submit('save')
        tc.url('%s/wiki/%s' % (self.url, name), regexp=False)

        return content
Example #22
0
    def edit_wiki_page(self, name, content=None, comment=None):
        """Edits a wiki page, with random content is none is provided.
        and a random comment if none is provided. Returns the content.
        """
        if content is None:
            content = random_page()
        if comment is None:
            comment = random_sentence()
        self.go_to_wiki(name)
        tc.formvalue('modifypage', 'action', 'edit')
        tc.submit()
        tc.formvalue('edit', 'text', content)
        tc.formvalue('edit', 'comment', comment)
        tc.submit('save')
        page_url = self.url + '/wiki/%s' % name
        tc.url(page_url+'$')

        return content
Example #23
0
    def create_product(self, prefix=None, name=None, desc=None):
        """Create a product from the product list page."""
        products_url = self.url + '/products'
        tc.go(products_url)
        tc.find('Products')
        tc.submit('add', 'new')
        tc.find('New Product')

        prefix = prefix or random_word()
        name = name or random_sentence()
        desc = desc or random_paragraph()

        tc.formvalue('edit', 'prefix', prefix)
        tc.formvalue('edit', 'name', name)
        tc.formvalue('edit', 'description', desc)
        tc.submit()
        tc.find('The product "%s" has been added' % prefix)
        return prefix, name
Example #24
0
    def create_product(self, prefix=None, name=None, desc=None):
        """Create a product from the product list page."""
        products_url = self.url + '/products'
        tc.go(products_url)
        tc.find('Products')
        tc.submit('add', 'new')
        tc.find('New Product')

        prefix = prefix or random_word()
        name = name or random_sentence()
        desc = desc or random_paragraph()

        tc.formvalue('edit', 'prefix', prefix)
        tc.formvalue('edit', 'name', name)
        tc.formvalue('edit', 'description', desc)
        tc.submit()
        tc.find('The product "%s" has been added' % prefix)
        return prefix, name
Example #25
0
    def edit_wiki_page(self, name, content=None, comment=None):
        """Edits a wiki page, with random content is none is provided.
        and a random comment if none is provided. Returns the content.
        """
        if content is None:
            content = random_page()
        if comment is None:
            comment = random_sentence()
        self.go_to_wiki(name)
        tc.formvalue('modifypage', 'action', 'edit')
        tc.submit()
        tc.formvalue('edit', 'text', content)
        tc.formvalue('edit', 'comment', comment)
        tc.submit('save')
        page_url = self.url + '/wiki/%s' % name
        tc.url(page_url + '$')

        return content
Example #26
0
 def attach_file_to_wiki(self, name, data=None):
     """Attaches a file to the given wiki page, with random content if none
     is provided.  Assumes the wiki page exists.
     """
     if data == None:
         data = random_page()
     self.go_to_wiki(name)
     # set the value to what it already is, so that twill will know we
     # want this form.
     tc.formvalue('attachfile', 'action', 'new')
     tc.submit()
     tc.url(self.url + "/attachment/wiki/" \
            "%s/\\?action=new&attachfilebutton=Attach\\+file" % name)
     tempfilename = random_word()
     fp = StringIO(data)
     tc.formfile('attachment', 'attachment', tempfilename, fp=fp)
     tc.formvalue('attachment', 'description', random_sentence())
     tc.submit()
     tc.url(self.url + '/attachment/wiki/%s/$' % name)
Example #27
0
    def admin_create_product(self, prefix=None, name=None, owner=None):
        """Create a product from the admin page."""
        admin_product_url = self.url + '/admin/ticket/products'
        tc.go(admin_product_url)
        tc.url(admin_product_url + '$')
        prefix = prefix or random_word()
        name = name or random_sentence()
        owner = owner or random_word()
        tc.formvalue('addproduct', 'prefix', prefix)
        tc.formvalue('addproduct', 'name', name)
        tc.formvalue('addproduct', 'owner', owner)
        tc.submit()

        tc.find(r'The product "%s" has been added' % prefix)
        tc.find(r'<a href="/admin/ticket/products/%s">%s</a>' %
                (prefix, prefix))
        tc.find(r'<a href="/admin/ticket/products/%s">%s</a>' % (prefix, name))
        tc.find(r'<td class="owner">%s</td>' % owner)
        return prefix, name, owner
Example #28
0
    def admin_create_product(self, prefix=None, name=None, owner=None):
        """Create a product from the admin page."""
        admin_product_url = self.url + '/admin/ticket/products'
        tc.go(admin_product_url)
        tc.url(admin_product_url + '$')
        prefix = prefix or random_word()
        name = name or random_sentence()
        owner = owner or random_word()
        tc.formvalue('addproduct', 'prefix', prefix)
        tc.formvalue('addproduct', 'name', name)
        tc.formvalue('addproduct', 'owner', owner)
        tc.submit()

        tc.find(r'The product "%s" has been added' % prefix)
        tc.find(r'<a href="/admin/ticket/products/%s">%s</a>'
                % (prefix, prefix))
        tc.find(r'<a href="/admin/ticket/products/%s">%s</a>'
                % (prefix, name))
        tc.find(r'<td class="owner">%s</td>' % owner)
        return prefix, name, owner
Example #29
0
 def attach_file_to_wiki(self, name, data=None):
     """Attaches a file to the given wiki page, with random content if none
     is provided.  Assumes the wiki page exists.
     """
     if data == None:
         data = random_page()
     self.go_to_wiki(name)
     # set the value to what it already is, so that twill will know we
     # want this form.
     tc.formvalue('attachfile', 'action', 'new')
     tc.submit()
     tc.url(self.url + "/attachment/wiki/" \
            "%s/\\?action=new&attachfilebutton=Attach\\+file" % name)
     tempfilename = random_word()
     fp = StringIO(data)
     tc.formfile('attachment', 'attachment', tempfilename, fp=fp)
     tc.formvalue('attachment', 'description', random_sentence())
     tc.submit()
     tc.url(self.url + '/attachment/wiki/%s/$' % name)
     return tempfilename
Example #30
0
 def runTest(self):
     """Test for regression of the timeline fix in r5883
     From Tim:
     the issue was that event.markup was never being output anywhere, so
     you actually have to render the template with a wiki modification
     and see if '(diff)' shows up as the text in a link
     also note that (diff) should _not_ show up for a wiki creation
     """
     pagename = random_unique_camel()
     self._tester.create_wiki_page(pagename)
     self._tester.go_to_timeline()
     tc.find(pagename)
     tc.notfind(pagename + '.*diff</a>\\)')
     self._tester.go_to_wiki(pagename)
     tc.submit(formname='modifypage')
     tc.find('Editing ' + pagename)
     tc.formvalue('edit', 'text', random_page())
     tc.formvalue('edit', 'comment', random_sentence())
     tc.submit('save')
     self._tester.go_to_timeline()
     tc.find(pagename + '.*diff</a>\\)')
Example #31
0
 def runTest(self):
     """Test for regression of the timeline fix in r5883
     From Tim:
     the issue was that event.markup was never being output anywhere, so
     you actually have to render the template with a wiki modification
     and see if '(diff)' shows up as the text in a link
     also note that (diff) should _not_ show up for a wiki creation
     """
     pagename = random_unique_camel()
     self._tester.create_wiki_page(pagename)
     self._tester.go_to_timeline()
     tc.find(pagename)
     tc.notfind(pagename + '.*diff</a>\\)')
     self._tester.go_to_wiki(pagename)
     tc.formvalue('modifypage', 'action', 'edit')
     tc.submit()
     tc.find('Editing ' + pagename)
     tc.formvalue('edit', 'text', random_page())
     tc.formvalue('edit', 'comment', random_sentence())
     tc.submit('save')
     self._tester.go_to_timeline()
     tc.find(pagename + '.*diff</a>\\)')
Example #32
0
    def runTest(self):
        """Test for regression of http://trac.edgewall.org/ticket/10957"""

        self._tester.go_to_front()
        try:
            self._tester.logout()

            # Check that page can't be created without WIKI_CREATE
            page_name = random_unique_camel()
            self._tester.go_to_wiki(page_name)
            tc.find("Trac Error")
            tc.find("Page %s not found" % page_name)
            tc.notfind("Create this page")
            tc.go(self._tester.url + '/wiki/%s?action=edit' % page_name)
            tc.find("Error: Forbidden")
            tc.find(
                "WIKI_CREATE privileges are required to perform this "
                "operation on %s. You don't have the required permissions." %
                page_name)

            # Check that page can be created when user has WIKI_CREATE
            self._testenv.grant_perm('anonymous', 'WIKI_CREATE')
            content_v1 = random_sentence()
            self._tester.create_wiki_page(page_name, content_v1)
            tc.find(content_v1)

            # Check that page can't be edited without WIKI_MODIFY
            tc.notfind("Edit this page")
            tc.notfind("Attach file")
            tc.go(self._tester.url + '/wiki/%s?action=edit' % page_name)
            tc.find("Error: Forbidden")
            tc.find(
                "WIKI_MODIFY privileges are required to perform this "
                "operation on %s. You don't have the required permissions." %
                page_name)

            # Check that page can be edited when user has WIKI_MODIFY
            self._testenv.grant_perm('anonymous', 'WIKI_MODIFY')
            self._tester.go_to_wiki(page_name)
            tc.find("Edit this page")
            tc.find("Attach file")
            content_v2 = random_sentence()
            self._tester.edit_wiki_page(page_name, content_v2)
            tc.find(content_v2)

            # Check that page can be reverted to a previous revision
            tc.go(self._tester.url + '/wiki/%s?version=1' % page_name)
            tc.find("Revert to this version")
            tc.formvalue('modifypage', 'action', 'edit')
            tc.submit()
            tc.find(content_v1)

            # Check that page can't be reverted without WIKI_MODIFY
            self._tester.edit_wiki_page(page_name)
            self._testenv.revoke_perm('anonymous', 'WIKI_MODIFY')
            tc.go(self._tester.url + '/wiki/%s?version=1' % page_name)
            tc.notfind("Revert to this version")
            tc.go(self._tester.url +
                  '/wiki/%s?action=edit&version=1' % page_name)
            tc.find(
                "WIKI_MODIFY privileges are required to perform this "
                "operation on %s. You don't have the required permissions." %
                page_name)

        finally:
            # Restore pre-test state.
            self._tester.login('admin')
            self._testenv.revoke_perm('anonymous', 'WIKI_CREATE')
Example #33
0
 def test_add_notice_is_unique(self):
     req = MockRequest(self.env)
     message = random_sentence(5)
     add_notice(req, message)
     add_notice(req, message)
     self.assertEqual(1, len(req.chrome['notices']))
Example #34
0
    def runTest(self):
        """Test for regression of http://trac.edgewall.org/ticket/10957"""

        self._tester.go_to_front()
        try:
            self._tester.logout()

            # Check that page can't be created without WIKI_CREATE
            page_name = random_unique_camel()
            self._tester.go_to_wiki(page_name)
            tc.find("Trac Error")
            tc.find("Page %s not found" % page_name)
            tc.notfind("Create this page")
            tc.go(self._tester.url + '/wiki/%s?action=edit' % page_name)
            tc.find("Error: Forbidden")
            tc.find("WIKI_CREATE privileges are required to perform this "
                    "operation on %s. You don't have the required permissions."
                    % page_name)

            # Check that page can be created when user has WIKI_CREATE
            self._testenv.grant_perm('anonymous', 'WIKI_CREATE')
            content_v1 = random_sentence()
            self._tester.create_wiki_page(page_name, content_v1)
            tc.find(content_v1)

            # Check that page can't be edited without WIKI_MODIFY
            tc.notfind("Edit this page")
            tc.notfind("Attach file")
            tc.go(self._tester.url + '/wiki/%s?action=edit' % page_name)
            tc.find("Error: Forbidden")
            tc.find("WIKI_MODIFY privileges are required to perform this "
                    "operation on %s. You don't have the required permissions."
                    % page_name)

            # Check that page can be edited when user has WIKI_MODIFY
            self._testenv.grant_perm('anonymous', 'WIKI_MODIFY')
            self._tester.go_to_wiki(page_name)
            tc.find("Edit this page")
            tc.find("Attach file")
            content_v2 = random_sentence()
            self._tester.edit_wiki_page(page_name, content_v2)
            tc.find(content_v2)

            # Check that page can be reverted to a previous revision
            tc.go(self._tester.url + '/wiki/%s?version=1' % page_name)
            tc.find("Revert to this version")
            tc.formvalue('modifypage', 'action', 'edit')
            tc.submit()
            tc.find(content_v1)

            # Check that page can't be reverted without WIKI_MODIFY
            self._tester.edit_wiki_page(page_name)
            self._testenv.revoke_perm('anonymous', 'WIKI_MODIFY')
            tc.go(self._tester.url + '/wiki/%s?version=1' % page_name)
            tc.notfind("Revert to this version")
            tc.go(self._tester.url + '/wiki/%s?action=edit&version=1' % page_name)
            tc.find("WIKI_MODIFY privileges are required to perform this "
                    "operation on %s. You don't have the required permissions."
                    % page_name)

        finally:
            # Restore pre-test state.
            self._tester.login('admin')
            self._testenv.revoke_perm('anonymous', 'WIKI_CREATE')