def test_basic_for_team(self):
        """Check that the page shows the bugs/work items assigned to members
        of a team.
        """
        workitem1 = self.factory.makeSpecificationWorkItem(
            assignee=self.team.teamowner, milestone=self.today_milestone)
        workitem2 = self.factory.makeSpecificationWorkItem(
            assignee=self.team.teamowner, milestone=self.tomorrow_milestone)
        bugtask1 = self.factory.makeBug(
            milestone=self.today_milestone).bugtasks[0]
        bugtask2 = self.factory.makeBug(
            milestone=self.tomorrow_milestone).bugtasks[0]
        for bugtask in [bugtask1, bugtask2]:
            removeSecurityProxy(bugtask).assignee = self.team.teamowner

        browser = self.getViewBrowser(
            self.team, view_name='+upcomingwork', no_login=True)

        # Check that the two work items and bugtasks created above are shown
        # and grouped under the appropriate milestone date.
        groups = find_tags_by_class(browser.contents, 'workitems-group')
        self.assertEqual(2, len(groups))
        todays_group = extract_text(groups[0])
        tomorrows_group = extract_text(groups[1])
        self.assertStartsWith(
            todays_group, 'Work items due in %s' % self.today)
        self.assertIn(workitem1.title, todays_group)
        with anonymous_logged_in():
            self.assertIn(bugtask1.bug.title, todays_group)

        self.assertStartsWith(
            tomorrows_group, 'Work items due in %s' % self.tomorrow)
        self.assertIn(workitem2.title, tomorrows_group)
        with anonymous_logged_in():
            self.assertIn(bugtask2.bug.title, tomorrows_group)
    def test_basic_for_person(self):
        """Check that the page shows the bugs/work items assigned to a person.
        """
        person = self.factory.makePerson()
        workitem = self.factory.makeSpecificationWorkItem(
            assignee=person, milestone=self.today_milestone)
        bugtask = self.factory.makeBug(
            milestone=self.tomorrow_milestone).bugtasks[0]
        removeSecurityProxy(bugtask).assignee = person

        browser = self.getViewBrowser(
            person, view_name='+upcomingwork', no_login=True)

        # Check that the two work items created above are shown and grouped
        # under the appropriate milestone date.
        groups = find_tags_by_class(browser.contents, 'workitems-group')
        self.assertEqual(2, len(groups))
        todays_group = extract_text(groups[0])
        tomorrows_group = extract_text(groups[1])
        self.assertStartsWith(
            todays_group, 'Work items due in %s' % self.today)
        self.assertIn(workitem.title, todays_group)

        self.assertStartsWith(
            tomorrows_group, 'Work items due in %s' % self.tomorrow)
        with anonymous_logged_in():
            self.assertIn(bugtask.bug.title, tomorrows_group)
