loolwsd: test: update changes to WebSocketErrorMessageException
This commit is contained in:
parent
6388298a04
commit
0a92e02339
2 changed files with 21 additions and 13 deletions
|
@ -504,10 +504,8 @@ private:
|
|||
if (!child)
|
||||
{
|
||||
// Let the client know we can't serve now.
|
||||
status = "statusindicator: fail";
|
||||
ws->sendFrame(status.data(), (int) status.size());
|
||||
ws->shutdown();
|
||||
throw WebSocketException("Failed to get new child. Client cannot serve now.", WebSocket::WS_ENDPOINT_GOING_AWAY);
|
||||
Log::error("Failed to get new child. Client cannot serve now.");
|
||||
throw WebSocketErrorMessageException(SERVICE_UNAVALABLE_INTERNAL_ERROR);
|
||||
}
|
||||
|
||||
// Set one we just created.
|
||||
|
@ -685,7 +683,8 @@ public:
|
|||
{
|
||||
const std::string msg = std::string("error: ") + exc.what();
|
||||
ws->sendFrame(msg.data(), msg.size());
|
||||
ws->shutdown();
|
||||
// abnormal close frame handshake
|
||||
ws->shutdown(WebSocket::WS_ENDPOINT_GOING_AWAY, exc.what());
|
||||
}
|
||||
catch (const std::exception& exc2)
|
||||
{
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include <Common.hpp>
|
||||
#include <UserMessages.hpp>
|
||||
#include <Util.hpp>
|
||||
#include <LOOLProtocol.hpp>
|
||||
|
||||
|
@ -170,7 +171,7 @@ void HTTPWSTest::testBadRequest()
|
|||
session.setKeepAlive(true);
|
||||
session.sendRequest(request);
|
||||
session.receiveResponse(response);
|
||||
CPPUNIT_ASSERT(response.getStatus() == Poco::Net::HTTPResponse::HTTP_BAD_REQUEST);
|
||||
CPPUNIT_ASSERT(response.getStatus() == Poco::Net::HTTPResponse::HTTPResponse::HTTP_SERVICE_UNAVAILABLE);
|
||||
}
|
||||
catch (const Poco::Exception& exc)
|
||||
{
|
||||
|
@ -199,7 +200,7 @@ void HTTPWSTest::testHandShake()
|
|||
Poco::Net::WebSocket socket(session, request, response);
|
||||
|
||||
const std::string prefixEdit = "editlock:";
|
||||
const char* fail = "fail";
|
||||
const char* fail = "error:";
|
||||
std::string payload("statusindicator: find");
|
||||
|
||||
std::string receive;
|
||||
|
@ -233,18 +234,26 @@ void HTTPWSTest::testHandShake()
|
|||
}
|
||||
else
|
||||
{
|
||||
payload = "statusindicator: fail";
|
||||
CPPUNIT_ASSERT_EQUAL((int) payload.size(), bytes);
|
||||
CPPUNIT_ASSERT(payload.compare(0, payload.size(), buffer, 0, bytes) == 0);
|
||||
// check error message
|
||||
CPPUNIT_ASSERT(std::strstr(buffer, SERVICE_UNAVALABLE_INTERNAL_ERROR) != nullptr);
|
||||
CPPUNIT_ASSERT(flags == Poco::Net::WebSocket::FRAME_TEXT);
|
||||
|
||||
// close frame message
|
||||
bytes = socket.receiveFrame(buffer, sizeof(buffer), flags);
|
||||
CPPUNIT_ASSERT(std::strstr(buffer, SERVICE_UNAVALABLE_INTERNAL_ERROR) != nullptr);
|
||||
CPPUNIT_ASSERT((flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) == Poco::Net::WebSocket::FRAME_OP_CLOSE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
payload = "statusindicator: fail";
|
||||
CPPUNIT_ASSERT_EQUAL((int) payload.size(), bytes);
|
||||
CPPUNIT_ASSERT(payload.compare(0, payload.size(), buffer, 0, bytes) == 0);
|
||||
// check error message
|
||||
CPPUNIT_ASSERT(std::strstr(buffer, SERVICE_UNAVALABLE_INTERNAL_ERROR) != nullptr);
|
||||
CPPUNIT_ASSERT(flags == Poco::Net::WebSocket::FRAME_TEXT);
|
||||
|
||||
// close frame message
|
||||
bytes = socket.receiveFrame(buffer, sizeof(buffer), flags);
|
||||
CPPUNIT_ASSERT(std::strstr(buffer, SERVICE_UNAVALABLE_INTERNAL_ERROR) != nullptr);
|
||||
CPPUNIT_ASSERT((flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) == Poco::Net::WebSocket::FRAME_OP_CLOSE);
|
||||
}
|
||||
|
||||
socket.shutdown();
|
||||
|
|
Loading…
Reference in a new issue