views:

164

answers:

0

I am using Oauth Signpost to test our implementation of oauth I have a test that checks correct behaviour when the consumer id is incorrect, What I want to do is to check that the HTML content contains the correct error message.

My question is now: How can I access the HTML content using the OAuthProvider, OAuthConsumer or Exception after calling provider.retrieveRequestToken?

Note: Using grails and functional-tests plugin to write tests.

I tried looking at the documentation of signpost but found no help http://code.google.com/p/oauth-signpost/

My Test: I want to be able to replace HTMLRESPONSE with something.

  void testIncorrectConsumerId(){
    OAuthConsumer consumer = new DefaultOAuthConsumer("incorrect_consumer_id", "consumer_secret", SignatureMethod.HMAC_SHA1)

    OAuthProvider provider = new DefaultOAuthProvider(consumer, baseURL + "oauth_request_token", baseURL + "oauth_access_token", baseURL +"oauth_authentication")

    try {
      String authenticationUrl = provider.retrieveRequestToken("http://dummy.callback.url")
    } catch (Exception e) {
      assertEquals(e.getMessage(), correct_error_message)
      assertEquals( HTMLRESPONSE.contains, "incorrect consumer key" )
    }

  }