Skip to content

Commit

Permalink
store GSL_KEY in app.config
Browse files Browse the repository at this point in the history
  • Loading branch information
mackenzie-grimes-noaa committed Dec 19, 2024
1 parent e97d3f0 commit b23926f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
3 changes: 1 addition & 2 deletions python/nwsc_dummy_service/ncd_web_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def __init__(self, base_dir: str):
def handler(self):
"""Logic for requests to /all-events"""
# check that this request has proper key to get or add data
if request.headers.get('X-Api-Key') != GSL_KEY:
if request.headers.get('X-Api-Key') != current_app.config['GSL_KEY']:
return jsonify({'message': 'ERROR: Unauthorized'}), 401

if request.method == 'POST':
Expand Down Expand Up @@ -99,7 +99,6 @@ def handler(self):
return jsonify({'profiles': profiles, 'errors': []}), 200



class AppWrapper:
"""Web server class wrapping Flask operations"""
def __init__(self, base_dir: str):
Expand Down
1 change: 1 addition & 0 deletions python/nwsc_dummy_service/test/test_ncd_web_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def mock_current_app(monkeypatch: MonkeyPatch) -> Mock:
mock_obj = Mock(name='MockCurrentApp', spec=Flask)
mock_obj.logger.info.return_value = None
mock_obj.logger.error.return_value = None
mock_obj.config = MultiDict({'GSL_KEY': GSL_KEY})
monkeypatch.setattr('python.nwsc_dummy_service.ncd_web_service.current_app', mock_obj)
return mock_obj

Expand Down

0 comments on commit b23926f

Please sign in to comment.