Ejemplo n.º 1
0
 def test_wiki_replace(self):
     name1 = random_unique_camel()
     name2 = random_unique_camel()
     path1 = os.path.join(self.tempdir, name1)
     path2 = os.path.join(self.tempdir, name2)
     content1 = random_paragraph()
     content2 = random_paragraph()
     self._insert_page(name1)
     self._insert_page(name2)
     with open(path1, 'w') as f:
         f.write(content1)
     with open(path2, 'w') as f:
         f.write(content2)
     rv, output = self.execute('replace', path1, path2)
     page1 = WikiPage(self.env, name1)
     page2 = WikiPage(self.env, name2)
     self.assertEqual(0, rv, output)
     self.assertExpectedResult(output, {
         'name1': name1,
         'name2': name2,
         'path1': path1,
         'path2': path2,
     })
     self.assertIn(('INFO', '%s imported from %s' % (name1, path1)),
                   self.env.log_messages)
     self.assertIn(('INFO', '%s imported from %s' % (name2, path2)),
                   self.env.log_messages)
     self.assertEqual(content1, page1.text)
     self.assertEqual(content2, page2.text)
     self.assertEqual(1, page1.version)
     self.assertEqual(1, page2.version)
Ejemplo n.º 2
0
    def runTest(self):
        """Admin modify priority details"""
        name1 = self._testenv.add_priority()
        self._tester.go_to_url('/admin/ticket/priority')

        # Modify the details of the priority
        tc.follow(name1)
        priority_url = self._tester.url + "/admin/ticket/priority"
        tc.url(priority_url + '/' + name1, regexp=False)
        name2 = random_unique_camel()
        tc.formvalue('edit', 'name', name2)
        tc.submit('save')
        tc.url(priority_url, regexp=False)

        # Cancel more modifications
        self._tester.go_to_url(priority_url)
        tc.follow(name2)
        name3 = random_unique_camel()
        tc.formvalue('edit', 'name', name3)
        tc.submit('cancel')
        tc.url(priority_url, regexp=False)

        # Verify that only the correct modifications show up
        tc.notfind(name1)
        tc.find(name2)
        tc.notfind(name3)
Ejemplo n.º 3
0
    def runTest(self):
        """Test for regression of http://trac.edgewall.org/ticket/11355
        Save with no changes should redirect back to the repository listing.
        """
        # Add a repository
        self._tester.go_to_admin("Repositories")
        name = random_unique_camel()
        dir = os.path.join(tempfile.gettempdir(), name.lower())
        tc.formvalue("trac-addrepos", "name", name)
        tc.formvalue("trac-addrepos", "dir", dir)
        tc.submit("add_repos")
        tc.find('The repository "%s" has been added.' % name)

        # Save unmodified form and redirect back to listing page
        tc.follow(r"\b%s\b" % name)
        tc.url(self._tester.url + "/admin/versioncontrol/repository/" + name)
        tc.submit("save", formname="edit")
        tc.url(self._tester.url + "/admin/versioncontrol/repository")
        tc.find("Your changes have been saved.")

        # Warning is added when repository dir is not an absolute path
        tc.follow(r"\b%s\b" % name)
        tc.url(self._tester.url + "/admin/versioncontrol/repository/" + name)
        tc.formvalue("edit", "dir", os.path.basename(dir))
        tc.submit("save")
        tc.url(self._tester.url + "/admin/versioncontrol/repository/" + name)
        tc.find("The repository directory must be an absolute path.")
Ejemplo n.º 4
0
 def _insert_pages(self, int_or_names):
     if isinstance(int_or_names, int):
         names = sorted(random_unique_camel()
                        for _ in range(0, int_or_names))
     else:
         names = sorted(int_or_names)
     return [self._insert_page(n) for n in names]
