We have two web applications. One of them implements an OAuth 1.0 server, the other one is the consumer. I'm designing some JUnit tests to run out of the box, from Java code, without using filters from OAuth for Spring Security, as I'm not in a web application environment. I've reading the introduction (https://github.com/SpringSource/spri...th/wiki/oauth1) and the api documentation, but I cannot figure out how to do that. I need a request token to access a protected resource in the server from my tests.
I need to create an OAuthSecurityContextHolder to be able to perform restful calls from my test cases:
At the moment, I am getting a 401 unauthorized http error. How can I get a token from my server?Code:@Before public void onSetup() { OAuthSecurityContextImpl context = new OAuthSecurityContextImpl(); Map<String, OAuthConsumerToken> accessTokens = new TreeMap<String, OAuthConsumerToken>(); OAuthConsumerToken token = new OAuthConsumerToken(); token.setAccessToken(true); token.setResourceId(TOKEN_RESOURCE_ID); token.setSecret(TOKEN_SECRET); token.setValue(TOKEN_VALUE); accessTokens.put(TOKEN_RESOURCE_ID, token); context.setAccessTokens(accessTokens); OAuthSecurityContextHolder.setContext(context); }


Reply With Quote