[Launchpad-reviewers] [Merge] ~cjwatson/launchpad:go-proxy-archive-layout into launchpad:master

2022-07-12 Thread Colin Watson
Colin Watson has proposed merging ~cjwatson/launchpad:go-proxy-archive-layout 
into launchpad:master with ~cjwatson/launchpad:ci-build-upload-make-spr as a 
prerequisite.

Commit message:
Handle publishing to the Go module proxy archive layout

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/426764

This follows the description of the `GOPROXY` protocol in 
https://go.dev/ref/mod#module-proxy.  (The naming is confusing: module proxies 
seem to have a layout in their own right, rather than proxying to some kind of 
repository stored elsewhere as one might expect from the name.)

I anticipated some decisions that I expect to have to take elsewhere.  Go 
module paths are essentially the equivalent of package names for other package 
types, but they typically contain slashes, which is inconvenient for Launchpad 
source package names since they're involved in URL traversal.  Fortunately, 
they have a relatively restrictive set of valid characters, so I expect to 
mangle them into "," for source package name purposes (chosen as a character 
without too many unpleasant properties which isn't itself permitted in Go 
module paths), and I arranged to perform the corresponding demangling here.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~cjwatson/launchpad:go-proxy-archive-layout into launchpad:master.
diff --git a/lib/lp/archivepublisher/artifactory.py b/lib/lp/archivepublisher/artifactory.py
index 2ee56ab..6970f9a 100644
--- a/lib/lp/archivepublisher/artifactory.py
+++ b/lib/lp/archivepublisher/artifactory.py
@@ -59,6 +59,14 @@ def _path_for(
 "Cannot publish a Conda package with no subdir"
 )
 path = rootpath / subdir
+elif repository_format == ArchiveRepositoryFormat.GO_PROXY:
+# Go module paths contain "/" characters
+# (https://go.dev/ref/mod#go-mod-file-ident), which are awkward to
+# include in Launchpad source package names since they would need
+# special URL traversal handling.  "," is disallowed in Go module
+# paths, so we use that to mangle them into source package names.
+# Reverse this mangling for publication.
+path = rootpath / source_name.replace(",", "/") / "@v"
 else:
 raise AssertionError(
 "Unsupported repository format: %r" % repository_format
@@ -504,6 +512,12 @@ class ArtifactoryPool:
 "*.tar.bz2",
 "*.conda",
 ]
+elif repository_format == ArchiveRepositoryFormat.GO_PROXY:
+return [
+"*.info",
+"*.mod",
+"*.zip",
+]
 else:
 raise AssertionError(
 "Unknown repository format %r" % repository_format
diff --git a/lib/lp/archivepublisher/tests/test_artifactory.py b/lib/lp/archivepublisher/tests/test_artifactory.py
index 18af683..ee7799a 100644
--- a/lib/lp/archivepublisher/tests/test_artifactory.py
+++ b/lib/lp/archivepublisher/tests/test_artifactory.py
@@ -126,6 +126,17 @@ class TestArtifactoryPool(TestCase):
 pool.pathFor(None, "foo", "1.0", pub_file),
 )
 
+def test_pathFor_go_proxy_with_file(self):
+pool = self.makePool(ArchiveRepositoryFormat.GO_PROXY)
+pub_file = FakePackageReleaseFile(b"go-module", "v1.0.zip")
+self.assertEqual(
+ArtifactoryPath(
+"https://foo.example.com/artifactory/repository/;
+"launchpad.net/go-module/@v/v1.0.zip"
+),
+pool.pathFor(None, "launchpad.net,go-module", "v1.0", pub_file),
+)
+
 def test_addFile(self):
 pool = self.makePool()
 foo = ArtifactoryPoolTestingFile(
@@ -224,13 +235,24 @@ class TestArtifactoryPool(TestCase):
 pool.getArtifactPatterns(ArchiveRepositoryFormat.CONDA),
 )
 
-def test_getAllArtifacts(self):
+def test_getArtifactPatterns_go_proxy(self):
+pool = self.makePool()
+self.assertEqual(
+[
+"*.info",
+"*.mod",
+"*.zip",
+],
+pool.getArtifactPatterns(ArchiveRepositoryFormat.GO_PROXY),
+)
+
+def test_getAllArtifacts_debian(self):
 # getAllArtifacts mostly relies on constructing a correct AQL query,
 # which we can't meaningfully test without a real Artifactory
 # instance, although `FakeArtifactoryFixture` tries to do something
