コード例 #1
0
 def test_access_for_persons_with_special_permissions(self):
     # Admins have access all products, including inactive and propretary
     # products.
     with celebrity_logged_in('admin'):
         self.check_admin_access()
     # Commercial admins have access to all products.
     with celebrity_logged_in('commercial_admin'):
         self.check_admin_access()
コード例 #2
0
 def test_celebrity_logged_in(self):
     # celebrity_logged_in runs in a context where a celebrity is logged
     # in.
     vcs_imports = getUtility(ILaunchpadCelebrities).vcs_imports
     with celebrity_logged_in('vcs_imports'):
         person = self.getLoggedInPerson()
     self.assertTrue(person.inTeam(vcs_imports))
コード例 #3
0
 def test_inGoodStanding(self):
     self.factory.makePerson(email='*****@*****.**')
     yes_person = self.factory.makePerson(email='*****@*****.**')
     with celebrity_logged_in('admin'):
         yes_person.personal_standing = PersonalStanding.GOOD
     self.assertIs(True, self.api.inGoodStanding('*****@*****.**'))
     self.assertIs(False, self.api.inGoodStanding('*****@*****.**'))
コード例 #4
0
    def test_close_bugs_for_sourcepackagerelease_with_private_bug(self):
        """close_bugs_for_sourcepackagerelease works with private bugs."""
        changes_file_template = "Format: 1.7\nLaunchpad-bugs-fixed: %s\n"
        # changelog_entry is required for an assertion inside the function
        # we're testing.
        spr = self.factory.makeSourcePackageRelease(changelog_entry="blah")
        archive_admin = self.factory.makePerson()
        series = spr.upload_distroseries
        dsp = series.distribution.getSourcePackage(spr.sourcepackagename)
        bug = self.factory.makeBug(
            target=dsp, information_type=InformationType.USERDATA)
        changes = StringIO(changes_file_template % bug.id)

        with person_logged_in(archive_admin):
            # The archive admin user can't normally see this bug.
            self.assertRaises(ForbiddenAttribute, bug, 'status')
            # But the bug closure should work.
            close_bugs_for_sourcepackagerelease(series, spr, changes)

        # Rather than closing the bugs immediately, this creates a
        # ProcessAcceptedBugsJob.
        with celebrity_logged_in("admin"):
            self.assertEqual(BugTaskStatus.NEW, bug.default_bugtask.status)
        job_source = getUtility(IProcessAcceptedBugsJobSource)
        [job] = list(job_source.iterReady())
        self.assertEqual(series, job.distroseries)
        self.assertEqual(spr, job.sourcepackagerelease)
        self.assertEqual([bug.id], job.bug_ids)
コード例 #5
0
def create_child(factory):
    processor = factory.makeProcessor()
    parent = factory.makeDistroSeries()
    parent_das = factory.makeDistroArchSeries(distroseries=parent, processor=processor)
    lf = factory.makeLibraryFileAlias()
    # Since the LFA needs to be in the librarian, commit.
    transaction.commit()
    parent_das.addOrUpdateChroot(lf)
    with celebrity_logged_in("admin"):
        parent_das.supports_virtualized = True
        parent.nominatedarchindep = parent_das
        publisher = SoyuzTestPublisher()
        publisher.prepareBreezyAutotest()
        packages = {"udev": "0.1-1", "libc6": "2.8-1"}
        for package in packages.keys():
            publisher.getPubBinaries(
                distroseries=parent,
                binaryname=package,
                version=packages[package],
                status=PackagePublishingStatus.PUBLISHED,
            )
        test1 = getUtility(IPackagesetSet).new(u"test1", u"test 1 packageset", parent.owner, distroseries=parent)
        test1_packageset_id = str(test1.id)
        test1.addSources("udev")
    parent.updatePackageCount()
    child = factory.makeDistroSeries()
    getUtility(ISourcePackageFormatSelectionSet).add(child, SourcePackageFormat.FORMAT_1_0)
    # Make sure everything hits the database, switching db users aborts.
    transaction.commit()
    return parent, child, test1_packageset_id
コード例 #6
0
 def test_subscribeGrantsVisibility(self):
     # When a user is subscribed to a bug, they are granted access.
     user = self.factory.makePerson()
     self.assertFalse(self.bug.userCanView(user))
     with celebrity_logged_in('admin'):
         self.bug.subscribe(user, self.owner)
         self.assertTrue(self.bug.userCanView(user))
