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

Commit c5f0727

Browse files
committed
mock test url and config for unit-tests
1 parent 62f23dd commit c5f0727

5 files changed

Lines changed: 119 additions & 7 deletions

File tree

deploy/test/auth_test.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
[beacon_general_info]
66
# Name of the Beacon service
7-
title=EGA Beacon
7+
title=GA4GHBeacon at CSC
88

99
# Version of the Beacon implementation
1010
version=1.4.0

tests/test.ini

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# This file is used to configure the Beacon info endpoint
2+
# This file's default location is /beacon-python/beacon_api/conf/config.ini
3+
4+
5+
[beacon_general_info]
6+
# Name of the Beacon service
7+
title=GA4GHBeacon at CSC
8+
9+
# Version of the Beacon implementation
10+
version=1.4.0
11+
12+
# Author of this software
13+
author=CSC developers
14+
15+
# Software license for this distribution
16+
license=Apache 2.0
17+
18+
# Copyright holder for this software
19+
copyright=CSC - IT Center for Science
20+
21+
# Documentation url for GA4GH Discovery
22+
docs_url=https://beacon-python.readthedocs.io/en/latest/
23+
24+
[beacon_api_info]
25+
# Version of the Beacon API specification this implementation adheres to
26+
apiVersion=1.1.0
27+
28+
# Globally unique identifier for this Beacon instance
29+
beaconId=elixir-finland
30+
31+
# Description of this Beacon service
32+
description=Beacon API Web Server based on the GA4GH Beacon API
33+
34+
# Homepage for Beacon service
35+
url=https://ega-archive.org/
36+
37+
# Alternative URL for Beacon service for e.g. internal use cases
38+
alturl=https://ega-archive.org/
39+
40+
# Datetime when this Beacon was created
41+
createtime=2018-07-25T00:00:00Z
42+
43+
44+
[handover_info]
45+
# The base url for all handovers
46+
drs=https://examplebrowser.org
47+
48+
# Make the handovers 1- or 0-based
49+
handover_base = 1
50+
51+
# Handovers for datasets
52+
dataset_paths=
53+
Variants,browse the variants matched by the query,dataset/{dataset}/browser/variant/{chr}-{start}-{ref}-{alt}
54+
Region,browse data of the region matched by the query,dataset/{dataset}/browser/region/{chr}-{start}-{end}
55+
Data,retrieve information of the datasets,dataset/{dataset}/browser
56+
57+
# Handovers for general beacon
58+
beacon_paths=
59+
Project,retrieve information about the datasets,dataset/{dataset}
60+
61+
62+
[organisation_info]
63+
# Globally unique identifier for organisation that hosts this Beacon service
64+
org_id=CSC
65+
66+
# Name of organisation that hosts this Beacon service
67+
org_name=CSC - IT Center for Science
68+
69+
# Description for organisation
70+
org_description=Finnish expertise in ICT for research, education, culture and public administration
71+
72+
# Visit address of organisation
73+
org_address=Keilaranta 14, Espoo, finland
74+
75+
# Homepage of organisation
76+
org_welcomeUrl=https://www.csc.fi/
77+
78+
# URL for contacting organisation
79+
org_contactUrl=https://www.csc.fi/contact-info
80+
81+
# URL for organisation logo
82+
org_logoUrl=https://www.csc.fi/documents/10180/161914/CSC_2012_LOGO_RGB_72dpi.jpg
83+
84+
# Other organisational information
85+
org_info=CSC represents Finland in the ELIXIR partner nodes
86+
87+
[oauth2]
88+
# OAuth2 server that returns public key for JWT Bearer token validation
89+
server=http://test.csc.fi/jwk
90+
91+
# Authenticated Bearer token issuers, separated by commas if multiple
92+
issuers=http://test.csc.fi
93+
94+
# Where to check the bona_fide_status
95+
userinfo=http://test.csc.fi/userinfo
96+
97+
# What the value of `AcceptedTermsAndPolicies` and `ResearcherStatus` must be in order
98+
# to be recognised as a Bona Fide researcher
99+
bona_fide_value=https://doi.org/10.1038/s41431-018-0219-y
100+
101+
# String or URI to state the intended recipient of the token.
102+
# If your application is part of a larger network,
103+
# the network administrator should supply you with their `aud` identifier
104+
# in other cases, leave this empty or use the personal identifier given to you from your AAI
105+
audience=
106+
107+
# Verify `aud` claim of token.
108+
# If your service is not part of any network or AAI, but you still want to use tokens
109+
# produced by other AAI parties, set this value to False to skip the audience validation step
110+
verify_aud=False

