|
1 // Copyright (c) 2003-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 "CDEF143497.h" |
|
17 #include "httptestutils.h" |
|
18 #include "testhttpfilter.h" |
|
19 |
|
20 const TInt KTransactionCount = 1; |
|
21 const TInt KConnectionCount = 1; |
|
22 _LIT8(KTxtRawRequest1, "GET / HTTP/1.1\r\nHost: 127.0.0.1\r\nUser-Agent: 3gpp-gba\r\n\r\n"); |
|
23 _LIT8(KTxtRawResponse1, "HTTP/1.1 401 Authorization Required\r\nWWW-Authenticate: Basic realm=\"Secure Area\"\r\nContent-Length: 6\r\n\r\nhello!"); |
|
24 _LIT8(KTxtRawRequest2,"GET / HTTP/1.1\r\nHost: 127.0.0.1\r\nAuthorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==\r\nUser-Agent: 3gpp-gba\r\n\r\n"); |
|
25 _LIT8(KTxtRawResponse2, "HTTP/1.0 200 Ok\r\nContent-Length: 6\r\n\r\nhello!"); |
|
26 _LIT8(KNullResponse, " "); |
|
27 |
|
28 CDEF143497 * CDEF143497 ::NewL(CHTTPTestUtils& aTestUtils) |
|
29 { |
|
30 CDEF143497 * self = new (ELeave) CDEF143497 (aTestUtils); |
|
31 CleanupStack::PushL(self); |
|
32 self->ConstructL(); |
|
33 CleanupStack::Pop(self); |
|
34 return self; |
|
35 } |
|
36 |
|
37 CDEF143497 ::CDEF143497 (CHTTPTestUtils& aTestUtils) |
|
38 : CPipeliningTestCase(), iTestUtils(aTestUtils) |
|
39 { |
|
40 } |
|
41 |
|
42 void CDEF143497 ::ConstructL() |
|
43 { |
|
44 } |
|
45 |
|
46 CDEF143497 ::~CDEF143497 () |
|
47 { |
|
48 } |
|
49 |
|
50 const TDesC& CDEF143497 ::TestCaseName() const |
|
51 { |
|
52 _LIT(KTxtTitle, "Defect Fix CDEF143497"); |
|
53 return KTxtTitle(); |
|
54 } |
|
55 |
|
56 TInt CDEF143497 ::TotalTransactionCount() const |
|
57 { |
|
58 return KTransactionCount; |
|
59 } |
|
60 |
|
61 TInt CDEF143497 ::ConnectionCount() const |
|
62 { |
|
63 return KConnectionCount; |
|
64 } |
|
65 |
|
66 |
|
67 RHTTPTransaction CDEF143497 ::GetTransactionL(TInt aIndex, RHTTPSession aSession, MHTTPTransactionCallback& aClient) |
|
68 { |
|
69 __ASSERT_ALWAYS(aIndex<KTransactionCount, User::Invariant()); |
|
70 CTestFilterInterface::InstallFilterL(aSession); |
|
71 RStringF method = aSession.StringPool().StringF(HTTP::EGET,RHTTPSession::GetTable()); |
|
72 _LIT8(KTxtUri, "http://127.0.0.1"); |
|
73 TUriParser8 uri; |
|
74 uri.Parse(KTxtUri()); |
|
75 return aSession.OpenTransactionL(uri, aClient, method); |
|
76 } |
|
77 |
|
78 const TDesC8& CDEF143497 ::GetRawRequest(TInt /*aConnectionIndex*/, TInt /*aTransIndex*/) |
|
79 { |
|
80 static TInt RequestCounter =0; |
|
81 if(RequestCounter==0) |
|
82 { |
|
83 RequestCounter++; |
|
84 return KTxtRawRequest1(); |
|
85 } |
|
86 if(RequestCounter==1) |
|
87 { |
|
88 return KTxtRawRequest2(); |
|
89 } |
|
90 else |
|
91 return KNullResponse(); |
|
92 } |
|
93 |
|
94 const TDesC8& CDEF143497 ::GetRawResponse(TInt /*aConnectionIndex*/, TInt /*aTransIndex*/) |
|
95 { |
|
96 static TInt ResponseCounter =0; |
|
97 if(ResponseCounter==0) |
|
98 { |
|
99 ResponseCounter++; |
|
100 return KTxtRawResponse1(); |
|
101 } |
|
102 if(ResponseCounter==1) |
|
103 return KTxtRawResponse2(); |
|
104 else |
|
105 return KNullResponse(); |
|
106 |
|
107 } |
|
108 |
|
109 TInt CDEF143497::ExpectedError(RHTTPTransaction /*aTrans*/) |
|
110 { |
|
111 return KErrNone; |
|
112 } |
|
113 |
|
114 TBool CDEF143497::GetCredentialsL(const TUriC8& /*aURI*/, RString aRealm, RStringF /*aAuthenticationType*/, RString& aUsername, RString& aPassword) |
|
115 { |
|
116 _LIT8(KUsername, "Aladdin"); |
|
117 _LIT8(KPassword, "open sesame"); |
|
118 RStringPool p = aRealm.Pool(); |
|
119 aUsername = p.OpenStringL(KUsername); |
|
120 aPassword = p.OpenStringL(KPassword); |
|
121 return ETrue; |
|
122 } |
|
123 |