Adapting html interface to zeroeq changes#128
Conversation
| core/JsonOptionsTests.cpp | ||
| core/LoggingUtilityTest.cpp | ||
| core/RestCommandTests.cpp | ||
| core/RestWindowsTests.cpp |
| , _contentFilters( filters ) | ||
| { | ||
| } | ||
| #define BOOST_TEST_MODULE WebInterfaceTest |
|
|
||
| auto future = windowsContent.getWindowInfo( std::string(), std::string( )); | ||
| auto response = future.get(); | ||
| BOOST_CHECK( response.code == 200 ); |
There was a problem hiding this comment.
prefer BOOST_CHECK_EQUAL( a, b ) when comparing two values
|
|
||
| const auto uuid = window->getID().toString().replace( _regex, "" ); | ||
|
|
||
| sleep(2); |
| ContentWindowPtr window( new ContentWindow( content )); | ||
| displayGroup->addContentWindow( window ); | ||
|
|
||
| auto future = windowsContent.getWindowInfo( std::string(), std::string( )); |
There was a problem hiding this comment.
also check the payload and headers (content type) for all requests
| const auto url = _getThumbnailUri( *window ); | ||
| const QString uri = window->getContent().get()->getURI(); | ||
| _httpServer.handleGET(url.toStdString(), [uri] () | ||
| QtConcurrent::run( QThreadPool::globalInstance(), |
There was a problem hiding this comment.
I think that QThreadPool::globalInstance() is the default, it can be omitted (also remove the include)
| QtConcurrent::run( QThreadPool::globalInstance(), | ||
| [this, window]() | ||
| { | ||
| const QString& uri = window->getContent().get()->getURI(); |
| #define RESTWINDOWS_H | ||
|
|
||
| #include <servus/serializable.h> // base class | ||
| #include "zeroeq/http/response.h" |
There was a problem hiding this comment.
use <> for non-local includes and move after local includes
| /** @return the string used as an endpoint by REST interface. */ | ||
| std::string getTypeName() const final; | ||
| /** | ||
| * Expose the list of windows to REST Interface |
There was a problem hiding this comment.
update comment, add name and doc to the two parameters
| */ | ||
| RestWindows( zeroeq::http::Server& server, | ||
| const DisplayGroup& displayGroup ); | ||
| RestWindows( const DisplayGroup& displayGroup ); |
There was a problem hiding this comment.
update doc, server was removed from the params
| DisplayGroupPtr displayGroup( new DisplayGroup( wallSize )); | ||
| FileReceiver fileReceiver; | ||
|
|
||
| bool open; |
There was a problem hiding this comment.
= false, otherwise the check is unpredictable ;-)
| response = future.get(); | ||
| BOOST_CHECK( response.payload == _getThumbnail() ); | ||
| BOOST_CHECK( response.code == 200 ); | ||
| BOOST_CHECK_EQUAL( response.code, 204 ); |
There was a problem hiding this comment.
shouldn't it be a 404 for a window that has been removed? Otherwise the client will keep asking for it?
| auto filePath = QString::fromStdString( path ); | ||
| if( !_preparedPaths.contains( filePath )) | ||
| return _makeResponse( http::Code::FORBIDDEN, "info", | ||
| "uploaded not prepared" ); |
| const std::string& payload ) | ||
| { | ||
|
|
||
| auto filePath = QString::fromStdString( path ); |
| const bool success = openPromise->get_future().get(); | ||
|
|
||
| _server.remove( "tide/upload/" + path ); | ||
| _preparedPaths.removeOne( filePath ); |
There was a problem hiding this comment.
can be moved right after file.close(), no need to wait for open() to succeed if it is removed always
| * Expose the content of a directory to REST Interface | ||
| * List the content of a directory to be exposed to REST Interface | ||
| * | ||
| * @param pathPoint the path of a directory to list |
| const auto endpointSplit = endpoint.split( "/" ); | ||
| if( endpointSplit.size() == 2 && endpointSplit[1] == "thumbnail") | ||
| { | ||
| const auto uuid = endpointSplit[0]; |
| /** | ||
| * Expose the list of windows to REST Interface | ||
| * | ||
| * @param path the url part including window uuid and action |
| QFile file( imageUri ); | ||
| file.open( QIODevice::ReadOnly ); | ||
| auto payload = file.readAll().toStdString(); | ||
|
|
There was a problem hiding this comment.
you could also already check that open is false until here:
BOOST_REQUIRE_EQUAL( open, false );
| /** | ||
| * Prepare an upload of a file via REST Interface. | ||
| * | ||
| * @param payload the name of a file client wants to upload. |
44dd10b to
f8e8fd8
Compare
1d98dad to
e3dbe6a
Compare
e3dbe6a to
551172b
Compare
|
still need to fix travis build: https://travis-ci.org/BlueBrain/Tide/jobs/218908492 |
72887b2 to
aff37ee
Compare
No description provided.