1
0
mirror of https://github.com/krateng/maloja.git synced 2023-08-10 21:12:55 +03:00

Updated API tests

This commit is contained in:
krateng 2021-12-27 20:35:00 +01:00
parent fe1ed955cd
commit 57c090bdcd

View File

@ -1,9 +1,12 @@
{
"info": {
"_postman_id": "632b8649-8470-43d3-934d-8c89dc90464c",
"_postman_id": "71b19d5e-78a1-4a4a-98b5-12cbf2f13fe6",
"name": "Maloja",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "Scrobbling",
"item": [
{
"name": "Scrobble Native",
@ -18,7 +21,7 @@
"formdata": []
},
"url": {
"raw": "{{url}}/apis/mlj_1/newscrobble?key={{api_key}}&artist={{example_artist}}&title={{example_song}}&artist={{example_artist_2}}",
"raw": "{{url}}/apis/mlj_1/newscrobble?key={{api_key}}&artist={{data.artist1}}&title={{data.title1}}&artist={{data.artist2}}",
"host": [
"{{url}}"
],
@ -34,15 +37,15 @@
},
{
"key": "artist",
"value": "{{example_artist}}"
"value": "{{data.artist1}}"
},
{
"key": "title",
"value": "{{example_song}}"
"value": "{{data.title1}}"
},
{
"key": "artist",
"value": "{{example_artist_2}}"
"value": "{{data.artist2}}"
}
]
}
@ -55,7 +58,7 @@
"method": "POST",
"header": [],
"url": {
"raw": "{{url}}/api/newscrobble?key={{api_key}}&artist={{example_artist}}&title={{example_song}}&artist={{example_artist_2}}",
"raw": "{{url}}/api/newscrobble?key={{api_key}}&artist={{data.artist1}}&title={{data.title1}}&artist={{data.artist2}}",
"host": [
"{{url}}"
],
@ -70,15 +73,15 @@
},
{
"key": "artist",
"value": "{{example_artist}}"
"value": "{{data.artist1}}"
},
{
"key": "title",
"value": "{{example_song}}"
"value": "{{data.title1}}"
},
{
"key": "artist",
"value": "{{example_artist_2}}"
"value": "{{data.artist2}}"
}
]
}
@ -100,17 +103,17 @@
},
{
"key": "artist",
"value": "{{example_artist}}",
"value": "{{data.artist1}}",
"type": "text"
},
{
"key": "title",
"value": "{{example_song}}",
"value": "{{data.title1}}",
"type": "text"
},
{
"key": "artist",
"value": "{{example_artist_2}}",
"value": "{{data.artist2}}",
"type": "text"
}
]
@ -144,17 +147,17 @@
},
{
"key": "artist",
"value": "{{example_artist}}",
"value": "{{data.artist1}}",
"type": "text"
},
{
"key": "title",
"value": "{{example_song}}",
"value": "{{data.title1}}",
"type": "text"
},
{
"key": "artist",
"value": "{{example_artist_2}}",
"value": "{{data.artist2}}",
"type": "text"
}
]
@ -186,7 +189,7 @@
],
"body": {
"mode": "raw",
"raw": "{\n \"key\": \"{{api_key}}\",\n \"artist\": \"{{example_artist}}\",\n \"title\": \"{{example_song}}\"\n}"
"raw": "{\n \"key\": \"{{api_key}}\",\n \"artist\": \"{{data.artist1}}\",\n \"title\": \"{{data.title1}}\"\n}"
},
"url": {
"raw": "{{url}}/apis/mlj_1/newscrobble",
@ -216,7 +219,7 @@
],
"body": {
"mode": "raw",
"raw": "{\n \"key\": \"{{api_key}}\",\n \"artists\": [\"{{example_artist}}\",\"{{example_artist_2}}\"],\n \"title\": \"{{example_song}}\"\n}"
"raw": "{\n \"key\": \"{{api_key}}\",\n \"artists\": [\"{{data.artist1}}\",\"{{data.artist2}}\"],\n \"title\": \"{{data.title1}}\"\n}"
},
"url": {
"raw": "{{url}}/apis/mlj_1/newscrobble",
@ -246,7 +249,7 @@
],
"body": {
"mode": "raw",
"raw": "{\n \"key\": \"{{api_key}}\",\n \"artist\": \"{{example_artist}}\",\n \"title\": \"{{example_song}}\"\n}"
"raw": "{\n \"key\": \"{{api_key}}\",\n \"artist\": \"{{data.artist1}}\",\n \"title\": \"{{data.artist2}}\"\n}"
},
"url": {
"raw": "{{url}}/api/newscrobble",
@ -285,7 +288,7 @@
],
"body": {
"mode": "raw",
"raw": "{\n\t\"listen_type\":\"single\",\n\t\"payload\":[\n\t\t{\n\t\t\t\"track_metadata\":{\n\t\t\t\t\"artist_name\":\"{{example_artist}}\",\n\t\t\t\t\"track_name\":\"{{example_song}}\"\n\t\t\t}\n\t\t}\n\t]\n}"
"raw": "{\n\t\"listen_type\":\"single\",\n\t\"payload\":[\n\t\t{\n\t\t\t\"track_metadata\":{\n\t\t\t\t\"artist_name\":\"{{data.artist1}}\",\n\t\t\t\t\"track_name\":\"{{data.title1}}\"\n\t\t\t}\n\t\t}\n\t]\n}"
},
"url": {
"raw": "{{url}}/apis/listenbrainz/1/submit-listens",
@ -321,7 +324,7 @@
],
"body": {
"mode": "raw",
"raw": "{\n\t\"listen_type\":\"single\",\n\t\"payload\":[\n\t\t{\n\t\t\t\"track_metadata\":{\n\t\t\t\t\"artist_name\":\"{{example_artist}}\",\n\t\t\t\t\"track_name\":\"{{example_song}}\"\n\t\t\t}\n\t\t}\n\t]\n}"
"raw": "{\n\t\"listen_type\":\"single\",\n\t\"payload\":[\n\t\t{\n\t\t\t\"track_metadata\":{\n\t\t\t\t\"artist_name\":\"{{data.artist1}}\",\n\t\t\t\t\"track_name\":\"{{data.title1}}\"\n\t\t\t}\n\t\t}\n\t]\n}"
},
"url": {
"raw": "{{url}}/api/s/listenbrainz/1/submit-listens",
@ -378,7 +381,7 @@
],
"body": {
"mode": "raw",
"raw": "{\n\t\"method\":\"track.scrobble\",\n\t\"artist\":\"{{example_artist}}\",\n\t\"track\":\"{{example_song}}\",\n\t\"sk\":\"{{session_key}}\"\n}"
"raw": "{\n\t\"method\":\"track.scrobble\",\n\t\"artist\":\"{{data.artist1}}\",\n\t\"track\":\"{{data.title1}}\",\n\t\"sk\":\"{{session_key}}\"\n}"
},
"url": {
"raw": "{{url}}/apis/audioscrobbler/2.0/",
@ -420,7 +423,7 @@
],
"body": {
"mode": "raw",
"raw": "{\n\t\"method\":\"track.scrobble\",\n\t\"artist\":\"{{example_artist}}\",\n\t\"track\":\"{{example_song}}\",\n\t\"sk\":\"{{session_key}}\"\n}"
"raw": "{\n\t\"method\":\"track.scrobble\",\n\t\"artist\":\"{{data.artist1}}\",\n\t\"track\":\"{{data.title1}}\",\n\t\"sk\":\"{{session_key}}\"\n}"
},
"url": {
"raw": "{{url}}/api/s/audioscrobbler/2.0/",
@ -446,8 +449,7 @@
"script": {
"exec": [
"var data = JSON.parse(responseBody);",
"postman.setEnvironmentVariable(\"session_key\", data.session.key);",
"",
"pm.environment.set(\"session_key\", data.session.key);",
"tests[\"gotkey\"] = true;"
],
"type": "text/javascript"
@ -496,8 +498,9 @@
"script": {
"exec": [
"var data = responseBody.split(\"\\n\");",
"postman.setEnvironmentVariable(\"session_key\", data[1]);",
"postman.setEnvironmentVariable(\"scrobble_url\", data[3]);"
"",
"pm.environment.set(\"session_key\", data[1]);",
"pm.environment.set(\"scrobble_url\", data[3]);"
],
"type": "text/javascript"
}
@ -507,10 +510,10 @@
"script": {
"exec": [
"apikey = pm.variables.get(\"api_key\");",
"ts = pm.variables.get(\"timestamp\");",
"ts = pm.variables.get(\"data.timestamp1\");",
"",
"token = CryptoJS.MD5(CryptoJS.MD5(apikey) + ts)",
"postman.setEnvironmentVariable(\"legacy_token\", token);"
"token = CryptoJS.MD5(CryptoJS.MD5(apikey) + ts).toString()",
"pm.environment.set(\"legacy_token\", token);"
],
"type": "text/javascript"
}
@ -527,7 +530,7 @@
"raw": ""
},
"url": {
"raw": "{{url}}/apis/audioscrobbler_legacy/?hs=true&t={{timestamp}}&a={{legacy_token}}",
"raw": "{{url}}/apis/audioscrobbler_legacy/?hs=true&t={{data.timestamp1}}&a={{legacy_token}}",
"host": [
"{{url}}"
],
@ -543,7 +546,7 @@
},
{
"key": "t",
"value": "{{timestamp}}"
"value": "{{data.timestamp1}}"
},
{
"key": "a",
@ -560,7 +563,7 @@
"method": "GET",
"header": [],
"url": {
"raw": "{{scrobble_url}}?s={{session_key}}&a[0]={{example_artist}}&t[0]={{example_song}}&a[1]={{example_artist_2}}&t[1]={{example_song_2}}&i[0]={{timestamp}}&i[1]={{timestamp_2}}",
"raw": "{{scrobble_url}}?s={{session_key}}&a[0]={{data.artist1}}&t[0]={{data.title1}}&a[1]={{data.artist2}}&t[1]={{data.title2}}&i[0]={{data.timestamp1}}&i[1]={{data.timestamp2}}",
"host": [
"{{scrobble_url}}"
],
@ -571,27 +574,27 @@
},
{
"key": "a[0]",
"value": "{{example_artist}}"
"value": "{{data.artist1}}"
},
{
"key": "t[0]",
"value": "{{example_song}}"
"value": "{{data.title1}}"
},
{
"key": "a[1]",
"value": "{{example_artist_2}}"
"value": "{{data.artist2}}"
},
{
"key": "t[1]",
"value": "{{example_song_2}}"
"value": "{{data.title2}}"
},
{
"key": "i[0]",
"value": "{{timestamp}}"
"value": "{{data.timestamp1}}"
},
{
"key": "i[1]",
"value": "{{timestamp_2}}"
"value": "{{data.timestamp2}}"
}
]
}
@ -600,6 +603,210 @@
}
]
}
]
},
{
"name": "Metadata",
"item": [
{
"name": "Spotify",
"item": [
{
"name": "Authorize",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
"apiid = pm.collectionVariables.get(\"external.spotify.api_id\");",
"apisecret = pm.collectionVariables.get(\"external.spotify.api_secret\");",
"",
"authb64 = new Buffer(apiid + ':' + apisecret).toString('base64');",
"pm.environment.set(\"authb64\", authb64);",
""
],
"type": "text/javascript"
}
},
{
"listen": "test",
"script": {
"exec": [
"var data = JSON.parse(responseBody);",
"pm.collectionVariables.set(\"external.spotify.access_token\", data.access_token);"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Authorization",
"value": "Basic {{authb64}}",
"type": "text"
}
],
"body": {
"mode": "urlencoded",
"urlencoded": [
{
"key": "grant_type",
"value": "client_credentials",
"type": "text"
}
]
},
"url": {
"raw": "https://accounts.spotify.com/api/token",
"protocol": "https",
"host": [
"accounts",
"spotify",
"com"
],
"path": [
"api",
"token"
]
}
},
"response": []
},
{
"name": "Track Info Old",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "https://api.spotify.com/v1/search?type=track&access_token={{external.spotify.access_token}}&q=artist:{{data.artist3}} track:{{data.title3}}",
"protocol": "https",
"host": [
"api",
"spotify",
"com"
],
"path": [
"v1",
"search"
],
"query": [
{
"key": "type",
"value": "track"
},
{
"key": "access_token",
"value": "{{external.spotify.access_token}}"
},
{
"key": "q",
"value": "artist:{{data.artist3}} track:{{data.title3}}"
}
]
}
},
"response": []
},
{
"name": "Track Info New",
"request": {
"method": "GET",
"header": [
{
"key": "Authorization",
"value": "Bearer {{external.spotify.access_token}}",
"type": "text"
}
],
"url": {
"raw": "https://api.spotify.com/v1/search?type=track&q=artist:{{data.artist3}}%20track:{{data.title3}}",
"protocol": "https",
"host": [
"api",
"spotify",
"com"
],
"path": [
"v1",
"search"
],
"query": [
{
"key": "type",
"value": "track"
},
{
"key": "q",
"value": "artist:{{data.artist3}}%20track:{{data.title3}}"
}
]
}
},
"response": []
}
]
}
]
},
{
"name": "Scrobbleforward",
"item": [
{
"name": "Last.fm",
"item": [
{
"name": "Authorize",
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "urlencoded",
"urlencoded": []
},
"url": {
"raw": "https://ws.audioscrobbler.com/2.0/?method=auth.getMobileSession&username={{external.lastfm.username}}&password={{external.lastfm.password}}&api_key={{external.lastfm.api_key}}&api_sig=TODO",
"protocol": "https",
"host": [
"ws",
"audioscrobbler",
"com"
],
"path": [
"2.0",
""
],
"query": [
{
"key": "method",
"value": "auth.getMobileSession"
},
{
"key": "username",
"value": "{{external.lastfm.username}}"
},
{
"key": "password",
"value": "{{external.lastfm.password}}"
},
{
"key": "api_key",
"value": "{{external.lastfm.api_key}}"
},
{
"key": "api_sig",
"value": "TODO"
}
]
}
},
"response": []
}
]
}
]
}
],
"event": [
{
@ -608,8 +815,8 @@
"type": "text/javascript",
"exec": [
"var current_timestamp = Math.floor(Date.now() / 1000);",
"postman.setEnvironmentVariable(\"timestamp\", current_timestamp);",
"postman.setEnvironmentVariable(\"timestamp_2\", current_timestamp - 200);"
"pm.collectionVariables.set(\"data.timestamp1\", current_timestamp);",
"pm.collectionVariables.set(\"data.timestamp2\", current_timestamp);"
]
}
},
@ -633,20 +840,68 @@
"value": "localdevtestkey"
},
{
"key": "example_artist",
"key": "session_key",
"value": ""
},
{
"key": "data.artist1",
"value": "EXID ft. Jeremy Soule"
},
{
"key": "example_song",
"value": "Why is the Rum gone?"
},
{
"key": "example_artist_2",
"key": "data.artist2",
"value": "BLACKPINK ft. Tzuyu"
},
{
"key": "example_song_2",
"key": "data.artist3",
"value": "TWICE"
},
{
"key": "data.title1",
"value": "Why is the Rum gone?"
},
{
"key": "data.title2",
"value": "POP/STARS"
},
{
"key": "data.title3",
"value": "One in a Million"
},
{
"key": "data.timestamp1",
"value": ""
},
{
"key": "data.timestamp2",
"value": ""
},
{
"key": "external.spotify.api_id",
"value": ""
},
{
"key": "external.spotify.api_secret",
"value": ""
},
{
"key": "external.spotify.access_token",
"value": ""
},
{
"key": "external.lastfm.username",
"value": ""
},
{
"key": "external.lastfm.password",
"value": ""
},
{
"key": "external.lastfm.api_key",
"value": ""
},
{
"key": "external.lastfm.secret",
"value": ""
}
]
}