private void setupGadgetAdminMock(boolean isWhitelisted) { expect(gadgetAdminStore.isWhitelisted(isA(String.class), isA(String.class))) .andReturn(isWhitelisted); }
private void setupGadgetAdminMock(boolean isWhitelisted) { expect(gadgetAdminStore.isWhitelisted(isA(String.class), isA(String.class))) .andReturn(isWhitelisted); }
@Test(expected = ProcessingException.class) public void nonWhitelistedGadgetThrows() throws Exception { expect(gadgetAdminStore.isWhitelisted(isA(String.class), isA(String.class))).andReturn(false); replay(); processor.process(makeContext("html")); }
@Test public void whitelistChecked() throws Exception { expect(gadgetAdminStore.isWhitelisted(isA(String.class), isA(String.class))).andReturn(true); replay(); processor.process(makeContext("url")); }
@Test(expected = ProcessingException.class) public void nonWhitelistedGadgetThrows() throws Exception { expect(gadgetAdminStore.isWhitelisted(isA(String.class), isA(String.class))).andReturn(false); replay(); processor.process(makeContext("html")); }
@Test public void whitelistChecked() throws Exception { expect(gadgetAdminStore.isWhitelisted(isA(String.class), isA(String.class))).andReturn(true); replay(); processor.process(makeContext("url")); }
@Test public void substitutionsPerformedTypeUrl() throws Exception { expect(gadgetAdminStore.isWhitelisted(isA(String.class), isA(String.class))).andReturn(true); replay(); processor.process(makeContext("url")); assertTrue("Substitutions not performed", substituter.wasSubstituted); }
@Test public void substitutionsPerformedTypeUrl() throws Exception { expect(gadgetAdminStore.isWhitelisted(isA(String.class), isA(String.class))).andReturn(true); replay(); processor.process(makeContext("url")); assertTrue("Substitutions not performed", substituter.wasSubstituted); }
@Test public void substitutionsPerformedTypeHtml() throws Exception { expect(gadgetAdminStore.isWhitelisted(isA(String.class), isA(String.class))).andReturn(true); replay(); processor.process(makeContext("html")); assertTrue("Substitutions not performed", substituter.wasSubstituted); }
@Test public void substitutionsPerformedTypeHtml() throws Exception { expect(gadgetAdminStore.isWhitelisted(isA(String.class), isA(String.class))).andReturn(true); replay(); processor.process(makeContext("html")); assertTrue("Substitutions not performed", substituter.wasSubstituted); }
@Test public void noSupportedViewHasNoCurrentView() throws Exception { expect(gadgetAdminStore.isWhitelisted(isA(String.class), isA(String.class))).andReturn(true); replay(); Gadget gadget = processor.process(makeContext("not-real-view")); assertNull(gadget.getCurrentView()); }
@Test public void noSupportedViewHasNoCurrentView() throws Exception { expect(gadgetAdminStore.isWhitelisted(isA(String.class), isA(String.class))).andReturn(true); replay(); Gadget gadget = processor.process(makeContext("not-real-view")); assertNull(gadget.getCurrentView()); }
@Test public void normalProcessing() throws Exception { expect(gadgetAdminStore.isWhitelisted(isA(String.class), isA(String.class))).andReturn(true); replay(); Gadget gadget = processor.process(makeContext("html")); assertEquals(BASIC_HTML_CONTENT, gadget.getCurrentView().getContent()); }
@Test public void doViewAliasing() throws Exception { expect(gadgetAdminStore.isWhitelisted(isA(String.class), isA(String.class))).andReturn(true); replay(); Gadget gadget = processor.process(makeContext("aliased")); assertEquals(BASIC_HTML_CONTENT, gadget.getCurrentView().getContent()); }
@Test public void doViewAliasing() throws Exception { expect(gadgetAdminStore.isWhitelisted(isA(String.class), isA(String.class))).andReturn(true); replay(); Gadget gadget = processor.process(makeContext("aliased")); assertEquals(BASIC_HTML_CONTENT, gadget.getCurrentView().getContent()); }
@Test public void normalProcessing() throws Exception { expect(gadgetAdminStore.isWhitelisted(isA(String.class), isA(String.class))).andReturn(true); replay(); Gadget gadget = processor.process(makeContext("html")); assertEquals(BASIC_HTML_CONTENT, gadget.getCurrentView().getContent()); }
@Test public void GetRequestWithNonWhitelistedGadget() throws Exception { reset(gadgetAdminStore); expect(gadgetAdminStore.isWhitelisted(isA(String.class), isA(String.class))).andReturn(false); replay(); boolean exceptionThrown = false; try { handler.fetch(request, recorder); } catch (GadgetException e) { exceptionThrown = true; assertEquals(403, e.getHttpStatusCode()); assertEquals(GadgetException.Code.NON_WHITELISTED_GADGET, e.getCode()); } assertTrue(exceptionThrown); verify(); }
@Test public void GetRequestWithNonWhitelistedGadget() throws Exception { reset(gadgetAdminStore); expect(gadgetAdminStore.isWhitelisted(isA(String.class), isA(String.class))).andReturn(false); replay(); boolean exceptionThrown = false; try { handler.fetch(request, recorder); } catch (GadgetException e) { exceptionThrown = true; assertEquals(403, e.getHttpStatusCode()); assertEquals(GadgetException.Code.NON_WHITELISTED_GADGET, e.getCode()); } assertTrue(exceptionThrown); verify(); }
@Test public void typeUrlViewsAreSkippedForSanitizedGadget() throws Exception { expect(gadgetAdminStore.isWhitelisted(isA(String.class), isA(String.class))) .andReturn(true).anyTimes(); replay(); Gadget gadget = processor.process(makeContext("url", SPEC_URL, true)); assertNull(gadget.getCurrentView()); gadget = processor.process(makeContext("html", SPEC_URL, true)); assertEquals(BASIC_HTML_CONTENT, gadget.getCurrentView().getContent()); }
@Test public void typeUrlViewsAreSkippedForSanitizedGadget() throws Exception { expect(gadgetAdminStore.isWhitelisted(isA(String.class), isA(String.class))) .andReturn(true).anyTimes(); replay(); Gadget gadget = processor.process(makeContext("url", SPEC_URL, true)); assertNull(gadget.getCurrentView()); gadget = processor.process(makeContext("html", SPEC_URL, true)); assertEquals(BASIC_HTML_CONTENT, gadget.getCurrentView().getContent()); }