diff --git a/Makefile b/Makefile index f7bd534..bf37f76 100644 --- a/Makefile +++ b/Makefile @@ -126,6 +126,7 @@ test-http-client: /workdir/get_provider_settings.http \ /workdir/tunein_playback_station.http \ /workdir/set_preset_6.http \ + /workdir/set_preset_5.http \ /workdir/get_full_account.http \ /workdir/get_group.http \ /workdir/unregister_device.http \ diff --git a/tests/integration/http-client/http-client.env.json b/tests/integration/http-client/http-client.env.json index 3f6d75e..143edc1 100644 --- a/tests/integration/http-client/http-client.env.json +++ b/tests/integration/http-client/http-client.env.json @@ -11,7 +11,10 @@ "macAddress1": "B05ECAFE", "macAddress2": "B05ECAFF", "accountId": "7654321", - "deviceName": "SoundTouch-20" + "deviceName": "SoundTouch-11", + "spotifyUserId": "13570", + "spotifyToken": "example-spotify-token", + "spotifyDisplayName": "For Lovers, Not Killers" }, "ci": { "host": "http://soundtouch-service:8000", @@ -25,6 +28,9 @@ "macAddress1": "B05ECAFE", "macAddress2": "B05ECAFF", "accountId": "7654321", - "deviceName": "SoundTouch-20" + "deviceName": "SoundTouch-12", + "spotifyUserId": "13570", + "spotifyToken": "example-spotify-token", + "spotifyDisplayName": "For Lovers, Not Killers" } } diff --git a/tests/integration/http-client/set_preset_5.http b/tests/integration/http-client/set_preset_5.http new file mode 100644 index 0000000..4f9f7fd --- /dev/null +++ b/tests/integration/http-client/set_preset_5.http @@ -0,0 +1,57 @@ +### POST /streaming/account/{{accountId}}/source (Cloud Source Registration) +POST {{host}}/streaming/account/{{accountId}}/source +Host: streaming.bose.com +User-Agent: Bose_Lisa/27.0.6 +Accept: application/vnd.bose.streaming-v1.1+xml +Authorization: Bearer {{token}} +Content-Type: application/vnd.bose.streaming-v1.1+xml + +{{spotifyUserId}}15{{spotifyToken}}{{spotifyDisplayName}} + +> {% + client.test("Response is 201 Created", function() { + client.assert(response.status === 201, "Response status is not 201"); + }); + + client.test("Response body is a source", function() { + const doc = response.body; + const sourceID = doc.getElementsByTagName("sourceID")[0].textContent; + client.assert(sourceID !== "", "Response body does not contain a non-empty "); + client.global.set("sourceID", sourceID); + client.assert(doc.getElementsByTagName("sourceProviderID")[0].textContent === "15", "Response body does not contain 15"); + }); +%} + +### PUT /streaming/account/{{accountId}}/device/{{deviceId}}/preset/5 +PUT {{host}}/streaming/account/{{accountId}}/device/{{deviceId}}/preset/5 +Host: streaming.bose.com +User-Agent: Bose_Lisa/27.0.6 +Accept: application/vnd.bose.streaming-v1.2+xml +Authorization: Bearer {{token}} +Content-Type: application/vnd.bose.streaming-v1.2+xml + +{{sourceID}}For Lovers, Not KillersFor Lovers, Not Killers/playback/container/c3BvdGlmeTphbGJ1bTo0VUhYUkF3RWswbnQ1QjczNDlvSXVstracklisturl + +> {% + client.test("Response is 200 OK", function() { + client.assert(response.status === 200, "Response status is not 200"); + }); + + client.test("Response body is a preset", function() { + const doc = response.body; + const preset = doc.getElementsByTagName("preset")[0]; + + client.assert(preset.getAttribute("buttonNumber") === "5", "Response body does not contain buttonNumber=\"5\""); + client.assert(doc.getElementsByTagName("name")[0].textContent === "For Lovers, Not Killers", "Response body does not contain For Lovers, Not Killers"); + client.assert(doc.getElementsByTagName("location")[0].textContent === "/playback/container/c3BvdGlmeTphbGJ1bTo0VUhYUkF3RWswbnQ1QjczNDlvSXVs", "Response body does not contain ..."); + client.assert(doc.getElementsByTagName("contentItemType")[0].textContent === "tracklisturl", "Response body does not contain tracklisturl"); + + const source = doc.getElementsByTagName("source")[0]; + client.assert(source.getAttribute("id") === client.global.get("sourceID"), "Response body does not contain source id=\"" + client.global.get("sourceID") + "\""); + client.assert(source.getAttribute("type") === "Audio", "Response body does not contain source type=\"Audio\""); + client.assert(source.getAttribute("displayName") === null, "Response body should NOT contain displayName attribute in source"); + client.assert(doc.getElementsByTagName("sourceproviderid")[0].textContent === "15", "Response body does not contain 15"); + client.assert(source.getElementsByTagName("username")[0].textContent === "", "Response body does not contain empty in source, found: " + source.getElementsByTagName("username")[0].textContent); + client.assert(doc.getElementsByTagName("username")[1].textContent === "For Lovers, Not Killers", "Response body does not contain For Lovers, Not Killers in preset, found: " + doc.getElementsByTagName("username")[1].textContent); + }); +%}