Search in sources :

Example 6 with Image

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);
}
Also used : PluggableInstanceSettings(com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings) Capabilities(com.thoughtworks.go.plugin.domain.authorization.Capabilities) AuthorizationPluginInfo(com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo) Image(com.thoughtworks.go.plugin.domain.common.Image)

Example 7 with Image

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();
    }
}
Also used : Image(com.thoughtworks.go.plugin.domain.common.Image) CombinedPluginInfo(com.thoughtworks.go.plugin.domain.common.CombinedPluginInfo)

Example 8 with Image

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"));
}
Also used : Capabilities(com.thoughtworks.go.plugin.domain.authorization.Capabilities) AuthorizationPluginInfo(com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) Image(com.thoughtworks.go.plugin.domain.common.Image) Test(org.junit.Test)

Aggregations

Image (com.thoughtworks.go.plugin.domain.common.Image)8 Test (org.junit.Test)4 AuthorizationPluginInfo (com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo)3 Capabilities (com.thoughtworks.go.plugin.domain.authorization.Capabilities)3 PluggableInstanceSettings (com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings)2 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)2 AnalyticsPluginInfo (com.thoughtworks.go.plugin.domain.analytics.AnalyticsPluginInfo)1 Capabilities (com.thoughtworks.go.plugin.domain.analytics.Capabilities)1 CombinedPluginInfo (com.thoughtworks.go.plugin.domain.common.CombinedPluginInfo)1