diff options
author | Andrey Lihatskiy <alihatskiy@productengine.com> | 2024-04-29 07:43:28 +0300 |
---|---|---|
committer | Andrey Lihatskiy <alihatskiy@productengine.com> | 2024-04-29 07:56:09 +0300 |
commit | 1b68f71348ecf3983b76b40d7940da8377f049b7 (patch) | |
tree | 2974eddaef130a067c26033d60a59fc790365b3d /indra/viewer_components | |
parent | af4ea94efc1999f3b19fd8d643d0331f0b77e265 (diff) |
#824 Process source files in bulk: replace tabs with spaces, convert CRLF to LF, and trim trailing whitespaces as needed
Diffstat (limited to 'indra/viewer_components')
-rw-r--r-- | indra/viewer_components/login/lllogin.cpp | 140 | ||||
-rw-r--r-- | indra/viewer_components/login/lllogin.h | 174 | ||||
-rw-r--r-- | indra/viewer_components/login/tests/lllogin_test.cpp | 296 |
3 files changed, 305 insertions, 305 deletions
diff --git a/indra/viewer_components/login/lllogin.cpp b/indra/viewer_components/login/lllogin.cpp index 5d50d1e182..2a0468f3ad 100644 --- a/indra/viewer_components/login/lllogin.cpp +++ b/indra/viewer_components/login/lllogin.cpp @@ -1,24 +1,24 @@ -/** +/** * @file lllogin.cpp * * $LicenseInfo:firstyear=2009&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$ */ @@ -30,8 +30,8 @@ /*==========================================================================*| #ifdef LL_WINDOWS - // non-virtual destructor warning, boost::statechart does this intentionally. - #pragma warning (disable : 4265) + // non-virtual destructor warning, boost::statechart does this intentionally. + #pragma warning (disable : 4265) #endif |*==========================================================================*/ @@ -53,7 +53,7 @@ class LLLogin::Impl { public: Impl(): - mPump("login", true) // Create the module's event pump with a tweaked (unique) name. + mPump("login", true) // Create the module's event pump with a tweaked (unique) name. { mValidAuthResponse["status"] = LLSD(); mValidAuthResponse["errorcode"] = LLSD(); @@ -63,35 +63,35 @@ public: void connect(const std::string& uri, const LLSD& credentials); void disconnect(); - LLEventPump& getEventPump() { return mPump; } + LLEventPump& getEventPump() { return mPump; } private: - LLSD getProgressEventLLSD(const std::string& state, const std::string& change, - const LLSD& data = LLSD()) - { - LLSD status_data; - status_data["state"] = state; - status_data["change"] = change; - status_data["progress"] = 0.0f; - - if(mAuthResponse.has("transfer_rate")) - { - status_data["transfer_rate"] = mAuthResponse["transfer_rate"]; - } - - if(data.isDefined()) - { - status_data["data"] = data; - } - return status_data; - } - - void sendProgressEvent(const std::string& state, const std::string& change, - const LLSD& data = LLSD()) - { - LLSD status_data = getProgressEventLLSD(state, change, data); - mPump.post(status_data); - } + LLSD getProgressEventLLSD(const std::string& state, const std::string& change, + const LLSD& data = LLSD()) + { + LLSD status_data; + status_data["state"] = state; + status_data["change"] = change; + status_data["progress"] = 0.0f; + + if(mAuthResponse.has("transfer_rate")) + { + status_data["transfer_rate"] = mAuthResponse["transfer_rate"]; + } + + if(data.isDefined()) + { + status_data["data"] = data; + } + return status_data; + } + + void sendProgressEvent(const std::string& state, const std::string& change, + const LLSD& data = LLSD()) + { + LLSD status_data = getProgressEventLLSD(state, change, data); + mPump.post(status_data); + } LLSD validateResponse(const std::string& pumpName, const LLSD& response) { @@ -114,19 +114,19 @@ private: void loginCoro(std::string uri, LLSD credentials); LLEventStream mPump; - LLSD mAuthResponse, mValidAuthResponse; + LLSD mAuthResponse, mValidAuthResponse; }; void LLLogin::Impl::connect(const std::string& uri, const LLSD& login_params) { LL_DEBUGS("LLLogin") << " connect with uri '" << uri << "', login_params " << login_params << LL_ENDL; - + // Launch a coroutine with our login_() method. Run the coroutine until // its first wait; at that point, return here. - std::string coroname = + std::string coroname = LLCoros::instance().launch("LLLogin::Impl::login_", boost::bind(&Impl::loginCoro, this, uri, login_params)); - LL_DEBUGS("LLLogin") << " connected with uri '" << uri << "', login_params " << login_params << LL_ENDL; + LL_DEBUGS("LLLogin") << " connected with uri '" << uri << "', login_params " << login_params << LL_ENDL; } namespace { @@ -141,8 +141,8 @@ static LLEventMailDrop sSyncPoint("LoginSync"); void LLLogin::Impl::loginCoro(std::string uri, LLSD login_params) { LLSD printable_params = login_params; - if (printable_params.has("params") - && printable_params["params"].has("passwd")) + if (printable_params.has("params") + && printable_params["params"].has("passwd")) { printable_params["params"]["passwd"] = "*******"; } @@ -322,7 +322,7 @@ void LLLogin::Impl::loginCoro(std::string uri, LLSD login_params) // Tell caller this didn't work out so well. // *NOTE: The response from LLXMLRPCListener's Poller::poll method returns an - // llsd with no "responses" node. To make the output from an incomplete login symmetrical + // llsd with no "responses" node. To make the output from an incomplete login symmetrical // to success, add a data/message and data/reason fields. LLSD error_response(LLSDMap ("reason", mAuthResponse["status"]) @@ -349,7 +349,7 @@ void LLLogin::Impl::disconnect() //********************* // LLLogin LLLogin::LLLogin() : - mImpl(new LLLogin::Impl()) + mImpl(new LLLogin::Impl()) { } @@ -359,21 +359,21 @@ LLLogin::~LLLogin() void LLLogin::connect(const std::string& uri, const LLSD& credentials) { - mImpl->connect(uri, credentials); + mImpl->connect(uri, credentials); } void LLLogin::disconnect() { - mImpl->disconnect(); + mImpl->disconnect(); } LLEventPump& LLLogin::getEventPump() { - return mImpl->getEventPump(); + return mImpl->getEventPump(); } -// The following is the list of important functions that happen in the +// The following is the list of important functions that happen in the // current login process that we want to move to this login module. // The list associates to event with the original idle_startup() 'STATE'. @@ -381,15 +381,15 @@ LLEventPump& LLLogin::getEventPump() // Setup login // State_LOGIN_AUTH_INIT -// Authenticate +// Authenticate // STATE_LOGIN_AUTHENTICATE -// Connect to the login server, presumably login.cgi, requesting the login +// Connect to the login server, presumably login.cgi, requesting the login // and a slew of related initial connection information. // This is an asynch action. The final response, whether success or error // is handled by STATE_LOGIN_PROCESS_REPONSE. // There is no immediate error or output from this call. -// -// Input: +// +// Input: // URI // Credentials (first, last, password) // Start location @@ -404,19 +404,19 @@ LLEventPump& LLLogin::getEventPump() //sAuthUriNum = llclamp(sAuthUriNum, 0, (S32)sAuthUris.size()-1); //LLUserAuth::getInstance()->authenticate( -// sAuthUris[sAuthUriNum], -// auth_method, -// firstname, -// lastname, -// password, // web_login_key, -// start.str(), -// gSkipOptionalUpdate, -// gAcceptTOS, -// gAcceptCriticalMessage, -// gLastExecEvent, -// requested_options, -// hashed_mac_string, -// LLAppViewer::instance()->getSerialNumber()); +// sAuthUris[sAuthUriNum], +// auth_method, +// firstname, +// lastname, +// password, // web_login_key, +// start.str(), +// gSkipOptionalUpdate, +// gAcceptTOS, +// gAcceptCriticalMessage, +// gLastExecEvent, +// requested_options, +// hashed_mac_string, +// LLAppViewer::instance()->getSerialNumber()); // // Download the Response @@ -427,22 +427,22 @@ LLEventPump& LLLogin::getEventPump() // that don't need to do so, but geez! // There are two states to do this one function just to update the login // status text from 'Logging In...' to 'Downloading...' -// +// // // Handle Login Response // STATE_LOGIN_PROCESS_RESPONSE -// +// // This state handle the result of the request to login. There is a metric ton of // code in this case. This state will transition to: // STATE_WORLD_INIT, on success. // STATE_AUTHENTICATE, on failure. // STATE_UPDATE_CHECK, to handle user during login interaction like TOS display. // -// Much of the code in this case belongs on the viewer side of the fence and not in login. +// Much of the code in this case belongs on the viewer side of the fence and not in login. // Login should probably return with a couple of events, success and failure. -// Failure conditions can be specified in the events data pacet to allow the viewer +// Failure conditions can be specified in the events data pacet to allow the viewer // to re-engauge login as is appropriate. (Or should there be multiple failure messages?) -// Success is returned with the data requested from the login. According to OGP specs -// there may be intermediate steps before reaching this result in future login +// Success is returned with the data requested from the login. According to OGP specs +// there may be intermediate steps before reaching this result in future login // implementations. diff --git a/indra/viewer_components/login/lllogin.h b/indra/viewer_components/login/lllogin.h index de58ca0c29..45bcc2866f 100644 --- a/indra/viewer_components/login/lllogin.h +++ b/indra/viewer_components/login/lllogin.h @@ -1,24 +1,24 @@ -/** +/** * @file lllogin.h * * $LicenseInfo:firstyear=2009&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$ */ @@ -38,90 +38,90 @@ class LLEventPump; class LLLogin { public: - LLLogin(); - ~LLLogin(); - - /** - * Make a connection to a grid. - * @param uri The 'well known and published' authentication URL. - * @param credentials LLSD data that contians the credentials. - * *NOTE:Mani The credential data can vary depending upon the authentication - * method used. The current interface matches the values passed to - * the XMLRPC login request. - { - method : string, - first : string, - last : string, - passwd : string, - start : string, - skipoptional : bool, - agree_to_tos : bool, - read_critical : bool, - last_exec_event : int, - version : string, - channel : string, - mac : string, - id0 : string, - options : [ strings ] - } - - */ - void connect(const std::string& uri, const LLSD& credentials); - - /** - * Disconnect from a the current connection. - */ - void disconnect(); - - /** - * Retrieve the event pump from this login class. - */ - LLEventPump& getEventPump(); - - /* - Event API - - LLLogin will issue multiple events to it pump to indicate the - progression of states through login. The most important - states are "offline" and "online" which indicate auth failure - and auth success respectively. - - pump: login (tweaked) - These are the events posted to the 'login' - event pump from the login module. - { - state : string, // See below for the list of states. - progress : real // for progress bar. - data : LLSD // Dependent upon state. - } - - States for method 'login_to_simulator' - offline - set initially state and upon failure. data is the server response. - srvrequest - upon uri rewrite request. no data. - authenticating - upon auth request. data, 'attempt' number and 'request' llsd. - downloading - upon ack from auth server, before completion. no data - online - upon auth success. data is server response. - - - Dependencies: - pump: LLAres - LLLogin makes a request for a SRV record from the uri provided by the connect method. - The following event pump should exist to service that request. - pump name: LLAres - request = { - op : "rewriteURI" - uri : string - reply : string - - pump: LLXMLRPCListener - The request merely passes the credentials LLSD along, with one additional - member, 'reply', which is the string name of the event pump to reply on. - - */ + LLLogin(); + ~LLLogin(); + + /** + * Make a connection to a grid. + * @param uri The 'well known and published' authentication URL. + * @param credentials LLSD data that contians the credentials. + * *NOTE:Mani The credential data can vary depending upon the authentication + * method used. The current interface matches the values passed to + * the XMLRPC login request. + { + method : string, + first : string, + last : string, + passwd : string, + start : string, + skipoptional : bool, + agree_to_tos : bool, + read_critical : bool, + last_exec_event : int, + version : string, + channel : string, + mac : string, + id0 : string, + options : [ strings ] + } + + */ + void connect(const std::string& uri, const LLSD& credentials); + + /** + * Disconnect from a the current connection. + */ + void disconnect(); + + /** + * Retrieve the event pump from this login class. + */ + LLEventPump& getEventPump(); + + /* + Event API + + LLLogin will issue multiple events to it pump to indicate the + progression of states through login. The most important + states are "offline" and "online" which indicate auth failure + and auth success respectively. + + pump: login (tweaked) + These are the events posted to the 'login' + event pump from the login module. + { + state : string, // See below for the list of states. + progress : real // for progress bar. + data : LLSD // Dependent upon state. + } + + States for method 'login_to_simulator' + offline - set initially state and upon failure. data is the server response. + srvrequest - upon uri rewrite request. no data. + authenticating - upon auth request. data, 'attempt' number and 'request' llsd. + downloading - upon ack from auth server, before completion. no data + online - upon auth success. data is server response. + + + Dependencies: + pump: LLAres + LLLogin makes a request for a SRV record from the uri provided by the connect method. + The following event pump should exist to service that request. + pump name: LLAres + request = { + op : "rewriteURI" + uri : string + reply : string + + pump: LLXMLRPCListener + The request merely passes the credentials LLSD along, with one additional + member, 'reply', which is the string name of the event pump to reply on. + + */ private: - class Impl; - std::unique_ptr<Impl> mImpl; + class Impl; + std::unique_ptr<Impl> mImpl; }; #endif // LL_LLLOGIN_H diff --git a/indra/viewer_components/login/tests/lllogin_test.cpp b/indra/viewer_components/login/tests/lllogin_test.cpp index f9267533ff..8aea3b37aa 100644 --- a/indra/viewer_components/login/tests/lllogin_test.cpp +++ b/indra/viewer_components/login/tests/lllogin_test.cpp @@ -3,25 +3,25 @@ * @author Mark Palange * @date 2009-02-26 * @brief Tests of lllogin.cpp. - * + * * $LicenseInfo:firstyear=2009&license=viewerlgpl$ * Second Life Viewer Source Code * Copyright (C) 2009-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$ */ @@ -73,7 +73,7 @@ class LoginListener: public LLEventTrackable size_t mCalls{ 0 }; Debug mDebug; public: - LoginListener(const std::string& name) : + LoginListener(const std::string& name) : mName(name), mDebug(stringize(*this)) {} @@ -81,7 +81,7 @@ public: bool call(const LLSD& event) { mDebug(STRINGIZE("LoginListener called!: " << event)); - + mLastEvent = event; ++mCalls; return false; @@ -139,57 +139,57 @@ public: class LLXMLRPCListener: public LLEventTrackable { - std::string mName; - LLSD mEvent; - bool mImmediateResponse; - LLSD mResponse; + std::string mName; + LLSD mEvent; + bool mImmediateResponse; + LLSD mResponse; Debug mDebug; public: - LLXMLRPCListener(const std::string& name, - bool i = false, - const LLSD& response = LLSD() - ) : - mName(name), - mImmediateResponse(i), - mResponse(response), + LLXMLRPCListener(const std::string& name, + bool i = false, + const LLSD& response = LLSD() + ) : + mName(name), + mImmediateResponse(i), + mResponse(response), mDebug(stringize(*this)) - { - if(mResponse.isUndefined()) - { - mResponse["status"] = "Complete"; // StatusComplete - mResponse["errorcode"] = 0; - mResponse["error"] = "dummy response"; - mResponse["transfer_rate"] = 0; - mResponse["responses"]["login"] = true; - } - } - - void setResponse(const LLSD& r) - { - mResponse = r; - } - - bool handle_event(const LLSD& event) - { - mDebug(STRINGIZE("LLXMLRPCListener called!: " << event)); - mEvent = event; - if(mImmediateResponse) - { - sendReply(); - } - return false; - } - - void sendReply() - { - LLEventPumps::instance().obtain(mEvent["reply"]).post(mResponse); - } - - LLBoundListener listenTo(LLEventPump& pump) + { + if(mResponse.isUndefined()) + { + mResponse["status"] = "Complete"; // StatusComplete + mResponse["errorcode"] = 0; + mResponse["error"] = "dummy response"; + mResponse["transfer_rate"] = 0; + mResponse["responses"]["login"] = true; + } + } + + void setResponse(const LLSD& r) + { + mResponse = r; + } + + bool handle_event(const LLSD& event) + { + mDebug(STRINGIZE("LLXMLRPCListener called!: " << event)); + mEvent = event; + if(mImmediateResponse) + { + sendReply(); + } + return false; + } + + void sendReply() + { + LLEventPumps::instance().obtain(mEvent["reply"]).post(mResponse); + } + + LLBoundListener listenTo(LLEventPump& pump) { return pump.listen(mName, boost::bind(&LLXMLRPCListener::handle_event, this, _1)); - } + } friend std::ostream& operator<<(std::ostream& out, const LLXMLRPCListener& listener) { @@ -223,121 +223,121 @@ namespace tut void llviewerlogin_object::test<1>() { DEBUG; - // Testing login with an immediate response from XMLPRC - // The response will come before the post request exits. - // This tests an edge case of the login state handling. - LLEventStream xmlrpcPump("LLXMLRPCTransaction"); // Dummy XMLRPC pump + // Testing login with an immediate response from XMLPRC + // The response will come before the post request exits. + // This tests an edge case of the login state handling. + LLEventStream xmlrpcPump("LLXMLRPCTransaction"); // Dummy XMLRPC pump - bool respond_immediately = true; + bool respond_immediately = true; - // Have dummy XMLRPC respond immediately. - LLXMLRPCListener dummyXMLRPC("dummy_xmlrpc", respond_immediately); - LLTempBoundListener conn1 = dummyXMLRPC.listenTo(xmlrpcPump); + // Have dummy XMLRPC respond immediately. + LLXMLRPCListener dummyXMLRPC("dummy_xmlrpc", respond_immediately); + LLTempBoundListener conn1 = dummyXMLRPC.listenTo(xmlrpcPump); - LLLogin login; + LLLogin login; - LoginListener listener("test_ear"); - LLTempBoundListener conn2 = listener.listenTo(login.getEventPump()); + LoginListener listener("test_ear"); + LLTempBoundListener conn2 = listener.listenTo(login.getEventPump()); - LLSD credentials; - credentials["first"] = "foo"; - credentials["last"] = "bar"; - credentials["passwd"] = "secret"; + LLSD credentials; + credentials["first"] = "foo"; + credentials["last"] = "bar"; + credentials["passwd"] = "secret"; - login.connect("login.bar.com", credentials); - listener.waitFor( - "online state", - [&listener]()->bool{ return listener.lastEvent()["state"].asString() == "online"; }); - } + login.connect("login.bar.com", credentials); + listener.waitFor( + "online state", + [&listener]()->bool{ return listener.lastEvent()["state"].asString() == "online"; }); + } template<> template<> void llviewerlogin_object::test<2>() { DEBUG; - // Test completed response, that fails to login. - set_test_name("LLLogin valid response, failure (eg. bad credentials)"); + // Test completed response, that fails to login. + set_test_name("LLLogin valid response, failure (eg. bad credentials)"); + + // Testing normal login procedure. + LLEventStream xmlrpcPump("LLXMLRPCTransaction"); // Dummy XMLRPC pump + + LLXMLRPCListener dummyXMLRPC("dummy_xmlrpc"); + LLTempBoundListener conn1 = dummyXMLRPC.listenTo(xmlrpcPump); + + LLLogin login; + LoginListener listener("test_ear"); + LLTempBoundListener conn2 = listener.listenTo(login.getEventPump()); + + LLSD credentials; + credentials["first"] = "who"; + credentials["last"] = "what"; + credentials["passwd"] = "badpasswd"; + + login.connect("login.bar.com", credentials); + llcoro::suspend(); + + ensure_equals("Auth state", listener.lastEvent()["change"].asString(), "authenticating"); + + auto prev = listener.getCalls(); + + // Send the failed auth request reponse + LLSD data; + data["status"] = "Complete"; + data["errorcode"] = 0; + data["error"] = "dummy response"; + data["transfer_rate"] = 0; + data["responses"]["login"] = "false"; + dummyXMLRPC.setResponse(data); + dummyXMLRPC.sendReply(); + // we happen to know LLLogin uses a 10-second timeout to try to sync + // with SLVersionChecker -- allow at least that much time before + // giving up + listener.waitFor(prev, 11.0); + + ensure_equals("Failed to offline", listener.lastEvent()["state"].asString(), "offline"); + } - // Testing normal login procedure. - LLEventStream xmlrpcPump("LLXMLRPCTransaction"); // Dummy XMLRPC pump + template<> template<> + void llviewerlogin_object::test<3>() + { + DEBUG; + // Test incomplete response, that end the attempt. + set_test_name("LLLogin valid response, failure (eg. bad credentials)"); - LLXMLRPCListener dummyXMLRPC("dummy_xmlrpc"); - LLTempBoundListener conn1 = dummyXMLRPC.listenTo(xmlrpcPump); + // Testing normal login procedure. + LLEventStream xmlrpcPump("LLXMLRPCTransaction"); // Dummy XMLRPC pump - LLLogin login; - LoginListener listener("test_ear"); - LLTempBoundListener conn2 = listener.listenTo(login.getEventPump()); + LLXMLRPCListener dummyXMLRPC("dummy_xmlrpc"); + LLTempBoundListener conn1 = dummyXMLRPC.listenTo(xmlrpcPump); - LLSD credentials; - credentials["first"] = "who"; - credentials["last"] = "what"; - credentials["passwd"] = "badpasswd"; + LLLogin login; + LoginListener listener("test_ear"); + LLTempBoundListener conn2 = listener.listenTo(login.getEventPump()); - login.connect("login.bar.com", credentials); - llcoro::suspend(); + LLSD credentials; + credentials["first"] = "these"; + credentials["last"] = "don't"; + credentials["passwd"] = "matter"; - ensure_equals("Auth state", listener.lastEvent()["change"].asString(), "authenticating"); + login.connect("login.bar.com", credentials); + llcoro::suspend(); - auto prev = listener.getCalls(); + ensure_equals("Auth state", listener.lastEvent()["change"].asString(), "authenticating"); - // Send the failed auth request reponse - LLSD data; - data["status"] = "Complete"; - data["errorcode"] = 0; - data["error"] = "dummy response"; - data["transfer_rate"] = 0; - data["responses"]["login"] = "false"; - dummyXMLRPC.setResponse(data); - dummyXMLRPC.sendReply(); - // we happen to know LLLogin uses a 10-second timeout to try to sync - // with SLVersionChecker -- allow at least that much time before - // giving up - listener.waitFor(prev, 11.0); + auto prev = listener.getCalls(); - ensure_equals("Failed to offline", listener.lastEvent()["state"].asString(), "offline"); - } + // Send the failed auth request reponse + LLSD data; + data["status"] = "OtherError"; + data["errorcode"] = 0; + data["error"] = "dummy response"; + data["transfer_rate"] = 0; + dummyXMLRPC.setResponse(data); + dummyXMLRPC.sendReply(); + // we happen to know LLLogin uses a 10-second timeout to try to sync + // with SLVersionChecker -- allow at least that much time before + // giving up + listener.waitFor(prev, 11.0); - template<> template<> - void llviewerlogin_object::test<3>() - { - DEBUG; - // Test incomplete response, that end the attempt. - set_test_name("LLLogin valid response, failure (eg. bad credentials)"); - - // Testing normal login procedure. - LLEventStream xmlrpcPump("LLXMLRPCTransaction"); // Dummy XMLRPC pump - - LLXMLRPCListener dummyXMLRPC("dummy_xmlrpc"); - LLTempBoundListener conn1 = dummyXMLRPC.listenTo(xmlrpcPump); - - LLLogin login; - LoginListener listener("test_ear"); - LLTempBoundListener conn2 = listener.listenTo(login.getEventPump()); - - LLSD credentials; - credentials["first"] = "these"; - credentials["last"] = "don't"; - credentials["passwd"] = "matter"; - - login.connect("login.bar.com", credentials); - llcoro::suspend(); - - ensure_equals("Auth state", listener.lastEvent()["change"].asString(), "authenticating"); - - auto prev = listener.getCalls(); - - // Send the failed auth request reponse - LLSD data; - data["status"] = "OtherError"; - data["errorcode"] = 0; - data["error"] = "dummy response"; - data["transfer_rate"] = 0; - dummyXMLRPC.setResponse(data); - dummyXMLRPC.sendReply(); - // we happen to know LLLogin uses a 10-second timeout to try to sync - // with SLVersionChecker -- allow at least that much time before - // giving up - listener.waitFor(prev, 11.0); - - ensure_equals("Failed to offline", listener.lastEvent()["state"].asString(), "offline"); - } + ensure_equals("Failed to offline", listener.lastEvent()["state"].asString(), "offline"); + } } |