# Path: atlassian_jwt_auth/key.py
# PEM_FILE_TYPE = 'application/x-pem-file'
# class KeyIdentifier(object):
# class BasePublicKeyRetriever(object):
# class HTTPSPublicKeyRetriever(BasePublicKeyRetriever):
# class HTTPSMultiRepositoryPublicKeyRetriever(BasePublicKeyRetriever):
# class BasePrivateKeyRetriever(object):
# class DataUriPrivateKeyRetriever(BasePrivateKeyRetriever):
# class StaticPrivateKeyRetriever(BasePrivateKeyRetriever):
# class FilePrivateKeyRetriever(BasePrivateKeyRetriever):
# class FilePrivateKeyRepository(object):
#     def __init__(self, identifier):
#     def key_id(self):
# def validate_key_identifier(identifier):
# def _get_key_id_from_jwt_header(a_jwt):
#     def retrieve(self, key_identifier, **kwargs):
#     def __init__(self, base_url):
#     def _get_session(self):
#     def retrieve(self, key_identifier, **requests_kwargs):
#     def _retrieve(self, url, requests_kwargs):
#     def _check_content_type(self, url, content_type):
#     def __init__(self, key_repository_urls):
#     def _create_retrievers(self, key_repository_urls):
#     def handle_retrieval_exception(self, retriever, exception):
#     def retrieve(self, key_identifier, **requests_kwargs):
#     def load(self, issuer):
#     def __init__(self, data_uri):
#     def load(self, issuer):
#     def __init__(self, key_identifier, private_key_pem):
#     def load(self, issuer):
#     def __init__(self, private_key_repository_path):
#     def load(self, issuer):
#     def _find_last_key_id(self, issuer):
#     def __init__(self, path):
#     def find_valid_key_ids(self, issuer):
#     def load_key(self, key_identifier):
# 
# Path: atlassian_jwt_auth/tests/utils.py
# def get_new_rsa_private_key_in_pem_format():
# def get_public_key_pem_for_private_key_pem(private_key_pem):
# def get_example_jwt_auth_signer(**kwargs):
# def create_token(issuer, audience, key_id, private_key, subject=None):
#     def get_new_private_key_in_pem_format(self):
#     def algorithm(self):
#     def get_new_private_key_in_pem_format(self):
#     def algorithm(self):
#     def get_new_private_key_in_pem_format(self):
# class BaseJWTAlgorithmTestMixin(object):
# class RS256KeyTestMixin(object):
# class ES256KeyTestMixin(object):


import os
import shutil
import tempfile
import unittest
import atlassian_jwt_auth
from atlassian_jwt_auth import key
from atlassian_jwt_auth.tests import utils
        token = signer.generate_jwt('audience')
        self.assertIsNotNone(token)

    def test_picks_last_valid_key_id(self):
        signer = self.create_signer_for_issuer('issuer-with-many-keys')
        token = signer.generate_jwt('audience')
        key_identifier = key._get_key_id_from_jwt_header(token)
        expected_key_id = 'issuer-with-many-keys/key3.pem'
        self.assertEqual(key_identifier.key_id, expected_key_id)

    def test_fails_if_issuer_has_no_valid_keys(self):
        signer = self.create_signer_for_issuer('invalid-issuer')
        with self.assertRaisesRegex(IOError, 'Issuer has no valid keys'):
            signer.generate_jwt('audience')

    def test_fails_if_issuer_does_not_exist(self):
        signer = self.create_signer_for_issuer('this-does-not-exist')
        with self.assertRaisesRegex(OSError, 'No such file or directory'):
            signer.generate_jwt('audience')


class JWTAuthSignerWithFilePrivateKeyRetrieverRS256Test(
        BaseJWTAuthSignerWithFilePrivateKeyRetrieverTest,
        utils.RS256KeyTestMixin,
        unittest.TestCase):
    pass


