|
1 /* |
|
2 * Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // [INCLUDE FILES] - do not remove |
|
21 #include <e32svr.h> |
|
22 #include <StifParser.h> |
|
23 #include <StifTestInterface.h> |
|
24 #include "senConnectionTester.h" |
|
25 |
|
26 // EXTERNAL INCLUDES |
|
27 #include <http.h> |
|
28 #include <httperr.h> |
|
29 |
|
30 #include <SenBaseFragment.h> |
|
31 #include <SenBaseElement.h> |
|
32 #include <SenDomFragment.h> |
|
33 #include <SenServiceConnection.h> |
|
34 #include <SenServicePattern.h> |
|
35 #include <SenSoapEnvelope.h> |
|
36 #include <SenSoapEnvelope2.h> |
|
37 #include <SenXmlReader.h> |
|
38 #include <SenXmlServiceDescription.h> |
|
39 #include <SenXmlUtils.h> |
|
40 #include <SenServiceManager.h> |
|
41 #include <SenIdentityProvider.h> |
|
42 #include <SenHttpTransportProperties.h> |
|
43 #include <SenSoapMessage.h> |
|
44 #include <SenSoapMessage2.h> |
|
45 #include <SenDateUtils.h> |
|
46 #include <SenTransportProperties.h> |
|
47 |
|
48 #include <senvtcptransportproperties.h> |
|
49 |
|
50 #include <xmlengchunkcontainer.h> |
|
51 #include <xmlengfilecontainer.h> |
|
52 #include <xmlengserializer.h> |
|
53 |
|
54 #include <e32base.h> // for CActive |
|
55 #include <aknnotewrappers.h> |
|
56 |
|
57 #include <commdb.h> |
|
58 |
|
59 #include <s32file.h> // filestream |
|
60 #include <e32svr.h> // fileman |
|
61 // EXTERNAL DATA STRUCTURES |
|
62 //extern ?external_data; |
|
63 |
|
64 // EXTERNAL FUNCTION PROTOTYPES |
|
65 //extern ?external_function( ?arg_type,?arg_type ); |
|
66 |
|
67 // CONSTANTS |
|
68 namespace |
|
69 { |
|
70 |
|
71 #ifdef AOL_RADIO_SERVICE |
|
72 // AOL redio.etenee.net:9080 |
|
73 _LIT8(KWSPContract, "urn:aol-com:services:radio"); |
|
74 _LIT8(KAuthServEndpoint, "http://radio.etenee.net:9080/tfs/IDPSSO_IDWSF"); |
|
75 _LIT8(KASProviderID, "http://radio.etenee.net:9080/tfs/"); |
|
76 _LIT8(KTestAuthzID, "012345678901234"); |
|
77 _LIT8(KTestPassword, "012345678901234"); |
|
78 #elif VALIMO_ADDRESSBOOK_SERVICE |
|
79 // Addressbook service hosted inside Nokia intra by ASP / testing team |
|
80 _LIT8(KWSPContract, "urn:nokia:test:addrbook:2004-09"); |
|
81 _LIT8(KAuthServEndpoint, "http://10.21.32.110/tfs/IDPSSO_IDWSF10"); |
|
82 _LIT8(KASProviderID, "provider01"); |
|
83 _LIT8(KTestAuthzID, "john"); |
|
84 _LIT8(KTestPassword, "password"); |
|
85 #elif SYSOPENDIGIA_ADDRESSBOOK_SERVICE |
|
86 |
|
87 _LIT8(KWSPContract, "urn:nokia:test:addrbook:2004-09"); |
|
88 _LIT8(KAuthServEndpoint, "http://ys01liw022.partner.yomi.com:9080/tfs/IDPSSO_IDWSF"); |
|
89 _LIT8(KASProviderID, "http://ys01liw022.partner.yomi.com:9080/tfs/"); |
|
90 _LIT8(KTestAuthzID, "012345678901234"); |
|
91 _LIT8(KTestPassword, "012345678901234"); |
|
92 #else // == default (no MACROs defined in .mmp) |
|
93 // Addressbook service hosted by Forum Nokia (accessible from external network) |
|
94 _LIT8(KWSPContract, "urn:nokia:test:addrbook:2004-09"); |
|
95 _LIT8(KAuthServEndpoint, "http://selma.ndhub.net:9080/tfs/IDPSSO_IDWSF"); |
|
96 _LIT8(KASProviderID, "http://selma.ndhub.net:9080/tfs/"); |
|
97 _LIT8(KTestAuthzID, "testuser1"); |
|
98 _LIT8(KTestPassword, "testuser1"); |
|
99 #endif // FN_ADDRESSBOOK_SERVICE |
|
100 |
|
101 |
|
102 _LIT8(KASContract, "urn:liberty:as:2004-04"); |
|
103 _LIT8(KHttpsEndPoint, "https://10.21.32.110/sereneHardCoded/WS_WSI_R9980_001" ); |
|
104 |
|
105 _LIT8(KWSIFrameworkID, "WS-I"); |
|
106 _LIT8(KIDWSFFrameworkID, "ID-WSF"); |
|
107 _LIT8(KRESTFrameworkID, "REST"); |
|
108 // _LIT8(KWsStarFrameworkID, "WS-STAR"); |
|
109 #ifdef SYSOPENDIGIA_ADDRESSBOOK_SERVICE |
|
110 _LIT8(KAddressBookServiceId, "http://radio.aol.com/xsd/2.0/ns/"); |
|
111 _LIT8(KAddressBookContract, "http://radio.aol.com/xsd/2.0/ns/"); |
|
112 #else |
|
113 _LIT8(KAddressBookServiceId, "urn:nokia:test:addrbook:2004-09"); |
|
114 _LIT8(KAddressBookContract, "urn:nokia:test:addrbook:2004-09"); |
|
115 #endif |
|
116 |
|
117 #ifdef __WINS__ |
|
118 #ifdef SYSOPENDIGIA_ADDRESSBOOK_SERVICE |
|
119 _LIT(KIAPName, "Ethernet No Daemon Static IP"); |
|
120 #else |
|
121 //_LIT(KIAPName, "Ethernet No Daemon Static IP"); |
|
122 _LIT(KIAPName, "Ethernet with Daemon Dynamic IP"); |
|
123 #endif |
|
124 #else |
|
125 // ARMv5 |
|
126 _LIT(KIAPName, "Internet"); |
|
127 #endif |
|
128 _LIT8(KLoggerFileNameProperty, "HttpLoggerFileName"); |
|
129 |
|
130 _LIT(KFileToRead, "e:\\Logs\\LoggingHttpFilter\\httptrace.xml"); |
|
131 _LIT8(KFileName, "httptrace.xml"); |
|
132 |
|
133 _LIT8(KHTTPMethodGet, "GET"); |
|
134 _LIT8(KHTTPMethodPost, "POST"); |
|
135 |
|
136 // const TBool MultipleSimultanousRHttpSessionsSupported = EFalse; |
|
137 // If IAP changes all previously sent messages will be canceled. |
|
138 |
|
139 |
|
140 //_LIT8(KProxyHost, "esprx00.nokia.com"); |
|
141 _LIT8(KProxyHost, "172.19.160.50"); // IP address to: bsprx01.americas.nokia.com |
|
142 const TInt KProxyPort = 8080; |
|
143 |
|
144 //MSN Constants : |
|
145 //--------------- |
|
146 _LIT8(KPassportUser, "m_minkkis@hotmail.com"); |
|
147 _LIT8(KPassportPass, "M1nkk1s"); |
|
148 |
|
149 _LIT8(KStsEndpoint, "https://login.live.com/rst2.srf"); |
|
150 _LIT8(KMSNProxy, "tcp.mws.beta.mobile.live.com"); |
|
151 //_LIT8(KMetadataEndpoint, "http://10.132.11.31/WSStar/secpolicy/secpol.xml"); |
|
152 _LIT8(KMetadataEndpoint, "https://http.mws.mobile.live.com/2006/10/MWP2007_02/SecurityPolicy/Default.aspx"); |
|
153 |
|
154 _LIT8(KPolicyAdr, "Addressing"); |
|
155 _LIT8(KPolicyMT, "MetadataEndpoint"); |
|
156 _LIT8(KPolicyTLS, "UsernameTokenOverTLS"); |
|
157 _LIT8(KPolicySOAP12, "SOAP12"); |
|
158 _LIT8(KPolicyPassExt, "PassportExtensions"); |
|
159 _LIT8(KProviderId, "provider01"); |
|
160 |
|
161 #ifdef OLD_MSN_NAMESPACE_2005_08 |
|
162 _LIT8(KMessagingEndpoint, "tcp://schemas.live.com/mws/2005/08/messaging"); |
|
163 _LIT8(KMessagingContract, "http://schemas.live.com/mws/2005/08/messaging"); |
|
164 _LIT8(KMessagingNameSpace, "http://schemas.live.com/mws/2005/08/core"); |
|
165 #else |
|
166 _LIT8(KMessagingEndpoint, "tcp://schemas.live.com/mws/2006/10/messaging"); |
|
167 _LIT8(KMessagingContract, "http://schemas.live.com/mws/2006/10/messaging"); |
|
168 _LIT8(KMessagingNameSpace, "http://schemas.live.com/mws/2006/10/core"); |
|
169 #endif |
|
170 } |
|
171 |
|
172 // MACROS |
|
173 //#define ?macro ?macro_def |
|
174 #define STIFF_ASSERT_NOT_EQUALS_DESC(expression1, expression2, desc) \ |
|
175 {TL((expression1) != (expression2)){RDebug::Print(_L(desc)) ;}} |
|
176 |
|
177 #define STIFF_ASSERT_DESC(expression, desc) {if(!(expression)){RDebug::Print(_L(desc)) ;return KErrArgument;}} |
|
178 #define LOCAL_ASSERT(expression) {if(!(expression)){return KErrArgument;}} |
|
179 |
|
180 // LOCAL CONSTANTS AND MACROS |
|
181 //const ?type ?constant_var = ?constant; |
|
182 //#define ?macro_name ?macro_def |
|
183 |
|
184 // MODULE DATA STRUCTURES |
|
185 //enum ?declaration |
|
186 //typedef ?declaration |
|
187 |
|
188 // LOCAL FUNCTION PROTOTYPES |
|
189 //?type ?function_name( ?arg_type, ?arg_type ); |
|
190 |
|
191 // FORWARD DECLARATIONS |
|
192 //class ?FORWARD_CLASSNAME; |
|
193 |
|
194 // ============================= LOCAL FUNCTIONS =============================== |
|
195 |
|
196 // ----------------------------------------------------------------------------- |
|
197 // ?function_name ?description. |
|
198 // ?description |
|
199 // Returns: ?value_1: ?description |
|
200 // ?value_n: ?description_line1 |
|
201 // ?description_line2 |
|
202 // ----------------------------------------------------------------------------- |
|
203 // |
|
204 /* |
|
205 ?type ?function_name( |
|
206 ?arg_type arg, // ?description |
|
207 ?arg_type arg) // ?description |
|
208 { |
|
209 |
|
210 ?code // ?comment |
|
211 |
|
212 // ?comment |
|
213 ?code |
|
214 } |
|
215 */ |
|
216 |
|
217 // ============================ MEMBER FUNCTIONS =============================== |
|
218 |
|
219 // ----------------------------------------------------------------------------- |
|
220 // CsenConnectionTester::Delete |
|
221 // Delete here all resources allocated and opened from test methods. |
|
222 // Called from destructor. |
|
223 // ----------------------------------------------------------------------------- |
|
224 // |
|
225 void CsenConnectionTester::Delete() |
|
226 { |
|
227 |
|
228 } |
|
229 |
|
230 // ----------------------------------------------------------------------------- |
|
231 // CsenConnectionTester::RunMethodL |
|
232 // Run specified method. Contains also table of test mothods and their names. |
|
233 // ----------------------------------------------------------------------------- |
|
234 // |
|
235 TInt CsenConnectionTester::RunMethodL( |
|
236 CStifItemParser& aItem ) |
|
237 { |
|
238 |
|
239 static TStifFunctionInfo const KFunctions[] = |
|
240 { |
|
241 // Copy this line for every implemented function. |
|
242 // First string is the function name used in TestScripter script file. |
|
243 // Second is the actual implementation member function. |
|
244 ENTRY("RegisterIdentityProviderL_CSenServiceConnection_RegisterIdentityProviderL",CsenConnectionTester::UT_CSenServiceConnection_RegisterIdentityProviderLL), |
|
245 ENTRY("NewL-contracttest_CSenServiceConnection_NewLcontract",CsenConnectionTester::UT_CSenServiceConnection_NewL_ContractL), |
|
246 ENTRY("SendL,Pattern,IAP1Test_CSenServiceConnection_SendL,Pattern,IAP1Test",CsenConnectionTester::UT_CSenServiceConnection_SendL_Pattern_IAP1L), |
|
247 ENTRY("SendL,Pattern,IAP2Test_CSenServiceConnection_SendL,Pattern,IAP2Test",CsenConnectionTester::UT_CSenServiceConnection_SendL_Pattern_IAP2L), |
|
248 ENTRY("SendL,Pattern,IAP3Test_CSenServiceConnection_SendL,Pattern,IAP3Test",CsenConnectionTester::UT_CSenServiceConnection_SendL_Pattern_IAP3L), |
|
249 ENTRY("NewLC-contracttest_CSenServiceConnection_NewLCcontract",CsenConnectionTester::UT_CSenServiceConnection_NewLC_ContractL), |
|
250 ENTRY("NewL-descriptiontestforWS-I_CSenServiceConnection_NewLdescriptionforWS-I",CsenConnectionTester::UT_CSenServiceConnection_NewL_WS_I_DescriptionL), |
|
251 ENTRY("NewLC-descriptiontestforWS-I_CSenServiceConnection_NewLCdescriptionforWS-I",CsenConnectionTester::UT_CSenServiceConnection_NewLC_WS_I_DescriptionL), |
|
252 ENTRY("NewL-descriptiontestforID-WSF_CSenServiceConnection_NewLdescriptionforID-WSF",CsenConnectionTester::UT_CSenServiceConnection_NewL_ID_WSF_DescriptionL), |
|
253 ENTRY("NewLC-descriptiontestforID-WSF_CSenServiceConnection_NewLCdescriptionforID-WSF",CsenConnectionTester::UT_CSenServiceConnection_NewLC_ID_WSF_DescriptionL), |
|
254 ENTRY("NewL-patterntestforWS-I_CSenServiceConnection_NewLpatternforWS-I",CsenConnectionTester::UT_CSenServiceConnection_NewL_WS_I_PatternL), |
|
255 ENTRY("NewLC-patterntestforWS-I_CSenServiceConnection_NewLCpatternforWS-I",CsenConnectionTester::UT_CSenServiceConnection_NewLC_WS_I_PatternL), |
|
256 ENTRY("NewL-patterntestforID-WSF_CSenServiceConnection_NewLpatternforID-WSF",CsenConnectionTester::UT_CSenServiceConnection_NewL_ID_WSF_PatternL), |
|
257 ENTRY("NewLC-patterntestforID-WSF_CSenServiceConnection_NewLCpatternforID-WSF",CsenConnectionTester::UT_CSenServiceConnection_NewLC_ID_WSF_PatternL), |
|
258 ENTRY("SendL-noerrortest_CSenServiceConnection_SendLnoerror",CsenConnectionTester::UT_CSenServiceConnection_SendL_NoErrorL), |
|
259 ENTRY("SendL-canceltest_CSenServiceConnection_SendLnoerror",CsenConnectionTester::UT_CSenServiceConnection_SendL_CancelL), |
|
260 ENTRY("SendL-connectionisnotinitializedtest_CSenServiceConnection_SendLconnectionisnotinitialized",CsenConnectionTester::UT_CSenServiceConnection_SendL_ConNotInitialL), |
|
261 ENTRY("SendL-MultipleMessages_CSenServiceConnection_SendLMultipleMessages",CsenConnectionTester::UT_CSenServiceConnection_SendMultipleMessagesL), |
|
262 ENTRY("SendL,Get,Post1Test_CSenServiceConnection_SendL,Get,Post1Test",CsenConnectionTester::UT_CSenServiceConnection_SendL_Get_Post1L), |
|
263 ENTRY("SendL,Get,Post2Test_CSenServiceConnection_SendL,Get,Post2Test",CsenConnectionTester::UT_CSenServiceConnection_SendL_Get_Post2L), |
|
264 ENTRY("SendL,Post,Proxy1Test_CSenServiceConnection_SendL,Post,Proxy1Test",CsenConnectionTester::UT_CSenServiceConnection_SendL_Proxy1L), |
|
265 ENTRY("SendL,Post,Proxy2Test_CSenServiceConnection_SendLconnectionisnotinitialized",CsenConnectionTester::UT_CSenServiceConnection_SendL_Proxy2L), |
|
266 ENTRY("SendL,ContentType1Test_CSenServiceConnection_SendL,ContentType1Test",CsenConnectionTester::UT_CSenServiceConnection_SendL_ContentType1L), |
|
267 ENTRY("SendL,ContentType2Test_CSenServiceConnection_SendL,ContentType2Test",CsenConnectionTester::UT_CSenServiceConnection_SendL_ContentType2L), |
|
268 ENTRY("SendL,UserAgent1Test_CSenServiceConnection_SendL,UserAgent1Test",CsenConnectionTester::UT_CSenServiceConnection_SendL_UserAgent1L), |
|
269 ENTRY("SendL,UserAgent2Test_CSenServiceConnection_SendL,UserAgent2Test",CsenConnectionTester::UT_CSenServiceConnection_SendL_UserAgent2L), |
|
270 ENTRY("SendL,MessageSoapActionTest_CSenServiceConnection_SendL,MessageSoapActionTest",CsenConnectionTester::UT_CSenServiceConnection_SendL_MessageSoapActionL), |
|
271 ENTRY("SendL,SoapAction1Test_CSenServiceConnection_SendL,SoapAction1Test",CsenConnectionTester::UT_CSenServiceConnection_SendL_SoapAction1L), |
|
272 ENTRY("SendL,SoapAction2Test_CSenServiceConnection_SendL,SoapAction2Test",CsenConnectionTester::UT_CSenServiceConnection_SendL_SoapAction2L), |
|
273 ENTRY("SendL,CustomHttpHeaderTest_CSenServiceConnection_SendL,CustomHttpHeaderTest",CsenConnectionTester::UT_CSenServiceConnection_SendL_CustomHttpHeaderL), |
|
274 ENTRY("SendL,TPboundariesTest_CSenServiceConnection_SendL,TPboundariesTest",CsenConnectionTester::UT_CSenServiceConnection_TP_Boundaries1), |
|
275 ENTRY("SendL,TPboundariesTest_CSenServiceConnection_",CsenConnectionTester::UT_CSenServiceConnection_TP_Boundaries2), |
|
276 ENTRY("SendL,TPboundariesTest_CSenServiceConnection_",CsenConnectionTester::UT_CSenServiceConnection_TP_Boundaries3), |
|
277 ENTRY("SendL,TPboundariesTest_CSenServiceConnection_",CsenConnectionTester::UT_CSenServiceConnection_TP_Boundaries4), |
|
278 ENTRY("SendL,TPboundariesTest_CSenServiceConnection_",CsenConnectionTester::UT_CSenServiceConnection_TP_Boundaries5), |
|
279 ENTRY("SendL,TPboundariesTest_CSenServiceConnection_",CsenConnectionTester::UT_CSenServiceConnection_TP_Boundaries6), |
|
280 ENTRY("SendL,TPboundariesTest_CSenServiceConnection_",CsenConnectionTester::UT_CSenServiceConnection_TP_Boundaries7), |
|
281 ENTRY("SendL,TPboundariesTest_CSenServiceConnection_",CsenConnectionTester::UT_CSenServiceConnection_TP_Boundaries8), |
|
282 ENTRY("SendL,TPboundariesTest_CSenServiceConnection_",CsenConnectionTester::UT_CSenServiceConnection_TP_Boundaries9), |
|
283 ENTRY("SendL,TPSecDialogTest_CSenServiceConnection_SendLconnectionisnotinitialized",CsenConnectionTester::UT_CSenServiceConnection_TP_SecDialog), |
|
284 ENTRY("SendL,TPOmittedTrueTest_CSenServiceConnection_",CsenConnectionTester::UT_CSenServiceConnection_TP_Omitted_True), |
|
285 ENTRY("SendL,TPOmittedFalseTest_CSenServiceConnection_",CsenConnectionTester::UT_CSenServiceConnection_TP_Omitted_False), |
|
286 ENTRY("SendL,TPRemovedTest_CSenServiceConnection_",CsenConnectionTester::UT_CSenServiceConnection_TP_Removed), |
|
287 ENTRY("SendL,TPOmit/RemTest_CSenServiceConnection_",CsenConnectionTester::UT_CSenServiceConnection_TP_Omit_Rem), |
|
288 ENTRY("SubmitL,LibXml2_CSenServiceConnection_",CsenConnectionTester::UT_CSenServiceConnection_SubmitL_LibXml2_L), |
|
289 ENTRY("SubmitL,LibXml2+props_CSenServiceConnection_",CsenConnectionTester::UT_CSenServiceConnection_SubmitL_LibXml2_with_Properties_L), |
|
290 ENTRY("SubmitL,BLOB20KB_CSenServiceConnection_",CsenConnectionTester::UT_CSenServiceConnection_SubmitL_LibXml2_MTOM_20KBL), |
|
291 ENTRY("SubmitL,BLOB200KB_CSenServiceConnection_",CsenConnectionTester::UT_CSenServiceConnection_SubmitL_LibXml2_MTOM_200KBL), |
|
292 ENTRY("SubmitL,BLOBless1MB_CSenServiceConnection_",CsenConnectionTester::UT_CSenServiceConnection_SubmitL_LibXml2_MTOM_Less1MBL), |
|
293 ENTRY("SubmitL,BLOBmore1MB_CSenServiceConnection_",CsenConnectionTester::UT_CSenServiceConnection_SubmitL_LibXml2_MTOM_More1MBL), |
|
294 ENTRY("MSN-Basiccase_CSenServiceConnection_",CsenConnectionTester::UT_CSenServiceConnection_TestMessengerL), |
|
295 ENTRY("MSN-ReUseCredential_CSenServiceConnection_",CsenConnectionTester::UT_CSenServiceConnection_TestMessenger2L), |
|
296 ENTRY("MSN-AuthCallbacksuccess_CSenServiceConnection_",CsenConnectionTester::UT_CSenServiceConnection_TestMessenger3L), |
|
297 ENTRY("MSN-AuthCallbackfail_CSenServiceConnection_",CsenConnectionTester::UT_CSenServiceConnection_TestMessenger4L), |
|
298 ENTRY("MSN-UserInfoPrompt_CSenServiceConnection_",CsenConnectionTester::UT_CSenServiceConnection_TestMessenger5L), |
|
299 ENTRY("MSN-showprompt_CSenServiceConnection_",CsenConnectionTester::UT_CSenServiceConnection_TestMessenger6L), |
|
300 ENTRY("MSN-Invalidpassword_CSenServiceConnection_",CsenConnectionTester::UT_CSenServiceConnection_TestMessenger7L), |
|
301 // [test cases entries] - Do not remove |
|
302 |
|
303 }; |
|
304 |
|
305 const TInt count = sizeof( KFunctions ) / |
|
306 sizeof( TStifFunctionInfo ); |
|
307 |
|
308 return RunInternalL( KFunctions, count, aItem ); |
|
309 |
|
310 } |
|
311 |
|
312 // ----------------------------------------------------------------------------- |
|
313 // METHODS |
|
314 // ----------------------------------------------------------------------------- |
|
315 void CsenConnectionTester::HandleMessageL(const TDesC8& aMessage) |
|
316 { |
|
317 iCallback = ECallbackHandleMessage; |
|
318 if ( ipMessage ) |
|
319 { |
|
320 delete ipMessage; |
|
321 ipMessage = NULL; |
|
322 } |
|
323 ipMessage = aMessage.AllocL(); |
|
324 iTransactionId = iServiceConnection->TxnId(); |
|
325 |
|
326 StopActiveScheduler(); |
|
327 } |
|
328 |
|
329 void CsenConnectionTester::HandleErrorL(const int aErrorCode, const TDesC8& aError) |
|
330 { |
|
331 iCallback = ECallbackHandleError; |
|
332 iErrorCode = aErrorCode; |
|
333 |
|
334 // debugging only - START |
|
335 if( HTTPStatus::IsInformational( this->iErrorCode ) ) |
|
336 { |
|
337 // if((aStatus >= HTTPStatus::EContinue) && (aStatus < HTTPStatus::EOk)) |
|
338 RDebug::Print(_L("- HTTP error code: IS INFORMATION.")); |
|
339 } |
|
340 if( HTTPStatus::IsSuccessful( this->iErrorCode ) ) |
|
341 { |
|
342 // if((aStatus >= HTTPStatus::EOk) && (aStatus < HTTPStatus::EMultipleChoices)) |
|
343 RDebug::Print(_L("- HTTP error code: IS SUCCESSFUL.")); |
|
344 } |
|
345 if( HTTPStatus::IsRedirection( this->iErrorCode ) ) |
|
346 { |
|
347 // if((aStatus >= HTTPStatus::EMultipleChoices) && (aStatus < HTTPStatus::EBadRequest)) |
|
348 RDebug::Print(_L("- HTTP error code: IS REDIRECTION.")); |
|
349 } |
|
350 if( HTTPStatus::IsClientError( this->iErrorCode ) ) |
|
351 { |
|
352 // if((aStatus >= HTTPStatus::EBadRequest) && (aStatus < HTTPStatus::EInternalServerError)) |
|
353 RDebug::Print(_L("- HTTP error code: IS CLIENT ERROR.")); |
|
354 } |
|
355 if( HTTPStatus::IsServerError( this->iErrorCode ) ) |
|
356 { |
|
357 // if(aStatus >= HTTPStatus::EInternalServerError) |
|
358 RDebug::Print(_L("- HTTP error code: IS CLIENT ERROR.")); |
|
359 } |
|
360 // debuggin only - END |
|
361 |
|
362 if ( ipMessage ) |
|
363 { |
|
364 delete ipMessage; |
|
365 ipMessage = NULL; |
|
366 } |
|
367 ipMessage = aError.AllocL(); |
|
368 iTransactionId = iServiceConnection->TxnId(); |
|
369 |
|
370 TBuf<70> errorMessage; |
|
371 _LIT(KErrNotInitialized, "Connection isn't initialized."); |
|
372 |
|
373 switch(aErrorCode) |
|
374 { |
|
375 case KErrSubmitting: |
|
376 errorMessage = KErrNotInitialized; |
|
377 break; |
|
378 default: |
|
379 break; |
|
380 } |
|
381 |
|
382 StopActiveScheduler(); |
|
383 } |
|
384 |
|
385 void CsenConnectionTester::ErrorL(TInt aCode) |
|
386 { |
|
387 _LIT(KNotReady, "Connection is not ready."); |
|
388 |
|
389 TBuf<70> errorMessage; |
|
390 switch(aCode) |
|
391 { |
|
392 case EConnectionNotReady: |
|
393 errorMessage = KNotReady; |
|
394 break; |
|
395 default: |
|
396 break; |
|
397 } |
|
398 } |
|
399 |
|
400 void CsenConnectionTester::SetStatus(const TInt aStatus) |
|
401 { |
|
402 switch(aStatus) |
|
403 { |
|
404 case KSenConnectionStatusNew: |
|
405 break; |
|
406 case KSenConnectionStatusReady: |
|
407 iInitialized = ETrue; |
|
408 break; |
|
409 case KSenConnectionStatusExpired: |
|
410 break; |
|
411 default: |
|
412 TBuf<32> num; |
|
413 num.AppendNum(aStatus); |
|
414 break; |
|
415 } |
|
416 if ( aStatus >= KSenConnectionStatusCreateFailed && aStatus <= KSenConnectionStatusMetadataExchange ) |
|
417 { |
|
418 iConnectionState = aStatus; |
|
419 if(!iInitialized) |
|
420 { |
|
421 TInt leaveCode(KErrNone); |
|
422 TRAP(leaveCode, ErrorL(EConnectionNotReady)); |
|
423 leaveCode = 0; // not used |
|
424 } |
|
425 StopActiveScheduler(); |
|
426 } |
|
427 } |
|
428 |
|
429 void CsenConnectionTester::SetupL( ) |
|
430 { |
|
431 __UHEAP_MARK; |
|
432 |
|
433 RFile file; |
|
434 RFs iFsSession; |
|
435 _LIT(KFileName,"e:\\testing\\data\\rest.on"); |
|
436 |
|
437 |
|
438 User::LeaveIfError(iFsSession.Connect()); |
|
439 |
|
440 TInt fileOP = file.Open(iFsSession,KFileName,EFileRead); |
|
441 if (fileOP == KErrNone) |
|
442 { |
|
443 RDebug::Print(_L( "Found rest.on file => using RESTful framework" ) ); |
|
444 file.Close(); |
|
445 ipFrameworkID = HBufC8::NewL(KRESTFrameworkID().Length()); |
|
446 ipFrameworkID->Des().Append(KRESTFrameworkID); |
|
447 } |
|
448 else |
|
449 { |
|
450 RDebug::Print(_L( "File rest.on not found => defaulting to WS-I" ) ); |
|
451 ipFrameworkID = HBufC8::NewL(KWSIFrameworkID().Length()); |
|
452 ipFrameworkID->Des().Append(KWSIFrameworkID); |
|
453 } |
|
454 iFsSession.Close(); |
|
455 |
|
456 iCallback = ECallbackNone; |
|
457 } |
|
458 |
|
459 void CsenConnectionTester::Teardown( ) |
|
460 { |
|
461 delete ipFrameworkID; |
|
462 ipFrameworkID = NULL; |
|
463 delete ipMessage; |
|
464 ipMessage = NULL; |
|
465 delete ipProviderForAuthProvider; |
|
466 ipProviderForAuthProvider = NULL; |
|
467 __UHEAP_MARKEND; |
|
468 } |
|
469 |
|
470 TInt CsenConnectionTester::UT_CSenServiceConnection_RegisterIdentityProviderLL() |
|
471 { |
|
472 iManager = CSenServiceManager::NewL(); |
|
473 STIFF_ASSERT_NOT_EQUALS_DESC(iManager, (CSenServiceManager*)NULL, "The test is failed."); |
|
474 |
|
475 CSenIdentityProvider* idp = CSenIdentityProvider::NewLC( |
|
476 KAuthServEndpoint, KASContract); |
|
477 |
|
478 // Set the Provider ID |
|
479 idp->SetProviderID(KASProviderID); |
|
480 |
|
481 // Associate Forum Nokia's Addressbook service ID (contract) |
|
482 // to this Identity Provider |
|
483 idp->SetServiceID(KWSPContract); |
|
484 |
|
485 // Set Liberty ID-WSF framework ID |
|
486 idp->SetFrameworkIdL(KDefaultIdWsfFrameworkID); |
|
487 |
|
488 // ------------------------------------------------------------------------ |
|
489 // The following username/password properties will be used for |
|
490 // authentication. Please note, that use advisory authentication |
|
491 // id "IMEI" would result device ID to be directly fetched from phone. |
|
492 // ------------------------------------------------------------------------ |
|
493 // |
|
494 |
|
495 #if SYSOPENDIGIA_ADDRESSBOOK_SERVICE |
|
496 idp->SetUserInfoL(KNullDesC8, KTestAuthzID, KTestPassword); |
|
497 #else |
|
498 idp->SetUserInfoL(KTestAuthzID, KNullDesC8, KTestPassword); |
|
499 #endif |
|
500 |
|
501 TL((iManager->RegisterIdentityProviderL(*idp)) == KErrNone); |
|
502 TL((iManager->RegisterServiceDescriptionL(*idp)) == KErrNone); |
|
503 |
|
504 CleanupStack::PopAndDestroy(idp); |
|
505 |
|
506 __ASSERT_ALWAYS_NO_LEAVE(delete iManager); |
|
507 iManager = NULL; |
|
508 return KErrNone; |
|
509 } |
|
510 |
|
511 TInt CsenConnectionTester::UT_CSenServiceConnection_NewL_ContractL( ) |
|
512 { |
|
513 iServiceConnection = CSenServiceConnection::NewL(*this, KAddressBookContract); |
|
514 StartActiveScheduler(1); |
|
515 |
|
516 LOCAL_ASSERT(iConnectionState == KSenConnectionStatusReady); |
|
517 TL(iServiceConnection != (CSenServiceConnection*)NULL); |
|
518 |
|
519 __ASSERT_ALWAYS_NO_LEAVE(delete iServiceConnection); |
|
520 iServiceConnection = NULL; |
|
521 return KErrNone; |
|
522 } |
|
523 |
|
524 TInt CsenConnectionTester::UT_CSenServiceConnection_NewLC_ContractL( ) |
|
525 { |
|
526 iServiceConnection = CSenServiceConnection::NewLC(*this, KAddressBookContract); |
|
527 StartActiveScheduler(1); |
|
528 |
|
529 LOCAL_ASSERT(iConnectionState == KSenConnectionStatusReady); |
|
530 TL(iServiceConnection != (CSenServiceConnection*)NULL); |
|
531 |
|
532 CleanupStack::Pop(iServiceConnection); |
|
533 __ASSERT_ALWAYS_NO_LEAVE(delete iServiceConnection); |
|
534 iServiceConnection = NULL; |
|
535 return KErrNone; |
|
536 } |
|
537 |
|
538 TInt CsenConnectionTester::UT_CSenServiceConnection_NewL_WS_I_DescriptionL( ) |
|
539 { |
|
540 // Only Endpoint and FrameworkId needs to be defined in WS-I case. |
|
541 // There is no need to define Contract. => KNullDesC8 is passed as a Contract. |
|
542 iSenXmlServiceDescription = CSenXmlServiceDescription::NewL(KAuthServEndpoint, KNullDesC8()); |
|
543 iSenXmlServiceDescription->SetFrameworkIdL(*ipFrameworkID); |
|
544 |
|
545 iServiceConnection = CSenServiceConnection::NewL(*this, *iSenXmlServiceDescription); |
|
546 StartActiveScheduler(1); |
|
547 |
|
548 STIFF_ASSERT_DESC(iConnectionState == KSenConnectionStatusReady, |
|
549 "Could not initialize ServiceConnection"); |
|
550 |
|
551 __ASSERT_ALWAYS_NO_LEAVE(delete iServiceConnection); |
|
552 iServiceConnection = NULL; |
|
553 |
|
554 __ASSERT_ALWAYS_NO_LEAVE(delete iSenXmlServiceDescription); |
|
555 iSenXmlServiceDescription = NULL; |
|
556 return KErrNone; |
|
557 } |
|
558 |
|
559 TInt CsenConnectionTester::UT_CSenServiceConnection_NewLC_WS_I_DescriptionL( ) |
|
560 { |
|
561 // Only Endpoint and FrameworkId needs to be defined in WS-I case. |
|
562 // There is no need to define Contract. => KNullDesC8 is passed as a Contract. |
|
563 iSenXmlServiceDescription = CSenXmlServiceDescription::NewL(KAuthServEndpoint, KNullDesC8()); |
|
564 iSenXmlServiceDescription->SetFrameworkIdL(*ipFrameworkID); |
|
565 |
|
566 iServiceConnection = CSenServiceConnection::NewLC(*this, *iSenXmlServiceDescription); |
|
567 StartActiveScheduler(1); |
|
568 |
|
569 STIFF_ASSERT_DESC(iConnectionState == KSenConnectionStatusReady, |
|
570 "Could not initialize ServiceConnection"); |
|
571 |
|
572 CleanupStack::Pop(iServiceConnection); |
|
573 __ASSERT_ALWAYS_NO_LEAVE(delete iServiceConnection); |
|
574 iServiceConnection = NULL; |
|
575 |
|
576 __ASSERT_ALWAYS_NO_LEAVE(delete iSenXmlServiceDescription); |
|
577 iSenXmlServiceDescription = NULL; |
|
578 return KErrNone; |
|
579 } |
|
580 |
|
581 TInt CsenConnectionTester::UT_CSenServiceConnection_NewL_ID_WSF_DescriptionL( ) |
|
582 { |
|
583 iSenXmlServiceDescription = CSenXmlServiceDescription::NewL(); |
|
584 iSenXmlServiceDescription->SetFrameworkIdL(KIDWSFFrameworkID); |
|
585 iSenXmlServiceDescription->SetContractL(KAddressBookServiceId); |
|
586 |
|
587 TUint32 iapId = SearchIAPIdByNameL(KIAPName); |
|
588 iSenXmlServiceDescription->SetIapIdL(iapId); |
|
589 |
|
590 iServiceConnection = CSenServiceConnection::NewL(*this, *iSenXmlServiceDescription); |
|
591 StartActiveScheduler(1); |
|
592 |
|
593 STIFF_ASSERT_DESC(iConnectionState == KSenConnectionStatusReady, |
|
594 "Could not initialize ServiceConnection"); |
|
595 |
|
596 __ASSERT_ALWAYS_NO_LEAVE(delete iServiceConnection); |
|
597 iServiceConnection = NULL; |
|
598 |
|
599 __ASSERT_ALWAYS_NO_LEAVE(delete iSenXmlServiceDescription); |
|
600 iSenXmlServiceDescription = NULL; |
|
601 return KErrNone; |
|
602 } |
|
603 |
|
604 TInt CsenConnectionTester::UT_CSenServiceConnection_NewLC_ID_WSF_DescriptionL( ) |
|
605 { |
|
606 iSenXmlServiceDescription = CSenXmlServiceDescription::NewL(); |
|
607 iSenXmlServiceDescription->SetFrameworkIdL(KIDWSFFrameworkID); |
|
608 iSenXmlServiceDescription->SetContractL(KAddressBookServiceId); |
|
609 |
|
610 TUint32 iapId = SearchIAPIdByNameL(KIAPName); |
|
611 iSenXmlServiceDescription->SetIapIdL(iapId); |
|
612 |
|
613 iServiceConnection = CSenServiceConnection::NewLC(*this, *iSenXmlServiceDescription); |
|
614 StartActiveScheduler(1); |
|
615 |
|
616 STIFF_ASSERT_DESC(iConnectionState == KSenConnectionStatusReady, |
|
617 "Could not initialize ServiceConnection"); |
|
618 |
|
619 CleanupStack::Pop(iServiceConnection); |
|
620 __ASSERT_ALWAYS_NO_LEAVE(delete iServiceConnection); |
|
621 iServiceConnection = NULL; |
|
622 |
|
623 __ASSERT_ALWAYS_NO_LEAVE(delete iSenXmlServiceDescription); |
|
624 iSenXmlServiceDescription = NULL; |
|
625 return KErrNone; |
|
626 } |
|
627 |
|
628 TInt CsenConnectionTester::UT_CSenServiceConnection_NewL_WS_I_PatternL( ) |
|
629 { |
|
630 CSenServicePattern* pSenServicePattern = CSenServicePattern::NewLC(KAuthServEndpoint, KNullDesC8()); |
|
631 pSenServicePattern->SetFrameworkIdL(*ipFrameworkID); |
|
632 //pSenServicePattern->SetContractL(KAuthServEndpoint); |
|
633 |
|
634 iServiceConnection = CSenServiceConnection::NewL(*this, *pSenServicePattern); |
|
635 StartActiveScheduler(1); |
|
636 |
|
637 STIFF_ASSERT_DESC(iConnectionState == KSenConnectionStatusReady, |
|
638 "Could not initialize ServiceConnection"); |
|
639 |
|
640 __ASSERT_ALWAYS_NO_LEAVE(delete iServiceConnection); |
|
641 iServiceConnection = NULL; |
|
642 |
|
643 CleanupStack::Pop(pSenServicePattern); |
|
644 __ASSERT_ALWAYS_NO_LEAVE(delete pSenServicePattern); |
|
645 pSenServicePattern = NULL; |
|
646 return KErrNone; |
|
647 } |
|
648 |
|
649 TInt CsenConnectionTester::UT_CSenServiceConnection_NewLC_WS_I_PatternL( ) |
|
650 { |
|
651 CSenServicePattern* aSenServicePattern = CSenServicePattern::NewL(KAuthServEndpoint, KNullDesC8()); |
|
652 aSenServicePattern->SetFrameworkIdL(*ipFrameworkID); |
|
653 //aSenServicePattern->SetContractL(KAuthServEndpoint); |
|
654 |
|
655 iServiceConnection = CSenServiceConnection::NewLC(*this, *aSenServicePattern); |
|
656 StartActiveScheduler(1); |
|
657 |
|
658 STIFF_ASSERT_DESC(iConnectionState == KSenConnectionStatusReady, |
|
659 "Could not initialize ServiceConnection"); |
|
660 |
|
661 CleanupStack::Pop(); //iServiceConnection |
|
662 __ASSERT_ALWAYS_NO_LEAVE(delete iServiceConnection); |
|
663 iServiceConnection = NULL; |
|
664 |
|
665 delete aSenServicePattern; |
|
666 aSenServicePattern = NULL; |
|
667 return KErrNone; |
|
668 } |
|
669 |
|
670 TInt CsenConnectionTester::UT_CSenServiceConnection_NewL_ID_WSF_PatternL( ) |
|
671 { |
|
672 CSenServicePattern* pPattern = CSenServicePattern::NewLC(KAddressBookServiceId, KNullDesC8()); |
|
673 pPattern->SetFrameworkIdL(KIDWSFFrameworkID); |
|
674 pPattern->SetContractL(KAddressBookServiceId); |
|
675 |
|
676 TUint32 iapId = SearchIAPIdByNameL(KIAPName); |
|
677 pPattern->SetConsumerIapIdL(iapId); |
|
678 |
|
679 iServiceConnection = CSenServiceConnection::NewL(*this, *pPattern); |
|
680 StartActiveScheduler(1); |
|
681 |
|
682 STIFF_ASSERT_NOT_EQUALS_DESC(iServiceConnection,(CSenServiceConnection*)NULL, "The test is failed."); |
|
683 |
|
684 __ASSERT_ALWAYS_NO_LEAVE(delete iServiceConnection); |
|
685 iServiceConnection = NULL; |
|
686 |
|
687 CleanupStack::Pop(pPattern); |
|
688 __ASSERT_ALWAYS_NO_LEAVE(delete pPattern); |
|
689 pPattern = NULL; |
|
690 return KErrNone; |
|
691 } |
|
692 |
|
693 TInt CsenConnectionTester::UT_CSenServiceConnection_NewLC_ID_WSF_PatternL( ) |
|
694 { |
|
695 CSenServicePattern* pPattern = CSenServicePattern::NewLC(KAddressBookServiceId, KNullDesC8()); |
|
696 pPattern->SetFrameworkIdL(KIDWSFFrameworkID); |
|
697 pPattern->SetContractL(KAddressBookServiceId); |
|
698 |
|
699 TUint32 iapId = SearchIAPIdByNameL(KIAPName); |
|
700 pPattern->SetConsumerIapIdL(iapId); |
|
701 |
|
702 iServiceConnection = CSenServiceConnection::NewLC(*this, *pPattern); |
|
703 StartActiveScheduler(1); |
|
704 |
|
705 TL (iServiceConnection != (CSenServiceConnection*)NULL); |
|
706 CleanupStack::Pop(); //iServiceConnection |
|
707 __ASSERT_ALWAYS_NO_LEAVE(delete iServiceConnection); |
|
708 iServiceConnection = NULL; |
|
709 |
|
710 CleanupStack::Pop(pPattern); |
|
711 __ASSERT_ALWAYS_NO_LEAVE(delete pPattern); |
|
712 pPattern = NULL; |
|
713 return KErrNone; |
|
714 } |
|
715 |
|
716 TInt CsenConnectionTester::UT_CSenServiceConnection_SendL_NoErrorL( ) |
|
717 { |
|
718 iSenXmlServiceDescription = CSenXmlServiceDescription::NewL(); |
|
719 iSenXmlServiceDescription->SetFrameworkIdL(KIDWSFFrameworkID); |
|
720 iSenXmlServiceDescription->SetContractL(KAddressBookServiceId); |
|
721 |
|
722 TUint32 iapId = SearchIAPIdByNameL(KIAPName); |
|
723 iSenXmlServiceDescription->SetIapIdL(iapId); |
|
724 |
|
725 iServiceConnection = CSenServiceConnection::NewL(*this, *iSenXmlServiceDescription); |
|
726 StartActiveScheduler(1); |
|
727 |
|
728 STIFF_ASSERT_NOT_EQUALS_DESC(iServiceConnection,(CSenServiceConnection*)NULL, "The test is failed."); |
|
729 |
|
730 _LIT8(KRequest, "<ab:Query xmlns:ab=\"urn:nokia:test:addrbook:2004-09\"><ab:QueryItem><ab:Select>/ab:Card[containts[ab:N/ab:FAMILY,\'Bob\'] or containts[ab:N/ab:GIVEN,\'Bob\'] or containts[ab:TEL,\'Bob\']]</ab:Select></ab:QueryItem></ab:Query>"); |
|
731 |
|
732 TInt transactionIdOrError = iServiceConnection->SendL(KRequest); |
|
733 LOCAL_ASSERT(transactionIdOrError > KErrNone); |
|
734 |
|
735 StartActiveScheduler(1); |
|
736 |
|
737 TL (iTransactionId == transactionIdOrError); |
|
738 |
|
739 __ASSERT_ALWAYS_NO_LEAVE(delete iSenXmlServiceDescription); |
|
740 iSenXmlServiceDescription = NULL; |
|
741 |
|
742 __ASSERT_ALWAYS_NO_LEAVE(delete iServiceConnection); |
|
743 iServiceConnection = NULL; |
|
744 return KErrNone; |
|
745 } |
|
746 |
|
747 TInt CsenConnectionTester::UT_CSenServiceConnection_SendL_CancelL( ) |
|
748 { |
|
749 iSenXmlServiceDescription = CSenXmlServiceDescription::NewL(); |
|
750 iSenXmlServiceDescription->SetFrameworkIdL(KIDWSFFrameworkID); |
|
751 iSenXmlServiceDescription->SetContractL(KAddressBookServiceId); |
|
752 |
|
753 TUint32 iapId = SearchIAPIdByNameL(KIAPName); |
|
754 iSenXmlServiceDescription->SetIapIdL(iapId); |
|
755 |
|
756 iServiceConnection = CSenServiceConnection::NewL(*this, *iSenXmlServiceDescription); |
|
757 StartActiveScheduler(1); |
|
758 |
|
759 STIFF_ASSERT_NOT_EQUALS_DESC(iServiceConnection,(CSenServiceConnection*)NULL, "The test is failed."); |
|
760 |
|
761 _LIT8(KRequest, "<ab:Query xmlns:ab=\"urn:nokia:test:addrbook:2004-09\"><ab:QueryItem><ab:Select>/ab:Card[containts[ab:N/ab:FAMILY,\'Bob\'] or containts[ab:N/ab:GIVEN,\'Bob\'] or containts[ab:TEL,\'Bob\']]</ab:Select></ab:QueryItem></ab:Query>"); |
|
762 |
|
763 TInt transactionIdOrError = iServiceConnection->SendL(KRequest); |
|
764 LOCAL_ASSERT(transactionIdOrError > KErrNone); |
|
765 |
|
766 iServiceConnection->CancelTransaction(transactionIdOrError); |
|
767 |
|
768 StartActiveScheduler(1); |
|
769 |
|
770 TL (iTransactionId == transactionIdOrError); |
|
771 LOCAL_ASSERT(iErrorCode == KErrSenCancelled); |
|
772 |
|
773 User::After(2000000); |
|
774 |
|
775 __ASSERT_ALWAYS_NO_LEAVE(delete iSenXmlServiceDescription); |
|
776 iSenXmlServiceDescription = NULL; |
|
777 |
|
778 __ASSERT_ALWAYS_NO_LEAVE(delete iServiceConnection); |
|
779 iServiceConnection = NULL; |
|
780 return KErrNone; |
|
781 } |
|
782 |
|
783 TInt CsenConnectionTester::UT_CSenServiceConnection_SendL_ConNotInitialL( ) |
|
784 { |
|
785 iSenXmlServiceDescription = CSenXmlServiceDescription::NewL(); |
|
786 iSenXmlServiceDescription->SetFrameworkIdL(KIDWSFFrameworkID); |
|
787 iSenXmlServiceDescription->SetContractL(KAddressBookServiceId); |
|
788 |
|
789 TUint32 iapId = SearchIAPIdByNameL(KIAPName); |
|
790 iSenXmlServiceDescription->SetIapIdL(iapId); |
|
791 |
|
792 iServiceConnection = CSenServiceConnection::NewL(*this, *iSenXmlServiceDescription); |
|
793 |
|
794 STIFF_ASSERT_NOT_EQUALS_DESC(iServiceConnection,(CSenServiceConnection*)NULL, "The test is failed."); |
|
795 |
|
796 _LIT8(KRequest, "<ab:Query xmlns:ab=\"urn:nokia:test:addrbook:2004-09\"><ab:QueryItem><ab:Select>/ab:Card[containts[ab:N/ab:FAMILY,\'Bob\'] or containts[ab:N/ab:GIVEN,\'Bob\'] or containts[ab:TEL,\'Bob\']]</ab:Select></ab:QueryItem></ab:Query>"); |
|
797 |
|
798 TL((iServiceConnection->SendL(KRequest)) == KErrSenNotInitialized); |
|
799 StartActiveScheduler(1); |
|
800 |
|
801 delete iSenXmlServiceDescription; |
|
802 iSenXmlServiceDescription = NULL; |
|
803 |
|
804 __ASSERT_ALWAYS_NO_LEAVE(delete iServiceConnection); |
|
805 iServiceConnection = NULL; |
|
806 return KErrNone; |
|
807 } |
|
808 |
|
809 TInt CsenConnectionTester::UT_CSenServiceConnection_SendMultipleMessagesL( ) |
|
810 { |
|
811 CSenServicePattern* pPattern = |
|
812 CSenServicePattern::NewLC(KAuthServEndpoint, KNullDesC8()); |
|
813 pPattern->SetFrameworkIdL(*ipFrameworkID); |
|
814 |
|
815 TUint32 iapId = SearchIAPIdByNameL(KIAPName); |
|
816 |
|
817 iServiceConnection = CSenServiceConnection::NewL(*this, *pPattern); |
|
818 |
|
819 CleanupStack::PopAndDestroy(pPattern); |
|
820 |
|
821 StartActiveScheduler(1); |
|
822 LOCAL_ASSERT(iConnectionState == KSenConnectionStatusReady); |
|
823 // Connection is ready to be used. |
|
824 |
|
825 CSenSoapMessage* pSOAPMessage = CreateAuthRequestLC(); |
|
826 |
|
827 // Http Get (using SetTransportPropertiesL) |
|
828 // **************************************** |
|
829 CSenHttpTransportProperties* pHttpProperties = CSenHttpTransportProperties::NewLC(); |
|
830 pHttpProperties->SetIapIdL(iapId); |
|
831 HBufC8* pSerializedProperties = pHttpProperties->AsUtf8L(); |
|
832 |
|
833 CleanupStack::PushL(pSerializedProperties); |
|
834 |
|
835 iServiceConnection->SendL(*pSOAPMessage, *pSerializedProperties); |
|
836 iServiceConnection->SendL(*pSOAPMessage, *pSerializedProperties); |
|
837 iServiceConnection->SendL(*pSOAPMessage, *pSerializedProperties); |
|
838 iServiceConnection->SendL(*pSOAPMessage, *pSerializedProperties); |
|
839 iServiceConnection->SendL(*pSOAPMessage, *pSerializedProperties); |
|
840 //CleanupStack::PopAndDestroy(pSerializedProperties); |
|
841 |
|
842 //pHttpProperties->SetOmittedL(KIapIdLocalName, ETrue); |
|
843 //pSerializedProperties = pHttpProperties->AsUtf8L(); |
|
844 |
|
845 iServiceConnection->SendL(*pSOAPMessage, *pSerializedProperties); |
|
846 iServiceConnection->SendL(*pSOAPMessage, *pSerializedProperties); |
|
847 iServiceConnection->SendL(*pSOAPMessage, *pSerializedProperties); |
|
848 iServiceConnection->SendL(*pSOAPMessage, *pSerializedProperties); |
|
849 iServiceConnection->SendL(*pSOAPMessage, *pSerializedProperties); |
|
850 StartActiveScheduler(10); |
|
851 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
852 |
|
853 CleanupStack::PopAndDestroy(pSerializedProperties); |
|
854 CleanupStack::PopAndDestroy(pHttpProperties); |
|
855 |
|
856 CleanupStack::PopAndDestroy(pSOAPMessage); |
|
857 |
|
858 delete iServiceConnection; |
|
859 iServiceConnection = NULL; |
|
860 return KErrNone; |
|
861 } |
|
862 |
|
863 |
|
864 TInt CsenConnectionTester::UT_CSenServiceConnection_SendL_Get_Post1L( ) |
|
865 { |
|
866 // 1. SendL(MSG [SC::POST by default]) |
|
867 // 2. SendL(MSG, TP::GET), |
|
868 // 3. SendL(MSG, TP::POST) |
|
869 |
|
870 CSenServicePattern* pPattern = |
|
871 CSenServicePattern::NewLC(KAuthServEndpoint, KNullDesC8()); |
|
872 pPattern->SetFrameworkIdL(*ipFrameworkID); |
|
873 |
|
874 TUint32 iapId = SearchIAPIdByNameL(KIAPName); |
|
875 pPattern->SetConsumerIapIdL(iapId); |
|
876 |
|
877 iServiceConnection = CSenServiceConnection::NewL(*this, *pPattern); |
|
878 |
|
879 CleanupStack::PopAndDestroy(pPattern); |
|
880 |
|
881 StartActiveScheduler(1); |
|
882 LOCAL_ASSERT(iConnectionState == KSenConnectionStatusReady); |
|
883 // Connection is ready to be used. |
|
884 |
|
885 CSenSoapMessage* pSOAPMessage = CreateAuthRequestLC(); |
|
886 |
|
887 // Http Post |
|
888 CSenHttpTransportProperties* pHttpProperties = CSenHttpTransportProperties::NewLC(); |
|
889 pHttpProperties->SetHttpHeaderL(KLoggerFileNameProperty, KFileName); |
|
890 HBufC8* pSerializedProperties = pHttpProperties->AsUtf8L(); |
|
891 CleanupStack::PushL(pSerializedProperties); |
|
892 iServiceConnection->SendL(*pSOAPMessage, *pSerializedProperties); |
|
893 StartActiveScheduler(1); |
|
894 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
895 |
|
896 // Check from HTTP Transaction logger log that POST method were used. |
|
897 HBufC8* pFileContent = ReadFileL(KFileToRead); |
|
898 LOCAL_ASSERT(pFileContent != NULL); |
|
899 CleanupStack::PushL(pFileContent); |
|
900 HBufC8* pValue = HttpMethodValueFromXmlLC(*pFileContent); |
|
901 if ( pValue ) |
|
902 { |
|
903 LOCAL_ASSERT(*pValue == KHTTPMethodPost); |
|
904 } |
|
905 CleanupStack::PopAndDestroy(pValue); |
|
906 CleanupStack::PopAndDestroy(pFileContent); |
|
907 |
|
908 // Http Get |
|
909 pHttpProperties->SetHttpMethodL(CSenHttpTransportProperties::ESenHttpGet); |
|
910 CleanupStack::PopAndDestroy(pSerializedProperties); |
|
911 pSerializedProperties = pHttpProperties->AsUtf8L(); |
|
912 CleanupStack::PushL(pSerializedProperties); |
|
913 |
|
914 iServiceConnection->SendL(*pSOAPMessage, *pSerializedProperties); |
|
915 StartActiveScheduler(1); |
|
916 LOCAL_ASSERT(iCallback == ECallbackHandleError); |
|
917 |
|
918 // Check from HTTP Transaction logger log that GET method were used. |
|
919 pFileContent = ReadFileL(KFileToRead); |
|
920 LOCAL_ASSERT(pFileContent != NULL); |
|
921 CleanupStack::PushL(pFileContent); |
|
922 pValue = HttpMethodValueFromXmlLC(*pFileContent); |
|
923 if ( pValue ) |
|
924 { |
|
925 LOCAL_ASSERT(*pValue == KHTTPMethodGet); |
|
926 } |
|
927 CleanupStack::PopAndDestroy(pValue); |
|
928 CleanupStack::PopAndDestroy(pFileContent); |
|
929 |
|
930 // Http Post |
|
931 pHttpProperties->SetHttpMethodL(CSenHttpTransportProperties::ESenHttpPost); |
|
932 CleanupStack::PopAndDestroy(pSerializedProperties); |
|
933 pSerializedProperties = pHttpProperties->AsUtf8L(); |
|
934 CleanupStack::PushL(pSerializedProperties); |
|
935 |
|
936 iServiceConnection->SendL(*pSOAPMessage, *pSerializedProperties); |
|
937 StartActiveScheduler(1); |
|
938 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
939 |
|
940 // Check from HTTP Transaction logger log that POST method were used. |
|
941 pFileContent = ReadFileL(KFileToRead); |
|
942 LOCAL_ASSERT(pFileContent != NULL); |
|
943 CleanupStack::PushL(pFileContent); |
|
944 pValue = HttpMethodValueFromXmlLC(*pFileContent); |
|
945 if ( pValue ) |
|
946 { |
|
947 LOCAL_ASSERT(*pValue == KHTTPMethodPost); |
|
948 } |
|
949 CleanupStack::PopAndDestroy(pValue); |
|
950 CleanupStack::PopAndDestroy(pFileContent); |
|
951 |
|
952 CleanupStack::PopAndDestroy(pSerializedProperties); |
|
953 |
|
954 CleanupStack::PopAndDestroy(pHttpProperties); |
|
955 CleanupStack::PopAndDestroy(pSOAPMessage); |
|
956 |
|
957 delete iServiceConnection; |
|
958 iServiceConnection = NULL; |
|
959 return KErrNone; |
|
960 } |
|
961 |
|
962 TInt CsenConnectionTester::UT_CSenServiceConnection_SendL_Get_Post2L( ) |
|
963 { |
|
964 // 1. SetTransportPropertiesL(TP::GET) |
|
965 // 2. SendL(MSG) - Send(MSG, TP::POST) |
|
966 // 3. SendL (MSG [SC::GET]) |
|
967 // 4. SetTransportPropertiesL(TP:POST) |
|
968 // 5. SendL(MSG [SC:POST] |
|
969 |
|
970 CSenServicePattern* pPattern = |
|
971 CSenServicePattern::NewLC(KAuthServEndpoint, KNullDesC8()); |
|
972 pPattern->SetFrameworkIdL(*ipFrameworkID); |
|
973 |
|
974 TUint32 iapId = SearchIAPIdByNameL(KIAPName); |
|
975 pPattern->SetConsumerIapIdL(iapId); |
|
976 |
|
977 iServiceConnection = CSenServiceConnection::NewL(*this, *pPattern); |
|
978 |
|
979 CleanupStack::PopAndDestroy(pPattern); |
|
980 |
|
981 StartActiveScheduler(1); |
|
982 LOCAL_ASSERT(iConnectionState == KSenConnectionStatusReady); |
|
983 // Connection is ready to be used. |
|
984 |
|
985 CSenSoapMessage* pSOAPMessage = CreateAuthRequestLC(); |
|
986 |
|
987 // Http Get (using SetTransportPropertiesL) |
|
988 // **************************************** |
|
989 CSenHttpTransportProperties* pHttpProperties = CSenHttpTransportProperties::NewLC(); |
|
990 pHttpProperties->SetHttpMethodL(CSenHttpTransportProperties::ESenHttpGet); |
|
991 pHttpProperties->SetHttpHeaderL(KLoggerFileNameProperty, KFileName); |
|
992 HBufC8* pSerializedProperties = pHttpProperties->AsUtf8L(); |
|
993 CleanupStack::PushL(pSerializedProperties); |
|
994 iServiceConnection->SetTransportPropertiesL(*pSerializedProperties); |
|
995 iServiceConnection->SendL(*pSOAPMessage); |
|
996 StartActiveScheduler(1); |
|
997 LOCAL_ASSERT(iCallback == ECallbackHandleError); |
|
998 |
|
999 // Check from HTTP Transaction logger log that GET method were used. |
|
1000 HBufC8* pFileContent = ReadFileL(KFileToRead); |
|
1001 LOCAL_ASSERT(pFileContent != NULL); |
|
1002 CleanupStack::PushL(pFileContent); |
|
1003 HBufC8* pValue = HttpMethodValueFromXmlLC(*pFileContent); |
|
1004 if ( pValue ) |
|
1005 { |
|
1006 LOCAL_ASSERT(*pValue == KHTTPMethodGet); |
|
1007 } |
|
1008 CleanupStack::PopAndDestroy(pValue); |
|
1009 CleanupStack::PopAndDestroy(pFileContent); |
|
1010 |
|
1011 // Http Post (using TransportProperties in SendL parameters) |
|
1012 // ********************************************************* |
|
1013 pHttpProperties->SetHttpMethodL(CSenHttpTransportProperties::ESenHttpPost); |
|
1014 CleanupStack::PopAndDestroy(pSerializedProperties); |
|
1015 pSerializedProperties = pHttpProperties->AsUtf8L(); |
|
1016 CleanupStack::PushL(pSerializedProperties); |
|
1017 |
|
1018 iServiceConnection->SendL(*pSOAPMessage, *pSerializedProperties); |
|
1019 StartActiveScheduler(1); |
|
1020 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
1021 |
|
1022 // Check from HTTP Transaction logger log that Post method were used. |
|
1023 pFileContent = ReadFileL(KFileToRead); |
|
1024 LOCAL_ASSERT(pFileContent != NULL); |
|
1025 CleanupStack::PushL(pFileContent); |
|
1026 pValue = HttpMethodValueFromXmlLC(*pFileContent); |
|
1027 if ( pValue ) |
|
1028 { |
|
1029 LOCAL_ASSERT(*pValue == KHTTPMethodPost); |
|
1030 } |
|
1031 CleanupStack::PopAndDestroy(pValue); |
|
1032 CleanupStack::PopAndDestroy(pFileContent); |
|
1033 |
|
1034 // Http Get (using TransportProperties in SendL parameters) |
|
1035 // ******************************************************** |
|
1036 pHttpProperties->SetHttpMethodL(CSenHttpTransportProperties::ESenHttpGet); |
|
1037 CleanupStack::PopAndDestroy(pSerializedProperties); |
|
1038 pSerializedProperties = pHttpProperties->AsUtf8L(); |
|
1039 CleanupStack::PushL(pSerializedProperties); |
|
1040 |
|
1041 iServiceConnection->SendL(*pSOAPMessage, *pSerializedProperties); |
|
1042 StartActiveScheduler(1); |
|
1043 LOCAL_ASSERT(iCallback == ECallbackHandleError); |
|
1044 |
|
1045 // Check from HTTP Transaction logger log that GET method were used. |
|
1046 pFileContent = ReadFileL(KFileToRead); |
|
1047 LOCAL_ASSERT(pFileContent != NULL); |
|
1048 CleanupStack::PushL(pFileContent); |
|
1049 pValue = HttpMethodValueFromXmlLC(*pFileContent); |
|
1050 if ( pValue ) |
|
1051 { |
|
1052 LOCAL_ASSERT(*pValue == KHTTPMethodGet); |
|
1053 } |
|
1054 CleanupStack::PopAndDestroy(pValue); |
|
1055 CleanupStack::PopAndDestroy(pFileContent); |
|
1056 |
|
1057 // Http Post (using SetTransportPropertiesL) |
|
1058 // ***************************************** |
|
1059 pHttpProperties->SetHttpMethodL(CSenHttpTransportProperties::ESenHttpPost); |
|
1060 CleanupStack::PopAndDestroy(pSerializedProperties); |
|
1061 pSerializedProperties = pHttpProperties->AsUtf8L(); |
|
1062 CleanupStack::PushL(pSerializedProperties); |
|
1063 |
|
1064 iServiceConnection->SetTransportPropertiesL(*pSerializedProperties); |
|
1065 iServiceConnection->SendL(*pSOAPMessage); |
|
1066 StartActiveScheduler(1); |
|
1067 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
1068 |
|
1069 // Check from HTTP Transaction logger log that Post method were used. |
|
1070 pFileContent = ReadFileL(KFileToRead); |
|
1071 LOCAL_ASSERT(pFileContent != NULL); |
|
1072 CleanupStack::PushL(pFileContent); |
|
1073 pValue = HttpMethodValueFromXmlLC(*pFileContent); |
|
1074 if ( pValue ) |
|
1075 { |
|
1076 LOCAL_ASSERT(*pValue == KHTTPMethodPost); |
|
1077 } |
|
1078 CleanupStack::PopAndDestroy(pValue); |
|
1079 CleanupStack::PopAndDestroy(pFileContent); |
|
1080 |
|
1081 // Http Post (using TransportProperties in SendL parameters) |
|
1082 // ********************************************************* |
|
1083 pHttpProperties->SetHttpMethodL(CSenHttpTransportProperties::ESenHttpPost); |
|
1084 CleanupStack::PopAndDestroy(pSerializedProperties); |
|
1085 pSerializedProperties = pHttpProperties->AsUtf8L(); |
|
1086 CleanupStack::PushL(pSerializedProperties); |
|
1087 |
|
1088 iServiceConnection->SendL(*pSOAPMessage, *pSerializedProperties); |
|
1089 StartActiveScheduler(1); |
|
1090 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
1091 |
|
1092 // Check from HTTP Transaction logger log that POST method were used. |
|
1093 pFileContent = ReadFileL(KFileToRead); |
|
1094 LOCAL_ASSERT(pFileContent != NULL); |
|
1095 CleanupStack::PushL(pFileContent); |
|
1096 pValue = HttpMethodValueFromXmlLC(*pFileContent); |
|
1097 if ( pValue ) |
|
1098 { |
|
1099 LOCAL_ASSERT(*pValue == KHTTPMethodPost); |
|
1100 } |
|
1101 CleanupStack::PopAndDestroy(pValue); |
|
1102 CleanupStack::PopAndDestroy(pFileContent); |
|
1103 |
|
1104 CleanupStack::PopAndDestroy(pSerializedProperties); |
|
1105 |
|
1106 CleanupStack::PopAndDestroy(pHttpProperties); |
|
1107 CleanupStack::PopAndDestroy(pSOAPMessage); |
|
1108 |
|
1109 delete iServiceConnection; |
|
1110 iServiceConnection = NULL; |
|
1111 return KErrNone; |
|
1112 } |
|
1113 |
|
1114 TInt CsenConnectionTester::UT_CSenServiceConnection_SendL_Proxy1L( ) |
|
1115 { |
|
1116 // SetProxy via Set(TP) |
|
1117 // ******************** |
|
1118 // 1. SetTransportProperties(TP::PROXY) |
|
1119 // 2. SendL(MSG) _LIT8(KSoapAction, "SOAPAction"); |
|
1120 |
|
1121 _LIT8(KSoapAction, "SOAPAction"); |
|
1122 _LIT8(KSoapActionValue, "SoapEnvelopeAction"); |
|
1123 _LIT8(KSoapActionReturnValue, "\"SoapEnvelopeAction\""); |
|
1124 |
|
1125 CSenServicePattern* pPattern = CSenServicePattern::NewLC(KAuthServEndpoint, KNullDesC8()); |
|
1126 pPattern->SetFrameworkIdL(*ipFrameworkID); |
|
1127 |
|
1128 |
|
1129 |
|
1130 TUint32 iapId = SearchIAPIdByNameL(KIAPName); |
|
1131 pPattern->SetConsumerIapIdL(iapId); |
|
1132 |
|
1133 iServiceConnection = CSenServiceConnection::NewL(*this, *pPattern); |
|
1134 |
|
1135 CleanupStack::PopAndDestroy(pPattern); |
|
1136 |
|
1137 StartActiveScheduler(1); |
|
1138 |
|
1139 // Now the code execution has returned in here (either HandleMessageL or HandleErrorL was invoked) |
|
1140 |
|
1141 LOCAL_ASSERT(iConnectionState == KSenConnectionStatusReady); |
|
1142 // Connection is ready to be used. |
|
1143 |
|
1144 CSenSoapMessage* pSOAPMessage = CreateAuthRequestLC(); |
|
1145 pSOAPMessage->SetSoapActionL(KSoapActionValue); |
|
1146 |
|
1147 // Http Post |
|
1148 CSenHttpTransportProperties* pHttpProperties = CSenHttpTransportProperties::NewLC(); |
|
1149 pHttpProperties->SetHttpHeaderL(KLoggerFileNameProperty, KFileName); |
|
1150 pHttpProperties->SetProxyHostL(KProxyHost); |
|
1151 pHttpProperties->SetProxyPortL(KProxyPort); |
|
1152 HBufC8* pSerializedProperties = pHttpProperties->AsUtf8L(); |
|
1153 CleanupStack::PushL(pSerializedProperties); |
|
1154 iServiceConnection->SetTransportPropertiesL(*pSerializedProperties); |
|
1155 |
|
1156 iServiceConnection->SendL(*pSOAPMessage); |
|
1157 StartActiveScheduler(1); |
|
1158 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
1159 |
|
1160 CleanupStack::PopAndDestroy(pSerializedProperties); |
|
1161 CleanupStack::PopAndDestroy(pHttpProperties); |
|
1162 |
|
1163 CleanupStack::PopAndDestroy(pSOAPMessage); |
|
1164 |
|
1165 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
1166 |
|
1167 // Read HTTP Transaction from file |
|
1168 HBufC8* pFileContent = ReadFileL(KFileToRead); |
|
1169 |
|
1170 LOCAL_ASSERT(pFileContent != NULL); |
|
1171 |
|
1172 CleanupStack::PushL(pFileContent); |
|
1173 |
|
1174 HBufC8* pValue = HttpPropertyValueFromXmlLC(*pFileContent, KSoapAction); |
|
1175 if( pValue ) |
|
1176 { |
|
1177 LOCAL_ASSERT(*pValue == KSoapActionReturnValue); |
|
1178 } |
|
1179 CleanupStack::PopAndDestroy(pValue); |
|
1180 |
|
1181 CleanupStack::PopAndDestroy(pFileContent); |
|
1182 |
|
1183 delete iServiceConnection; |
|
1184 iServiceConnection = NULL; |
|
1185 return KErrNone; |
|
1186 } |
|
1187 |
|
1188 TInt CsenConnectionTester::UT_CSenServiceConnection_SendL_Proxy2L( ) |
|
1189 { |
|
1190 // SetProxy via SendL(MSG, TP) |
|
1191 // *************************** |
|
1192 // 1. SendL(MSG, TP::PROXY) |
|
1193 |
|
1194 _LIT8(KSoapAction, "SOAPAction"); |
|
1195 _LIT8(KSoapActionValue, "SoapEnvelopeAction"); |
|
1196 _LIT8(KSoapActionReturnValue, "\"SoapEnvelopeAction\""); |
|
1197 |
|
1198 CSenServicePattern* pPattern = CSenServicePattern::NewLC(KAuthServEndpoint, KNullDesC8()); |
|
1199 pPattern->SetFrameworkIdL(*ipFrameworkID); |
|
1200 |
|
1201 TUint32 iapId = SearchIAPIdByNameL(KIAPName); |
|
1202 pPattern->SetConsumerIapIdL(iapId); |
|
1203 |
|
1204 iServiceConnection = CSenServiceConnection::NewL(*this, *pPattern); |
|
1205 |
|
1206 CleanupStack::PopAndDestroy(pPattern); |
|
1207 |
|
1208 StartActiveScheduler(1); |
|
1209 LOCAL_ASSERT(iConnectionState == KSenConnectionStatusReady); |
|
1210 // Connection is ready to be used. |
|
1211 |
|
1212 CSenSoapMessage* pSOAPMessage = CreateAuthRequestLC(); |
|
1213 pSOAPMessage->SetSoapActionL(KSoapActionValue); |
|
1214 |
|
1215 // Http Post |
|
1216 CSenHttpTransportProperties* pHttpProperties = CSenHttpTransportProperties::NewLC(); |
|
1217 pHttpProperties->SetHttpHeaderL(KLoggerFileNameProperty, KFileName); |
|
1218 pHttpProperties->SetProxyHostL(KProxyHost); |
|
1219 pHttpProperties->SetProxyPortL(KProxyPort); |
|
1220 HBufC8* pSerializedProperties = pHttpProperties->AsUtf8L(); |
|
1221 CleanupStack::PushL(pSerializedProperties); |
|
1222 |
|
1223 iServiceConnection->SendL(*pSOAPMessage, *pSerializedProperties); |
|
1224 StartActiveScheduler(1); |
|
1225 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
1226 |
|
1227 CleanupStack::PopAndDestroy(pSerializedProperties); |
|
1228 CleanupStack::PopAndDestroy(pHttpProperties); |
|
1229 |
|
1230 CleanupStack::PopAndDestroy(pSOAPMessage); |
|
1231 |
|
1232 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
1233 |
|
1234 // Read HTTP Transaction from file |
|
1235 HBufC8* pFileContent = ReadFileL(KFileToRead); |
|
1236 |
|
1237 LOCAL_ASSERT(pFileContent != NULL); |
|
1238 |
|
1239 CleanupStack::PushL(pFileContent); |
|
1240 |
|
1241 HBufC8* pValue = HttpPropertyValueFromXmlLC(*pFileContent, KSoapAction); |
|
1242 if( pValue ) |
|
1243 { |
|
1244 LOCAL_ASSERT(*pValue == KSoapActionReturnValue); |
|
1245 } |
|
1246 CleanupStack::PopAndDestroy(pValue); |
|
1247 |
|
1248 CleanupStack::PopAndDestroy(pFileContent); |
|
1249 |
|
1250 delete iServiceConnection; |
|
1251 iServiceConnection = NULL; |
|
1252 return KErrNone; |
|
1253 } |
|
1254 |
|
1255 TInt CsenConnectionTester::UT_CSenServiceConnection_SendL_Pattern_IAP1L( ) |
|
1256 { |
|
1257 // ServicePattern::SetConsumerIapIdL(IAP_ID) |
|
1258 // ***************************************** |
|
1259 // 1. Create new Service Pattern (SPatt) |
|
1260 // 2. SPatt::SetConsumerIapIdL(IAP_ID) |
|
1261 // 3. Instantiate new SC, wait for SetStatus(READY) |
|
1262 // 4. SendL(MSG) using selected IAP |
|
1263 |
|
1264 CSenServicePattern* pPattern = |
|
1265 CSenServicePattern::NewLC(KAuthServEndpoint, KNullDesC8()); |
|
1266 pPattern->SetFrameworkIdL(*ipFrameworkID); |
|
1267 |
|
1268 TUint32 iapId = SearchIAPIdByNameL(KIAPName); |
|
1269 pPattern->SetConsumerIapIdL(iapId); |
|
1270 |
|
1271 iServiceConnection = CSenServiceConnection::NewL(*this, *pPattern); |
|
1272 |
|
1273 CleanupStack::PopAndDestroy(pPattern); |
|
1274 |
|
1275 StartActiveScheduler(1); |
|
1276 LOCAL_ASSERT(iConnectionState == KSenConnectionStatusReady); |
|
1277 // Connection is ready to be used. |
|
1278 |
|
1279 CSenSoapMessage* pSOAPMessage = CreateAuthRequestLC(); |
|
1280 |
|
1281 iServiceConnection->SendL(*pSOAPMessage); |
|
1282 StartActiveScheduler(1); |
|
1283 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
1284 |
|
1285 CleanupStack::PopAndDestroy(pSOAPMessage); |
|
1286 |
|
1287 delete iServiceConnection; |
|
1288 iServiceConnection = NULL; |
|
1289 return KErrNone; |
|
1290 } |
|
1291 |
|
1292 TInt CsenConnectionTester::UT_CSenServiceConnection_SendL_Pattern_IAP2L( ) |
|
1293 { |
|
1294 // SendL(MSG, TP:IAP_ID) NOTE: this test case requires user interaction!!! |
|
1295 // ******************************************************************************* |
|
1296 // 1. Instantiate new SC, wait for SetStatus(READY) [IAP is prompted from end user!] |
|
1297 // 2. TP::SetIapIdL(IAP_ID) |
|
1298 // 3. SendL(MSG, TP::IAP_ID) using selected IAP |
|
1299 // 4. SendL(MSG) -- should prompt the IAP from the end-user |
|
1300 |
|
1301 CSenServicePattern* pPattern = |
|
1302 CSenServicePattern::NewLC(KAuthServEndpoint, KNullDesC8()); |
|
1303 pPattern->SetFrameworkIdL(*ipFrameworkID); |
|
1304 |
|
1305 iServiceConnection = CSenServiceConnection::NewL(*this, *pPattern); |
|
1306 |
|
1307 CleanupStack::PopAndDestroy(pPattern); |
|
1308 |
|
1309 StartActiveScheduler(1); |
|
1310 LOCAL_ASSERT(iConnectionState == KSenConnectionStatusReady); |
|
1311 // Connection is ready to be used. |
|
1312 |
|
1313 CSenSoapMessage* pSOAPMessage = CreateAuthRequestLC(); |
|
1314 |
|
1315 CSenHttpTransportProperties* pHttpProperties = CSenHttpTransportProperties::NewLC(); |
|
1316 TUint32 iapId = SearchIAPIdByNameL(KIAPName); |
|
1317 pHttpProperties->SetIapIdL(iapId); |
|
1318 HBufC8* pSerializedProperties = pHttpProperties->AsUtf8L(); |
|
1319 CleanupStack::PushL(pSerializedProperties); |
|
1320 iServiceConnection->SendL(*pSOAPMessage, *pSerializedProperties); |
|
1321 StartActiveScheduler(1); |
|
1322 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
1323 |
|
1324 CleanupStack::PopAndDestroy(pSerializedProperties); |
|
1325 CleanupStack::PopAndDestroy(pHttpProperties); |
|
1326 |
|
1327 iServiceConnection->SendL(*pSOAPMessage); |
|
1328 StartActiveScheduler(1); |
|
1329 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
1330 |
|
1331 CleanupStack::PopAndDestroy(pSOAPMessage); |
|
1332 |
|
1333 delete iServiceConnection; |
|
1334 iServiceConnection = NULL; |
|
1335 return KErrNone; |
|
1336 } |
|
1337 |
|
1338 TInt CsenConnectionTester::UT_CSenServiceConnection_SendL_Pattern_IAP3L( ) |
|
1339 { |
|
1340 // SetTransportPropertiesL(TP::IAP_ID) |
|
1341 // 1. SetTransportPropertiesL(TP::IAP_ID) |
|
1342 // 2. SendL(MSG) using selected IAP |
|
1343 // 3. TP:SetOmittedL(IAP_ID) |
|
1344 // 4. SendL(MSG, TP::IAP_ID-Omitted) -- should prompt the IAP from the end-user |
|
1345 |
|
1346 CSenServicePattern* pPattern = |
|
1347 CSenServicePattern::NewLC(KAuthServEndpoint, KNullDesC8()); |
|
1348 pPattern->SetFrameworkIdL(*ipFrameworkID); |
|
1349 |
|
1350 iServiceConnection = CSenServiceConnection::NewL(*this, *pPattern); |
|
1351 |
|
1352 CleanupStack::PopAndDestroy(pPattern); |
|
1353 |
|
1354 StartActiveScheduler(1); |
|
1355 LOCAL_ASSERT(iConnectionState == KSenConnectionStatusReady); |
|
1356 // Connection is ready to be used. |
|
1357 |
|
1358 CSenSoapMessage* pSOAPMessage = CreateAuthRequestLC(); |
|
1359 |
|
1360 // 1. SetTransportPropertiesL(TP::IAP_ID) |
|
1361 CSenHttpTransportProperties* pHttpProperties = CSenHttpTransportProperties::NewLC(); |
|
1362 TUint32 iapId = SearchIAPIdByNameL(KIAPName); |
|
1363 pHttpProperties->SetIapIdL(iapId); |
|
1364 HBufC8* pSerializedProperties = pHttpProperties->AsUtf8L(); |
|
1365 CleanupStack::PushL(pSerializedProperties); |
|
1366 iServiceConnection->SetTransportPropertiesL(*pSerializedProperties); |
|
1367 // 2. SendL(MSG) using selected IAP |
|
1368 iServiceConnection->SendL(*pSOAPMessage); |
|
1369 StartActiveScheduler(1); |
|
1370 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
1371 |
|
1372 CleanupStack::PopAndDestroy(pSerializedProperties); |
|
1373 CleanupStack::PopAndDestroy(pHttpProperties); |
|
1374 |
|
1375 pHttpProperties = CSenHttpTransportProperties::NewLC(); |
|
1376 // 3. TP:SetOmittedL(IAP_ID) |
|
1377 //pHttpProperties->SetOmittedL(KIapIdLocalName, ETrue); |
|
1378 pSerializedProperties = pHttpProperties->AsUtf8L(); |
|
1379 CleanupStack::PushL(pSerializedProperties); |
|
1380 // 4. SendL(MSG, TP::IAP_ID-Omitted) -- should prompt the IAP from the end-user |
|
1381 iServiceConnection->SendL(*pSOAPMessage, *pSerializedProperties); |
|
1382 StartActiveScheduler(1); |
|
1383 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
1384 |
|
1385 CleanupStack::PopAndDestroy(pSerializedProperties); |
|
1386 CleanupStack::PopAndDestroy(pHttpProperties); |
|
1387 |
|
1388 CleanupStack::PopAndDestroy(pSOAPMessage); |
|
1389 |
|
1390 delete iServiceConnection; |
|
1391 iServiceConnection = NULL; |
|
1392 return KErrNone; |
|
1393 } |
|
1394 |
|
1395 TInt CsenConnectionTester::UT_CSenServiceConnection_SendL_ContentType1L( ) |
|
1396 { |
|
1397 // SendL(MSG, TP::Content-Type) |
|
1398 // 1. Get TP via SC:TransportPropertiesL() // store currently effective content-type |
|
1399 // 2. TP::SetContentTypeIdL(Content-Type) |
|
1400 // 3. SendL(MSG, TP::Content-Type) // check that selected Content-Type is used |
|
1401 // 4. SendL(MSG) // original content type should be used (from step 1) |
|
1402 |
|
1403 _LIT8(KContentTypeValue, "text"); |
|
1404 |
|
1405 CSenServicePattern* pPattern = |
|
1406 CSenServicePattern::NewLC(KAuthServEndpoint, KNullDesC8()); |
|
1407 pPattern->SetFrameworkIdL(*ipFrameworkID); |
|
1408 |
|
1409 iServiceConnection = CSenServiceConnection::NewL(*this, *pPattern); |
|
1410 |
|
1411 CleanupStack::PopAndDestroy(pPattern); |
|
1412 |
|
1413 StartActiveScheduler(1); |
|
1414 LOCAL_ASSERT(iConnectionState == KSenConnectionStatusReady); |
|
1415 // Connection is ready to be used. |
|
1416 |
|
1417 HBufC8* pOriginalContentType = NULL; |
|
1418 |
|
1419 // 1. Get TP via SC:TransportPropertiesL() // store currently effective content-type |
|
1420 HBufC8* pTransportPropertiesAsXml = NULL; |
|
1421 iServiceConnection->TransportPropertiesL(pTransportPropertiesAsXml); |
|
1422 if ( pTransportPropertiesAsXml ) |
|
1423 { |
|
1424 CleanupStack::PushL(pTransportPropertiesAsXml); |
|
1425 CSenXmlReader* pParser = CSenXmlReader::NewLC(); |
|
1426 CSenHttpTransportProperties* pReadHttpProperties = |
|
1427 CSenHttpTransportProperties::NewLC(*pTransportPropertiesAsXml, |
|
1428 *pParser); |
|
1429 TPtrC8 contentType; |
|
1430 TInt retVal = pReadHttpProperties->ContentTypeL(contentType); |
|
1431 if ( retVal == KErrNone ) |
|
1432 { |
|
1433 pOriginalContentType = contentType.AllocL(); |
|
1434 } |
|
1435 CleanupStack::PopAndDestroy(pReadHttpProperties); |
|
1436 CleanupStack::PopAndDestroy(pParser); |
|
1437 CleanupStack::PopAndDestroy(pTransportPropertiesAsXml); |
|
1438 } |
|
1439 |
|
1440 LOCAL_ASSERT(pOriginalContentType != NULL); // Content-type is a MUST for every transport |
|
1441 |
|
1442 if ( pOriginalContentType ) |
|
1443 { |
|
1444 CleanupStack::PushL(pOriginalContentType); |
|
1445 } |
|
1446 |
|
1447 CSenSoapMessage* pSOAPMessage = CreateAuthRequestLC(); |
|
1448 |
|
1449 // 2. TP::SetContentTypeIdL(Content-Type) |
|
1450 CSenHttpTransportProperties* pHttpProperties = CSenHttpTransportProperties::NewLC(); |
|
1451 pHttpProperties->SetHttpHeaderL(KLoggerFileNameProperty, KFileName); |
|
1452 TUint32 iapId = SearchIAPIdByNameL(KIAPName); |
|
1453 pHttpProperties->SetIapIdL(iapId); |
|
1454 pHttpProperties->SetContentTypeL(KContentTypeValue); |
|
1455 HBufC8* pSerializedProperties = pHttpProperties->AsUtf8L(); |
|
1456 CleanupStack::PushL(pSerializedProperties); |
|
1457 |
|
1458 // 3. SendL(MSG, TP::Content-Type) // check that selected Content-Type is used |
|
1459 iServiceConnection->SendL(*pSOAPMessage, *pSerializedProperties); |
|
1460 StartActiveScheduler(1); |
|
1461 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
1462 |
|
1463 CleanupStack::PopAndDestroy(pSerializedProperties); |
|
1464 CleanupStack::PopAndDestroy(pHttpProperties); |
|
1465 |
|
1466 // Check from HTTP Transaction logger log that correct ContentType were used. |
|
1467 HBufC8* pFileContent = ReadFileL(KFileToRead); |
|
1468 LOCAL_ASSERT(pFileContent != NULL); |
|
1469 CleanupStack::PushL(pFileContent); |
|
1470 HBufC8* pValue = HttpPropertyValueFromXmlLC(*pFileContent, _L8("Content-Type")); |
|
1471 |
|
1472 if ( pValue ) |
|
1473 { |
|
1474 LOCAL_ASSERT(*pValue == KContentTypeValue); |
|
1475 } |
|
1476 CleanupStack::PopAndDestroy(pValue); |
|
1477 CleanupStack::PopAndDestroy(pFileContent); |
|
1478 |
|
1479 // 4. SendL(MSG) // original content type should be used (from step 1) |
|
1480 pHttpProperties = CSenHttpTransportProperties::NewLC(); |
|
1481 pHttpProperties->SetHttpHeaderL(KLoggerFileNameProperty, KFileName); |
|
1482 pHttpProperties->SetIapIdL(iapId); |
|
1483 pSerializedProperties = pHttpProperties->AsUtf8L(); |
|
1484 CleanupStack::PushL(pSerializedProperties); |
|
1485 iServiceConnection->SendL(*pSOAPMessage, *pSerializedProperties); |
|
1486 StartActiveScheduler(1); |
|
1487 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
1488 |
|
1489 CleanupStack::PopAndDestroy(pSerializedProperties); |
|
1490 CleanupStack::PopAndDestroy(pHttpProperties); |
|
1491 |
|
1492 // Check from HTTP Transaction logger log that correct ContentType were used. |
|
1493 pFileContent = ReadFileL(KFileToRead); |
|
1494 LOCAL_ASSERT(pFileContent != NULL); |
|
1495 CleanupStack::PushL(pFileContent); |
|
1496 pValue = HttpPropertyValueFromXmlLC(*pFileContent, _L8("Content-Type")); |
|
1497 if( pValue && pOriginalContentType ) |
|
1498 { |
|
1499 LOCAL_ASSERT(*pValue == *pOriginalContentType); |
|
1500 } |
|
1501 CleanupStack::PopAndDestroy(pValue); |
|
1502 CleanupStack::PopAndDestroy(pFileContent); |
|
1503 |
|
1504 CleanupStack::PopAndDestroy(pSOAPMessage); |
|
1505 |
|
1506 if ( pOriginalContentType ) |
|
1507 { |
|
1508 CleanupStack::PopAndDestroy(pOriginalContentType); |
|
1509 } |
|
1510 |
|
1511 delete iServiceConnection; |
|
1512 iServiceConnection = NULL; |
|
1513 return KErrNone; |
|
1514 } |
|
1515 |
|
1516 TInt CsenConnectionTester::UT_CSenServiceConnection_SendL_ContentType2L( ) |
|
1517 { |
|
1518 // SetTransportPropertiesL(TP::Content-Type) |
|
1519 // 1. Get TP via SC:TransportPropertiesL() |
|
1520 // 2. SendL(MSG), Content-Type got from step 1 should be effective |
|
1521 // 3. SetTransportPropertiesL(TP::Content-Type) // change content-type |
|
1522 // 4. SendL(MSG) // check new content-type |
|
1523 // 5. SendL(MSG, TP:Content-Type) // check *third* kind of content-type |
|
1524 |
|
1525 _LIT8(KContentTypeValue1, "text"); |
|
1526 _LIT8(KContentTypeValue2, "xml"); |
|
1527 |
|
1528 CSenServicePattern* pPattern = |
|
1529 CSenServicePattern::NewLC(KAuthServEndpoint, KNullDesC8()); |
|
1530 pPattern->SetFrameworkIdL(*ipFrameworkID); |
|
1531 |
|
1532 iServiceConnection = CSenServiceConnection::NewL(*this, *pPattern); |
|
1533 |
|
1534 CleanupStack::PopAndDestroy(pPattern); |
|
1535 |
|
1536 StartActiveScheduler(1); |
|
1537 LOCAL_ASSERT(iConnectionState == KSenConnectionStatusReady); |
|
1538 // Connection is ready to be used. |
|
1539 |
|
1540 // 1. Get TP via SC:TransportPropertiesL() |
|
1541 TPtrC8 contentType; |
|
1542 HBufC8* pTransportPropertiesAsXml = NULL; |
|
1543 iServiceConnection->TransportPropertiesL(pTransportPropertiesAsXml); |
|
1544 if ( pTransportPropertiesAsXml ) |
|
1545 { |
|
1546 CleanupStack::PushL(pTransportPropertiesAsXml); |
|
1547 CSenXmlReader* pParser = CSenXmlReader::NewLC(); |
|
1548 CSenHttpTransportProperties* pReadHttpProperties = |
|
1549 CSenHttpTransportProperties::NewLC(*pTransportPropertiesAsXml, |
|
1550 *pParser); |
|
1551 pReadHttpProperties->ContentTypeL(contentType); |
|
1552 CleanupStack::PopAndDestroy(pReadHttpProperties); |
|
1553 CleanupStack::PopAndDestroy(pParser); |
|
1554 CleanupStack::PopAndDestroy(pTransportPropertiesAsXml); |
|
1555 } |
|
1556 |
|
1557 CSenSoapMessage* pSOAPMessage = CreateAuthRequestLC(); |
|
1558 |
|
1559 // 2. SendL(MSG), Content-Type got from step 1 should be effective |
|
1560 CSenHttpTransportProperties* pHttpProperties = CSenHttpTransportProperties::NewLC(); |
|
1561 pHttpProperties->SetHttpHeaderL(KLoggerFileNameProperty, KFileName); |
|
1562 TUint32 iapId = SearchIAPIdByNameL(KIAPName); |
|
1563 pHttpProperties->SetIapIdL(iapId); |
|
1564 HBufC8* pSerializedProperties = pHttpProperties->AsUtf8L(); |
|
1565 CleanupStack::PushL(pSerializedProperties); |
|
1566 iServiceConnection->SetTransportPropertiesL(*pSerializedProperties); |
|
1567 iServiceConnection->SendL(*pSOAPMessage, *pSerializedProperties); |
|
1568 StartActiveScheduler(1); |
|
1569 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
1570 |
|
1571 CleanupStack::PopAndDestroy(pSerializedProperties); |
|
1572 CleanupStack::PopAndDestroy(pHttpProperties); |
|
1573 |
|
1574 // 3. SetTransportPropertiesL(TP::Content-Type) // change content-type |
|
1575 pHttpProperties = CSenHttpTransportProperties::NewLC(); |
|
1576 pHttpProperties->SetContentTypeL(KContentTypeValue1); |
|
1577 pSerializedProperties = pHttpProperties->AsUtf8L(); |
|
1578 CleanupStack::PushL(pSerializedProperties); |
|
1579 iServiceConnection->SetTransportPropertiesL(*pSerializedProperties); |
|
1580 CleanupStack::PopAndDestroy(pSerializedProperties); |
|
1581 CleanupStack::PopAndDestroy(pHttpProperties); |
|
1582 |
|
1583 // 4. SendL(MSG) // check new content-type |
|
1584 pHttpProperties = CSenHttpTransportProperties::NewLC(); |
|
1585 pHttpProperties->SetHttpHeaderL(KLoggerFileNameProperty, KFileName); |
|
1586 pHttpProperties->SetIapIdL(iapId); |
|
1587 pSerializedProperties = pHttpProperties->AsUtf8L(); |
|
1588 CleanupStack::PushL(pSerializedProperties); |
|
1589 iServiceConnection->SendL(*pSOAPMessage, *pSerializedProperties); |
|
1590 StartActiveScheduler(1); |
|
1591 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
1592 CleanupStack::PopAndDestroy(pSerializedProperties); |
|
1593 CleanupStack::PopAndDestroy(pHttpProperties); |
|
1594 |
|
1595 // Check from HTTP Transaction logger log that correct ContentType were used. |
|
1596 HBufC8* pFileContent = ReadFileL(KFileToRead); |
|
1597 LOCAL_ASSERT(pFileContent != NULL); |
|
1598 CleanupStack::PushL(pFileContent); |
|
1599 HBufC8* pValue = HttpPropertyValueFromXmlLC(*pFileContent, _L8("Content-Type")); |
|
1600 if( pValue ) |
|
1601 { |
|
1602 LOCAL_ASSERT(*pValue == KContentTypeValue1); |
|
1603 } |
|
1604 CleanupStack::PopAndDestroy(pValue); |
|
1605 CleanupStack::PopAndDestroy(pFileContent); |
|
1606 |
|
1607 // 5. SendL(MSG, TP:Content-Type) // check *third* kind of content-type |
|
1608 pHttpProperties = CSenHttpTransportProperties::NewLC(); |
|
1609 pHttpProperties->SetHttpHeaderL(KLoggerFileNameProperty, KFileName); |
|
1610 pHttpProperties->SetContentTypeL(KContentTypeValue2); |
|
1611 pHttpProperties->SetIapIdL(iapId); |
|
1612 pSerializedProperties = pHttpProperties->AsUtf8L(); |
|
1613 CleanupStack::PushL(pSerializedProperties); |
|
1614 iServiceConnection->SendL(*pSOAPMessage, *pSerializedProperties); |
|
1615 StartActiveScheduler(1); |
|
1616 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
1617 CleanupStack::PopAndDestroy(pSerializedProperties); |
|
1618 CleanupStack::PopAndDestroy(pHttpProperties); |
|
1619 |
|
1620 // Check from HTTP Transaction logger log that correct ContentType were used. |
|
1621 pFileContent = ReadFileL(KFileToRead); |
|
1622 LOCAL_ASSERT(pFileContent != NULL); |
|
1623 CleanupStack::PushL(pFileContent); |
|
1624 pValue = HttpPropertyValueFromXmlLC(*pFileContent, _L8("Content-Type")); |
|
1625 if( pValue ) |
|
1626 { |
|
1627 LOCAL_ASSERT(*pValue == KContentTypeValue2); |
|
1628 } |
|
1629 CleanupStack::PopAndDestroy(pValue); |
|
1630 CleanupStack::PopAndDestroy(pFileContent); |
|
1631 |
|
1632 CleanupStack::PopAndDestroy(pSOAPMessage); |
|
1633 |
|
1634 delete iServiceConnection; |
|
1635 iServiceConnection = NULL; |
|
1636 return KErrNone; |
|
1637 } |
|
1638 |
|
1639 TInt CsenConnectionTester::UT_CSenServiceConnection_SendL_UserAgent1L( ) |
|
1640 { |
|
1641 // SendL(MSG, TP::User-Agent) |
|
1642 // 1. Get TP via SC:TransportPropertiesL() // store currently effective User-Agent |
|
1643 // 2. TP::SetUserAgentL(User-Agent) |
|
1644 // 3. SendL(MSG, TP::User-Agent) // check that selected User-Agentis used |
|
1645 // 4. SendL(MSG) // original User-Agent should be used (from step 1) |
|
1646 |
|
1647 _LIT8(KUserAgentValue, "TestAgent"); |
|
1648 |
|
1649 CSenServicePattern* pPattern = |
|
1650 CSenServicePattern::NewLC(KAuthServEndpoint, KNullDesC8()); |
|
1651 pPattern->SetFrameworkIdL(*ipFrameworkID); |
|
1652 |
|
1653 iServiceConnection = CSenServiceConnection::NewL(*this, *pPattern); |
|
1654 |
|
1655 CleanupStack::PopAndDestroy(pPattern); |
|
1656 |
|
1657 StartActiveScheduler(1); |
|
1658 LOCAL_ASSERT(iConnectionState == KSenConnectionStatusReady); |
|
1659 // Connection is ready to be used. |
|
1660 |
|
1661 // 1. Get TP via SC:TransportPropertiesL() // store currently effective User-Agent |
|
1662 HBufC8* pOriginalUserAgent = NULL; |
|
1663 HBufC8* pTransportPropertiesAsXml = NULL; |
|
1664 iServiceConnection->TransportPropertiesL(pTransportPropertiesAsXml); |
|
1665 if ( pTransportPropertiesAsXml ) |
|
1666 { |
|
1667 TPtrC8 userAgent; |
|
1668 CleanupStack::PushL(pTransportPropertiesAsXml); |
|
1669 CSenXmlReader* pParser = CSenXmlReader::NewLC(); |
|
1670 CSenHttpTransportProperties* pReadHttpProperties = |
|
1671 CSenHttpTransportProperties::NewLC(*pTransportPropertiesAsXml, |
|
1672 *pParser); |
|
1673 pReadHttpProperties->UserAgentL(userAgent); |
|
1674 pOriginalUserAgent = userAgent.AllocL(); |
|
1675 CleanupStack::PopAndDestroy(pReadHttpProperties); |
|
1676 CleanupStack::PopAndDestroy(pParser); |
|
1677 CleanupStack::PopAndDestroy(pTransportPropertiesAsXml); |
|
1678 CleanupStack::PushL(pOriginalUserAgent); |
|
1679 } |
|
1680 |
|
1681 CSenSoapMessage* pSOAPMessage = CreateAuthRequestLC(); |
|
1682 |
|
1683 // 2. TP::SetUserAgentL(User-Agent) |
|
1684 CSenHttpTransportProperties* pHttpProperties = CSenHttpTransportProperties::NewLC(); |
|
1685 pHttpProperties->SetUserAgentL(KUserAgentValue); |
|
1686 |
|
1687 // 3. SendL(MSG, TP::User-Agent) // check that selected User-Agent is used |
|
1688 pHttpProperties->SetHttpHeaderL(KLoggerFileNameProperty, KFileName); |
|
1689 TUint32 iapId = SearchIAPIdByNameL(KIAPName); |
|
1690 pHttpProperties->SetIapIdL(iapId); |
|
1691 HBufC8* pSerializedProperties = pHttpProperties->AsUtf8L(); |
|
1692 CleanupStack::PushL(pSerializedProperties); |
|
1693 iServiceConnection->SendL(*pSOAPMessage, *pSerializedProperties); |
|
1694 StartActiveScheduler(1); |
|
1695 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
1696 |
|
1697 CleanupStack::PopAndDestroy(pSerializedProperties); |
|
1698 CleanupStack::PopAndDestroy(pHttpProperties); |
|
1699 |
|
1700 // Check from HTTP Transaction logger log that selected User-Agent were used. |
|
1701 HBufC8* pFileContent = ReadFileL(KFileToRead); |
|
1702 LOCAL_ASSERT(pFileContent != NULL); |
|
1703 CleanupStack::PushL(pFileContent); |
|
1704 HBufC8* pValue = HttpPropertyValueFromXmlLC(*pFileContent, _L8("User-Agent")); |
|
1705 LOCAL_ASSERT(*pValue == KUserAgentValue); |
|
1706 CleanupStack::PopAndDestroy(pValue); |
|
1707 CleanupStack::PopAndDestroy(pFileContent); |
|
1708 |
|
1709 // 4. SendL(MSG) // original User-Agent should be used (from step 1) |
|
1710 pHttpProperties = CSenHttpTransportProperties::NewLC(); |
|
1711 pHttpProperties->SetHttpHeaderL(KLoggerFileNameProperty, KFileName); |
|
1712 pHttpProperties->SetIapIdL(iapId); |
|
1713 pSerializedProperties = pHttpProperties->AsUtf8L(); |
|
1714 CleanupStack::PushL(pSerializedProperties); |
|
1715 iServiceConnection->SendL(*pSOAPMessage, *pSerializedProperties); |
|
1716 StartActiveScheduler(1); |
|
1717 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
1718 |
|
1719 CleanupStack::PopAndDestroy(pSerializedProperties); |
|
1720 CleanupStack::PopAndDestroy(pHttpProperties); |
|
1721 |
|
1722 // Check from HTTP Transaction logger log that original User-Agent were used. |
|
1723 pFileContent = ReadFileL(KFileToRead); |
|
1724 LOCAL_ASSERT(pFileContent != NULL); |
|
1725 CleanupStack::PushL(pFileContent); |
|
1726 pValue = HttpPropertyValueFromXmlLC(*pFileContent, _L8("User-Agent")); |
|
1727 if ( pValue && pOriginalUserAgent ) |
|
1728 { |
|
1729 LOCAL_ASSERT(*pValue == *pOriginalUserAgent); |
|
1730 } |
|
1731 CleanupStack::PopAndDestroy(pValue); |
|
1732 CleanupStack::PopAndDestroy(pFileContent); |
|
1733 |
|
1734 CleanupStack::PopAndDestroy(pSOAPMessage); |
|
1735 |
|
1736 if ( pOriginalUserAgent ) |
|
1737 { |
|
1738 CleanupStack::PopAndDestroy(pOriginalUserAgent); |
|
1739 } |
|
1740 |
|
1741 delete iServiceConnection; |
|
1742 iServiceConnection = NULL; |
|
1743 return KErrNone; |
|
1744 } |
|
1745 |
|
1746 TInt CsenConnectionTester::UT_CSenServiceConnection_SendL_UserAgent2L( ) |
|
1747 { |
|
1748 // SetTransportPropertiesL(TP:User-Agent) |
|
1749 // 1. Get TP via SC:TransportPropertiesL() // store original user-agent |
|
1750 // 2. SendL(MSG); // check User-Agent from step 1 is sent/used |
|
1751 // 3. SetTransportPropertiesL(TP::User-Agent) // change user-agent |
|
1752 // 4. SendL(MSG, TP::User-Agent) // change user agent, check that it is used |
|
1753 // 5. SendL(MSG); // check that set User-Agent is used, from step 3 |
|
1754 |
|
1755 _LIT8(KUserAgentValue1, "TestAgent1"); |
|
1756 _LIT8(KUserAgentValue2, "TestAgent2"); |
|
1757 |
|
1758 CSenServicePattern* pPattern = |
|
1759 CSenServicePattern::NewLC(KAuthServEndpoint, KNullDesC8()); |
|
1760 pPattern->SetFrameworkIdL(*ipFrameworkID); |
|
1761 |
|
1762 iServiceConnection = CSenServiceConnection::NewL(*this, *pPattern); |
|
1763 |
|
1764 CleanupStack::PopAndDestroy(pPattern); |
|
1765 |
|
1766 StartActiveScheduler(1); |
|
1767 LOCAL_ASSERT(iConnectionState == KSenConnectionStatusReady); |
|
1768 // Connection is ready to be used. |
|
1769 |
|
1770 // 1. Get TP via SC:TransportPropertiesL() // store original user-agent |
|
1771 HBufC8* pOriginalUserAgent = NULL; |
|
1772 HBufC8* pTransportPropertiesAsXml = NULL; |
|
1773 iServiceConnection->TransportPropertiesL(pTransportPropertiesAsXml); |
|
1774 if ( pTransportPropertiesAsXml ) |
|
1775 { |
|
1776 TPtrC8 userAgent; |
|
1777 CleanupStack::PushL(pTransportPropertiesAsXml); |
|
1778 CSenXmlReader* pParser = CSenXmlReader::NewLC(); |
|
1779 CSenHttpTransportProperties* pReadHttpProperties = |
|
1780 CSenHttpTransportProperties::NewLC(*pTransportPropertiesAsXml, |
|
1781 *pParser); |
|
1782 pReadHttpProperties->UserAgentL(userAgent); |
|
1783 pOriginalUserAgent = userAgent.AllocL(); |
|
1784 CleanupStack::PopAndDestroy(pReadHttpProperties); |
|
1785 CleanupStack::PopAndDestroy(pParser); |
|
1786 CleanupStack::PopAndDestroy(pTransportPropertiesAsXml); |
|
1787 CleanupStack::PushL(pOriginalUserAgent); |
|
1788 } |
|
1789 |
|
1790 CSenSoapMessage* pSOAPMessage = CreateAuthRequestLC(); |
|
1791 |
|
1792 // 2. SendL(MSG); // check User-Agent from step 1 is sent/used |
|
1793 CSenHttpTransportProperties* pHttpProperties = CSenHttpTransportProperties::NewLC(); |
|
1794 pHttpProperties->SetHttpHeaderL(KLoggerFileNameProperty, KFileName); |
|
1795 TUint32 iapId = SearchIAPIdByNameL(KIAPName); |
|
1796 pHttpProperties->SetIapIdL(iapId); |
|
1797 HBufC8* pSerializedProperties = pHttpProperties->AsUtf8L(); |
|
1798 CleanupStack::PushL(pSerializedProperties); |
|
1799 iServiceConnection->SendL(*pSOAPMessage, *pSerializedProperties); |
|
1800 StartActiveScheduler(1); |
|
1801 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
1802 |
|
1803 CleanupStack::PopAndDestroy(pSerializedProperties); |
|
1804 CleanupStack::PopAndDestroy(pHttpProperties); |
|
1805 |
|
1806 // Check from HTTP Transaction logger log that original User-Agent were used. |
|
1807 HBufC8* pFileContent = ReadFileL(KFileToRead); |
|
1808 LOCAL_ASSERT(pFileContent != NULL); |
|
1809 CleanupStack::PushL(pFileContent); |
|
1810 HBufC8* pValue = HttpPropertyValueFromXmlLC(*pFileContent, _L8("User-Agent")); |
|
1811 |
|
1812 if ( pValue && pOriginalUserAgent ) |
|
1813 { |
|
1814 LOCAL_ASSERT(*pValue == *pOriginalUserAgent); |
|
1815 } |
|
1816 CleanupStack::PopAndDestroy(pValue); |
|
1817 CleanupStack::PopAndDestroy(pFileContent); |
|
1818 |
|
1819 // 3. SetTransportPropertiesL(TP::User-Agent) // change user-agent |
|
1820 pHttpProperties = CSenHttpTransportProperties::NewLC(); |
|
1821 pHttpProperties->SetUserAgentL(KUserAgentValue1); |
|
1822 pHttpProperties->SetHttpHeaderL(KLoggerFileNameProperty, KFileName); |
|
1823 pHttpProperties->SetIapIdL(iapId); |
|
1824 pSerializedProperties = pHttpProperties->AsUtf8L(); |
|
1825 CleanupStack::PushL(pSerializedProperties); |
|
1826 iServiceConnection->SetTransportPropertiesL(*pSerializedProperties); |
|
1827 CleanupStack::PopAndDestroy(pSerializedProperties); |
|
1828 CleanupStack::PopAndDestroy(pHttpProperties); |
|
1829 |
|
1830 // 4. SendL(MSG, TP::User-Agent) // change user agent, check that it is used |
|
1831 pHttpProperties = CSenHttpTransportProperties::NewLC(); |
|
1832 pHttpProperties->SetUserAgentL(KUserAgentValue2); |
|
1833 pSerializedProperties = pHttpProperties->AsUtf8L(); |
|
1834 CleanupStack::PushL(pSerializedProperties); |
|
1835 iServiceConnection->SendL(*pSOAPMessage, *pSerializedProperties); |
|
1836 StartActiveScheduler(1); |
|
1837 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
1838 |
|
1839 CleanupStack::PopAndDestroy(pSerializedProperties); |
|
1840 CleanupStack::PopAndDestroy(pHttpProperties); |
|
1841 |
|
1842 // Check from HTTP Transaction logger log that defined User-Agent were used. |
|
1843 pFileContent = ReadFileL(KFileToRead); |
|
1844 LOCAL_ASSERT(pFileContent != NULL); |
|
1845 CleanupStack::PushL(pFileContent); |
|
1846 pValue = HttpPropertyValueFromXmlLC(*pFileContent, _L8("User-Agent")); |
|
1847 LOCAL_ASSERT(*pValue == KUserAgentValue2); |
|
1848 CleanupStack::PopAndDestroy(pValue); |
|
1849 CleanupStack::PopAndDestroy(pFileContent); |
|
1850 |
|
1851 // 5. SendL(MSG); // check that set User-Agent is used, from step 3 |
|
1852 iServiceConnection->SendL(*pSOAPMessage); |
|
1853 StartActiveScheduler(1); |
|
1854 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
1855 |
|
1856 // Check from HTTP Transaction logger log that defined (in step 3) User-Agent were used. |
|
1857 pFileContent = ReadFileL(KFileToRead); |
|
1858 LOCAL_ASSERT(pFileContent != NULL); |
|
1859 CleanupStack::PushL(pFileContent); |
|
1860 pValue = HttpPropertyValueFromXmlLC(*pFileContent, _L8("User-Agent")); |
|
1861 LOCAL_ASSERT(*pValue == KUserAgentValue1); |
|
1862 CleanupStack::PopAndDestroy(pValue); |
|
1863 CleanupStack::PopAndDestroy(pFileContent); |
|
1864 |
|
1865 CleanupStack::PopAndDestroy(pSOAPMessage); |
|
1866 |
|
1867 if ( pOriginalUserAgent ) |
|
1868 { |
|
1869 CleanupStack::PopAndDestroy(pOriginalUserAgent); |
|
1870 } |
|
1871 |
|
1872 delete iServiceConnection; |
|
1873 iServiceConnection = NULL; |
|
1874 return KErrNone; |
|
1875 } |
|
1876 |
|
1877 TInt CsenConnectionTester::UT_CSenServiceConnection_SendL_MessageSoapActionL( ) |
|
1878 { |
|
1879 _LIT8(KSoapAction, "SOAPAction"); |
|
1880 _LIT8(KSoapActionValue, "MessageAction"); |
|
1881 _LIT8(KSoapActionReturnValue, "\"MessageAction\""); |
|
1882 |
|
1883 CSenServicePattern* pPattern = |
|
1884 CSenServicePattern::NewLC(KAuthServEndpoint, KNullDesC8()); |
|
1885 pPattern->SetFrameworkIdL(*ipFrameworkID); |
|
1886 |
|
1887 TUint32 iapId = SearchIAPIdByNameL(KIAPName); |
|
1888 pPattern->SetConsumerIapIdL(iapId); |
|
1889 |
|
1890 iServiceConnection = CSenServiceConnection::NewL(*this, *pPattern); |
|
1891 |
|
1892 CleanupStack::PopAndDestroy(pPattern); |
|
1893 |
|
1894 StartActiveScheduler(1); |
|
1895 LOCAL_ASSERT(iConnectionState == KSenConnectionStatusReady); |
|
1896 // Connection is ready to be used. |
|
1897 |
|
1898 CSenSoapMessage* pSOAPMessage = CreateAuthRequestLC(); |
|
1899 pSOAPMessage->SetSoapActionL(KSoapActionValue); |
|
1900 |
|
1901 // Http Post |
|
1902 CSenHttpTransportProperties* pHttpProperties = CSenHttpTransportProperties::NewLC(); |
|
1903 pHttpProperties->SetHttpHeaderL(KLoggerFileNameProperty, KFileName); |
|
1904 HBufC8* pSerializedProperties = pHttpProperties->AsUtf8L(); |
|
1905 CleanupStack::PushL(pSerializedProperties); |
|
1906 |
|
1907 iServiceConnection->SendL(*pSOAPMessage, *pSerializedProperties); |
|
1908 StartActiveScheduler(1); |
|
1909 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
1910 |
|
1911 CleanupStack::PopAndDestroy(pSerializedProperties); |
|
1912 CleanupStack::PopAndDestroy(pHttpProperties); |
|
1913 |
|
1914 CleanupStack::PopAndDestroy(pSOAPMessage); |
|
1915 |
|
1916 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
1917 |
|
1918 // Read HTTP Transaction from file |
|
1919 HBufC8* pFileContent = ReadFileL(KFileToRead); |
|
1920 |
|
1921 LOCAL_ASSERT(pFileContent != NULL); |
|
1922 |
|
1923 CleanupStack::PushL(pFileContent); |
|
1924 |
|
1925 HBufC8* pValue = HttpPropertyValueFromXmlLC(*pFileContent, KSoapAction); |
|
1926 LOCAL_ASSERT(*pValue == KSoapActionReturnValue); |
|
1927 CleanupStack::PopAndDestroy(pValue); |
|
1928 |
|
1929 CleanupStack::PopAndDestroy(pFileContent); |
|
1930 |
|
1931 delete iServiceConnection; |
|
1932 iServiceConnection = NULL; |
|
1933 return KErrNone; |
|
1934 } |
|
1935 |
|
1936 TInt CsenConnectionTester::UT_CSenServiceConnection_SendL_SoapAction1L( ) |
|
1937 { |
|
1938 // SendL(MSG, TP:SOAPAction) |
|
1939 // 1. Get TP via SC:TransportPropertiesL() // store currently effective SOAPAction |
|
1940 // 2. TP::SetSoapActionL(SOAPAction) |
|
1941 // 3. SendL(MSG, TP::SOAPAction) // check that selected SOAPAction is used |
|
1942 // 4. SendL(MSG) // original SOAPAction should be used (from step 1) |
|
1943 |
|
1944 _LIT8(KSoapAction, "SOAPAction"); |
|
1945 _LIT8(KSoapActionValue, "MessagePropertyAction"); |
|
1946 _LIT8(KSoapActionReturnValue, "\"MessagePropertyAction\""); |
|
1947 |
|
1948 CSenServicePattern* pPattern = |
|
1949 CSenServicePattern::NewLC(KAuthServEndpoint, KNullDesC8()); |
|
1950 pPattern->SetFrameworkIdL(*ipFrameworkID); |
|
1951 |
|
1952 TUint32 iapId = SearchIAPIdByNameL(KIAPName); |
|
1953 pPattern->SetConsumerIapIdL(iapId); |
|
1954 |
|
1955 iServiceConnection = CSenServiceConnection::NewL(*this, *pPattern); |
|
1956 |
|
1957 CleanupStack::PopAndDestroy(pPattern); |
|
1958 |
|
1959 StartActiveScheduler(1); |
|
1960 LOCAL_ASSERT(iConnectionState == KSenConnectionStatusReady); |
|
1961 // Connection is ready to be used. |
|
1962 |
|
1963 // 1. Get TP via SC:TransportPropertiesL() // store currently effective SOAPAction |
|
1964 HBufC8* pOriginalSoapAction = NULL; |
|
1965 HBufC8* pTransportPropertiesAsXml = NULL; |
|
1966 iServiceConnection->TransportPropertiesL(pTransportPropertiesAsXml); |
|
1967 if ( pTransportPropertiesAsXml ) |
|
1968 { |
|
1969 CleanupStack::PushL(pTransportPropertiesAsXml); |
|
1970 CSenXmlReader* pParser = CSenXmlReader::NewLC(); |
|
1971 CSenHttpTransportProperties* pReadHttpProperties = |
|
1972 CSenHttpTransportProperties::NewLC(*pTransportPropertiesAsXml, |
|
1973 *pParser); |
|
1974 TPtrC8 soapAction(KNullDesC8); |
|
1975 TInt retVal = pReadHttpProperties->SoapActionL(soapAction); |
|
1976 if ( retVal == KErrNone ) |
|
1977 { |
|
1978 pOriginalSoapAction = soapAction.AllocL(); |
|
1979 } |
|
1980 CleanupStack::PopAndDestroy(pReadHttpProperties); |
|
1981 CleanupStack::PopAndDestroy(pParser); |
|
1982 CleanupStack::PopAndDestroy(pTransportPropertiesAsXml); |
|
1983 } |
|
1984 |
|
1985 if ( pOriginalSoapAction ) |
|
1986 { |
|
1987 CleanupStack::PushL(pOriginalSoapAction); |
|
1988 } |
|
1989 |
|
1990 CSenSoapMessage* pSOAPMessage = CreateAuthRequestLC(); |
|
1991 |
|
1992 // 2. TP::SetSoapActionL(SOAPAction) |
|
1993 CSenHttpTransportProperties* pHttpProperties = CSenHttpTransportProperties::NewLC(); |
|
1994 pHttpProperties->SetSoapActionL(KSoapActionValue); |
|
1995 |
|
1996 // 3. SendL(MSG, TP::SOAPAction) // check that selected SOAPAction is used |
|
1997 pHttpProperties->SetHttpHeaderL(KLoggerFileNameProperty, KFileName); |
|
1998 pHttpProperties->SetIapIdL(iapId); |
|
1999 HBufC8* pSerializedProperties = pHttpProperties->AsUtf8L(); |
|
2000 CleanupStack::PushL(pSerializedProperties); |
|
2001 iServiceConnection->SendL(*pSOAPMessage, *pSerializedProperties); |
|
2002 StartActiveScheduler(1); |
|
2003 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
2004 CleanupStack::PopAndDestroy(pSerializedProperties); |
|
2005 CleanupStack::PopAndDestroy(pHttpProperties); |
|
2006 |
|
2007 // Check from HTTP Transaction logger log that defined SoapAction were used. |
|
2008 HBufC8* pFileContent = ReadFileL(KFileToRead); |
|
2009 LOCAL_ASSERT(pFileContent != NULL); |
|
2010 CleanupStack::PushL(pFileContent); |
|
2011 HBufC8* pValue = HttpPropertyValueFromXmlLC(*pFileContent, KSoapAction); |
|
2012 if( pValue ) |
|
2013 { |
|
2014 LOCAL_ASSERT(*pValue == KSoapActionReturnValue); |
|
2015 } |
|
2016 CleanupStack::PopAndDestroy(pValue); |
|
2017 CleanupStack::PopAndDestroy(pFileContent); |
|
2018 |
|
2019 // 4. SendL(MSG) // original SOAPAction should be used (from step 1) |
|
2020 pHttpProperties = CSenHttpTransportProperties::NewLC(); |
|
2021 pHttpProperties->SetHttpHeaderL(KLoggerFileNameProperty, KFileName); |
|
2022 pHttpProperties->SetIapIdL(iapId); |
|
2023 pSerializedProperties = pHttpProperties->AsUtf8L(); |
|
2024 CleanupStack::PushL(pSerializedProperties); |
|
2025 iServiceConnection->SendL(*pSOAPMessage, *pSerializedProperties); |
|
2026 StartActiveScheduler(1); |
|
2027 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
2028 CleanupStack::PopAndDestroy(pSerializedProperties); |
|
2029 CleanupStack::PopAndDestroy(pHttpProperties); |
|
2030 |
|
2031 // Check from HTTP Transaction logger log that original SoapAction is used. |
|
2032 pFileContent = ReadFileL(KFileToRead); |
|
2033 LOCAL_ASSERT(pFileContent != NULL); |
|
2034 CleanupStack::PushL(pFileContent); |
|
2035 pValue = HttpPropertyValueFromXmlLC(*pFileContent, KSoapAction); |
|
2036 |
|
2037 if( pValue && pOriginalSoapAction ) |
|
2038 { |
|
2039 LOCAL_ASSERT(*pValue == *pOriginalSoapAction); |
|
2040 } |
|
2041 // else if ( pValue ) |
|
2042 // { |
|
2043 // This is temporary: the default "" SOAPAction value has been removed from HTTPC: |
|
2044 // also WS-I, REST and ID-WSF define this "" -value only on ::SendL (in message layer!) |
|
2045 // This means, that "original soap action" from SC does not CURRENTLY yet provide the |
|
2046 // framework default(!) |
|
2047 // LOCAL_ASSERT( *pValue == KSenSoapActionHeaderValueEmpty ) // default from framework. |
|
2048 // } |
|
2049 CleanupStack::PopAndDestroy(pValue); |
|
2050 CleanupStack::PopAndDestroy(pFileContent); |
|
2051 |
|
2052 CleanupStack::PopAndDestroy(pSOAPMessage); |
|
2053 |
|
2054 if ( pOriginalSoapAction ) |
|
2055 { |
|
2056 CleanupStack::PopAndDestroy(pOriginalSoapAction); |
|
2057 } |
|
2058 |
|
2059 delete iServiceConnection; |
|
2060 iServiceConnection = NULL; |
|
2061 return KErrNone; |
|
2062 } |
|
2063 |
|
2064 TInt CsenConnectionTester::UT_CSenServiceConnection_SendL_SoapAction2L( ) |
|
2065 { |
|
2066 // SendL(SOAP-ENV::SOAPAction) |
|
2067 // 1. Get TP via SC:TransportPropertiesL() // store original soap-action |
|
2068 // 2. SendL(SOAP-ENV::SOAPAction); // check SOAPAction from SoapEnvelope is sent/used |
|
2069 // 3. SendL(MSG); // check that original SOAPACtion is used, from step 1 |
|
2070 // 4. SetTransportProperties(TP::SOAPAction2); |
|
2071 // 5. SendL(MSG); // check that previous SC::SOAPAction is used, from step 4 |
|
2072 // 6. SendL(MSG, TP:SOAPAction); // check that TP:SOAPAction is used |
|
2073 // 7. SendL(SOAP-ENV::SOAPAction); // check that SOAP-ENV:SOAPAction is used |
|
2074 // 8. SendL(SOAP-ENV); // check that previous SC::SOAPAction is used, from step 4 |
|
2075 // 9. SendL(SOAP-ENV, TP::SOAPAction); // check that new TP::SOAPAction is used |
|
2076 // 10. SendL(SOAP-ENV:SOAPAction, TP::SOAPAction ); // both are set: check that SOAP-ENV:SOAPAction is used, over-riding TP |
|
2077 // 11. SendL(SOAP-ENV:SOAPAction ); SC::SOAPAction // only SOAP-ENV::SOAPAction is set: check that it is effective, instead of SC::SOAPAction |
|
2078 // 12. SendL(MSG, TP:SOAPAction ); SC::SOAPAction // only TP::SOAPAction is set: check that it is effective, instead of SC::SOAPAction |
|
2079 |
|
2080 _LIT8(KSoapAction, "SOAPAction"); |
|
2081 _LIT8(KEnvelopeSoapActionValue, "EnvelopeAction"); |
|
2082 _LIT8(KEnvelopeSoapActionReturnValue, "\"EnvelopeAction\""); |
|
2083 _LIT8(KSessionSoapActionValue, "SessionAction"); |
|
2084 _LIT8(KSessionSoapActionReturnValue, "\"SessionAction\""); |
|
2085 _LIT8(KMessageSoapActionValue, "MessageAction"); |
|
2086 _LIT8(KMessageSoapActionReturnValue, "\"MessageAction\""); |
|
2087 |
|
2088 CSenServicePattern* pPattern = |
|
2089 CSenServicePattern::NewLC(KAuthServEndpoint, KNullDesC8()); |
|
2090 pPattern->SetFrameworkIdL(*ipFrameworkID); |
|
2091 |
|
2092 TUint32 iapId = SearchIAPIdByNameL(KIAPName); |
|
2093 pPattern->SetConsumerIapIdL(iapId); |
|
2094 |
|
2095 iServiceConnection = CSenServiceConnection::NewL(*this, *pPattern); |
|
2096 |
|
2097 CleanupStack::PopAndDestroy(pPattern); |
|
2098 |
|
2099 StartActiveScheduler(1); |
|
2100 LOCAL_ASSERT(iConnectionState == KSenConnectionStatusReady); |
|
2101 // Connection is ready to be used. |
|
2102 |
|
2103 // 1. Get TP via SC:TransportPropertiesL() // store original soap-action |
|
2104 HBufC8* pOriginalSoapAction = NULL; |
|
2105 HBufC8* pTransportPropertiesAsXml = NULL; |
|
2106 iServiceConnection->TransportPropertiesL(pTransportPropertiesAsXml); |
|
2107 if ( pTransportPropertiesAsXml ) |
|
2108 { |
|
2109 CleanupStack::PushL(pTransportPropertiesAsXml); |
|
2110 CSenXmlReader* pParser = CSenXmlReader::NewLC(); |
|
2111 CSenHttpTransportProperties* pReadHttpProperties = |
|
2112 CSenHttpTransportProperties::NewLC(*pTransportPropertiesAsXml, |
|
2113 *pParser); |
|
2114 TPtrC8 soapAction(KNullDesC8); |
|
2115 TInt retVal = pReadHttpProperties->SoapActionL(soapAction); |
|
2116 if ( retVal == KErrNone ) |
|
2117 { |
|
2118 pOriginalSoapAction = soapAction.AllocL(); |
|
2119 } |
|
2120 CleanupStack::PopAndDestroy(pReadHttpProperties); |
|
2121 CleanupStack::PopAndDestroy(pParser); |
|
2122 CleanupStack::PopAndDestroy(pTransportPropertiesAsXml); |
|
2123 } |
|
2124 |
|
2125 if ( pOriginalSoapAction ) |
|
2126 { |
|
2127 CleanupStack::PushL(pOriginalSoapAction); |
|
2128 } |
|
2129 |
|
2130 CSenSoapMessage* pSOAPMessage = CreateAuthRequestLC(); |
|
2131 |
|
2132 // 2. SendL(SOAP-ENV::SOAPAction); // check SOAPAction from SoapEnvelope is sent/used |
|
2133 pSOAPMessage->SetSoapActionL(KEnvelopeSoapActionValue); |
|
2134 CSenHttpTransportProperties* pHttpProperties = CSenHttpTransportProperties::NewLC(); |
|
2135 pHttpProperties->SetHttpHeaderL(KLoggerFileNameProperty, KFileName); |
|
2136 pHttpProperties->SetIapIdL(iapId); |
|
2137 HBufC8* pSerializedProperties = pHttpProperties->AsUtf8L(); |
|
2138 CleanupStack::PushL(pSerializedProperties); |
|
2139 iServiceConnection->SendL(*pSOAPMessage, *pSerializedProperties); |
|
2140 StartActiveScheduler(1); |
|
2141 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
2142 CleanupStack::PopAndDestroy(pSerializedProperties); |
|
2143 CleanupStack::PopAndDestroy(pHttpProperties); |
|
2144 |
|
2145 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
2146 |
|
2147 // Check from HTTP Transaction logger log that defined SoapAction were used. |
|
2148 HBufC8* pFileContent = ReadFileL(KFileToRead); |
|
2149 LOCAL_ASSERT(pFileContent != NULL); |
|
2150 CleanupStack::PushL(pFileContent); |
|
2151 HBufC8* pValue = HttpPropertyValueFromXmlLC(*pFileContent, KSoapAction); |
|
2152 if( pValue ) |
|
2153 { |
|
2154 LOCAL_ASSERT(*pValue == KEnvelopeSoapActionReturnValue); |
|
2155 } |
|
2156 CleanupStack::PopAndDestroy(pValue); |
|
2157 CleanupStack::PopAndDestroy(pFileContent); |
|
2158 |
|
2159 CleanupStack::PopAndDestroy(pSOAPMessage); |
|
2160 // Create a new Soap message because old one contains defined SoapAction |
|
2161 pSOAPMessage = CreateAuthRequestLC(); |
|
2162 |
|
2163 // 3. SendL(MSG); // check that original SOAPACtion is used, from step 1 |
|
2164 pHttpProperties = CSenHttpTransportProperties::NewLC(); |
|
2165 pHttpProperties->SetHttpHeaderL(KLoggerFileNameProperty, KFileName); |
|
2166 pHttpProperties->SetIapIdL(iapId); |
|
2167 pSerializedProperties = pHttpProperties->AsUtf8L(); |
|
2168 CleanupStack::PushL(pSerializedProperties); |
|
2169 iServiceConnection->SendL(*pSOAPMessage, *pSerializedProperties); |
|
2170 StartActiveScheduler(1); |
|
2171 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
2172 CleanupStack::PopAndDestroy(pSerializedProperties); |
|
2173 CleanupStack::PopAndDestroy(pHttpProperties); |
|
2174 |
|
2175 // Check from HTTP Transaction logger log that original SoapAction were used. |
|
2176 pFileContent = ReadFileL(KFileToRead); |
|
2177 LOCAL_ASSERT(pFileContent != NULL); |
|
2178 CleanupStack::PushL(pFileContent); |
|
2179 pValue = HttpPropertyValueFromXmlLC(*pFileContent, KSoapAction); |
|
2180 if ( pValue && pOriginalSoapAction ) |
|
2181 { |
|
2182 LOCAL_ASSERT(*pValue == *pOriginalSoapAction); |
|
2183 } |
|
2184 CleanupStack::PopAndDestroy(pValue); |
|
2185 CleanupStack::PopAndDestroy(pFileContent); |
|
2186 |
|
2187 // 4. SetTransportProperties(TP::SOAPAction2); |
|
2188 pHttpProperties = CSenHttpTransportProperties::NewLC(); |
|
2189 pHttpProperties->SetSoapActionL(KSessionSoapActionValue); |
|
2190 pHttpProperties->SetHttpHeaderL(KLoggerFileNameProperty, KFileName); |
|
2191 pHttpProperties->SetIapIdL(iapId); |
|
2192 pSerializedProperties = pHttpProperties->AsUtf8L(); |
|
2193 CleanupStack::PushL(pSerializedProperties); |
|
2194 iServiceConnection->SetTransportPropertiesL(*pSerializedProperties); |
|
2195 CleanupStack::PopAndDestroy(pSerializedProperties); |
|
2196 CleanupStack::PopAndDestroy(pHttpProperties); |
|
2197 |
|
2198 // 5. SendL(MSG); // check that previous SC::SOAPAction is used, from step 4 |
|
2199 iServiceConnection->SendL(*pSOAPMessage); |
|
2200 StartActiveScheduler(1); |
|
2201 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
2202 |
|
2203 // Check from HTTP Transaction logger log that defined (in step 4.) SoapAction were used. |
|
2204 pFileContent = ReadFileL(KFileToRead); |
|
2205 LOCAL_ASSERT(pFileContent != NULL); |
|
2206 CleanupStack::PushL(pFileContent); |
|
2207 pValue = HttpPropertyValueFromXmlLC(*pFileContent, KSoapAction); |
|
2208 if( pValue ) |
|
2209 { |
|
2210 LOCAL_ASSERT(*pValue == KSessionSoapActionReturnValue); |
|
2211 } |
|
2212 CleanupStack::PopAndDestroy(pValue); |
|
2213 CleanupStack::PopAndDestroy(pFileContent); |
|
2214 |
|
2215 // 6. SendL(MSG, TP:SOAPAction); // check that TP:SOAPAction is used |
|
2216 pHttpProperties = CSenHttpTransportProperties::NewLC(); |
|
2217 pHttpProperties->SetSoapActionL(KMessageSoapActionValue); |
|
2218 pHttpProperties->SetHttpHeaderL(KLoggerFileNameProperty, KFileName); |
|
2219 pHttpProperties->SetIapIdL(iapId); |
|
2220 pSerializedProperties = pHttpProperties->AsUtf8L(); |
|
2221 CleanupStack::PushL(pSerializedProperties); |
|
2222 iServiceConnection->SendL(*pSOAPMessage, *pSerializedProperties); |
|
2223 CleanupStack::PopAndDestroy(pSerializedProperties); |
|
2224 CleanupStack::PopAndDestroy(pHttpProperties); |
|
2225 StartActiveScheduler(1); |
|
2226 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
2227 |
|
2228 // Check from HTTP Transaction logger log that defined SoapAction were used. |
|
2229 pFileContent = ReadFileL(KFileToRead); |
|
2230 LOCAL_ASSERT(pFileContent != NULL); |
|
2231 CleanupStack::PushL(pFileContent); |
|
2232 pValue = HttpPropertyValueFromXmlLC(*pFileContent, KSoapAction); |
|
2233 if( pValue ) |
|
2234 { |
|
2235 LOCAL_ASSERT(*pValue == KMessageSoapActionReturnValue); |
|
2236 } |
|
2237 CleanupStack::PopAndDestroy(pValue); |
|
2238 CleanupStack::PopAndDestroy(pFileContent); |
|
2239 |
|
2240 // 7. SendL(SOAP-ENV::SOAPAction); // check that SOAP-ENV:SOAPAction is used |
|
2241 pSOAPMessage->SetSoapActionL(KEnvelopeSoapActionValue); |
|
2242 iServiceConnection->SendL(*pSOAPMessage); |
|
2243 StartActiveScheduler(1); |
|
2244 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
2245 |
|
2246 // Check from HTTP Transaction logger log that defined SoapAction were used. |
|
2247 pFileContent = ReadFileL(KFileToRead); |
|
2248 LOCAL_ASSERT(pFileContent != NULL); |
|
2249 CleanupStack::PushL(pFileContent); |
|
2250 pValue = HttpPropertyValueFromXmlLC(*pFileContent, KSoapAction); |
|
2251 if ( pValue ) |
|
2252 { |
|
2253 LOCAL_ASSERT(*pValue == KEnvelopeSoapActionReturnValue); |
|
2254 } |
|
2255 CleanupStack::PopAndDestroy(pValue); |
|
2256 CleanupStack::PopAndDestroy(pFileContent); |
|
2257 |
|
2258 CleanupStack::PopAndDestroy(pSOAPMessage); |
|
2259 // Create a new Soap message because old one contains defined SoapAction |
|
2260 pSOAPMessage = CreateAuthRequestLC(); |
|
2261 |
|
2262 // 8. SendL(SOAP-ENV); // check that previous SC::SOAPAction is used, from step 4 |
|
2263 iServiceConnection->SendL(*pSOAPMessage); |
|
2264 StartActiveScheduler(1); |
|
2265 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
2266 |
|
2267 // Check from HTTP Transaction logger log that defined (in step 4.) SoapAction were used. |
|
2268 pFileContent = ReadFileL(KFileToRead); |
|
2269 LOCAL_ASSERT(pFileContent != NULL); |
|
2270 CleanupStack::PushL(pFileContent); |
|
2271 pValue = HttpPropertyValueFromXmlLC(*pFileContent, KSoapAction); |
|
2272 if ( pValue ) |
|
2273 { |
|
2274 LOCAL_ASSERT(*pValue == KSessionSoapActionReturnValue); |
|
2275 } |
|
2276 CleanupStack::PopAndDestroy(pValue); |
|
2277 CleanupStack::PopAndDestroy(pFileContent); |
|
2278 |
|
2279 // 9. SendL(SOAP-ENV, TP::SOAPAction); // check that new TP::SOAPAction is used |
|
2280 pHttpProperties = CSenHttpTransportProperties::NewLC(); |
|
2281 pHttpProperties->SetSoapActionL(KMessageSoapActionValue); |
|
2282 pHttpProperties->SetHttpHeaderL(KLoggerFileNameProperty, KFileName); |
|
2283 pHttpProperties->SetIapIdL(iapId); |
|
2284 pSerializedProperties = pHttpProperties->AsUtf8L(); |
|
2285 CleanupStack::PushL(pSerializedProperties); |
|
2286 iServiceConnection->SendL(*pSOAPMessage, *pSerializedProperties); |
|
2287 CleanupStack::PopAndDestroy(pSerializedProperties); |
|
2288 CleanupStack::PopAndDestroy(pHttpProperties); |
|
2289 StartActiveScheduler(1); |
|
2290 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
2291 |
|
2292 // Check from HTTP Transaction logger log that defined SoapAction were used. |
|
2293 pFileContent = ReadFileL(KFileToRead); |
|
2294 LOCAL_ASSERT(pFileContent != NULL); |
|
2295 CleanupStack::PushL(pFileContent); |
|
2296 pValue = HttpPropertyValueFromXmlLC(*pFileContent, KSoapAction); |
|
2297 if( pValue ) |
|
2298 { |
|
2299 LOCAL_ASSERT(*pValue == KMessageSoapActionReturnValue); |
|
2300 } |
|
2301 CleanupStack::PopAndDestroy(pValue); |
|
2302 CleanupStack::PopAndDestroy(pFileContent); |
|
2303 |
|
2304 // 10. SendL(SOAP-ENV:SOAPAction, TP::SOAPAction); // both are set: check that SOAP-ENV:SOAPAction is used, over-riding TP |
|
2305 pSOAPMessage->SetSoapActionL(KEnvelopeSoapActionValue); |
|
2306 pHttpProperties = CSenHttpTransportProperties::NewLC(); |
|
2307 pHttpProperties->SetSoapActionL(KMessageSoapActionValue); |
|
2308 pHttpProperties->SetHttpHeaderL(KLoggerFileNameProperty, KFileName); |
|
2309 pHttpProperties->SetIapIdL(iapId); |
|
2310 pSerializedProperties = pHttpProperties->AsUtf8L(); |
|
2311 CleanupStack::PushL(pSerializedProperties); |
|
2312 iServiceConnection->SendL(*pSOAPMessage, *pSerializedProperties); |
|
2313 CleanupStack::PopAndDestroy(pSerializedProperties); |
|
2314 CleanupStack::PopAndDestroy(pHttpProperties); |
|
2315 StartActiveScheduler(1); |
|
2316 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
2317 |
|
2318 // Check from HTTP Transaction logger log that defined SoapAction were used. |
|
2319 pFileContent = ReadFileL(KFileToRead); |
|
2320 LOCAL_ASSERT(pFileContent != NULL); |
|
2321 CleanupStack::PushL(pFileContent); |
|
2322 pValue = HttpPropertyValueFromXmlLC(*pFileContent, KSoapAction); |
|
2323 if ( pValue ) |
|
2324 { |
|
2325 LOCAL_ASSERT(*pValue == KEnvelopeSoapActionReturnValue); |
|
2326 } |
|
2327 CleanupStack::PopAndDestroy(pValue); |
|
2328 CleanupStack::PopAndDestroy(pFileContent); |
|
2329 |
|
2330 CleanupStack::PopAndDestroy(pSOAPMessage); |
|
2331 // Create a new Soap message because old one contains defined SoapAction |
|
2332 pSOAPMessage = CreateAuthRequestLC(); |
|
2333 |
|
2334 // 11. SendL(SOAP-ENV:SOAPAction ); SC::SOAPAction // only SOAP-ENV::SOAPAction is set: check that it is effective, instead of SC::SOAPAction |
|
2335 // Note: SOAPAction for ServiceConnection was defined in step 4. |
|
2336 pSOAPMessage->SetSoapActionL(KEnvelopeSoapActionValue); |
|
2337 iServiceConnection->SendL(*pSOAPMessage); |
|
2338 StartActiveScheduler(1); |
|
2339 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
2340 |
|
2341 // Check from HTTP Transaction logger log that defined SoapAction were used. |
|
2342 pFileContent = ReadFileL(KFileToRead); |
|
2343 LOCAL_ASSERT(pFileContent != NULL); |
|
2344 CleanupStack::PushL(pFileContent); |
|
2345 pValue = HttpPropertyValueFromXmlLC(*pFileContent, KSoapAction); |
|
2346 if ( pValue ) |
|
2347 { |
|
2348 LOCAL_ASSERT(*pValue == KEnvelopeSoapActionReturnValue); |
|
2349 } |
|
2350 CleanupStack::PopAndDestroy(pValue); |
|
2351 CleanupStack::PopAndDestroy(pFileContent); |
|
2352 |
|
2353 CleanupStack::PopAndDestroy(pSOAPMessage); |
|
2354 // Create a new Soap message because old one contains defined SoapAction |
|
2355 pSOAPMessage = CreateAuthRequestLC(); |
|
2356 |
|
2357 // 12. SendL(MSG, TP:SOAPAction ); SC::SOAPAction // only TP::SOAPAction is set: check that it is effective, instead of SC::SOAPAction |
|
2358 // Note: SOAPAction for ServiceConnection was defined in step 4. |
|
2359 pHttpProperties = CSenHttpTransportProperties::NewLC(); |
|
2360 pHttpProperties->SetSoapActionL(KMessageSoapActionValue); |
|
2361 pHttpProperties->SetHttpHeaderL(KLoggerFileNameProperty, KFileName); |
|
2362 pHttpProperties->SetIapIdL(iapId); |
|
2363 pSerializedProperties = pHttpProperties->AsUtf8L(); |
|
2364 CleanupStack::PushL(pSerializedProperties); |
|
2365 iServiceConnection->SendL(*pSOAPMessage, *pSerializedProperties); |
|
2366 CleanupStack::PopAndDestroy(pSerializedProperties); |
|
2367 CleanupStack::PopAndDestroy(pHttpProperties); |
|
2368 StartActiveScheduler(1); |
|
2369 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
2370 |
|
2371 // Check from HTTP Transaction logger log that defined SoapAction were used. |
|
2372 pFileContent = ReadFileL(KFileToRead); |
|
2373 LOCAL_ASSERT(pFileContent != NULL); |
|
2374 CleanupStack::PushL(pFileContent); |
|
2375 pValue = HttpPropertyValueFromXmlLC(*pFileContent, KSoapAction); |
|
2376 if ( pValue ) |
|
2377 { |
|
2378 LOCAL_ASSERT(*pValue == KMessageSoapActionReturnValue); |
|
2379 } |
|
2380 CleanupStack::PopAndDestroy(pValue); |
|
2381 CleanupStack::PopAndDestroy(pFileContent); |
|
2382 |
|
2383 CleanupStack::PopAndDestroy(pSOAPMessage); |
|
2384 |
|
2385 if ( pOriginalSoapAction ) |
|
2386 { |
|
2387 CleanupStack::PopAndDestroy(pOriginalSoapAction); |
|
2388 } |
|
2389 |
|
2390 delete iServiceConnection; |
|
2391 iServiceConnection = NULL; |
|
2392 return KErrNone; |
|
2393 } |
|
2394 |
|
2395 TInt CsenConnectionTester::UT_CSenServiceConnection_SendL_CustomHttpHeaderL( ) |
|
2396 { |
|
2397 // Set custom HTTP header |
|
2398 // 1. Declare CUSTOM_HTTP_HEADER_NAME and CUSTOM_HTTP_HEADER_VALUE (value should include Scandic characters, like Ä and Ö) |
|
2399 // 2. Get TP using SC:TransportPropertiesL() |
|
2400 // 3. SendL(MSG) // see that CUSTOM_HTTP_HEADER -field is not present |
|
2401 // 4. SendL(MSG, TP::CUSTOM_HTTP_HEADER) // see that http filter logs CUSTOM_HTTP_HEADER |
|
2402 // 5. Define TP::CUSTOM_HTTP_HEADER_VALUE2 (for already existing CUSTOM_HTTP_HEADER_NAME) |
|
2403 // 6. Call SC::SetTransportPropertiesL(TP::CUSTOM_HTTP_HEADER_VALUE2) // VALUE2 should containt basic XML entities -- escapes like &, <, >, ' etc.. |
|
2404 // 7. SendL(MSG) // see that TP::CUSTOM_HTTP_HEADER_VALUE2 is effective |
|
2405 |
|
2406 // 1. Declare CUSTOM_HTTP_HEADER_NAME and CUSTOM_HTTP_HEADER_VALUE (value should include Scandic characters, like Ä and Ö) |
|
2407 _LIT8(KCustomHttpHeader, "CustomHeader"); |
|
2408 _LIT8(KCustomHttpHeaderValue1, "CustomHeaderValue1ÅÄÖåäö"); // UTF8 String which contains: "CustomHeaderValue1ÅÄÖåäö" |
|
2409 _LIT8(KCustomHttpHeaderValue2, "CustomHeaderValue2<>&"); |
|
2410 HBufC8* pEncoded = SenXmlUtils::EncodeHttpCharactersLC(KCustomHttpHeaderValue2); |
|
2411 |
|
2412 CSenServicePattern* pPattern = |
|
2413 CSenServicePattern::NewLC(KAuthServEndpoint, KNullDesC8()); |
|
2414 pPattern->SetFrameworkIdL(*ipFrameworkID); |
|
2415 |
|
2416 iServiceConnection = CSenServiceConnection::NewL(*this, *pPattern); |
|
2417 |
|
2418 CleanupStack::PopAndDestroy(pPattern); |
|
2419 |
|
2420 StartActiveScheduler(1); |
|
2421 LOCAL_ASSERT(iConnectionState == KSenConnectionStatusReady); |
|
2422 // Connection is ready to be used. |
|
2423 |
|
2424 // 2. Get TP using SC:TransportPropertiesL() |
|
2425 HBufC8* pTransportPropertiesAsXml = NULL; |
|
2426 iServiceConnection->TransportPropertiesL(pTransportPropertiesAsXml); |
|
2427 if ( pTransportPropertiesAsXml ) |
|
2428 { |
|
2429 delete pTransportPropertiesAsXml; |
|
2430 } |
|
2431 |
|
2432 CSenSoapMessage* pSOAPMessage = CreateAuthRequestLC(); |
|
2433 |
|
2434 // 3. SendL(MSG) // see that CUSTOM_HTTP_HEADER -field is not present |
|
2435 CSenHttpTransportProperties* pHttpProperties = CSenHttpTransportProperties::NewLC(); |
|
2436 pHttpProperties->SetHttpHeaderL(KLoggerFileNameProperty, KFileName); |
|
2437 TUint32 iapId = SearchIAPIdByNameL(KIAPName); |
|
2438 pHttpProperties->SetIapIdL(iapId); |
|
2439 HBufC8* pSerializedProperties = pHttpProperties->AsUtf8L(); |
|
2440 CleanupStack::PushL(pSerializedProperties); |
|
2441 iServiceConnection->SendL(*pSOAPMessage, *pSerializedProperties); |
|
2442 StartActiveScheduler(1); |
|
2443 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
2444 |
|
2445 CleanupStack::PopAndDestroy(pSerializedProperties); |
|
2446 CleanupStack::PopAndDestroy(pHttpProperties); |
|
2447 |
|
2448 // Check from HTTP Transaction logger log that CUSTOM_HTTP_HEADER was not used. |
|
2449 HBufC8* pFileContent = ReadFileL(KFileToRead); |
|
2450 LOCAL_ASSERT(pFileContent != NULL); |
|
2451 CleanupStack::PushL(pFileContent); |
|
2452 HBufC8* pValue = HttpPropertyValueFromXmlLC(*pFileContent, KCustomHttpHeader); |
|
2453 if ( pValue ) |
|
2454 { |
|
2455 LOCAL_ASSERT(pValue == NULL); |
|
2456 } |
|
2457 CleanupStack::PopAndDestroy(pValue); |
|
2458 CleanupStack::PopAndDestroy(pFileContent); |
|
2459 |
|
2460 // 4. SendL(MSG, TP::CUSTOM_HTTP_HEADER) // see that http filter logs CUSTOM_HTTP_HEADER |
|
2461 pHttpProperties = CSenHttpTransportProperties::NewLC(); |
|
2462 pHttpProperties->SetHttpHeaderL(KLoggerFileNameProperty, KFileName); |
|
2463 pHttpProperties->SetIapIdL(iapId); |
|
2464 pHttpProperties->SetHttpHeaderL(KCustomHttpHeader, KCustomHttpHeaderValue1); |
|
2465 pSerializedProperties = pHttpProperties->AsUtf8L(); |
|
2466 CleanupStack::PushL(pSerializedProperties); |
|
2467 iServiceConnection->SendL(*pSOAPMessage, *pSerializedProperties); |
|
2468 StartActiveScheduler(1); |
|
2469 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
2470 |
|
2471 CleanupStack::PopAndDestroy(pSerializedProperties); |
|
2472 CleanupStack::PopAndDestroy(pHttpProperties); |
|
2473 |
|
2474 // Check from HTTP Transaction logger log that CUSTOM_HTTP_HEADER was used. |
|
2475 pFileContent = ReadFileL(KFileToRead); |
|
2476 LOCAL_ASSERT(pFileContent != NULL); |
|
2477 CleanupStack::PushL(pFileContent); |
|
2478 pValue = HttpPropertyValueFromXmlLC(*pFileContent, KCustomHttpHeader); |
|
2479 if ( pValue ) |
|
2480 { |
|
2481 LOCAL_ASSERT(*pValue == KCustomHttpHeaderValue1); |
|
2482 } |
|
2483 CleanupStack::PopAndDestroy(pValue); |
|
2484 CleanupStack::PopAndDestroy(pFileContent); |
|
2485 |
|
2486 // 5. Define TP::CUSTOM_HTTP_HEADER_VALUE2 (for already existing CUSTOM_HTTP_HEADER_NAME) |
|
2487 pHttpProperties = CSenHttpTransportProperties::NewLC(); |
|
2488 pHttpProperties->SetHttpHeaderL(KLoggerFileNameProperty, KFileName); |
|
2489 pHttpProperties->SetIapIdL(iapId); |
|
2490 pHttpProperties->SetHttpHeaderL(KCustomHttpHeader, *pEncoded); |
|
2491 pSerializedProperties = pHttpProperties->AsUtf8L(); |
|
2492 CleanupStack::PushL(pSerializedProperties); |
|
2493 // 6. Call SC::SetTransportPropertiesL(TP::CUSTOM_HTTP_HEADER_VALUE2) // VALUE2 should containt basic XML entities -- escapes like &, <, >, ' etc.. |
|
2494 iServiceConnection->SetTransportPropertiesL(*pSerializedProperties); |
|
2495 CleanupStack::PopAndDestroy(pSerializedProperties); |
|
2496 CleanupStack::PopAndDestroy(pHttpProperties); |
|
2497 |
|
2498 // 7. SendL(MSG) // see that TP::CUSTOM_HTTP_HEADER_VALUE2 is effective |
|
2499 iServiceConnection->SendL(*pSOAPMessage); |
|
2500 StartActiveScheduler(1); |
|
2501 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
2502 |
|
2503 // Check from HTTP Transaction logger log that CUSTOM_HTTP_HEADER was used. |
|
2504 pFileContent = ReadFileL(KFileToRead); |
|
2505 LOCAL_ASSERT(pFileContent != NULL); |
|
2506 CleanupStack::PushL(pFileContent); |
|
2507 pValue = HttpPropertyValueFromXmlLC(*pFileContent, KCustomHttpHeader); |
|
2508 RDebug::RawPrint( *pValue ); |
|
2509 if ( pValue ) |
|
2510 { |
|
2511 RDebug::Print(_L("ENCODED:") ); |
|
2512 RDebug::RawPrint( *pEncoded ); |
|
2513 RDebug::Print(_L("OUTPUT:") ); |
|
2514 RDebug::RawPrint( *pValue ); |
|
2515 LOCAL_ASSERT(*pValue == *pEncoded); |
|
2516 } |
|
2517 CleanupStack::PopAndDestroy(pValue); |
|
2518 CleanupStack::PopAndDestroy(pFileContent); |
|
2519 |
|
2520 CleanupStack::PopAndDestroy(pSOAPMessage); |
|
2521 CleanupStack::PopAndDestroy(pEncoded); |
|
2522 |
|
2523 delete iServiceConnection; |
|
2524 iServiceConnection = NULL; |
|
2525 return KErrNone; |
|
2526 } |
|
2527 |
|
2528 TInt CsenConnectionTester::UT_CSenServiceConnection_TP_Boundaries1( ) |
|
2529 { |
|
2530 TInt result; |
|
2531 _LIT8(KCustomHttpHeader,"CustomHeader"); |
|
2532 //_LIT8(KCustomHttpHeaderValue, ); // NULL cannot be used as descriptor literal value in Symbian |
|
2533 //result = UT_CSenServiceConnection_TP_Custom_Header(KCustomHttpHeader,KCustomHttpHeaderValue); |
|
2534 result = UT_CSenServiceConnection_TP_Custom_Header(KCustomHttpHeader, KNullDesC8); |
|
2535 TL(result == KErrNone); |
|
2536 return KErrNone; |
|
2537 } |
|
2538 |
|
2539 |
|
2540 TInt CsenConnectionTester::UT_CSenServiceConnection_TP_Boundaries2( ) |
|
2541 { |
|
2542 TInt result; |
|
2543 // _LIT8(KCustomHttpHeader,); // NULL cannot be used as descriptor literal value in Symbian => it is more important to test KNullDesC8 (zero-length inputs etc) |
|
2544 _LIT8(KCustomHttpHeader, "X"); // property name's length = 1 |
|
2545 _LIT8(KCustomHttpHeaderValue, "CustomHeaderValue"); |
|
2546 |
|
2547 // Note: XML specs do not allow <Element> (tag name) to have zero-length. |
|
2548 |
|
2549 // It is not a bad idea to create such a test case, where GOAL is actually test the http property class |
|
2550 // itself (public DLL which is run by client app process); Utils DLL should maybe leave after it has been made to |
|
2551 // regocnize illegal inputs. All the might check special chars, BUT --NOTE-- it would make the setters quite much |
|
2552 // heavier (in terms of performance) if the key names (xml tag names) are first validated. |
|
2553 //result = UT_CSenServiceConnection_TP_Custom_Header(KNullDesC8, KCustomHttpHeaderValue); |
|
2554 result = UT_CSenServiceConnection_TP_Custom_Header(KCustomHttpHeader, KCustomHttpHeaderValue); |
|
2555 TL(result == KErrNone); |
|
2556 return KErrNone; |
|
2557 } |
|
2558 |
|
2559 TInt CsenConnectionTester::UT_CSenServiceConnection_TP_Boundaries3( ) |
|
2560 { |
|
2561 TInt result; |
|
2562 _LIT8(KCustomHttpHeader, "CustomHeader"); |
|
2563 result = UT_CSenServiceConnection_TP_Custom_Header(KCustomHttpHeader, KNullDesC8); |
|
2564 //NOTE: --> we could create test case for length==1 case: _LIT8(KCustomHttpHeaderValue, "Y"); // property value's length = 1 |
|
2565 // _LIT8(KCustomHttpHeaderValue, ""); // == KNullDesC8 |
|
2566 //result = UT_CSenServiceConnection_TP_Custom_Header(KCustomHttpHeader, KCustomHttpHeaderValue); |
|
2567 TL(result == KErrNone); |
|
2568 return KErrNone; |
|
2569 } |
|
2570 |
|
2571 TInt CsenConnectionTester::UT_CSenServiceConnection_TP_Boundaries4( ) |
|
2572 { |
|
2573 TInt result; |
|
2574 //_LIT8(KCustomHttpHeader,""); // == KNullDesC8 |
|
2575 _LIT8(KCustomHttpHeader, "X"); // property name's length = 1 |
|
2576 _LIT8(KCustomHttpHeaderValue, "CustomHeaderValue"); |
|
2577 //result = UT_CSenServiceConnection_TP_Custom_Header(KNullDesC8, KCustomHttpHeaderValue); |
|
2578 result = UT_CSenServiceConnection_TP_Custom_Header(KCustomHttpHeader, KCustomHttpHeaderValue); |
|
2579 |
|
2580 TL(result == KErrNone); |
|
2581 return KErrNone; |
|
2582 } |
|
2583 |
|
2584 TInt CsenConnectionTester::UT_CSenServiceConnection_TP_Boundaries5( ) |
|
2585 { |
|
2586 TInt result; |
|
2587 _LIT8(KCustomHttpHeader,"CustomHeader"); |
|
2588 _LIT8(KCustomHttpHeaderValue, "256HeaderValuexxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); |
|
2589 result = UT_CSenServiceConnection_TP_Custom_Header(KCustomHttpHeader,KCustomHttpHeaderValue); |
|
2590 TL (result == KErrNone); |
|
2591 return KErrNone; |
|
2592 } |
|
2593 |
|
2594 |
|
2595 TInt CsenConnectionTester::UT_CSenServiceConnection_TP_Boundaries6( ) |
|
2596 { |
|
2597 TInt result; |
|
2598 // Note: property name used to start with number here => changed, since it is against XML specs (property names are XML tags, parser does not accept tags which start by a number) |
|
2599 |
|
2600 // It is not a bad idea to create such a test case, where GOAL is actually test the http property class |
|
2601 // itself (public DLL which is run by client app process); Utils DLL should maybe leave after it has been made to |
|
2602 // regocnize illegal inputs. All the might check special chars, BUT --NOTE-- it would make the setters quite much |
|
2603 // heavier (in terms of performance) if the key names (xml tag names) are first validated. |
|
2604 _LIT8(KCustomHttpHeader,"Header256xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); |
|
2605 _LIT8(KCustomHttpHeaderValue, "CustomHeaderValue"); |
|
2606 result = UT_CSenServiceConnection_TP_Custom_Header(KCustomHttpHeader,KCustomHttpHeaderValue); |
|
2607 TL (result == KErrNone); |
|
2608 return KErrNone; |
|
2609 } |
|
2610 |
|
2611 TInt CsenConnectionTester::UT_CSenServiceConnection_TP_Boundaries7( ) |
|
2612 { |
|
2613 TInt result; |
|
2614 _LIT8(KCustomHttpHeader,"Header256xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); |
|
2615 _LIT8(KCustomHttpHeaderValue, "256HeaderValuexxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); |
|
2616 result = UT_CSenServiceConnection_TP_Custom_Header(KCustomHttpHeader,KCustomHttpHeaderValue); |
|
2617 TL (result == KErrNone); |
|
2618 return KErrNone; |
|
2619 } |
|
2620 |
|
2621 TInt CsenConnectionTester::UT_CSenServiceConnection_TP_Boundaries8( ) |
|
2622 { |
|
2623 TInt result; |
|
2624 _LIT8(KCustomHttpHeader,"CustomHeader"); |
|
2625 _LIT8( KCRLFSP, "\r\n " ); |
|
2626 //_LIT8(KCustomHttpHeaderValue, "CustomHeaderValue55"); |
|
2627 result = UT_CSenServiceConnection_TP_Custom_Header(KCustomHttpHeader,KCRLFSP); |
|
2628 TL (result == KErrNone); |
|
2629 return KErrNone; |
|
2630 } |
|
2631 |
|
2632 TInt CsenConnectionTester::UT_CSenServiceConnection_TP_Boundaries9( ) |
|
2633 { |
|
2634 TInt result; |
|
2635 _LIT8(KCustomHttpHeader,"CustomHeader"); |
|
2636 _LIT8(KCustomHttpHeaderValue, "CustomHeaderValue1, CustomHeaderValue2"); |
|
2637 result = UT_CSenServiceConnection_TP_Custom_Header(KCustomHttpHeader,KCustomHttpHeaderValue); |
|
2638 TL (result == KErrNone); |
|
2639 return KErrNone; |
|
2640 } |
|
2641 |
|
2642 //Befor executing this TC remember to set big enought TimeOut value (10 min.) |
|
2643 |
|
2644 |
|
2645 TInt CsenConnectionTester::UT_CSenServiceConnection_TP_SecDialog() |
|
2646 { |
|
2647 TBool secDial; |
|
2648 |
|
2649 CSenServicePattern* pPattern = |
|
2650 CSenServicePattern::NewLC(KHttpsEndPoint, KNullDesC8()); |
|
2651 pPattern->SetFrameworkIdL(*ipFrameworkID); |
|
2652 |
|
2653 iServiceConnection = CSenServiceConnection::NewL(*this, *pPattern); |
|
2654 |
|
2655 CleanupStack::PopAndDestroy(pPattern); |
|
2656 |
|
2657 StartActiveScheduler(1); |
|
2658 LOCAL_ASSERT(iConnectionState == KSenConnectionStatusReady); |
|
2659 // Connection is ready to be used. |
|
2660 |
|
2661 CSenSoapMessage* pSOAPMessage = CreateAuthRequestLC(); |
|
2662 |
|
2663 |
|
2664 CSenHttpTransportProperties* pHttpProperties = CSenHttpTransportProperties::NewLC(); |
|
2665 |
|
2666 pHttpProperties->SetSecureDialogL(ETrue); |
|
2667 pHttpProperties->SecureDialogL(secDial); |
|
2668 TL (secDial != EFalse); |
|
2669 |
|
2670 TUint32 iapId = SearchIAPIdByNameL(KIAPName); |
|
2671 pHttpProperties->SetIapIdL(iapId); |
|
2672 HBufC8* pSerializedProperties = pHttpProperties->AsUtf8L(); |
|
2673 CleanupStack::PushL(pSerializedProperties); |
|
2674 iServiceConnection->SendL(*pSOAPMessage, *pSerializedProperties); |
|
2675 StartActiveScheduler(1); |
|
2676 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
2677 |
|
2678 CleanupStack::PopAndDestroy(pSerializedProperties); |
|
2679 CleanupStack::PopAndDestroy(pHttpProperties); |
|
2680 |
|
2681 pHttpProperties = CSenHttpTransportProperties::NewLC(); |
|
2682 pHttpProperties->SetSecureDialogL(EFalse); |
|
2683 pHttpProperties->SecureDialogL(secDial); |
|
2684 TL (secDial == EFalse); |
|
2685 pHttpProperties->SetIapIdL(iapId); |
|
2686 pSerializedProperties = pHttpProperties->AsUtf8L(); |
|
2687 CleanupStack::PushL(pSerializedProperties); |
|
2688 iServiceConnection->SendL(*pSOAPMessage, *pSerializedProperties); |
|
2689 StartActiveScheduler(1); |
|
2690 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
2691 |
|
2692 CleanupStack::PopAndDestroy(pSerializedProperties); |
|
2693 CleanupStack::PopAndDestroy(pHttpProperties); |
|
2694 |
|
2695 CleanupStack::PopAndDestroy(pSOAPMessage); |
|
2696 |
|
2697 delete iServiceConnection; |
|
2698 iServiceConnection = NULL; |
|
2699 return KErrNone; |
|
2700 } |
|
2701 |
|
2702 TInt CsenConnectionTester::UT_CSenServiceConnection_TP_Omitted_True() |
|
2703 { |
|
2704 TBool secDial; |
|
2705 CSenHttpTransportProperties* pHttpProperties = CSenHttpTransportProperties::NewLC(); |
|
2706 |
|
2707 pHttpProperties->SetSecureDialogL( ETrue ); |
|
2708 pHttpProperties->SecureDialogL(secDial); |
|
2709 TL (secDial != EFalse); |
|
2710 pHttpProperties->SetOmittedL(KSecureDialogLocalName,ETrue); |
|
2711 |
|
2712 TUint32 iapId = SearchIAPIdByNameL(KIAPName); |
|
2713 pHttpProperties->SetIapIdL(iapId); |
|
2714 HBufC8* pSerializedProperties = pHttpProperties->AsUtf8L(); |
|
2715 CleanupStack::PushL(pSerializedProperties); |
|
2716 |
|
2717 TInt cmpVal = pSerializedProperties->Find(_L8("<SecureDialog Omitted=\"true\">true</SecureDialog>")); |
|
2718 TL (cmpVal != KErrNotFound) |
|
2719 |
|
2720 CleanupStack::PopAndDestroy(pSerializedProperties); |
|
2721 CleanupStack::PopAndDestroy(pHttpProperties); |
|
2722 return KErrNone; |
|
2723 } |
|
2724 |
|
2725 TInt CsenConnectionTester::UT_CSenServiceConnection_TP_Omitted_False() |
|
2726 { |
|
2727 TBool secDial; |
|
2728 CSenHttpTransportProperties* pHttpProperties = CSenHttpTransportProperties::NewLC(); |
|
2729 |
|
2730 pHttpProperties->SetSecureDialogL( ETrue ); |
|
2731 pHttpProperties->SecureDialogL(secDial); |
|
2732 TL (secDial != EFalse); |
|
2733 pHttpProperties->SetOmittedL(KSecureDialogLocalName, EFalse); |
|
2734 |
|
2735 TUint32 iapId = SearchIAPIdByNameL(KIAPName); |
|
2736 pHttpProperties->SetIapIdL(iapId); |
|
2737 HBufC8* pSerializedProperties = pHttpProperties->AsUtf8L(); |
|
2738 CleanupStack::PushL(pSerializedProperties); |
|
2739 |
|
2740 TInt cmpVal = pSerializedProperties->Find(_L8("<SecureDialog Omitted=\"false\">true</SecureDialog>")); |
|
2741 TL (cmpVal != KErrNotFound) |
|
2742 |
|
2743 CleanupStack::PopAndDestroy(pSerializedProperties); |
|
2744 CleanupStack::PopAndDestroy(pHttpProperties); |
|
2745 return KErrNone; |
|
2746 } |
|
2747 |
|
2748 |
|
2749 TInt CsenConnectionTester::UT_CSenServiceConnection_TP_Removed() |
|
2750 { |
|
2751 TBool secDial; |
|
2752 CSenHttpTransportProperties* pHttpProperties = CSenHttpTransportProperties::NewLC(); |
|
2753 |
|
2754 pHttpProperties->SetSecureDialogL(ETrue); |
|
2755 pHttpProperties->SecureDialogL(secDial); |
|
2756 TL (secDial != EFalse); |
|
2757 pHttpProperties->RemovePropertyL(KSecureDialogLocalName); |
|
2758 |
|
2759 TUint32 iapId = SearchIAPIdByNameL(KIAPName); |
|
2760 pHttpProperties->SetIapIdL(iapId); |
|
2761 HBufC8* pSerializedProperties = pHttpProperties->AsUtf8L(); |
|
2762 CleanupStack::PushL(pSerializedProperties); |
|
2763 |
|
2764 TInt cmpVal = pSerializedProperties->Find(_L8("<SecureDialog>")); |
|
2765 TL(cmpVal == KErrNotFound) |
|
2766 |
|
2767 CleanupStack::PopAndDestroy(pSerializedProperties); |
|
2768 CleanupStack::PopAndDestroy(pHttpProperties); |
|
2769 return KErrNone; |
|
2770 } |
|
2771 |
|
2772 TInt CsenConnectionTester::UT_CSenServiceConnection_TP_Omit_Rem() |
|
2773 { |
|
2774 _LIT8(KUserAgentValue, "TestAgent"); |
|
2775 _LIT8(KUserAgentDefaultValue, "Serene"); |
|
2776 CSenServicePattern* pPattern = |
|
2777 CSenServicePattern::NewLC(KAuthServEndpoint, KNullDesC8()); |
|
2778 pPattern->SetFrameworkIdL(*ipFrameworkID); |
|
2779 |
|
2780 iServiceConnection = CSenServiceConnection::NewL(*this, *pPattern); |
|
2781 |
|
2782 CleanupStack::PopAndDestroy(pPattern); |
|
2783 |
|
2784 StartActiveScheduler(1); |
|
2785 LOCAL_ASSERT(iConnectionState == KSenConnectionStatusReady); |
|
2786 // Connection is ready to be used. |
|
2787 |
|
2788 // 1. Get TP using SC:TransportPropertiesL() |
|
2789 HBufC8* pTransportPropertiesAsXml = NULL; |
|
2790 iServiceConnection->TransportPropertiesL(pTransportPropertiesAsXml); |
|
2791 if ( pTransportPropertiesAsXml ) |
|
2792 { |
|
2793 delete pTransportPropertiesAsXml; |
|
2794 } |
|
2795 |
|
2796 CSenSoapMessage* pSOAPMessage = CreateAuthRequestLC(); |
|
2797 |
|
2798 // 2. SendL(MSG) // with set user-agent |
|
2799 CSenHttpTransportProperties* pHttpProperties = CSenHttpTransportProperties::NewLC(); |
|
2800 pHttpProperties->SetHttpHeaderL(KLoggerFileNameProperty, KFileName); |
|
2801 pHttpProperties->SetUserAgentL(KUserAgentValue); |
|
2802 TUint32 iapId = SearchIAPIdByNameL(KIAPName); |
|
2803 pHttpProperties->SetIapIdL(iapId); |
|
2804 HBufC8* pSerializedProperties = pHttpProperties->AsUtf8L(); |
|
2805 CleanupStack::PushL(pSerializedProperties); |
|
2806 iServiceConnection->SendL(*pSOAPMessage, *pSerializedProperties); |
|
2807 StartActiveScheduler(1); |
|
2808 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
2809 |
|
2810 CleanupStack::PopAndDestroy(pSerializedProperties); |
|
2811 CleanupStack::PopAndDestroy(pHttpProperties); |
|
2812 |
|
2813 //3. Check from HTTP Transaction logger log that user-agent was used. |
|
2814 HBufC8* pFileContent = ReadFileL(KFileToRead); |
|
2815 LOCAL_ASSERT(pFileContent != NULL); |
|
2816 CleanupStack::PushL(pFileContent); |
|
2817 HBufC8* pValue = HttpPropertyValueFromXmlLC(*pFileContent, KUserAgentLocalName); |
|
2818 if( pValue ) |
|
2819 { |
|
2820 LOCAL_ASSERT(*pValue == KUserAgentValue); |
|
2821 } |
|
2822 CleanupStack::PopAndDestroy(pValue); |
|
2823 CleanupStack::PopAndDestroy(pFileContent); |
|
2824 |
|
2825 |
|
2826 // 4. SendL(MSG) // with removed user-agent |
|
2827 pHttpProperties = CSenHttpTransportProperties::NewLC(); |
|
2828 pHttpProperties->SetHttpHeaderL(KLoggerFileNameProperty, KFileName); |
|
2829 pHttpProperties->SetUserAgentL(KUserAgentValue); |
|
2830 pHttpProperties->RemovePropertyL(KUserAgentLocalName); |
|
2831 pHttpProperties->SetIapIdL(iapId); |
|
2832 pSerializedProperties = pHttpProperties->AsUtf8L(); |
|
2833 CleanupStack::PushL(pSerializedProperties); |
|
2834 iServiceConnection->SendL(*pSOAPMessage, *pSerializedProperties); |
|
2835 StartActiveScheduler(1); |
|
2836 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
2837 |
|
2838 CleanupStack::PopAndDestroy(pSerializedProperties); |
|
2839 CleanupStack::PopAndDestroy(pHttpProperties); |
|
2840 |
|
2841 //5. Check from HTTP Transaction logger log that user-agent was used. |
|
2842 pFileContent = ReadFileL(KFileToRead); |
|
2843 LOCAL_ASSERT(pFileContent != NULL); |
|
2844 CleanupStack::PushL(pFileContent); |
|
2845 pValue = HttpPropertyValueFromXmlLC(*pFileContent, KUserAgentLocalName); |
|
2846 if ( pValue ) |
|
2847 { |
|
2848 LOCAL_ASSERT(*pValue != KUserAgentValue); |
|
2849 } |
|
2850 CleanupStack::PopAndDestroy(pValue); |
|
2851 CleanupStack::PopAndDestroy(pFileContent); |
|
2852 |
|
2853 |
|
2854 // 6. SendL(MSG) // with omitted set to EFalse for user-agent |
|
2855 pHttpProperties = CSenHttpTransportProperties::NewLC(); |
|
2856 pHttpProperties->SetHttpHeaderL(KLoggerFileNameProperty, KFileName); |
|
2857 pHttpProperties->SetUserAgentL(KUserAgentValue); |
|
2858 pHttpProperties->SetOmittedL(KUserAgentLocalName, EFalse); |
|
2859 pHttpProperties->SetIapIdL(iapId); |
|
2860 pSerializedProperties = pHttpProperties->AsUtf8L(); |
|
2861 CleanupStack::PushL(pSerializedProperties); |
|
2862 iServiceConnection->SendL(*pSOAPMessage, *pSerializedProperties); |
|
2863 StartActiveScheduler(1); |
|
2864 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
2865 |
|
2866 CleanupStack::PopAndDestroy(pSerializedProperties); |
|
2867 CleanupStack::PopAndDestroy(pHttpProperties); |
|
2868 |
|
2869 //7. Check from HTTP Transaction logger log that given user-agent |
|
2870 // was used (when EFalse was given as Omitted value). |
|
2871 pFileContent = ReadFileL(KFileToRead); |
|
2872 LOCAL_ASSERT(pFileContent != NULL); |
|
2873 CleanupStack::PushL(pFileContent); |
|
2874 pValue = HttpPropertyValueFromXmlLC(*pFileContent, KUserAgentLocalName); |
|
2875 if ( pValue ) |
|
2876 { |
|
2877 LOCAL_ASSERT(*pValue == KUserAgentValue); |
|
2878 } |
|
2879 CleanupStack::PopAndDestroy(pValue); |
|
2880 CleanupStack::PopAndDestroy(pFileContent); |
|
2881 |
|
2882 // 8. SendL(MSG) // with omitted set to ETrue for user-agent |
|
2883 pHttpProperties = CSenHttpTransportProperties::NewLC(); |
|
2884 pHttpProperties->SetHttpHeaderL(KLoggerFileNameProperty, KFileName); |
|
2885 pHttpProperties->SetUserAgentL(KUserAgentValue); |
|
2886 pHttpProperties->SetOmittedL(KUserAgentLocalName, ETrue); |
|
2887 pHttpProperties->SetIapIdL(iapId); |
|
2888 pSerializedProperties = pHttpProperties->AsUtf8L(); |
|
2889 CleanupStack::PushL(pSerializedProperties); |
|
2890 iServiceConnection->SendL(*pSOAPMessage, *pSerializedProperties); |
|
2891 StartActiveScheduler(1); |
|
2892 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
2893 |
|
2894 CleanupStack::PopAndDestroy(pSerializedProperties); |
|
2895 CleanupStack::PopAndDestroy(pHttpProperties); |
|
2896 |
|
2897 //9. Check from HTTP Transaction logger log that |
|
2898 // default user-agent for HTTP Transport plugin was |
|
2899 // used instead of user-agent which was set together |
|
2900 // with omitted value ETrue. |
|
2901 pFileContent = ReadFileL(KFileToRead); |
|
2902 LOCAL_ASSERT(pFileContent != NULL); |
|
2903 CleanupStack::PushL(pFileContent); |
|
2904 pValue = HttpPropertyValueFromXmlLC(*pFileContent, KUserAgentLocalName); |
|
2905 if ( pValue ) |
|
2906 { |
|
2907 LOCAL_ASSERT(*pValue == KUserAgentDefaultValue); |
|
2908 } |
|
2909 CleanupStack::PopAndDestroy(pValue); |
|
2910 CleanupStack::PopAndDestroy(pFileContent); |
|
2911 |
|
2912 |
|
2913 CleanupStack::PopAndDestroy(pSOAPMessage); |
|
2914 |
|
2915 delete iServiceConnection; |
|
2916 iServiceConnection = NULL; |
|
2917 return KErrNone; |
|
2918 } |
|
2919 |
|
2920 |
|
2921 TInt CsenConnectionTester::UT_CSenServiceConnection_SubmitL_LibXml2_L( ) |
|
2922 { |
|
2923 // Create ServiceConnection |
|
2924 CSenServicePattern* pPattern = |
|
2925 CSenServicePattern::NewLC(KAuthServEndpoint, KNullDesC8()); |
|
2926 pPattern->SetFrameworkIdL(*ipFrameworkID); |
|
2927 TUint32 iapId = SearchIAPIdByNameL(KIAPName); |
|
2928 pPattern->SetConsumerIapIdL(iapId); |
|
2929 iServiceConnection = CSenServiceConnection::NewL(*this, *pPattern); |
|
2930 CleanupStack::PopAndDestroy(pPattern); |
|
2931 StartActiveScheduler(1); |
|
2932 LOCAL_ASSERT(iConnectionState == KSenConnectionStatusReady); |
|
2933 // Connection is ready to be used. |
|
2934 |
|
2935 // 1. Chunk declaration |
|
2936 _LIT8( cid, "123456789@123456789" ); |
|
2937 _LIT( chunkName, "test chunk" ); |
|
2938 _LIT8( chunkContent, "Testing chunk1" ); |
|
2939 TInt chunkSize = 1000; |
|
2940 TInt chunkMaxSize = 5000; |
|
2941 TInt chunkOffset = 100; |
|
2942 TInt chunkDataSize = 14; |
|
2943 RChunk binaryDataChunk; |
|
2944 binaryDataChunk.CreateGlobal(chunkName(), chunkSize, chunkMaxSize); |
|
2945 CleanupClosePushL(binaryDataChunk); |
|
2946 TUint8* heapPtr = binaryDataChunk.Base(); |
|
2947 heapPtr = heapPtr + chunkOffset; |
|
2948 // Place a new descriptor in the chunk to initialize it |
|
2949 new (heapPtr-sizeof(TPtr8)) TPtr8(heapPtr, 0, chunkDataSize); |
|
2950 // Set the descriptor |
|
2951 TPtr8* pDes = reinterpret_cast<TPtr8*>(heapPtr-sizeof(TPtr8)); |
|
2952 pDes->Zero(); |
|
2953 pDes->Append(chunkContent); |
|
2954 |
|
2955 // 2. Chunk declaration |
|
2956 _LIT8( cid2, "xyz" ); |
|
2957 _LIT( chunkName2, "test chunk2" ); |
|
2958 _LIT8( chunkContent2, "Testing chunk2" ); |
|
2959 TInt chunkSize2 = 3000; |
|
2960 TInt chunkMaxSize2 = 10000; |
|
2961 TInt chunkOffset2 = 112; |
|
2962 TInt chunkDataSize2 = 14; |
|
2963 |
|
2964 RChunk binaryDataChunk2; |
|
2965 binaryDataChunk2.CreateGlobal(chunkName2(), chunkSize2, chunkMaxSize2); |
|
2966 CleanupClosePushL(binaryDataChunk2); |
|
2967 TUint8* heapPtr2 = binaryDataChunk2.Base(); |
|
2968 heapPtr2 = heapPtr2 + chunkOffset2; |
|
2969 // Place a new descriptor in the chunk to initialize it |
|
2970 new (heapPtr2-sizeof(TPtr8)) TPtr8(heapPtr2, 0, chunkDataSize2); |
|
2971 // Set the descriptor |
|
2972 TPtr8* pDes2 = reinterpret_cast<TPtr8*>(heapPtr2-sizeof(TPtr8)); |
|
2973 pDes2->Zero(); |
|
2974 pDes2->Append(chunkContent2); |
|
2975 |
|
2976 // 1. File declaration |
|
2977 _LIT8( cid3, "999999999@123456789" ); |
|
2978 _LIT( KTestFileName, "e:\\testing\\data\\fileContainer.txt" ); |
|
2979 _LIT8( KFileContent, "Test FileContainer1" ); |
|
2980 RFs rfs; |
|
2981 User::LeaveIfError(rfs.Connect()); |
|
2982 CleanupClosePushL(rfs); |
|
2983 TInt retVal = rfs.ShareProtected(); |
|
2984 RFile file; |
|
2985 CleanupClosePushL(file); |
|
2986 User::LeaveIfError(file.Replace(rfs, KTestFileName, EFileWrite)); |
|
2987 User::LeaveIfError(file.Write(KFileContent)); |
|
2988 file.Flush(); |
|
2989 file.Close(); |
|
2990 User::LeaveIfError(file.Open(rfs, KTestFileName, EFileRead)); |
|
2991 |
|
2992 // 2. File declaration |
|
2993 _LIT8( cid4, "1z2" ); |
|
2994 _LIT( KTestFileName2, "e:\\testing\\data\\fileContainer2.txt" ); |
|
2995 _LIT8( KFileContent2, "Test FileContainer2" ); |
|
2996 RFs rfs2; |
|
2997 User::LeaveIfError(rfs2.Connect()); |
|
2998 CleanupClosePushL(rfs2); |
|
2999 retVal = rfs2.ShareProtected(); |
|
3000 RFile file2; |
|
3001 CleanupClosePushL(file2); |
|
3002 User::LeaveIfError(file2.Replace(rfs2, KTestFileName2, EFileWrite)); |
|
3003 User::LeaveIfError(file2.Write(KFileContent2)); |
|
3004 file2.Flush(); |
|
3005 file2.Close(); |
|
3006 User::LeaveIfError(file2.Open(rfs2, KTestFileName2, EFileRead)); |
|
3007 |
|
3008 // Create SOAPMessage |
|
3009 CSenSoapMessage2* pSOAPMessage = CSenSoapMessage2::NewL(); |
|
3010 CleanupStack::PushL(pSOAPMessage); |
|
3011 |
|
3012 RSenDocument document = pSOAPMessage->AsDocumentL(); |
|
3013 |
|
3014 // Create BinaryContainers |
|
3015 TXmlEngChunkContainer chunkContainer = document.CreateChunkContainerL( |
|
3016 cid, |
|
3017 binaryDataChunk, |
|
3018 chunkOffset, |
|
3019 chunkDataSize); |
|
3020 TXmlEngChunkContainer chunkContainer2 = document.CreateChunkContainerL( |
|
3021 cid2, |
|
3022 binaryDataChunk2, |
|
3023 chunkOffset2, |
|
3024 chunkDataSize2); |
|
3025 TXmlEngChunkContainer chunkContainer3 = document.CreateChunkContainerL( |
|
3026 cid2, |
|
3027 binaryDataChunk2, |
|
3028 chunkOffset2, |
|
3029 chunkDataSize2); |
|
3030 TXmlEngFileContainer fileContainer = document.CreateFileContainerL(cid3, file); |
|
3031 TXmlEngFileContainer fileContainer2 = document.CreateFileContainerL(cid4, file2); |
|
3032 |
|
3033 // Get Envelope element |
|
3034 TXmlEngElement envelopeElement = pSOAPMessage->AsElementL(); |
|
3035 |
|
3036 // Create mime namespace declaration into Envelope element |
|
3037 // xmlns:xmlmime="http://www.w3.org/2004/11/xmlmime" |
|
3038 |
|
3039 |
|
3040 TXmlEngNamespace mimeNamespace = envelopeElement. AddNamespaceDeclarationL(_L8("http://www.w3.org/2004/11/xmlmime"), |
|
3041 _L8("xmlmime")); |
|
3042 |
|
3043 // TXmlEngNamespace mimeNamespace = envelopeElement. AddNamespaceDeclarationL(_L8("http://www.w3.org/2004/11/xmlmime"), |
|
3044 // _L8("mime")); // IE does not render XML where attribute name startes with "xml" (xmlmime) |
|
3045 |
|
3046 |
|
3047 // Create service specific namespace declaration into Body element |
|
3048 // xmlns:m="http://example.org/stuff" |
|
3049 TXmlEngNamespace serviceNamespace = pSOAPMessage->BodyL().AddNamespaceDeclarationL( |
|
3050 _L8("http://example.org/stuff"), |
|
3051 _L8("m")); |
|
3052 // Add data element into Body |
|
3053 // <S:Body xmlns:m="http://example.org/stuff"> |
|
3054 // <m:data> |
|
3055 // ... |
|
3056 // </m:data> |
|
3057 // </S:Body> |
|
3058 TXmlEngElement dataElement = pSOAPMessage->BodyL().AddNewElementL(_L8("data"), |
|
3059 serviceNamespace); |
|
3060 |
|
3061 // Add 1. attachment element into data element |
|
3062 // <m:data> |
|
3063 // <m:textAttachment1 xmlmime:contentType="text"> |
|
3064 // <xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:123456789@123456789"/> |
|
3065 // </m:textAttachment1> |
|
3066 // ... |
|
3067 // </m:data> |
|
3068 TXmlEngElement attachmentElement1 = dataElement.AddNewElementL(_L8("textAttachment1"), |
|
3069 serviceNamespace); |
|
3070 attachmentElement1.AddNewAttributeL(_L8("contentType"), _L8("text"), mimeNamespace); |
|
3071 attachmentElement1.AppendChildL(chunkContainer); |
|
3072 |
|
3073 // Add 2. attachment element into data element |
|
3074 TXmlEngElement attachmentElement2 = dataElement.AddNewElementL(_L8("textAttachment2"), |
|
3075 serviceNamespace); |
|
3076 attachmentElement2.AddNewAttributeL(_L8("contentType"), _L8("text"), mimeNamespace); |
|
3077 attachmentElement2.AppendChildL(fileContainer); |
|
3078 |
|
3079 // Add 3. attachment element into data element |
|
3080 TXmlEngElement attachmentElement3 = dataElement.AddNewElementL(_L8("textAttachment3"), |
|
3081 serviceNamespace); |
|
3082 attachmentElement3.AddNewAttributeL(_L8("contentType"), _L8("text"), mimeNamespace); |
|
3083 attachmentElement3.AppendChildL(chunkContainer2); |
|
3084 |
|
3085 // Add 4. attachment element into data element |
|
3086 TXmlEngElement attachmentElement4 = dataElement.AddNewElementL(_L8("textAttachment4"), |
|
3087 serviceNamespace); |
|
3088 attachmentElement4.AddNewAttributeL(_L8("contentType"), _L8("text"), mimeNamespace); |
|
3089 attachmentElement4.AppendChildL(fileContainer2); |
|
3090 |
|
3091 // Add 5. attachment element inside data element |
|
3092 TXmlEngElement attachmentElement5 = dataElement.AddNewElementL(_L8("textAttachment5"), |
|
3093 serviceNamespace); |
|
3094 attachmentElement5.AddNewAttributeL(_L8("contentType"), _L8("text"), mimeNamespace); |
|
3095 attachmentElement5.AppendChildL(chunkContainer3); |
|
3096 |
|
3097 // Http Post |
|
3098 CSenHttpTransportProperties* pHttpProperties = CSenHttpTransportProperties::NewLC(); |
|
3099 pHttpProperties->SetHttpHeaderL(KLoggerFileNameProperty, KFileName); |
|
3100 HBufC8* pPropsAsXml = pHttpProperties->AsUtf8LC(); |
|
3101 iServiceConnection->SetTransportPropertiesL(*pPropsAsXml); |
|
3102 CleanupStack::PopAndDestroy(pPropsAsXml); |
|
3103 CleanupStack::PopAndDestroy(pHttpProperties); |
|
3104 |
|
3105 CSenSoapEnvelope2* pRetMessage = NULL; |
|
3106 iServiceConnection->SubmitL(*pSOAPMessage, pRetMessage); |
|
3107 delete pRetMessage; |
|
3108 |
|
3109 // Check from HTTP Transaction logger log that POST method was used. |
|
3110 HBufC8* pFileContent = ReadFileL(KFileToRead); |
|
3111 LOCAL_ASSERT(pFileContent != NULL); |
|
3112 CleanupStack::PushL(pFileContent); |
|
3113 HBufC8* pValue = HttpMethodValueFromXmlLC(*pFileContent); |
|
3114 if ( pValue ) |
|
3115 { |
|
3116 LOCAL_ASSERT(*pValue == KHTTPMethodPost); |
|
3117 } |
|
3118 CleanupStack::PopAndDestroy(pValue); |
|
3119 CleanupStack::PopAndDestroy(pFileContent); |
|
3120 |
|
3121 CleanupStack::PopAndDestroy(pSOAPMessage); |
|
3122 |
|
3123 CleanupStack::PopAndDestroy(&file2); |
|
3124 CleanupStack::PopAndDestroy(&rfs2); |
|
3125 CleanupStack::PopAndDestroy(&file); |
|
3126 CleanupStack::PopAndDestroy(&rfs); |
|
3127 CleanupStack::PopAndDestroy(&binaryDataChunk2); |
|
3128 CleanupStack::PopAndDestroy(&binaryDataChunk); |
|
3129 |
|
3130 delete iServiceConnection; |
|
3131 iServiceConnection = NULL; |
|
3132 return KErrNone; |
|
3133 } |
|
3134 |
|
3135 |
|
3136 TInt CsenConnectionTester::UT_CSenServiceConnection_SubmitL_LibXml2_with_Properties_L( ) |
|
3137 { |
|
3138 // Create ServiceConnection |
|
3139 CSenServicePattern* pPattern = |
|
3140 CSenServicePattern::NewLC(KAuthServEndpoint, KNullDesC8()); |
|
3141 pPattern->SetFrameworkIdL(*ipFrameworkID); |
|
3142 TUint32 iapId = SearchIAPIdByNameL(KIAPName); |
|
3143 pPattern->SetConsumerIapIdL(iapId); |
|
3144 iServiceConnection = CSenServiceConnection::NewL(*this, *pPattern); |
|
3145 CleanupStack::PopAndDestroy(pPattern); |
|
3146 StartActiveScheduler(1); |
|
3147 LOCAL_ASSERT(iConnectionState == KSenConnectionStatusReady); |
|
3148 // Connection is ready to be used. |
|
3149 |
|
3150 // 1. Chunk declaration |
|
3151 _LIT8( cid, "123456789@123456789" ); |
|
3152 _LIT( chunkName, "test chunk" ); |
|
3153 _LIT8( chunkContent, "Testing chunk1" ); |
|
3154 TInt chunkSize = 1000; |
|
3155 TInt chunkMaxSize = 5000; |
|
3156 TInt chunkOffset = 100; |
|
3157 TInt chunkDataSize = 14; |
|
3158 RChunk binaryDataChunk; |
|
3159 binaryDataChunk.CreateGlobal(chunkName(), chunkSize, chunkMaxSize); |
|
3160 CleanupClosePushL(binaryDataChunk); |
|
3161 TUint8* heapPtr = binaryDataChunk.Base(); |
|
3162 heapPtr = heapPtr + chunkOffset; |
|
3163 // Place a new descriptor in the chunk to initialize it |
|
3164 new (heapPtr-sizeof(TPtr8)) TPtr8(heapPtr, 0, chunkDataSize); |
|
3165 // Set the descriptor |
|
3166 TPtr8* pDes = reinterpret_cast<TPtr8*>(heapPtr-sizeof(TPtr8)); |
|
3167 pDes->Zero(); |
|
3168 pDes->Append(chunkContent); |
|
3169 |
|
3170 // 2. Chunk declaration |
|
3171 _LIT8( cid2, "xyz" ); |
|
3172 _LIT( chunkName2, "test chunk2" ); |
|
3173 _LIT8( chunkContent2, "Testing chunk2" ); |
|
3174 TInt chunkSize2 = 3000; |
|
3175 TInt chunkMaxSize2 = 10000; |
|
3176 TInt chunkOffset2 = 112; |
|
3177 TInt chunkDataSize2 = 14; |
|
3178 |
|
3179 RChunk binaryDataChunk2; |
|
3180 binaryDataChunk2.CreateGlobal(chunkName2(), chunkSize2, chunkMaxSize2); |
|
3181 CleanupClosePushL(binaryDataChunk2); |
|
3182 TUint8* heapPtr2 = binaryDataChunk2.Base(); |
|
3183 heapPtr2 = heapPtr2 + chunkOffset2; |
|
3184 // Place a new descriptor in the chunk to initialize it |
|
3185 new (heapPtr2-sizeof(TPtr8)) TPtr8(heapPtr2, 0, chunkDataSize2); |
|
3186 // Set the descriptor |
|
3187 TPtr8* pDes2 = reinterpret_cast<TPtr8*>(heapPtr2-sizeof(TPtr8)); |
|
3188 pDes2->Zero(); |
|
3189 pDes2->Append(chunkContent2); |
|
3190 |
|
3191 // 1. File declaration |
|
3192 _LIT8( cid3, "999999999@123456789" ); |
|
3193 _LIT( KTestFileName, "e:\\testing\\data\\fileContainer.txt" ); |
|
3194 _LIT8( KFileContent, "Test FileContainer1" ); |
|
3195 RFs rfs; |
|
3196 User::LeaveIfError(rfs.Connect()); |
|
3197 CleanupClosePushL(rfs); |
|
3198 TInt retVal = rfs.ShareProtected(); |
|
3199 RFile file; |
|
3200 CleanupClosePushL(file); |
|
3201 User::LeaveIfError(file.Replace(rfs, KTestFileName, EFileWrite)); |
|
3202 User::LeaveIfError(file.Write(KFileContent)); |
|
3203 file.Flush(); |
|
3204 file.Close(); |
|
3205 User::LeaveIfError(file.Open(rfs, KTestFileName, EFileRead)); |
|
3206 |
|
3207 // 2. File declaration |
|
3208 _LIT8( cid4, "1z2" ); |
|
3209 _LIT( KTestFileName2, "e:\\testing\\data\\fileContainer2.txt" ); |
|
3210 _LIT8( KFileContent2, "Test FileContainer2" ); |
|
3211 RFs rfs2; |
|
3212 User::LeaveIfError(rfs2.Connect()); |
|
3213 CleanupClosePushL(rfs2); |
|
3214 retVal = rfs2.ShareProtected(); |
|
3215 RFile file2; |
|
3216 CleanupClosePushL(file2); |
|
3217 User::LeaveIfError(file2.Replace(rfs2, KTestFileName2, EFileWrite)); |
|
3218 User::LeaveIfError(file2.Write(KFileContent2)); |
|
3219 file2.Flush(); |
|
3220 file2.Close(); |
|
3221 User::LeaveIfError(file2.Open(rfs2, KTestFileName2, EFileRead)); |
|
3222 |
|
3223 // Create SOAPMessage |
|
3224 CSenSoapMessage2* pSOAPMessage = CSenSoapMessage2::NewL(); |
|
3225 CleanupStack::PushL(pSOAPMessage); |
|
3226 |
|
3227 RSenDocument document = pSOAPMessage->AsDocumentL(); |
|
3228 |
|
3229 // Create BinaryContainers |
|
3230 TXmlEngChunkContainer chunkContainer = document.CreateChunkContainerL( |
|
3231 cid, |
|
3232 binaryDataChunk, |
|
3233 chunkOffset, |
|
3234 chunkDataSize); |
|
3235 TXmlEngChunkContainer chunkContainer2 = document.CreateChunkContainerL( |
|
3236 cid2, |
|
3237 binaryDataChunk2, |
|
3238 chunkOffset2, |
|
3239 chunkDataSize2); |
|
3240 TXmlEngChunkContainer chunkContainer3 = document.CreateChunkContainerL( |
|
3241 cid2, |
|
3242 binaryDataChunk2, |
|
3243 chunkOffset2, |
|
3244 chunkDataSize2); |
|
3245 TXmlEngFileContainer fileContainer = document.CreateFileContainerL(cid3, file); |
|
3246 TXmlEngFileContainer fileContainer2 = document.CreateFileContainerL(cid4, file2); |
|
3247 |
|
3248 // Get Envelope element |
|
3249 TXmlEngElement envelopeElement = pSOAPMessage->AsElementL(); |
|
3250 |
|
3251 // Create mime namespace declaration into Envelope element |
|
3252 // xmlns:xmlmime="http://www.w3.org/2004/11/xmlmime" |
|
3253 TXmlEngNamespace mimeNamespace = envelopeElement. AddNamespaceDeclarationL(_L8("http://www.w3.org/2004/11/xmlmime"), |
|
3254 _L8("xmlmime")); |
|
3255 // Create service specific namespace declaration into Body element |
|
3256 // xmlns:m="http://example.org/stuff" |
|
3257 TXmlEngNamespace serviceNamespace = pSOAPMessage->BodyL().AddNamespaceDeclarationL( |
|
3258 _L8("http://example.org/stuff"), |
|
3259 _L8("m")); |
|
3260 // Add data element into Body |
|
3261 // <S:Body xmlns:m="http://example.org/stuff"> |
|
3262 // <m:data> |
|
3263 // ... |
|
3264 // </m:data> |
|
3265 // </S:Body> |
|
3266 TXmlEngElement dataElement = pSOAPMessage->BodyL().AddNewElementL(_L8("data"), |
|
3267 serviceNamespace); |
|
3268 |
|
3269 // Add 1. attachment element into data element |
|
3270 // <m:data> |
|
3271 // <m:textAttachment1 xmlmime:contentType="text"> |
|
3272 // <xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:123456789@123456789"/> |
|
3273 // </m:textAttachment1> |
|
3274 // ... |
|
3275 // </m:data> |
|
3276 TXmlEngElement attachmentElement1 = dataElement.AddNewElementL(_L8("textAttachment1"), |
|
3277 serviceNamespace); |
|
3278 attachmentElement1.AddNewAttributeL(_L8("contentType"), _L8("text"), mimeNamespace); |
|
3279 attachmentElement1.AppendChildL(chunkContainer); |
|
3280 |
|
3281 // Add 2. attachment element into data element |
|
3282 TXmlEngElement attachmentElement2 = dataElement.AddNewElementL(_L8("textAttachment2"), |
|
3283 serviceNamespace); |
|
3284 attachmentElement2.AddNewAttributeL(_L8("contentType"), _L8("text"), mimeNamespace); |
|
3285 attachmentElement2.AppendChildL(fileContainer); |
|
3286 |
|
3287 // Add 3. attachment element into data element |
|
3288 TXmlEngElement attachmentElement3 = dataElement.AddNewElementL(_L8("textAttachment3"), |
|
3289 serviceNamespace); |
|
3290 attachmentElement3.AddNewAttributeL(_L8("contentType"), _L8("text"), mimeNamespace); |
|
3291 attachmentElement3.AppendChildL(chunkContainer2); |
|
3292 |
|
3293 // Add 4. attachment element into data element |
|
3294 TXmlEngElement attachmentElement4 = dataElement.AddNewElementL(_L8("textAttachment4"), |
|
3295 serviceNamespace); |
|
3296 attachmentElement4.AddNewAttributeL(_L8("contentType"), _L8("text"), mimeNamespace); |
|
3297 attachmentElement4.AppendChildL(fileContainer2); |
|
3298 |
|
3299 // Add 5. attachment element inside data element |
|
3300 TXmlEngElement attachmentElement5 = dataElement.AddNewElementL(_L8("textAttachment5"), |
|
3301 serviceNamespace); |
|
3302 attachmentElement5.AddNewAttributeL(_L8("contentType"), _L8("text"), mimeNamespace); |
|
3303 attachmentElement5.AppendChildL(chunkContainer3); |
|
3304 |
|
3305 // Http Post |
|
3306 CSenHttpTransportProperties* pHttpProperties = CSenHttpTransportProperties::NewLC(); |
|
3307 pHttpProperties->SetHttpHeaderL(KLoggerFileNameProperty, KFileName); |
|
3308 pSOAPMessage->SetProperties(pHttpProperties); |
|
3309 CleanupStack::Pop(pHttpProperties); // ownership was transferred to message |
|
3310 |
|
3311 CSenSoapEnvelope2* pRetMessage = NULL; |
|
3312 iServiceConnection->SubmitL(*pSOAPMessage, pRetMessage); |
|
3313 delete pRetMessage; |
|
3314 |
|
3315 // Check from HTTP Transaction logger log that POST method was used. |
|
3316 HBufC8* pFileContent = ReadFileL(KFileToRead); |
|
3317 LOCAL_ASSERT(pFileContent != NULL); |
|
3318 CleanupStack::PushL(pFileContent); |
|
3319 HBufC8* pValue = HttpMethodValueFromXmlLC(*pFileContent); |
|
3320 if ( pValue ) |
|
3321 { |
|
3322 LOCAL_ASSERT(*pValue == KHTTPMethodPost); |
|
3323 } |
|
3324 CleanupStack::PopAndDestroy(pValue); |
|
3325 CleanupStack::PopAndDestroy(pFileContent); |
|
3326 |
|
3327 CleanupStack::PopAndDestroy(pSOAPMessage); |
|
3328 |
|
3329 CleanupStack::PopAndDestroy(&file2); |
|
3330 CleanupStack::PopAndDestroy(&rfs2); |
|
3331 CleanupStack::PopAndDestroy(&file); |
|
3332 CleanupStack::PopAndDestroy(&rfs); |
|
3333 CleanupStack::PopAndDestroy(&binaryDataChunk2); |
|
3334 CleanupStack::PopAndDestroy(&binaryDataChunk); |
|
3335 |
|
3336 delete iServiceConnection; |
|
3337 iServiceConnection = NULL; |
|
3338 return KErrNone; |
|
3339 } |
|
3340 |
|
3341 TInt CsenConnectionTester::UT_CSenServiceConnection_SubmitL_LibXml2_MTOM_20KBL( ) |
|
3342 { |
|
3343 // Create ServiceConnection |
|
3344 |
|
3345 // _LIT8(KSHCEndPoint, "http://172.21.10.144:8080/mtom/servlet/MtomServlet"); |
|
3346 _LIT8(KSHCEndPoint, "http://4FID02268.NOE.Nokia.com:8080/mtom/servlet/MtomServlet"); |
|
3347 |
|
3348 CSenServicePattern* pPattern = CSenServicePattern::NewLC(KSHCEndPoint, KNullDesC8()); |
|
3349 // pPattern->SetFrameworkIdL(*ipFrameworkID); |
|
3350 pPattern->SetFrameworkIdL(KRESTFrameworkID); |
|
3351 TUint32 iapId = SearchIAPIdByNameL(KIAPName); |
|
3352 pPattern->SetConsumerIapIdL(iapId); |
|
3353 iServiceConnection = CSenServiceConnection::NewL(*this, *pPattern); |
|
3354 CleanupStack::PopAndDestroy(pPattern); |
|
3355 StartActiveScheduler(1); |
|
3356 LOCAL_ASSERT(iConnectionState == KSenConnectionStatusReady); |
|
3357 // Connection is ready to be used. |
|
3358 |
|
3359 // 1. Chunk declaration |
|
3360 _LIT8( cid, "123456789@123456789" ); |
|
3361 _LIT( chunkName, "test chunk" ); |
|
3362 _LIT8( chunkContent, "Testing chunk1" ); |
|
3363 TInt chunkSize = 1000; |
|
3364 TInt chunkMaxSize = 5000; |
|
3365 TInt chunkOffset = 100; |
|
3366 TInt chunkDataSize = 14; |
|
3367 RChunk binaryDataChunk; |
|
3368 binaryDataChunk.CreateGlobal(chunkName(), chunkSize, chunkMaxSize); |
|
3369 CleanupClosePushL(binaryDataChunk); |
|
3370 TUint8* heapPtr = binaryDataChunk.Base(); |
|
3371 heapPtr = heapPtr + chunkOffset; |
|
3372 // Place a new descriptor in the chunk to initialize it |
|
3373 new (heapPtr-sizeof(TPtr8)) TPtr8(heapPtr, 0, chunkDataSize); |
|
3374 // Set the descriptor |
|
3375 TPtr8* pDes = reinterpret_cast<TPtr8*>(heapPtr-sizeof(TPtr8)); |
|
3376 pDes->Zero(); |
|
3377 pDes->Append(chunkContent); |
|
3378 |
|
3379 // 2. Chunk declaration |
|
3380 _LIT8( cid2, "xyz" ); |
|
3381 _LIT( chunkName2, "test chunk2" ); |
|
3382 _LIT8( chunkContent2, "Testing chunk2" ); |
|
3383 TInt chunkSize2 = 3000; |
|
3384 TInt chunkMaxSize2 = 10000; |
|
3385 TInt chunkOffset2 = 112; |
|
3386 TInt chunkDataSize2 = 14; |
|
3387 |
|
3388 RChunk binaryDataChunk2; |
|
3389 binaryDataChunk2.CreateGlobal(chunkName2(), chunkSize2, chunkMaxSize2); |
|
3390 CleanupClosePushL(binaryDataChunk2); |
|
3391 TUint8* heapPtr2 = binaryDataChunk2.Base(); |
|
3392 heapPtr2 = heapPtr2 + chunkOffset2; |
|
3393 // Place a new descriptor in the chunk to initialize it |
|
3394 new (heapPtr2-sizeof(TPtr8)) TPtr8(heapPtr2, 0, chunkDataSize2); |
|
3395 // Set the descriptor |
|
3396 TPtr8* pDes2 = reinterpret_cast<TPtr8*>(heapPtr2-sizeof(TPtr8)); |
|
3397 pDes2->Zero(); |
|
3398 pDes2->Append(chunkContent2); |
|
3399 |
|
3400 // 1. File declaration |
|
3401 _LIT8( cid3, "999999999@123456789" ); |
|
3402 _LIT( KTestFileName, "e:\\testing\\data\\Sunset2.jpg" ); |
|
3403 RFs rfs; |
|
3404 User::LeaveIfError(rfs.Connect()); |
|
3405 CleanupClosePushL(rfs); |
|
3406 TInt retVal = rfs.ShareProtected(); |
|
3407 RFile file; |
|
3408 CleanupClosePushL(file); |
|
3409 User::LeaveIfError(file.Open(rfs, KTestFileName, EFileRead)); |
|
3410 |
|
3411 // 2. File declaration |
|
3412 _LIT8( cid4, "1z2" ); |
|
3413 _LIT( KTestFileName2, "e:\\testing\\data\\fileContainer2.txt" ); |
|
3414 _LIT8( KFileContent2, "Test FileContainer2" ); |
|
3415 RFs rfs2; |
|
3416 User::LeaveIfError(rfs2.Connect()); |
|
3417 CleanupClosePushL(rfs2); |
|
3418 retVal = rfs2.ShareProtected(); |
|
3419 RFile file2; |
|
3420 CleanupClosePushL(file2); |
|
3421 User::LeaveIfError(file2.Replace(rfs2, KTestFileName2, EFileWrite)); |
|
3422 User::LeaveIfError(file2.Write(KFileContent2)); |
|
3423 file2.Flush(); |
|
3424 file2.Close(); |
|
3425 User::LeaveIfError(file2.Open(rfs2, KTestFileName2, EFileRead)); |
|
3426 |
|
3427 // 3. File declaration |
|
3428 _LIT8( cid5, "999999999@12789" ); |
|
3429 _LIT( KTestFileName3, "e:\\testing\\data\\Winter2.jpg" ); |
|
3430 RFs rfs3; |
|
3431 User::LeaveIfError(rfs3.Connect()); |
|
3432 CleanupClosePushL(rfs3); |
|
3433 retVal = rfs3.ShareProtected(); |
|
3434 RFile file3; |
|
3435 CleanupClosePushL(file3); |
|
3436 User::LeaveIfError(file3.Open(rfs3, KTestFileName3, EFileRead)); |
|
3437 |
|
3438 |
|
3439 // Create SOAPMessage |
|
3440 CSenSoapMessage2* pSOAPMessage = CSenSoapMessage2::NewL(ESOAP12); |
|
3441 _LIT8( KSoapActionValue, "http://schemas.live.com/mws/2005/08/contacts/Sync" ); |
|
3442 pSOAPMessage->SetSoapActionL(KSoapActionValue); |
|
3443 // CSenSoapMessage2* pSOAPMessage = CSenSoapMessage2::NewL(); // ESOAP11 |
|
3444 CleanupStack::PushL(pSOAPMessage); |
|
3445 |
|
3446 RSenDocument document = pSOAPMessage->AsDocumentL(); |
|
3447 |
|
3448 // Create BinaryContainers |
|
3449 TXmlEngChunkContainer chunkContainer = document.CreateChunkContainerL( |
|
3450 cid, |
|
3451 binaryDataChunk, |
|
3452 chunkOffset, |
|
3453 chunkDataSize); |
|
3454 TXmlEngChunkContainer chunkContainer2 = document.CreateChunkContainerL( |
|
3455 cid2, |
|
3456 binaryDataChunk2, |
|
3457 chunkOffset2, |
|
3458 chunkDataSize2); |
|
3459 TXmlEngChunkContainer chunkContainer3 = document.CreateChunkContainerL( |
|
3460 cid2, |
|
3461 binaryDataChunk2, |
|
3462 chunkOffset2, |
|
3463 chunkDataSize2); |
|
3464 TXmlEngFileContainer fileContainer = document.CreateFileContainerL(cid3, file); |
|
3465 TXmlEngFileContainer fileContainer2 = document.CreateFileContainerL(cid4, file2); |
|
3466 TXmlEngFileContainer fileContainer3 = document.CreateFileContainerL(cid5, file3); |
|
3467 |
|
3468 |
|
3469 // Get Envelope element |
|
3470 TXmlEngElement envelopeElement = pSOAPMessage->AsElementL(); |
|
3471 |
|
3472 // Create mime namespace declaration into Envelope element |
|
3473 // xmlns:xmlmime="http://www.w3.org/2004/11/xmlmime" |
|
3474 |
|
3475 |
|
3476 TXmlEngNamespace mimeNamespace = envelopeElement. AddNamespaceDeclarationL(_L8("http://www.w3.org/2005/05/xmlmime"), |
|
3477 _L8("xmlmime")); |
|
3478 |
|
3479 // TXmlEngNamespace mimeNamespace = envelopeElement. AddNamespaceDeclarationL(_L8("http://www.w3.org/2004/11/xmlmime"), |
|
3480 // _L8("mime")); // IE does not render XML where attribute name startes with "xml" (xmlmime) |
|
3481 |
|
3482 |
|
3483 // Create service specific namespace declaration into Body element |
|
3484 // xmlns:m="http://example.org/stuff" |
|
3485 TXmlEngNamespace serviceNamespace = pSOAPMessage->BodyL().AddNamespaceDeclarationL( |
|
3486 _L8("http://example.org/stuff"), |
|
3487 _L8("m")); |
|
3488 // Add data element into Body |
|
3489 // <S:Body xmlns:m="http://example.org/stuff"> |
|
3490 // <m:data> |
|
3491 // ... |
|
3492 // </m:data> |
|
3493 // </S:Body> |
|
3494 TXmlEngElement dataElement = pSOAPMessage->BodyL().AddNewElementL(_L8("data"), |
|
3495 serviceNamespace); |
|
3496 |
|
3497 // Add 1. attachment element into data element |
|
3498 // <m:data> |
|
3499 // <m:textAttachment1 xmlmime:contentType="text"> |
|
3500 // <xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:123456789@123456789"/> |
|
3501 // </m:textAttachment1> |
|
3502 // ... |
|
3503 // </m:data> |
|
3504 TXmlEngElement attachmentElement1 = dataElement.AddNewElementL(_L8("textAttachment1"), |
|
3505 serviceNamespace); |
|
3506 attachmentElement1.AddNewAttributeL(_L8("contentType"), _L8("text/plain"), mimeNamespace); |
|
3507 attachmentElement1.AppendChildL(chunkContainer); |
|
3508 |
|
3509 // Add 2. attachment element into data element |
|
3510 TXmlEngElement attachmentElement2 = dataElement.AddNewElementL(_L8("textAttachment2"), |
|
3511 serviceNamespace); |
|
3512 attachmentElement2.AddNewAttributeL(_L8("contentType"), _L8("image/png"), mimeNamespace); |
|
3513 attachmentElement2.AppendChildL(fileContainer); |
|
3514 |
|
3515 // Add 3. attachment element into data element |
|
3516 TXmlEngElement attachmentElement3 = dataElement.AddNewElementL(_L8("textAttachment3"), |
|
3517 serviceNamespace); |
|
3518 attachmentElement3.AddNewAttributeL(_L8("contentType"), _L8("text/plain"), mimeNamespace); |
|
3519 attachmentElement3.AppendChildL(chunkContainer2); |
|
3520 |
|
3521 // Add 4. attachment element into data element |
|
3522 TXmlEngElement attachmentElement4 = dataElement.AddNewElementL(_L8("textAttachment4"), |
|
3523 serviceNamespace); |
|
3524 attachmentElement4.AddNewAttributeL(_L8("contentType"), _L8("text/plain"), mimeNamespace); |
|
3525 attachmentElement4.AppendChildL(fileContainer2); |
|
3526 |
|
3527 // Add 5. attachment element inside data element |
|
3528 TXmlEngElement attachmentElement5 = dataElement.AddNewElementL(_L8("textAttachment5"), |
|
3529 serviceNamespace); |
|
3530 attachmentElement5.AddNewAttributeL(_L8("contentType"), _L8("text/plain"), mimeNamespace); |
|
3531 attachmentElement5.AppendChildL(chunkContainer3); |
|
3532 |
|
3533 // Add 6. attachment element into data element |
|
3534 TXmlEngElement attachmentElement6 = dataElement.AddNewElementL(_L8("textAttachment2"), |
|
3535 serviceNamespace); |
|
3536 attachmentElement6.AddNewAttributeL(_L8("contentType"), _L8("image/png"), mimeNamespace); |
|
3537 attachmentElement6.AppendChildL(fileContainer3); |
|
3538 |
|
3539 // Http Post |
|
3540 CSenHttpTransportProperties* pHttpProperties = CSenHttpTransportProperties::NewLC(); |
|
3541 pHttpProperties->SetHttpHeaderL(KLoggerFileNameProperty, KFileName); |
|
3542 HBufC8* pPropsAsXml = pHttpProperties->AsUtf8LC(); |
|
3543 iServiceConnection->SetTransportPropertiesL(*pPropsAsXml); |
|
3544 CleanupStack::PopAndDestroy(pPropsAsXml); |
|
3545 CleanupStack::PopAndDestroy(pHttpProperties); |
|
3546 |
|
3547 CSenSoapEnvelope2* pRetMessage = NULL; |
|
3548 iServiceConnection->SubmitL(*pSOAPMessage, pRetMessage); |
|
3549 delete pRetMessage; |
|
3550 |
|
3551 CleanupStack::PopAndDestroy(pSOAPMessage); |
|
3552 CleanupStack::PopAndDestroy(&file3); |
|
3553 CleanupStack::PopAndDestroy(&rfs3); |
|
3554 CleanupStack::PopAndDestroy(&file2); |
|
3555 CleanupStack::PopAndDestroy(&rfs2); |
|
3556 CleanupStack::PopAndDestroy(&file); |
|
3557 CleanupStack::PopAndDestroy(&rfs); |
|
3558 CleanupStack::PopAndDestroy(&binaryDataChunk2); |
|
3559 CleanupStack::PopAndDestroy(&binaryDataChunk); |
|
3560 |
|
3561 delete iServiceConnection; |
|
3562 iServiceConnection = NULL; |
|
3563 return KErrNone; |
|
3564 } |
|
3565 |
|
3566 TInt CsenConnectionTester::UT_CSenServiceConnection_SubmitL_LibXml2_MTOM_200KBL( ) |
|
3567 { |
|
3568 // Create ServiceConnection |
|
3569 |
|
3570 // _LIT8(KSHCEndPoint, "http://172.21.10.144:8080/mtom/servlet/MtomServlet"); |
|
3571 _LIT8(KSHCEndPoint, "http://4FID02268.NOE.Nokia.com:8080/mtom/servlet/MtomServlet"); |
|
3572 |
|
3573 CSenServicePattern* pPattern = CSenServicePattern::NewLC(KSHCEndPoint, KNullDesC8()); |
|
3574 // pPattern->SetFrameworkIdL(*ipFrameworkID); |
|
3575 pPattern->SetFrameworkIdL(KRESTFrameworkID); |
|
3576 TUint32 iapId = SearchIAPIdByNameL(KIAPName); |
|
3577 pPattern->SetConsumerIapIdL(iapId); |
|
3578 iServiceConnection = CSenServiceConnection::NewL(*this, *pPattern); |
|
3579 CleanupStack::PopAndDestroy(pPattern); |
|
3580 StartActiveScheduler(1); |
|
3581 LOCAL_ASSERT(iConnectionState == KSenConnectionStatusReady); |
|
3582 // Connection is ready to be used. |
|
3583 |
|
3584 // 1. Chunk declaration |
|
3585 _LIT8( cid, "123456789@123456789" ); |
|
3586 _LIT( chunkName, "test chunk" ); |
|
3587 _LIT8( chunkContent, "Testing chunk1.Testing chunk1.Testing chunk1.Testing chunk1.Testing chunk1.Testing chunk1.Testing chunk1.Testing chunk1.Testing chunk1.Testing chunk1." ); |
|
3588 TInt chunkSize = 1000; |
|
3589 TInt chunkMaxSize = 5000; |
|
3590 TInt chunkOffset = 100; |
|
3591 TInt chunkDataSize = 150; |
|
3592 RChunk binaryDataChunk; |
|
3593 binaryDataChunk.CreateGlobal(chunkName(), chunkSize, chunkMaxSize); |
|
3594 CleanupClosePushL(binaryDataChunk); |
|
3595 TUint8* heapPtr = binaryDataChunk.Base(); |
|
3596 heapPtr = heapPtr + chunkOffset; |
|
3597 // Place a new descriptor in the chunk to initialize it |
|
3598 new (heapPtr-sizeof(TPtr8)) TPtr8(heapPtr, 0, chunkDataSize); |
|
3599 // Set the descriptor |
|
3600 TPtr8* pDes = reinterpret_cast<TPtr8*>(heapPtr-sizeof(TPtr8)); |
|
3601 pDes->Zero(); |
|
3602 pDes->Append(chunkContent); |
|
3603 |
|
3604 // 2. Chunk declaration |
|
3605 _LIT8( cid2, "xyz" ); |
|
3606 _LIT( chunkName2, "test chunk2" ); |
|
3607 _LIT8( chunkContent2, "Testing chunk2" ); |
|
3608 TInt chunkSize2 = 3000; |
|
3609 TInt chunkMaxSize2 = 10000; |
|
3610 TInt chunkOffset2 = 112; |
|
3611 TInt chunkDataSize2 = 14; |
|
3612 |
|
3613 RChunk binaryDataChunk2; |
|
3614 binaryDataChunk2.CreateGlobal(chunkName2(), chunkSize2, chunkMaxSize2); |
|
3615 CleanupClosePushL(binaryDataChunk2); |
|
3616 TUint8* heapPtr2 = binaryDataChunk2.Base(); |
|
3617 heapPtr2 = heapPtr2 + chunkOffset2; |
|
3618 // Place a new descriptor in the chunk to initialize it |
|
3619 new (heapPtr2-sizeof(TPtr8)) TPtr8(heapPtr2, 0, chunkDataSize2); |
|
3620 // Set the descriptor |
|
3621 TPtr8* pDes2 = reinterpret_cast<TPtr8*>(heapPtr2-sizeof(TPtr8)); |
|
3622 pDes2->Zero(); |
|
3623 pDes2->Append(chunkContent2); |
|
3624 |
|
3625 // 1. File declaration |
|
3626 _LIT8( cid3, "999999999@123456789" ); |
|
3627 _LIT( KTestFileName, "e:\\testing\\data\\Sunset.jpg" ); |
|
3628 RFs rfs; |
|
3629 User::LeaveIfError(rfs.Connect()); |
|
3630 CleanupClosePushL(rfs); |
|
3631 TInt retVal = rfs.ShareProtected(); |
|
3632 RFile file; |
|
3633 CleanupClosePushL(file); |
|
3634 User::LeaveIfError(file.Open(rfs, KTestFileName, EFileRead)); |
|
3635 |
|
3636 // 2. File declaration |
|
3637 _LIT8( cid4, "1z2" ); |
|
3638 _LIT( KTestFileName2, "e:\\testing\\data\\fileContainer2.txt" ); |
|
3639 _LIT8( KFileContent2, "Test FileContainer2" ); |
|
3640 RFs rfs2; |
|
3641 User::LeaveIfError(rfs2.Connect()); |
|
3642 CleanupClosePushL(rfs2); |
|
3643 retVal = rfs2.ShareProtected(); |
|
3644 RFile file2; |
|
3645 CleanupClosePushL(file2); |
|
3646 User::LeaveIfError(file2.Replace(rfs2, KTestFileName2, EFileWrite)); |
|
3647 User::LeaveIfError(file2.Write(KFileContent2)); |
|
3648 file2.Flush(); |
|
3649 file2.Close(); |
|
3650 User::LeaveIfError(file2.Open(rfs2, KTestFileName2, EFileRead)); |
|
3651 |
|
3652 // 3. File declaration |
|
3653 _LIT8( cid5, "999999999@12789" ); |
|
3654 _LIT( KTestFileName3, "e:\\testing\\data\\Winter.jpg" ); |
|
3655 RFs rfs3; |
|
3656 User::LeaveIfError(rfs3.Connect()); |
|
3657 CleanupClosePushL(rfs3); |
|
3658 retVal = rfs3.ShareProtected(); |
|
3659 RFile file3; |
|
3660 CleanupClosePushL(file3); |
|
3661 User::LeaveIfError(file3.Open(rfs3, KTestFileName3, EFileRead)); |
|
3662 |
|
3663 |
|
3664 // Create SOAPMessage |
|
3665 CSenSoapMessage2* pSOAPMessage = CSenSoapMessage2::NewL(ESOAP12); |
|
3666 _LIT8( KSoapActionValue, "http://schemas.live.com/mws/2005/08/contacts/Sync" ); |
|
3667 pSOAPMessage->SetSoapActionL(KSoapActionValue); |
|
3668 // CSenSoapMessage2* pSOAPMessage = CSenSoapMessage2::NewL(); // ESOAP11 |
|
3669 CleanupStack::PushL(pSOAPMessage); |
|
3670 |
|
3671 RSenDocument document = pSOAPMessage->AsDocumentL(); |
|
3672 |
|
3673 // Create BinaryContainers |
|
3674 TXmlEngChunkContainer chunkContainer = document.CreateChunkContainerL( |
|
3675 cid, |
|
3676 binaryDataChunk, |
|
3677 chunkOffset, |
|
3678 chunkDataSize); |
|
3679 TXmlEngChunkContainer chunkContainer2 = document.CreateChunkContainerL( |
|
3680 cid2, |
|
3681 binaryDataChunk2, |
|
3682 chunkOffset2, |
|
3683 chunkDataSize2); |
|
3684 TXmlEngChunkContainer chunkContainer3 = document.CreateChunkContainerL( |
|
3685 cid2, |
|
3686 binaryDataChunk2, |
|
3687 chunkOffset2, |
|
3688 chunkDataSize2); |
|
3689 TXmlEngFileContainer fileContainer = document.CreateFileContainerL(cid3, file); |
|
3690 TXmlEngFileContainer fileContainer2 = document.CreateFileContainerL(cid4, file2); |
|
3691 TXmlEngFileContainer fileContainer3 = document.CreateFileContainerL(cid5, file3); |
|
3692 |
|
3693 |
|
3694 // Get Envelope element |
|
3695 TXmlEngElement envelopeElement = pSOAPMessage->AsElementL(); |
|
3696 |
|
3697 // Create mime namespace declaration into Envelope element |
|
3698 // xmlns:xmlmime="http://www.w3.org/2004/11/xmlmime" |
|
3699 |
|
3700 |
|
3701 TXmlEngNamespace mimeNamespace = envelopeElement. AddNamespaceDeclarationL(_L8("http://www.w3.org/2005/05/xmlmime"), |
|
3702 _L8("xmlmime")); |
|
3703 |
|
3704 // TXmlEngNamespace mimeNamespace = envelopeElement. AddNamespaceDeclarationL(_L8("http://www.w3.org/2004/11/xmlmime"), |
|
3705 // _L8("mime")); // IE does not render XML where attribute name startes with "xml" (xmlmime) |
|
3706 |
|
3707 |
|
3708 // Create service specific namespace declaration into Body element |
|
3709 // xmlns:m="http://example.org/stuff" |
|
3710 TXmlEngNamespace serviceNamespace = pSOAPMessage->BodyL().AddNamespaceDeclarationL( |
|
3711 _L8("http://example.org/stuff"), |
|
3712 _L8("m")); |
|
3713 // Add data element into Body |
|
3714 // <S:Body xmlns:m="http://example.org/stuff"> |
|
3715 // <m:data> |
|
3716 // ... |
|
3717 // </m:data> |
|
3718 // </S:Body> |
|
3719 TXmlEngElement dataElement = pSOAPMessage->BodyL().AddNewElementL(_L8("data"), |
|
3720 serviceNamespace); |
|
3721 |
|
3722 // Add 1. attachment element into data element |
|
3723 // <m:data> |
|
3724 // <m:textAttachment1 xmlmime:contentType="text"> |
|
3725 // <xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:123456789@123456789"/> |
|
3726 // </m:textAttachment1> |
|
3727 // ... |
|
3728 // </m:data> |
|
3729 TXmlEngElement attachmentElement1 = dataElement.AddNewElementL(_L8("textAttachment1"), |
|
3730 serviceNamespace); |
|
3731 attachmentElement1.AddNewAttributeL(_L8("contentType"), _L8("text/plain"), mimeNamespace); |
|
3732 attachmentElement1.AppendChildL(chunkContainer); |
|
3733 |
|
3734 // Add 2. attachment element into data element |
|
3735 TXmlEngElement attachmentElement2 = dataElement.AddNewElementL(_L8("textAttachment2"), |
|
3736 serviceNamespace); |
|
3737 attachmentElement2.AddNewAttributeL(_L8("contentType"), _L8("image/png"), mimeNamespace); |
|
3738 attachmentElement2.AppendChildL(fileContainer); |
|
3739 |
|
3740 // Add 3. attachment element into data element |
|
3741 TXmlEngElement attachmentElement3 = dataElement.AddNewElementL(_L8("textAttachment3"), |
|
3742 serviceNamespace); |
|
3743 attachmentElement3.AddNewAttributeL(_L8("contentType"), _L8("text/plain"), mimeNamespace); |
|
3744 attachmentElement3.AppendChildL(chunkContainer2); |
|
3745 |
|
3746 // Add 4. attachment element into data element |
|
3747 TXmlEngElement attachmentElement4 = dataElement.AddNewElementL(_L8("textAttachment4"), |
|
3748 serviceNamespace); |
|
3749 attachmentElement4.AddNewAttributeL(_L8("contentType"), _L8("text/plain"), mimeNamespace); |
|
3750 attachmentElement4.AppendChildL(fileContainer2); |
|
3751 |
|
3752 // Add 5. attachment element inside data element |
|
3753 TXmlEngElement attachmentElement5 = dataElement.AddNewElementL(_L8("textAttachment5"), |
|
3754 serviceNamespace); |
|
3755 attachmentElement5.AddNewAttributeL(_L8("contentType"), _L8("text/plain"), mimeNamespace); |
|
3756 attachmentElement5.AppendChildL(chunkContainer3); |
|
3757 |
|
3758 // Add 6. attachment element into data element |
|
3759 TXmlEngElement attachmentElement6 = dataElement.AddNewElementL(_L8("textAttachment2"), |
|
3760 serviceNamespace); |
|
3761 attachmentElement6.AddNewAttributeL(_L8("contentType"), _L8("image/png"), mimeNamespace); |
|
3762 attachmentElement6.AppendChildL(fileContainer3); |
|
3763 |
|
3764 // Http Post |
|
3765 CSenHttpTransportProperties* pHttpProperties = CSenHttpTransportProperties::NewLC(); |
|
3766 pHttpProperties->SetHttpHeaderL(KLoggerFileNameProperty, KFileName); |
|
3767 HBufC8* pPropsAsXml = pHttpProperties->AsUtf8LC(); |
|
3768 iServiceConnection->SetTransportPropertiesL(*pPropsAsXml); |
|
3769 CleanupStack::PopAndDestroy(pPropsAsXml); |
|
3770 CleanupStack::PopAndDestroy(pHttpProperties); |
|
3771 |
|
3772 CSenSoapEnvelope2* pRetMessage = NULL; |
|
3773 iServiceConnection->SubmitL(*pSOAPMessage, pRetMessage); |
|
3774 delete pRetMessage; |
|
3775 |
|
3776 CleanupStack::PopAndDestroy(pSOAPMessage); |
|
3777 CleanupStack::PopAndDestroy(&file3); |
|
3778 CleanupStack::PopAndDestroy(&rfs3); |
|
3779 CleanupStack::PopAndDestroy(&file2); |
|
3780 CleanupStack::PopAndDestroy(&rfs2); |
|
3781 CleanupStack::PopAndDestroy(&file); |
|
3782 CleanupStack::PopAndDestroy(&rfs); |
|
3783 CleanupStack::PopAndDestroy(&binaryDataChunk2); |
|
3784 CleanupStack::PopAndDestroy(&binaryDataChunk); |
|
3785 |
|
3786 delete iServiceConnection; |
|
3787 iServiceConnection = NULL; |
|
3788 return KErrNone; |
|
3789 } |
|
3790 |
|
3791 TInt CsenConnectionTester::UT_CSenServiceConnection_SubmitL_LibXml2_MTOM_Less1MBL( ) |
|
3792 { |
|
3793 // Create ServiceConnection |
|
3794 |
|
3795 // _LIT8(KSHCEndPoint, "http://172.21.10.144:8080/mtom/servlet/MtomServlet"); |
|
3796 _LIT8(KSHCEndPoint, "http://4FID02268.NOE.Nokia.com:8080/mtom/servlet/MtomServlet"); |
|
3797 CSenServicePattern* pPattern = CSenServicePattern::NewLC(KSHCEndPoint, KNullDesC8()); |
|
3798 // pPattern->SetFrameworkIdL(*ipFrameworkID); |
|
3799 pPattern->SetFrameworkIdL(KRESTFrameworkID); |
|
3800 TUint32 iapId = SearchIAPIdByNameL(KIAPName); |
|
3801 pPattern->SetConsumerIapIdL(iapId); |
|
3802 iServiceConnection = CSenServiceConnection::NewL(*this, *pPattern); |
|
3803 CleanupStack::PopAndDestroy(pPattern); |
|
3804 StartActiveScheduler(1); |
|
3805 LOCAL_ASSERT(iConnectionState == KSenConnectionStatusReady); |
|
3806 // Connection is ready to be used. |
|
3807 |
|
3808 // 1. Chunk declaration |
|
3809 _LIT8( cid, "123456789@123456789" ); |
|
3810 _LIT( chunkName, "test chunk" ); |
|
3811 _LIT8( chunkContent, "Testing chunk1.Testing chunk1.Testing chunk1.Testing chunk1.Testing chunk1.Testing chunk1.Testing chunk1.Testing chunk1.Testing chunk1.Testing chunk1." ); |
|
3812 TInt chunkSize = 1000; |
|
3813 TInt chunkMaxSize = 5000; |
|
3814 TInt chunkOffset = 100; |
|
3815 TInt chunkDataSize = 150; |
|
3816 RChunk binaryDataChunk; |
|
3817 binaryDataChunk.CreateGlobal(chunkName(), chunkSize, chunkMaxSize); |
|
3818 CleanupClosePushL(binaryDataChunk); |
|
3819 TUint8* heapPtr = binaryDataChunk.Base(); |
|
3820 heapPtr = heapPtr + chunkOffset; |
|
3821 // Place a new descriptor in the chunk to initialize it |
|
3822 new (heapPtr-sizeof(TPtr8)) TPtr8(heapPtr, 0, chunkDataSize); |
|
3823 // Set the descriptor |
|
3824 TPtr8* pDes = reinterpret_cast<TPtr8*>(heapPtr-sizeof(TPtr8)); |
|
3825 pDes->Zero(); |
|
3826 pDes->Append(chunkContent); |
|
3827 |
|
3828 // 2. Chunk declaration |
|
3829 _LIT8( cid2, "xyz" ); |
|
3830 _LIT( chunkName2, "test chunk2" ); |
|
3831 _LIT8( chunkContent2, "Testing chunk2" ); |
|
3832 TInt chunkSize2 = 3000; |
|
3833 TInt chunkMaxSize2 = 10000; |
|
3834 TInt chunkOffset2 = 112; |
|
3835 TInt chunkDataSize2 = 14; |
|
3836 |
|
3837 RChunk binaryDataChunk2; |
|
3838 binaryDataChunk2.CreateGlobal(chunkName2(), chunkSize2, chunkMaxSize2); |
|
3839 CleanupClosePushL(binaryDataChunk2); |
|
3840 TUint8* heapPtr2 = binaryDataChunk2.Base(); |
|
3841 heapPtr2 = heapPtr2 + chunkOffset2; |
|
3842 // Place a new descriptor in the chunk to initialize it |
|
3843 new (heapPtr2-sizeof(TPtr8)) TPtr8(heapPtr2, 0, chunkDataSize2); |
|
3844 // Set the descriptor |
|
3845 TPtr8* pDes2 = reinterpret_cast<TPtr8*>(heapPtr2-sizeof(TPtr8)); |
|
3846 pDes2->Zero(); |
|
3847 pDes2->Append(chunkContent2); |
|
3848 |
|
3849 // 1. File declaration |
|
3850 _LIT8( cid3, "999999999@123456789" ); |
|
3851 _LIT( KTestFileName, "e:\\testing\\data\\Sunset.jpg" ); |
|
3852 RFs rfs; |
|
3853 User::LeaveIfError(rfs.Connect()); |
|
3854 CleanupClosePushL(rfs); |
|
3855 TInt retVal = rfs.ShareProtected(); |
|
3856 RFile file; |
|
3857 CleanupClosePushL(file); |
|
3858 User::LeaveIfError(file.Open(rfs, KTestFileName, EFileRead)); |
|
3859 |
|
3860 // 2. File declaration |
|
3861 _LIT8( cid4, "1z2" ); |
|
3862 _LIT( KTestFileName2, "e:\\testing\\data\\fileContainer2.txt" ); |
|
3863 _LIT8( KFileContent2, "Test FileContainer2" ); |
|
3864 RFs rfs2; |
|
3865 User::LeaveIfError(rfs2.Connect()); |
|
3866 CleanupClosePushL(rfs2); |
|
3867 retVal = rfs2.ShareProtected(); |
|
3868 RFile file2; |
|
3869 CleanupClosePushL(file2); |
|
3870 User::LeaveIfError(file2.Replace(rfs2, KTestFileName2, EFileWrite)); |
|
3871 User::LeaveIfError(file2.Write(KFileContent2)); |
|
3872 file2.Flush(); |
|
3873 file2.Close(); |
|
3874 User::LeaveIfError(file2.Open(rfs2, KTestFileName2, EFileRead)); |
|
3875 |
|
3876 // 3. File declaration |
|
3877 _LIT8( cid5, "999999999@12789" ); |
|
3878 _LIT( KTestFileName3, "e:\\testing\\data\\testPic3.jpg"); |
|
3879 RFs rfs3; |
|
3880 User::LeaveIfError(rfs3.Connect()); |
|
3881 CleanupClosePushL(rfs3); |
|
3882 retVal = rfs3.ShareProtected(); |
|
3883 RFile file3; |
|
3884 CleanupClosePushL(file3); |
|
3885 User::LeaveIfError(file3.Open(rfs3, KTestFileName3, EFileRead)); |
|
3886 |
|
3887 |
|
3888 // Create SOAPMessage |
|
3889 CSenSoapMessage2* pSOAPMessage = CSenSoapMessage2::NewL(ESOAP12); |
|
3890 _LIT8( KSoapActionValue, "http://schemas.live.com/mws/2005/08/contacts/Sync" ); |
|
3891 pSOAPMessage->SetSoapActionL(KSoapActionValue); |
|
3892 // CSenSoapMessage2* pSOAPMessage = CSenSoapMessage2::NewL(); // ESOAP11 |
|
3893 CleanupStack::PushL(pSOAPMessage); |
|
3894 |
|
3895 RSenDocument document = pSOAPMessage->AsDocumentL(); |
|
3896 |
|
3897 // Create BinaryContainers |
|
3898 TXmlEngChunkContainer chunkContainer = document.CreateChunkContainerL( |
|
3899 cid, |
|
3900 binaryDataChunk, |
|
3901 chunkOffset, |
|
3902 chunkDataSize); |
|
3903 TXmlEngChunkContainer chunkContainer2 = document.CreateChunkContainerL( |
|
3904 cid2, |
|
3905 binaryDataChunk2, |
|
3906 chunkOffset2, |
|
3907 chunkDataSize2); |
|
3908 TXmlEngChunkContainer chunkContainer3 = document.CreateChunkContainerL( |
|
3909 cid2, |
|
3910 binaryDataChunk2, |
|
3911 chunkOffset2, |
|
3912 chunkDataSize2); |
|
3913 TXmlEngFileContainer fileContainer = document.CreateFileContainerL(cid3, file); |
|
3914 TXmlEngFileContainer fileContainer2 = document.CreateFileContainerL(cid4, file2); |
|
3915 TXmlEngFileContainer fileContainer3 = document.CreateFileContainerL(cid5, file3); |
|
3916 |
|
3917 |
|
3918 // Get Envelope element |
|
3919 TXmlEngElement envelopeElement = pSOAPMessage->AsElementL(); |
|
3920 |
|
3921 // Create mime namespace declaration into Envelope element |
|
3922 // xmlns:xmlmime="http://www.w3.org/2004/11/xmlmime" |
|
3923 |
|
3924 |
|
3925 TXmlEngNamespace mimeNamespace = envelopeElement. AddNamespaceDeclarationL(_L8("http://www.w3.org/2005/05/xmlmime"), |
|
3926 _L8("xmlmime")); |
|
3927 |
|
3928 // TXmlEngNamespace mimeNamespace = envelopeElement. AddNamespaceDeclarationL(_L8("http://www.w3.org/2004/11/xmlmime"), |
|
3929 // _L8("mime")); // IE does not render XML where attribute name startes with "xml" (xmlmime) |
|
3930 |
|
3931 |
|
3932 // Create service specific namespace declaration into Body element |
|
3933 // xmlns:m="http://example.org/stuff" |
|
3934 TXmlEngNamespace serviceNamespace = pSOAPMessage->BodyL().AddNamespaceDeclarationL( |
|
3935 _L8("http://example.org/stuff"), |
|
3936 _L8("m")); |
|
3937 // Add data element into Body |
|
3938 // <S:Body xmlns:m="http://example.org/stuff"> |
|
3939 // <m:data> |
|
3940 // ... |
|
3941 // </m:data> |
|
3942 // </S:Body> |
|
3943 TXmlEngElement dataElement = pSOAPMessage->BodyL().AddNewElementL(_L8("data"), |
|
3944 serviceNamespace); |
|
3945 |
|
3946 // Add 1. attachment element into data element |
|
3947 // <m:data> |
|
3948 // <m:textAttachment1 xmlmime:contentType="text"> |
|
3949 // <xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:123456789@123456789"/> |
|
3950 // </m:textAttachment1> |
|
3951 // ... |
|
3952 // </m:data> |
|
3953 TXmlEngElement attachmentElement1 = dataElement.AddNewElementL(_L8("textAttachment1"), |
|
3954 serviceNamespace); |
|
3955 attachmentElement1.AddNewAttributeL(_L8("contentType"), _L8("text/plain"), mimeNamespace); |
|
3956 attachmentElement1.AppendChildL(chunkContainer); |
|
3957 |
|
3958 // Add 2. attachment element into data element |
|
3959 TXmlEngElement attachmentElement2 = dataElement.AddNewElementL(_L8("textAttachment2"), |
|
3960 serviceNamespace); |
|
3961 attachmentElement2.AddNewAttributeL(_L8("contentType"), _L8("image/png"), mimeNamespace); |
|
3962 attachmentElement2.AppendChildL(fileContainer); |
|
3963 |
|
3964 // Add 3. attachment element into data element |
|
3965 TXmlEngElement attachmentElement3 = dataElement.AddNewElementL(_L8("textAttachment3"), |
|
3966 serviceNamespace); |
|
3967 attachmentElement3.AddNewAttributeL(_L8("contentType"), _L8("text/plain"), mimeNamespace); |
|
3968 attachmentElement3.AppendChildL(chunkContainer2); |
|
3969 |
|
3970 // Add 4. attachment element into data element |
|
3971 TXmlEngElement attachmentElement4 = dataElement.AddNewElementL(_L8("textAttachment4"), |
|
3972 serviceNamespace); |
|
3973 attachmentElement4.AddNewAttributeL(_L8("contentType"), _L8("text/plain"), mimeNamespace); |
|
3974 attachmentElement4.AppendChildL(fileContainer2); |
|
3975 |
|
3976 // Add 5. attachment element inside data element |
|
3977 TXmlEngElement attachmentElement5 = dataElement.AddNewElementL(_L8("textAttachment5"), |
|
3978 serviceNamespace); |
|
3979 attachmentElement5.AddNewAttributeL(_L8("contentType"), _L8("text/plain"), mimeNamespace); |
|
3980 attachmentElement5.AppendChildL(chunkContainer3); |
|
3981 |
|
3982 // Add 6. attachment element into data element |
|
3983 TXmlEngElement attachmentElement6 = dataElement.AddNewElementL(_L8("textAttachment2"), |
|
3984 serviceNamespace); |
|
3985 attachmentElement6.AddNewAttributeL(_L8("contentType"), _L8("image/png"), mimeNamespace); |
|
3986 attachmentElement6.AppendChildL(fileContainer3); |
|
3987 |
|
3988 |
|
3989 // Http Post |
|
3990 CSenHttpTransportProperties* pHttpProperties = CSenHttpTransportProperties::NewLC(); |
|
3991 pHttpProperties->SetHttpHeaderL(KLoggerFileNameProperty, KFileName); |
|
3992 HBufC8* pPropsAsXml = pHttpProperties->AsUtf8LC(); |
|
3993 iServiceConnection->SetTransportPropertiesL(*pPropsAsXml); |
|
3994 CleanupStack::PopAndDestroy(pPropsAsXml); |
|
3995 CleanupStack::PopAndDestroy(pHttpProperties); |
|
3996 |
|
3997 |
|
3998 CSenSoapEnvelope2* pRetMessage = NULL; |
|
3999 iServiceConnection->SubmitL(*pSOAPMessage, pRetMessage); |
|
4000 delete pRetMessage; |
|
4001 |
|
4002 CleanupStack::PopAndDestroy(pSOAPMessage); |
|
4003 CleanupStack::PopAndDestroy(&file3); |
|
4004 CleanupStack::PopAndDestroy(&rfs3); |
|
4005 CleanupStack::PopAndDestroy(&file2); |
|
4006 CleanupStack::PopAndDestroy(&rfs2); |
|
4007 CleanupStack::PopAndDestroy(&file); |
|
4008 CleanupStack::PopAndDestroy(&rfs); |
|
4009 CleanupStack::PopAndDestroy(&binaryDataChunk2); |
|
4010 CleanupStack::PopAndDestroy(&binaryDataChunk); |
|
4011 |
|
4012 delete iServiceConnection; |
|
4013 iServiceConnection = NULL; |
|
4014 return KErrNone; |
|
4015 } |
|
4016 |
|
4017 TInt CsenConnectionTester::UT_CSenServiceConnection_SubmitL_LibXml2_MTOM_More1MBL( ) |
|
4018 { |
|
4019 // Create ServiceConnection |
|
4020 |
|
4021 // _LIT8(KSHCEndPoint, "http://172.21.10.144:8080/mtom/servlet/MtomServlet"); |
|
4022 _LIT8(KSHCEndPoint, "http://4FID02268.NOE.Nokia.com:8080/mtom/servlet/MtomServlet"); |
|
4023 CSenServicePattern* pPattern = CSenServicePattern::NewLC(KSHCEndPoint, KNullDesC8()); |
|
4024 // pPattern->SetFrameworkIdL(*ipFrameworkID); |
|
4025 pPattern->SetFrameworkIdL(KRESTFrameworkID); |
|
4026 TUint32 iapId = SearchIAPIdByNameL(KIAPName); |
|
4027 pPattern->SetConsumerIapIdL(iapId); |
|
4028 iServiceConnection = CSenServiceConnection::NewL(*this, *pPattern); |
|
4029 CleanupStack::PopAndDestroy(pPattern); |
|
4030 StartActiveScheduler(1); |
|
4031 LOCAL_ASSERT(iConnectionState == KSenConnectionStatusReady); |
|
4032 // Connection is ready to be used. |
|
4033 |
|
4034 // 1. Chunk declaration |
|
4035 _LIT8( cid, "123456789@123456789" ); |
|
4036 _LIT( chunkName, "test chunk" ); |
|
4037 _LIT8( chunkContent, "Testing chunk1.Testing chunk1.Testing chunk1.Testing chunk1.Testing chunk1.Testing chunk1.Testing chunk1.Testing chunk1.Testing chunk1.Testing chunk1." ); |
|
4038 TInt chunkSize = 1000; |
|
4039 TInt chunkMaxSize = 5000; |
|
4040 TInt chunkOffset = 100; |
|
4041 TInt chunkDataSize = 150; |
|
4042 RChunk binaryDataChunk; |
|
4043 binaryDataChunk.CreateGlobal(chunkName(), chunkSize, chunkMaxSize); |
|
4044 CleanupClosePushL(binaryDataChunk); |
|
4045 TUint8* heapPtr = binaryDataChunk.Base(); |
|
4046 heapPtr = heapPtr + chunkOffset; |
|
4047 // Place a new descriptor in the chunk to initialize it |
|
4048 new (heapPtr-sizeof(TPtr8)) TPtr8(heapPtr, 0, chunkDataSize); |
|
4049 // Set the descriptor |
|
4050 TPtr8* pDes = reinterpret_cast<TPtr8*>(heapPtr-sizeof(TPtr8)); |
|
4051 pDes->Zero(); |
|
4052 pDes->Append(chunkContent); |
|
4053 |
|
4054 // 2. Chunk declaration |
|
4055 _LIT8( cid2, "xyz" ); |
|
4056 _LIT( chunkName2, "test chunk2" ); |
|
4057 _LIT8( chunkContent2, "Testing chunk2" ); |
|
4058 TInt chunkSize2 = 3000; |
|
4059 TInt chunkMaxSize2 = 10000; |
|
4060 TInt chunkOffset2 = 112; |
|
4061 TInt chunkDataSize2 = 14; |
|
4062 |
|
4063 RChunk binaryDataChunk2; |
|
4064 binaryDataChunk2.CreateGlobal(chunkName2(), chunkSize2, chunkMaxSize2); |
|
4065 CleanupClosePushL(binaryDataChunk2); |
|
4066 TUint8* heapPtr2 = binaryDataChunk2.Base(); |
|
4067 heapPtr2 = heapPtr2 + chunkOffset2; |
|
4068 // Place a new descriptor in the chunk to initialize it |
|
4069 new (heapPtr2-sizeof(TPtr8)) TPtr8(heapPtr2, 0, chunkDataSize2); |
|
4070 // Set the descriptor |
|
4071 TPtr8* pDes2 = reinterpret_cast<TPtr8*>(heapPtr2-sizeof(TPtr8)); |
|
4072 pDes2->Zero(); |
|
4073 pDes2->Append(chunkContent2); |
|
4074 |
|
4075 // 1. File declaration |
|
4076 _LIT8( cid3, "999999999@123456789" ); |
|
4077 _LIT( KTestFileName, "e:\\testing\\data\\Sunset.jpg" ); |
|
4078 RFs rfs; |
|
4079 User::LeaveIfError(rfs.Connect()); |
|
4080 CleanupClosePushL(rfs); |
|
4081 TInt retVal = rfs.ShareProtected(); |
|
4082 RFile file; |
|
4083 CleanupClosePushL(file); |
|
4084 User::LeaveIfError(file.Open(rfs, KTestFileName, EFileRead)); |
|
4085 |
|
4086 // 2. File declaration |
|
4087 _LIT8( cid4, "1z2" ); |
|
4088 _LIT( KTestFileName2, "e:\\testing\\data\\fileContainer2.txt" ); |
|
4089 _LIT8( KFileContent2, "Test FileContainer2" ); |
|
4090 RFs rfs2; |
|
4091 User::LeaveIfError(rfs2.Connect()); |
|
4092 CleanupClosePushL(rfs2); |
|
4093 retVal = rfs2.ShareProtected(); |
|
4094 RFile file2; |
|
4095 CleanupClosePushL(file2); |
|
4096 User::LeaveIfError(file2.Replace(rfs2, KTestFileName2, EFileWrite)); |
|
4097 User::LeaveIfError(file2.Write(KFileContent2)); |
|
4098 file2.Flush(); |
|
4099 file2.Close(); |
|
4100 User::LeaveIfError(file2.Open(rfs2, KTestFileName2, EFileRead)); |
|
4101 |
|
4102 // 3. File declaration |
|
4103 _LIT8( cid5, "999999999@12789" ); |
|
4104 _LIT( KTestFileName3, "e:\\testing\\data\\testPic4.jpg"); |
|
4105 RFs rfs3; |
|
4106 User::LeaveIfError(rfs3.Connect()); |
|
4107 CleanupClosePushL(rfs3); |
|
4108 retVal = rfs3.ShareProtected(); |
|
4109 RFile file3; |
|
4110 CleanupClosePushL(file3); |
|
4111 User::LeaveIfError(file3.Open(rfs3, KTestFileName3, EFileRead)); |
|
4112 |
|
4113 |
|
4114 // Create SOAPMessage |
|
4115 CSenSoapMessage2* pSOAPMessage = CSenSoapMessage2::NewL(ESOAP12); |
|
4116 _LIT8( KSoapActionValue, "http://schemas.live.com/mws/2005/08/contacts/Sync" ); |
|
4117 pSOAPMessage->SetSoapActionL(KSoapActionValue); |
|
4118 // CSenSoapMessage2* pSOAPMessage = CSenSoapMessage2::NewL(); // ESOAP11 |
|
4119 CleanupStack::PushL(pSOAPMessage); |
|
4120 |
|
4121 RSenDocument document = pSOAPMessage->AsDocumentL(); |
|
4122 |
|
4123 // Create BinaryContainers |
|
4124 TXmlEngChunkContainer chunkContainer = document.CreateChunkContainerL( |
|
4125 cid, |
|
4126 binaryDataChunk, |
|
4127 chunkOffset, |
|
4128 chunkDataSize); |
|
4129 TXmlEngChunkContainer chunkContainer2 = document.CreateChunkContainerL( |
|
4130 cid2, |
|
4131 binaryDataChunk2, |
|
4132 chunkOffset2, |
|
4133 chunkDataSize2); |
|
4134 TXmlEngChunkContainer chunkContainer3 = document.CreateChunkContainerL( |
|
4135 cid2, |
|
4136 binaryDataChunk2, |
|
4137 chunkOffset2, |
|
4138 chunkDataSize2); |
|
4139 TXmlEngFileContainer fileContainer = document.CreateFileContainerL(cid3, file); |
|
4140 TXmlEngFileContainer fileContainer2 = document.CreateFileContainerL(cid4, file2); |
|
4141 TXmlEngFileContainer fileContainer3 = document.CreateFileContainerL(cid5, file3); |
|
4142 |
|
4143 |
|
4144 // Get Envelope element |
|
4145 TXmlEngElement envelopeElement = pSOAPMessage->AsElementL(); |
|
4146 |
|
4147 // Create mime namespace declaration into Envelope element |
|
4148 // xmlns:xmlmime="http://www.w3.org/2004/11/xmlmime" |
|
4149 |
|
4150 |
|
4151 TXmlEngNamespace mimeNamespace = envelopeElement. AddNamespaceDeclarationL(_L8("http://www.w3.org/2005/05/xmlmime"), |
|
4152 _L8("xmlmime")); |
|
4153 |
|
4154 // TXmlEngNamespace mimeNamespace = envelopeElement. AddNamespaceDeclarationL(_L8("http://www.w3.org/2004/11/xmlmime"), |
|
4155 // _L8("mime")); // IE does not render XML where attribute name startes with "xml" (xmlmime) |
|
4156 |
|
4157 |
|
4158 // Create service specific namespace declaration into Body element |
|
4159 // xmlns:m="http://example.org/stuff" |
|
4160 TXmlEngNamespace serviceNamespace = pSOAPMessage->BodyL().AddNamespaceDeclarationL( |
|
4161 _L8("http://example.org/stuff"), |
|
4162 _L8("m")); |
|
4163 // Add data element into Body |
|
4164 // <S:Body xmlns:m="http://example.org/stuff"> |
|
4165 // <m:data> |
|
4166 // ... |
|
4167 // </m:data> |
|
4168 // </S:Body> |
|
4169 TXmlEngElement dataElement = pSOAPMessage->BodyL().AddNewElementL(_L8("data"), |
|
4170 serviceNamespace); |
|
4171 |
|
4172 // Add 1. attachment element into data element |
|
4173 // <m:data> |
|
4174 // <m:textAttachment1 xmlmime:contentType="text"> |
|
4175 // <xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:123456789@123456789"/> |
|
4176 // </m:textAttachment1> |
|
4177 // ... |
|
4178 // </m:data> |
|
4179 TXmlEngElement attachmentElement1 = dataElement.AddNewElementL(_L8("textAttachment1"), |
|
4180 serviceNamespace); |
|
4181 attachmentElement1.AddNewAttributeL(_L8("contentType"), _L8("text/plain"), mimeNamespace); |
|
4182 attachmentElement1.AppendChildL(chunkContainer); |
|
4183 |
|
4184 // Add 2. attachment element into data element |
|
4185 TXmlEngElement attachmentElement2 = dataElement.AddNewElementL(_L8("textAttachment2"), |
|
4186 serviceNamespace); |
|
4187 attachmentElement2.AddNewAttributeL(_L8("contentType"), _L8("image/png"), mimeNamespace); |
|
4188 attachmentElement2.AppendChildL(fileContainer); |
|
4189 |
|
4190 // Add 3. attachment element into data element |
|
4191 TXmlEngElement attachmentElement3 = dataElement.AddNewElementL(_L8("textAttachment3"), |
|
4192 serviceNamespace); |
|
4193 attachmentElement3.AddNewAttributeL(_L8("contentType"), _L8("text/plain"), mimeNamespace); |
|
4194 attachmentElement3.AppendChildL(chunkContainer2); |
|
4195 |
|
4196 // Add 4. attachment element into data element |
|
4197 TXmlEngElement attachmentElement4 = dataElement.AddNewElementL(_L8("textAttachment4"), |
|
4198 serviceNamespace); |
|
4199 attachmentElement4.AddNewAttributeL(_L8("contentType"), _L8("text/plain"), mimeNamespace); |
|
4200 attachmentElement4.AppendChildL(fileContainer2); |
|
4201 |
|
4202 // Add 5. attachment element inside data element |
|
4203 TXmlEngElement attachmentElement5 = dataElement.AddNewElementL(_L8("textAttachment5"), |
|
4204 serviceNamespace); |
|
4205 attachmentElement5.AddNewAttributeL(_L8("contentType"), _L8("text/plain"), mimeNamespace); |
|
4206 attachmentElement5.AppendChildL(chunkContainer3); |
|
4207 |
|
4208 // Add 6. attachment element into data element |
|
4209 TXmlEngElement attachmentElement6 = dataElement.AddNewElementL(_L8("textAttachment2"), |
|
4210 serviceNamespace); |
|
4211 attachmentElement6.AddNewAttributeL(_L8("contentType"), _L8("image/png"), mimeNamespace); |
|
4212 attachmentElement6.AppendChildL(fileContainer3); |
|
4213 |
|
4214 |
|
4215 // Http Post |
|
4216 CSenHttpTransportProperties* pHttpProperties = CSenHttpTransportProperties::NewLC(); |
|
4217 pHttpProperties->SetHttpHeaderL(KLoggerFileNameProperty, KFileName); |
|
4218 HBufC8* pPropsAsXml = pHttpProperties->AsUtf8LC(); |
|
4219 iServiceConnection->SetTransportPropertiesL(*pPropsAsXml); |
|
4220 CleanupStack::PopAndDestroy(pPropsAsXml); |
|
4221 CleanupStack::PopAndDestroy(pHttpProperties); |
|
4222 |
|
4223 |
|
4224 CSenSoapEnvelope2* pRetMessage = NULL; |
|
4225 iServiceConnection->SubmitL(*pSOAPMessage, pRetMessage); |
|
4226 delete pRetMessage; |
|
4227 |
|
4228 CleanupStack::PopAndDestroy(pSOAPMessage); |
|
4229 CleanupStack::PopAndDestroy(&file3); |
|
4230 CleanupStack::PopAndDestroy(&rfs3); |
|
4231 CleanupStack::PopAndDestroy(&file2); |
|
4232 CleanupStack::PopAndDestroy(&rfs2); |
|
4233 CleanupStack::PopAndDestroy(&file); |
|
4234 CleanupStack::PopAndDestroy(&rfs); |
|
4235 CleanupStack::PopAndDestroy(&binaryDataChunk2); |
|
4236 CleanupStack::PopAndDestroy(&binaryDataChunk); |
|
4237 |
|
4238 delete iServiceConnection; |
|
4239 iServiceConnection = NULL; |
|
4240 return KErrNone; |
|
4241 } |
|
4242 |
|
4243 TInt CsenConnectionTester::UT_CSenServiceConnection_TestMessengerL( ) |
|
4244 { |
|
4245 RegisterSTSL(); |
|
4246 |
|
4247 CreateConnectionToMessengerServiceL(); |
|
4248 |
|
4249 StartActiveScheduler(1); |
|
4250 |
|
4251 LOCAL_ASSERT(iConnectionState == KSenConnectionStatusReady); |
|
4252 TL (iServiceConnection != (CSenServiceConnection*)NULL); |
|
4253 |
|
4254 CSenVtcpTransportProperties* pProperties = CreateMSTransportPropertiesL(EMSNMessengerRegister); |
|
4255 CleanupStack::PushL(pProperties); |
|
4256 iServiceConnection->SetTransportPropertiesL(*pProperties->AsUtf8LC()); |
|
4257 CleanupStack::PopAndDestroy(); //pVtcpProperties->AsUtf8LC() |
|
4258 CleanupStack::PopAndDestroy(pProperties); |
|
4259 |
|
4260 TInt sendRetCode(KErrNone); |
|
4261 |
|
4262 // Send Register message to Messenger |
|
4263 CSenSoapMessage2* pSoapMessage = CreateMSSoapMessage(EMSNMessengerRegister); |
|
4264 CleanupStack::PushL(pSoapMessage); |
|
4265 |
|
4266 sendRetCode = iServiceConnection->SendL(*pSoapMessage); |
|
4267 LOCAL_ASSERT(sendRetCode > KErrNone); |
|
4268 |
|
4269 StartActiveScheduler(1); |
|
4270 |
|
4271 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
4272 CleanupStack::PopAndDestroy(pSoapMessage); |
|
4273 |
|
4274 // Send UnRegister message to Messenger |
|
4275 pSoapMessage = CreateMSSoapMessage(EMSNMessengerUnRegister); |
|
4276 CleanupStack::PushL(pSoapMessage); |
|
4277 |
|
4278 sendRetCode = iServiceConnection->SendL(*pSoapMessage); |
|
4279 LOCAL_ASSERT(sendRetCode > KErrNone); |
|
4280 |
|
4281 StartActiveScheduler(1); |
|
4282 |
|
4283 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
4284 CleanupStack::PopAndDestroy(pSoapMessage); |
|
4285 |
|
4286 delete iServiceConnection; |
|
4287 iServiceConnection = NULL; |
|
4288 return KErrNone; |
|
4289 } |
|
4290 |
|
4291 TInt CsenConnectionTester::UT_CSenServiceConnection_TestMessenger2L( ) |
|
4292 { |
|
4293 UnregisterSTSL(); |
|
4294 RegisterSTSL(); |
|
4295 |
|
4296 CreateConnectionToMessengerServiceL(); |
|
4297 |
|
4298 StartActiveScheduler(1); |
|
4299 |
|
4300 LOCAL_ASSERT(iConnectionState == KSenConnectionStatusReady); |
|
4301 TL (iServiceConnection != (CSenServiceConnection*)NULL); |
|
4302 |
|
4303 CSenVtcpTransportProperties* pProperties = CreateMSTransportPropertiesL(EMSNMessengerRegister); |
|
4304 CleanupStack::PushL(pProperties); |
|
4305 iServiceConnection->SetTransportPropertiesL(*pProperties->AsUtf8LC()); |
|
4306 CleanupStack::PopAndDestroy(); //pVtcpProperties->AsUtf8LC() |
|
4307 CleanupStack::PopAndDestroy(pProperties); |
|
4308 |
|
4309 TInt sendRetCode(KErrNone); |
|
4310 |
|
4311 // Send Register message to Messenger |
|
4312 CSenSoapMessage2* pSoapMessage = CreateMSSoapMessage(EMSNMessengerRegister); |
|
4313 CleanupStack::PushL(pSoapMessage); |
|
4314 |
|
4315 sendRetCode = iServiceConnection->SendL(*pSoapMessage); |
|
4316 LOCAL_ASSERT(sendRetCode > KErrNone); |
|
4317 |
|
4318 StartActiveScheduler(1); |
|
4319 |
|
4320 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
4321 CleanupStack::PopAndDestroy(pSoapMessage); |
|
4322 |
|
4323 // Send UnRegister message to Messenger |
|
4324 pSoapMessage = CreateMSSoapMessage(EMSNMessengerUnRegister); |
|
4325 CleanupStack::PushL(pSoapMessage); |
|
4326 |
|
4327 sendRetCode = iServiceConnection->SendL(*pSoapMessage); |
|
4328 LOCAL_ASSERT(sendRetCode > KErrNone); |
|
4329 |
|
4330 StartActiveScheduler(1); |
|
4331 |
|
4332 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
4333 CleanupStack::PopAndDestroy(pSoapMessage); |
|
4334 |
|
4335 CSenServiceManager* pManager = CSenServiceManager::NewLC(); |
|
4336 |
|
4337 // Get used IdentityProvider from ServiceConnection |
|
4338 CSenIdentityProvider* pIdp = NULL; |
|
4339 iServiceConnection->IdentityProviderL(pIdp); |
|
4340 CleanupStack::PushL(pIdp); |
|
4341 |
|
4342 // Get used Credential from Credentials DB |
|
4343 RCredentialArray credentialArray; |
|
4344 CleanupClosePushL(credentialArray); |
|
4345 RCredentialPropertiesArray credentialPropertiesArray; |
|
4346 CleanupClosePushL(credentialPropertiesArray); |
|
4347 LOCAL_ASSERT((pManager->CredentialsL(KMessagingEndpoint, *pIdp, |
|
4348 credentialArray, |
|
4349 credentialPropertiesArray)) == KErrNone); |
|
4350 |
|
4351 // Check that atleast one Credential were found. |
|
4352 LOCAL_ASSERT(credentialArray.Count() > 0); |
|
4353 |
|
4354 CleanupStack::Pop(&credentialPropertiesArray); |
|
4355 CleanupStack::Pop(&credentialArray); |
|
4356 CleanupStack::Pop(pIdp); |
|
4357 CleanupStack::PopAndDestroy(pManager); |
|
4358 |
|
4359 delete iServiceConnection; |
|
4360 iServiceConnection = NULL; |
|
4361 |
|
4362 CleanupStack::PushL(pIdp); |
|
4363 CleanupClosePushL(credentialArray); |
|
4364 CleanupClosePushL(credentialPropertiesArray); |
|
4365 |
|
4366 // Clean DBs STARTS |
|
4367 // 1) Unregister STS ServiceDescription and |
|
4368 // STS IdentityProvider |
|
4369 // => Unregistering IdentityProvider removes |
|
4370 // related Credentials from Credentials DB |
|
4371 // |
|
4372 UnregisterSTSL(); |
|
4373 |
|
4374 // 2) Unregister actual Service (= Messaging) ServiceDescription |
|
4375 pManager = CSenServiceManager::NewLC(); |
|
4376 CSenXmlServiceDescription* pPattern = CSenXmlServiceDescription::NewLC(); |
|
4377 pPattern->SetFrameworkIdL(KDefaultWSStarFrameworkID); |
|
4378 pPattern->SetEndPointL(KMessagingEndpoint); |
|
4379 pPattern->SetContractL(KMessagingContract); |
|
4380 TInt error = pManager->UnregisterServiceDescriptionL( *pPattern); |
|
4381 CleanupStack::PopAndDestroy(pPattern); |
|
4382 CleanupStack::PopAndDestroy(pManager); |
|
4383 // Clean DBs ENDS |
|
4384 |
|
4385 RegisterSTSL(); |
|
4386 |
|
4387 pManager = CSenServiceManager::NewLC(); |
|
4388 |
|
4389 // Add Credential to Credentials DB |
|
4390 // => When Connection is initialized, working Credential |
|
4391 // should be found from Credentials DB |
|
4392 // => Working Credential should be used and |
|
4393 // request to get new SecurityToken should NOT be sent. |
|
4394 LOCAL_ASSERT((pManager->AddCredentialL(KMessagingEndpoint, |
|
4395 *pIdp, |
|
4396 *credentialArray[0], |
|
4397 *credentialPropertiesArray[0])) == KErrNone); |
|
4398 |
|
4399 CleanupStack::PopAndDestroy(pManager); |
|
4400 credentialPropertiesArray.ResetAndDestroy(); |
|
4401 CleanupStack::PopAndDestroy(&credentialPropertiesArray); |
|
4402 credentialArray.ResetAndDestroy(); |
|
4403 CleanupStack::PopAndDestroy(&credentialArray); |
|
4404 CleanupStack::PopAndDestroy(pIdp); |
|
4405 |
|
4406 CreateConnectionToMessengerServiceL(); |
|
4407 |
|
4408 StartActiveScheduler(1); |
|
4409 |
|
4410 LOCAL_ASSERT(iConnectionState == KSenConnectionStatusReady); |
|
4411 TL (iServiceConnection != (CSenServiceConnection*)NULL); |
|
4412 |
|
4413 pProperties = CreateMSTransportPropertiesL(EMSNMessengerRegister); |
|
4414 CleanupStack::PushL(pProperties); |
|
4415 iServiceConnection->SetTransportPropertiesL(*pProperties->AsUtf8LC()); |
|
4416 CleanupStack::PopAndDestroy(); //pVtcpProperties->AsUtf8LC() |
|
4417 CleanupStack::PopAndDestroy(pProperties); |
|
4418 |
|
4419 // Send Register message to Messenger |
|
4420 pSoapMessage = CreateMSSoapMessage(EMSNMessengerRegister); |
|
4421 CleanupStack::PushL(pSoapMessage); |
|
4422 |
|
4423 sendRetCode = iServiceConnection->SendL(*pSoapMessage); |
|
4424 LOCAL_ASSERT(sendRetCode > KErrNone); |
|
4425 |
|
4426 StartActiveScheduler(1); |
|
4427 |
|
4428 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
4429 CleanupStack::PopAndDestroy(pSoapMessage); |
|
4430 |
|
4431 // Send UnRegister message to Messenger |
|
4432 pSoapMessage = CreateMSSoapMessage(EMSNMessengerUnRegister); |
|
4433 CleanupStack::PushL(pSoapMessage); |
|
4434 |
|
4435 sendRetCode = iServiceConnection->SendL(*pSoapMessage); |
|
4436 LOCAL_ASSERT(sendRetCode > KErrNone); |
|
4437 |
|
4438 StartActiveScheduler(1); |
|
4439 |
|
4440 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
4441 CleanupStack::PopAndDestroy(pSoapMessage); |
|
4442 |
|
4443 delete iServiceConnection; |
|
4444 iServiceConnection = NULL; |
|
4445 return KErrNone; |
|
4446 } |
|
4447 |
|
4448 TInt CsenConnectionTester::UT_CSenServiceConnection_TestMessenger3L( ) |
|
4449 { |
|
4450 UnregisterSTSL(); |
|
4451 |
|
4452 CSenServiceManager* manager = CSenServiceManager::NewLC(); |
|
4453 _LIT8(KWsStarContract, "urn:wstar:sts"); |
|
4454 _LIT8(KAddressing, "http://schemas.xmlsoap.org/ws/2006/10/addressing"); |
|
4455 _LIT8(KInvalidPassportPass, "Invalid"); |
|
4456 |
|
4457 iAuthInfoAskCounter = 0; |
|
4458 //Create Identity provider for STS |
|
4459 ipProviderForAuthProvider = CSenIdentityProvider::NewL(KStsEndpoint); |
|
4460 ipProviderForAuthProvider->SetContractL(KWsStarContract);//(TDesC8) |
|
4461 ipProviderForAuthProvider->SetFrameworkIdL(KDefaultWSStarFrameworkID); |
|
4462 ipProviderForAuthProvider->SetProviderID(KProviderId); |
|
4463 ipProviderForAuthProvider->SetUserInfoL( KPassportUser, KPassportUser, KPassportPass); |
|
4464 |
|
4465 //register Identity provider for STS |
|
4466 CSenIdentityProvider* pInvalidStsProvider = CSenIdentityProvider::NewLC(KStsEndpoint); |
|
4467 pInvalidStsProvider->SetContractL(KWsStarContract);//(TDesC8) |
|
4468 pInvalidStsProvider->SetFrameworkIdL(KDefaultWSStarFrameworkID); |
|
4469 pInvalidStsProvider->SetProviderID(KProviderId); |
|
4470 pInvalidStsProvider->SetUserInfoL( KPassportUser, KPassportUser, KInvalidPassportPass); |
|
4471 //pInvalidStsProvider->AsElement().AddAttrL(_L8("promptUserInfo"),_L8("false")); |
|
4472 manager->RegisterIdentityProviderL( *pInvalidStsProvider ); |
|
4473 CleanupStack::PopAndDestroy(pInvalidStsProvider); |
|
4474 |
|
4475 //register SD for STS |
|
4476 CSenXmlServiceDescription* pattern = CSenXmlServiceDescription::NewLC();//KNullDesC8(), KWsStarContract); |
|
4477 pattern->SetFrameworkIdL(KDefaultWSStarFrameworkID); |
|
4478 pattern->SetContractL(KWsStarContract); |
|
4479 pattern->SetEndPointL(KStsEndpoint); |
|
4480 pattern->AsElement().AddElementL(_L8("ProviderID")).SetContentL(KProviderId); |
|
4481 SetPolicyL(pattern, KPolicyAdr, KAddressing); //this RST2 |
|
4482 SetPolicyL(pattern, KPolicySOAP12, KNullDesC8); //this RST2 |
|
4483 |
|
4484 SetPolicyL(pattern, KPolicyMT, KMetadataEndpoint); |
|
4485 SetPolicyL(pattern, KPolicyPassExt, KNullDesC8); |
|
4486 SetPolicyL(pattern, KPolicyTLS, KNullDesC8); |
|
4487 TInt error = manager->RegisterServiceDescriptionL( *pattern); |
|
4488 |
|
4489 CleanupStack::PopAndDestroy(pattern); |
|
4490 CleanupStack::PopAndDestroy(manager); |
|
4491 |
|
4492 CreateConnectionToMessengerServiceL(); |
|
4493 |
|
4494 StartActiveScheduler(1); |
|
4495 |
|
4496 // Check that authentication info were asked exactly 3 times. |
|
4497 LOCAL_ASSERT(iAuthInfoAskCounter == 1); |
|
4498 |
|
4499 // |
|
4500 LOCAL_ASSERT(iConnectionState == KSenConnectionStatusReady ); |
|
4501 TL (iServiceConnection != (CSenServiceConnection*)NULL); |
|
4502 |
|
4503 CSenVtcpTransportProperties* pProperties = CreateMSTransportPropertiesL(EMSNMessengerRegister); |
|
4504 CleanupStack::PushL(pProperties); |
|
4505 iServiceConnection->SetTransportPropertiesL(*pProperties->AsUtf8LC()); |
|
4506 CleanupStack::PopAndDestroy(); //pVtcpProperties->AsUtf8LC() |
|
4507 CleanupStack::PopAndDestroy(pProperties); |
|
4508 |
|
4509 TInt sendRetCode(KErrNone); |
|
4510 |
|
4511 // Send Register message to Messenger |
|
4512 CSenSoapMessage2* pSoapMessage = CreateMSSoapMessage(EMSNMessengerRegister); |
|
4513 CleanupStack::PushL(pSoapMessage); |
|
4514 |
|
4515 sendRetCode = iServiceConnection->SendL(*pSoapMessage); |
|
4516 LOCAL_ASSERT(sendRetCode > KErrNone); |
|
4517 |
|
4518 StartActiveScheduler(1); |
|
4519 |
|
4520 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
4521 CleanupStack::PopAndDestroy(pSoapMessage); |
|
4522 |
|
4523 // Send UnRegister message to Messenger |
|
4524 pSoapMessage = CreateMSSoapMessage(EMSNMessengerUnRegister); |
|
4525 CleanupStack::PushL(pSoapMessage); |
|
4526 |
|
4527 sendRetCode = iServiceConnection->SendL(*pSoapMessage); |
|
4528 LOCAL_ASSERT(sendRetCode > KErrNone); |
|
4529 |
|
4530 StartActiveScheduler(1); |
|
4531 |
|
4532 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
4533 CleanupStack::PopAndDestroy(pSoapMessage); |
|
4534 |
|
4535 delete iServiceConnection; |
|
4536 iServiceConnection = NULL; |
|
4537 |
|
4538 delete ipProviderForAuthProvider; |
|
4539 ipProviderForAuthProvider = NULL; |
|
4540 return KErrNone; |
|
4541 } |
|
4542 |
|
4543 TInt CsenConnectionTester::UT_CSenServiceConnection_TestMessenger4L( ) |
|
4544 { |
|
4545 UnregisterSTSL(); |
|
4546 |
|
4547 CSenServiceManager* manager = CSenServiceManager::NewLC(); |
|
4548 _LIT8(KWsStarContract, "urn:wstar:sts"); |
|
4549 _LIT8(KAddressing, "http://schemas.xmlsoap.org/ws/2006/10/addressing"); |
|
4550 _LIT8(KInvalidPassportPass, "Invalid"); |
|
4551 |
|
4552 iAuthInfoAskCounter = 0; |
|
4553 //Create Identity provider for STS |
|
4554 ipProviderForAuthProvider = CSenIdentityProvider::NewL(KStsEndpoint); |
|
4555 ipProviderForAuthProvider->SetContractL(KWsStarContract);//(TDesC8) |
|
4556 ipProviderForAuthProvider->SetFrameworkIdL(KDefaultWSStarFrameworkID); |
|
4557 ipProviderForAuthProvider->SetProviderID(KProviderId); |
|
4558 ipProviderForAuthProvider->SetUserInfoL( KPassportUser, KPassportUser, KInvalidPassportPass); |
|
4559 |
|
4560 //register Identity provider for STS |
|
4561 CSenIdentityProvider* pInvalidStsProvider = CSenIdentityProvider::NewLC(KStsEndpoint); |
|
4562 pInvalidStsProvider->SetContractL(KWsStarContract);//(TDesC8) |
|
4563 pInvalidStsProvider->SetFrameworkIdL(KDefaultWSStarFrameworkID); |
|
4564 pInvalidStsProvider->SetProviderID(KProviderId); |
|
4565 pInvalidStsProvider->SetUserInfoL( KPassportUser, KPassportUser, KInvalidPassportPass); |
|
4566 manager->RegisterIdentityProviderL( *pInvalidStsProvider ); |
|
4567 CleanupStack::PopAndDestroy(pInvalidStsProvider); |
|
4568 |
|
4569 //register SD for STS |
|
4570 CSenXmlServiceDescription* pattern = CSenXmlServiceDescription::NewLC();//KNullDesC8(), KWsStarContract); |
|
4571 pattern->SetFrameworkIdL(KDefaultWSStarFrameworkID); |
|
4572 pattern->SetContractL(KWsStarContract); |
|
4573 pattern->SetEndPointL(KStsEndpoint); |
|
4574 pattern->AsElement().AddElementL(_L8("ProviderID")).SetContentL(KProviderId); |
|
4575 SetPolicyL(pattern, KPolicyAdr, KAddressing); //this RST2 |
|
4576 SetPolicyL(pattern, KPolicySOAP12, KNullDesC8); //this RST2 |
|
4577 |
|
4578 SetPolicyL(pattern, KPolicyMT, KMetadataEndpoint); |
|
4579 SetPolicyL(pattern, KPolicyPassExt, KNullDesC8); |
|
4580 SetPolicyL(pattern, KPolicyTLS, KNullDesC8); |
|
4581 TInt error = manager->RegisterServiceDescriptionL( *pattern); |
|
4582 |
|
4583 CleanupStack::PopAndDestroy(pattern); |
|
4584 CleanupStack::PopAndDestroy(manager); |
|
4585 |
|
4586 CreateConnectionToMessengerServiceL(); |
|
4587 |
|
4588 StartActiveScheduler(1); |
|
4589 |
|
4590 // Check that authentication info were asked exactly 3 times. |
|
4591 LOCAL_ASSERT(iAuthInfoAskCounter == 3); |
|
4592 |
|
4593 LOCAL_ASSERT(iConnectionState == KSenConnectionStatusCreateFailed ); |
|
4594 |
|
4595 delete iServiceConnection; |
|
4596 iServiceConnection = NULL; |
|
4597 |
|
4598 delete ipProviderForAuthProvider; |
|
4599 ipProviderForAuthProvider = NULL; |
|
4600 return KErrNone; |
|
4601 } |
|
4602 |
|
4603 TInt CsenConnectionTester::UT_CSenServiceConnection_TestMessenger5L( ) |
|
4604 { |
|
4605 UnregisterSTSL(); |
|
4606 CSenServiceManager* manager = CSenServiceManager::NewLC(); |
|
4607 _LIT8(KWsStarContract, "urn:wstar:sts"); |
|
4608 _LIT8(KAddressing, "http://schemas.xmlsoap.org/ws/2006/10/addressing"); |
|
4609 _LIT8(KInvalidPassportPass, "Invalid"); |
|
4610 |
|
4611 iAuthInfoAskCounter = 0; |
|
4612 //Create Identity provider for STS |
|
4613 ipProviderForAuthProvider = CSenIdentityProvider::NewL(KStsEndpoint); |
|
4614 ipProviderForAuthProvider->SetContractL(KWsStarContract);//(TDesC8) |
|
4615 ipProviderForAuthProvider->SetFrameworkIdL(KDefaultWSStarFrameworkID); |
|
4616 ipProviderForAuthProvider->SetProviderID(KProviderId); |
|
4617 ipProviderForAuthProvider->SetUserInfoL( KPassportUser, KPassportUser, KInvalidPassportPass); |
|
4618 |
|
4619 //register Identity provider for STS |
|
4620 CSenIdentityProvider* pInvalidStsProvider = CSenIdentityProvider::NewLC(KStsEndpoint); |
|
4621 pInvalidStsProvider->SetContractL(KWsStarContract);//(TDesC8) |
|
4622 pInvalidStsProvider->SetFrameworkIdL(KDefaultWSStarFrameworkID); |
|
4623 pInvalidStsProvider->SetProviderID(KProviderId); |
|
4624 pInvalidStsProvider->SetUserInfoL( KPassportUser, KPassportUser, KInvalidPassportPass); |
|
4625 pInvalidStsProvider->AsElement().AddAttrL(_L8("promptUserInfo"),_L8("false")); |
|
4626 manager->RegisterIdentityProviderL( *pInvalidStsProvider ); |
|
4627 CleanupStack::PopAndDestroy(pInvalidStsProvider); |
|
4628 |
|
4629 //register SD for STS |
|
4630 CSenXmlServiceDescription* pattern = CSenXmlServiceDescription::NewLC();//KNullDesC8(), KWsStarContract); |
|
4631 pattern->SetFrameworkIdL(KDefaultWSStarFrameworkID); |
|
4632 pattern->SetContractL(KWsStarContract); |
|
4633 pattern->SetEndPointL(KStsEndpoint); |
|
4634 pattern->AsElement().AddElementL(_L8("ProviderID")).SetContentL(KProviderId); |
|
4635 SetPolicyL(pattern, KPolicyAdr, KAddressing); //this RST2 |
|
4636 SetPolicyL(pattern, KPolicySOAP12, KNullDesC8); //this RST2 |
|
4637 |
|
4638 SetPolicyL(pattern, KPolicyMT, KMetadataEndpoint); |
|
4639 SetPolicyL(pattern, KPolicyPassExt, KNullDesC8); |
|
4640 SetPolicyL(pattern, KPolicyTLS, KNullDesC8); |
|
4641 TInt error = manager->RegisterServiceDescriptionL( *pattern); |
|
4642 |
|
4643 CleanupStack::PopAndDestroy(pattern); |
|
4644 CleanupStack::PopAndDestroy(manager); |
|
4645 |
|
4646 CreateConnectionToMessengerServiceL(); |
|
4647 |
|
4648 StartActiveScheduler(1); |
|
4649 |
|
4650 // Check that authentication info were asked exactly 3 times. |
|
4651 LOCAL_ASSERT( iAuthInfoAskCounter == 0 ); |
|
4652 |
|
4653 LOCAL_ASSERT( iConnectionState == KSenConnectionStatusCreateFailed ); |
|
4654 |
|
4655 delete iServiceConnection; |
|
4656 iServiceConnection = NULL; |
|
4657 |
|
4658 delete ipProviderForAuthProvider; |
|
4659 ipProviderForAuthProvider = NULL; |
|
4660 return KErrNone; |
|
4661 } |
|
4662 |
|
4663 TInt CsenConnectionTester::UT_CSenServiceConnection_TestMessenger6L( ) |
|
4664 { |
|
4665 CSenServiceManager* manager = CSenServiceManager::NewLC(); |
|
4666 _LIT8(KWsStarContract, "urn:wstar:sts"); |
|
4667 _LIT8(KAddressing, "http://schemas.xmlsoap.org/ws/2006/10/addressing"); |
|
4668 _LIT8(KInvalidPassportPass, "Invalid"); |
|
4669 |
|
4670 //register Identity provider for STS |
|
4671 CSenIdentityProvider* pInvalidStsProvider = CSenIdentityProvider::NewLC(KStsEndpoint); |
|
4672 pInvalidStsProvider->SetContractL(KWsStarContract);//(TDesC8) |
|
4673 pInvalidStsProvider->SetFrameworkIdL(KDefaultWSStarFrameworkID); |
|
4674 pInvalidStsProvider->SetProviderID(KProviderId); |
|
4675 pInvalidStsProvider->SetUserInfoL( KPassportUser, KPassportUser, KInvalidPassportPass); |
|
4676 manager->RegisterIdentityProviderL( *pInvalidStsProvider ); |
|
4677 CleanupStack::PopAndDestroy(pInvalidStsProvider); |
|
4678 |
|
4679 //register SD for STS |
|
4680 CSenXmlServiceDescription* pattern = CSenXmlServiceDescription::NewLC();//KNullDesC8(), KWsStarContract); |
|
4681 pattern->SetFrameworkIdL(KDefaultWSStarFrameworkID); |
|
4682 pattern->SetContractL(KWsStarContract); |
|
4683 pattern->SetEndPointL(KStsEndpoint); |
|
4684 pattern->AsElement().AddElementL(_L8("ProviderID")).SetContentL(KProviderId); |
|
4685 SetPolicyL(pattern, KPolicyAdr, KAddressing); //this RST2 |
|
4686 SetPolicyL(pattern, KPolicySOAP12, KNullDesC8); //this RST2 |
|
4687 |
|
4688 SetPolicyL(pattern, KPolicyMT, KMetadataEndpoint); |
|
4689 SetPolicyL(pattern, KPolicyPassExt, KNullDesC8); |
|
4690 SetPolicyL(pattern, KPolicyTLS, KNullDesC8); |
|
4691 TInt error = manager->RegisterServiceDescriptionL( *pattern); |
|
4692 |
|
4693 CleanupStack::PopAndDestroy(pattern); |
|
4694 CleanupStack::PopAndDestroy(manager); |
|
4695 |
|
4696 CreateConnectionToMessengerServiceWithoutCallbackL(); |
|
4697 |
|
4698 StartActiveScheduler(1); |
|
4699 |
|
4700 LOCAL_ASSERT(iConnectionState == KSenConnectionStatusReady); |
|
4701 TL (iServiceConnection != (CSenServiceConnection*)NULL); |
|
4702 |
|
4703 CSenVtcpTransportProperties* pProperties = CreateMSTransportPropertiesL(EMSNMessengerRegister); |
|
4704 CleanupStack::PushL(pProperties); |
|
4705 iServiceConnection->SetTransportPropertiesL(*pProperties->AsUtf8LC()); |
|
4706 CleanupStack::PopAndDestroy(); //pVtcpProperties->AsUtf8LC() |
|
4707 CleanupStack::PopAndDestroy(pProperties); |
|
4708 |
|
4709 TInt sendRetCode(KErrNone); |
|
4710 |
|
4711 // Send Register message to Messenger |
|
4712 CSenSoapMessage2* pSoapMessage = CreateMSSoapMessage(EMSNMessengerRegister); |
|
4713 CleanupStack::PushL(pSoapMessage); |
|
4714 |
|
4715 sendRetCode = iServiceConnection->SendL(*pSoapMessage); |
|
4716 LOCAL_ASSERT(sendRetCode > KErrNone); |
|
4717 |
|
4718 StartActiveScheduler(1); |
|
4719 |
|
4720 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
4721 CleanupStack::PopAndDestroy(pSoapMessage); |
|
4722 |
|
4723 // Send UnRegister message to Messenger |
|
4724 pSoapMessage = CreateMSSoapMessage(EMSNMessengerUnRegister); |
|
4725 CleanupStack::PushL(pSoapMessage); |
|
4726 |
|
4727 sendRetCode = iServiceConnection->SendL(*pSoapMessage); |
|
4728 LOCAL_ASSERT(sendRetCode > KErrNone); |
|
4729 |
|
4730 StartActiveScheduler(1); |
|
4731 |
|
4732 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
4733 CleanupStack::PopAndDestroy(pSoapMessage); |
|
4734 |
|
4735 delete iServiceConnection; |
|
4736 iServiceConnection = NULL; |
|
4737 return KErrNone; |
|
4738 } |
|
4739 |
|
4740 TInt CsenConnectionTester::UT_CSenServiceConnection_TestMessenger7L( ) |
|
4741 { |
|
4742 // Create one "fake" ServiceManager instance which keeps |
|
4743 // Serene server up and running through whole test case. |
|
4744 CSenServiceManager* manager = CSenServiceManager::NewLC(); |
|
4745 |
|
4746 UnregisterSTSL(); |
|
4747 RegisterSTSL(); |
|
4748 |
|
4749 CreateConnectionToMessengerServiceL(); |
|
4750 |
|
4751 StartActiveScheduler(1); |
|
4752 |
|
4753 LOCAL_ASSERT(iConnectionState == KSenConnectionStatusReady); |
|
4754 TL (iServiceConnection != (CSenServiceConnection*)NULL); |
|
4755 |
|
4756 CSenVtcpTransportProperties* pProperties = CreateMSTransportPropertiesL(EMSNMessengerRegister); |
|
4757 CleanupStack::PushL(pProperties); |
|
4758 iServiceConnection->SetTransportPropertiesL(*pProperties->AsUtf8LC()); |
|
4759 CleanupStack::PopAndDestroy(); //pVtcpProperties->AsUtf8LC() |
|
4760 CleanupStack::PopAndDestroy(pProperties); |
|
4761 |
|
4762 TInt sendRetCode(KErrNone); |
|
4763 |
|
4764 // Send Register message to Messenger |
|
4765 CSenSoapMessage2* pSoapMessage = CreateMSSoapMessage(EMSNMessengerRegister); |
|
4766 CleanupStack::PushL(pSoapMessage); |
|
4767 |
|
4768 sendRetCode = iServiceConnection->SendL(*pSoapMessage); |
|
4769 LOCAL_ASSERT(sendRetCode > KErrNone); |
|
4770 |
|
4771 StartActiveScheduler(1); |
|
4772 |
|
4773 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
4774 CleanupStack::PopAndDestroy(pSoapMessage); |
|
4775 |
|
4776 // Send UnRegister message to Messenger |
|
4777 pSoapMessage = CreateMSSoapMessage(EMSNMessengerUnRegister); |
|
4778 CleanupStack::PushL(pSoapMessage); |
|
4779 |
|
4780 sendRetCode = iServiceConnection->SendL(*pSoapMessage); |
|
4781 LOCAL_ASSERT(sendRetCode > KErrNone); |
|
4782 |
|
4783 StartActiveScheduler(1); |
|
4784 |
|
4785 LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
4786 CleanupStack::PopAndDestroy(pSoapMessage); |
|
4787 |
|
4788 delete iServiceConnection; |
|
4789 iServiceConnection = NULL; |
|
4790 |
|
4791 // Clean DBs STARTS |
|
4792 // 1) Unregister STS IdentityProvider |
|
4793 // => Unregistering IdentityProvider removes |
|
4794 // related Credentials from Credentials DB |
|
4795 // |
|
4796 UnregisterSTSL(); |
|
4797 // Clean DBs ENDS |
|
4798 |
|
4799 RegisterSTSInvalidPasswordL(); |
|
4800 |
|
4801 CreateConnectionToMessengerServiceL(); |
|
4802 |
|
4803 StartActiveScheduler(1); |
|
4804 |
|
4805 LOCAL_ASSERT( iConnectionState == KSenConnectionStatusCreateFailed ); |
|
4806 LOCAL_ASSERT( iCallback == ECallbackHandleError ); |
|
4807 LOCAL_ASSERT( iErrorCode == -30320 ); // -30320 = KErrSenFailedAuthentication |
|
4808 |
|
4809 delete iServiceConnection; |
|
4810 iServiceConnection = NULL; |
|
4811 |
|
4812 CleanupStack::PopAndDestroy(manager); |
|
4813 return KErrNone; |
|
4814 } |
|
4815 |
|
4816 int CsenConnectionTester::UT_CSenServiceConnection_TP_Custom_Header(const TDesC8& KCustomHttpHeader, |
|
4817 const TDesC8& KCustomHttpHeaderValue) |
|
4818 { |
|
4819 // Set custom HTTP header |
|
4820 // 1. Declare CUSTOM_HTTP_HEADER_NAME and CUSTOM_HTTP_HEADER_VALUE |
|
4821 // 2. Get TP using SC:TransportPropertiesL() |
|
4822 // 3. SendL(MSG, TP::CUSTOM_HTTP_HEADER) // see that CUSTOM_HTTP_HEADER -field is present |
|
4823 // 4. Check from HTTP Transaction logger log that CUSTOM_HTTP_HEADER was used. |
|
4824 |
|
4825 CSenServicePattern* pPattern = CSenServicePattern::NewLC(KAuthServEndpoint, KNullDesC8()); |
|
4826 pPattern->SetFrameworkIdL(*ipFrameworkID); |
|
4827 |
|
4828 iServiceConnection = CSenServiceConnection::NewL(*this, *pPattern); |
|
4829 |
|
4830 CleanupStack::PopAndDestroy(pPattern); |
|
4831 |
|
4832 StartActiveScheduler(1); |
|
4833 //LOCAL_ASSERT(iConnectionState == KSenConnectionStatusReady); |
|
4834 if(iConnectionState != KSenConnectionStatusReady) return KErrCouldNotConnect; |
|
4835 // Connection is ready to be used. |
|
4836 |
|
4837 // 2. Get TP using SC:TransportPropertiesL() |
|
4838 HBufC8* pTransportPropertiesAsXml = NULL; |
|
4839 iServiceConnection->TransportPropertiesL(pTransportPropertiesAsXml); |
|
4840 if ( pTransportPropertiesAsXml ) |
|
4841 { |
|
4842 delete pTransportPropertiesAsXml; |
|
4843 } |
|
4844 |
|
4845 CSenSoapMessage* pSOAPMessage = CreateAuthRequestLC(); |
|
4846 |
|
4847 // 3. SendL(MSG) // with custom header |
|
4848 CSenHttpTransportProperties* pHttpProperties = CSenHttpTransportProperties::NewLC(); |
|
4849 pHttpProperties->SetHttpHeaderL(KLoggerFileNameProperty, KFileName); |
|
4850 pHttpProperties->SetHttpHeaderL(KCustomHttpHeader, KCustomHttpHeaderValue); |
|
4851 TUint32 iapId = SearchIAPIdByNameL(KIAPName); |
|
4852 pHttpProperties->SetIapIdL(iapId); |
|
4853 HBufC8* pSerializedProperties = pHttpProperties->AsUtf8L(); |
|
4854 CleanupStack::PushL(pSerializedProperties); |
|
4855 iServiceConnection->SendL(*pSOAPMessage, *pSerializedProperties); |
|
4856 StartActiveScheduler(1); |
|
4857 //LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
4858 |
|
4859 CleanupStack::PopAndDestroy(pSerializedProperties); |
|
4860 CleanupStack::PopAndDestroy(pHttpProperties); |
|
4861 |
|
4862 //4. Check from HTTP Transaction logger log that CUSTOM_HTTP_HEADER was used. |
|
4863 HBufC8* pFileContent = ReadFileL(KFileToRead); |
|
4864 //LOCAL_ASSERT(pFileContent != NULL); |
|
4865 if (pFileContent == NULL) return KErrNotFound; |
|
4866 CleanupStack::PushL(pFileContent); |
|
4867 HBufC8* pValue = HttpPropertyValueFromXmlLC(*pFileContent, KCustomHttpHeader); |
|
4868 //LOCAL_ASSERT(pValue == NULL); |
|
4869 if(pValue == NULL) return KErrNotFound; |
|
4870 CleanupStack::PopAndDestroy(pValue); |
|
4871 CleanupStack::PopAndDestroy(pFileContent); |
|
4872 |
|
4873 |
|
4874 CleanupStack::PopAndDestroy(pSOAPMessage); |
|
4875 |
|
4876 |
|
4877 delete iServiceConnection; |
|
4878 iServiceConnection = NULL; |
|
4879 |
|
4880 return KErrNone; |
|
4881 } |
|
4882 |
|
4883 TInt CsenConnectionTester::UT_CSenServiceConnection_TP_Send(const TDesC8& aLogFileName, const TDesC8& aCustomHttpHeader, |
|
4884 const TDesC8& aCustomHttpHeaderValue, CSenServiceConnection* iServiceConnection) |
|
4885 { |
|
4886 TInt result = KErrNone; |
|
4887 CSenSoapMessage* pSOAPMessage = CreateAuthRequestLC(); |
|
4888 |
|
4889 // SendL(MSG) // with custom header |
|
4890 CSenHttpTransportProperties* pHttpProperties = CSenHttpTransportProperties::NewLC(); |
|
4891 pHttpProperties->SetHttpHeaderL(KLoggerFileNameProperty, aLogFileName); |
|
4892 pHttpProperties->SetHttpHeaderL(aCustomHttpHeader, aCustomHttpHeaderValue); |
|
4893 TUint32 iapId = SearchIAPIdByNameL(KIAPName); |
|
4894 pHttpProperties->SetIapIdL(iapId); |
|
4895 HBufC8* pSerializedProperties = pHttpProperties->AsUtf8L(); |
|
4896 CleanupStack::PushL(pSerializedProperties); |
|
4897 iServiceConnection->SendL(*pSOAPMessage, *pSerializedProperties); |
|
4898 StartActiveScheduler(1); |
|
4899 //LOCAL_ASSERT(iCallback == ECallbackHandleMessage); |
|
4900 if(iCallback != ECallbackHandleMessage) return KErrGeneral; |
|
4901 |
|
4902 CleanupStack::PopAndDestroy(pSerializedProperties); |
|
4903 CleanupStack::PopAndDestroy(pHttpProperties); |
|
4904 CleanupStack::PopAndDestroy(pSOAPMessage); |
|
4905 return result; |
|
4906 } |
|
4907 |
|
4908 |
|
4909 TInt CsenConnectionTester::UT_CSenServiceConnection_TP_CheckLogs(const TDesC& aLogFilePath, const TDesC8& aCustomHttpHeader, const TDesC8& aCustomHttpHeaderValue) |
|
4910 { |
|
4911 TInt result = KErrNone; |
|
4912 HBufC8* pFileContent = ReadFileL(aLogFilePath); |
|
4913 //LOCAL_ASSERT(pFileContent != NULL); |
|
4914 if (pFileContent == NULL) return KErrNotFound; |
|
4915 |
|
4916 CleanupStack::PushL(pFileContent); |
|
4917 HBufC8* pValue = HttpPropertyValueFromXmlLC(*pFileContent, aCustomHttpHeader); |
|
4918 //LOCAL_ASSERT(*pValue == aCustomHttpHeaderValue); |
|
4919 if (*pValue != aCustomHttpHeaderValue) return KErrNotFound; |
|
4920 |
|
4921 CleanupStack::PopAndDestroy(pValue); |
|
4922 CleanupStack::PopAndDestroy(pFileContent); |
|
4923 |
|
4924 return result; |
|
4925 } |
|
4926 |
|
4927 |
|
4928 HBufC8* CsenConnectionTester::HttpMethodValueFromXmlLC(const TDesC8& aXml) |
|
4929 { |
|
4930 CSenXmlReader* pReader = CSenXmlReader::NewL(); |
|
4931 CleanupStack::PushL(pReader); |
|
4932 CSenDomFragment* pDom = CSenDomFragment::NewL(); |
|
4933 CleanupStack::PushL(pDom); |
|
4934 pReader->SetContentHandler(*pDom); |
|
4935 pDom->SetReader(*pReader); |
|
4936 pReader->ParseL(aXml); |
|
4937 |
|
4938 CSenElement& element = pDom->AsElement(); |
|
4939 CSenElement* pRequestElement = element.Element(_L8("Request")); |
|
4940 CSenElement* pTPElement = pRequestElement->Element(_L8("Method")); |
|
4941 |
|
4942 HBufC8* pRetBuf = pTPElement->Content().AllocL(); |
|
4943 |
|
4944 CleanupStack::PopAndDestroy(pDom); |
|
4945 CleanupStack::PopAndDestroy(pReader); |
|
4946 |
|
4947 CleanupStack::PushL(pRetBuf); |
|
4948 |
|
4949 return pRetBuf; |
|
4950 } |
|
4951 |
|
4952 TInt CsenConnectionTester::Find(const TDesC8& aDestination, |
|
4953 const TDesC8& aDescToFind, |
|
4954 TInt aStartingPos ) |
|
4955 { |
|
4956 TInt descLength = aDescToFind.Length(); |
|
4957 TInt length = aDestination.Length() - descLength + 1; |
|
4958 for (TInt i = aStartingPos; i < length ; i++) |
|
4959 { |
|
4960 if ( aDestination.Mid(i,descLength) == aDescToFind ) |
|
4961 { |
|
4962 return i; |
|
4963 } |
|
4964 } |
|
4965 |
|
4966 return KErrNotFound; |
|
4967 } |
|
4968 |
|
4969 TBool CsenConnectionTester::ReplaceAll(TPtr8 aDestination, |
|
4970 const TDesC8& aFrom, |
|
4971 const TDesC8& aTo) |
|
4972 { |
|
4973 TInt retVal(EFalse); |
|
4974 |
|
4975 TInt pos = Find(aDestination, aFrom, 0); |
|
4976 if (pos != KErrNotFound) retVal = ETrue; |
|
4977 |
|
4978 while (pos != KErrNotFound) |
|
4979 { |
|
4980 aDestination.Replace(pos,aFrom.Length(),aTo); |
|
4981 pos = Find(aDestination, aFrom, pos+1); |
|
4982 } |
|
4983 |
|
4984 return retVal; |
|
4985 } |
|
4986 |
|
4987 TBool CsenConnectionTester::DecodeHttpCharactersL(const TDesC8& aOriginal, |
|
4988 HBufC8*& aDecoded) |
|
4989 { |
|
4990 // Five basic entities as descriptors |
|
4991 _LIT8(KEscapedApos, "'"); |
|
4992 _LIT8(KEscapedDblQuot, """); |
|
4993 _LIT8(KEscapedGt, ">"); |
|
4994 _LIT8(KEscapedLt, "<"); |
|
4995 _LIT8(KEscapedAmp, "&"); |
|
4996 |
|
4997 // XML-escaping chars as descriptors |
|
4998 _LIT8(KAmpersandDesC8, "&"); |
|
4999 _LIT8(KAposDesC8, "\'"); |
|
5000 _LIT8(KDblQuotDesC8, "\""); |
|
5001 _LIT8(KGtDesC8, ">"); |
|
5002 _LIT8(KLtDesC8, "<"); |
|
5003 |
|
5004 delete aDecoded; |
|
5005 aDecoded = NULL; |
|
5006 |
|
5007 // make a copy of the original |
|
5008 aDecoded = aOriginal.AllocL(); |
|
5009 |
|
5010 TBool retVal(EFalse); |
|
5011 |
|
5012 // replace all five basic entities with XML escaping counterpart, |
|
5013 // if found. |
|
5014 if (ReplaceAll(aDecoded->Des(), KEscapedApos(), KAposDesC8())) |
|
5015 { |
|
5016 retVal = ETrue; |
|
5017 } |
|
5018 if (ReplaceAll(aDecoded->Des(), KEscapedDblQuot(), KDblQuotDesC8())) |
|
5019 { |
|
5020 retVal = ETrue; |
|
5021 } |
|
5022 if (ReplaceAll(aDecoded->Des(), KEscapedGt(), KGtDesC8())) |
|
5023 { |
|
5024 retVal = ETrue; |
|
5025 } |
|
5026 if (ReplaceAll(aDecoded->Des(), KEscapedLt(), KLtDesC8())) |
|
5027 { |
|
5028 retVal = ETrue; |
|
5029 } |
|
5030 if (ReplaceAll(aDecoded->Des(), KEscapedAmp(), KAmpersandDesC8())) |
|
5031 { |
|
5032 retVal = ETrue; |
|
5033 } |
|
5034 |
|
5035 return retVal; |
|
5036 } |
|
5037 |
|
5038 HBufC8* CsenConnectionTester::HttpPropertyValueFromXmlLC(const TDesC8& aXml, |
|
5039 const TDesC8& aPropertyName) |
|
5040 { |
|
5041 CSenXmlReader* pReader = CSenXmlReader::NewL(); |
|
5042 CleanupStack::PushL(pReader); |
|
5043 CSenDomFragment* pDom = CSenDomFragment::NewL(); |
|
5044 CleanupStack::PushL(pDom); |
|
5045 pReader->SetContentHandler(*pDom); |
|
5046 pDom->SetReader(*pReader); |
|
5047 pReader->ParseL(aXml); |
|
5048 |
|
5049 HBufC8* pRetBuf = NULL; |
|
5050 |
|
5051 CSenElement& element = pDom->AsElement(); |
|
5052 CSenElement* pRequestElement = element.Element(_L8("Request")); |
|
5053 if ( pRequestElement ) |
|
5054 { |
|
5055 CSenElement* pTPElement = pRequestElement->Element(_L8("TranportProperties")); |
|
5056 if ( pTPElement ) |
|
5057 { |
|
5058 CSenElement* pElement = pTPElement->Element(aPropertyName); |
|
5059 if ( pElement ) |
|
5060 { |
|
5061 pRetBuf = pElement->Content().AllocL(); |
|
5062 CleanupStack::PushL(pRetBuf); |
|
5063 HBufC8* pNew = NULL; |
|
5064 DecodeHttpCharactersL(*pRetBuf, pNew); |
|
5065 CleanupStack::PopAndDestroy(pRetBuf); |
|
5066 pRetBuf = pNew; |
|
5067 } |
|
5068 } |
|
5069 } |
|
5070 |
|
5071 CleanupStack::PopAndDestroy(pDom); |
|
5072 CleanupStack::PopAndDestroy(pReader); |
|
5073 CleanupStack::PushL(pRetBuf); |
|
5074 return pRetBuf; |
|
5075 } |
|
5076 |
|
5077 HBufC8* CsenConnectionTester::ReadFileL(const TDesC& aFilename) |
|
5078 { |
|
5079 RFs fsSession; |
|
5080 CleanupClosePushL(fsSession); |
|
5081 User::LeaveIfError(fsSession.Connect() == NULL); |
|
5082 TEntry entry; |
|
5083 User::LeaveIfError(fsSession.Entry(aFilename,entry)); |
|
5084 HBufC8* pFileContent = NULL; |
|
5085 RFileReadStream fileInStream; |
|
5086 CleanupClosePushL(fileInStream); |
|
5087 if (fileInStream.Open(fsSession,aFilename,EFileRead) == KErrNone) |
|
5088 { |
|
5089 HBufC8* pTempFileContent = HBufC8::NewLC(entry.iSize+10); |
|
5090 TRAPD(error, |
|
5091 fileInStream.ReadL((TUint8*)pTempFileContent->Ptr(),entry.iSize); |
|
5092 ); |
|
5093 |
|
5094 if (!error) |
|
5095 { |
|
5096 TPtrC8 fileContent((TUint8*)pTempFileContent->Ptr(),entry.iSize); |
|
5097 pFileContent = fileContent.AllocL(); |
|
5098 } |
|
5099 CleanupStack::PopAndDestroy(pTempFileContent); |
|
5100 } |
|
5101 CleanupStack::PopAndDestroy(&fileInStream); |
|
5102 CleanupStack::PopAndDestroy(&fsSession); |
|
5103 return pFileContent; |
|
5104 } |
|
5105 |
|
5106 TUint32 CsenConnectionTester::SearchIAPIdByNameL( const TDesC& aIAPName ) |
|
5107 { |
|
5108 TBool found = EFalse; |
|
5109 CCommsDatabase* pDB = CCommsDatabase::NewL(EDatabaseTypeIAP); |
|
5110 CleanupStack::PushL(pDB); |
|
5111 |
|
5112 //open internet accesspoint table |
|
5113 CCommsDbTableView* pDbTView = pDB->OpenTableLC(TPtrC(IAP)); |
|
5114 TInt retVal = pDbTView->GotoFirstRecord(); |
|
5115 TBuf<128> name; |
|
5116 TUint32 id = 0; |
|
5117 //Find the correct record |
|
5118 while ( retVal == KErrNone && found == EFalse ) |
|
5119 { |
|
5120 pDbTView->ReadTextL(TPtrC(COMMDB_NAME), name); |
|
5121 pDbTView->ReadUintL(TPtrC(COMMDB_ID), id); |
|
5122 found = ( name == aIAPName ); |
|
5123 if ( !found ) |
|
5124 { |
|
5125 retVal = pDbTView->GotoNextRecord(); |
|
5126 } |
|
5127 } |
|
5128 CleanupStack::PopAndDestroy(pDbTView); |
|
5129 CleanupStack::PopAndDestroy(pDB); |
|
5130 return id; |
|
5131 } |
|
5132 |
|
5133 CSenSoapMessage* CsenConnectionTester::CreateAuthRequestLC() |
|
5134 { |
|
5135 _LIT8(KRequest, "<sa:SASLRequest xmlns:sa=\"urn:liberty:sa:2004-04\" mechanism=\"PLAIN ANONYMOUS\" advisoryAuthnID=\"012345678901234\"/>"); |
|
5136 CSenSoapMessage* pSOAPMessage = CSenSoapMessage::NewL(); |
|
5137 CleanupStack::PushL(pSOAPMessage); |
|
5138 |
|
5139 //xxxxxxxx*************** CorrelationHeader starts *************************** |
|
5140 CSenBaseElement* pElement = CSenBaseElement::NewL(_L8("urn:liberty:sb:2003-08"), _L8("Correlation"), _L8("sb:Correlation")); |
|
5141 CleanupStack::PushL(pElement); |
|
5142 |
|
5143 pElement->AddAttrL(_L8("messageID"),_L8("")); |
|
5144 pElement->AddAttrL(_L8("refToMessageID"),_L8("")); |
|
5145 |
|
5146 TTime t; |
|
5147 t.HomeTime(); |
|
5148 TBuf8<SenDateUtils::KXmlDateTimeMaxLength> ts; |
|
5149 SenDateUtils::ToXmlDateTimeUtf8L(ts, t); |
|
5150 pElement->AddAttrL(_L8("timestamp"), ts); |
|
5151 |
|
5152 pSOAPMessage->AddHeaderL(*pElement); // pElement will be owned by pSOAPMessage |
|
5153 CleanupStack::Pop(pElement); |
|
5154 //************************ CorrelationHeader ends **************************** |
|
5155 |
|
5156 pSOAPMessage->SetBodyL(KRequest); |
|
5157 return pSOAPMessage; |
|
5158 } |
|
5159 |
|
5160 CSenSoapMessage2* CsenConnectionTester::CreateNewAuthRequestLC() |
|
5161 { |
|
5162 _LIT8(KRequest, "<sa:SASLRequest xmlns:sa=\"urn:liberty:sa:2004-04\" mechanism=\"PLAIN ANONYMOUS\" advisoryAuthnID=\"012345678901234\"/>"); |
|
5163 CSenSoapMessage2* pSOAPMessage = CSenSoapMessage2::NewL(); |
|
5164 CleanupStack::PushL(pSOAPMessage); |
|
5165 |
|
5166 //xxxxxxxx*************** CorrelationHeader starts *************************** |
|
5167 /*CSenBaseElement* pElement = CSenBaseElement::NewL(_L8("urn:liberty:sb:2003-08"), _L8("Correlation"), _L8("sb:Correlation")); |
|
5168 CleanupStack::PushL(pElement); |
|
5169 |
|
5170 pElement->AddAttrL(_L8("messageID"),_L8("")); |
|
5171 pElement->AddAttrL(_L8("refToMessageID"),_L8("")); |
|
5172 |
|
5173 TTime t; |
|
5174 t.HomeTime(); |
|
5175 TBuf8<SenDateUtils::KXmlDateTimeMaxLength> ts; |
|
5176 SenDateUtils::ToXmlDateTimeUtf8L(ts, t); |
|
5177 pElement->AddAttrL(_L8("timestamp"), ts); |
|
5178 |
|
5179 //pSOAPMessage->AddHeaderL(*pElement); // pElement will be owned by pSOAPMessage |
|
5180 CleanupStack::Pop(pElement);*/ |
|
5181 //************************ CorrelationHeader ends **************************** |
|
5182 |
|
5183 pSOAPMessage->SetBodyL(KRequest); |
|
5184 return pSOAPMessage; |
|
5185 } |
|
5186 |
|
5187 CSenVtcpTransportProperties* CsenConnectionTester::CreateMSTransportPropertiesL(TMSCommands aCommand) |
|
5188 { |
|
5189 #ifdef OLD_MSN_NAMESPACE_2005_08 |
|
5190 _LIT8(KRegisterAct, "http://schemas.live.com/mws/2005/08/messaging/Register"); |
|
5191 _LIT8(KInviteReqAct,"http://schemas.live.com/mws/2005/08/messaging/Invite"); |
|
5192 _LIT8(KSendReqAct,"http://schemas.live.com/mws/2005/08/messaging/Message"); |
|
5193 #else |
|
5194 _LIT8(KRegisterAct, "http://schemas.live.com/mws/2006/10/messaging/Register"); |
|
5195 _LIT8(KInviteReqAct,"http://schemas.live.com/mws/2006/10/messaging/Invite"); |
|
5196 _LIT8(KSendReqAct,"http://schemas.live.com/mws/2006/10/messaging/Message"); |
|
5197 |
|
5198 #endif |
|
5199 |
|
5200 CSenVtcpTransportProperties* pVtcpProperties = CSenVtcpTransportProperties::NewLC(); |
|
5201 pVtcpProperties->SetProxyHostL(KMSNProxy); |
|
5202 //pVtcpProperties->SetOnewayMessageOnOffL(TRUE); |
|
5203 |
|
5204 pVtcpProperties->SetMwsNamespaceL(KMessagingNameSpace); |
|
5205 |
|
5206 switch (aCommand) |
|
5207 { |
|
5208 case EMSNMessengerRegister: |
|
5209 { |
|
5210 pVtcpProperties->SetSoapActionL(KRegisterAct); |
|
5211 break; |
|
5212 } |
|
5213 case EMSNMessengerUnRegister: |
|
5214 { |
|
5215 pVtcpProperties->SetSoapActionL(KRegisterAct); |
|
5216 break; |
|
5217 } |
|
5218 case EMSNMessengerInvite: |
|
5219 { |
|
5220 pVtcpProperties->SetSoapActionL(KInviteReqAct); |
|
5221 break; |
|
5222 } |
|
5223 case EMSNMessengerSend: |
|
5224 { |
|
5225 pVtcpProperties->SetSoapActionL(KSendReqAct); |
|
5226 break; |
|
5227 } |
|
5228 default: |
|
5229 break; |
|
5230 } |
|
5231 |
|
5232 CleanupStack::Pop(pVtcpProperties); |
|
5233 |
|
5234 return pVtcpProperties; |
|
5235 } |
|
5236 |
|
5237 CSenSoapMessage2* CsenConnectionTester::CreateMSSoapMessage(TMSCommands aCommand) |
|
5238 { |
|
5239 #ifdef OLD_MSN_NAMESPACE_2005_08 |
|
5240 _LIT8(KReristerReq, "<sip:RegisterRequest xmlns:sip=\"http://schemas.live.com/mws/2005/08/messaging\">\ |
|
5241 <sip:Expires>240</sip:Expires>\ |
|
5242 <sip:AutoOffline>0</sip:AutoOffline>\ |
|
5243 <sip:Capabilities>1074003969</sip:Capabilities>\ |
|
5244 <sip:SubscribedNotifications>31</sip:SubscribedNotifications>\ |
|
5245 <sip:MessengerArgot sip:Status=\"Online\" sip:PresenceUpdates=\"All\"/>\ |
|
5246 </sip:RegisterRequest>"); |
|
5247 |
|
5248 _LIT8(KUnReristerReq, "<sip:RegisterRequest xmlns:sip=\"http://schemas.live.com/mws/2005/08/messaging\">\ |
|
5249 <sip:Expires>0</sip:Expires>\ |
|
5250 <sip:MessengerArgot sip:Status=\"Online\" sip:PresenceUpdates=\"All\"/>\ |
|
5251 </sip:RegisterRequest>"); |
|
5252 |
|
5253 _LIT8(KInviteReq, |
|
5254 "<sip:InviteRequest xmlns:sip=\"http://schemas.live.com/mws/2005/08/messaging\">\ |
|
5255 <sip:Call>\ |
|
5256 <mc:To xmlns:mc=\"http://schemas.live.com/mws/2005/08/contacts\">7553</mc:To>\ |
|
5257 </sip:Call>\ |
|
5258 </sip:InviteRequest>"); |
|
5259 |
|
5260 _LIT8(KSendReq, |
|
5261 "<sip:MessageRequest xmlns:sip=\"http://schemas.live.com/mws/2005/08/messaging\">\ |
|
5262 <sip:Call>\ |
|
5263 <sip:CallID>1</sip:CallID>\ |
|
5264 </sip:Call>\ |
|
5265 <sip:MessageObject sip:ContentType=\"text/plain\">\ |
|
5266 <sip:MessageBody>lalamido</sip:MessageBody>\ |
|
5267 </sip:MessageObject>\ |
|
5268 </sip:MessageRequest>"); |
|
5269 #else |
|
5270 _LIT8(KReristerReq, "<sip:RegisterRequest xmlns:sip=\"http://schemas.live.com/mws/2006/10/messaging\">\ |
|
5271 <sip:Expires>240</sip:Expires>\ |
|
5272 <sip:AutoOffline>0</sip:AutoOffline>\ |
|
5273 <sip:Capabilities>1074003969</sip:Capabilities>\ |
|
5274 <sip:SubscribedNotifications>31</sip:SubscribedNotifications>\ |
|
5275 <sip:MessengerArgot sip:Status=\"Online\" sip:PresenceUpdates=\"All\"/>\ |
|
5276 </sip:RegisterRequest>"); |
|
5277 |
|
5278 _LIT8(KUnReristerReq, "<sip:RegisterRequest xmlns:sip=\"http://schemas.live.com/mws/2006/10/messaging\">\ |
|
5279 <sip:Expires>0</sip:Expires>\ |
|
5280 <sip:MessengerArgot sip:Status=\"Online\" sip:PresenceUpdates=\"All\"/>\ |
|
5281 </sip:RegisterRequest>"); |
|
5282 |
|
5283 _LIT8(KInviteReq, |
|
5284 "<sip:InviteRequest xmlns:sip=\"http://schemas.live.com/mws/2006/10/messaging\">\ |
|
5285 <sip:Call>\ |
|
5286 <mc:To xmlns:mc=\"http://schemas.live.com/mws/2006/10/contacts\">4878</mc:To>\ |
|
5287 </sip:Call>\ |
|
5288 </sip:InviteRequest>"); |
|
5289 |
|
5290 _LIT8(KSendReq, |
|
5291 "<sip:MessageRequest xmlns:sip=\"http://schemas.live.com/mws/2006/10/messaging\">\ |
|
5292 <sip:Call>\ |
|
5293 <sip:CallID>1</sip:CallID>\ |
|
5294 </sip:Call>\ |
|
5295 <sip:MessageObject sip:ContentType=\"text/plain\">\ |
|
5296 <sip:MessageBody>lalamido</sip:MessageBody>\ |
|
5297 </sip:MessageObject>\ |
|
5298 </sip:MessageRequest>"); |
|
5299 #endif |
|
5300 |
|
5301 CSenSoapMessage2* pMessage = CSenSoapMessage2::NewLC(ESOAP12); |
|
5302 |
|
5303 AddDeviceOptionsHeader2L(*pMessage); |
|
5304 |
|
5305 AddApplicationHeader2L(*pMessage); |
|
5306 |
|
5307 switch (aCommand) |
|
5308 { |
|
5309 case EMSNMessengerRegister: |
|
5310 { |
|
5311 pMessage->SetBodyL(KReristerReq); |
|
5312 break; |
|
5313 } |
|
5314 case EMSNMessengerUnRegister: |
|
5315 { |
|
5316 pMessage->SetBodyL(KUnReristerReq); |
|
5317 break; |
|
5318 } |
|
5319 case EMSNMessengerInvite: |
|
5320 { |
|
5321 pMessage->SetBodyL(KInviteReq); |
|
5322 break; |
|
5323 } |
|
5324 case EMSNMessengerSend: |
|
5325 { |
|
5326 pMessage->SetBodyL(KSendReq); |
|
5327 break; |
|
5328 } |
|
5329 default: |
|
5330 break; |
|
5331 } |
|
5332 |
|
5333 CleanupStack::Pop(pMessage); |
|
5334 |
|
5335 return pMessage; |
|
5336 } |
|
5337 |
|
5338 void CsenConnectionTester::RegisterSTSL() |
|
5339 { |
|
5340 CSenServiceManager* manager = CSenServiceManager::NewLC(); |
|
5341 _LIT8(KWsStarContract, "urn:wstar:sts"); |
|
5342 _LIT8(KAddressing, "http://schemas.xmlsoap.org/ws/2006/10/addressing"); |
|
5343 |
|
5344 //register Identity provider for STS |
|
5345 CSenIdentityProvider* stsProvider = CSenIdentityProvider::NewLC(KStsEndpoint); |
|
5346 stsProvider->SetContractL(KWsStarContract);//(TDesC8) |
|
5347 stsProvider->SetFrameworkIdL(KDefaultWSStarFrameworkID); |
|
5348 stsProvider->SetProviderID(KProviderId); |
|
5349 stsProvider->SetUserInfoL( KPassportUser, KPassportUser, KPassportPass); |
|
5350 manager->RegisterIdentityProviderL( *stsProvider); |
|
5351 CleanupStack::PopAndDestroy(stsProvider); |
|
5352 |
|
5353 //register SD for STS |
|
5354 CSenXmlServiceDescription* pattern = CSenXmlServiceDescription::NewLC();//KNullDesC8(), KWsStarContract); |
|
5355 pattern->SetFrameworkIdL(KDefaultWSStarFrameworkID); |
|
5356 pattern->SetContractL(KWsStarContract); |
|
5357 pattern->SetEndPointL(KStsEndpoint); |
|
5358 pattern->AsElement().AddElementL(_L8("ProviderID")).SetContentL(KProviderId); |
|
5359 SetPolicyL(pattern, KPolicyAdr, KAddressing); //this RST2 |
|
5360 SetPolicyL(pattern, KPolicySOAP12, KNullDesC8); //this RST2 |
|
5361 |
|
5362 SetPolicyL(pattern, KPolicyMT, KMetadataEndpoint); |
|
5363 SetPolicyL(pattern, KPolicyPassExt, KNullDesC8); |
|
5364 SetPolicyL(pattern, KPolicyTLS, KNullDesC8); |
|
5365 TInt error = manager->RegisterServiceDescriptionL( *pattern); |
|
5366 |
|
5367 CleanupStack::PopAndDestroy(pattern); |
|
5368 CleanupStack::PopAndDestroy(manager); |
|
5369 } |
|
5370 |
|
5371 void CsenConnectionTester::RegisterSTSInvalidPasswordL() |
|
5372 { |
|
5373 CSenServiceManager* manager = CSenServiceManager::NewLC(); |
|
5374 _LIT8(KWsStarContract, "urn:wstar:sts"); |
|
5375 _LIT8(KAddressing, "http://schemas.xmlsoap.org/ws/2006/10/addressing"); |
|
5376 |
|
5377 //register Identity provider for STS |
|
5378 CSenIdentityProvider* stsProvider = CSenIdentityProvider::NewLC(KStsEndpoint); |
|
5379 stsProvider->SetContractL(KWsStarContract);//(TDesC8) |
|
5380 stsProvider->SetFrameworkIdL(KDefaultWSStarFrameworkID); |
|
5381 stsProvider->SetProviderID(KProviderId); |
|
5382 stsProvider->SetUserInfoL( KPassportUser, KPassportUser, _L8("Invalid")); |
|
5383 manager->RegisterIdentityProviderL( *stsProvider); |
|
5384 CleanupStack::PopAndDestroy(stsProvider); |
|
5385 |
|
5386 //register SD for STS |
|
5387 CSenXmlServiceDescription* pattern = CSenXmlServiceDescription::NewLC();//KNullDesC8(), KWsStarContract); |
|
5388 pattern->SetFrameworkIdL(KDefaultWSStarFrameworkID); |
|
5389 pattern->SetContractL(KWsStarContract); |
|
5390 pattern->SetEndPointL(KStsEndpoint); |
|
5391 pattern->AsElement().AddElementL(_L8("ProviderID")).SetContentL(KProviderId); |
|
5392 SetPolicyL(pattern, KPolicyAdr, KAddressing); //this RST2 |
|
5393 SetPolicyL(pattern, KPolicySOAP12, KNullDesC8); //this RST2 |
|
5394 |
|
5395 SetPolicyL(pattern, KPolicyMT, KMetadataEndpoint); |
|
5396 SetPolicyL(pattern, KPolicyPassExt, KNullDesC8); |
|
5397 SetPolicyL(pattern, KPolicyTLS, KNullDesC8); |
|
5398 TInt error = manager->RegisterServiceDescriptionL( *pattern); |
|
5399 |
|
5400 CleanupStack::PopAndDestroy(pattern); |
|
5401 CleanupStack::PopAndDestroy(manager); |
|
5402 } |
|
5403 |
|
5404 void CsenConnectionTester::UnregisterSTSL() |
|
5405 { |
|
5406 CSenServiceManager* manager = CSenServiceManager::NewLC(); |
|
5407 _LIT8(KWsStarContract, "urn:wstar:sts"); |
|
5408 _LIT8(KAddressing, "http://schemas.xmlsoap.org/ws/2006/10/addressing"); |
|
5409 |
|
5410 //Unregister Identity provider for STS |
|
5411 CSenIdentityProvider* stsProvider = CSenIdentityProvider::NewLC(KStsEndpoint); |
|
5412 stsProvider->SetContractL(KWsStarContract);//(TDesC8) |
|
5413 stsProvider->SetFrameworkIdL(KDefaultWSStarFrameworkID); |
|
5414 stsProvider->SetProviderID(KProviderId); |
|
5415 stsProvider->SetUserInfoL( KPassportUser, KPassportUser, KPassportPass); |
|
5416 manager->UnregisterIdentityProviderL( *stsProvider); |
|
5417 CleanupStack::PopAndDestroy(stsProvider); |
|
5418 |
|
5419 //Unregister SD for STS |
|
5420 CSenXmlServiceDescription* pattern = CSenXmlServiceDescription::NewLC();//KNullDesC8(), KWsStarContract); |
|
5421 pattern->SetFrameworkIdL(KDefaultWSStarFrameworkID); |
|
5422 pattern->SetContractL(KWsStarContract); |
|
5423 pattern->SetEndPointL(KStsEndpoint); |
|
5424 pattern->AsElement().AddElementL(_L8("ProviderID")).SetContentL(KProviderId); |
|
5425 SetPolicyL(pattern, KPolicyAdr, KAddressing); //this RST2 |
|
5426 SetPolicyL(pattern, KPolicySOAP12, KNullDesC8); //this RST2 |
|
5427 |
|
5428 SetPolicyL(pattern, KPolicyMT, KMetadataEndpoint); |
|
5429 SetPolicyL(pattern, KPolicyPassExt, KNullDesC8); |
|
5430 SetPolicyL(pattern, KPolicyTLS, KNullDesC8); |
|
5431 TInt error = manager->UnregisterServiceDescriptionL( *pattern); |
|
5432 |
|
5433 CleanupStack::PopAndDestroy(pattern); |
|
5434 CleanupStack::PopAndDestroy(manager); |
|
5435 } |
|
5436 |
|
5437 void CsenConnectionTester::SetPolicyL( CSenXmlServiceDescription* pServDesc, |
|
5438 const TDesC8& pName, |
|
5439 const TDesC8& pValue) |
|
5440 { |
|
5441 CSenElement* servicePolicy = pServDesc->AsElement().Element(_L8("ServicePolicy")); |
|
5442 CSenElement* clientPolicy = servicePolicy->Element(_L8("ClientPolicy")); |
|
5443 if(!clientPolicy) |
|
5444 servicePolicy->AddElementL(_L8("ClientPolicy")); |
|
5445 clientPolicy = servicePolicy->Element(_L8("ClientPolicy")); |
|
5446 |
|
5447 if(pValue==KNullDesC8()) |
|
5448 { |
|
5449 clientPolicy->AddElementL(pName); |
|
5450 } |
|
5451 else |
|
5452 { |
|
5453 clientPolicy->AddElementL(pName).SetContentL(pValue); |
|
5454 } |
|
5455 } |
|
5456 |
|
5457 void CsenConnectionTester::CreateConnectionToMessengerServiceL() |
|
5458 { |
|
5459 _LIT8(KAddressing, "http://schemas.xmlsoap.org/ws/2004/08/addressing"); |
|
5460 CSenXmlServiceDescription* pServiceDesc = CSenXmlServiceDescription::NewLC(KMessagingEndpoint, KMessagingContract); |
|
5461 |
|
5462 TUint32 iapId = SearchIAPIdByNameL(KIAPName); |
|
5463 pServiceDesc->SetIapIdL(iapId); |
|
5464 |
|
5465 pServiceDesc->SetFrameworkIdL(KDefaultWSStarFrameworkID); |
|
5466 pServiceDesc->AsElement().AddElementL(_L8("ProviderID")).SetContentL(KProviderId); |
|
5467 SetPolicyL(pServiceDesc, KPolicySOAP12, KNullDesC8); |
|
5468 SetPolicyL(pServiceDesc, KPolicyAdr, KAddressing); |
|
5469 |
|
5470 // create connection |
|
5471 iServiceConnection = CSenServiceConnection::NewL(*this, *pServiceDesc, *this); |
|
5472 CleanupStack::PopAndDestroy(pServiceDesc); |
|
5473 } |
|
5474 |
|
5475 void CsenConnectionTester::CreateConnectionToMessengerServiceWithoutCallbackL() |
|
5476 { |
|
5477 _LIT8(KAddressing, "http://schemas.xmlsoap.org/ws/2004/08/addressing"); |
|
5478 CSenXmlServiceDescription* pServiceDesc = CSenXmlServiceDescription::NewLC(KMessagingEndpoint, KMessagingContract); |
|
5479 |
|
5480 TUint32 iapId = SearchIAPIdByNameL(KIAPName); |
|
5481 pServiceDesc->SetIapIdL(iapId); |
|
5482 |
|
5483 |
|
5484 pServiceDesc->SetFrameworkIdL(KDefaultWSStarFrameworkID); |
|
5485 pServiceDesc->AsElement().AddElementL(_L8("ProviderID")).SetContentL(KProviderId); |
|
5486 SetPolicyL(pServiceDesc, KPolicySOAP12, KNullDesC8); |
|
5487 SetPolicyL(pServiceDesc, KPolicyAdr, KAddressing); |
|
5488 |
|
5489 // create connection |
|
5490 iServiceConnection = CSenServiceConnection::NewL(*this, *pServiceDesc); |
|
5491 CleanupStack::PopAndDestroy(pServiceDesc); |
|
5492 } |
|
5493 |
|
5494 void CsenConnectionTester::AddDeviceOptionsHeader2L(CSenSoapMessage2& aMessage) |
|
5495 { |
|
5496 TXmlEngElement header = aMessage.HeaderL(); |
|
5497 |
|
5498 TXmlEngElement deviceOp = header.AddNewElementL(_L8("DeviceOptions"), |
|
5499 KMessagingNameSpace, |
|
5500 _L8("mws")); |
|
5501 |
|
5502 TXmlEngElement child = deviceOp.AddNewElementSameNsL(_L8("Locale")); |
|
5503 child.AddTextL(_L8("1033")); |
|
5504 |
|
5505 TXmlEngElement child1 = deviceOp.AddNewElementSameNsL(_L8("UserAgent")); |
|
5506 |
|
5507 TXmlEngElement child1_1 = child1.AddNewElementSameNsL(_L8("Manufacturer")); |
|
5508 child1_1.AddTextL(_L8("NO_UserAgent")); |
|
5509 |
|
5510 TXmlEngElement child1_2 = child1.AddNewElementSameNsL(_L8("Model")); |
|
5511 child1_2.AddTextL(_L8("NO_Model")); |
|
5512 |
|
5513 TXmlEngElement child1_3 = child1.AddNewElementSameNsL(_L8("OS")); |
|
5514 |
|
5515 TXmlEngElement child1_3_1 = child1_3.AddNewElementSameNsL(_L8("Name")); |
|
5516 child1_3_1.AddTextL(_L8("NO_OS")); |
|
5517 |
|
5518 TXmlEngElement child1_3_2 = child1_3.AddNewElementSameNsL(_L8("Version")); |
|
5519 child1_3_2.AddTextL(_L8("NO_Version")); |
|
5520 } |
|
5521 |
|
5522 void CsenConnectionTester::AddApplicationHeader2L(CSenSoapMessage2& aMessage) |
|
5523 { |
|
5524 TXmlEngElement header = aMessage.HeaderL(); |
|
5525 |
|
5526 TXmlEngElement application = header.AddNewElementL(_L8("Application"),KMessagingNameSpace,_L8("mws")); |
|
5527 |
|
5528 TXmlEngElement child = application.AddNewElementSameNsL(_L8("Name")); |
|
5529 child.AddTextL(_L8("NO_CLIENT")); |
|
5530 |
|
5531 TXmlEngElement child1 = application.AddNewElementSameNsL(_L8("Vendor")); |
|
5532 child1.AddTextL(_L8("NO_VENDOR")); |
|
5533 |
|
5534 TXmlEngElement child2 = application.AddNewElementSameNsL(_L8("Version")); |
|
5535 child2.AddTextL(_L8("NO_VERSION")); |
|
5536 } |
|
5537 |
|
5538 void CsenConnectionTester::StartActiveScheduler(TInt aNumberOfPendingOps) |
|
5539 { |
|
5540 iNumberOfPendingOps = aNumberOfPendingOps; |
|
5541 CActiveScheduler::Start(); |
|
5542 } |
|
5543 |
|
5544 void CsenConnectionTester::StopActiveScheduler() |
|
5545 { |
|
5546 iNumberOfPendingOps--; |
|
5547 if ( iNumberOfPendingOps == 0 ) |
|
5548 { |
|
5549 CActiveScheduler::Stop(); |
|
5550 } |
|
5551 } |
|
5552 |
|
5553 const CSenIdentityProvider* CsenConnectionTester::IdentityProviderL() const |
|
5554 { |
|
5555 //((UT_CSenServiceConnection*)this)->iAuthInfoAskCounter++; |
|
5556 ((CsenConnectionTester*)this)->iAuthInfoAskCounter++; |
|
5557 |
|
5558 return ipProviderForAuthProvider; |
|
5559 } |
|
5560 TAny* CsenConnectionTester::GetInterfaceByUid( TUid aUID ) |
|
5561 { |
|
5562 return; |
|
5563 } |
|
5564 |
|
5565 // ----------------------------------------------------------------------------- |
|
5566 // CsenConnectionTester::?member_function |
|
5567 // ?implementation_description |
|
5568 // (other items were commented in a header). |
|
5569 // ----------------------------------------------------------------------------- |
|
5570 // |
|
5571 /* |
|
5572 TInt CsenConnectionTester::?member_function( |
|
5573 CItemParser& aItem ) |
|
5574 { |
|
5575 |
|
5576 ?code |
|
5577 |
|
5578 } |
|
5579 */ |
|
5580 |
|
5581 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
5582 // None |
|
5583 |
|
5584 // [End of File] - Do not remove |