mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-04 01:49:15 +00:00
Removed LicenseExpiredException
This exception was removed from the license plugin. We use `ElasticsearchException` instead with `es.license.expired.feature` header to hold the expired feature. We use `LicenseUtils.newExpirationException` to create and throw the proper exception. Original commit: elastic/x-pack-elasticsearch@5e722be1cc
This commit is contained in:
parent
31e2516fd6
commit
792359103d
@ -17,7 +17,7 @@ import org.elasticsearch.action.support.ActionFilterChain;
|
||||
import org.elasticsearch.common.component.AbstractComponent;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.license.plugin.core.LicenseExpiredException;
|
||||
import org.elasticsearch.license.plugin.core.LicenseUtils;
|
||||
import org.elasticsearch.shield.User;
|
||||
import org.elasticsearch.shield.audit.AuditTrail;
|
||||
import org.elasticsearch.shield.authc.AuthenticationService;
|
||||
@ -80,7 +80,7 @@ public class ShieldActionFilter extends AbstractComponent implements ActionFilte
|
||||
logger.error("blocking [{}] operation due to expired license. Cluster health, cluster stats and indices stats \n" +
|
||||
"operations are blocked on shield license expiration. All data operations (read and write) continue to work. \n" +
|
||||
"If you have a new license, please update it. Otherwise, please reach out to your support contact.", action);
|
||||
throw new LicenseExpiredException(LicenseService.FEATURE_NAME);
|
||||
throw LicenseUtils.newExpirationException(LicenseService.FEATURE_NAME);
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -7,6 +7,7 @@ package org.elasticsearch.integration;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
|
||||
import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse;
|
||||
import org.elasticsearch.action.admin.cluster.stats.ClusterStatsIndices;
|
||||
@ -20,10 +21,10 @@ import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.inject.Module;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.license.core.License;
|
||||
import org.elasticsearch.license.plugin.core.LicenseExpiredException;
|
||||
import org.elasticsearch.license.plugin.core.LicensesClientService;
|
||||
import org.elasticsearch.plugins.AbstractPlugin;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
import org.elasticsearch.rest.RestStatus;
|
||||
import org.elasticsearch.shield.license.LicenseService;
|
||||
import org.elasticsearch.test.ShieldIntegrationTest;
|
||||
import org.elasticsearch.test.ShieldSettingsSource;
|
||||
@ -119,33 +120,41 @@ public class LicensingTests extends ShieldIntegrationTest {
|
||||
try {
|
||||
client.admin().indices().prepareStats().get();
|
||||
fail("expected an license expired exception when executing an index stats action");
|
||||
} catch (LicenseExpiredException lee) {
|
||||
} catch (ElasticsearchException ee) {
|
||||
// expected
|
||||
assertThat(lee.feature(), equalTo(LicenseService.FEATURE_NAME));
|
||||
assertThat(ee, instanceOf(ElasticsearchException.WithRestHeadersException.class));
|
||||
assertThat(((ElasticsearchException.WithRestHeadersException) ee).getHeaders().get("es.license.expired.feature"), hasItem(LicenseService.FEATURE_NAME));
|
||||
assertThat(ee.status(), is(RestStatus.UNAUTHORIZED));
|
||||
}
|
||||
|
||||
try {
|
||||
client.admin().cluster().prepareClusterStats().get();
|
||||
fail("expected an license expired exception when executing cluster stats action");
|
||||
} catch (LicenseExpiredException lee) {
|
||||
} catch (ElasticsearchException ee) {
|
||||
// expected
|
||||
assertThat(lee.feature(), equalTo(LicenseService.FEATURE_NAME));
|
||||
assertThat(ee, instanceOf(ElasticsearchException.WithRestHeadersException.class));
|
||||
assertThat(((ElasticsearchException.WithRestHeadersException) ee).getHeaders().get("es.license.expired.feature"), hasItem(LicenseService.FEATURE_NAME));
|
||||
assertThat(ee.status(), is(RestStatus.UNAUTHORIZED));
|
||||
}
|
||||
|
||||
try {
|
||||
client.admin().cluster().prepareHealth().get();
|
||||
fail("expected an license expired exception when executing cluster health action");
|
||||
} catch (LicenseExpiredException lee) {
|
||||
} catch (ElasticsearchException ee) {
|
||||
// expected
|
||||
assertThat(lee.feature(), equalTo(LicenseService.FEATURE_NAME));
|
||||
assertThat(ee, instanceOf(ElasticsearchException.WithRestHeadersException.class));
|
||||
assertThat(((ElasticsearchException.WithRestHeadersException) ee).getHeaders().get("es.license.expired.feature"), hasItem(LicenseService.FEATURE_NAME));
|
||||
assertThat(ee.status(), is(RestStatus.UNAUTHORIZED));
|
||||
}
|
||||
|
||||
try {
|
||||
client.admin().cluster().prepareNodesStats().get();
|
||||
fail("expected an license expired exception when executing cluster health action");
|
||||
} catch (LicenseExpiredException lee) {
|
||||
} catch (ElasticsearchException ee) {
|
||||
// expected
|
||||
assertThat(lee.feature(), equalTo(LicenseService.FEATURE_NAME));
|
||||
assertThat(ee, instanceOf(ElasticsearchException.WithRestHeadersException.class));
|
||||
assertThat(((ElasticsearchException.WithRestHeadersException) ee).getHeaders().get("es.license.expired.feature"), hasItem(LicenseService.FEATURE_NAME));
|
||||
assertThat(ee.status(), is(RestStatus.UNAUTHORIZED));
|
||||
}
|
||||
|
||||
enableLicensing();
|
||||
|
Loading…
x
Reference in New Issue
Block a user