use of com.thoughtworks.go.plugin.domain.common.CombinedPluginInfo in project gocd by gocd.
the class PluginImagesControllerDelegate method show.
public byte[] show(Request request, Response response) throws IOException {
String pluginId = request.params("plugin_id");
String hash = request.params("hash");
CombinedPluginInfo pluginInfo = pluginInfoFinder.pluginInfoFor(pluginId);
if (pluginInfo == null) {
throw halt(404, "");
}
Image image = pluginInfo.getImage();
if (image == null || !image.getHash().equals(hash)) {
throw halt(404, "");
}
response.raw().setHeader("Cache-Control", "max-age=31557600, public");
if (fresh(request, image.getHash())) {
notModified(response);
return new byte[0];
}
response.status(200);
response.header("Content-Type", image.getContentType());
this.setEtagHeader(response, image.getHash());
if (request.requestMethod().equals("head")) {
return new byte[0];
} else {
return image.getDataAsBytes();
}
}
use of com.thoughtworks.go.plugin.domain.common.CombinedPluginInfo in project gocd by gocd.
the class InitialContextProviderTest method shouldNotShowAnalyticsDashboardWhenUserIsNotAdmin.
@Test
public void shouldNotShowAnalyticsDashboardWhenUserIsNotAdmin() {
Map<String, Object> modelMap = new HashMap<>();
when(securityService.isUserAdmin(any(Username.class))).thenReturn(false);
CombinedPluginInfo combinedPluginInfo = new CombinedPluginInfo(analyticsPluginInfo());
when(pluginInfoFinder.allPluginInfos(PluginConstants.ANALYTICS_EXTENSION)).thenReturn(Collections.singletonList(combinedPluginInfo));
VelocityContext velocityContext = initialContextProvider.getVelocityContext(modelMap, dummySparkController.getClass(), "viewName");
assertThat(velocityContext.internalGet("showAnalyticsDashboard")).isEqualTo(false);
}
use of com.thoughtworks.go.plugin.domain.common.CombinedPluginInfo in project gocd by gocd.
the class InitialContextProviderTest method shouldNotShowAnalyticsDashboardPluginIsNotPresent.
@Test
public void shouldNotShowAnalyticsDashboardPluginIsNotPresent() {
Map<String, Object> modelMap = new HashMap<>();
when(securityService.isUserAdmin(any(Username.class))).thenReturn(true);
when(pluginInfoFinder.allPluginInfos(PluginConstants.ANALYTICS_EXTENSION)).thenReturn(Collections.singletonList(new CombinedPluginInfo()));
VelocityContext velocityContext = initialContextProvider.getVelocityContext(modelMap, dummySparkController.getClass(), "viewName");
assertThat(velocityContext.internalGet("showAnalyticsDashboard")).isEqualTo(false);
}
Aggregations