|
|
|
@@ -21,6 +21,9 @@
|
|
|
|
|
|
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
|
|
|
|
|
#include "core/String.hpp"
|
|
|
|
|
#include "core/Version.hpp"
|
|
|
|
|
|
|
|
|
|
#include "ProtocolVersion.hpp"
|
|
|
|
|
#include "SubsonicResponse.hpp"
|
|
|
|
|
|
|
|
|
@@ -58,12 +61,15 @@ namespace lms::api::subsonic::tests
|
|
|
|
|
|
|
|
|
|
TEST(SubsonicResponse, emptyJson)
|
|
|
|
|
{
|
|
|
|
|
Response response{ Response::createOkResponse(ProtocolVersion{ 1, 16, 0 }) };
|
|
|
|
|
Response response{ Response::createOkResponse(defaultServerProtocolVersion) };
|
|
|
|
|
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
response.write(oss, ResponseFormat::json);
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(oss.str(), R"({"subsonic-response":{"openSubsonic":true,"serverVersion":"v3.72.0","status":"ok","type":"lms","version":"1.16.0"}})");
|
|
|
|
|
std::string expected{ R"({"subsonic-response":{"openSubsonic":true,"serverVersion":"${VERSION}","status":"ok","type":"lms","version":"1.16.1"}})" };
|
|
|
|
|
expected = core::stringUtils::replaceInString(expected, "${VERSION}", core::getVersion());
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(oss.str(), expected);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST(SubsonicResponse, json)
|
|
|
|
@@ -73,18 +79,24 @@ namespace lms::api::subsonic::tests
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
response.write(oss, ResponseFormat::json);
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(oss.str(), R"({"subsonic-response":{"openSubsonic":true,"serverVersion":"v3.72.0","status":"ok","type":"lms","version":"1.16.0","MyNode":{"Attr1":"value1","Attr2":"value2","attr3":"<value3=\"foo\">","attr4":true,"attr5":false,"attr6":3.14159,"attr7":333666,"MyArrayChild":[{"Attr42":0},{"Attr42":1}],"MyArray1":["value1","value2","value1","value2"],"MyArray2":[0]}}})");
|
|
|
|
|
std::string expected{ R"({"subsonic-response":{"openSubsonic":true,"serverVersion":"${VERSION}","status":"ok","type":"lms","version":"1.16.1","MyNode":{"Attr1":"value1","Attr2":"value2","attr3":"<value3=\"foo\">","attr4":true,"attr5":false,"attr6":3.14159,"attr7":333666,"MyArrayChild":[{"Attr42":0},{"Attr42":1}],"MyArray1":["value1","value2","value1","value2"],"MyArray2":[0]}}})" };
|
|
|
|
|
expected = core::stringUtils::replaceInString(expected, "${VERSION}", core::getVersion());
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(oss.str(), expected);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST(SubsonicResponse, emptyXml)
|
|
|
|
|
{
|
|
|
|
|
Response response{ Response::createOkResponse(ProtocolVersion{ 1, 16, 0 }) };
|
|
|
|
|
Response response{ Response::createOkResponse(defaultServerProtocolVersion) };
|
|
|
|
|
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
response.write(oss, ResponseFormat::xml);
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(oss.str(), R"(<?xml version="1.0" encoding="utf-8"?>
|
|
|
|
|
<subsonic-response openSubsonic="true" serverVersion="v3.72.0" status="ok" type="lms" version="1.16.0" xmlns="http://subsonic.org/restapi"/>)");
|
|
|
|
|
std::string expected{ R"(<?xml version="1.0" encoding="utf-8"?>
|
|
|
|
|
<subsonic-response openSubsonic="true" serverVersion="${VERSION}" status="ok" type="lms" version="1.16.1" xmlns="http://subsonic.org/restapi"/>)" };
|
|
|
|
|
expected = core::stringUtils::replaceInString(expected, "${VERSION}", core::getVersion());
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(oss.str(), expected);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST(SubsonicResponse, xml)
|
|
|
|
@@ -94,8 +106,11 @@ namespace lms::api::subsonic::tests
|
|
|
|
|
std::ostringstream oss;
|
|
|
|
|
response.write(oss, ResponseFormat::xml);
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(oss.str(), R"(<?xml version="1.0" encoding="utf-8"?>
|
|
|
|
|
<subsonic-response openSubsonic="true" serverVersion="v3.72.0" status="ok" type="lms" version="1.16.0" xmlns="http://subsonic.org/restapi"><MyNode Attr1="value1" Attr2="value2" attr3="<value3="foo">" attr4="true" attr5="false" attr6="3.14159" attr7="333666"><MyArrayChild Attr42="0"/><MyArrayChild Attr42="1"/><MyArray1>value1</MyArray1><MyArray1>value2</MyArray1><MyArray1>value1</MyArray1><MyArray1>value2</MyArray1><MyArray2>0</MyArray2></MyNode></subsonic-response>)");
|
|
|
|
|
std::string expected{ R"(<?xml version="1.0" encoding="utf-8"?>
|
|
|
|
|
<subsonic-response openSubsonic="true" serverVersion="${VERSION}" status="ok" type="lms" version="1.16.1" xmlns="http://subsonic.org/restapi"><MyNode Attr1="value1" Attr2="value2" attr3="<value3="foo">" attr4="true" attr5="false" attr6="3.14159" attr7="333666"><MyArrayChild Attr42="0"/><MyArrayChild Attr42="1"/><MyArray1>value1</MyArray1><MyArray1>value2</MyArray1><MyArray1>value1</MyArray1><MyArray1>value2</MyArray1><MyArray2>0</MyArray2></MyNode></subsonic-response>)" };
|
|
|
|
|
expected = core::stringUtils::replaceInString(expected, "${VERSION}", core::getVersion());
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(oss.str(), expected);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace lms::api::subsonic::tests
|
|
|
|
|