Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

5433 replace platform.linux distribution #5559

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions securedrop/source_app/api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import json
import platform

from flask import Blueprint, current_app, make_response

Expand All @@ -8,6 +7,10 @@
import version


with open("/etc/lsb-release", "r") as f:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/etc/lsb-release comes from the base-files package.

server_os = f.readlines()[1].split("=")[1].strip("\n")


def make_blueprint(config):
view = Blueprint('api', __name__)

Expand All @@ -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()
Expand Down
3 changes: 1 addition & 2 deletions securedrop/tests/test_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down