Esempio n. 3
0
    def test_deptree_filters_blocked(self):
        # dep tree's blocked_specs and dependencies attributes filter
        # blueprints the user can't see.
        sharing_policy = SpecificationSharingPolicy.PUBLIC_OR_PROPRIETARY
        owner = self.factory.makePerson()
        product = self.factory.makeProduct(
            owner=owner, specification_sharing_policy=sharing_policy)
        root = self.factory.makeBlueprint(product=product)
        proprietary_blocked = self.factory.makeBlueprint(
            product=product, information_type=InformationType.PROPRIETARY)
        public_blocked = self.factory.makeBlueprint(product=product)
        proprietary_blocked.createDependency(root)
        public_blocked.createDependency(root)

        # Anonymous can see only the public
        with anonymous_logged_in():
            view = create_view(root, name="+deptree")
            self.assertEqual([public_blocked], view.all_blocked)
            self.assertEqual([public_blocked], view.blocked_specs)

        # The owner can see everything.
        with person_logged_in(owner):
            view = create_view(root, name="+deptree")
            self.assertEqual([proprietary_blocked, public_blocked],
                             view.all_blocked)
            self.assertEqual([proprietary_blocked, public_blocked],
                             view.blocked_specs)

        # A random person cannot see the propriety dep.
        with person_logged_in(self.factory.makePerson()):
            view = create_view(root, name="+deptree")
            self.assertEqual([public_blocked], view.all_blocked)
            self.assertEqual([public_blocked], view.blocked_specs)
    def test_blog_posts(self):
        """Posts from the launchpad blog are shown when feature is enabled"""
        self.useFixture(FeatureFixture({'app.root_blog.enabled': True}))
        posts = [
            self._make_blog_post(1, "A post", "Post contents.", "2002"),
            self._make_blog_post(2, "Another post", "More contents.", "2003"),
        ]
        calls = []

        def _get_blog_posts():
            calls.append('called')
            return posts

        root = getUtility(ILaunchpadRoot)
        with anonymous_logged_in():
            view = create_initialized_view(root, 'index.html')
            view.getRecentBlogPosts = _get_blog_posts
            result = view()
        markup = BeautifulSoup(
            result, parse_only=SoupStrainer(id='homepage-blogposts'))
        self.assertEqual(['called'], calls)
        items = markup.findAll('li', 'news')
        # Notice about launchpad being opened is always added at the end
        self.assertEqual(3, len(items))
        a = items[-1].find("a")
        self.assertEqual("Launchpad now open source", a.string.strip())
        for post, item in zip(posts, items):
            a = item.find("a")
            self.assertEqual(post['link'], a["href"])
            self.assertEqual(post['title'], a.string)
    def test_blog_posts(self):
        """Posts from the launchpad blog are shown when feature is enabled"""
        self.useFixture(FeatureFixture({'app.root_blog.enabled': True}))
        posts = [
            self._make_blog_post(1, "A post", "Post contents.", "2002"),
            self._make_blog_post(2, "Another post", "More contents.", "2003"),
            ]
        calls = []

        def _get_blog_posts():
            calls.append('called')
            return posts

        root = getUtility(ILaunchpadRoot)
        with anonymous_logged_in():
            view = create_initialized_view(root, 'index.html')
            view.getRecentBlogPosts = _get_blog_posts
            result = view()
        markup = BeautifulSoup(result,
            parseOnlyThese=SoupStrainer(id='homepage-blogposts'))
        self.assertEqual(['called'], calls)
        items = markup.findAll('li', 'news')
        # Notice about launchpad being opened is always added at the end
        self.assertEqual(3, len(items))
        a = items[-1].find("a")
        self.assertEqual("Launchpad now open source", a.string.strip())
        for post, item in zip(posts, items):
            a = item.find("a")
            self.assertEqual(post['link'], a["href"])
            self.assertEqual(post['title'], a.string)
    def test_deptree_filters_blocked(self):
        # dep tree's blocked_specs and dependencies attributes filter
        # blueprints the user can't see.
        sharing_policy = SpecificationSharingPolicy.PUBLIC_OR_PROPRIETARY
        owner = self.factory.makePerson()
        product = self.factory.makeProduct(
            owner=owner, specification_sharing_policy=sharing_policy)
        root = self.factory.makeBlueprint(product=product)
        proprietary_blocked = self.factory.makeBlueprint(
            product=product, information_type=InformationType.PROPRIETARY)
        public_blocked = self.factory.makeBlueprint(product=product)
        proprietary_blocked.createDependency(root)
        public_blocked.createDependency(root)

        # Anonymous can see only the public
        with anonymous_logged_in():
            view = create_view(root, name="+deptree")
            self.assertEqual([public_blocked], view.all_blocked)
            self.assertEqual([public_blocked], view.blocked_specs)

        # The owner can see everything.
        with person_logged_in(owner):
            view = create_view(root, name="+deptree")
            self.assertEqual(
                [proprietary_blocked, public_blocked], view.all_blocked)
            self.assertEqual(
                [proprietary_blocked, public_blocked], view.blocked_specs)

        # A random person cannot see the propriety dep.
        with person_logged_in(self.factory.makePerson()):
            view = create_view(root, name="+deptree")
            self.assertEqual([public_blocked], view.all_blocked)
            self.assertEqual([public_blocked], view.blocked_specs)
