Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
Merge pull request #235 from CSCfi/dev
Browse files Browse the repository at this point in the history
1.6.3
  • Loading branch information
teemukataja authored Dec 5, 2022
2 parents 917bbe6 + 4a8c822 commit 4ef6b98
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 27 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/dependabot-auto-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ jobs:
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v1.1.1
uses: dependabot/fetch-metadata@v1.3.5
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: Wait other jobs are passed or failed
if: ${{ contains(github.event.pull_request.labels.*.name, 'pip dependencies') || contains(github.event.pull_request.labels.*.name, 'github actions') }}
if: ${{ steps.metadata.outputs.package-ecosystem == 'pip' || steps.metadata.outputs.package-ecosystem == 'github_actions' }}
uses: kachick/wait-other-jobs@v1
timeout-minutes: 30
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: Enable auto-merge for Dependabot PRs
if: ${{ contains(github.event.pull_request.labels.*.name, 'pip dependencies') || contains(github.event.pull_request.labels.*.name, 'github actions') }}
if: ${{ steps.metadata.outputs.package-ecosystem == 'pip' || steps.metadata.outputs.package-ecosystem == 'github_actions' }}
run: gh pr review --approve "$PR_URL" && gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ jobs:
- name: 'Checkout Repository'
uses: actions/checkout@v3
- name: 'Dependency Review'
uses: actions/dependency-review-action@v2
uses: actions/dependency-review-action@v3
with:
fail-on-severity: moderate
2 changes: 1 addition & 1 deletion .github/workflows/int.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
path: beacon2

- name: Download beacon 2 data
uses: carlosperate/download-file-action@v1.1.1
uses: carlosperate/download-file-action@v2.0.0
id: download-data
with:
file-url: 'https://drive.google.com/uc?export=download&id=1PLv5F54a5pqR_ts5fL68jtmmkuJjDxMA'
Expand Down
6 changes: 6 additions & 0 deletions aggregator/aggregator.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,16 @@ def set_cors(app):
cors.add(route)


async def response_headers(_, res):
"""Modify response headers before returning response."""
res.headers["Server"] = "Beacon-Network"


async def init_app():
"""Initialise the web server."""
LOG.info("Initialising web server.")
app = web.Application(middlewares=[api_key()])
app.on_response_prepare.append(response_headers)
app.router.add_routes(routes)
if CONFIG.cors:
set_cors(app)
Expand Down
6 changes: 3 additions & 3 deletions docs/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ Response
"updatedAt": "2019-08-02 00:00:13.006256+00:00",
"contactUrl": "https://www.csc.fi/contact-info",
"environment": "dev",
"version": "1.4.2",
"version": "1.6.3",
"url": "https://staging-elixirbeacon.rahtiapp.fi/"
},
{
Expand All @@ -301,7 +301,7 @@ Response
"updatedAt": "2019-08-02 00:00:13.016122+00:00",
"contactUrl": "https://www.csc.fi/contact-info",
"environment": "prod",
"version": "1.4.2",
"version": "1.6.3",
"url": "https://staging-elixirbeacon.rahtiapp.fi/"
},
{
Expand Down Expand Up @@ -362,7 +362,7 @@ Response
"updatedAt": "2019-08-02 00:00:13.006256+00:00",
"contactUrl": "https://www.csc.fi/contact-info",
"environment": "dev",
"version": "1.4.2",
"version": "1.6.3",
"url": "https://staging-elixirbeacon.rahtiapp.fi/"
}
Expand Down
6 changes: 6 additions & 0 deletions registry/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,16 @@ def set_cors(app):
cors.add(route)


async def response_headers(_, res):
"""Modify response headers before returning response."""
res.headers["Server"] = "Beacon-Network"


async def init_app():
"""Initialise the web server."""
LOG.info("Initialising web server.")
app = web.Application(middlewares=[api_key()])
app.on_response_prepare.append(response_headers)
app.router.add_routes(routes)
if CONFIG.cors:
set_cors(app)
Expand Down
10 changes: 5 additions & 5 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
asyncio==3.4.3
aiohttp==3.8.1
aiohttp==3.8.3
aiohttp-cors==0.7.0
aiocache==0.11.1
aiomcache==0.7.0
ujson==5.4.0
ujson==5.6.0
uvloop==0.14.0; python_version < '3.7'
uvloop==0.16.0; python_version >= '3.7'
asyncpg==0.26.0
jsonschema==4.9.0
uvloop==0.17.0; python_version >= '3.7'
asyncpg==0.27.0
jsonschema==4.17.3
gunicorn==20.1.0
28 changes: 14 additions & 14 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name="beacon_network",
version="1.4.2",
version="1.6.3",
description="Beacon Network services",
long_description_content_type="text/markdown",
project_urls={
Expand Down Expand Up @@ -30,31 +30,31 @@
package_data={"": ["*.json", "*.ini"]},
install_requires=[
"asyncio==3.4.3",
"aiohttp==3.8.1",
"aiohttp==3.8.3",
"aiohttp-cors==0.7.0",
"aiocache==0.11.1",
"aiomcache==0.7.0",
"ujson==5.4.0",
"ujson==5.6.0",
"uvloop==0.14.0; python_version < '3.7'",
"uvloop==0.16.0; python_version >= '3.7'",
"asyncpg==0.26.0",
"jsonschema==4.9.0",
"uvloop==0.17.0; python_version >= '3.7'",
"asyncpg==0.27.0",
"jsonschema==4.17.3",
"gunicorn==20.1.0",
],
extras_require={
"test": [
"coverage==6.4.2",
"pytest<7.2",
"pytest-cov==3.0.0",
"testfixtures==7.0.0",
"tox==3.25.1",
"flake8==5.0.1",
"coverage==6.5.0",
"pytest<7.3",
"pytest-cov==4.0.0",
"testfixtures==7.0.3",
"tox==3.27.1",
"flake8==6.0.0",
"flake8-docstrings==1.6.0",
"asynctest==0.13.0",
"aioresponses==0.7.3",
"black==22.6.0",
"black==22.10.0",
],
"docs": ["sphinx >= 1.4", "sphinx_rtd_theme==1.0.0"],
"docs": ["sphinx >= 1.4", "sphinx_rtd_theme==1.1.1"],
},
entry_points={
"console_scripts": ["beacon_registry=registry.registry:main", "beacon_aggregator=aggregator.aggregator:main"],
Expand Down
7 changes: 7 additions & 0 deletions tests/aggregator/test_aggregator_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ async def get_application(self):
"""Retrieve web application for test."""
return await init_app()

@unittest_run_loop
async def test_response_headers(self):
"""Test response headers are set correctly in on_prepare_response."""
resp = await self.client.request("GET", "/")
assert 200 == resp.status
assert "Beacon-Network" == resp.headers.get("Server", "")

@unittest_run_loop
async def test_index(self):
"""Test root endpoint."""
Expand Down
7 changes: 7 additions & 0 deletions tests/registry/test_registry_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ async def get_application(self, mock_db):
"""Retrieve web application for test."""
return await init_app()

@unittest_run_loop
async def test_response_headers(self):
"""Test response headers are set correctly in on_prepare_response."""
resp = await self.client.request("GET", "/")
assert 200 == resp.status
assert "Beacon-Network" == resp.headers.get("Server", "")

@unittest_run_loop
async def test_index(self):
"""Test root endpoint."""
Expand Down

0 comments on commit 4ef6b98

Please sign in to comment.