def _generate_test_cases():
    try:
        root_dir = os.path.abspath(file_root())
    except Exception:
        root_dir = os.getcwd()
    if (not os.path.isdir(root_dir)):
        root_dir = os.getcwd()
    base_dir = os.path.join(root_dir, 'aws_encryption_sdk_resources')
    ciphertext_manifest_path = os.path.join(base_dir, 'manifests', 'ciphertext.manifest')
    if (not os.path.isfile(ciphertext_manifest_path)):
        return []
    with open(ciphertext_manifest_path, encoding='utf-8') as f:
        ciphertext_manifest = json.load(f)
    _test_cases = []
    for (algorithm, keys) in ciphertext_manifest['test_keys'].items():
        algorithm = to_bytes(algorithm.upper())
        for (key_bits, key_desc) in keys.items():
            key_desc = to_bytes(key_desc)
            key_bits = int(key_bits)
            raw_key = to_bytes(key_desc.get('line_separator', '').join(key_desc['key']))
            if (key_desc['encoding'].lower() in ('raw', 'pem')):
                _STATIC_KEYS[algorithm][key_bits] = raw_key
            elif (key_desc['encoding'].lower() == 'base64'):
                _STATIC_KEYS[algorithm][key_bits] = base64.b64decode(raw_key)
            else:
                raise Exception(('TODO' + 'Unknown key encoding'))
    for test_case in ciphertext_manifest['test_cases']:
        key_ids = []
        algorithm = aws_encryption_sdk.Algorithm.get_by_id(int(test_case['algorithm'], 16))
        for key in test_case['master_keys']:
            sys.stderr.write((('XC:: ' + json.dumps(key)) + '\n'))
            if (key['provider_id'] == StaticStoredMasterKeyProvider.provider_id):
                key_ids.append(RawKeyDescription(key['encryption_algorithm'], key.get('key_bits', (algorithm.data_key_len * 8)), key.get('padding_algorithm', ''), key.get('padding_hash', '')).key_id)
        if key_ids:
            _test_cases.append(Scenario(os.path.join(base_dir, test_case['plaintext']['filename']), os.path.join(base_dir, test_case['ciphertext']['filename']), key_ids))
    return _test_cases
def _generate_test_cases():
    try:
        root_dir = os.path.abspath(file_root())
    except Exception:
        root_dir = os.getcwd()
    if (not os.path.isdir(root_dir)):
        root_dir = os.getcwd()
    base_dir = os.path.join(root_dir, 'aws_encryption_sdk_resources')
    ciphertext_manifest_path = os.path.join(base_dir, 'manifests', 'ciphertext.manifest')
    if (not os.path.isfile(ciphertext_manifest_path)):
        return []
    with open(ciphertext_manifest_path, encoding='utf-8') as f:
        ciphertext_manifest = json.load(f)
    _test_cases = []
    for (algorithm, keys) in ciphertext_manifest['test_keys'].items():
        algorithm = to_bytes(algorithm.upper())
        for (key_bits, key_desc) in keys.items():
            key_desc = to_bytes(key_desc)
            key_bits = int(key_bits)
            raw_key = to_bytes(key_desc.get('line_separator', ).join(key_desc['key']))
            if (key_desc['encoding'].lower() in ('raw', 'pem')):
                _STATIC_KEYS[algorithm][key_bits] = raw_key
            elif (key_desc['encoding'].lower() == 'base64'):
                _STATIC_KEYS[algorithm][key_bits] = base64.b64decode(raw_key)
            else:
                raise Exception(('TODO' + 'Unknown key encoding'))
    for test_case in ciphertext_manifest['test_cases']:
        key_ids = []
        algorithm = aws_encryption_sdk.Algorithm.get_by_id(int(test_case['algorithm'], 16))
        for key in test_case['master_keys']:
            sys.stderr.write((('XC:: ' + json.dumps(key)) + '\n'))
            if (key['provider_id'] == StaticStoredMasterKeyProvider.provider_id):
                key_ids.append(RawKeyDescription(key['encryption_algorithm'], key.get('key_bits', (algorithm.data_key_len * 8)), key.get('padding_algorithm', ), key.get('padding_hash', )).key_id)
        if key_ids:
            _test_cases.append(Scenario(os.path.join(base_dir, test_case['plaintext']['filename']), os.path.join(base_dir, test_case['ciphertext']['filename']), key_ids))
    return _test_cases