|
1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "t_INC035621.h" |
|
17 |
|
18 void CTestFixINC035621::DoRunL() |
|
19 { |
|
20 complete=EFalse; |
|
21 // Create a session and a transaction |
|
22 iSession.OpenL(); |
|
23 InstallAuthenticationL(iSession); |
|
24 // _LIT8(KTestURIString,"http://WapTestName/http_tests/rc/401/private/index.html"); |
|
25 _LIT8(KTestURIString,"WapTestName"); |
|
26 |
|
27 HBufC8* newUrl8 = TSrvAddrVal::ReplaceHostNameL(KTestURIString(), iIniSettingsFile); |
|
28 CleanupStack::PushL(newUrl8); |
|
29 TPtr8 newUriPtr8=newUrl8->Des(); |
|
30 newUriPtr8.Insert(0,_L8("http://")); |
|
31 newUriPtr8.Append(_L8("/http_tests/rc/401/private/index.html")); |
|
32 |
|
33 TUriParser8 uri8; |
|
34 // uri8.Parse(*newUrl8); // -- old |
|
35 uri8.Parse(newUriPtr8); |
|
36 |
|
37 |
|
38 iMyStrP = iSession.StringPool(); |
|
39 iTransaction = iSession.OpenTransactionL(uri8, *this); |
|
40 |
|
41 iError = KErrGeneral; |
|
42 |
|
43 // Submit a transaction |
|
44 iTransaction.SubmitL(); |
|
45 |
|
46 // Run the test |
|
47 CActiveScheduler::Start(); |
|
48 |
|
49 CleanupStack::PopAndDestroy(newUrl8); |
|
50 |
|
51 iSession.Close(); |
|
52 |
|
53 // Leave if it hasn't passed. |
|
54 User::LeaveIfError(iError); |
|
55 } |
|
56 |
|
57 void CTestFixINC035621::DoCancel() |
|
58 { |
|
59 } |
|
60 |
|
61 |
|
62 TInt CTestFixINC035621::MHFRunError(TInt /*aError*/, |
|
63 RHTTPTransaction aTransaction, |
|
64 const THTTPEvent& /*aEvent*/) |
|
65 { |
|
66 aTransaction.Fail(); |
|
67 return 0; |
|
68 } |
|
69 |
|
70 CTestFixINC035621* CTestFixINC035621::NewLC(CScriptFile* aIniSettingsFile) |
|
71 { |
|
72 CTestFixINC035621* that = new (ELeave) CTestFixINC035621(aIniSettingsFile); |
|
73 CleanupStack::PushL(that); |
|
74 return that; |
|
75 } |
|
76 |
|
77 CTestFixINC035621::CTestFixINC035621(CScriptFile* aIniSettingsFile) : |
|
78 CHttpTestBase(), |
|
79 iIniSettingsFile(aIniSettingsFile) |
|
80 { |
|
81 } |
|
82 |
|
83 CTestFixINC035621::~CTestFixINC035621() |
|
84 { |
|
85 } |
|
86 |
|
87 |
|
88 void CTestFixINC035621::MHFRunL(RHTTPTransaction aTransaction, |
|
89 const THTTPEvent& aEvent) |
|
90 { |
|
91 switch(aEvent.iStatus) |
|
92 { |
|
93 case THTTPEvent::ESucceeded: |
|
94 { |
|
95 if (!complete) |
|
96 { |
|
97 complete=ETrue; |
|
98 // _LIT8(KTestURIString,"http://WapTestName/http_tests/rc/401/private/dumpform.pl"); |
|
99 _LIT8(KTestURIString,"WapTestName"); |
|
100 |
|
101 HBufC8* newUrl8 = TSrvAddrVal::ReplaceHostNameL(KTestURIString(), iIniSettingsFile); |
|
102 CleanupStack::PushL(newUrl8); |
|
103 TPtr8 newUriPtr8=newUrl8->Des(); |
|
104 newUriPtr8.Insert(0,_L8("http://")); |
|
105 newUriPtr8.Append(_L8("/http_tests/rc/401/private/dumpform.pl")); |
|
106 |
|
107 TUriParser8 uri8; |
|
108 // uri8.Parse(*newUrl8); // -- old |
|
109 uri8.Parse(newUriPtr8); |
|
110 |
|
111 iTransaction = iSession.OpenTransactionL(uri8, *this); |
|
112 |
|
113 // Submit a transaction |
|
114 iTransaction.SubmitL(); |
|
115 |
|
116 CleanupStack::PopAndDestroy(newUrl8); |
|
117 } |
|
118 else |
|
119 { |
|
120 // If nothing has gone wrong so far, we've passed |
|
121 if (iError == KErrGeneral) |
|
122 iError = KErrNone; |
|
123 |
|
124 // Send second request |
|
125 CActiveScheduler::Stop(); |
|
126 } |
|
127 } |
|
128 break; |
|
129 |
|
130 case THTTPEvent::EGotResponseBodyData: |
|
131 { |
|
132 TInt statusCode = aTransaction.Response().StatusCode(); |
|
133 if (statusCode==HTTPStatus::EUnauthorized) |
|
134 { |
|
135 |
|
136 } |
|
137 aTransaction.Response().Body()->ReleaseData(); |
|
138 } |
|
139 break; |
|
140 |
|
141 case THTTPEvent::EFailed: |
|
142 CActiveScheduler::Stop(); |
|
143 break; |
|
144 |
|
145 default: |
|
146 break; |
|
147 } |
|
148 } |
|
149 |
|
150 const TDesC& CTestFixINC035621::TestName() |
|
151 { |
|
152 _LIT(KTestName,"Defect INC035621"); |
|
153 return KTestName; |
|
154 } |
|
155 |
|
156 |
|
157 TBool CTestFixINC035621::GetCredentialsL(const TUriC8& aURI, RString aRealm, RStringF aAuthenticationType, |
|
158 RString& aUsername, RString& aPassword) |
|
159 { |
|
160 iEngine->Utils().LogIt(_L("Supplying credentials")); |
|
161 // Can't log 8 bit data, so dump it. |
|
162 iEngine->Utils().DumpData(aURI.UriDes()); |
|
163 iEngine->Utils().DumpData(aRealm.DesC()); |
|
164 iEngine->Utils().DumpData(aAuthenticationType.DesC()); |
|
165 _LIT8(KScooby, "scooby"); |
|
166 _LIT8(KDoo, "doo"); |
|
167 RStringPool p = aRealm.Pool(); |
|
168 aUsername = p.OpenStringL(KScooby); |
|
169 aPassword = p.OpenStringL(KDoo); |
|
170 return ETrue; |
|
171 } |