Prepare http-client test for Amazon

This commit is contained in:
Tobias Gesellchen
2026-04-29 20:30:06 +02:00
parent 3e96e95a7d
commit 406180e4ce
3 changed files with 49 additions and 0 deletions
+1
View File
@@ -135,6 +135,7 @@ test-http-client:
/workdir/get_soundtouch_updates.http \
/workdir/get_streaming_token.http \
/workdir/post_oauth_token.http \
/workdir/post_oauth_token_amazon.http \
/workdir/get_provider_settings.http \
/workdir/tunein_playback_station.http \
/workdir/set_preset_6.http \
@@ -17,6 +17,8 @@
"spotifyToken": "example-spotify-token",
"spotifyRefreshToken": "example-spotify-refresh-token",
"spotifyDisplayName": "For Lovers, Not Killers",
"amazonProviderID": "20",
"amazonRefreshToken": "example-amazon-refresh-token",
"bmxApiKey": "bmx-api-key",
"qplayProviderID": "26"
},
@@ -38,6 +40,8 @@
"spotifyToken": "example-spotify-token",
"spotifyRefreshToken": "example-spotify-refresh-token",
"spotifyDisplayName": "For Lovers, Not Killers",
"amazonProviderID": "20",
"amazonRefreshToken": "example-amazon-refresh-token",
"bmxApiKey": "bmx-api-key",
"qplayProviderID": "26"
}
@@ -0,0 +1,44 @@
### POST /oauth/device/{{deviceId}}/music/musicprovider/20/token/cs1
# Mirrors the exact request the SoundTouch firmware makes when it needs a fresh Amazon access token.
# The speaker extracts the bare refresh_token from its stored AmazonSecret JSON and sends it here.
# Log reference: STSOAuth2::ConstructPostDataString — grant_type=refresh_token, code and redirect_uri are always empty.
POST {{host}}/oauth/device/{{deviceId}}/music/musicprovider/20/token/cs1
Authorization: Bearer {{token}}
Content-Type: application/json
{
"code": "",
"grant_type": "refresh_token",
"redirect_uri": "",
"refresh_token": "{{amazonRefreshToken}}"
}
> {%
// TODO: upgrade to 200 + JSON structure assertions once the Amazon service is implemented
// and a mock Amazon OAuth server is wired into the CI docker-compose (mirroring spotify-mock).
client.test("Route is registered (stub returns 501, not 404)", function() {
client.assert(response.status === 501, "Expected 501 Not Implemented from stub, got " + response.status);
});
// client.test("Request executed successfully", function() {
// client.assert(response.status === 200, "Response status is not 200");
// });
// client.test("Response content type is JSON", function() {
// var type = response.contentType.mimeType;
// client.assert(type === "application/json", "Expected 'application/json' but received '" + type + "'");
// });
// client.test("Response body has expected structure", function() {
// client.assert(response.body.hasOwnProperty("access_token"), "Response body missing 'access_token'");
// client.assert(response.body.access_token.length > 0, "access_token is empty");
//
// client.assert(response.body.hasOwnProperty("expires_in"), "Response body missing 'expires_in'");
// client.assert(typeof response.body.expires_in === "number", "expires_in is not a number");
//
// client.assert(response.body.hasOwnProperty("token_type"), "Response body missing 'token_type'");
// client.assert(response.body.token_type === "Bearer", "token_type is not 'Bearer'");
//
// // Amazon omits 'scope' — do not assert its presence.
// });
%}