コード例 #7
0
def set_service_usage(pillar_name, **kw):
    factory = LaunchpadObjectFactory()
    with celebrity_logged_in('admin'):
        pillar = getUtility(IPillarNameSet)[pillar_name]
        for attr, service_usage_name in kw.items():
            service_usage = getattr(ServiceUsage, service_usage_name)
            if attr == 'bug_tracking_usage':
                pillar.official_malone = (
                    service_usage == ServiceUsage.LAUNCHPAD)
                if service_usage == ServiceUsage.EXTERNAL:
                    pillar.bugtracker = factory.makeBugTracker()

            # if we're setting codehosting on product things get trickier.
            elif attr == 'codehosting_usage' and IProduct.providedBy(pillar):
                if service_usage == ServiceUsage.LAUNCHPAD:
                    branch = factory.makeProductBranch(product=pillar)
                    product_series = factory.makeProductSeries(
                        product=pillar,
                        branch=branch)
                    pillar.development_focus = product_series
                elif service_usage == ServiceUsage.EXTERNAL:
                    branch = factory.makeProductBranch(
                        product=pillar,
                        branch_type=BranchType.MIRRORED)
                    product_series = factory.makeProductSeries(
                        product=pillar,
                        branch=branch)
                    pillar.development_focus = product_series
                elif service_usage == ServiceUsage.UNKNOWN:
                    branch = factory.makeProductBranch(product=pillar)
                    product_series = factory.makeProductSeries(
                        product=pillar)
                    pillar.development_focus = product_series
            else:
                setattr(pillar, attr, service_usage)
コード例 #8
0
 def _do_premerge(self, from_person, to_person):
     # Do the pre merge work performed by the LoginToken.
     with celebrity_logged_in('admin'):
         email = from_person.preferredemail
         email.status = EmailAddressStatus.NEW
         email.person = to_person
     transaction.commit()
コード例 #9
0
 def test_celebrity_logged_in_restores_person(self):
     # Once outside of the celebrity_logged_in context, the originally
     # logged-in person is re-logged in.
     person = self.factory.makePerson()
     login_as(person)
     with celebrity_logged_in('vcs_imports'):
         pass
     self.assertLoggedIn(person)
コード例 #10
0
 def test_admin_can_set_visible(self):
     # Admins can set question comment
     # visibility.
     with celebrity_logged_in('admin') as admin:
         person = admin
     question = self._get_question_for_user(person)
     self._set_visibility(question)
     self.assertFalse(self.message.visible)
コード例 #11
0
 def test_registry_admin_can_set_visible(self):
     # Members of registry experts can set question comment
     # visibility.
     with celebrity_logged_in('registry_experts') as registry:
         person = registry
     question = self._get_question_for_user(person)
     self._set_visibility(question)
     self.assertFalse(self.message.visible)
コード例 #12
0
 def test_inactive_product_groups_are_excluded(self):
     # Inactive project groups are not in the vocabulary.
     with celebrity_logged_in("registry_experts"):
         self.project_group.active = False
     terms = self.vocabulary.searchForTerms("snark")
     result = [term.value for term in terms]
     self.assertEqual([self.product, self.distribution], result)
     self.assertFalse(self.project_group in self.vocabulary)
コード例 #13
0
 def test_inaccessible_private_bug_not_found(self):
     # Private bugs don't acknowledge their existence to non-subscribers.
     with celebrity_logged_in('admin'):
         getUtility(IBugSet).get(4).setPrivate(
             True, self.factory.makePerson())
     message = self.getFailureForMessage('*****@*****.**')
     self.assertIn(
         "There is no such bug in Launchpad: 4", message)
コード例 #14
0
 def test_privateBugUnsubscribeRevokesVisibility(self):
     # A person unsubscribed from a private bug can no longer see it.
     user = self.factory.makePerson()
     with celebrity_logged_in('admin'):
         self.bug.subscribe(user, self.owner)
         self.assertTrue(self.bug.userCanView(user))
         self.bug.unsubscribe(user, self.owner)
     self.assertFalse(self.bug.userCanView(user))
コード例 #15
0
 def makeHiddenMessage(self):
     """Required by the mixin."""
     with celebrity_logged_in('admin'):
         bug = self.factory.makeBug()
         comment = self.factory.makeBugComment(
                 bug=bug, body=self.comment_text)
         comment.visible = False
     return bug
コード例 #16
0
 def test_links_admin(self):
     # An admin can change details and administer a project group.
     with celebrity_logged_in('admin'):
         user = getUtility(ILaunchBag).user
         view = create_initialized_view(
             self.project_group, '+index', principal=user)
         contents = view.render()
         self.assertThat(contents, Contains("Change details"))
         self.assertThat(contents, Contains("Administer"))
