From 406180e4ce45653bce9153529f04d8d507e81f7f Mon Sep 17 00:00:00 2001 From: Tobias Gesellchen Date: Tue, 28 Apr 2026 22:05:09 +0200 Subject: [PATCH] Prepare http-client test for Amazon --- Makefile | 1 + .../http-client/http-client.env.json | 4 ++ .../http-client/post_oauth_token_amazon.http | 44 +++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 tests/integration/http-client/post_oauth_token_amazon.http diff --git a/Makefile b/Makefile index 45fe72f..12522f0 100644 --- a/Makefile +++ b/Makefile @@ -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 \ diff --git a/tests/integration/http-client/http-client.env.json b/tests/integration/http-client/http-client.env.json index f477678..36355c1 100644 --- a/tests/integration/http-client/http-client.env.json +++ b/tests/integration/http-client/http-client.env.json @@ -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" } diff --git a/tests/integration/http-client/post_oauth_token_amazon.http b/tests/integration/http-client/post_oauth_token_amazon.http new file mode 100644 index 0000000..834a2c0 --- /dev/null +++ b/tests/integration/http-client/post_oauth_token_amazon.http @@ -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. + // }); +%}