Skip to content

Commit 266e8c4

Browse files
committed
Add test for AsyncHttpClient#922
1 parent 25c7ba4 commit 266e8c4

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/test/java/com/ning/http/client/oauth/OAuthSignatureCalculatorTest.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,35 @@ private void testSignatureBaseString(Request request) {
103103
+ "oauth_version%3D1.0");
104104
}
105105

106+
// fork above test with an OAuth token that requires encoding
107+
private void testSignatureBaseStringWithEncodableOAuthToken(Request request) {
108+
ConsumerKey consumer = new ConsumerKey("9djdj82h48djs9d2", CONSUMER_SECRET);
109+
RequestToken user = new RequestToken("kkk9d7dh3k39sjv7", TOKEN_SECRET);
110+
OAuthSignatureCalculator calc = new OAuthSignatureCalculator(consumer, user);
111+
112+
String signatureBaseString = calc.signatureBaseString(//
113+
request.getMethod(),//
114+
request.getUri(),//
115+
137131201,//
116+
"ZLc92RAkooZcIO/0cctl0Q==",//
117+
request.getFormParams(),//
118+
request.getQueryParams()).toString();
119+
120+
assertEquals(signatureBaseString, "POST&" //
121+
+ "http%3A%2F%2Fexample.com%2Frequest" //
122+
+ "&a2%3Dr%2520b%26"//
123+
+ "a3%3D2%2520q%26" + "a3%3Da%26"//
124+
+ "b5%3D%253D%25253D%26"//
125+
+ "c%2540%3D%26"//
126+
+ "c2%3D%26"//
127+
+ "oauth_consumer_key%3D9djdj82h48djs9d2%26"//
128+
+ "oauth_nonce%3DZLc92RAkooZcIO%252F0cctl0Q%253D%253D%26"//
129+
+ "oauth_signature_method%3DHMAC-SHA1%26"//
130+
+ "oauth_timestamp%3D137131201%26"//
131+
+ "oauth_token%3Dkkk9d7dh3k39sjv7%26"//
132+
+ "oauth_version%3D1.0");
133+
}
134+
106135
@Test(groups = "fast")
107136
public void testSignatureBaseStringWithProperlyEncodedUri() {
108137

@@ -113,6 +142,7 @@ public void testSignatureBaseStringWithProperlyEncodedUri() {
113142
.build();
114143

115144
testSignatureBaseString(request);
145+
testSignatureBaseStringWithEncodableOAuthToken(request);
116146
}
117147

118148
@Test(groups = "fast")
@@ -127,6 +157,7 @@ public void testSignatureBaseStringWithRawUri() {
127157
.build();
128158

129159
testSignatureBaseString(request);
160+
testSignatureBaseStringWithEncodableOAuthToken(request);
130161
}
131162

132163
// based on the reference test case from

0 commit comments

Comments
 (0)