コード例 #17
0
 def test_bugs_answers_usage_bugs(self):
     # The dict values are True for bugs and either.
     with celebrity_logged_in('admin'):
         self.dsp.distribution.official_malone = True
     view = create_view(self.dsp, '+index')
     self.assertTrue(view.bugs_answers_usage['uses_bugs'])
     self.assertFalse(view.bugs_answers_usage['uses_answers'])
     self.assertFalse(view.bugs_answers_usage['uses_both'])
     self.assertTrue(view.bugs_answers_usage['uses_either'])
コード例 #18
0
 def test_privileged_users_can_approve(self):
     product = self.factory.makeProduct(driver=self.factory.makePerson())
     series = self.factory.makeProductSeries(product=product)
     with celebrity_logged_in("admin"):
         series.driver = self.factory.makePerson()
     nomination = self.factory.makeBugNomination(target=series)
     self.assertTrue(nomination.canApprove(product.owner))
     self.assertTrue(nomination.canApprove(product.driver))
     self.assertTrue(nomination.canApprove(series.driver))
コード例 #19
0
 def test_bugs_answers_usage_answers(self):
     # The dict values are True for answers and either.
     with celebrity_logged_in('admin'):
         self.dsp.distribution.answers_usage = ServiceUsage.LAUNCHPAD
     view = create_view(self.dsp, '+index')
     self.assertFalse(view.bugs_answers_usage['uses_bugs'])
     self.assertTrue(view.bugs_answers_usage['uses_answers'])
     self.assertFalse(view.bugs_answers_usage['uses_both'])
     self.assertIs(True, view.bugs_answers_usage['uses_either'])
コード例 #20
0
 def test_getBranchesWithVisibleBugs_hides_private_bugs_from_anon(self):
     # getBranchesWithVisibleBugs does not show private bugs to users
     # who aren't logged in.
     branch = self.factory.makeBranch()
     bug = self.factory.makeBug(information_type=InformationType.USERDATA)
     with celebrity_logged_in('admin'):
         bug.linkBranch(branch, self.factory.makePerson())
     utility = getUtility(IBugBranchSet)
     self.assertContentEqual(
         [], utility.getBranchesWithVisibleBugs([branch], None))
コード例 #21
0
 def test_bugs_answers_usage_both(self):
     # The dict values are all True.
     with celebrity_logged_in('admin'):
         self.dsp.distribution.official_malone = True
         self.dsp.distribution.answers_usage = ServiceUsage.LAUNCHPAD
     view = create_view(self.dsp, '+index')
     self.assertTrue(view.bugs_answers_usage['uses_bugs'])
     self.assertTrue(view.bugs_answers_usage['uses_answers'])
     self.assertTrue(view.bugs_answers_usage['uses_both'])
     self.assertTrue(view.bugs_answers_usage['uses_either'])
コード例 #22
0
 def test_getBranchesWithVisibleBugs_shows_private_bugs_to_admins(self):
     # getBranchesWithVisibleBugs will show private bugs to admins.
     branch = self.factory.makeBranch()
     bug = self.factory.makeBug(information_type=InformationType.USERDATA)
     with celebrity_logged_in('admin'):
         bug.linkBranch(branch, self.factory.makePerson())
     utility = getUtility(IBugBranchSet)
     admin = getUtility(ILaunchpadCelebrities).admin
     self.assertContentEqual(
         [branch.id], utility.getBranchesWithVisibleBugs([branch], admin))
コード例 #23
0
 def test_getBranchesWithVisibleBugs_shows_public_bugs_to_anon(self):
     # getBranchesWithVisibleBugs shows public bugs to anyone,
     # including anonymous users.
     branch = self.factory.makeBranch()
     bug = self.factory.makeBug()
     with celebrity_logged_in('admin'):
         bug.linkBranch(branch, self.factory.makePerson())
     utility = getUtility(IBugBranchSet)
     self.assertContentEqual(
         [branch.id], utility.getBranchesWithVisibleBugs([branch], None))
コード例 #24
0
    def test_any_component_uploader_can_approve_for_no_package(self):
        # An uploader for any component can approve a nomination without
        # a package.
        series = self.factory.makeDistroSeries()
        with celebrity_logged_in("admin"):
            perm = series.main_archive.newComponentUploader(self.factory.makePerson(), self.factory.makeComponent())
        nomination = self.factory.makeBugNomination(target=series)

        self.assertFalse(nomination.canApprove(self.factory.makePerson()))
        self.assertTrue(nomination.canApprove(perm.person))
