From 9704e2d8ac14ce8a9b30da9ea11326545eba6d32 Mon Sep 17 00:00:00 2001 From: Tobias Gesellchen Date: Fri, 17 Apr 2026 23:15:52 +0200 Subject: [PATCH] Make the get_full_account test more comprehensive (#171) https://github.com/gesellix/Bose-SoundTouch/issues/135 --- .../http-client/customer_support.http | 1 - .../http-client/delete_preset_6.http | 1 - .../http-client/get_full_account.http | 46 +++++++++++++++---- tests/integration/http-client/get_group.http | 1 - .../integration/http-client/get_presets.http | 1 - .../http-client/get_provider_settings.http | 1 - tests/integration/http-client/power_on.http | 1 - .../integration/http-client/set_preset_5.http | 2 - .../integration/http-client/set_preset_6.http | 1 - .../http-client/tunein_playback_station.http | 3 -- 10 files changed, 37 insertions(+), 21 deletions(-) diff --git a/tests/integration/http-client/customer_support.http b/tests/integration/http-client/customer_support.http index 37dfe58..a473f67 100644 --- a/tests/integration/http-client/customer_support.http +++ b/tests/integration/http-client/customer_support.http @@ -1,6 +1,5 @@ ### POST /streaming/support/customersupport POST {{host}}/streaming/support/customersupport -Host: streaming.bose.com Content-Type: application/vnd.bose.streaming-v1.2+xml User-Agent: Bose_Lisa/27.0.6 Accept: application/vnd.bose.streaming-v1.2+xml diff --git a/tests/integration/http-client/delete_preset_6.http b/tests/integration/http-client/delete_preset_6.http index f0f55a8..58f6a6c 100644 --- a/tests/integration/http-client/delete_preset_6.http +++ b/tests/integration/http-client/delete_preset_6.http @@ -1,6 +1,5 @@ ### DELETE /streaming/account/{{accountId}}/device/{{deviceId}}/preset/6 DELETE {{host}}/streaming/account/{{accountId}}/device/{{deviceId}}/preset/6 -Host: streaming.bose.com Accept: application/vnd.bose.streaming-v1.2+xml Authorization: Bearer {{token}} Content-Type: application/vnd.bose.streaming-v1.2+xml diff --git a/tests/integration/http-client/get_full_account.http b/tests/integration/http-client/get_full_account.http index 4149273..bae1273 100644 --- a/tests/integration/http-client/get_full_account.http +++ b/tests/integration/http-client/get_full_account.http @@ -1,22 +1,50 @@ ### GET /streaming/account/{{accountId}}/full GET {{host}}/streaming/account/{{accountId}}/full -Host: streaming.bose.com -Authorization: Bearer {{token}} -Content-Type: application/vnd.bose.streaming-v1.2+xml User-Agent: Bose_Lisa/27.0.6 Accept: application/vnd.bose.streaming-v1.2+xml +Authorization: Bearer {{token}} > {% client.test("Request executed successfully", function() { client.assert(response.status === 200, "Response status is not 200"); - client.assert(response.contentType.mimeType === "application/vnd.bose.streaming-v1.2+xml", "Expected 'application/vnd.bose.streaming-v1.2+xml' but received '" + response.contentType.mimeType + "'"); }); - client.test("Response body contains ", function() { - const expectedAccountId = client.variables.environment.get("accountId"); - const doc = response.body; - const account = doc.getElementsByTagName("account")[0]; - client.assert(account !== undefined, "Response body does not contain "); + client.test("Response content-type is correct", function() { + var type = response.contentType.mimeType; + client.assert(type === "application/vnd.bose.streaming-v1.2+xml", "Expected 'application/vnd.bose.streaming-v1.2+xml' but received '" + type + "'"); + }); + + client.test("Response body structure", function() { + var account = response.body.getElementsByTagName("account")[0]; + client.assert(account !== null, "Missing 'account' root element"); + // We use accountId from environment variables + var expectedAccountId = client.variables.environment.get("accountId"); client.assert(account.getAttribute("id") === expectedAccountId, "Expected account id '" + expectedAccountId + "' but received '" + account.getAttribute("id") + "'"); + + var accountStatus = account.getElementsByTagName("accountStatus")[0]; + client.assert(accountStatus.textContent === "OK", "Account status is not OK"); + + var devices = account.getElementsByTagName("devices")[0]; + client.assert(devices !== null, "Missing 'devices' element"); + + var deviceList = devices.getElementsByTagName("device"); + client.assert(deviceList.length > 0, "No 'device' elements found"); + + var firstDevice = deviceList[0]; + client.assert(firstDevice.getAttribute("deviceid").length > 0, "Missing deviceid attribute"); + + var attachedProduct = firstDevice.getElementsByTagName("attachedProduct")[0]; + client.assert(attachedProduct !== null, "Missing 'attachedProduct'"); + client.assert(attachedProduct.getAttribute("product_code").length > 0, "Missing product_code"); + + var presets = firstDevice.getElementsByTagName("presets")[0]; + client.assert(presets !== undefined, "Missing 'presets' element"); + + var recents = firstDevice.getElementsByTagName("recents")[0]; + client.assert(recents !== undefined, "Missing 'recents' element"); + + var sources = account.getElementsByTagName("sources")[0]; + client.assert(sources !== null, "Missing 'sources' element"); + client.assert(sources.getElementsByTagName("source").length > 0, "No 'source' elements found in account sources"); }); %} diff --git a/tests/integration/http-client/get_group.http b/tests/integration/http-client/get_group.http index f4a2d5b..c00df56 100644 --- a/tests/integration/http-client/get_group.http +++ b/tests/integration/http-client/get_group.http @@ -1,6 +1,5 @@ ### GET /streaming/account/{{accountId}}/device/{{deviceId}}/group/ GET {{host}}/streaming/account/{{accountId}}/device/{{deviceId}}/group/ -Host: streaming.bose.com Content-Type: application/vnd.bose.streaming-v1.2+xml User-Agent: Bose_Lisa/27.0.6 Accept: application/vnd.bose.streaming-v1.2+xml diff --git a/tests/integration/http-client/get_presets.http b/tests/integration/http-client/get_presets.http index 3d3a402..f39009a 100644 --- a/tests/integration/http-client/get_presets.http +++ b/tests/integration/http-client/get_presets.http @@ -1,6 +1,5 @@ ### GET /streaming/account/{{accountId}}/device/{{deviceId}}/presets GET {{host}}/streaming/account/{{accountId}}/device/{{deviceId}}/presets -Host: streaming.bose.com Accept: application/vnd.bose.streaming-v1.2+xml Authorization: Bearer {{token}} Content-Type: application/vnd.bose.streaming-v1.2+xml diff --git a/tests/integration/http-client/get_provider_settings.http b/tests/integration/http-client/get_provider_settings.http index b469b04..abcfc3b 100644 --- a/tests/integration/http-client/get_provider_settings.http +++ b/tests/integration/http-client/get_provider_settings.http @@ -1,6 +1,5 @@ ### GET /streaming/account/{{accountId}}/provider_settings GET {{host}}/streaming/account/{{accountId}}/provider_settings -Host: streaming.bose.com Accept: application/vnd.bose.streaming-v1.2+xml Authorization: Bearer {{token}} Content-Type: application/vnd.bose.streaming-v1.2+xml diff --git a/tests/integration/http-client/power_on.http b/tests/integration/http-client/power_on.http index 8c45d4d..63d9511 100644 --- a/tests/integration/http-client/power_on.http +++ b/tests/integration/http-client/power_on.http @@ -1,6 +1,5 @@ ### POST /streaming/support/power_on POST {{host}}/streaming/support/power_on -Host: streaming.bose.com User-Agent: Bose_Lisa/27.0.6 Accept: application/vnd.bose.streaming-v1.2+xml Authorization: Bearer {{token}} diff --git a/tests/integration/http-client/set_preset_5.http b/tests/integration/http-client/set_preset_5.http index 191a6a7..f0a9ba5 100644 --- a/tests/integration/http-client/set_preset_5.http +++ b/tests/integration/http-client/set_preset_5.http @@ -1,6 +1,5 @@ ### 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}} @@ -25,7 +24,6 @@ Content-Type: application/vnd.bose.streaming-v1.1+xml ### 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}} diff --git a/tests/integration/http-client/set_preset_6.http b/tests/integration/http-client/set_preset_6.http index 4f4e9e9..8e895c5 100644 --- a/tests/integration/http-client/set_preset_6.http +++ b/tests/integration/http-client/set_preset_6.http @@ -1,6 +1,5 @@ ### PUT /streaming/account/{{accountId}}/device/{{deviceId}}/preset/6 PUT {{host}}/streaming/account/{{accountId}}/device/{{deviceId}}/preset/6 -Host: streaming.bose.com User-Agent: Bose_Lisa/27.0.6 Accept: application/vnd.bose.streaming-v1.2+xml Authorization: Bearer {{token}} diff --git a/tests/integration/http-client/tunein_playback_station.http b/tests/integration/http-client/tunein_playback_station.http index 77985ad..e8a5c52 100644 --- a/tests/integration/http-client/tunein_playback_station.http +++ b/tests/integration/http-client/tunein_playback_station.http @@ -1,6 +1,5 @@ ### GET /bmx/tunein/v1/playback/station/_station_ GET {{host}}/bmx/tunein/v1/playback/station/_station_ -Host: content.api.bose.io Accept: */* Accept-Language: en X-Bmx-Api-Key: bmx-api-key-dummy @@ -20,7 +19,6 @@ User-Agent: Bose_Lisa/27.0.6 ### POST /bmx/tunein/v1/token POST {{host}}/bmx/tunein/v1/token -Host: content.api.bose.io User-Agent: Bose_Lisa/27.0.6 Accept: */* Accept-Language: en @@ -45,7 +43,6 @@ Content-Type: application/json ### GET /bmx/tunein/v1/playback/station/_station_ (Authorized) GET {{host}}/bmx/tunein/v1/playback/station/_station_ -Host: content.api.bose.io User-Agent: Bose_Lisa/27.0.6 Accept: */* Accept-Language: en