Esempio n. 7
0
    def test_copes_with_private_repos(self):
        invisible_repo = self.factory.makeGitRepository(
            owner=self.owner, target=self.target,
            information_type=InformationType.PRIVATESECURITY)
        other_repo = self.factory.makeGitRepository(
            owner=self.owner, target=self.target,
            information_type=InformationType.PUBLIC)
        with admin_logged_in():
            getUtility(IGitRepositorySet).setDefaultRepositoryForOwner(
                owner=self.owner, target=self.target,
                repository=invisible_repo, user=self.owner)

        # An anonymous user can't see the default.
        with anonymous_logged_in():
            anon_view = create_initialized_view(self.owner_target, '+git')
            self.assertIs(None, anon_view.default_git_repository)
            self.assertContentEqual(
                [other_repo], anon_view.repo_collection.getRepositories())

        # Neither can a random unprivileged user.
        with person_logged_in(self.factory.makePerson()):
            anon_view = create_initialized_view(self.owner_target, '+git')
            self.assertIs(None, anon_view.default_git_repository)
            self.assertContentEqual(
                [other_repo], anon_view.repo_collection.getRepositories())

        # But someone who can see the repo gets the normal view.
        with person_logged_in(self.owner):
            owner_view = create_initialized_view(
                self.owner_target, '+git', principal=self.owner)
            self.assertEqual(invisible_repo, owner_view.default_git_repository)
            self.assertContentEqual(
                [invisible_repo, other_repo],
                owner_view.repo_collection.getRepositories())
Esempio n. 8
0
    def test_copes_with_private_repos(self):
        # XXX wgrant 2015-06-12: owner is self.user instead of
        # self.owner here so the Distribution tests work.
        # GitRepository._reconcileAccess doesn't handle distro repos
        # properly, so an AccessPolicyGrant isn't sufficient.
        invisible_repo = self.factory.makeGitRepository(
            owner=self.user, target=self.target,
            information_type=InformationType.PRIVATESECURITY)
        other_repo = self.factory.makeGitRepository(
            owner=self.owner, target=self.target,
            information_type=InformationType.PUBLIC)

        # An anonymous user can't see the private branch.
        with anonymous_logged_in():
            anon_view = create_initialized_view(self.context, '+git')
            self.assertContentEqual(
                [other_repo], anon_view.repo_collection.getRepositories())

        # Neither can a random unprivileged user.
        with person_logged_in(self.factory.makePerson()):
            anon_view = create_initialized_view(self.context, '+git')
            self.assertContentEqual(
                [other_repo], anon_view.repo_collection.getRepositories())

        # But someone who can see the repo gets the full view.
        with person_logged_in(self.user):
            owner_view = create_initialized_view(
                self.context, '+git', principal=self.user)
            self.assertContentEqual(
                [invisible_repo, other_repo],
                owner_view.repo_collection.getRepositories())
