Skip to content

Commit 034460d

Browse files
ponyisiBenGalewsky
authored andcommitted
endpoint name is the instance name if it's defined
1 parent ce683c5 commit 034460d

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

servicex_app/servicex_app/web/servicex_file.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from urllib.parse import urlparse
44

55
import flask
6-
from flask import (request, send_file, session)
6+
from flask import (request, send_file, session, current_app)
77
from servicex_app.decorators import oauth_required
88
from servicex_app.models import UserModel
99

@@ -14,7 +14,7 @@ def servicex_file():
1414
email = session.get('email')
1515
user = UserModel.find_by_email(email)
1616
endpoint_url = get_correct_url(request)
17-
endpoint_name = urlparse(endpoint_url).hostname
17+
endpoint_name = current_app.config.get("INSTANCE_NAME", urlparse(endpoint_url).hostname)
1818

1919
body = "api_endpoints:\n"
2020
body += f" - name: {endpoint_name}\n"

servicex_app/servicex_app_test/web/test_servicex_file.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@ def test_servicex_file(self, client, user):
2424
assert response.data.decode() == dedent(expected)
2525
assert response.headers['Content-Disposition'] == 'attachment; filename=servicex.yaml'
2626

27+
cfg = {'INSTANCE_NAME': 'important-instance'}
28+
client.application.config.update(cfg)
29+
response: Response = client.get(url_for('servicex-file'))
30+
expected = """\
31+
api_endpoints:
32+
- name: important-instance
33+
endpoint: http://localhost/
34+
token: abcdef
35+
default_endpoint: important-instance
36+
"""
37+
assert response.data.decode() == dedent(expected)
38+
assert response.headers['Content-Disposition'] == 'attachment; filename=servicex.yaml'
39+
2740
def test_correct_url(self, client):
2841
"""
2942
Test that http endpoints are replaced with https addresses with the

0 commit comments

Comments
 (0)