Ejemplo n.º 5
0
    def runTest(self):
        """Test timeline in RSS format."""
        pagename = random_unique_camel()
        self._tester.create_wiki_page(pagename)
        page = WikiPage(self._testenv.get_trac_environment(), pagename)
        self._tester.go_to_timeline()
        tc.follow("RSS Feed")
        tc.find(
            r"""<\?xml version="1.0"\?>[\n]+
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Functional Tests</title>
    <link>http://127.0.0.1:\d+/timeline</link>
    <description>Trac Timeline</description>
    <language>en-US</language>
    <generator>Trac [^<]+</generator>
    <image>
      <title>Functional Tests</title>
      <url>http://127.0.0.1:\d+/chrome/site/your_project_logo.png</url>
      <link>http://127.0.0.1:\d+/timeline</link>
    </image>
    <item>
      <title>%(pagename)s created</title>

      <dc:creator>admin</dc:creator>
      <pubDate>%(http_date)s</pubDate>
      <link>http://127.0.0.1:\d+/wiki/%(pagename)s\?version=1</link>
      <guid isPermaLink="false">http://127.0.0.1:\d+/wiki/%(pagename)s\?version=1/\d+</guid>
      <description>[^<]+</description>
      <category>wiki</category>
    </item>
""" % {
                'pagename': pagename,
                'http_date': http_date(page.time)
            }, 'ms')
Ejemplo n.º 6
0
    def runTest(self):
        """Test for regression of http://trac.edgewall.org/ticket/11355
        Save with no changes should redirect back to the repository listing.
        """
        # Add a repository
        self._tester.go_to_admin("Repositories")
        name = random_unique_camel()
        dir = os.path.join(tempfile.gettempdir(), name.lower())
        tc.formvalue('trac-addrepos', 'name', name)
        tc.formvalue('trac-addrepos', 'dir', dir)
        tc.submit('add_repos')
        tc.find('The repository "%s" has been added.' % name)

        # Save unmodified form and redirect back to listing page
        tc.follow(r"\b%s\b" % name)
        tc.url(self._tester.url + '/admin/versioncontrol/repository/' + name)
        tc.submit('save', formname='edit')
        tc.url(self._tester.url + '/admin/versioncontrol/repository')
        tc.find("Your changes have been saved.")

        # Warning is added when repository dir is not an absolute path
        tc.follow(r"\b%s\b" % name)
        tc.url(self._tester.url + '/admin/versioncontrol/repository/' + name)
        tc.formvalue('edit', 'dir', os.path.basename(dir))
        tc.submit('save')
        tc.url(self._tester.url + '/admin/versioncontrol/repository/' + name)
        tc.find('The repository directory must be an absolute path.')
Ejemplo n.º 7
0
    def runTest(self):
        """Admin rename milestone"""
        name1 = self._tester.create_milestone()
        name2 = random_unique_camel()
        tid = self._tester.create_ticket(info={'milestone': name1})
        milestone_url = self._tester.url + '/admin/ticket/milestones'

        self._tester.go_to_url(milestone_url)
        tc.follow(name1)
        tc.url(milestone_url + '/' + name1)
        tc.formvalue('edit', 'name', name2)
        tc.submit('save')

        tc.find(r"Your changes have been saved\.")
        tc.find(r"\b%s\b" % name2)
        tc.notfind(r"\b%s\b" % name1)
        self._tester.go_to_ticket(tid)
        tc.find('<a class="milestone" href="/milestone/%(name)s" '
                'title="No date set">%(name)s</a>' % {'name': name2})
        tc.find('<th class="trac-field-milestone">Milestone:</th>[ \t\n]+'
                '<td>[ \t\n]+<span class="trac-field-old">%s</span>'
                '[ \t\n]+→[ \t\n]+'
                '<span class="trac-field-new">%s</span>[ \t\n]+</td>' %
                (name1, name2))
        tc.find("Milestone renamed")
Ejemplo n.º 8
0
 def create_component(self, name=None, owner=None, description=None):
     """Creates the specified component, with a random camel-cased name if
     none is provided.  Returns the name."""
     if name is None:
         name = random_unique_camel()
     component_url = self.url + "/admin/ticket/components"
     tc.go(component_url)
     tc.url(component_url)
     tc.formvalue('addcomponent', 'name', name)
     if owner is not None:
         tc.formvalue('addcomponent', 'owner', owner)
     tc.submit()
     # Verify the component appears in the component list
     tc.url(component_url)
     tc.find(name)
     tc.notfind(internal_error)
     if description is not None:
         tc.follow(r"\b%s\b" % name)
         tc.formvalue('modcomp', 'description', description)
         tc.submit('save')
         tc.url(component_url)
         tc.find("Your changes have been saved.")
         tc.notfind(internal_error)
     # TODO: verify the component shows up in the newticket page
     return name
