You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by be...@apache.org on 2008/09/10 19:35:11 UTC

svn commit: r693907 - /incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth/MakeRequestClient.java

Author: beaton
Date: Wed Sep 10 10:35:10 2008
New Revision: 693907

URL: http://svn.apache.org/viewvc?rev=693907&view=rev
Log:
More comments on test utility.


Modified:
    incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth/MakeRequestClient.java

Modified: incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth/MakeRequestClient.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth/MakeRequestClient.java?rev=693907&r1=693906&r2=693907&view=diff
==============================================================================
--- incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth/MakeRequestClient.java (original)
+++ incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth/MakeRequestClient.java Wed Sep 10 10:35:10 2008
@@ -27,7 +27,9 @@
 import org.apache.shindig.gadgets.oauth.OAuthArguments.UseToken;
 
 /**
- * 
+ * Test utility to emulate the requests sent via gadgets.io.makeRequest.  The simulation starts
+ * at what arrives at OAuthFetcher.  Code above OAuthFetcher (MakeRequestHandler, preloads) are not
+ * exercised here.
  */
 public class MakeRequestClient {
   
@@ -40,6 +42,15 @@
   private String approvalUrl;
   private boolean ignoreCache;
 
+  /**
+   * Create a make request client with the given security token, sending requests through an
+   * OAuth fetcher to an OAuth service provider.
+   * 
+   * @param securityToken identity of the user.
+   * @param fetcherConfig configuration for the OAuthFetcher
+   * @param serviceProvider service provider being targeted.
+   * @param serviceName nickname for the service being accessed.
+   */
   public MakeRequestClient(SecurityToken securityToken, OAuthFetcherConfig fetcherConfig,
       FakeOAuthServiceProvider serviceProvider, String serviceName) {
     this.securityToken = securityToken;
@@ -50,6 +61,9 @@
     this.ignoreCache = false;
   }
   
+  /**
+   * Set the arguments to the OAuth fetch.
+   */
   public void setBaseArgs(OAuthArguments baseArgs) {
     this.baseArgs = baseArgs;
   }
@@ -62,6 +76,9 @@
     this.ignoreCache = ignoreCache;
   }
   
+  /**
+   * Send an OAuth GET request to the given URL.
+   */
   public HttpResponse sendGet(String target) throws Exception {
     HttpRequest request = new HttpRequest(Uri.parse(target));
     request.setOAuthArguments(recallState());
@@ -73,6 +90,9 @@
     return response;
   }
   
+  /**
+   * Send an OAuth POST request to the given URL.
+   */
   public HttpResponse sendFormPost(String target, String body) throws Exception {
     HttpRequest request = new HttpRequest(Uri.parse(target));
     request.setOAuthArguments(recallState());
@@ -86,6 +106,9 @@
     return response;
   }
   
+  /**
+   * Create arguments simulating authz=OAUTH.
+   */
   public OAuthArguments makeNonSocialOAuthArguments() {
     OAuthArguments params = new OAuthArguments();
     params.setUseToken(UseToken.ALWAYS);
@@ -95,6 +118,9 @@
     return params;
   }
   
+  /**
+   * Create arguments simulating authz=SIGNED.
+   */
   public OAuthArguments makeSignedFetchArguments() {
     OAuthArguments params = new OAuthArguments();
     params.setUseToken(UseToken.NEVER);
@@ -102,13 +128,19 @@
     params.setSignViewer(true);
     return params;
   }
-    
+   
+  /**
+   * Track state (see gadgets.io.makeRequest handling of the oauthState parameter).
+   */
   private OAuthArguments recallState() {
     OAuthArguments params = new OAuthArguments(baseArgs);
     params.setOrigClientState(oauthState);
     return params;
   }
   
+  /**
+   * Track state (see gadgets.io.makeRequest handling of the oauthState parameter).
+   */
   private void saveState(HttpResponse response) {
     approvalUrl = null;
     if (response.getMetadata() != null) {
@@ -119,6 +151,9 @@
     }
   }
   
+  /**
+   * Simulate the user visiting the service provider and approved access to their data.
+   */
   public void approveToken(String params) throws Exception {
     // This will throw if approvalUrl looks wrong.
     serviceProvider.browserVisit(approvalUrl + "&" + params);