-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add JWT Authentication to API Endpoints
- Loading branch information
Showing
8 changed files
with
94 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,3 +42,5 @@ urllib3==1.26.5 | |
Werkzeug==2.2.3 | ||
zipp==0.5.2 | ||
pyopenms==2.6.0 | ||
PyJWT==2.8.0 | ||
flask-jwt-extended==4.5.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,21 @@ | ||
import os | ||
import json | ||
from unittest.mock import patch | ||
from instance.config import TEST_TOKEN | ||
|
||
test_json_path = './tests/fixtures/test_data_types.json' | ||
orig_json_path = 'chem_spectra.controller.spectra_layout_api.data_type_json_path' | ||
test_jwt_token = TEST_TOKEN | ||
|
||
def test_get_spectra_layouts_with_data(client): | ||
data_type_json_path = './tests/fixtures/test_data_types.json' | ||
response = client.get('/spectra_layouts') | ||
response_data = response.json() | ||
assert response.status_code == 200 | ||
assert response_data == { | ||
"INFRARED": ["INFRARED SPECTRUM"], | ||
"MS": ["MASS SPECTRUM"], | ||
"NMR": ["NMR SPECTRUM", "NMRSPECTRUM"], | ||
"RAMAN": ["RAMAN"] | ||
} | ||
with patch(orig_json_path, new=test_json_path): | ||
response = client.get('/api/v1/chemspectra/spectra_layouts', | ||
headers={'Authorization': f'Bearer {test_jwt_token}'}) | ||
response_data = response.json | ||
assert response.status_code == 200 | ||
assert response_data == { | ||
"INFRARED": ["INFRARED SPECTRUM"], | ||
"MS": ["MASS SPECTRUM"], | ||
"NMR": ["NMR SPECTRUM", "NMRSPECTRUM"], | ||
"RAMAN": ["RAMAN"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,17 @@ | ||
{ | ||
"datatypes": { | ||
"NMR": ["NMR SPECTRUM", "NMRSPECTRUM"], | ||
"INFRARED": ["INFRARED SPECTRUM"], | ||
"RAMAN": ["RAMAN"], | ||
"MS": ["MASS SPECTRUM"] | ||
} | ||
} | ||
"datatypes": { | ||
"NMR": [ | ||
"NMR SPECTRUM", | ||
"NMRSPECTRUM" | ||
], | ||
"INFRARED": [ | ||
"INFRARED SPECTRUM" | ||
], | ||
"RAMAN": [ | ||
"RAMAN" | ||
], | ||
"MS": [ | ||
"MASS SPECTRUM" | ||
] | ||
} | ||
} |