usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject [21/29] usergrid git commit: Fix for USERGRID-1106: fixed by rewriting test to do exactly what it used to do before the new framework conversion.
Date Tue, 01 Dec 2015 14:25:51 GMT
Fix for USERGRID-1106: fixed by rewriting test to do exactly what it used to do before the
new framework conversion.


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/c1f5e16a
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/c1f5e16a
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/c1f5e16a

Branch: refs/heads/USERGRID-872
Commit: c1f5e16a72bda590be1e890be005a636fd247550
Parents: 6fffe93
Author: Dave Johnson <snoopdave@apache.org>
Authored: Fri Nov 20 09:56:30 2015 -0500
Committer: Dave Johnson <snoopdave@apache.org>
Committed: Fri Nov 20 09:56:30 2015 -0500

----------------------------------------------------------------------
 .../applications/ApplicationResourceIT.java     | 33 ++++++++++++--------
 1 file changed, 20 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/c1f5e16a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java
b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java
index 8d29290..e822f66 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java
@@ -645,34 +645,41 @@ public class ApplicationResourceIT extends AbstractRestIT {
     }
 
     /**
-     * Retrieve an access token using HTTP Basic authentication
+     * Retrieve an app user access token using HTTP Basic authentication
      */
     @Test
-    @Ignore("Pending https://issues.apache.org/jira/browse/USERGRID-1106")
-    //Are we trying to generate token with token? Couldn't find endpoint that accepts token
for generating token
     public void clientCredentialsFlowWithHeaderAuthorization() throws Exception {
-        //retrieve the credentials
-        Credentials orgCredentials = getAppCredentials();
-        String clientId = orgCredentials.getClientId();
-        String clientSecret = orgCredentials.getClientSecret();
 
+        // get app credentials from /<org>/<app>/credentials end-point (using
admin credentials)
+        Credentials appCredentials = getAppCredentials();
+        String clientId = appCredentials.getClientId();
+        String clientSecret = appCredentials.getClientSecret();
+
+        // use app credentials to admin user access token
         Token token = clientSetup.getRestClient().management().token()
             .post(Token.class,new Token("client_credentials", clientId, clientSecret));
 
-        //GET the token endpoint, adding authorization header
-        Token apiResponse = this.app().token().getTarget( false )
+        String clientCredentials = clientId + ":" + clientSecret;
+        String encodedToken = Base64.encodeToString( clientCredentials.getBytes() );
+
+        Map<String, String> payload = hashMap( "grant_type", "client_credentials" );
+
+        // use admin user access token to get app user access token
+        Token apiResponse = this.app().token().getTarget( false ).request()
             //add the auth header
-            .request()
-            .header( "Authorization", "Bearer " + token.getAccessToken() )
+            .header( "Authorization", "Basic " + encodedToken )
             .accept( MediaType.APPLICATION_JSON )
-            .post(javax.ws.rs.client.Entity.entity(
-                hashMap( "grant_type", "client_credentials" ), MediaType.APPLICATION_JSON_TYPE
), Token.class );
+            .post(javax.ws.rs.client.Entity.entity(payload, MediaType.APPLICATION_JSON_TYPE
), Token.class );
 
         //Assert that a valid token with a valid TTL is returned
         assertNotNull("A valid response was returned.", apiResponse);
         assertNull("There is no error.", apiResponse.getError());
         assertNotNull("It has access_token.", apiResponse.getAccessToken());
         assertNotNull("It has expires_in.", apiResponse.getExpirationDate());
+
+
+
+
     }
 
     /**


Mime
View raw message