tests/test_app.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def generate_token(issuer):
2929
"k": "hJtXIZ2uSN5kbQfbtTNWbpdmhkV8FJG-Onbc6mxCcYg"
3030
}
3131
header = {
32-
"jku": "https://login.elixir-czech.org/oidc/jwk",
32+
"jku": "http://test.csc.fi/jwk",
3333
"kid": "018c0ae5-4d9b-471b-bfd6-eef314bc7037",
3434
"alg": "HS256"
3535
}
@@ -53,7 +53,7 @@ def generate_bad_token():
5353
"k": "hJtXIZ2uSN5kbQfbtTNWbpdmhkV8FJG-Onbc6mxCcYg"
5454
}
5555
header = {
56-
"jku": "https://login.elixir-czech.org/oidc/jwk",
56+
"jku": "http://test.csc.fi/jwk",
5757
"kid": "018c0ae5-4d9b-471b-bfd6-eef314bc7037",
5858
"alg": "HS256"
5959
}
@@ -87,7 +87,7 @@ class AppTestCase(AioHTTPTestCase):
8787
@asynctest.mock.patch('beacon_api.app.initialize', side_effect=create_db_mock)
8888
async def get_application(self, pool_mock):
8989
"""Retrieve web Application for test."""
90-
token, public_key = generate_token('https://login.elixir-czech.org/oidc/')
90+
token, public_key = generate_token('http://test.csc.fi')
9191
self.bad_token, _ = generate_bad_token()
9292
self.env = EnvironmentVarGuard()
9393
self.env.set('PUBLIC_KEY', json.dumps(public_key))

tests/test_response.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,14 @@ async def test_bad_retrieve_user_data(self, m):
113113
@aioresponses()
114114
async def test_bad_none_retrieve_user_data(self, m):
115115
"""Test a failing userdata call because response didn't have ga4gh format."""
116-
m.get("https://login.elixir-czech.org/oidc/userinfo", payload={"not_ga4gh": [{}]})
116+
m.get("http://test.csc.fi/userinfo", payload={"not_ga4gh": [{}]})
117117
user_data = await retrieve_user_data('good_token')
118118
self.assertEqual(user_data, None)
119119

120120
@aioresponses()
121121
async def test_good_retrieve_user_data(self, m):
122122
"""Test a passing call to retrieve user data."""
123-
m.get("https://login.elixir-czech.org/oidc/userinfo", payload={"ga4gh": [{}]})
123+
m.get("http://test.csc.fi/userinfo", payload={"ga4gh": [{}]})
124124
user_data = await retrieve_user_data('good_token')
125125
self.assertEqual(user_data, [{}])
126126

@@ -140,7 +140,7 @@ async def test_get_key(self, m):
140140
"e": "AQAB"
141141
}
142142
]}
143-
m.get("https://login.elixir-czech.org/oidc/jwk", payload=data)
143+
m.get("http://test.csc.fi/jwk", payload=data)
144144
result = await get_key()
145145
# key = load_pem_public_key(result.encode('utf-8'), backend=default_backend())
146146
self.assertTrue(isinstance(result, dict))

tox.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ deps =
2929
commands = flake8 .
3030

3131
[testenv]
32+
setenv =
33+
CONFIG_FILE = {toxinidir}/tests/test.ini
3234
passenv = TRAVIS TRAVIS_*
3335
deps =
3436
.[test]

0 commit comments

Comments
 (0)