-# with it.  This test mainly ensures that we transform the response
+# with it.  These tests mainly ensure that we transform the response
 # correctly.
-pool = self.makePool()
+pool = self.makePool(ArchiveRepositoryFormat.DEBIAN)
 ArtifactoryPoolTestingFile(
 pool=pool,
 source_name="foo",
@@ -247,22 +269,6 @@ class 

[Launchpad-reviewers] [Merge] ~jugmac00/launchpad-buildd:process-secrets into launchpad-buildd:master

2022-07-12 Thread Jürgen Gmach
Jürgen Gmach has proposed merging ~jugmac00/launchpad-buildd:process-secrets 
into launchpad-buildd:master.

Commit message:
Pass secrets to the CI runner

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~jugmac00/launchpad-buildd/+git/launchpad-buildd/+merge/426759
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~jugmac00/launchpad-buildd:process-secrets into launchpad-buildd:master.
diff --git a/debian/changelog b/debian/changelog
index 7a37ee9..34fdff6 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -8,6 +8,9 @@ launchpad-buildd (216) UNRELEASED; urgency=medium
   * Add a timeout when revoking proxy tokens.
   * Log SHA-512 hash of built snaps (LP: #1979844).
 
+  [ Jürgen Gmach ]
+  * Pass secrets to the CI runner.
+
  -- Andrey Fedoseev   Mon, 27 Jun 2022 12:32:05 +0500
 
 launchpad-buildd (215) focal; urgency=medium
diff --git a/lpbuildd/ci.py b/lpbuildd/ci.py
index 3119a09..c420b9a 100644
--- a/lpbuildd/ci.py
+++ b/lpbuildd/ci.py
@@ -61,6 +61,7 @@ class CIBuildManager(BuildManagerProxyMixin, DebianBuildManager):
 self.apt_repositories = extra_args.get("apt_repositories")
 self.environment_variables = extra_args.get("environment_variables")
 self.plugin_settings = extra_args.get("plugin_settings")
+self.secrets = extra_args.get("secrets")
 
 super().initiate(files, chroot, extra_args)
 
@@ -149,6 +150,10 @@ class CIBuildManager(BuildManagerProxyMixin, DebianBuildManager):
 for key, value in self.plugin_settings.items():
 args.extend(
 ["--plugin-setting", f"{key}={value}"])
+if self.secrets is not None:
+for key, value in self.secrets.items():
+args.extend(
+["--secrets", f"{key}={value}"])
 job_name, job_index = self.current_job
 self.current_job_id = _make_job_id(job_name, job_index)
 args.extend([job_name, str(job_index)])
diff --git a/lpbuildd/target/run_ci.py b/lpbuildd/target/run_ci.py
index d21204a..cc67257 100644
--- a/lpbuildd/target/run_ci.py
+++ b/lpbuildd/target/run_ci.py
@@ -3,6 +3,10 @@
 
 import logging
 import os
+import tempfile
+from pathlib import Path
+
+import yaml
 
 from lpbuildd.target.build_snap import SnapChannelsAction
 from lpbuildd.target.operation import Operation
@@ -116,6 +120,11 @@ class RunCI(BuilderProxyOperationMixin, Operation):
 default=[],
 help="plugin setting where the key and value are separated by =",
 )
+parser.add_argument(
+"--secrets",
+type=Path,
+help="secrets provided in a YAML configuration file",
+)
 
 def run_job(self):
 logger.info("Running job phase...")
@@ -149,6 +158,16 @@ class RunCI(BuilderProxyOperationMixin, Operation):
 )
 for key, value in plugin_settings.items():
 lpcraft_args.extend(["--plugin-setting", f"{key}={value}"])
+if self.args.secrets:
+text = yaml.dump(self.args.secrets)
+with tempfile.NamedTemporaryFile(mode="w") as f:
+f.write(text)
+path_to_secrets = f.name
+self.backend.copy_in(
+source_path=path_to_secrets,
+target_path="/tmp/.launchpad-secrets.yaml"
+)
+lpcraft_args.extend(["--secrets", "/tmp/.launchpad-secrets.yaml"])
 
 escaped_lpcraft_args = (
 " ".join(shell_escape(arg) for arg in lpcraft_args))
diff --git a/lpbuildd/target/tests/test_run_ci.py b/lpbuildd/target/tests/test_run_ci.py
index f7c2231..1b27409 100644
--- a/lpbuildd/target/tests/test_run_ci.py
+++ b/lpbuildd/target/tests/test_run_ci.py
@@ -419,6 +419,27 @@ class TestRunCI(TestCase):
 ], cwd="/build/tree"),
 ]))
 
