use of com.thoughtworks.go.plugin.domain.common.Metadata in project gocd by gocd.
the class AuthorizationExtensionTest method shouldTalkToPlugin_To_GetPluginConfigurationMetadata.
@Test
void shouldTalkToPlugin_To_GetPluginConfigurationMetadata() {
String responseBody = "[{\"key\":\"username\",\"metadata\":{\"required\":true,\"secure\":false}},{\"key\":\"password\",\"metadata\":{\"required\":true,\"secure\":true}}]";
when(pluginManager.submitTo(eq(PLUGIN_ID), eq(AUTHORIZATION_EXTENSION), requestArgumentCaptor.capture())).thenReturn(new DefaultGoPluginApiResponse(SUCCESS_RESPONSE_CODE, responseBody));
List<PluginConfiguration> authConfigMetadata = authorizationExtension.getAuthConfigMetadata(PLUGIN_ID);
assertRequest(requestArgumentCaptor.getValue(), AUTHORIZATION_EXTENSION, "1.0", REQUEST_GET_AUTH_CONFIG_METADATA, null);
assertThat(authConfigMetadata.size()).isEqualTo(2);
assertThat(authConfigMetadata).hasSize(2).contains(new PluginConfiguration("username", new Metadata(true, false)), new PluginConfiguration("password", new Metadata(true, true)));
}
use of com.thoughtworks.go.plugin.domain.common.Metadata in project gocd by gocd.
the class ArtifactExtensionTestBase method shouldGetFetchArtifactMetadataFromPlugin.
@Test
public void shouldGetFetchArtifactMetadataFromPlugin() {
String responseBody = "[{\"key\":\"FILENAME\",\"metadata\":{\"required\":true,\"secure\":false}},{\"key\":\"VERSION\",\"metadata\":{\"required\":true,\"secure\":true}}]";
when(pluginManager.submitTo(eq(PLUGIN_ID), eq(ARTIFACT_EXTENSION), requestArgumentCaptor.capture())).thenReturn(DefaultGoPluginApiResponse.success(responseBody));
final List<PluginConfiguration> response = artifactExtension.getFetchArtifactMetadata(PLUGIN_ID);
final GoPluginApiRequest request = requestArgumentCaptor.getValue();
assertThat(request.extension(), is(ARTIFACT_EXTENSION));
assertThat(request.requestName(), is(REQUEST_FETCH_ARTIFACT_METADATA));
assertNull(request.requestBody());
assertThat(response.size(), is(2));
assertThat(response, containsInAnyOrder(new PluginConfiguration("FILENAME", new Metadata(true, false)), new PluginConfiguration("VERSION", new Metadata(true, true))));
}
use of com.thoughtworks.go.plugin.domain.common.Metadata in project gocd by gocd.
the class PluginProfileMetadataKeysTest method shouldGetPluginConfigurations.
@Test
public void shouldGetPluginConfigurations() throws Exception {
PluginProfileMetadataKeys metadata = PluginProfileMetadataKeys.fromJSON("[{\n" + " \"key\": \"username\",\n" + " \"metadata\": {\n" + " \"secure\": true,\n" + " \"required\": false\n" + " }\n" + "}, {\n" + " \"key\": \"password\",\n" + " \"metadata\": {\n" + " \"secure\": true,\n" + " \"required\": true\n" + " }\n" + "}]");
List<PluginConfiguration> pluginConfigurations = metadata.toPluginConfigurations();
assertThat(pluginConfigurations, containsInAnyOrder(new PluginConfiguration("username", new Metadata(false, true)), new PluginConfiguration("password", new Metadata(true, true))));
}
use of com.thoughtworks.go.plugin.domain.common.Metadata in project gocd by gocd.
the class PluginProfileMetadataKeysTest method shouldGetPluginConfigurationsWithMetadataDefaultedToFalseInAbsenceOfPluginMetadata.
@Test
public void shouldGetPluginConfigurationsWithMetadataDefaultedToFalseInAbsenceOfPluginMetadata() throws Exception {
PluginProfileMetadataKeys metadata = PluginProfileMetadataKeys.fromJSON("[{\n" + " \"key\": \"username\"\n" + "}, {\n" + " \"key\": \"password\",\n" + " \"metadata\": {\n" + " \"secure\": true,\n" + " \"required\": true\n" + " }\n" + "}]");
List<PluginConfiguration> pluginConfigurations = metadata.toPluginConfigurations();
assertThat(pluginConfigurations, containsInAnyOrder(new PluginConfiguration("username", new Metadata(false, false)), new PluginConfiguration("password", new Metadata(true, true))));
}
use of com.thoughtworks.go.plugin.domain.common.Metadata in project gocd by gocd.
the class SecretsExtensionV1Test method shouldTalkToPlugin_toFetchSecretsConfigMetadata.
@Test
void shouldTalkToPlugin_toFetchSecretsConfigMetadata() {
String responseBody = "[{\"key\":\"Username\",\"metadata\":{\"required\":true,\"secure\":false}},{\"key\":\"Password\",\"metadata\":{\"required\":true,\"secure\":true}}]";
when(pluginManager.submitTo(eq(PLUGIN_ID), eq(SECRETS_EXTENSION), requestArgumentCaptor.capture())).thenReturn(DefaultGoPluginApiResponse.success(responseBody));
final List<PluginConfiguration> metadata = secretsExtensionV1.getSecretsConfigMetadata(PLUGIN_ID);
assertThat(metadata).hasSize(2);
assertThat(metadata).contains(new PluginConfiguration("Username", new Metadata(true, false)), new PluginConfiguration("Password", new Metadata(true, true)));
assertExtensionRequest(REQUEST_GET_SECRETS_CONFIG_METADATA, null);
}
Aggregations