realm / realm-core

Core database component for the Realm Mobile Database SDKs

Home Page:https://realm.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add back missing test for 4003 "moved permanently" websocket response from server

sync-by-unito opened this issue · comments

The latest updates to App and the app tests in Core master has removed the old testing for both a HTTP 308 and websocket 4003 error responses and only tests the HTTP 308 response. Update this test to include both types of return values from the server.

Original test:

redir_provider->websocket_connect_func = [&logger,
&connect_count]() -> std::optional<SocketProviderError> {
logger->trace("websocket connect (%1)", ++connect_count);
if (connect_count == 1)
return SocketProviderError(sync::HTTPStatus::PermanentRedirect);
if (connect_count == 2)
return SocketProviderError(sync::websocket::WebSocketError::websocket_moved_permanently);
return std::nullopt;
};

    redir_provider->websocket_connect_func = [&logger, &connect_count]() -> std::optional<SocketProviderError> {
        logger->trace("websocket connect (%1)", ++connect_count);
        if (connect_count == 1)
            return SocketProviderError(sync::HTTPStatus::PermanentRedirect);
        if (connect_count == 2)
            return SocketProviderError(sync::websocket::WebSocketError::websocket_moved_permanently);
        return std::nullopt;
    };

Updated test: https://github.com/realm/realm-core/blob/master/test/object-store/sync/app.cpp#L3462-L3470

    socket_provider->websocket_connect_func = [&]() -> std::optional<SocketProviderError> {
        // Report a 308 response the first time we try to reconnect the websocket,
        // which should result in App performing a location update.
        // The actual Location header isn't used when we get a redirect on
        // the websocket, so we don't need to supply it here
        if (connect_count++ > 0)
            return std::nullopt;
        return sync::HTTPStatus::PermanentRedirect;
    };

➤ PM Bot commented:

Jira ticket: RCORE-2095

➤ michael-wb commented:

As a result of BAAS-31713, the 4003 redirect response for a websocket is going to be updated to be a 308 response when the initial "websocket connect" HTTP request is sent to the server. This test will need to validate that operation on the client.