Esempio n. 9
0
 def test_title_and_description_writes(self):
     question = self.factory.makeQuestion()
     with anonymous_logged_in():
         with ExpectedException(Unauthorized):
             question.title = 'foo anon'
         with ExpectedException(Unauthorized):
             question.description = 'foo anon'
     with person_logged_in(self.factory.makePerson()):
         with ExpectedException(Unauthorized):
             question.title = 'foo random'
         with ExpectedException(Unauthorized):
             question.description = 'foo random'
     answer_contact = self.factory.makePerson()
     with person_logged_in(answer_contact):
         answer_contact.addLanguage(getUtility(ILanguageSet)['en'])
         question.target.addAnswerContact(answer_contact, answer_contact)
         with ExpectedException(Unauthorized):
             question.title = 'foo contact'
         with ExpectedException(Unauthorized):
             question.description = 'foo contact'
     with person_logged_in(question.owner):
         question.title = question.description = 'foo owner'
     with person_logged_in(question.target.owner):
         question.title = question.description = 'foo target owner'
     with admin_logged_in():
         question.title = question.description = 'foo admin'
     with celebrity_logged_in('registry_experts'):
         question.title = question.description = 'foo registry'
    def test_basic_for_person(self):
        """Check that the page shows the bugs/work items assigned to a person.
        """
        person = self.factory.makePerson()
        workitem = self.factory.makeSpecificationWorkItem(
            assignee=person, milestone=self.today_milestone)
        bugtask = self.factory.makeBug(
            milestone=self.tomorrow_milestone).bugtasks[0]
        removeSecurityProxy(bugtask).assignee = person

        browser = self.getViewBrowser(person,
                                      view_name='+upcomingwork',
                                      no_login=True)

        # Check that the two work items created above are shown and grouped
        # under the appropriate milestone date.
        groups = find_tags_by_class(browser.contents, 'workitems-group')
        self.assertEqual(2, len(groups))
        todays_group = extract_text(groups[0])
        tomorrows_group = extract_text(groups[1])
        self.assertStartsWith(todays_group,
                              'Work items due in %s' % self.today)
        self.assertIn(workitem.title, todays_group)

        self.assertStartsWith(tomorrows_group,
                              'Work items due in %s' % self.tomorrow)
        with anonymous_logged_in():
            self.assertIn(bugtask.bug.title, tomorrows_group)
 def test_score_archive_allows_buildd_and_commercial_admin(self):
     # Buildd and commercial admins can change an archive's build score.
     archive = self.factory.makeArchive()
     self.assertScoreWriteableByTeam(
         archive, getUtility(ILaunchpadCelebrities).buildd_admin)
     with anonymous_logged_in():
         self.assertScoreWriteableByTeam(
             archive, getUtility(ILaunchpadCelebrities).commercial_admin)
 def test_score_archive_allows_buildd_and_ppa_admin(self):
     # Buildd and PPA admins can change an archive's build score.
     archive = self.factory.makeArchive()
     self.assertScoreWriteableByTeam(
         archive, getUtility(ILaunchpadCelebrities).buildd_admin)
     with anonymous_logged_in():
         self.assertScoreWriteableByTeam(
             archive, getUtility(ILaunchpadCelebrities).ppa_admin)
 def test_external_bugs_api(self):
     """The bugs API on the other hand is an external service so it is
     available on the external port.
     """
     with anonymous_logged_in():
         external_api = self.get_public_proxy('bugs/')
         bug_dict = dict(
             product='firefox', summary='the summary', comment='the comment')
         result = external_api.filebug(bug_dict)
         self.assertEqual('http://bugs.launchpad.dev/bugs/16', result)
 def test_external_bugs_api(self):
     """The bugs API on the other hand is an external service so it is
     available on the external port.
     """
     with anonymous_logged_in():
         external_api = self.get_public_proxy('bugs/')
         bug_dict = dict(product='firefox',
                         summary='the summary',
                         comment='the comment')
         result = external_api.filebug(bug_dict)
         self.assertStartsWith(result, 'http://bugs.launchpad.dev/bugs/')
 def test_read_to_all(self):
     """`BugSubscriptionFilter`s can be read by anyone."""
     bug_subscription_filter = BugSubscriptionFilter()
     bug_subscription_filter.structural_subscription = self.subscription
     bug_subscription_filter = ProxyFactory(bug_subscription_filter)
     with person_logged_in(self.subscriber):
         bug_subscription_filter.find_all_tags
     with person_logged_in(self.factory.makePerson()):
         bug_subscription_filter.find_all_tags
     with anonymous_logged_in():
         bug_subscription_filter.find_all_tags
 def test_read_to_all(self):
     """`BugSubscriptionFilter`s can be read by anyone."""
     bug_subscription_filter = BugSubscriptionFilter()
     bug_subscription_filter.structural_subscription = self.subscription
     bug_subscription_filter = ProxyFactory(bug_subscription_filter)
     with person_logged_in(self.subscriber):
         bug_subscription_filter.find_all_tags
     with person_logged_in(self.factory.makePerson()):
         bug_subscription_filter.find_all_tags
     with anonymous_logged_in():
         bug_subscription_filter.find_all_tags