+def test_run_job_with_secrets(self):
+args = [
+"run-ci",
+"--backend=fake", "--series=focal", "--arch=amd64", "1",
+"--secrets", "path/to/tempfile",
+"test", "0",
+]
+run_ci = parse_args(args=args).operation
+run_ci.run_job()
+self.assertThat(run_ci.backend.run.calls, MatchesListwise([
+RanCommand(["mkdir", "-p", "/build/output/test:0"]),
+RanBuildCommand([
+"/bin/bash", "-o", "pipefail", "-c",
+"lpcraft -v run-one --output-directory /build/output/test:0 "
+"test 0 "
+"--secrets /tmp/.launchpad-secrets.yaml "
+"2>&1 "
+"| tee /build/output/test:0.log",
+], cwd="/build/tree"),
+]))
+
 def test_run_succeeds(self):
 args = [
 "run-ci",
diff --git a/lpbuildd/tests/test_ci.py b/lpbuildd/tests/test_ci.py
index 1582b92..4e17860 100644
--- a/lpbuildd/tests/test_ci.py
+++ 

[Launchpad-reviewers] [Merge] ~jugmac00/launchpad-buildd:process-secrets into launchpad-buildd:master

2022-07-12 Thread Jürgen Gmach
The proposal to merge ~jugmac00/launchpad-buildd:process-secrets into 
launchpad-buildd:master has been updated.

Status: Needs review => Work in progress

For more details, see:
https://code.launchpad.net/~jugmac00/launchpad-buildd/+git/launchpad-buildd/+merge/426759
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~jugmac00/launchpad-buildd:process-secrets into launchpad-buildd:master.


___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~jugmac00/launchpad-buildd:process-secrets into launchpad-buildd:master

2022-07-12 Thread Jürgen Gmach
Jürgen Gmach has proposed merging ~jugmac00/launchpad-buildd:process-secrets 
into launchpad-buildd:master.

Commit message:
Pass secrets to the CI runner

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~jugmac00/launchpad-buildd/+git/launchpad-buildd/+merge/426759
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~jugmac00/launchpad-buildd:process-secrets into launchpad-buildd:master.
diff --git a/debian/changelog b/debian/changelog
index 7a37ee9..34fdff6 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -8,6 +8,9 @@ launchpad-buildd (216) UNRELEASED; urgency=medium
   * Add a timeout when revoking proxy tokens.
   * Log SHA-512 hash of built snaps (LP: #1979844).
 
+  [ Jürgen Gmach ]
+  * Pass secrets to the CI runner.
+
  -- Andrey Fedoseev   Mon, 27 Jun 2022 12:32:05 +0500
 
 launchpad-buildd (215) focal; urgency=medium
diff --git a/lpbuildd/ci.py b/lpbuildd/ci.py
index 3119a09..c420b9a 100644
--- a/lpbuildd/ci.py
+++ b/lpbuildd/ci.py
@@ -61,6 +61,7 @@ class CIBuildManager(BuildManagerProxyMixin, DebianBuildManager):
 self.apt_repositories = extra_args.get("apt_repositories")
 self.environment_variables = extra_args.get("environment_variables")
 self.plugin_settings = extra_args.get("plugin_settings")
+self.secrets = extra_args.get("secrets")
 
 super().initiate(files, chroot, extra_args)
 
@@ -149,6 +150,10 @@ class CIBuildManager(BuildManagerProxyMixin, DebianBuildManager):
 for key, value in self.plugin_settings.items():
 args.extend(
 ["--plugin-setting", f"{key}={value}"])
+if self.secrets is not None:
+for key, value in self.secrets.items():
+args.extend(
+["--secrets", f"{key}={value}"])
 job_name, job_index = self.current_job
 self.current_job_id = _make_job_id(job_name, job_index)
 args.extend([job_name, str(job_index)])
diff --git a/lpbuildd/target/run_ci.py b/lpbuildd/target/run_ci.py
index d21204a..49d0e63 100644
--- a/lpbuildd/target/run_ci.py
+++ b/lpbuildd/target/run_ci.py
@@ -3,6 +3,10 @@
 
 import logging
 import os
+import tempfile
+from pathlib import Path
+
+import yaml
 
 from lpbuildd.target.build_snap import SnapChannelsAction
 from lpbuildd.target.operation import Operation
@@ -116,6 +120,11 @@ class RunCI(BuilderProxyOperationMixin, Operation):
 default=[],
 help="plugin setting where the key and value are separated by =",
 )
+parser.add_argument(
+"--secrets",
+type=Path,
+help="secrets provided in a YAML configuration file",
+)
 
 def run_job(self):
 logger.info("Running job phase...")
@@ -149,6 +158,14 @@ class RunCI(BuilderProxyOperationMixin, Operation):
 )
 for key, value in plugin_settings.items():
 lpcraft_args.extend(["--plugin-setting", f"{key}={value}"])
