# 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
            namespace=ns)
        m.add_caveat(checkers.Caveat(location='bs-loc', condition='something'),
                     bs.oven.key, locator)
        data = m.serialize_json()
        m1 = bakery.Macaroon.deserialize_json(data)
        # 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, m.macaroon.version)
        self.assertEqual(len(m1.macaroon.caveats), 1)
        self.assertEqual(m1.namespace, m.namespace)
        self.assertEqual(m1._caveat_data, m._caveat_data)

        # test with the encoder, decoder
        data = json.dumps(m, cls=bakery.MacaroonJSONEncoder)
        m1 = json.loads(data, cls=bakery.MacaroonJSONDecoder)
        self.assertEqual(m1.macaroon.signature, m.macaroon.signature)
        self.assertEqual(m1.macaroon.version, m.macaroon.version)
        self.assertEqual(len(m1.macaroon.caveats), 1)
        self.assertEqual(m1.namespace, m.namespace)
        self.assertEqual(m1._caveat_data, m._caveat_data)

    def test_json_version1(self):
        self._test_json_with_version(bakery.VERSION_1)

    def test_json_version2(self):
        self._test_json_with_version(bakery.VERSION_2)

    def _test_json_with_version(self, version):
        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_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

            namespace=ns)
        m.add_caveat(checkers.Caveat(location='bs-loc', condition='something'),
                     bs.oven.key, locator)
        data = m.serialize_json()
        m1 = bakery.Macaroon.deserialize_json(data)
        # 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, m.macaroon.version)
        self.assertEqual(len(m1.macaroon.caveats), 1)
        self.assertEqual(m1.namespace, m.namespace)
        self.assertEqual(m1._caveat_data, m._caveat_data)

        # test with the encoder, decoder
        data = json.dumps(m, cls=bakery.MacaroonJSONEncoder)
        m1 = json.loads(data, cls=bakery.MacaroonJSONDecoder)
        self.assertEqual(m1.macaroon.signature, m.macaroon.signature)
        self.assertEqual(m1.macaroon.version, m.macaroon.version)
        self.assertEqual(len(m1.macaroon.caveats), 1)
        self.assertEqual(m1.namespace, m.namespace)
        self.assertEqual(m1._caveat_data, m._caveat_data)

    def test_json_version1(self):
        self._test_json_with_version(bakery.VERSION_1)

    def test_json_version2(self):
        self._test_json_with_version(bakery.VERSION_2)

    def _test_json_with_version(self, version):
        locator = bakery.ThirdPartyStore()

        bs = common.new_bakery('bs-loc', locator)