Esempio n. 17
0
 def test_delete_requires_Edit_permission(self):
     # delete() is only available to the subscriber.
     # We use a lambda here because a security proxy around
     # self.subscription is giving us the behavior we want to
     # demonstrate.  Merely accessing the "delete" name raises
     # Unauthorized, before the method is even called.  Therefore,
     # we use a lambda to make the trigger happen within "assertRaises".
     with anonymous_logged_in():
         self.assertRaises(Unauthorized, lambda: self.subscription.delete)
     with person_logged_in(self.factory.makePerson()):
         self.assertRaises(Unauthorized, lambda: self.subscription.delete)
 def test_delete_requires_Edit_permission(self):
     # delete() is only available to the subscriber.
     # We use a lambda here because a security proxy around
     # self.subscription is giving us the behavior we want to
     # demonstrate.  Merely accessing the "delete" name raises
     # Unauthorized, before the method is even called.  Therefore,
     # we use a lambda to make the trigger happen within "assertRaises".
     with anonymous_logged_in():
         self.assertRaises(Unauthorized, lambda: self.subscription.delete)
     with person_logged_in(self.factory.makePerson()):
         self.assertRaises(Unauthorized, lambda: self.subscription.delete)
    def test_user_pass_authentication(self):
        """If we provide a username and password, hello() will
        include the name of the logged in user.

        The interactions in this test, and the interaction in the XMLRPC
        methods are different, so we still have an anonymous interaction in
        this test.
        """
        with anonymous_logged_in():
            self.assertIs(None, getUtility(ILaunchBag).user)
            selftest = self.make_logged_in_proxy()
            self.assertEqual('Hello Sample Person.', selftest.hello())
    def test_user_pass_authentication(self):
        """If we provide a username and password, hello() will
        include the name of the logged in user.

        The interactions in this test, and the interaction in the XMLRPC
        methods are different, so we still have an anonymous interaction in
        this test.
        """
        with anonymous_logged_in():
            self.assertIs(None, getUtility(ILaunchBag).user)
            selftest = self.make_logged_in_proxy()
            self.assertEqual('Hello Sample Person.', selftest.hello())
 def test_package_diffs_hidden_to_unprivileged_user_if_not_available(self):
     # No diff information is shown if pacakge diffs are not available and
     # the user does not have permission to request their creation.
     ds_diff = self.factory.makeDistroSeriesDifference(
         versions={'base': '0.1', 'derived': '0.1-1derived1',
                   'parent': '0.1-2'},
         set_base_version=True)
     with anonymous_logged_in():
         view = create_initialized_view(
             ds_diff, '+listing-distroseries-extra')
         html = view()
         self.assertThat(html, Not(self.package_diff_header_matcher))
         self.assertThat(html, Not(self.package_diff_info_matcher))
 def test_delete_by_subscribers(self):
     """`BugSubscriptionFilter`s can only be deleted by subscribers."""
     bug_subscription_filter = BugSubscriptionFilter()
     bug_subscription_filter.structural_subscription = self.subscription
     bug_subscription_filter = ProxyFactory(bug_subscription_filter)
     # Anonymous users are denied rights to delete the filter.
     with anonymous_logged_in():
         self.assertRaises(
             Unauthorized, getattr, bug_subscription_filter, "delete")
     # Any other person is also denied.
     with person_logged_in(self.factory.makePerson()):
         self.assertRaises(
             Unauthorized, getattr, bug_subscription_filter, "delete")
     # The subscriber can delete the filter.
     with person_logged_in(self.subscriber):
         bug_subscription_filter.delete()
 def test_delete_by_subscribers(self):
     """`BugSubscriptionFilter`s can only be deleted by subscribers."""
     bug_subscription_filter = BugSubscriptionFilter()
     bug_subscription_filter.structural_subscription = self.subscription
     bug_subscription_filter = ProxyFactory(bug_subscription_filter)
     # Anonymous users are denied rights to delete the filter.
     with anonymous_logged_in():
         self.assertRaises(Unauthorized, getattr, bug_subscription_filter,
                           "delete")
     # Any other person is also denied.
     with person_logged_in(self.factory.makePerson()):
         self.assertRaises(Unauthorized, getattr, bug_subscription_filter,
                           "delete")
     # The subscriber can delete the filter.
     with person_logged_in(self.subscriber):
         bug_subscription_filter.delete()
 def test_write_to_subscribers(self):
     """`BugSubscriptionFilter`s can only be modifed by subscribers."""
     bug_subscription_filter = BugSubscriptionFilter()
     bug_subscription_filter.structural_subscription = self.subscription
     bug_subscription_filter = ProxyFactory(bug_subscription_filter)
     # The subscriber can edit the filter.
     with person_logged_in(self.subscriber):
         bug_subscription_filter.find_all_tags = True
     # Any other person is denied rights to edit the filter.
     with person_logged_in(self.factory.makePerson()):
         self.assertRaises(Unauthorized, setattr, bug_subscription_filter,
                           "find_all_tags", True)
     # Anonymous users are also denied.
     with anonymous_logged_in():
         self.assertRaises(Unauthorized, setattr, bug_subscription_filter,
                           "find_all_tags", True)
    def test_blog_posts_with_memcache(self):
        self.useFixture(FeatureFixture({'app.root_blog.enabled': True}))
        posts = [
            self._make_blog_post(1, "A post", "Post contents.", "2002"),
            self._make_blog_post(2, "Another post", "More contents.", "2003"),
        ]
        key = '%s:homepage-blog-posts' % config.instance_name
        getUtility(IMemcacheClient).set(key, posts)

        root = getUtility(ILaunchpadRoot)
        with anonymous_logged_in():
            view = create_initialized_view(root, 'index.html')
            result = view()
        markup = BeautifulSoup(
            result, parse_only=SoupStrainer(id='homepage-blogposts'))
        items = markup.findAll('li', 'news')
        self.assertEqual(3, len(items))
 def test_write_to_any_user_when_no_subscription(self):
     """
     `BugSubscriptionFilter`s can be modifed by any logged-in user when
     there is no related subscription.
     """
     bug_subscription_filter = BugSubscriptionFilter()
     bug_subscription_filter = ProxyFactory(bug_subscription_filter)
     # The subscriber can edit the filter.
     with person_logged_in(self.subscriber):
         bug_subscription_filter.find_all_tags = True
     # Any other person can edit the filter.
     with person_logged_in(self.factory.makePerson()):
         bug_subscription_filter.find_all_tags = True
     # Anonymous users are denied rights to edit the filter.
     with anonymous_logged_in():
         self.assertRaises(Unauthorized, setattr, bug_subscription_filter,
                           "find_all_tags", True)
    def test_blog_posts_with_memcache(self):
        self.useFixture(FeatureFixture({'app.root_blog.enabled': True}))
        posts = [
            self._make_blog_post(1, "A post", "Post contents.", "2002"),
            self._make_blog_post(2, "Another post", "More contents.", "2003"),
            ]
        key = '%s:homepage-blog-posts' % config.instance_name
        getUtility(IMemcacheClient).set(key, posts)

        root = getUtility(ILaunchpadRoot)
        with anonymous_logged_in():
            view = create_initialized_view(root, 'index.html')
            result = view()
        markup = BeautifulSoup(result,
            parseOnlyThese=SoupStrainer(id='homepage-blogposts'))
        items = markup.findAll('li', 'news')
        self.assertEqual(3, len(items))
 def test_write_to_subscribers(self):
     """`BugSubscriptionFilter`s can only be modifed by subscribers."""
     bug_subscription_filter = BugSubscriptionFilter()
     bug_subscription_filter.structural_subscription = self.subscription
     bug_subscription_filter = ProxyFactory(bug_subscription_filter)
     # The subscriber can edit the filter.
     with person_logged_in(self.subscriber):
         bug_subscription_filter.find_all_tags = True
     # Any other person is denied rights to edit the filter.
     with person_logged_in(self.factory.makePerson()):
         self.assertRaises(
             Unauthorized, setattr, bug_subscription_filter,
             "find_all_tags", True)
     # Anonymous users are also denied.
     with anonymous_logged_in():
         self.assertRaises(
             Unauthorized, setattr, bug_subscription_filter,
             "find_all_tags", True)
 def test_write_to_any_user_when_no_subscription(self):
     """
     `BugSubscriptionFilter`s can be modifed by any logged-in user when
     there is no related subscription.
     """
     bug_subscription_filter = BugSubscriptionFilter()
     bug_subscription_filter = ProxyFactory(bug_subscription_filter)
     # The subscriber can edit the filter.
     with person_logged_in(self.subscriber):
         bug_subscription_filter.find_all_tags = True
     # Any other person can edit the filter.
     with person_logged_in(self.factory.makePerson()):
         bug_subscription_filter.find_all_tags = True
     # Anonymous users are denied rights to edit the filter.
     with anonymous_logged_in():
         self.assertRaises(
             Unauthorized, setattr, bug_subscription_filter,
             "find_all_tags", True)
 def test_checkSubmitConditions_rejects_anonymous_request(self):
     with anonymous_logged_in():
         view = self._makeView()
         self.assertRaises(UnexpectedFormData, view._checkSubmitConditions)
 def test_newBugFilter_by_anonymous(self):
     # newBugFilter() is not available to anonymous users.
     with anonymous_logged_in():
         self.assertRaises(
             Unauthorized, lambda: self.subscription.newBugFilter)