Ejemplo n.º 9
0
    def create_milestone(self, name=None, due=None):
        """Creates the specified milestone, with a random name if none is
        provided.  Returns the name of the milestone.
        """
        if name == None:
            name = random_unique_camel()
        milestone_url = self.url + "/admin/ticket/milestones"
        tc.go(milestone_url)
        tc.url(milestone_url)
        tc.formvalue('addmilestone', 'name', name)
        if due:
            # TODO: How should we deal with differences in date formats?
            tc.formvalue('addmilestone', 'duedate', due)
        tc.submit()
        tc.notfind(internal_error)
        tc.notfind('Milestone .* already exists')
        tc.url(milestone_url)
        tc.find(name)

        # Make sure it's on the roadmap.
        tc.follow('Roadmap')
        tc.url(self.url + "/roadmap")
        tc.find('Milestone:.*%s' % name)
        tc.follow(name)
        tc.url('%s/milestone/%s' % (self.url, unicode_quote(name)))
        if not due:
            tc.find('No date set')

        return name
Ejemplo n.º 10
0
    def create_milestone(self, name=None, due=None):
        """Creates the specified milestone, with a random name if none is
        provided.  Returns the name of the milestone.
        """
        if name is None:
            name = random_unique_camel()
        milestone_url = self.url + "/admin/ticket/milestones"
        tc.go(milestone_url)
        tc.url(milestone_url)
        tc.formvalue('addmilestone', 'name', name)
        if due:
            # TODO: How should we deal with differences in date formats?
            tc.formvalue('addmilestone', 'duedate', due)
        tc.submit()
        tc.notfind(internal_error)
        tc.notfind('Milestone .* already exists')
        tc.url(milestone_url)
        tc.find(name)

        # Make sure it's on the roadmap.
        tc.follow(r"\bRoadmap\b")
        tc.url(self.url + "/roadmap")
        tc.find('Milestone:.*%s' % name)
        tc.follow(r"\b%s\b" % name)
        tc.url('%s/milestone/%s' % (self.url, unicode_quote(name)))
        if not due:
            tc.find('No date set')

        return name
Ejemplo n.º 11
0
 def create_component(self, name=None, owner=None, description=None):
     """Creates the specified component, with a random camel-cased name if
     none is provided.  Returns the name."""
     if name is None:
         name = random_unique_camel()
     component_url = self.url + "/admin/ticket/components"
     tc.go(component_url)
     tc.url(component_url)
     tc.formvalue('addcomponent', 'name', name)
     if owner is not None:
         tc.formvalue('addcomponent', 'owner', owner)
     tc.submit()
     # Verify the component appears in the component list
     tc.url(component_url)
     tc.find(name)
     tc.notfind(internal_error)
     if description is not None:
         tc.follow(r"\b%s\b" % name)
         tc.formvalue('edit', 'description', description)
         tc.submit('save')
         tc.url(component_url)
         tc.find("Your changes have been saved.")
         tc.notfind(internal_error)
     # TODO: verify the component shows up in the newticket page
     return name
Ejemplo n.º 12
0
 def _insert_page(self, name=None):
     page = WikiPage(self.env)
     if name is None:
         name = random_unique_camel()
     page.name = name
     page.text = random_paragraph()
     page.save('user1', 'Page created.')
     return name
Ejemplo n.º 13
0
 def test_wiki_export_page_not_found(self):
     name = random_unique_camel()
     export_path = os.path.join(self.tempdir, name)
     rv, output = self.execute('export', name, export_path)
     self.assertEqual(2, rv, output)
     self.assertExpectedResult(output, {
         'name': name,
     })
