@Inject public void setStateCrypter(@Named(OAuthFetcherConfig.OAUTH_STATE_CRYPTER) BlobCrypter stateCrypter) { checkInitialized(); this.stateCrypter = stateCrypter; }
@Test public void testServletWithCallback_noQueryParams() throws Exception { BlobCrypter crypter = new BasicBlobCrypter("00000000000000000000".getBytes()); OAuthCallbackState state = new OAuthCallbackState(crypter); OAuthCallbackServlet servlet = new OAuthCallbackServlet(); servlet.setStateCrypter(crypter); state.setRealCallbackUrl("http://www.example.com/callback"); expect(request.getParameter("cs")).andReturn(state.getEncryptedState()); expect(request.getQueryString()).andReturn("cs=foo"); replay(); servlet.doGet(this.request, this.recorder); verify(); assertEquals(302, this.recorder.getHttpStatusCode()); assertEquals("http://www.example.com/callback", this.recorder.getHeader("Location")); String cacheControl = this.recorder.getHeader("Cache-Control"); assertEquals("private,max-age=3600", cacheControl); } }
@Test public void testServlet() throws Exception { OAuthCallbackServlet servlet = new OAuthCallbackServlet(); replay(); servlet.doGet(this.request, this.recorder); verify(); assertEquals("text/html; charset=UTF-8", this.recorder.getContentType()); String body = this.recorder.getResponseAsString(); Assert.assertNotSame("body is " + body, body.indexOf("window.close()"), -1); }
@Test public void testServletWithCallback() throws Exception { BlobCrypter crypter = new BasicBlobCrypter("00000000000000000000".getBytes()); OAuthCallbackState state = new OAuthCallbackState(crypter); OAuthCallbackServlet servlet = new OAuthCallbackServlet(); servlet.setStateCrypter(crypter); state.setRealCallbackUrl("http://www.example.com/callback"); expect(request.getParameter("cs")).andReturn(state.getEncryptedState()); expect(request.getQueryString()).andReturn("cs=foo&bar=baz"); replay(); servlet.doGet(this.request, this.recorder); verify(); assertEquals(302, this.recorder.getHttpStatusCode()); assertEquals("http://www.example.com/callback?bar=baz", this.recorder.getHeader("Location")); String cacheControl = this.recorder.getHeader("Cache-Control"); assertEquals("private,max-age=3600", cacheControl); }
@Test public void testServlet() throws Exception { OAuthCallbackServlet servlet = new OAuthCallbackServlet(); replay(); servlet.doGet(this.request, this.recorder); verify(); assertEquals("text/html; charset=UTF-8", this.recorder.getContentType()); String body = this.recorder.getResponseAsString(); Assert.assertNotSame("body is " + body, body.indexOf("window.close()"), -1); }
@Test public void testServletWithCallback() throws Exception { BlobCrypter crypter = new BasicBlobCrypter("00000000000000000000".getBytes()); OAuthCallbackState state = new OAuthCallbackState(crypter); OAuthCallbackServlet servlet = new OAuthCallbackServlet(); servlet.setStateCrypter(crypter); state.setRealCallbackUrl("http://www.example.com/callback"); expect(request.getParameter("cs")).andReturn(state.getEncryptedState()); expect(request.getQueryString()).andReturn("cs=foo&bar=baz"); replay(); servlet.doGet(this.request, this.recorder); verify(); assertEquals(302, this.recorder.getHttpStatusCode()); assertEquals("http://www.example.com/callback?bar=baz", this.recorder.getHeader("Location")); String cacheControl = this.recorder.getHeader("Cache-Control"); assertEquals("private,max-age=3600", cacheControl); }
@Test public void testServlet() throws Exception { OAuthCallbackServlet servlet = new OAuthCallbackServlet(); replay(); servlet.doGet(this.request, this.recorder); verify(); assertEquals("text/html; charset=UTF-8", this.recorder.getContentType()); String body = this.recorder.getResponseAsString(); Assert.assertNotSame("body is " + body, body.indexOf("window.close()"), -1); }
@Inject public void setStateCrypter(@Named(OAuthFetcherConfig.OAUTH_STATE_CRYPTER) BlobCrypter stateCrypter) { checkInitialized(); this.stateCrypter = stateCrypter; }
@Test public void testServletWithCallback_noQueryParams() throws Exception { BlobCrypter crypter = new BasicBlobCrypter("00000000000000000000".getBytes()); OAuthCallbackState state = new OAuthCallbackState(crypter); OAuthCallbackServlet servlet = new OAuthCallbackServlet(); servlet.setStateCrypter(crypter); state.setRealCallbackUrl("http://www.example.com/callback"); expect(request.getParameter("cs")).andReturn(state.getEncryptedState()); expect(request.getQueryString()).andReturn("cs=foo"); replay(); servlet.doGet(this.request, this.recorder); verify(); assertEquals(302, this.recorder.getHttpStatusCode()); assertEquals("http://www.example.com/callback", this.recorder.getHeader("Location")); String cacheControl = this.recorder.getHeader("Cache-Control"); assertEquals("private,max-age=3600", cacheControl); } }
@Inject public void setStateCrypter(@Named(OAuthFetcherConfig.OAUTH_STATE_CRYPTER) BlobCrypter stateCrypter) { checkInitialized(); this.stateCrypter = stateCrypter; }
@Test public void testServletWithCallback_noQueryParams() throws Exception { BlobCrypter crypter = new BasicBlobCrypter("00000000000000000000".getBytes()); OAuthCallbackState state = new OAuthCallbackState(crypter); OAuthCallbackServlet servlet = new OAuthCallbackServlet(); servlet.setStateCrypter(crypter); state.setRealCallbackUrl("http://www.example.com/callback"); expect(request.getParameter("cs")).andReturn(state.getEncryptedState()); expect(request.getQueryString()).andReturn("cs=foo"); replay(); servlet.doGet(this.request, this.recorder); verify(); assertEquals(302, this.recorder.getHttpStatusCode()); assertEquals("http://www.example.com/callback", this.recorder.getHeader("Location")); String cacheControl = this.recorder.getHeader("Cache-Control"); assertEquals("private,max-age=3600", cacheControl); } }
@Test public void testServletWithCallback() throws Exception { BlobCrypter crypter = new BasicBlobCrypter("00000000000000000000".getBytes()); OAuthCallbackState state = new OAuthCallbackState(crypter); OAuthCallbackServlet servlet = new OAuthCallbackServlet(); servlet.setStateCrypter(crypter); state.setRealCallbackUrl("http://www.example.com/callback"); expect(request.getParameter("cs")).andReturn(state.getEncryptedState()); expect(request.getQueryString()).andReturn("cs=foo&bar=baz"); replay(); servlet.doGet(this.request, this.recorder); verify(); assertEquals(302, this.recorder.getHttpStatusCode()); assertEquals("http://www.example.com/callback?bar=baz", this.recorder.getHeader("Location")); String cacheControl = this.recorder.getHeader("Cache-Control"); assertEquals("private,max-age=3600", cacheControl); }