Search in sources :

Example 1 with AzureRepositoryPlugin

use of org.elasticsearch.plugin.repository.azure.AzureRepositoryPlugin in project elasticsearch by elastic.

the class AzureStorageSettingsFilterTests method testSettingsFiltering.

public void testSettingsFiltering() throws IOException {
    AzureRepositoryPlugin p = new AzureRepositoryPlugin();
    SettingsModule module = new SettingsModule(Settings.EMPTY, p.getSettings(), p.getSettingsFilter());
    SettingsFilter settingsFilter = ModuleTestCase.bindAndGetInstance(module, SettingsFilter.class);
    // Test using direct filtering
    Settings filteredSettings = settingsFilter.filter(settings);
    assertThat(filteredSettings.getAsMap().keySet(), contains("cloud.azure.storage.azure1.default"));
    // Test using toXContent filtering
    RestRequest request = new FakeRestRequest();
    settingsFilter.addFilterSettingParams(request);
    XContentBuilder xContentBuilder = XContentBuilder.builder(JsonXContent.jsonXContent);
    xContentBuilder.startObject();
    settings.toXContent(xContentBuilder, request);
    xContentBuilder.endObject();
    String filteredSettingsString = xContentBuilder.string();
    filteredSettings = Settings.builder().loadFromSource(filteredSettingsString, xContentBuilder.contentType()).build();
    assertThat(filteredSettings.getAsMap().keySet(), contains("cloud.azure.storage.azure1.default"));
}
Also used : RestRequest(org.elasticsearch.rest.RestRequest) FakeRestRequest(org.elasticsearch.test.rest.FakeRestRequest) AzureRepositoryPlugin(org.elasticsearch.plugin.repository.azure.AzureRepositoryPlugin) SettingsModule(org.elasticsearch.common.settings.SettingsModule) FakeRestRequest(org.elasticsearch.test.rest.FakeRestRequest) Settings(org.elasticsearch.common.settings.Settings) XContentBuilder(org.elasticsearch.common.xcontent.XContentBuilder) SettingsFilter(org.elasticsearch.common.settings.SettingsFilter)

Aggregations

Settings (org.elasticsearch.common.settings.Settings)1 SettingsFilter (org.elasticsearch.common.settings.SettingsFilter)1 SettingsModule (org.elasticsearch.common.settings.SettingsModule)1 XContentBuilder (org.elasticsearch.common.xcontent.XContentBuilder)1 AzureRepositoryPlugin (org.elasticsearch.plugin.repository.azure.AzureRepositoryPlugin)1 RestRequest (org.elasticsearch.rest.RestRequest)1 FakeRestRequest (org.elasticsearch.test.rest.FakeRestRequest)1