Esempio n. 32
0
 def test_anonymous_users_cannot_unlink_branches(self):
     # Anonymous users cannot unlink branches from bugs, even public bugs.
     bug = self.factory.makeBug()
     with anonymous_logged_in():
         self.assertRaises(Unauthorized, getattr, bug, 'unlinkBranch')
 def test_get_utility(self):
     with anonymous_logged_in():
         internal_api = self.get_private_proxy('bugs/')
         token_string = internal_api.newBugTrackerToken()
         token = getUtility(ILoginTokenSet)[token_string]
         self.assertEqual('LoginToken', token.__class__.__name__)
Esempio n. 34
0
 def test_anonymous_users_cannot_unlink_branches(self):
     # Anonymous users cannot unlink branches from bugs, even public bugs.
     bug = self.factory.makeBug()
     with anonymous_logged_in():
         self.assertRaises(Unauthorized, getattr, bug, 'unlinkBranch')
Esempio n. 35
0
 def test_newBugFilter_by_anonymous(self):
     # newBugFilter() is not available to anonymous users.
     with anonymous_logged_in():
         self.assertRaises(Unauthorized,
                           lambda: self.subscription.newBugFilter)
 def test_get_utility(self):
     with anonymous_logged_in():
         internal_api = self.get_private_proxy('bugs/')
         token_string = internal_api.newBugTrackerToken()
         token = getUtility(ILoginTokenSet)[token_string]
         self.assertEqual('LoginToken', token.__class__.__name__)