Ejemplo n.º 14
0
 def test_wiki_replace_from_invalid_path(self):
     name = random_unique_camel()
     path = os.path.join(self.tempdir, name)
     rv, output = self.execute('replace', path)
     self.assertEqual(2, rv, output)
     self.assertExpectedResult(output, {
         'path': path,
     })
     self.assertFalse(WikiPage(self.env, name).exists)
Ejemplo n.º 15
0
 def test_wiki_import_file_not_found(self):
     name = random_unique_camel()
     import_path = os.path.join(self.tempdir, name)
     rv, output = self.execute('import', name, import_path)
     page = WikiPage(self.env, name)
     self.assertEqual(2, rv, output)
     self.assertExpectedResult(output, {
         'import_path': import_path,
     })
Ejemplo n.º 16
0
 def runTest(self):
     """Empty <dd> element should not be created when there is
     no comment associated with an event.
     """
     pagename = random_unique_camel()
     self._tester.create_wiki_page(pagename)
     self._tester.attach_file_to_wiki(pagename, description="")
     self._tester.go_to_timeline()
     tc.find('<dt class="attachment unread">.*?</dt>', 's')
     tc.notfind(
         '<dt class="attachment unread">.*?</dt>[ \t\n]+'
         '<dd class="attachment">[ \t\n]*</dd>', 's')
Ejemplo n.º 17
0
 def test_wiki_replace_new_page(self):
     name = random_unique_camel()
     path = os.path.join(self.tempdir, name)
     content = self._write_file(path)
     rv, output = self.execute('replace', path)
     page = WikiPage(self.env, name)
     self.assertEqual(0, rv, output)
     self.assertExpectedResult(output, {
         'name': name,
         'path': path,
     })
     self.assertEqual(1, page.version)
     self.assertEqual(content, page.text)
Ejemplo n.º 18
0
    def test_wiki_rename(self):
        name1 = self._insert_page()
        name2 = random_unique_camel()

        rv, output = self.execute('rename', name1, name2)
        self.assertEqual(0, rv, output)
        self.assertExpectedResult(output, {
            'name1': name1,
            'name2': name2,
        })
        self.assertIn(('INFO', 'Renamed page %s to %s' % (name1, name2)),
                      self.env.log_messages)
        self.assertFalse(WikiPage(self.env, name1).exists)
        self.assertTrue(WikiPage(self.env, name2).exists)
Ejemplo n.º 19
0
 def test_wiki_import(self):
     name = random_unique_camel()
     import_path = os.path.join(self.tempdir, name)
     content = self._write_file(import_path)
     rv, output = self.execute('import', name, import_path)
     page = WikiPage(self.env, name)
     self.assertEqual(0, rv, output)
     self.assertExpectedResult(output, {
         'name': name,
         'path': import_path,
     })
     self.assertIn(('INFO', '%s imported from %s' % (name, import_path)),
                   self.env.log_messages)
     self.assertEqual(content, page.text)
Ejemplo n.º 20
0
 def create_version(self, name=None, releasetime=None):
     """Create a new version.  The name defaults to a random camel-cased
     word if not provided."""
     version_admin = self.url + "/admin/ticket/versions"
     if name is None:
         name = random_unique_camel()
     tc.go(version_admin)
     tc.url(version_admin)
     tc.formvalue('addversion', 'name', name)
     if releasetime is not None:
         tc.formvalue('addversion', 'time', releasetime)
     tc.submit()
     tc.url(version_admin)
     tc.find(name)
     tc.notfind(internal_error)
Ejemplo n.º 21
0
 def create_enum(self, kind, name=None):
     """Helper to create the specified enum (used for ``priority``,
     ``severity``, etc). If no name is given, a unique random word is used.
     The name is returned.
     """
     if name is None:
         name = random_unique_camel()
     enum_url = self.url + "/admin/ticket/" + kind
     self.go_to_url(enum_url)
     tc.formvalue('addenum', 'name', name)
     tc.submit()
     tc.url(re.escape(enum_url) + '#?$')
     tc.find(name)
     tc.notfind(internal_error)
     return name
