Skip to content
This repository has been archived by the owner on Apr 5, 2022. It is now read-only.

Commit

Permalink
Replaced another deprecated method.
Browse files Browse the repository at this point in the history
  • Loading branch information
habuma committed Sep 12, 2012
1 parent eb77cfa commit 4517da2
Showing 1 changed file with 13 additions and 6 deletions.
Expand Up @@ -15,6 +15,7 @@
*/
package org.springframework.social.oauth1;

import static org.hamcrest.core.StringContains.*;
import static org.junit.Assert.*;
import static org.springframework.http.HttpMethod.*;
import static org.springframework.test.web.client.match.RequestMatchers.*;
Expand All @@ -26,6 +27,7 @@
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.test.web.client.MockRestServiceServer;
import org.springframework.test.web.client.RequestMatcher;
import org.springframework.util.MultiValueMap;

public class OAuth1TemplateTest {
Expand All @@ -49,13 +51,12 @@ public void setup() {
oauth10a = new OAuth1Template("consumer_key", "consumer_secret", REQUEST_TOKEN_URL, AUTHORIZE_URL, null, ACCESS_TOKEN_URL, OAuth1Version.CORE_10_REVISION_A);
oauth10 = new OAuth1Template("consumer_key", "consumer_secret", REQUEST_TOKEN_URL, AUTHORIZE_URL, AUTHENTICATE_URL, ACCESS_TOKEN_URL, OAuth1Version.CORE_10);

customOauth10 = new OAuth1Template("consumer_key", "consumer_secret", REQUEST_TOKEN_URL,
AUTHORIZE_URL, null, ACCESS_TOKEN_URL, OAuth1Version.CORE_10) {
customOauth10 = new OAuth1Template("consumer_key", "consumer_secret", REQUEST_TOKEN_URL, AUTHORIZE_URL, null, ACCESS_TOKEN_URL, OAuth1Version.CORE_10) {
protected void addCustomAuthorizationParameters(MultiValueMap<String,String> parameters) {
parameters.set("custom_parameter", "custom_parameter_value");
};
};
}
}

@Test
public void buildAuthorizeUrl() {
Expand All @@ -80,12 +81,11 @@ public void fetchNewRequestToken_OAuth10a() {
MockRestServiceServer mockServer = MockRestServiceServer.createServer(oauth10a.getRestTemplate());
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.setContentType(MediaType.APPLICATION_FORM_URLENCODED);

mockServer
.expect(requestTo(REQUEST_TOKEN_URL))
.andExpect(method(POST))
.andExpect(
headerContains("Authorization",
"oauth_callback=\"http%3A%2F%2Fwww.someclient.com%2Foauth%2Fcallback\""))
.andExpect(headerContains("Authorization", "oauth_callback=\"http%3A%2F%2Fwww.someclient.com%2Foauth%2Fcallback\""))
.andExpect(headerContains("Authorization", "oauth_version=\"1.0\""))
.andExpect(headerContains("Authorization", "oauth_signature_method=\"HMAC-SHA1\""))
.andExpect(headerContains("Authorization", "oauth_consumer_key=\"consumer_key\""))
Expand Down Expand Up @@ -197,5 +197,12 @@ public void construct_nullAcessTokenUrl() {
public void setRequestFactory_null() {
oauth10a.setRequestFactory(null);
}


// private helper
@SuppressWarnings("unchecked")
private RequestMatcher headerContains(String name, String substring) {
return header(name, containsString(substring));
}

}

0 comments on commit 4517da2

Please sign in to comment.