# 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 json
import macaroonbakery.bakery as bakery
import macaroonbakery.checkers as checkers
import pymacaroons
import six
from unittest import TestCase
from macaroonbakery.tests import common
from pymacaroons import serializers
        m = bakery.Macaroon(
            root_key=b'root key', id=b'id',
            location='location', version=version,
            namespace=ns)
        m.add_caveat(checkers.Caveat(location='bs-loc', condition='something'),
                     bs.oven.key, locator)

        # Sanity check that no external caveat data has been added.
        self.assertEqual(len(m._caveat_data), 0)

        data = json.dumps(m, cls=bakery.MacaroonJSONEncoder)
        m1 = json.loads(data, cls=bakery.MacaroonJSONDecoder)

        # Just check the signature and version - we're not interested in fully
        # checking the macaroon marshaling here.
        self.assertEqual(m1.macaroon.signature, m.macaroon.signature)
        self.assertEqual(m1.macaroon.version,
                         bakery.macaroon_version(version))
        self.assertEqual(len(m1.macaroon.caveats), 1)

        # Namespace information has been thrown away.
        self.assertEqual(m1.namespace, bakery.legacy_namespace())

        self.assertEqual(len(m1._caveat_data), 0)

    def test_json_unknown_version(self):
        m = pymacaroons.Macaroon(version=pymacaroons.MACAROON_V2)
        with self.assertRaises(ValueError) as exc:
            json.loads(json.dumps({
                'm': m.serialize(serializer=serializers.JsonSerializer()),

# 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_macaroon.py
import json
import macaroonbakery.bakery as bakery
import macaroonbakery.checkers as checkers
import pymacaroons
import six
from unittest import TestCase
from macaroonbakery.tests import common
from pymacaroons import serializers

        m = bakery.Macaroon(
            root_key=b'root key', id=b'id',
            location='location', version=version,
            namespace=ns)
        m.add_caveat(checkers.Caveat(location='bs-loc', condition='something'),
                     bs.oven.key, locator)

        # Sanity check that no external caveat data has been added.
        self.assertEqual(len(m._caveat_data), 0)

        data = json.dumps(m, cls=bakery.MacaroonJSONEncoder)
        m1 = json.loads(data, cls=bakery.MacaroonJSONDecoder)

        # Just check the signature and version - we're not interested in fully
        # checking the macaroon marshaling here.
        self.assertEqual(m1.macaroon.signature, m.macaroon.signature)
        self.assertEqual(m1.macaroon.version,
                         bakery.macaroon_version(version))
        self.assertEqual(len(m1.macaroon.caveats), 1)

        # Namespace information has been thrown away.
        self.assertEqual(m1.namespace, bakery.legacy_namespace())

        self.assertEqual(len(m1._caveat_data), 0)

    def test_json_unknown_version(self):
        m = pymacaroons.Macaroon(version=pymacaroons.MACAROON_V2)
        with self.assertRaises(ValueError) as exc:
            json.loads(json.dumps({
                'm': m.serialize(serializer=serializers.JsonSerializer()),

                'v': bakery.LATEST_VERSION + 1