launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #24327
[Merge] ~pappacena/launchpad:remove-auditor into launchpad:master
Thiago F. Pappacena has proposed merging ~pappacena/launchpad:remove-auditor into launchpad:master.
Commit message:
Removing auditor
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~pappacena/launchpad/+git/launchpad/+merge/379021
Auditor client (and mock test server) are not in use, and we solved the audit problem on package upload with a database table keeping track of the history of the package upload.
Related MP: https://code.launchpad.net/~pappacena/lp-source-dependencies/+git/lp-source-dependencies/+merge/379020
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~pappacena/launchpad:remove-auditor into launchpad:master.
diff --git a/constraints.txt b/constraints.txt
index a47ebfd..0fe4f7f 100644
--- a/constraints.txt
+++ b/constraints.txt
@@ -162,9 +162,6 @@ anyjson==0.3.3
appdirs==1.4.3
asn1crypto==0.23.0
attrs==19.1.0
-auditor==0.0.3
-auditorclient==0.0.4
-auditorfixture==0.0.7
Automat==0.6.0
Babel==2.5.1
backports.functools-lru-cache==1.5
diff --git a/lib/lp/services/auditor/__init__.py b/lib/lp/services/auditor/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/lib/lp/services/auditor/__init__.py
+++ /dev/null
diff --git a/lib/lp/services/auditor/client.py b/lib/lp/services/auditor/client.py
deleted file mode 100644
index 3e2189f..0000000
--- a/lib/lp/services/auditor/client.py
+++ /dev/null
@@ -1,70 +0,0 @@
-# Copyright 2012-2013 Canonical Ltd. This software is licensed under the
-# GNU Affero General Public License version 3 (see the file LICENSE).
-
-"""Client that will send and receive audit logs to an auditor instance."""
-
-__metaclass__ = type
-__all__ = [
- 'AuditorClient',
- ]
-
-from auditorclient.client import Client
-from lazr.restful.utils import get_current_browser_request
-
-from lp.services.config import config
-from lp.services.enterpriseid import (
- enterpriseids_to_objects,
- object_to_enterpriseid,
- )
-from lp.services.timeline.requesttimeline import get_request_timeline
-
-
-class AuditorClient(Client):
-
- def __init__(self):
- super(AuditorClient, self).__init__(
- config.auditor.host, config.auditor.port)
-
- def __get_timeline_action(self, suffix, obj, operation, actorobj):
- data = "Object: %s; Operation: %s, Actor: %s" % (
- obj, operation, actorobj)
- timeline = get_request_timeline(get_current_browser_request())
- return timeline.start("auditor-%s" % suffix, data)
-
- def send(self, obj, operation, actorobj, comment=None, details=None):
- obj = object_to_enterpriseid(obj)
- actorobj = object_to_enterpriseid(actorobj)
- action = self.__get_timeline_action("send", obj, operation, actorobj)
- try:
- return super(AuditorClient, self).send(
- obj, operation, actorobj, comment, details)
- finally:
- action.finish()
-
- def _convert_to_enterpriseid(self, obj):
- if isinstance(obj, (list, tuple)):
- return [object_to_enterpriseid(o) for o in obj]
- else:
- return object_to_enterpriseid(obj)
-
- def receive(self, obj=None, operation=None, actorobj=None, limit=None):
- if obj:
- obj = self._convert_to_enterpriseid(obj)
- if actorobj:
- actorobj = self._convert_to_enterpriseid(actorobj)
- action = self.__get_timeline_action(
- "receive", obj, operation, actorobj)
- try:
- logs = super(AuditorClient, self).receive(
- obj, operation, actorobj, limit)
- finally:
- action.finish()
- # Process the actors and objects back from enterprise ids.
- eids = set()
- for entry in logs['log-entries']:
- eids |= set([entry['actor'], entry['object']])
- map_eids_to_obj = enterpriseids_to_objects(eids)
- for entry in logs['log-entries']:
- entry['actor'] = map_eids_to_obj.get(entry['actor'], None)
- entry['object'] = map_eids_to_obj.get(entry['object'], None)
- return logs['log-entries']
diff --git a/lib/lp/services/auditor/server.py b/lib/lp/services/auditor/server.py
deleted file mode 100644
index 205c68b..0000000
--- a/lib/lp/services/auditor/server.py
+++ /dev/null
@@ -1,27 +0,0 @@
-# Copyright 2012 Canonical Ltd. This software is licensed under the
-# GNU Affero General Public License version 3 (see the file LICENSE).
-
-"""Auditor server fixture."""
-
-__metaclass__ = type
-__all__ = [
- 'AuditorServer',
- ]
-
-from textwrap import dedent
-
-from auditorfixture.server import AuditorFixture
-
-
-class AuditorServer(AuditorFixture):
- """An Auditor server fixture with Launchpad-specific config.
-
- :ivar service_config: A snippet of .ini that describes the `auditor`
- configuration.
- """
-
- def setUp(self):
- super(AuditorServer, self).setUp()
- self.service_config = dedent("""\
- [auditor]
- port: %d""" % (self.config.port))
diff --git a/lib/lp/services/auditor/tests/__init__.py b/lib/lp/services/auditor/tests/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/lib/lp/services/auditor/tests/__init__.py
+++ /dev/null
diff --git a/lib/lp/services/auditor/tests/test_client.py b/lib/lp/services/auditor/tests/test_client.py
deleted file mode 100644
index 0248fa5..0000000
--- a/lib/lp/services/auditor/tests/test_client.py
+++ /dev/null
@@ -1,63 +0,0 @@
-# Copyright 2012-2013 Canonical Ltd. This software is licensed under the
-# GNU Affero General Public License version 3 (see the file LICENSE).
-
-__metaclass__ = type
-
-from lazr.restful.utils import get_current_browser_request
-
-from lp.services.auditor.client import AuditorClient
-from lp.services.enterpriseid import object_to_enterpriseid
-from lp.services.timeline.requesttimeline import get_request_timeline
-from lp.testing import TestCaseWithFactory
-from lp.testing.layers import AuditorLayer
-
-
-class TestAuditorClient(TestCaseWithFactory):
-
- layer = AuditorLayer
-
- def assertAction(self, category, data):
- timeline = get_request_timeline(get_current_browser_request())
- action = timeline.actions[-1]
- self.assertEqual(category, action.category)
- self.assertEqual(data, action.detail)
-
- def test_send_and_receive(self):
- # We can use .send() and .receive() on AuditorClient to log.
- actor = self.factory.makePerson()
- pu = self.factory.makePackageUpload()
- client = AuditorClient()
- result = client.send(pu, 'packageupload-accepted', actor)
- self.assertEqual('Operation recorded.', result)
- data = "Object: %s; Operation: packageupload-accepted, Actor: %s" % (
- object_to_enterpriseid(pu), object_to_enterpriseid(actor))
- self.assertAction('auditor-send', data)
- result = client.receive(obj=pu)
- del result[0]['date'] # Ignore the date.
- expected = [{
- u'comment': u'', u'details': u'', u'actor': actor,
- u'operation': u'packageupload-accepted', u'object': pu}]
- self.assertContentEqual(expected, result)
- self.assertAction(
- 'auditor-receive', "Object: %s; Operation: None, Actor: None" % (
- object_to_enterpriseid(pu)))
-
- def test_multiple_receive(self):
- # We can ask AuditorClient for a number of operations.
- actor = self.factory.makePerson()
- actor2 = self.factory.makePerson()
- client = AuditorClient()
- client.send(actor, 'person-deleted', actor)
- client.send(actor2, 'person-undeleted', actor)
- result = client.receive(
- obj=(actor, actor2),
- operation=('person-deleted', 'person-undeleted'))
- self.assertEqual(2, len(result))
- for r in result:
- del r['date'] # Ignore the date.
- expected = [
- {u'comment': u'', u'details': u'', u'actor': actor,
- u'operation': u'person-deleted', u'object': actor},
- {u'comment': u'', u'details': u'', u'actor': actor,
- u'operation': u'person-undeleted', u'object': actor2}]
- self.assertContentEqual(expected, result)
diff --git a/lib/lp/services/auditor/tests/test_server.py b/lib/lp/services/auditor/tests/test_server.py
deleted file mode 100644
index 217b41a..0000000
--- a/lib/lp/services/auditor/tests/test_server.py
+++ /dev/null
@@ -1,28 +0,0 @@
-# Copyright 2012 Canonical Ltd. This software is licensed under the
-# GNU Affero General Public License version 3 (see the file LICENSE).
-
-"""Tests for lp.services.auditor.AuditorServer."""
-
-__metaclass__ = type
-
-from ConfigParser import SafeConfigParser
-from StringIO import StringIO
-
-from lp.services.auditor.server import AuditorServer
-from lp.testing import TestCase
-from lp.testing.layers import BaseLayer
-
-
-class TestAuditorServer(TestCase):
-
- layer = BaseLayer
-
- def test_service_config(self):
- # AuditorServer pokes some .ini configuration into its config.
- fixture = self.useFixture(AuditorServer())
- service_config = SafeConfigParser()
- service_config.readfp(StringIO(fixture.service_config))
- self.assertEqual(["auditor"], service_config.sections())
- expected = {"port": "%d" % fixture.config.port}
- observed = dict(service_config.items("auditor"))
- self.assertEqual(expected, observed)
diff --git a/lib/lp/services/config/schema-lazr.conf b/lib/lp/services/config/schema-lazr.conf
index d8c1204..ada0c9d 100644
--- a/lib/lp/services/config/schema-lazr.conf
+++ b/lib/lp/services/config/schema-lazr.conf
@@ -33,11 +33,6 @@ dbuser: archivepublisher
run_parts_location: none
-[auditor]
-host: localhost
-port: none
-
-
[binaryfile_expire]
dbuser: binaryfile-expire
diff --git a/lib/lp/services/features/flags.py b/lib/lp/services/features/flags.py
index e366a94..9fdb4a0 100644
--- a/lib/lp/services/features/flags.py
+++ b/lib/lp/services/features/flags.py
@@ -191,12 +191,6 @@ flag_info = sorted([
'',
'',
''),
- ('auditor.enabled',
- 'boolean',
- 'If true, send audit data to an auditor instance.',
- '',
- '',
- ''),
('app.root_blog.enabled',
'boolean',
'If true, load posts from the Launchpad blog to show on the root page.',
diff --git a/lib/lp/soyuz/model/queue.py b/lib/lp/soyuz/model/queue.py
index 91e92cd..82e02a9 100644
--- a/lib/lp/soyuz/model/queue.py
+++ b/lib/lp/soyuz/model/queue.py
@@ -47,7 +47,6 @@ from lp.registry.interfaces.gpg import IGPGKeySet
from lp.registry.interfaces.person import IPersonSet
from lp.registry.interfaces.pocket import PackagePublishingPocket
from lp.registry.model.sourcepackagename import SourcePackageName
-from lp.services.auditor.client import AuditorClient
from lp.services.database.bulk import (
load_referencing,
load_related,
@@ -610,9 +609,6 @@ class PackageUpload(SQLBase):
self._acceptNonSyncFromQueue()
else:
self._acceptSyncFromQueue()
- if bool(getFeatureFlag('auditor.enabled')):
- client = AuditorClient()
- client.send(self, 'packageupload-accepted', user)
def rejectFromQueue(self, user, comment=None):
"""See `IPackageUpload`."""
@@ -637,9 +633,6 @@ class PackageUpload(SQLBase):
getUtility(IPackageUploadNotificationJobSource).create(
self, summary_text=summary_text)
self.syncUpdate()
- if bool(getFeatureFlag('auditor.enabled')):
- client = AuditorClient()
- client.send(self, 'packageupload-rejected', user)
def _isSingleSourceUpload(self):
"""Return True if this upload contains only a single source."""
diff --git a/lib/lp/testing/layers.py b/lib/lp/testing/layers.py
index 65fb63e..8a1afd3 100644
--- a/lib/lp/testing/layers.py
+++ b/lib/lp/testing/layers.py
@@ -23,7 +23,6 @@ from __future__ import absolute_import, print_function
__metaclass__ = type
__all__ = [
'AppServerLayer',
- 'AuditorLayer',
'BaseLayer',
'BingLaunchpadFunctionalLayer',
'BingServiceLayer',
@@ -109,7 +108,6 @@ import zope.testbrowser.wsgi
from zope.testbrowser.wsgi import AuthorizationMiddleware
from lp.services import pidfile
-from lp.services.auditor.server import AuditorServer
from lp.services.config import (
config,
dbconfig,
@@ -1423,42 +1421,6 @@ class LaunchpadFunctionalLayer(LaunchpadLayer, FunctionalLayer):
disconnect_stores()
-class AuditorLayer(LaunchpadFunctionalLayer):
-
- auditor = AuditorServer()
-
- _is_setup = False
-
- @classmethod
- @profiled
- def setUp(cls):
- cls.auditor.setUp()
- cls.config_fixture.add_section(cls.auditor.service_config)
- cls.appserver_config_fixture.add_section(cls.auditor.service_config)
- cls._is_setup = True
-
- @classmethod
- @profiled
- def tearDown(cls):
- if not cls._is_setup:
- return
- cls.auditor.cleanUp()
- cls._is_setup = False
- # Can't pop the config above, so bail here and let the test runner
- # start a sub-process.
- raise NotImplementedError
-
- @classmethod
- @profiled
- def testSetUp(cls):
- pass
-
- @classmethod
- @profiled
- def testTearDown(cls):
- pass
-
-
class BingLaunchpadFunctionalLayer(LaunchpadFunctionalLayer,
BingServiceLayer):
"""Provides Bing service in addition to LaunchpadFunctionalLayer."""
diff --git a/setup.py b/setup.py
index e149110..ef792da 100644
--- a/setup.py
+++ b/setup.py
@@ -144,8 +144,6 @@ setup(
# used in zcml.
install_requires=[
'ampoule',
- 'auditorclient',
- 'auditorfixture',
'backports.lzma; python_version < "3.3"',
'beautifulsoup4[lxml]',
'breezy',