# Path: macaroonbakery/tests/common.py
# class _StoppedClock(object):
# class OneIdentity(bakery.IdentityClient):
# class _NoOne(object):
# class ThirdPartyStrcmpChecker(bakery.ThirdPartyCaveatChecker):
# class ThirdPartyCheckerWithCaveats(bakery.ThirdPartyCaveatChecker):
# class ThirdPartyCaveatCheckerEmpty(bakery.ThirdPartyCaveatChecker):
#     def __init__(self, t):
#     def utcnow(self):
# def test_checker():
# def str_context(s):
# def str_check(ctx, cond, args):
# def true_check(ctx, cond, args):
#     def identity_from_context(self, ctx):
#     def declared_identity(self, ctx, declared):
#     def id(self):
#     def domain(self):
#     def __init__(self, str):
#     def check_third_party_caveat(self, ctx, cav_info):
#     def __init__(self, cavs=None):
#     def check_third_party_caveat(self, ctx, cav_info):
#     def check_third_party_caveat(self, ctx, cav_info):
# def new_bakery(location, locator=None):


import os
import unittest
import macaroonbakery.bakery as bakery
import macaroonbakery.checkers as checkers
from macaroonbakery.tests import common
from pymacaroons import MACAROON_V1, Macaroon
                               ts.oven.key, ts.oven.locator)

        # client asks for a discharge macaroon for each third party caveat
        def get_discharge(cav, payload):
            self.assertEqual(cav.location, 'bs-loc')
            return bakery.discharge(
                common.test_context,
                cav.caveat_id_bytes,
                payload,
                bs.oven.key,
                common.ThirdPartyStrcmpChecker('user==bob'),
                bs.oven.locator,
            )

        d = bakery.discharge_all(ts_macaroon, get_discharge)
        # client has all the discharge macaroons. For each discharge macaroon
        # bind it to our ts_macaroon and add it to our request.
        tampered_macaroon = Macaroon()
        for i, dm in enumerate(d[1:]):
            d[i + 1] = tampered_macaroon.prepare_for_request(dm)

        # client makes request to ts.
        with self.assertRaises(bakery.PermissionDenied) as exc:
            ts.checker.auth([d]).allow(common.test_context,
                                       bakery.LOGIN_OP)
        self.assertEqual('verification failed: Signatures do not match',
                         exc.exception.args[0])

    def test_need_declared(self):
        locator = bakery.ThirdPartyStore()

# Path: macaroonbakery/tests/common.py
# class _StoppedClock(object):
# class OneIdentity(bakery.IdentityClient):
# class _NoOne(object):
# class ThirdPartyStrcmpChecker(bakery.ThirdPartyCaveatChecker):
# class ThirdPartyCheckerWithCaveats(bakery.ThirdPartyCaveatChecker):
# class ThirdPartyCaveatCheckerEmpty(bakery.ThirdPartyCaveatChecker):
#     def __init__(self, t):
#     def utcnow(self):
# def test_checker():
# def str_context(s):
# def str_check(ctx, cond, args):
# def true_check(ctx, cond, args):
#     def identity_from_context(self, ctx):
#     def declared_identity(self, ctx, declared):
#     def id(self):
#     def domain(self):
#     def __init__(self, str):
#     def check_third_party_caveat(self, ctx, cav_info):
#     def __init__(self, cavs=None):
#     def check_third_party_caveat(self, ctx, cav_info):
#     def check_third_party_caveat(self, ctx, cav_info):
# def new_bakery(location, locator=None):


# Path: macaroonbakery/tests/test_discharge.py
import os
import unittest
import macaroonbakery.bakery as bakery
import macaroonbakery.checkers as checkers
from macaroonbakery.tests import common
from pymacaroons import MACAROON_V1, Macaroon

                               ts.oven.key, ts.oven.locator)

        # client asks for a discharge macaroon for each third party caveat
        def get_discharge(cav, payload):
            self.assertEqual(cav.location, 'bs-loc')
            return bakery.discharge(
                common.test_context,
                cav.caveat_id_bytes,
                payload,
                bs.oven.key,
                common.ThirdPartyStrcmpChecker('user==bob'),
                bs.oven.locator,
            )

        d = bakery.discharge_all(ts_macaroon, get_discharge)
        # client has all the discharge macaroons. For each discharge macaroon
        # bind it to our ts_macaroon and add it to our request.
        tampered_macaroon = Macaroon()
        for i, dm in enumerate(d[1:]):
            d[i + 1] = tampered_macaroon.prepare_for_request(dm)

        # client makes request to ts.
        with self.assertRaises(bakery.PermissionDenied) as exc:
            ts.checker.auth([d]).allow(common.test_context,
                                       bakery.LOGIN_OP)
        self.assertEqual('verification failed: Signatures do not match',
                         exc.exception.args[0])

    def test_need_declared(self):
        locator = bakery.ThirdPartyStore()

        first_party = common.new_bakery('first', locator)