diff --git a/assets/populate.py b/assets/populate.py index c6b7c7c..03e762c 100755 --- a/assets/populate.py +++ b/assets/populate.py @@ -8,7 +8,10 @@ from mido import MidiFile from configparser import ConfigParser url = os.environ.get("API_URL") +api_key = os.environ.get("API_KEY_POPULATE") auth_headers = {} +auth_headers["Authorization"] = f"API Key {api_key}" + def getOrCreateAlbum(name, artistId): if not name: @@ -68,18 +71,11 @@ def main(): global url if url == None: url = "http://localhost:3000" - print("Connecting as guest") - res = requests.post(f"{url}/auth/guest") - token = (res.json())["access_token"] - global auth_headers - auth_headers["Authorization"] = f"Bearer {token}" print("Searching for files...") for file in glob.glob("**/*.ini", recursive=True): print(f"File found: {file}") path = os.path.splitext(file)[0] populateFile(file, path + ".midi", path + ".mxl") - print("Deleting guest") - requests.delete(f"{url}/auth/me", headers=auth_headers) if __name__ == "__main__": exit(main()) diff --git a/scorometer/main.py b/scorometer/main.py index 904156a..58c0cef 100755 --- a/scorometer/main.py +++ b/scorometer/main.py @@ -26,10 +26,9 @@ from mido import MidiFile import uuid BACK_URL = os.environ.get("BACK_URL") or "http://back:3000" -r = requests.post(f"{BACK_URL}/auth/guest") -token = r.json()["access_token"] +API_KEY = os.environ.get("API_KEY_SCORO") auth_header = { - "Authorization": f"Bearer {token}" + "Authorization": f"API Key {API_KEY}" } game_uuid = uuid.uuid4() diff --git a/scorometer/tests/runner.sh b/scorometer/tests/runner.sh index bc75fca..db53e17 100755 --- a/scorometer/tests/runner.sh +++ b/scorometer/tests/runner.sh @@ -1,8 +1,7 @@ #!/bin/bash -TOKEN=$(curl localhost:3000/auth/guest -X POST | jq -r '.access_token') -EMPTY_DB=$(curl localhost:3000/song/1 -s -H "Authorization: Bearer $TOKEN" | jq '.statusCode == 404') +EMPTY_DB=$(curl localhost:3000/song/1 -s -H "Authorization: API Key $API_KEY_SCORO_TEST" | jq '.statusCode == 404') if [[ $EMPTY_DB == "true" ]]; then - curl localhost:3000/song -H "Authorization: Bearer $TOKEN" -X POST --data '{"name": "SCORO_TEST", "difficulties": {}, "midiPath": "/assets/musics/SCORO_TEST/SCORO_TEST.midi", "musicXmlPath": "/assets/musics/SCORO_TEST/SCORO_TEST.mxl"}' -H "Content-Type: application/json" &> /dev/null + curl localhost:3000/song -H "Authorization: API Key $API_KEY_SCORO_TEST" -X POST --data '{"name": "SCORO_TEST", "difficulties": {}, "midiPath": "/assets/musics/SCORO_TEST/SCORO_TEST.midi", "musicXmlPath": "/assets/musics/SCORO_TEST/SCORO_TEST.mxl"}' -H "Content-Type: application/json" &> /dev/null fi TESTS_DONE=0