incubator-amber-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asa...@apache.org
Subject svn commit: r1329140 - /incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src/test/java/org/apache/amber/oauth2/rs/OAuthAccessResourceRequestTest.java
Date Mon, 23 Apr 2012 09:10:32 GMT
Author: asanso
Date: Mon Apr 23 09:10:31 2012
New Revision: 1329140

URL: http://svn.apache.org/viewvc?rev=1329140&view=rev
Log:
AMBER-15 : adding new unit test

Modified:
    incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src/test/java/org/apache/amber/oauth2/rs/OAuthAccessResourceRequestTest.java

Modified: incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src/test/java/org/apache/amber/oauth2/rs/OAuthAccessResourceRequestTest.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src/test/java/org/apache/amber/oauth2/rs/OAuthAccessResourceRequestTest.java?rev=1329140&r1=1329139&r2=1329140&view=diff
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src/test/java/org/apache/amber/oauth2/rs/OAuthAccessResourceRequestTest.java
(original)
+++ incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src/test/java/org/apache/amber/oauth2/rs/OAuthAccessResourceRequestTest.java
Mon Apr 23 09:10:31 2012
@@ -214,7 +214,7 @@ public class OAuthAccessResourceRequestT
         expect(request.getParameterValues(OAuth.OAUTH_BEARER_TOKEN)).andStubReturn(new String[]
{"sometoken"});
         expect(request.getParameter(OAuth.OAUTH_VERSION_DIFFER)).andStubReturn(null);
         expect(request.getHeader(OAuth.HeaderType.AUTHORIZATION))
-            .andStubReturn("Bearer sadfasfd,oauth_signature_method=\"HMAC-SHA1\"");
+            .andStubReturn("Bearer sadfasfd");
         replay(request);
 
         try {
@@ -229,6 +229,29 @@ public class OAuthAccessResourceRequestT
     }
 
     @Test
+    public void testCreateBodyHeaderMixedTokensAndWrongVersion() throws Exception {
+
+        HttpServletRequest request = createMock(HttpServletRequest.class);
+        expect(request.getMethod()).andStubReturn(OAuth.HttpMethod.POST);
+        expect(request.getContentType()).andStubReturn(OAuth.ContentType.URL_ENCODED);
+        expect(request.getParameterValues(OAuth.OAUTH_BEARER_TOKEN)).andStubReturn(new String[]
{"sometoken"});
+        expect(request.getParameter(OAuth.OAUTH_VERSION_DIFFER)).andStubReturn(null);
+        expect(request.getHeader(OAuth.HeaderType.AUTHORIZATION))
+            .andStubReturn("Bearer sadfasfd,oauth_signature_method=\"HMAC-SHA1\"");
+        replay(request);
+
+        try {
+            new OAuthAccessResourceRequest(request, ParameterStyle.BODY, ParameterStyle.HEADER);
+            fail("Exception expected");
+        } catch (OAuthProblemException e) {
+            Assert
+                .assertTrue(
+                    OAuthError.TokenResponse.INVALID_REQUEST.equals(e.getError()));
+        }
+        verify(request);
+    }
+    
+    @Test
     public void testCreateBodyNoToken() throws Exception {
 
         HttpServletRequest request = createMock(HttpServletRequest.class);



Mime
View raw message