コード例 #25
0
 def test_links_registry_expert(self):
     # A registry expert cannot change details but can administer a project
     # group.
     with celebrity_logged_in('registry_experts'):
         user = getUtility(ILaunchBag).user
         view = create_initialized_view(
             self.project_group, '+index', principal=user)
         contents = view.render()
         self.assertThat(contents, Not(Contains("Change details")))
         self.assertThat(contents, Contains("Administer"))
コード例 #26
0
 def test_non_subscriber_with_good_standing_is_approved(self):
     # Non-subscribers with good standing are approved to post.
     with celebrity_logged_in('admin'):
         self.lp_user.personal_standing = PersonalStanding.GOOD
     message = self.makeMailmanMessage(
         self.mm_list, self.lp_user_email, 'subject', 'any content.')
     msg_data = {}
     silence = LPStanding.process(self.mm_list, message, msg_data)
     self.assertEqual(None, silence)
     self.assertTrue(msg_data['approved'])
コード例 #27
0
    def setUp(self):
        super(TestQuestionRepresentation, self).setUp()
        with celebrity_logged_in('admin'):
            self.question = self.factory.makeQuestion(
                title="This is a question")
            self.target_name = self.question.target.name

        self.webservice = LaunchpadWebServiceCaller(
            'launchpad-library', 'salgado-change-anything')
        self.webservice.default_api_version = 'devel'
コード例 #28
0
 def test_getBranchesWithVisibleBugs_ignores_extra_bugs(self):
     # getBranchesWithVisibleBugs reports a branch only once even if
     # it's liked to multiple bugs.
     branch = self.factory.makeBranch()
     user = self.factory.makePerson()
     with celebrity_logged_in('admin'):
         self.factory.makeBug().linkBranch(branch, user)
         self.factory.makeBug().linkBranch(branch, user)
     utility = getUtility(IBugBranchSet)
     self.assertContentEqual(
         [branch.id], utility.getBranchesWithVisibleBugs([branch], user))
コード例 #29
0
 def test_redirect_name_success(self):
     # The view redirects to the bug when it is found.
     bug = self.factory.makeBug()
     with celebrity_logged_in('admin'):
         bug.name = 'bingo'
     form = dict(id='bingo')
     view = create_initialized_view(
         self.application, name='+index', layer=BugsLayer, form=form)
     self.assertEqual(None, view.error_message)
     self.assertEqual(
         canonical_url(bug), view.request.response.getHeader('Location'))
コード例 #30
0
 def test_provides_commercial_subscription_expired(self):
     product = self.factory.makeProduct(name='fnord')
     self.factory.makeCommercialSubscription(product)
     import datetime
     import pytz
     then = datetime.datetime(2005, 6, 15, 0, 0, 0, 0, pytz.UTC)
     with celebrity_logged_in('admin'):
         product.commercial_subscription.date_expires = then
     self.assertEqual(
         'Commercial Subscription: Expired',
         self.getPickerEntry(product).details[1])
コード例 #31
0
 def test_getReviewableTranslationFiles_project_deactivated(self):
     # Deactive project are excluded from the list.
     from lp.testing import celebrity_logged_in
     with celebrity_logged_in('admin'):
         self.product.active = False
     self.assertEqual([], self._getReviewables())
コード例 #32
0
 def test_privateBugSubscriber(self):
     # A person subscribed to a private bug can see it.
     user = self.factory.makePerson()
     with celebrity_logged_in('admin'):
         self.bug.subscribe(user, self.owner)
     self.assertTrue(self.bug.userCanView(user))
コード例 #33
0
 def test_inactive_products_are_excluded(self):
     # Inactive products are not in the vocabulary.
     with celebrity_logged_in('registry_experts'):
         self.product.active = False
     result = self.vocabulary.search('bedbugs')
     self.assertEqual([], list(result))
コード例 #34
0
 def test_rosetta_expert_can_configure_translations(self):
     product = self.factory.makeProduct()
     with celebrity_logged_in('rosetta_experts'):
         view = create_view(product, '+translations')
         self.assertEqual(True, view.can_configure_translations())
コード例 #35
0
 def create_permission():
     with celebrity_logged_in('admin'):
         ArchivePermission(archive=self.archive,
                           person=self.factory.makePerson(),
                           component=getUtility(IComponentSet)["main"],
                           permission=ArchivePermissionType.UPLOAD)
コード例 #36
0
 def test_private(self):
     with celebrity_logged_in('commercial_admin') as person:
         ppa = person.createPPA(private=True)
     self.assertEqual(True, ppa.private)