class JWTAuthSignerWithFilePrivateKeyRetrieverES256Test(
        BaseJWTAuthSignerWithFilePrivateKeyRetrieverTest,

# Path: atlassian_jwt_auth/key.py
# PEM_FILE_TYPE = 'application/x-pem-file'
# class KeyIdentifier(object):
# class BasePublicKeyRetriever(object):
# class HTTPSPublicKeyRetriever(BasePublicKeyRetriever):
# class HTTPSMultiRepositoryPublicKeyRetriever(BasePublicKeyRetriever):
# class BasePrivateKeyRetriever(object):
# class DataUriPrivateKeyRetriever(BasePrivateKeyRetriever):
# class StaticPrivateKeyRetriever(BasePrivateKeyRetriever):
# class FilePrivateKeyRetriever(BasePrivateKeyRetriever):
# class FilePrivateKeyRepository(object):
#     def __init__(self, identifier):
#     def key_id(self):
# def validate_key_identifier(identifier):
# def _get_key_id_from_jwt_header(a_jwt):
#     def retrieve(self, key_identifier, **kwargs):
#     def __init__(self, base_url):
#     def _get_session(self):
#     def retrieve(self, key_identifier, **requests_kwargs):
#     def _retrieve(self, url, requests_kwargs):
#     def _check_content_type(self, url, content_type):
#     def __init__(self, key_repository_urls):
#     def _create_retrievers(self, key_repository_urls):
#     def handle_retrieval_exception(self, retriever, exception):
#     def retrieve(self, key_identifier, **requests_kwargs):
#     def load(self, issuer):
#     def __init__(self, data_uri):
#     def load(self, issuer):
#     def __init__(self, key_identifier, private_key_pem):
#     def load(self, issuer):
#     def __init__(self, private_key_repository_path):
#     def load(self, issuer):
#     def _find_last_key_id(self, issuer):
#     def __init__(self, path):
#     def find_valid_key_ids(self, issuer):
#     def load_key(self, key_identifier):
# 
# Path: atlassian_jwt_auth/tests/utils.py
# def get_new_rsa_private_key_in_pem_format():
# def get_public_key_pem_for_private_key_pem(private_key_pem):
# def get_example_jwt_auth_signer(**kwargs):
# def create_token(issuer, audience, key_id, private_key, subject=None):
#     def get_new_private_key_in_pem_format(self):
#     def algorithm(self):
#     def get_new_private_key_in_pem_format(self):
#     def algorithm(self):
#     def get_new_private_key_in_pem_format(self):
# class BaseJWTAlgorithmTestMixin(object):
# class RS256KeyTestMixin(object):
# class ES256KeyTestMixin(object):


# Path: atlassian_jwt_auth/tests/test_signer_private_key_repo.py
import os
import shutil
import tempfile
import unittest
import atlassian_jwt_auth
from atlassian_jwt_auth import key
from atlassian_jwt_auth.tests import utils

        token = signer.generate_jwt('audience')
        self.assertIsNotNone(token)

    def test_picks_last_valid_key_id(self):
        signer = self.create_signer_for_issuer('issuer-with-many-keys')
        token = signer.generate_jwt('audience')
        key_identifier = key._get_key_id_from_jwt_header(token)
        expected_key_id = 'issuer-with-many-keys/key3.pem'
        self.assertEqual(key_identifier.key_id, expected_key_id)

    def test_fails_if_issuer_has_no_valid_keys(self):
        signer = self.create_signer_for_issuer('invalid-issuer')
        with self.assertRaisesRegex(IOError, 'Issuer has no valid keys'):
            signer.generate_jwt('audience')

    def test_fails_if_issuer_does_not_exist(self):
        signer = self.create_signer_for_issuer('this-does-not-exist')
        with self.assertRaisesRegex(OSError, 'No such file or directory'):
            signer.generate_jwt('audience')


class JWTAuthSignerWithFilePrivateKeyRetrieverRS256Test(
        BaseJWTAuthSignerWithFilePrivateKeyRetrieverTest,
        utils.RS256KeyTestMixin,
        unittest.TestCase):
    pass


class JWTAuthSignerWithFilePrivateKeyRetrieverES256Test(
        BaseJWTAuthSignerWithFilePrivateKeyRetrieverTest,

        utils.ES256KeyTestMixin,