+if self.args.secrets:
+text = yaml.dump(self.args.secrets)
+with tempfile.NamedTemporaryFile(mode="w", delete=False) as f:
+f.write(text)
+path_to_secrets = f.name
+self.backend.copy_in(
+path_to_secrets, "/tmp/.launchpad-secrets.yaml")
+lpcraft_args.extend(["--secrets", "/tmp/.launchpad-secrets.yaml"])
 
 escaped_lpcraft_args = (
 " ".join(shell_escape(arg) for arg in lpcraft_args))
diff --git a/lpbuildd/target/tests/test_run_ci.py b/lpbuildd/target/tests/test_run_ci.py
index f7c2231..1b27409 100644
--- a/lpbuildd/target/tests/test_run_ci.py
+++ b/lpbuildd/target/tests/test_run_ci.py
@@ -419,6 +419,27 @@ class TestRunCI(TestCase):
 ], cwd="/build/tree"),
 ]))
 
+def test_run_job_with_secrets(self):
+args = [
+"run-ci",
+"--backend=fake", "--series=focal", "--arch=amd64", "1",
+"--secrets", "path/to/tempfile",
+"test", "0",
+]
+run_ci = parse_args(args=args).operation
+run_ci.run_job()
+self.assertThat(run_ci.backend.run.calls, MatchesListwise([
+RanCommand(["mkdir", "-p", "/build/output/test:0"]),
+RanBuildCommand([
+"/bin/bash", "-o", "pipefail", "-c",
+"lpcraft -v run-one --output-directory /build/output/test:0 "
+"test 0 "
+"--secrets /tmp/.launchpad-secrets.yaml "
+"2>&1 "
+"| tee /build/output/test:0.log",
+], cwd="/build/tree"),
+]))
+
 def test_run_succeeds(self):
 args = [
 "run-ci",
diff --git a/lpbuildd/tests/test_ci.py b/lpbuildd/tests/test_ci.py
index 1582b92..4e17860 100644
--- a/lpbuildd/tests/test_ci.py
+++ b/lpbuildd/tests/test_ci.py
@@ -257,6 +257,9 @@ class 

[Launchpad-reviewers] [Merge] ~lgp171188/launchpad:split-security.py-final-bits into launchpad:master

2022-07-12 Thread Guruprasad
Guruprasad has proposed merging 
~lgp171188/launchpad:split-security.py-final-bits into launchpad:master.

Commit message:
Split and move all the remaining package-specific security adapters in 
lp.security

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~lgp171188/launchpad/+git/launchpad/+merge/426704
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~lgp171188/launchpad:split-security.py-final-bits into launchpad:master.
diff --git a/doc/how-to/security.rst b/doc/how-to/security.rst
index 19ff373..35bdb89 100644
--- a/doc/how-to/security.rst
+++ b/doc/how-to/security.rst
@@ -40,7 +40,8 @@ interface.
 In Launchpad, an authorization policy is expressed through a security adapter.
 To define a security adapter for a given permission on an interface:
 
-1. Define the adapter in ``lib/lp/security.py``. Here's a simple example of
+1. Define the adapter in the corresponding package's `security.py`. Create
+   the file, if it doesn't exist already. Here's a simple example of
an adapter that authorizes only an object owner for the
``launchpad.Edit`` permission on objects that implement the ``IHasOwner``
interface:
@@ -111,3 +112,11 @@ Note that "accessed" means ``getattr()``, while "modified" means
 ``setattr()``.  The process of calling a method starts by using ``getattr()``
 to fetch the method from the object, so methods should be declared in
 ``interface`` or ``attributes`` even if they modify the object.
+
+3. Ensure that there is an  directive in the package's
+   top-level ``configure.zcml` file that specifies the package's security
+   module. If it isn't there already, add one like:
+
+.. code-block:: xml
+
+
diff --git a/lib/lp/answers/security.py b/lib/lp/answers/security.py
index 8332000..c10cc67 100644
--- a/lib/lp/answers/security.py
+++ b/lib/lp/answers/security.py
@@ -15,7 +15,7 @@ from lp.app.security import AnonymousAuthorization, AuthorizationBase
 from lp.registry.interfaces.distributionsourcepackage import (
 IDistributionSourcePackage,
 )
-from lp.security import EditByOwnersOrAdmins
+from lp.registry.security import EditByOwnersOrAdmins
 
 
 class AdminQuestion(AuthorizationBase):
diff --git a/lib/lp/archivepublisher/configure.zcml b/lib/lp/archivepublisher/configure.zcml
index f52d4ff..2ea8a71 100644
--- a/lib/lp/archivepublisher/configure.zcml
+++ b/lib/lp/archivepublisher/configure.zcml
@@ -10,6 +10,7 @@
 xmlns:xmlrpc="http://namespaces.zope.org/xmlrpc;
 i18n_domain="launchpad">
 
+
 
 
 
diff --git a/lib/lp/archivepublisher/security.py b/lib/lp/archivepublisher/security.py
new file mode 100644
index 000..b5be6c1
--- /dev/null
+++ b/lib/lp/archivepublisher/security.py
@@ -0,0 +1,13 @@
+# Copyright 2009-2022 Canonical Ltd.  This software is licensed under the
+# GNU Affero General Public License version 3 (see the file LICENSE).
+
+"""Security adapters for the archivepublisher package."""
+
+__all__ = []
+
+from lp.archivepublisher.interfaces.publisherconfig import IPublisherConfig
+from lp.security import AdminByAdminsTeam
+
+
+class ViewPublisherConfig(AdminByAdminsTeam):
+usedfor = IPublisherConfig
diff --git a/lib/lp/blueprints/security.py b/lib/lp/blueprints/security.py
index b4d8da2..c090dbf 100644
--- a/lib/lp/blueprints/security.py
+++ b/lib/lp/blueprints/security.py
@@ -17,7 +17,8 @@ from lp.blueprints.interfaces.specificationsubscription import (
 )
 from lp.blueprints.interfaces.sprint import ISprint
 from lp.blueprints.interfaces.sprintspecification import ISprintSpecification
-from lp.security import EditByOwnersOrAdmins, ModerateByRegistryExpertsOrAdmins
+from lp.registry.security import EditByOwnersOrAdmins
+from lp.security import ModerateByRegistryExpertsOrAdmins
 
 
 class EditSpecificationBranch(AuthorizationBase):
diff --git a/lib/lp/bugs/security.py b/lib/lp/bugs/security.py
index 0d60eaf..06675de 100644
--- a/lib/lp/bugs/security.py
+++ b/lib/lp/bugs/security.py
@@ -18,6 +18,7 @@ from lp.bugs.interfaces.bugnomination import IBugNomination
 from lp.bugs.interfaces.bugsubscription import IBugSubscription
 from lp.bugs.interfaces.bugsubscriptionfilter import IBugSubscriptionFilter
 from lp.bugs.interfaces.bugsupervisor import IHasBugSupervisor
+from lp.bugs.interfaces.bugtarget import IOfficialBugTagTargetRestricted
 from lp.bugs.interfaces.bugtask import IBugTaskDelete
 from lp.bugs.interfaces.bugtracker import IBugTracker
 from lp.bugs.interfaces.bugwatch import IBugWatch
@@ -383,14 +384,25 @@ class AdminBugWatch(AuthorizationBase):
 
 
 class EditStructuralSubscription(AuthorizationBase):
-"""Edit permissions for `IStructuralSubscription`."""
-
 permission = "launchpad.Edit"
 usedfor = IStructuralSubscription
 
 def checkAuthenticated(self, user):
-"""Subscribers can edit their own structural subscriptions."""
-return user.inTeam(self.obj.subscriber)
+"""Who can 

Re: [Launchpad-reviewers] [Merge] ~cjwatson/launchpad-mojo-specs/+git/private:vbuilder-config-drive into ~launchpad/launchpad-mojo-specs/+git/private:vbuilder

2022-07-12 Thread William Grant
Review: Approve


-- 
https://code.launchpad.net/~cjwatson/launchpad-mojo-specs/+git/private/+merge/426647
Your team Launchpad code reviewers is subscribed to branch 
~launchpad/launchpad-mojo-specs/+git/private:vbuilder.


___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~andrey-fedoseev/launchpad:remove-launchpad-object-factory into launchpad:master

2022-07-12 Thread Andrey Fedoseev
Andrey Fedoseev has proposed merging 
~andrey-fedoseev/launchpad:remove-launchpad-object-factory into 
launchpad:master.

Commit message:
Remove `LaunchpadObjectFactory` wrapper


Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~andrey-fedoseev/launchpad/+git/launchpad/+merge/426693

This wrapper is supposed to be used to produce warning message
whenever a factory method creates an object which isn't wrapped
in security proxy. However, this is enabled only when
LP_PROXY_WARNINGS=1 is set, and no one seems to be using it.

The wrapper implementation hides the list of available methods
of the underlying factory class which prevents code analysis,
so we decided to remove the wrapper.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~andrey-fedoseev/launchpad:remove-launchpad-object-factory into 
launchpad:master.
diff --git a/lib/lp/testing/factory.py b/lib/lp/testing/factory.py
index 61c3b2d..b6e7442 100644
--- a/lib/lp/testing/factory.py
+++ b/lib/lp/testing/factory.py
@@ -535,7 +535,7 @@ class ObjectFactory(metaclass=AutoDecorate(default_master_store)):
 return epoch + timedelta(minutes=self.getUniqueInteger())
 
 
-class BareLaunchpadObjectFactory(ObjectFactory):
+class LaunchpadObjectFactory(ObjectFactory):
 """Factory methods for creating Launchpad objects.
 
 All the factory methods should be callable with no parameters.
@@ -5521,15 +5521,6 @@ def is_security_proxied_or_harmless(obj):
 return False
 
 
-class UnproxiedFactoryMethodWarning(UserWarning):
-"""Raised when someone calls an unproxied factory method."""
-
-def __init__(self, method_name):
-super().__init__(
-"PLEASE FIX: LaunchpadObjectFactory.%s returns an "
-"unproxied object." % (method_name, ))
-
-
 class ShouldThisBeUsingRemoveSecurityProxy(UserWarning):
 """Raised when there is a potentially bad call to removeSecurityProxy."""
 
@@ -5540,42 +5531,6 @@ class ShouldThisBeUsingRemoveSecurityProxy(UserWarning):
 super().__init__(message)
 
 
-class LaunchpadObjectFactory:
-"""A wrapper around `BareLaunchpadObjectFactory`.
-
-Ensure that each object created by a `BareLaunchpadObjectFactory` method
-is either of a simple Python type or is security proxied.
-
-A warning message is printed to stderr if a factory method creates
-an object without a security proxy.
-
-Whereever you see such a warning: fix it!
-"""
-
-def __init__(self):
-self._factory = BareLaunchpadObjectFactory()
-
-def __getattr__(self, name):
-attr = getattr(self._factory, name)
-if os.environ.get('LP_PROXY_WARNINGS') == '1' and callable(attr):
-
-def guarded_method(*args, **kw):
-result = attr(*args, **kw)
-if not is_security_proxied_or_harmless(result):
-warnings.warn(
-UnproxiedFactoryMethodWarning(name), stacklevel=1)
-return result
-return guarded_method
-else:
-return attr
-
-def __dir__(self):
-"""Enumerate the attributes and methods of the wrapped object factory.
-
-This is especially useful for interactive users."""
-return dir(self._factory)
-
-
 def remove_security_proxy_and_shout_at_engineer(obj):
 """Remove an object's security proxy and print a warning.
 
diff --git a/lib/lp/testing/tests/test_factory.py b/lib/lp/testing/tests/test_factory.py
index 4953455..1256e7b 100644
--- a/lib/lp/testing/tests/test_factory.py
+++ b/lib/lp/testing/tests/test_factory.py
@@ -644,14 +644,6 @@ class TestFactory(TestCaseWithFactory):
 sequence='2000-1234', cvestate=CveStatus.DEPRECATED)
 self.assertEqual(CveStatus.DEPRECATED, cve.status)
 
-# dir() support.
-def test_dir(self):
-# LaunchpadObjectFactory supports dir() even though all of its
-# attributes are pseudo-attributes.
-self.assertEqual(
-dir(self.factory._factory),
-dir(self.factory))
-
 def test_getUniqueString_with_prefix(self):
 s = self.factory.getUniqueString("with-my-prefix")
 self.assertTrue(s.startswith("with-my-prefix"))
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp