use of com.thoughtworks.go.plugin.domain.common.Image in project gocd by gocd.
the class AuthorizationPluginInfoBuilder method pluginInfoFor.
public AuthorizationPluginInfo pluginInfoFor(GoPluginDescriptor descriptor) {
Capabilities capabilities = capabilities(descriptor.id());
PluggableInstanceSettings authConfigSettings = authConfigSettings(descriptor.id());
PluggableInstanceSettings roleSettings = roleSettings(descriptor.id(), capabilities);
Image image = image(descriptor.id());
return new AuthorizationPluginInfo(descriptor, authConfigSettings, roleSettings, image, capabilities);
}
use of com.thoughtworks.go.plugin.domain.common.Image 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.Image in project gocd by gocd.
the class AuthPluginInfoViewModelTest method shouldGetDetailsAboutThePlugin.
@Test
public void shouldGetDetailsAboutThePlugin() {
GoPluginDescriptor.About about = new GoPluginDescriptor.About("GitHub Auth Plugin", "1.0", null, null, null, null);
String pluginId = "github";
GoPluginDescriptor descriptor = new GoPluginDescriptor(pluginId, "1.0", about, null, null, false);
AuthorizationPluginInfo pluginInfo = new AuthorizationPluginInfo(descriptor, null, null, new Image("svg", "data", "hash"), new Capabilities(SupportedAuthType.Web, true, true));
AuthPluginInfoViewModel model = new AuthPluginInfoViewModel(pluginInfo);
assertThat(model.imageUrl(), is("/go/api/plugin_images/github/hash"));
assertThat(model.pluginId(), is("github"));
assertThat(model.name(), is("GitHub Auth Plugin"));
}
Aggregations