Esempio n. 37
0
 def test_anonymous_log_in(self):
     # anonymous_logged_in is a context logged in as anonymous.
     with anonymous_logged_in():
         self.assertLoggedIn(ANONYMOUS)
 def test_edit_link_for_anonymous(self):
     # A link to edit the filter is *not* rendered for anyone but the
     # subscriber.
     with anonymous_logged_in():
         self.assertEqual([], self.findEditLinks(self.view))
Esempio n. 39
0
 def test_edit_link_for_anonymous(self):
     # A link to edit the filter is *not* rendered for anyone but the
     # subscriber.
     with anonymous_logged_in():
         self.assertEqual([], self.findEditLinks(self.view))
Esempio n. 40
0
 def test_anonymous_log_in(self):
     # anonymous_logged_in is a context logged in as anonymous.
     with anonymous_logged_in():
         self.assertLoggedIn(ANONYMOUS)
Esempio n. 41
0
 def test_checkSubmitConditions_rejects_anonymous_request(self):
     with anonymous_logged_in():
         view = self._makeView()
         self.assertRaises(UnexpectedFormData, view._checkSubmitConditions)
Esempio n. 42
0
 def test_anonymous_cannot_view(self):
     webhook = self.factory.makeWebhook()
     with anonymous_logged_in():
         self.assertFalse(check_permission('launchpad.View', webhook))