Skip to content

Commit

Permalink
endpoint name is the instance name if it's defined
Browse files Browse the repository at this point in the history
  • Loading branch information
ponyisi authored and BenGalewsky committed Mar 7, 2025
1 parent ce683c5 commit 034460d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions servicex_app/servicex_app/web/servicex_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from urllib.parse import urlparse

import flask
from flask import (request, send_file, session)
from flask import (request, send_file, session, current_app)
from servicex_app.decorators import oauth_required
from servicex_app.models import UserModel

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

body = "api_endpoints:\n"
body += f" - name: {endpoint_name}\n"
Expand Down
13 changes: 13 additions & 0 deletions servicex_app/servicex_app_test/web/test_servicex_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@ def test_servicex_file(self, client, user):
assert response.data.decode() == dedent(expected)
assert response.headers['Content-Disposition'] == 'attachment; filename=servicex.yaml'

cfg = {'INSTANCE_NAME': 'important-instance'}
client.application.config.update(cfg)
response: Response = client.get(url_for('servicex-file'))
expected = """\
api_endpoints:
- name: important-instance
endpoint: http://localhost/
token: abcdef
default_endpoint: important-instance
"""
assert response.data.decode() == dedent(expected)
assert response.headers['Content-Disposition'] == 'attachment; filename=servicex.yaml'

def test_correct_url(self, client):
"""
Test that http endpoints are replaced with https addresses with the
Expand Down

0 comments on commit 034460d

Please # to comment.