launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #20732
Re: [Merge] lp:~maxiberta/launchpad/named-auth-tokens into lp:launchpad
Will fix asap. Thanks!
Diff comments:
>
> === modified file 'lib/lp/soyuz/model/archive.py'
> --- lib/lp/soyuz/model/archive.py 2016-03-14 23:42:45 +0000
> +++ lib/lp/soyuz/model/archive.py 2016-07-07 14:30:49 +0000
> @@ -1948,6 +1950,53 @@
> IStore(ArchiveAuthToken).add(archive_auth_token)
> return archive_auth_token
>
> + def newNamedAuthToken(self, name, token=None, date_created=None):
Agreed, I'm adding the feature flag asap.
> + """See `IArchive`."""
> +
> + # Bail if the archive isn't private
> + if not self.private:
> + raise ArchiveNotPrivate("Archive must be private.")
> +
> + if self.getNamedAuthToken(name) is not None:
> + raise DuplicateTokenName(
> + "An active token with name %s for archive %s alread exists." %
> + (name, self.displayname))
> +
> + # Now onto the actual token creation:
> + if token is None:
> + token = create_token(20)
> + archive_auth_token = ArchiveAuthToken()
> + archive_auth_token.archive = self
> + archive_auth_token.name = name
> + archive_auth_token.token = token
> + if date_created is not None:
> + archive_auth_token.date_created = date_created
> + IStore(ArchiveAuthToken).add(archive_auth_token)
> + return archive_auth_token.as_dict()
> +
> + def getNamedAuthToken(self, name):
> + """See `IArchive`."""
> + token_set = getUtility(IArchiveAuthTokenSet)
> + archive_auth_token = token_set.getActiveNamedTokenForArchive(self, name)
> + if archive_auth_token is not None:
> + return archive_auth_token.as_dict()
> +
> + def getNamedAuthTokens(self):
> + """See `IArchive`."""
> + token_set = getUtility(IArchiveAuthTokenSet)
> + archive_auth_tokens = token_set.getActiveNamedTokensForArchive(self)
> + return [archive_auth_token.as_dict()
> + for archive_auth_token in archive_auth_tokens]
> +
> + def revokeNamedAuthToken(self, name):
> + """See `IArchive`."""
> + token_set = getUtility(IArchiveAuthTokenSet)
> + archive_auth_token = token_set.getActiveNamedTokenForArchive(self, name)
> + if archive_auth_token is not None:
> + archive_auth_token.deactivate()
> + else:
> + raise NotFoundError(name)
> +
> def newSubscription(self, subscriber, registrant, date_expires=None,
> description=None):
> """See `IArchive`."""
>
> === modified file 'lib/lp/soyuz/model/archiveauthtoken.py'
> --- lib/lp/soyuz/model/archiveauthtoken.py 2015-10-21 09:37:08 +0000
> +++ lib/lp/soyuz/model/archiveauthtoken.py 2016-07-07 14:30:49 +0000
> @@ -88,8 +93,18 @@
> def getActiveTokenForArchiveAndPerson(self, archive, person):
> """See `IArchiveAuthTokenSet`."""
> store = Store.of(archive)
Yep, forgot to run lint, sorry.
> - return store.find(
> - ArchiveAuthToken,
> - ArchiveAuthToken.archive == archive,
> - ArchiveAuthToken.person == person,
> - ArchiveAuthToken.date_deactivated == None).one()
> + return self.getByArchive(archive).find(
> + ArchiveAuthToken.person == person).one()
> +
> + def getActiveNamedTokenForArchive(self, archive, name):
> + """See `IArchiveAuthTokenSet`."""
> + store = Store.of(archive)
> + return self.getByArchive(archive).find(
> + ArchiveAuthToken.name == name).one()
> +
> + def getActiveNamedTokensForArchive(self, archive):
> + """See `IArchiveAuthTokenSet`."""
> + store = Store.of(archive)
> + return self.getByArchive(archive).find(
> + ArchiveAuthToken.name != None)
> +
>
> === modified file 'lib/lp/testing/__init__.py'
> --- lib/lp/testing/__init__.py 2015-11-08 01:05:24 +0000
> +++ lib/lp/testing/__init__.py 2016-07-07 14:30:49 +0000
> @@ -619,7 +619,7 @@
> self.assertIsNot(
> None, pattern.search(normalise_whitespace(text)), text)
>
> - def assertIsInstance(self, instance, assert_class):
> + def assertIsInstance(self, instance, assert_class, msg=None):
I'm sorry I didn't explain. This extra param is needed to make the builtin assertDictEqual() happy, so that the custom one can be dropped.
> """Assert that an instance is an instance of assert_class.
>
> instance and assert_class have the same semantics as the parameters
--
https://code.launchpad.net/~maxiberta/launchpad/named-auth-tokens/+merge/299432
Your team Launchpad code reviewers is subscribed to branch lp:launchpad.
References