@Test public void testGetTokenStore_1() throws Exception { final OAuth2FetcherConfig fixture = new OAuth2FetcherConfig(new GadgetOAuth2TokenStore( EasyMock.createNiceMock(OAuth2Store.class), EasyMock.createNiceMock(GadgetSpecFactory.class)), true); final GadgetOAuth2TokenStore result = fixture.getTokenStore(); Assert.assertNotNull(result); }
@Test public void testIsViewerAccessTokensEnabled_2() throws Exception { final OAuth2FetcherConfig fixture = new OAuth2FetcherConfig(new GadgetOAuth2TokenStore( EasyMock.createNiceMock(OAuth2Store.class), EasyMock.createNiceMock(GadgetSpecFactory.class)), false); final boolean result = fixture.isViewerAccessTokensEnabled(); Assert.assertEquals(false, result); } }
@Test public void testGetOAuth2Store_1() throws Exception { final OAuth2FetcherConfig fixture = new OAuth2FetcherConfig(new GadgetOAuth2TokenStore( EasyMock.createNiceMock(OAuth2Store.class), EasyMock.createNiceMock(GadgetSpecFactory.class)), true); final OAuth2Store result = fixture.getOAuth2Store(); Assert.assertNotNull(result); Assert.assertEquals(false, result.clearCache()); }
private OAuth2Accessor getAccessorInternal() { OAuth2Accessor ret = null; if (this.fetcherConfig != null) { final GadgetOAuth2TokenStore tokenStore = this.fetcherConfig.getTokenStore(); if (tokenStore != null) { ret = tokenStore.getOAuth2Accessor(this.securityToken, this.arguments, this.realRequest.getGadget()); } } return ret; }
private boolean checkCanAuthorize(final OAuth2Accessor accessor) { final boolean isLogging = BasicOAuth2Request.LOG.isLoggable(); if (isLogging) { BasicOAuth2Request.LOG.entering(BasicOAuth2Request.LOG_CLASS, "checkCanAuthorize", accessor); } boolean ret = true; if (BasicOAuth2Request.LOG.isLoggable()) { BasicOAuth2Request.LOG.log("securityToken = {0}", this.securityToken); } final String pageOwner = this.securityToken.getOwnerId(); final String pageViewer = this.securityToken.getViewerId(); if (BasicOAuth2Request.LOG.isLoggable()) { BasicOAuth2Request.LOG.log("pageOwner = {0}", pageOwner); BasicOAuth2Request.LOG.log("pageViewer = {0}", pageViewer); } if (pageOwner == null || pageViewer == null) { accessor.setErrorResponse(null, OAuth2Error.AUTHORIZE_PROBLEM, "pageOwner or pageViewer is null", ""); ret = false; } else if (!this.fetcherConfig.isViewerAccessTokensEnabled() && !pageOwner.equals(pageViewer)) { accessor.setErrorResponse(null, OAuth2Error.AUTHORIZE_PROBLEM, "pageViewer is not pageOwner", ""); ret = false; } if (isLogging) { BasicOAuth2Request.LOG.exiting(BasicOAuth2Request.LOG_CLASS, "checkCanAuthorize", ret); } return ret; }
this.fetcherConfig = fetcherConfig; if (this.fetcherConfig != null) { this.store = this.fetcherConfig.getOAuth2Store(); } else { this.store = null;
@Test public void testIsViewerAccessTokensEnabled_2() throws Exception { final OAuth2FetcherConfig fixture = new OAuth2FetcherConfig(new GadgetOAuth2TokenStore( EasyMock.createNiceMock(OAuth2Store.class), EasyMock.createNiceMock(GadgetSpecFactory.class)), false); final boolean result = fixture.isViewerAccessTokensEnabled(); Assert.assertEquals(false, result); } }
@Test public void testGetOAuth2Store_1() throws Exception { final OAuth2FetcherConfig fixture = new OAuth2FetcherConfig(new GadgetOAuth2TokenStore( EasyMock.createNiceMock(OAuth2Store.class), EasyMock.createNiceMock(GadgetSpecFactory.class)), true); final OAuth2Store result = fixture.getOAuth2Store(); Assert.assertNotNull(result); Assert.assertEquals(false, result.clearCache()); }
@Test public void testIsViewerAccessTokensEnabled_1() throws Exception { final OAuth2FetcherConfig fixture = new OAuth2FetcherConfig(new GadgetOAuth2TokenStore( EasyMock.createNiceMock(OAuth2Store.class), EasyMock.createNiceMock(GadgetSpecFactory.class)), true); final boolean result = fixture.isViewerAccessTokensEnabled(); Assert.assertEquals(true, result); }
@Test public void testGetTokenStore_1() throws Exception { final OAuth2FetcherConfig fixture = new OAuth2FetcherConfig(new GadgetOAuth2TokenStore( EasyMock.createNiceMock(OAuth2Store.class), EasyMock.createNiceMock(GadgetSpecFactory.class)), true); final GadgetOAuth2TokenStore result = fixture.getTokenStore(); Assert.assertNotNull(result); }
@Test public void testOAuth2FetcherConfig_1() throws Exception { final GadgetOAuth2TokenStore tokenStore = new GadgetOAuth2TokenStore( EasyMock.createNiceMock(OAuth2Store.class), EasyMock.createNiceMock(GadgetSpecFactory.class)); final boolean viewerAccessTokensEnabled = true; final OAuth2FetcherConfig result = new OAuth2FetcherConfig(tokenStore, viewerAccessTokensEnabled); Assert.assertNotNull(result); Assert.assertEquals(true, result.isViewerAccessTokensEnabled()); }
@Test public void testOAuth2FetcherConfig_1() throws Exception { final GadgetOAuth2TokenStore tokenStore = new GadgetOAuth2TokenStore( EasyMock.createNiceMock(OAuth2Store.class), EasyMock.createNiceMock(GadgetSpecFactory.class)); final boolean viewerAccessTokensEnabled = true; final OAuth2FetcherConfig result = new OAuth2FetcherConfig(tokenStore, viewerAccessTokensEnabled); Assert.assertNotNull(result); Assert.assertEquals(true, result.isViewerAccessTokensEnabled()); }
@Test public void testIsViewerAccessTokensEnabled_1() throws Exception { final OAuth2FetcherConfig fixture = new OAuth2FetcherConfig(new GadgetOAuth2TokenStore( EasyMock.createNiceMock(OAuth2Store.class), EasyMock.createNiceMock(GadgetSpecFactory.class)), true); final boolean result = fixture.isViewerAccessTokensEnabled(); Assert.assertEquals(true, result); }