示例#1
0
def test_init_service_account_token(mocked_requests):
    """Test the handling of service account JWT tokens."""
    assert init_service_account_token(create_app()) is not None
示例#2
0
logger = logging.getLogger(__name__)
sentry_sdk.init(os.environ.get("SENTRY_DSN"))

init_selinon()
_session = FuturesSession(max_workers=3)

_SERVICE_HOST = os.environ.get("BAYESIAN_DATA_IMPORTER_SERVICE_HOST",
                               "bayesian-data-importer")
_SERVICE_PORT = os.environ.get("BAYESIAN_DATA_IMPORTER_SERVICE_PORT", "9192")
_CVE_SYNC_ENDPOINT = "api/v1/sync_latest_non_cve_version"
_LATEST_VERSION_SYNC_ENDPOINT = "api/v1/sync_latest_version"
_CVE_SOURCE_SYNC_ENDPOINT = "api/v1/sync_cve_source"

SERVICE_TOKEN = 'token'
try:
    SERVICE_TOKEN = init_service_account_token(app)
except requests.exceptions.RequestException as e:
    print('Unable to set authentication token for internal service calls. {}'.
          format(e))


@app.route('/api/v1/readiness')
def readiness():
    """Readiness probe."""
    return flask.jsonify({}), 200


@app.route('/api/v1/liveness')
def liveness():
    """Liveness probe."""
    return flask.jsonify({}), 200