shindig-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ssiev...@apache.org
Subject svn commit: r1348118 - in /shindig/trunk/java/gadgets/src: main/java/org/apache/shindig/gadgets/oauth2/BasicOAuth2Store.java test/java/org/apache/shindig/gadgets/oauth2/BasicOAuth2StoreTest.java
Date Fri, 08 Jun 2012 15:30:05 GMT
Author: ssievers
Date: Fri Jun  8 15:30:04 2012
New Revision: 1348118

URL: http://svn.apache.org/viewvc?rev=1348118&view=rev
Log:
SHINDIG-1791 | BasicOAuth2Store client lookup fails with sharedTokens set | Patch from Brian
Lillie.  Thanks!

Added:
    shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/BasicOAuth2StoreTest.java
Modified:
    shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/oauth2/BasicOAuth2Store.java

Modified: shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/oauth2/BasicOAuth2Store.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/oauth2/BasicOAuth2Store.java?rev=1348118&r1=1348117&r2=1348118&view=diff
==============================================================================
--- shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/oauth2/BasicOAuth2Store.java
(original)
+++ shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/oauth2/BasicOAuth2Store.java
Fri Jun  8 15:30:04 2012
@@ -397,7 +397,7 @@ public class BasicOAuth2Store implements
 
       token.setGadgetUri(processedGadgetUri);
 
-      final OAuth2Token existingToken = this.getToken(processedGadgetUri, token.getServiceName(),
+      final OAuth2Token existingToken = this.getToken(gadgetUri, token.getServiceName(),
               token.getUser(), token.getScope(), token.getType());
       try {
         if (existingToken == null) {

Added: shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/BasicOAuth2StoreTest.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/BasicOAuth2StoreTest.java?rev=1348118&view=auto
==============================================================================
--- shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/BasicOAuth2StoreTest.java
(added)
+++ shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth2/BasicOAuth2StoreTest.java
Fri Jun  8 15:30:04 2012
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.shindig.gadgets.oauth2;
+
+import static org.easymock.EasyMock.createMockBuilder;
+import static org.easymock.EasyMock.eq;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+
+import org.apache.shindig.common.crypto.BlobCrypter;
+import org.apache.shindig.common.servlet.Authority;
+import org.apache.shindig.gadgets.oauth2.persistence.OAuth2Cache;
+import org.apache.shindig.gadgets.oauth2.persistence.OAuth2Client;
+import org.apache.shindig.gadgets.oauth2.persistence.OAuth2Encrypter;
+import org.apache.shindig.gadgets.oauth2.persistence.OAuth2Persister;
+import org.apache.shindig.gadgets.oauth2.persistence.sample.InMemoryCache;
+
+import org.junit.Test;
+
+/**
+ * @author <a href="mailto:dev@shindig.apache.org">Shindig Dev</a>
+ * @version $Id: $
+ */
+public class BasicOAuth2StoreTest {
+
+  @Test
+  public void testSetTokenForSharedClient() throws Exception {
+    final OAuth2Cache cache = new InMemoryCache();
+    final OAuth2Persister persister = MockUtils.getDummyPersister();
+    final OAuth2Encrypter encrypter = MockUtils.getDummyEncrypter();
+    final BlobCrypter stateCrypter = MockUtils.getDummyStateCrypter();
+
+    OAuth2Token token = MockUtils.getAccessToken();
+    OAuth2Client client = MockUtils.getClient_Code_Confidential();
+    client.setSharedToken( true );
+
+    BasicOAuth2Store mockStore = createMockBuilder( BasicOAuth2Store.class )
+            .withConstructor( OAuth2Cache.class, OAuth2Persister.class, OAuth2Encrypter.class,
String.class, Authority.class, String.class, BlobCrypter.class )
+            .withArgs( cache, persister, encrypter, MockUtils.REDIRECT_URI, (Authority)null,
(String)null, stateCrypter )
+            .addMockedMethod( "getClient" )
+            .addMockedMethod( "getToken" )
+            .createMock();
+
+    expect( mockStore.getClient( eq(MockUtils.GADGET_URI1), eq(MockUtils.SERVICE_NAME) )
).andReturn( client );
+    expect( mockStore.getToken( eq(token.getGadgetUri()), eq(token.getServiceName()), eq(token.getUser()),
eq(token.getScope()), eq(token.getType() ) )).andReturn( token );
+
+    replay( mockStore );
+
+    mockStore.setToken( token );
+
+    verify( mockStore );
+  }
+}
+



Mime
View raw message