Ejemplo n.º 22
0
 def create_version(self, name=None, releasetime=None):
     """Create a new version.  The name defaults to a random camel-cased
     word if not provided."""
     version_admin = self.url + "/admin/ticket/versions"
     if name == None:
         name = random_unique_camel()
     tc.go(version_admin)
     tc.url(version_admin)
     tc.formvalue('addversion', 'name', name)
     if releasetime != None:
         tc.formvalue('addversion', 'time', releasetime)
     tc.submit()
     tc.url(version_admin)
     tc.find(name)
     tc.notfind(internal_error)
Ejemplo n.º 23
0
 def create_enum(self, kind, name=None):
     """Helper to create the specified enum (used for ``priority``,
     ``severity``, etc). If no name is given, a unique random word is used.
     The name is returned.
     """
     if name == None:
         name = random_unique_camel()
     priority_url = self.url + "/admin/ticket/" + kind
     tc.go(priority_url)
     tc.url(priority_url)
     tc.formvalue('addenum', 'name', name)
     tc.submit()
     tc.url(priority_url)
     tc.find(name)
     tc.notfind(internal_error)
     return name
Ejemplo n.º 24
0
 def create_component(self, name=None, user=None):
     """Creates the specified component, with a random camel-cased name if
     none is provided.  Returns the name."""
     if name == None:
         name = random_unique_camel()
     component_url = self.url + "/admin/ticket/components"
     tc.go(component_url)
     tc.url(component_url)
     tc.formvalue('addcomponent', 'name', name)
     if user != None:
         tc.formvalue('addcomponent', 'owner', user)
     tc.submit()
     # Verify the component appears in the component list
     tc.url(component_url)
     tc.find(name)
     tc.notfind(internal_error)
     # TODO: verify the component shows up in the newticket page
     return name
Ejemplo n.º 25
0
 def create_component(self, name=None, user=None):
     """Creates the specified component, with a random camel-cased name if
     none is provided.  Returns the name."""
     if name == None:
         name = random_unique_camel()
     component_url = self.url + "/admin/ticket/components"
     tc.go(component_url)
     tc.url(component_url)
     tc.formvalue('addcomponent', 'name', name)
     if user != None:
         tc.formvalue('addcomponent', 'owner', user)
     tc.submit()
     # Verify the component appears in the component list
     tc.url(component_url)
     tc.find(name)
     tc.notfind(internal_error)
     # TODO: verify the component shows up in the newticket page
     return name
Ejemplo n.º 26
0
    def create_milestone(self, name=None, due=None):
        """Creates the specified milestone, with a random name if none is
        provided.  Returns the name of the milestone.
        """
        if name is None:
            name = random_unique_camel()
        milestone_url = self.url + "/admin/ticket/milestones"
        self.go_to_url(milestone_url)
        tc.formvalue('addmilestone', 'name', name)
        if due:
            # TODO: How should we deal with differences in date formats?
            tc.formvalue('addmilestone', 'duedate', due)
        tc.submit()
        tc.notfind(internal_error)
        tc.notfind('Milestone .* already exists')
        tc.url(milestone_url, regexp=False)
        tc.find(name)

        return name
Ejemplo n.º 27
0
    def runTest(self):
        """Test timeline in RSS format."""
        pagename = random_unique_camel()
        self._tester.create_wiki_page(pagename)
        page = WikiPage(self._testenv.get_trac_environment(), pagename)
        self._tester.go_to_timeline()
        code, content = tc.download_link("RSS Feed")
        self.assertEqual(200, code)
        pattern = r"""<\?xml version="1.0"\?>[\n]+
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Functional Tests</title>
    <link>http://127.0.0.1:\d+/timeline</link>
    <description>Trac Timeline</description>
    <language>en-US</language>
    <generator>Trac [^<]+</generator>
    <image>
      <title>Functional Tests</title>
      <url>http://127.0.0.1:\d+/chrome/site/your_project_logo.png</url>
      <link>http://127.0.0.1:\d+/timeline</link>
    </image>
    <item>
      <title>%(pagename)s created</title>

      <dc:creator>admin</dc:creator>
      <pubDate>%(http_date)s</pubDate>
      <link>http://127.0.0.1:\d+/wiki/%(pagename)s\?version=1</link>
      <guid isPermaLink="false">http://127.0.0.1:\d+/wiki/%(pagename)s\?version=1/\d+</guid>
      <description>[^<]+</description>
      <category>wiki</category>
    </item>
""" % {
            'pagename': pagename,
            'http_date': http_date(page.time)
        }
        if not re.match(pattern.encode('utf-8'), content,
                        re.MULTILINE | re.DOTALL):
            url = tc.write_source(content)
            raise AssertionError(
                "Regex didn't match: {!r} not found in {}".format(
                    pattern, url))
