← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~cjwatson/launchpad/codeimport-git-namespace-macaroons into lp:launchpad

 

Colin Watson has proposed merging lp:~cjwatson/launchpad/codeimport-git-namespace-macaroons into lp:launchpad.

Commit message:
Namespace the code-import-job macaroon caveat to avoid potential future conflicts.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/codeimport-git-namespace-macaroons/+merge/308902
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/codeimport-git-namespace-macaroons into lp:launchpad.
=== modified file 'lib/lp/code/model/codeimportjob.py'
--- lib/lp/code/model/codeimportjob.py	2016-10-12 12:30:13 +0000
+++ lib/lp/code/model/codeimportjob.py	2016-10-20 09:59:22 +0000
@@ -31,9 +31,7 @@
     CodeImportMachineState,
     CodeImportResultStatus,
     CodeImportReviewStatus,
-    GitRepositoryType,
     )
-from lp.code.interfaces.codeimport import ICodeImportSet
 from lp.code.interfaces.codeimportevent import ICodeImportEventSet
 from lp.code.interfaces.codeimportjob import (
     ICodeImportJob,
@@ -43,7 +41,6 @@
     )
 from lp.code.interfaces.codeimportmachine import ICodeImportMachineSet
 from lp.code.interfaces.codeimportresult import ICodeImportResultSet
-from lp.code.interfaces.gitrepository import IGitRepository
 from lp.code.model.codeimportresult import CodeImportResult
 from lp.registry.interfaces.person import validate_public_person
 from lp.services.config import config
@@ -367,7 +364,7 @@
         macaroon = Macaroon(
             location=config.vhost.mainsite.hostname,
             identifier="code-import-job", key=self._root_secret)
-        macaroon.add_first_party_caveat("code-import-job %s" % context.id)
+        macaroon.add_first_party_caveat("lp.code-import-job %s" % context.id)
         return macaroon
 
     def checkMacaroonIssuer(self, macaroon):
@@ -377,7 +374,7 @@
         try:
             verifier = Verifier()
             verifier.satisfy_general(
-                lambda caveat: caveat.startswith("code-import-job "))
+                lambda caveat: caveat.startswith("lp.code-import-job "))
             return verifier.verify(macaroon, self._root_secret)
         except Exception:
             return False
@@ -388,7 +385,7 @@
             return False
         try:
             verifier = Verifier()
-            verifier.satisfy_exact("code-import-job %s" % context.id)
+            verifier.satisfy_exact("lp.code-import-job %s" % context.id)
             return (
                 verifier.verify(macaroon, self._root_secret) and
                 context.state == CodeImportJobState.RUNNING)

=== modified file 'lib/lp/code/model/tests/test_codeimportjob.py'
--- lib/lp/code/model/tests/test_codeimportjob.py	2016-10-12 12:52:41 +0000
+++ lib/lp/code/model/tests/test_codeimportjob.py	2016-10-20 09:59:22 +0000
@@ -1182,7 +1182,7 @@
         self.assertEqual("code-import-job", macaroon.identifier)
         self.assertThat(macaroon.caveats, MatchesListwise([
             MatchesStructure.byEquality(
-                caveat_id="code-import-job %s" % job.id),
+                caveat_id="lp.code-import-job %s" % job.id),
             ]))
 
     def test_checkMacaroonIssuer_good(self):


Follow ups