# 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 base64
import json
import macaroonbakery.bakery as bakery
import macaroonbakery.checkers as checkers
import pymacaroons
from collections import namedtuple
from datetime import timedelta
from unittest import TestCase
from macaroonbakery.tests.common import epoch, test_checker, test_context
from pymacaroons.verifier import FirstPartyCaveatVerifierDelegate, Verifier
        self.assertEqual(_macaroon_conditions(m.macaroon.caveats, False), [
            'true 1',
            'true 2',
            'true 3',
            'true 4',
        ])

    def test_first_party_caveat_squashing(self):
        locator = _DischargerLocator()
        ids = _IdService('ids', locator, self)
        auth = _OpAuthorizer({
            bakery.Op(entity='e1', action='read'): {'alice'},
            bakery.Op(entity='e2', action='read'): {'alice'},
        })
        ts = _Service('myservice', auth, ids, locator)
        tests = [
            ('duplicates removed', [
                checkers.Caveat(condition='true 1', namespace='testns'),
                checkers.Caveat(condition='true 2', namespace='testns'),
                checkers.Caveat(condition='true 1', namespace='testns'),
                checkers.Caveat(condition='true 1', namespace='testns'),
                checkers.Caveat(condition='true 3', namespace='testns'),
            ], [
                checkers.Caveat(condition='true 1', namespace='testns'),
                checkers.Caveat(condition='true 2', namespace='testns'),
                checkers.Caveat(condition='true 3', namespace='testns'),
            ]), ('earliest time before', [
                checkers.time_before_caveat(epoch + timedelta(days=1)),
                checkers.Caveat(condition='true 1', namespace='testns'),
                checkers.time_before_caveat(

# 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_checker.py
import base64
import json
import macaroonbakery.bakery as bakery
import macaroonbakery.checkers as checkers
import pymacaroons
from collections import namedtuple
from datetime import timedelta
from unittest import TestCase
from macaroonbakery.tests.common import epoch, test_checker, test_context
from pymacaroons.verifier import FirstPartyCaveatVerifierDelegate, Verifier

        self.assertEqual(_macaroon_conditions(m.macaroon.caveats, False), [
            'true 1',
            'true 2',
            'true 3',
            'true 4',
        ])

    def test_first_party_caveat_squashing(self):
        locator = _DischargerLocator()
        ids = _IdService('ids', locator, self)
        auth = _OpAuthorizer({
            bakery.Op(entity='e1', action='read'): {'alice'},
            bakery.Op(entity='e2', action='read'): {'alice'},
        })
        ts = _Service('myservice', auth, ids, locator)
        tests = [
            ('duplicates removed', [
                checkers.Caveat(condition='true 1', namespace='testns'),
                checkers.Caveat(condition='true 2', namespace='testns'),
                checkers.Caveat(condition='true 1', namespace='testns'),
                checkers.Caveat(condition='true 1', namespace='testns'),
                checkers.Caveat(condition='true 3', namespace='testns'),
            ], [
                checkers.Caveat(condition='true 1', namespace='testns'),
                checkers.Caveat(condition='true 2', namespace='testns'),
                checkers.Caveat(condition='true 3', namespace='testns'),
            ]), ('earliest time before', [
                checkers.time_before_caveat(epoch + timedelta(days=1)),
                checkers.Caveat(condition='true 1', namespace='testns'),
                checkers.time_before_caveat(

                    epoch + timedelta(days=0, hours=1)),