Ejemplo n.º 28
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>\\)')
Ejemplo n.º 29
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>\\)')
Ejemplo n.º 30
0
    def runTest(self):
        """Admin rename milestone"""
        name1 = self._tester.create_milestone()
        name2 = random_unique_camel()
        tid = self._tester.create_ticket(info={'milestone': name1})
        milestone_url = self._tester.url + '/admin/ticket/milestones'

        self._tester.go_to_url(milestone_url)
        tc.follow(name1)
        tc.url(milestone_url + '/' + name1)
        tc.formvalue('edit', 'name', name2)
        tc.submit('save')

        tc.find(r"Your changes have been saved\.")
        tc.find(r"\b%s\b" % name2)
        tc.notfind(r"\b%s\b" % name1)
        self._tester.go_to_ticket(tid)
        tc.find('<a class="milestone" href="/milestone/%(name)s" '
                'title="No date set">%(name)s</a>' % {'name': name2})
        tc.find('<strong class="trac-field-milestone">Milestone</strong>'
                '[ \t\n]+changed from <em>%s</em> to <em>%s</em>'
                % (name1, name2))
        tc.find("Milestone renamed")
Ejemplo n.º 31
0
    def create_wiki_page(self, name=None, content=None, comment=None):
        """Creates a wiki page, with a random unique CamelCase name if none
        is provided, random content if none is provided and a random comment
        if none is provided.  Returns the name of the wiki page.
        """
        if name is None:
            name = random_unique_camel()
        if content is None:
            content = random_page()
        self.go_to_wiki(name)
        tc.find("The page %s does not exist." % name)

        self.edit_wiki_page(name, content, comment)

        # verify the event shows up in the timeline
        self.go_to_timeline()
        tc.formvalue('prefs', 'wiki', True)
        tc.submit()
        tc.find(name + ".*created")

        self.go_to_wiki(name)

        return name
Ejemplo n.º 32
0
    def create_wiki_page(self, name=None, content=None, comment=None):
        """Creates a wiki page, with a random unique CamelCase name if none
        is provided, random content if none is provided and a random comment
        if none is provided.  Returns the name of the wiki page.
        """
        if name is None:
            name = random_unique_camel()
        if content is None:
            content = random_page()
        self.go_to_wiki(name)
        tc.find("The page %s does not exist." % tag.strong(name))

        self.edit_wiki_page(name, content, comment)

        # verify the event shows up in the timeline
        self.go_to_timeline()
        tc.formvalue('prefs', 'wiki', True)
        tc.submit()
        tc.find(name + ".*created")

        self.go_to_wiki(name)

        return name
Ejemplo n.º 33
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')
Ejemplo n.º 34
0
 def runTest(self):
     """Test for regression of http://trac.edgewall.org/ticket/4812"""
     pagename = random_unique_camel() + '/' + random_unique_camel()
     self._tester.create_wiki_page(pagename)
     self._tester.attach_file_to_wiki(pagename)
     tc.notfind('does not exist')
Ejemplo n.º 35
0
 def runTest(self):
     """Test for regression of http://trac.edgewall.org/ticket/4812"""
     pagename = random_unique_camel() + '/' + random_unique_camel()
     self._tester.create_wiki_page(pagename)
     self._tester.attach_file_to_wiki(pagename)
     tc.notfind('does not exist')
Ejemplo n.º 36
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')
Ejemplo n.º 37
0
 def _add_ticket_field_value(self, field, name, *args):
     if name is None:
         name = random_unique_camel()
     self._execute_command(field, 'add', name, *args)
     return name