from typing import List


def helper_create_jwt(jwt_manager, roles: List[str] = [], username: str = 'test-user'):
    """Create a jwt bearer token with the correct keys, roles and username."""
    token_header = {
        'alg': 'RS256',
        'typ': 'JWT',
        'kid': 'flask-jwt-oidc-test-client'
    }
    claims = {
        'iss': 'https://example.localdomain/auth/realms/example',
        'sub': '43e6a245-0bf7-4ccf-9bd0-e7fb85fd18cc',
        'aud': 'example',
        'exp': 2539722391,
        'iat': 1539718791,
        'jti': 'flask-jwt-oidc-test-support',
        'typ': 'Bearer',
        'username': f'{username}',
        'realm_access': {
            'roles': [] + roles
        }
    }
    return jwt_manager.create_jwt(claims, token_header)