diff --git a/securedrop/source_app/api.py b/securedrop/source_app/api.py index 07f600fb97..9948692ba4 100644 --- a/securedrop/source_app/api.py +++ b/securedrop/source_app/api.py @@ -1,5 +1,4 @@ import json -import platform from flask import Blueprint, current_app, make_response @@ -8,6 +7,10 @@ import version +with open("/etc/lsb-release", "r") as f: + server_os = f.readlines()[1].split("=")[1].strip("\n") + + def make_blueprint(config): view = Blueprint('api', __name__) @@ -17,7 +20,7 @@ def metadata(): 'allow_document_uploads': current_app.instance_config.allow_document_uploads, 'gpg_fpr': config.JOURNALIST_KEY, 'sd_version': version.__version__, - 'server_os': platform.linux_distribution()[1], + 'server_os': server_os, 'supported_languages': config.SUPPORTED_LOCALES, 'v2_source_url': get_sourcev2_url(), 'v3_source_url': get_sourcev3_url() diff --git a/securedrop/tests/test_source.py b/securedrop/tests/test_source.py index fe2009fc61..090924775d 100644 --- a/securedrop/tests/test_source.py +++ b/securedrop/tests/test_source.py @@ -583,8 +583,7 @@ def test_why_journalist_key(source_app): def test_metadata_route(config, source_app): - with patch.object(source_app_api.platform, "linux_distribution") as mocked_platform: - mocked_platform.return_value = ("Ubuntu", "16.04", "xenial") + with patch.object(source_app_api, "server_os", new="16.04"): with source_app.test_client() as app: resp = app.get(url_for('api.metadata')) assert resp.status_code == 200