def setUp(self): super(MacaroonTests, self).setUp() self.issuer = DummyMacaroonIssuer() self.useFixture( ZopeUtilityFixture(self.issuer, IMacaroonIssuer, name='test')) private_root = getUtility(IPrivateApplication) self.authserver = AuthServerAPIView(private_root.authserver, TestRequest())
def test_issueMacaroon_not_via_authserver(self): build = self.factory.makeBinaryPackageBuild( archive=self.factory.makeArchive(private=True)) private_root = getUtility(IPrivateApplication) authserver = AuthServerAPIView(private_root.authserver, TestRequest()) self.assertEqual( faults.PermissionDenied(), authserver.issueMacaroon( "binary-package-build", "BinaryPackageBuild", build))
def test_issueMacaroon_via_authserver(self): build = self.factory.makeSnapBuild(snap=self.factory.makeSnap( private=True)) private_root = getUtility(IPrivateApplication) authserver = AuthServerAPIView(private_root.authserver, TestRequest()) macaroon = Macaroon.deserialize( authserver.issueMacaroon("snap-build", "SnapBuild", build.id)) self.assertThat( macaroon, MatchesStructure(location=Equals("launchpad.dev"), identifier=Equals("snap-build"), caveats=MatchesListwise([ MatchesStructure.byEquality( caveat_id="lp.snap-build %s" % build.id), ])))
def __init__(self, *args, **kwargs): xmlrpc.XMLRPC.__init__(self, *args, **kwargs) private_root = getUtility(IPrivateApplication) self.authserver = AuthServerAPIView(private_root.authserver, TestRequest())
def setUp(self): TestCaseWithFactory.setUp(self) private_root = getUtility(IPrivateApplication) self.authserver = AuthServerAPIView(private_root.authserver, TestRequest())