# Path: mobsf/MobSF/utils.py
# def api_key():
#     """Print REST API Key."""
#     if os.environ.get('MOBSF_API_KEY'):
#         logger.info('\nAPI Key read from environment variable')
#         return os.environ['MOBSF_API_KEY']
# 
#     secret_file = os.path.join(settings.MobSF_HOME, 'secret')
#     if is_file_exists(secret_file):
#         try:
#             _api_key = open(secret_file).read().strip()
#             return gen_sha256_hash(_api_key)
#         except Exception:
#             logger.exception('Cannot Read API Key')


import json
import logging
import os
import platform
from django.conf import settings
from django.http import HttpResponse
from django.test import Client, TestCase
from mobsf.MobSF.utils import api_key
            else:
                logger.error('Search by MD5 test failed for %s', scan_md5)
                logger.info(resp.content)
                return True
        logger.info('[OK] Search by MD5 tests completed')

        # Deleting Scan Results
        logger.info('Running Delete Scan Results test')
        for md5 in scan_md5s:
            resp = http_client.post('/delete_scan/', {'md5': md5})
            if resp.status_code == 200:
                dat = json.loads(resp.content.decode('utf-8'))
                if dat['deleted'] == 'yes':
                    logger.info('[OK] Deleted Scan: %s', md5)
                else:
                    logger.error('Deleting Scan: %s', md5)
                    return True
            else:
                logger.error('Deleting Scan: %s', md5)
                return True
        logger.info('Delete Scan Results test completed')
    except Exception:
        logger.exception('Completing Static Analyzer Test')
        return True
    return False


def api_test():
    """View for Handling REST API Test."""
    logger.info('\nRunning REST API Unit test')

# Path: mobsf/MobSF/utils.py
# def api_key():
#     """Print REST API Key."""
#     if os.environ.get('MOBSF_API_KEY'):
#         logger.info('\nAPI Key read from environment variable')
#         return os.environ['MOBSF_API_KEY']
# 
#     secret_file = os.path.join(settings.MobSF_HOME, 'secret')
#     if is_file_exists(secret_file):
#         try:
#             _api_key = open(secret_file).read().strip()
#             return gen_sha256_hash(_api_key)
#         except Exception:
#             logger.exception('Cannot Read API Key')


# Path: mobsf/StaticAnalyzer/tests.py
import json
import logging
import os
import platform
from django.conf import settings
from django.http import HttpResponse
from django.test import Client, TestCase
from mobsf.MobSF.utils import api_key

            else:
                logger.error('Search by MD5 test failed for %s', scan_md5)
                logger.info(resp.content)
                return True
        logger.info('[OK] Search by MD5 tests completed')

        # Deleting Scan Results
        logger.info('Running Delete Scan Results test')
        for md5 in scan_md5s:
            resp = http_client.post('/delete_scan/', {'md5': md5})
            if resp.status_code == 200:
                dat = json.loads(resp.content.decode('utf-8'))
                if dat['deleted'] == 'yes':
                    logger.info('[OK] Deleted Scan: %s', md5)
                else:
                    logger.error('Deleting Scan: %s', md5)
                    return True
            else:
                logger.error('Deleting Scan: %s', md5)
                return True
        logger.info('Delete Scan Results test completed')
    except Exception:
        logger.exception('Completing Static Analyzer Test')
        return True
    return False


def api_test():
    """View for Handling REST API Test."""
    logger.info('\nRunning REST API Unit test')

    auth = api_key()