public GadgetsHandlerApi.TokenResponse call() throws Exception { try { return handlerService.getToken(tokenRequest); } catch (Exception e) { sendError(tokenRequest.getUrl(), e, FAILURE_TOKEN); return null; } } };
public GadgetsHandlerApi.TokenResponse call() throws Exception { try { return handlerService.getToken(tokenRequest); } catch (Exception e) { sendError(tokenRequest.getUrl(), e, FAILURE_TOKEN); return null; } } };
public CallableData call() throws Exception { try { return new CallableData(url, handlerService.getToken(tokenRequest)); } catch (Exception e) { return new CallableData(url, handlerService.createErrorResponse(null, e, FAILURE_TOKEN)); } } };
@Test(expected = ProcessingException.class) public void testGetTokenNoUrl() throws Exception { GadgetsHandlerApi.TokenRequest request = createTokenRequest(null, CONTAINER, createAuthContext(OWNER, VIEWER), ImmutableList.of("*")); replay(); gadgetHandler.getToken(request); }
@Test(expected = ProcessingException.class) public void testGetTokenNoContainer() throws Exception { GadgetsHandlerApi.TokenRequest request = createTokenRequest( FakeProcessor.SPEC_URL, null, createTokenData(OWNER, VIEWER), ImmutableList.of("*")); replay(); GadgetsHandlerApi.TokenResponse response = gadgetHandler.getToken(request); }
@Test(expected = ProcessingException.class) public void testGetTokenNoContainer() throws Exception { GadgetsHandlerApi.TokenRequest request = createTokenRequest(FakeProcessor.SPEC_URL, null, createAuthContext(OWNER, VIEWER), ImmutableList.of("*")); replay(); gadgetHandler.getToken(request); }
@Test(expected = ProcessingException.class) public void testGetTokenNoUrl() throws Exception { GadgetsHandlerApi.TokenRequest request = createTokenRequest(null, CONTAINER, createAuthContext(OWNER, VIEWER), ImmutableList.of("*")); replay(); gadgetHandler.getToken(request); }
@Test(expected = ProcessingException.class) public void testGetTokenNoUrl() throws Exception { GadgetsHandlerApi.TokenRequest request = createTokenRequest( null, CONTAINER, createTokenData(OWNER, VIEWER), ImmutableList.of("*")); replay(); GadgetsHandlerApi.TokenResponse response = gadgetHandler.getToken(request); }
@Test(expected = ProcessingException.class) public void testGetTokenNoContainer() throws Exception { GadgetsHandlerApi.TokenRequest request = createTokenRequest(FakeProcessor.SPEC_URL, null, createAuthContext(OWNER, VIEWER), ImmutableList.of("*")); replay(); gadgetHandler.getToken(request); }
@Test(expected = SecurityTokenException.class) public void testGetTokenException() throws Exception { GadgetsHandlerApi.TokenRequest request = createTokenRequest(FakeProcessor.SPEC_URL, CONTAINER, createAuthContext(OWNER, VIEWER), ImmutableList.of("*")); replay(); tokenCodec.exc = new SecurityTokenException("bad data"); gadgetHandler.getToken(request); }
@Test(expected = SecurityTokenException.class) public void testGetTokenException() throws Exception { GadgetsHandlerApi.TokenRequest request = createTokenRequest(FakeProcessor.SPEC_URL, CONTAINER, createAuthContext(OWNER, VIEWER), ImmutableList.of("*")); replay(); tokenCodec.exc = new SecurityTokenException("bad data"); gadgetHandler.getToken(request); }
@Test(expected = SecurityTokenException.class) public void testGetTokenException() throws Exception { GadgetsHandlerApi.TokenRequest request = createTokenRequest( FakeProcessor.SPEC_URL, CONTAINER, createTokenData(OWNER, VIEWER), ImmutableList.of("*")); replay(); tokenCodec.exc = new SecurityTokenException("bad data"); GadgetsHandlerApi.TokenResponse response = gadgetHandler.getToken(request); }
@Test(expected = ProcessingException.class) public void testGetTokenNoFields() throws Exception { GadgetsHandlerApi.TokenRequest request = createTokenRequest(FakeProcessor.SPEC_URL, CONTAINER, createAuthContext(OWNER, VIEWER), null); replay(); gadgetHandler.getToken(request); }
@Test(expected = ProcessingException.class) public void testGetTokenNoFields() throws Exception { GadgetsHandlerApi.TokenRequest request = createTokenRequest(FakeProcessor.SPEC_URL, CONTAINER, createAuthContext(OWNER, VIEWER), null); replay(); gadgetHandler.getToken(request); }
@Test(expected = ProcessingException.class) public void testGetTokenNoFields() throws Exception { GadgetsHandlerApi.TokenRequest request = createTokenRequest( FakeProcessor.SPEC_URL, CONTAINER, createTokenData(OWNER, VIEWER), null); replay(); GadgetsHandlerApi.TokenResponse response = gadgetHandler.getToken(request); }
@Test public void testGetTokenNoToken() throws Exception { GadgetsHandlerApi.TokenRequest request = createTokenRequest( FakeProcessor.SPEC_URL, CONTAINER, null, ImmutableList.of("*")); replay(); tokenCodec.encodedToken = TOKEN; GadgetsHandlerApi.TokenResponse response = gadgetHandler.getToken(request); assertEquals(TOKEN, response.getToken()); assertNull(CONTAINER, tokenCodec.tokenData); verify(); }
@Test public void testGetTokenNoToken() throws Exception { GadgetsHandlerApi.TokenRequest request = createTokenRequest(FakeProcessor.SPEC_URL, CONTAINER, null, ImmutableList.of("*")); replay(); tokenCodec.encodedToken = TOKEN; GadgetsHandlerApi.TokenResponse response = gadgetHandler.getToken(request); assertEquals(TOKEN, response.getToken()); assertNull(CONTAINER, tokenCodec.authContext); verify(); }
@Test public void testGetTokenNoToken() throws Exception { GadgetsHandlerApi.TokenRequest request = createTokenRequest(FakeProcessor.SPEC_URL, CONTAINER, null, ImmutableList.of("*")); replay(); tokenCodec.encodedToken = TOKEN; GadgetsHandlerApi.TokenResponse response = gadgetHandler.getToken(request); assertEquals(TOKEN, response.getToken()); assertNull(CONTAINER, tokenCodec.authContext); verify(); }
@Test public void testGetToken() throws Exception { GadgetsHandlerApi.TokenRequest request = createTokenRequest( FakeProcessor.SPEC_URL, CONTAINER, createTokenData(OWNER, VIEWER), ImmutableList.of("*")); replay(); tokenCodec.encodedToken = TOKEN; GadgetsHandlerApi.TokenResponse response = gadgetHandler.getToken(request); assertEquals(TOKEN, response.getToken()); assertEquals(OWNER, tokenCodec.tokenData.getOwnerId()); assertEquals(VIEWER, tokenCodec.tokenData.getViewerId()); assertEquals(CONTAINER, tokenCodec.tokenData.getContainer()); verify(); }
@Test public void testGetToken() throws Exception { GadgetsHandlerApi.TokenRequest request = createTokenRequest(FakeProcessor.SPEC_URL, CONTAINER, createAuthContext(OWNER, VIEWER), ImmutableList.of("*")); replay(); tokenCodec.encodedToken = TOKEN; GadgetsHandlerApi.TokenResponse response = gadgetHandler.getToken(request); assertEquals(TOKEN, response.getToken()); assertEquals(CURRENT_TIME_MS, response.getResponseTimeMs()); assertEquals(TOKEN_EXPIRY_TIME_MS, response.getExpireTimeMs()); assertEquals(OWNER, tokenCodec.authContext.getOwnerId()); assertEquals(VIEWER, tokenCodec.authContext.getViewerId()); assertEquals(CONTAINER, tokenCodec.authContext.getContainer()); verify(); }