summaryrefslogtreecommitdiff
path: root/indra/llmessage/tests
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llmessage/tests')
-rwxr-xr-xindra/llmessage/tests/llcurl_stub.cpp59
-rwxr-xr-xindra/llmessage/tests/llhttpclient_test.cpp33
-rwxr-xr-xindra/llmessage/tests/llhttpclientadapter_test.cpp81
-rw-r--r--indra/llmessage/tests/llhttpnode_stub.cpp112
-rwxr-xr-xindra/llmessage/tests/llmime_test.cpp445
-rwxr-xr-xindra/llmessage/tests/llregionpresenceverifier_test.cpp108
-rwxr-xr-xindra/llmessage/tests/lltrustedmessageservice_test.cpp1
7 files changed, 234 insertions, 605 deletions
diff --git a/indra/llmessage/tests/llcurl_stub.cpp b/indra/llmessage/tests/llcurl_stub.cpp
index 9b298d0c04..b7fdf4f437 100755
--- a/indra/llmessage/tests/llcurl_stub.cpp
+++ b/indra/llmessage/tests/llcurl_stub.cpp
@@ -24,55 +24,76 @@
* $/LicenseInfo$
*/
+#ifndef LL_CURL_STUB_CPP
+#define LL_CURL_STUB_CPP
+
+
#include "linden_common.h"
#include "llcurl.h"
+#include "llhttpconstants.cpp"
LLCurl::Responder::Responder()
{
}
-void LLCurl::Responder::completed(U32 status, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const &reason,
- LLSD const& mContent)
+void LLCurl::Responder::httpCompleted()
{
- if (isGoodStatus(status))
+ if (isGoodStatus())
{
- result(mContent);
+ httpSuccess();
}
else
{
- errorWithContent(status, reason, mContent);
+ httpFailure();
}
}
-void LLCurl::Responder::completedHeader(unsigned,
- std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&,
- LLSD const&)
+void LLCurl::Responder::completedRaw(LLChannelDescriptors const&,
+ boost::shared_ptr<LLBufferArray> const&)
{
}
-void LLCurl::Responder::completedRaw(unsigned,
- std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&,
- LLChannelDescriptors const&,
- boost::shared_ptr<LLBufferArray> const&)
+void LLCurl::Responder::httpFailure()
{
}
-void LLCurl::Responder::errorWithContent(unsigned,
- std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&,
- LLSD const&)
+LLCurl::Responder::~Responder ()
{
}
-LLCurl::Responder::~Responder ()
+void LLCurl::Responder::httpSuccess()
+{
+}
+
+std::string LLCurl::Responder::dumpResponse() const
+{
+ return "dumpResponse()";
+}
+
+void LLCurl::Responder::successResult(const LLSD& content)
{
+ setResult(HTTP_OK, "", content);
+ httpSuccess();
}
-void LLCurl::Responder::error(unsigned,
- std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
+void LLCurl::Responder::failureResult(S32 status, const std::string& reason, const LLSD& content)
+{
+ setResult(status, reason, content);
+ httpFailure();
+}
+
+
+void LLCurl::Responder::completeResult(S32 status, const std::string& reason, const LLSD& content)
{
+ setResult(status, reason, content);
+ httpCompleted();
}
-void LLCurl::Responder::result(LLSD const&)
+void LLCurl::Responder::setResult(S32 status, const std::string& reason, const LLSD& content /* = LLSD() */)
{
+ mStatus = status;
+ mReason = reason;
+ mContent = content;
}
+#endif
diff --git a/indra/llmessage/tests/llhttpclient_test.cpp b/indra/llmessage/tests/llhttpclient_test.cpp
index 87cbafa404..43fac83c57 100755
--- a/indra/llmessage/tests/llhttpclient_test.cpp
+++ b/indra/llmessage/tests/llhttpclient_test.cpp
@@ -40,8 +40,6 @@
#include "llproxy.h"
#include "llpumpio.h"
-#include "llsdhttpserver.h"
-#include "lliohttpserver.h"
#include "lliosocket.h"
#include "stringize.h"
@@ -101,7 +99,7 @@ namespace tut
if (mSawError)
{
std::string msg =
- llformat("error() called when not expected, status %d",
+ llformat("httpFailure() called when not expected, status %d",
mStatus);
fail(msg);
}
@@ -111,7 +109,7 @@ namespace tut
{
if (!mSawError)
{
- fail("error() wasn't called");
+ fail("httpFailure() wasn't called");
}
}
@@ -153,33 +151,26 @@ namespace tut
mClient.mResultDeleted = true;
}
- virtual void error(U32 status, const std::string& reason)
+ protected:
+ virtual void httpFailure()
{
mClient.mSawError = true;
- mClient.mStatus = status;
- mClient.mReason = reason;
+ mClient.mStatus = getStatus();
+ mClient.mReason = getReason();
}
- virtual void result(const LLSD& content)
+ virtual void httpSuccess()
{
- mClient.mResult = content;
+ mClient.mResult = getContent();
}
- virtual void completed(
- U32 status, const std::string& reason,
- const LLSD& content)
+ virtual void httpCompleted()
{
- LLHTTPClient::Responder::completed(status, reason, content);
-
+ LLHTTPClient::Responder::httpCompleted();
+
mClient.mSawCompleted = true;
- }
-
- virtual void completedHeader(
- U32 status, const std::string& reason,
- const LLSD& content)
- {
- mClient.mHeader = content;
mClient.mSawCompletedHeader = true;
+ mClient.mHeader = getResponseHeaders();
}
private:
diff --git a/indra/llmessage/tests/llhttpclientadapter_test.cpp b/indra/llmessage/tests/llhttpclientadapter_test.cpp
index 13ce0a0edd..cc7feeab4f 100755
--- a/indra/llmessage/tests/llhttpclientadapter_test.cpp
+++ b/indra/llmessage/tests/llhttpclientadapter_test.cpp
@@ -1,6 +1,6 @@
/**
- * @file
- * @brief
+ * @file llhttpclientadapter_test.cpp
+ * @brief Tests for LLHTTPClientAdapter
*
* $LicenseInfo:firstyear=2008&license=viewerlgpl$
* Second Life Viewer Source Code
@@ -33,8 +33,8 @@
float const HTTP_REQUEST_EXPIRY_SECS = 1.0F;
std::vector<std::string> get_urls;
-std::vector<boost::intrusive_ptr<LLCurl::Responder> > get_responders;
-void LLHTTPClient::get(const std::string& url, boost::intrusive_ptr<LLCurl::Responder> responder, const LLSD& headers, const F32 timeout)
+std::vector< LLCurl::ResponderPtr > get_responders;
+void LLHTTPClient::get(const std::string& url, LLCurl::ResponderPtr responder, const LLSD& headers, const F32 timeout)
{
get_urls.push_back(url);
get_responders.push_back(responder);
@@ -42,16 +42,30 @@ void LLHTTPClient::get(const std::string& url, boost::intrusive_ptr<LLCurl::Resp
std::vector<std::string> put_urls;
std::vector<LLSD> put_body;
-std::vector<boost::intrusive_ptr<LLCurl::Responder> > put_responders;
+std::vector<LLSD> put_headers;
+std::vector<LLCurl::ResponderPtr> put_responders;
-void LLHTTPClient::put(const std::string& url, const LLSD& body, boost::intrusive_ptr<LLCurl::Responder> responder, const LLSD& headers, const F32 timeout)
+void LLHTTPClient::put(const std::string& url, const LLSD& body, LLCurl::ResponderPtr responder, const LLSD& headers, const F32 timeout)
{
put_urls.push_back(url);
put_responders.push_back(responder);
put_body.push_back(body);
+ put_headers.push_back(headers);
}
+std::vector<std::string> delete_urls;
+std::vector<LLCurl::ResponderPtr> delete_responders;
+
+void LLHTTPClient::del(
+ const std::string& url,
+ LLCurl::ResponderPtr responder,
+ const LLSD& headers,
+ const F32 timeout)
+{
+ delete_urls.push_back(url);
+ delete_responders.push_back(responder);
+}
namespace tut
{
@@ -64,6 +78,9 @@ namespace tut
put_urls.clear();
put_responders.clear();
put_body.clear();
+ put_headers.clear();
+ delete_urls.clear();
+ delete_responders.clear();
}
};
@@ -73,7 +90,7 @@ namespace tut
namespace
{
- tut::factory tf("LLHTTPClientAdapterData test");
+ tut::factory tf("LLHTTPClientAdapterData");
}
namespace tut
@@ -91,7 +108,7 @@ namespace tut
{
LLHTTPClientAdapter adapter;
- boost::intrusive_ptr<LLCurl::Responder> responder = new LLCurl::Responder();
+ LLCurl::ResponderPtr responder = new LLCurl::Responder();
adapter.get("Made up URL", responder);
ensure_equals(get_urls.size(), 1);
@@ -103,7 +120,7 @@ namespace tut
void object::test<3>()
{
LLHTTPClientAdapter adapter;
- boost::intrusive_ptr<LLCurl::Responder> responder = new LLCurl::Responder();
+ LLCurl::ResponderPtr responder = new LLCurl::Responder();
adapter.get("Made up URL", responder);
@@ -117,7 +134,7 @@ namespace tut
{
LLHTTPClientAdapter adapter;
- boost::intrusive_ptr<LLCurl::Responder> responder = new LLCurl::Responder();
+ LLCurl::ResponderPtr responder = new LLCurl::Responder();
LLSD body;
body["TestBody"] = "Foobar";
@@ -133,7 +150,7 @@ namespace tut
{
LLHTTPClientAdapter adapter;
- boost::intrusive_ptr<LLCurl::Responder> responder = new LLCurl::Responder();
+ LLCurl::ResponderPtr responder = new LLCurl::Responder();
LLSD body;
body["TestBody"] = "Foobar";
@@ -150,7 +167,7 @@ namespace tut
{
LLHTTPClientAdapter adapter;
- boost::intrusive_ptr<LLCurl::Responder> responder = new LLCurl::Responder();
+ LLCurl::ResponderPtr responder = new LLCurl::Responder();
LLSD body;
body["TestBody"] = "Foobar";
@@ -160,5 +177,45 @@ namespace tut
ensure_equals(put_body.size(), 1);
ensure_equals(put_body[0]["TestBody"].asString(), "Foobar");
}
+
+ // Ensure that headers are passed through put properly
+ template<> template<>
+ void object::test<7>()
+ {
+ LLHTTPClientAdapter adapter;
+
+ LLCurl::ResponderPtr responder = new LLCurl::Responder();
+
+ LLSD body = LLSD::emptyMap();
+ body["TestBody"] = "Foobar";
+
+ LLSD headers = LLSD::emptyMap();
+ headers["booger"] = "omg";
+
+ adapter.put("Made up URL", body, responder, headers);
+
+ ensure_equals("Header count", put_headers.size(), 1);
+ ensure_equals(
+ "First header",
+ put_headers[0]["booger"].asString(),
+ "omg");
+ }
+
+ // Ensure that del() passes appropriate arguments to the LLHTTPClient
+ template<> template<>
+ void object::test<8>()
+ {
+ LLHTTPClientAdapter adapter;
+
+ LLCurl::ResponderPtr responder = new LLCurl::Responder();
+
+ adapter.del("Made up URL", responder);
+
+ ensure_equals("URL count", delete_urls.size(), 1);
+ ensure_equals("Received URL", delete_urls[0], "Made up URL");
+
+ ensure_equals("Responder count", delete_responders.size(), 1);
+ //ensure_equals("Responder", delete_responders[0], responder);
+ }
}
diff --git a/indra/llmessage/tests/llhttpnode_stub.cpp b/indra/llmessage/tests/llhttpnode_stub.cpp
new file mode 100644
index 0000000000..cc2108fed5
--- /dev/null
+++ b/indra/llmessage/tests/llhttpnode_stub.cpp
@@ -0,0 +1,112 @@
+/**
+ * @file llhttpnode_stub.cpp
+ * @brief STUB Implementation of classes for generic HTTP/LSL/REST handling.
+ *
+ * $LicenseInfo:firstyear=2006&license=viewergpl$
+ *
+ * Copyright (c) 2006-2009, Linden Research, Inc.
+ *
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab. Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ *
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ *
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ *
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#include "linden_common.h"
+#include "llhttpnode.h"
+
+const std::string CONTEXT_VERB("verb");
+const std::string CONTEXT_REQUEST("request");
+const std::string CONTEXT_WILDCARD("wildcard");
+const std::string CONTEXT_PATH("path");
+const std::string CONTEXT_QUERY_STRING("query-string");
+const std::string CONTEXT_REMOTE_HOST("remote-host");
+const std::string CONTEXT_REMOTE_PORT("remote-port");
+const std::string CONTEXT_HEADERS("headers");
+const std::string CONTEXT_RESPONSE("response");
+
+/**
+ * LLHTTPNode
+ */
+class LLHTTPNode::Impl
+{
+ // dummy
+};
+
+LLHTTPNode::LLHTTPNode(): impl(*new Impl) {}
+LLHTTPNode::~LLHTTPNode() {}
+LLSD LLHTTPNode::simpleGet() const { return LLSD(); }
+LLSD LLHTTPNode::simplePut(const LLSD& input) const { return LLSD(); }
+LLSD LLHTTPNode::simplePost(const LLSD& input) const { return LLSD(); }
+LLSD LLHTTPNode::simpleDel(const LLSD&) const { return LLSD(); }
+void LLHTTPNode::get(LLHTTPNode::ResponsePtr response, const LLSD& context) const {}
+void LLHTTPNode::put(LLHTTPNode::ResponsePtr response, const LLSD& context, const LLSD& input) const {}
+void LLHTTPNode::post(LLHTTPNode::ResponsePtr response, const LLSD& context, const LLSD& input) const {}
+void LLHTTPNode::del(LLHTTPNode::ResponsePtr response, const LLSD& context) const {}
+void LLHTTPNode::options(ResponsePtr response, const LLSD& context) const {}
+LLHTTPNode* LLHTTPNode::getChild(const std::string& name, LLSD& context) const { return NULL; }
+bool LLHTTPNode::handles(const LLSD& remainder, LLSD& context) const { return false; }
+bool LLHTTPNode::validate(const std::string& name, LLSD& context) const { return false; }
+const LLHTTPNode* LLHTTPNode::traverse(const std::string& path, LLSD& context) const { return NULL; }
+void LLHTTPNode::addNode(const std::string& path, LLHTTPNode* nodeToAdd) { }
+LLSD LLHTTPNode::allNodePaths() const { return LLSD(); }
+const LLHTTPNode* LLHTTPNode::rootNode() const { return NULL; }
+const LLHTTPNode* LLHTTPNode::findNode(const std::string& name) const { return NULL; }
+
+LLHTTPNode::Response::~Response(){}
+void LLHTTPNode::Response::notFound(const std::string& message)
+{
+ status(404, message);
+}
+void LLHTTPNode::Response::notFound()
+{
+ status(404, "Not Found");
+}
+void LLHTTPNode::Response::methodNotAllowed()
+{
+ status(405, "Method Not Allowed");
+}
+void LLHTTPNode::Response::statusUnknownError(S32 code)
+{
+ status(code, "Unknown Error");
+}
+
+void LLHTTPNode::Response::status(S32 code, const std::string& message)
+{
+}
+
+void LLHTTPNode::Response::addHeader(const std::string& name,const std::string& value)
+{
+ mHeaders[name] = value;
+}
+void LLHTTPNode::describe(Description& desc) const { }
+
+
+const LLChainIOFactory* LLHTTPNode::getProtocolHandler() const { return NULL; }
+
+
+LLHTTPRegistrar::NodeFactory::~NodeFactory() { }
+
+void LLHTTPRegistrar::registerFactory(
+ const std::string& path, NodeFactory& factory) {}
+void LLHTTPRegistrar::buildAllServices(LLHTTPNode& root) {}
+
+
diff --git a/indra/llmessage/tests/llmime_test.cpp b/indra/llmessage/tests/llmime_test.cpp
deleted file mode 100755
index aed5c4589c..0000000000
--- a/indra/llmessage/tests/llmime_test.cpp
+++ /dev/null
@@ -1,445 +0,0 @@
-/**
- * @file llmime_test.cpp
- * @author Phoenix
- * @date 2006-12-24
- * @brief BRIEF_DESC of llmime_test.cpp
- *
- * $LicenseInfo:firstyear=2006&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#include "linden_common.h"
-
-#include "llsdserialize.h"
-
-#include "../llmime.h"
-
-#include "../test/lltut.h"
-
-namespace tut
-{
- struct mime_index
- {
- };
- typedef test_group<mime_index> mime_index_t;
- typedef mime_index_t::object mime_index_object_t;
- tut::mime_index_t tut_mime_index("LLMime");
-
- template<> template<>
- void mime_index_object_t::test<1>()
- {
- LLMimeIndex mime;
- ensure("no headers", mime.headers().isUndefined());
- ensure_equals("invalid offset", mime.offset(), -1);
- ensure_equals("invalid content length", mime.contentLength(), -1);
- ensure("no content type", mime.contentType().empty());
- ensure("not multipart", !mime.isMultipart());
- ensure_equals("no attachments", mime.subPartCount(), 0);
- }
-
- template<> template<>
- void mime_index_object_t::test<2>()
- {
- const S32 CONTENT_LENGTH = 6000;
- const S32 CONTENT_OFFSET = 100;
- const std::string CONTENT_TYPE = std::string("image/j2c");
- LLSD headers;
- headers["Content-Length"] = CONTENT_LENGTH;
- headers["Content-Type"] = CONTENT_TYPE;
- LLMimeIndex mime(headers, CONTENT_OFFSET);
- ensure("headers are map", mime.headers().isMap());
- ensure_equals("offset", mime.offset(), CONTENT_OFFSET);
- ensure_equals("content length", mime.contentLength(), CONTENT_LENGTH);
- ensure_equals("type is image/j2c", mime.contentType(), CONTENT_TYPE);
- ensure("not multipart", !mime.isMultipart());
- ensure_equals("no attachments", mime.subPartCount(), 0);
- }
-
- template<> template<>
- void mime_index_object_t::test<3>()
- {
- const S32 MULTI_CONTENT_LENGTH = 8000;
- const S32 MULTI_CONTENT_OFFSET = 100;
- const std::string MULTI_CONTENT_TYPE = std::string("multipart/mixed");
- LLSD headers;
- headers["Content-Length"] = MULTI_CONTENT_LENGTH;
- headers["Content-Type"] = MULTI_CONTENT_TYPE;
- LLMimeIndex mime(headers, MULTI_CONTENT_OFFSET);
- llinfos << "headers: " << LLSDOStreamer<LLSDNotationFormatter>(headers)
- << llendl;
-
-
- const S32 META_CONTENT_LENGTH = 700;
- const S32 META_CONTENT_OFFSET = 69;
- const std::string META_CONTENT_TYPE = std::string(
- "text/llsd+xml");
- headers = LLSD::emptyMap();
- headers["Content-Length"] = META_CONTENT_LENGTH;
- headers["Content-Type"] = META_CONTENT_TYPE;
- LLMimeIndex meta(headers, META_CONTENT_OFFSET);
- mime.attachSubPart(meta);
-
- const S32 IMAGE_CONTENT_LENGTH = 6000;
- const S32 IMAGE_CONTENT_OFFSET = 200;
- const std::string IMAGE_CONTENT_TYPE = std::string("image/j2c");
- headers = LLSD::emptyMap();
- headers["Content-Length"] = IMAGE_CONTENT_LENGTH;
- headers["Content-Type"] = IMAGE_CONTENT_TYPE;
- LLMimeIndex image(headers, IMAGE_CONTENT_OFFSET);
- mime.attachSubPart(image);
-
- // make sure we have a valid multi-part
- ensure("is multipart", mime.isMultipart());
- ensure_equals("multi offset", mime.offset(), MULTI_CONTENT_OFFSET);
- ensure_equals(
- "multi content length",
- mime.contentLength(),
- MULTI_CONTENT_LENGTH);
- ensure_equals("two attachments", mime.subPartCount(), 2);
-
- // make sure ranged gets do the right thing with out of bounds
- // sub-parts.
- LLMimeIndex invalid_child(mime.subPart(-1));
- ensure("no headers", invalid_child.headers().isUndefined());
- ensure_equals("invalid offset", invalid_child.offset(), -1);
- ensure_equals(
- "invalid content length", invalid_child.contentLength(), -1);
- ensure("no content type", invalid_child.contentType().empty());
- ensure("not multipart", !invalid_child.isMultipart());
- ensure_equals("no attachments", invalid_child.subPartCount(), 0);
-
- invalid_child = mime.subPart(2);
- ensure("no headers", invalid_child.headers().isUndefined());
- ensure_equals("invalid offset", invalid_child.offset(), -1);
- ensure_equals(
- "invalid content length", invalid_child.contentLength(), -1);
- ensure("no content type", invalid_child.contentType().empty());
- ensure("not multipart", !invalid_child.isMultipart());
- ensure_equals("no attachments", invalid_child.subPartCount(), 0);
- }
-
- template<> template<>
- void mime_index_object_t::test<4>()
- {
- const S32 MULTI_CONTENT_LENGTH = 8000;
- const S32 MULTI_CONTENT_OFFSET = 100;
- const std::string MULTI_CONTENT_TYPE = std::string("multipart/mixed");
- LLSD headers;
- headers["Content-Length"] = MULTI_CONTENT_LENGTH;
- headers["Content-Type"] = MULTI_CONTENT_TYPE;
- LLMimeIndex mime(headers, MULTI_CONTENT_OFFSET);
-
- const S32 META_CONTENT_LENGTH = 700;
- const S32 META_CONTENT_OFFSET = 69;
- const std::string META_CONTENT_TYPE = std::string(
- "application/llsd+xml");
- headers = LLSD::emptyMap();
- headers["Content-Length"] = META_CONTENT_LENGTH;
- headers["Content-Type"] = META_CONTENT_TYPE;
- LLMimeIndex meta(headers, META_CONTENT_OFFSET);
- mime.attachSubPart(meta);
-
- const S32 IMAGE_CONTENT_LENGTH = 6000;
- const S32 IMAGE_CONTENT_OFFSET = 200;
- const std::string IMAGE_CONTENT_TYPE = std::string("image/j2c");
- headers = LLSD::emptyMap();
- headers["Content-Length"] = IMAGE_CONTENT_LENGTH;
- headers["Content-Type"] = IMAGE_CONTENT_TYPE;
- LLMimeIndex image(headers, IMAGE_CONTENT_OFFSET);
- mime.attachSubPart(image);
-
- // check what we have
- ensure("is multipart", mime.isMultipart());
- ensure_equals("multi offset", mime.offset(), MULTI_CONTENT_OFFSET);
- ensure_equals(
- "multi content length",
- mime.contentLength(),
- MULTI_CONTENT_LENGTH);
- ensure_equals("two attachments", mime.subPartCount(), 2);
-
- LLMimeIndex actual_meta = mime.subPart(0);
- ensure_equals(
- "meta type", actual_meta.contentType(), META_CONTENT_TYPE);
- ensure_equals(
- "meta offset", actual_meta.offset(), META_CONTENT_OFFSET);
- ensure_equals(
- "meta content length",
- actual_meta.contentLength(),
- META_CONTENT_LENGTH);
-
- LLMimeIndex actual_image = mime.subPart(1);
- ensure_equals(
- "image type", actual_image.contentType(), IMAGE_CONTENT_TYPE);
- ensure_equals(
- "image offset", actual_image.offset(), IMAGE_CONTENT_OFFSET);
- ensure_equals(
- "image content length",
- actual_image.contentLength(),
- IMAGE_CONTENT_LENGTH);
- }
-
-/*
- template<> template<>
- void mime_index_object_t::test<5>()
- {
- }
- template<> template<>
- void mime_index_object_t::test<6>()
- {
- }
- template<> template<>
- void mime_index_object_t::test<7>()
- {
- }
- template<> template<>
- void mime_index_object_t::test<8>()
- {
- }
- template<> template<>
- void mime_index_object_t::test<>()
- {
- }
-*/
-}
-
-
-namespace tut
-{
- struct mime_parse
- {
- };
- typedef test_group<mime_parse> mime_parse_t;
- typedef mime_parse_t::object mime_parse_object_t;
- tut::mime_parse_t tut_mime_parse("LLMimeParse");
-
- template<> template<>
- void mime_parse_object_t::test<1>()
- {
- // parse one mime object
- const std::string SERIALIZED_MIME("Content-Length: 200\r\nContent-Type: text/plain\r\n\r\naaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcccccccccc\r\n");
- std::stringstream istr;
- istr.str(SERIALIZED_MIME);
- LLMimeIndex mime;
- LLMimeParser parser;
- bool ok = parser.parseIndex(istr, mime);
- ensure("Parse successful.", ok);
- ensure_equals("content type", mime.contentType(), "text/plain");
- ensure_equals("content length", mime.contentLength(), 200);
- ensure_equals("offset", mime.offset(), 49);
- }
-
- template<> template<>
- void mime_parse_object_t::test<2>()
- {
- // make sure we only parse one.
- const std::string SERIALIZED_MIME("Content-Length: 200\r\nContent-Type: text/plain\r\n\r\naaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcccccccccc\r\n\r\nContent-Length: 200\r\nContent-Type: text/plain\r\n\r\naaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcccccccccc\r\n\r\n");
- std::stringstream istr;
- istr.str(SERIALIZED_MIME);
- LLMimeIndex mime;
- LLMimeParser parser;
- bool ok = parser.parseIndex(istr, mime);
- ensure("Parse successful.", ok);
- ensure("not multipart.", !mime.isMultipart());
- ensure_equals("content type", mime.contentType(), "text/plain");
- ensure_equals("content length", mime.contentLength(), 200);
- ensure_equals("offset", mime.offset(), 49);
- }
-
- template<> template<>
- void mime_parse_object_t::test<3>()
- {
- // test multi-part and lack of content length for some of it.
- /*
-Content-Type: multipart/mixed; boundary="segment"rnContent-Length: 148rnrn--segmentrnContent-Type: text/plainrnrnsome datarnrn--segmentrnContent-Type: text/xml; charset=UTF-8rnContent-Length: 22rnrn<llsd><undef /></llsd>rnrn
- */
- const std::string SERIALIZED_MIME("Content-Type: multipart/mixed; boundary=\"segment\"\r\nContent-Length: 150\r\n\r\n--segment\r\nContent-Type: text/plain\r\n\r\nsome data\r\n\r\n--segment\r\nContent-Type: text/xml; charset=UTF-8\r\nContent-Length: 22\r\n\r\n<llsd><undef /></llsd>\r\n\r\n");
- std::stringstream istr;
- istr.str(SERIALIZED_MIME);
- LLMimeIndex mime;
- LLMimeParser parser;
- bool ok = parser.parseIndex(istr, mime);
- ensure("Parse successful.", ok);
- ensure("is multipart.", mime.isMultipart());
- ensure_equals("sub-part count", mime.subPartCount(), 2);
- ensure_equals("content length", mime.contentLength(), 150);
- ensure_equals("data offset for multipart", mime.offset(), 74);
-
- LLMimeIndex mime_plain(mime.subPart(0));
- ensure_equals(
- "first part type",
- mime_plain.contentType(),
- "text/plain");
- ensure_equals(
- "first part content length not known.",
- mime_plain.contentLength(),
- -1);
- ensure_equals("first part offset", mime_plain.offset(), 113);
-
- LLMimeIndex mime_xml(mime.subPart(1));
- ensure_equals(
- "second part type",
- mime_xml.contentType(),
- "text/xml; charset=UTF-8");
- ensure_equals(
- "second part content length",
- mime_xml.contentLength(),
- 22);
- ensure_equals("second part offset", mime_xml.offset(), 198);
- }
-
- template<> template<>
- void mime_parse_object_t::test<4>()
- {
- // test multi-part, unquoted separator, and premature eof conditions
- /*
-Content-Type: multipart/mixed; boundary=segmentrnContent-Length: 220rnrn--segmentrnContent-Type: text/plainrnContent-Length: 55rnrnhow are you today?rnI do not know. I guess I am:n'fine'rnrn--segmentrnContent-Type: text/xml; charset=UTF-8rnContent-Length: 22rnrn<llsd><undef /></llsd>rnrn */
- const std::string SERIALIZED_MIME("Content-Type: multipart/mixed; boundary=segment\r\nContent-Length: 220\r\n\r\n--segment\r\nContent-Type: text/plain\r\nContent-Length: 55\r\n\r\nhow are you today?\r\nI do not know. I guess I am:\n'fine'\r\n\r\n--segment\r\nContent-Type: text/xml; charset=UTF-8\r\nContent-Length: 22\r\n\r\n<llsd><undef /></llsd>\r\n\r\n");
- std::stringstream istr;
- istr.str(SERIALIZED_MIME);
- LLMimeIndex mime;
- LLMimeParser parser;
- bool ok = parser.parseIndex(istr, mime);
- ensure("Parse successful.", ok);
- ensure("is multipart.", mime.isMultipart());
- ensure_equals("sub-part count", mime.subPartCount(), 2);
- ensure_equals("content length", mime.contentLength(), 220);
- ensure_equals("data offset for multipart", mime.offset(), 72);
-
- LLMimeIndex mime_plain(mime.subPart(0));
- ensure_equals(
- "first part type",
- mime_plain.contentType(),
- "text/plain");
- ensure_equals(
- "first part content length",
- mime_plain.contentLength(),
- 55);
- ensure_equals("first part offset", mime_plain.offset(), 131);
-
- LLMimeIndex mime_xml(mime.subPart(1));
- ensure_equals(
- "second part type",
- mime_xml.contentType(),
- "text/xml; charset=UTF-8");
- ensure_equals(
- "second part content length",
- mime_xml.contentLength(),
- 22);
- ensure_equals("second part offset", mime_xml.offset(), 262);
- }
-
- template<> template<>
- void mime_parse_object_t::test<5>()
- {
- // test multi-part with multiple params
- const std::string SERIALIZED_MIME("Content-Type: multipart/mixed; boundary=segment; comment=\"testing multiple params.\"\r\nContent-Length: 220\r\n\r\n--segment\r\nContent-Type: text/plain\r\nContent-Length: 55\r\n\r\nhow are you today?\r\nI do not know. I guess I am:\n'fine'\r\n\r\n--segment\r\nContent-Type: text/xml; charset=UTF-8\r\nContent-Length: 22\r\n\r\n<llsd><undef /></llsd>\r\n\r\n");
- std::stringstream istr;
- istr.str(SERIALIZED_MIME);
- LLMimeIndex mime;
- LLMimeParser parser;
- bool ok = parser.parseIndex(istr, mime);
- ensure("Parse successful.", ok);
- ensure("is multipart.", mime.isMultipart());
- ensure_equals("sub-part count", mime.subPartCount(), 2);
- ensure_equals("content length", mime.contentLength(), 220);
-
- LLMimeIndex mime_plain(mime.subPart(0));
- ensure_equals(
- "first part type",
- mime_plain.contentType(),
- "text/plain");
- ensure_equals(
- "first part content length",
- mime_plain.contentLength(),
- 55);
-
- LLMimeIndex mime_xml(mime.subPart(1));
- ensure_equals(
- "second part type",
- mime_xml.contentType(),
- "text/xml; charset=UTF-8");
- ensure_equals(
- "second part content length",
- mime_xml.contentLength(),
- 22);
- }
-
- template<> template<>
- void mime_parse_object_t::test<6>()
- {
- // test multi-part with no specified boundary and eof
-/*
-Content-Type: multipart/relatedrnContent-Length: 220rnrn--rnContent-Type: text/plainrnContent-Length: 55rnrnhow are you today?rnI do not know. I guess I am:n'fine'rnrn--rnContent-Type: text/xml; charset=UTF-8rnContent-Length: 22rnrn<llsd><undef /></llsd>rnrn
-*/
- const std::string SERIALIZED_MIME("Content-Type: multipart/related\r\nContent-Length: 500\r\n\r\n--\r\nContent-Type: text/plain\r\nContent-Length: 55\r\n\r\nhow are you today?\r\nI do not know. I guess I am:\n'fine'\r\n\r\n--\r\nContent-Type: text/xml; charset=UTF-8\r\nContent-Length: 22\r\n\r\n<llsd><undef /></llsd>\r\n\r\n");
- std::stringstream istr;
- istr.str(SERIALIZED_MIME);
- LLMimeIndex mime;
- LLMimeParser parser;
- bool ok = parser.parseIndex(istr, mime);
- ensure("Parse successful.", ok);
- ensure("is multipart.", mime.isMultipart());
- ensure_equals("sub-part count", mime.subPartCount(), 2);
- ensure_equals("content length", mime.contentLength(), 500);
- ensure_equals("data offset for multipart", mime.offset(), 56);
-
- LLMimeIndex mime_plain(mime.subPart(0));
- ensure_equals(
- "first part type",
- mime_plain.contentType(),
- "text/plain");
- ensure_equals(
- "first part content length",
- mime_plain.contentLength(),
- 55);
- ensure_equals("first part offset", mime_plain.offset(), 108);
-
- LLMimeIndex mime_xml(mime.subPart(1));
- ensure_equals(
- "second part type",
- mime_xml.contentType(),
- "text/xml; charset=UTF-8");
- ensure_equals(
- "second part content length",
- mime_xml.contentLength(),
- 22);
- ensure_equals("second part offset", mime_xml.offset(), 232);
- }
-
-/*
- template<> template<>
- void mime_parse_object_t::test<>()
- {
- }
- template<> template<>
- void mime_parse_object_t::test<>()
- {
- }
- template<> template<>
- void mime_parse_object_t::test<>()
- {
- }
- template<> template<>
- void mime_parse_object_t::test<>()
- {
- }
-*/
-}
diff --git a/indra/llmessage/tests/llregionpresenceverifier_test.cpp b/indra/llmessage/tests/llregionpresenceverifier_test.cpp
deleted file mode 100755
index 5b89f2a8c6..0000000000
--- a/indra/llmessage/tests/llregionpresenceverifier_test.cpp
+++ /dev/null
@@ -1,108 +0,0 @@
-/**
- * @file
- * @brief
- *
- * $LicenseInfo:firstyear=2008&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#include "linden_common.h"
-
-#include "../test/lltut.h"
-#include "llregionpresenceverifier.h"
-#include "llcurl_stub.cpp"
-#include "llhost.cpp"
-#include "net.cpp"
-#include "lltesthttpclientadapter.cpp"
-
-class LLTestResponse : public LLRegionPresenceVerifier::Response
-{
-public:
-
- virtual bool checkValidity(const LLSD& content) const
- {
- return true;
- }
-
- virtual void onRegionVerified(const LLSD& region_details)
- {
- }
-
- virtual void onRegionVerificationFailed()
- {
- }
-
- virtual LLHTTPClientInterface& getHttpClient()
- {
- return mHttpInterface;
- }
-
- LLTestHTTPClientAdapter mHttpInterface;
-};
-
-namespace tut
-{
- struct LLRegionPresenceVerifierData
- {
- LLRegionPresenceVerifierData() :
- mResponse(new LLTestResponse()),
- mResponder("", LLRegionPresenceVerifier::ResponsePtr(mResponse),
- LLSD(), 3)
- {
- }
-
- LLTestResponse* mResponse;
- LLRegionPresenceVerifier::VerifiedDestinationResponder mResponder;
- };
-
- typedef test_group<LLRegionPresenceVerifierData> factory;
- typedef factory::object object;
-}
-
-namespace
-{
- tut::factory tf("LLRegionPresenceVerifier");
-}
-
-namespace tut
-{
- // Test that VerifiedDestinationResponder does retry
- // on error when shouldRetry returns true.
- template<> template<>
- void object::test<1>()
- {
- mResponder.error(500, "Internal server error");
- ensure_equals(mResponse->mHttpInterface.mGetUrl.size(), 1);
- }
-
- // Test that VerifiedDestinationResponder only retries
- // on error until shouldRetry returns false.
- template<> template<>
- void object::test<2>()
- {
- mResponder.error(500, "Internal server error");
- mResponder.error(500, "Internal server error");
- mResponder.error(500, "Internal server error");
- mResponder.error(500, "Internal server error");
- ensure_equals(mResponse->mHttpInterface.mGetUrl.size(), 3);
- }
-}
-
diff --git a/indra/llmessage/tests/lltrustedmessageservice_test.cpp b/indra/llmessage/tests/lltrustedmessageservice_test.cpp
index b287a29841..55748ad27e 100755
--- a/indra/llmessage/tests/lltrustedmessageservice_test.cpp
+++ b/indra/llmessage/tests/lltrustedmessageservice_test.cpp
@@ -32,6 +32,7 @@
#include "message.h"
#include "llmessageconfig.h"
+#include "llhttpnode_stub.cpp"
LLMessageSystem* gMessageSystem = NULL;