# 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 datetime
import unittest
import jwt
import jwt.algorithms
import jwt.exceptions
import atlassian_jwt_auth
import atlassian_jwt_auth.exceptions
import atlassian_jwt_auth.key
import atlassian_jwt_auth.signer
from unittest import mock
from atlassian_jwt_auth.tests import utils
        with self.assertRaisesRegex(KeyError, expected_msg):
            verifier.verify_jwt(a_jwt, self._example_aud)

    def test_verify_jwt_with_none_aud(self):
        """ tests that verify_jwt rejects jwt that have a None aud claim. """
        verifier = self._setup_jwt_auth_verifier(self._public_key_pem)
        a_jwt = self._jwt_auth_signer.generate_jwt(
            self._example_aud,
            additional_claims={'aud': None})
        exceptions = (jwt.exceptions.InvalidAudienceError,
                      jwt.exceptions.InvalidTokenError)
        with self.assertRaises(exceptions) as cm:
            verifier.verify_jwt(a_jwt, self._example_aud)
        if not isinstance(cm.exception, jwt.exceptions.InvalidAudienceError):
            self.assertIn('aud', str(cm.exception))

    def test_verify_jwt_with_non_matching_aud(self):
        """ tests that verify_jwt rejects a jwt if the aud claim does not
            match the given & expected audience.
        """
        verifier = self._setup_jwt_auth_verifier(self._public_key_pem)
        a_jwt = self._jwt_auth_signer.generate_jwt(
            self._example_aud,
            additional_claims={'aud': self._example_aud + '-different'})
        with self.assertRaises(jwt.exceptions.InvalidAudienceError):
            verifier.verify_jwt(a_jwt, self._example_aud)


class JWTAuthVerifierRS256Test(
        BaseJWTAuthVerifierTest,

# 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_verifier.py
import datetime
import unittest
import jwt
import jwt.algorithms
import jwt.exceptions
import atlassian_jwt_auth
import atlassian_jwt_auth.exceptions
import atlassian_jwt_auth.key
import atlassian_jwt_auth.signer
from unittest import mock
from atlassian_jwt_auth.tests import utils

        with self.assertRaisesRegex(KeyError, expected_msg):
            verifier.verify_jwt(a_jwt, self._example_aud)

    def test_verify_jwt_with_none_aud(self):
        """ tests that verify_jwt rejects jwt that have a None aud claim. """
        verifier = self._setup_jwt_auth_verifier(self._public_key_pem)
        a_jwt = self._jwt_auth_signer.generate_jwt(
            self._example_aud,
            additional_claims={'aud': None})
        exceptions = (jwt.exceptions.InvalidAudienceError,
                      jwt.exceptions.InvalidTokenError)
        with self.assertRaises(exceptions) as cm:
            verifier.verify_jwt(a_jwt, self._example_aud)
        if not isinstance(cm.exception, jwt.exceptions.InvalidAudienceError):
            self.assertIn('aud', str(cm.exception))

    def test_verify_jwt_with_non_matching_aud(self):
        """ tests that verify_jwt rejects a jwt if the aud claim does not
            match the given & expected audience.
        """
        verifier = self._setup_jwt_auth_verifier(self._public_key_pem)
        a_jwt = self._jwt_auth_signer.generate_jwt(
            self._example_aud,
            additional_claims={'aud': self._example_aud + '-different'})
        with self.assertRaises(jwt.exceptions.InvalidAudienceError):
            verifier.verify_jwt(a_jwt, self._example_aud)


class JWTAuthVerifierRS256Test(
        BaseJWTAuthVerifierTest,

        utils.RS256KeyTestMixin,