Skip to content

Commit 540b570

Browse files
authored
Convert token service license object to LicensedFeature (#79284) (#79408)
* Convert token service license object to LicensedFeature (#79284) This commit moves the token service license checks to use the new LicensedFeature class. * fix compile * checkstyle
1 parent afcefdd commit 540b570

File tree

12 files changed

+61
-57
lines changed

12 files changed

+61
-57
lines changed

x-pack/plugin/core/src/main/java/org/elasticsearch/license/XPackLicenseState.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ public class XPackLicenseState {
4141
* Each value defines the licensed state necessary for the feature to be allowed.
4242
*/
4343
public enum Feature {
44-
SECURITY_TOKEN_SERVICE(OperationMode.STANDARD, false),
4544

4645
OPERATOR_PRIVILEGES(OperationMode.ENTERPRISE, true);
4746

x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/Security.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@
8383
import org.elasticsearch.transport.TransportRequestHandler;
8484
import org.elasticsearch.transport.nio.NioGroupFactory;
8585
import org.elasticsearch.watcher.ResourceWatcherService;
86+
import org.elasticsearch.xcontent.NamedXContentRegistry;
87+
import org.elasticsearch.xcontent.XContentBuilder;
8688
import org.elasticsearch.xpack.core.XPackField;
8789
import org.elasticsearch.xpack.core.XPackPlugin;
8890
import org.elasticsearch.xpack.core.XPackSettings;
@@ -229,8 +231,8 @@
229231
import org.elasticsearch.xpack.security.authz.SecuritySearchOperationListener;
230232
import org.elasticsearch.xpack.security.authz.accesscontrol.OptOutQueryCache;
231233
import org.elasticsearch.xpack.security.authz.interceptor.BulkShardRequestInterceptor;
232-
import org.elasticsearch.xpack.security.authz.interceptor.IndicesAliasesRequestInterceptor;
233234
import org.elasticsearch.xpack.security.authz.interceptor.DlsFlsLicenseRequestInterceptor;
235+
import org.elasticsearch.xpack.security.authz.interceptor.IndicesAliasesRequestInterceptor;
234236
import org.elasticsearch.xpack.security.authz.interceptor.RequestInterceptor;
235237
import org.elasticsearch.xpack.security.authz.interceptor.ResizeRequestInterceptor;
236238
import org.elasticsearch.xpack.security.authz.interceptor.SearchRequestInterceptor;
@@ -353,6 +355,8 @@ public class Security extends Plugin implements SystemIndexPlugin, IngestPlugin,
353355
LicensedFeature.momentaryLenient(null, "security-ip-filtering", License.OperationMode.GOLD);
354356
public static final LicensedFeature.Momentary AUDITING_FEATURE =
355357
LicensedFeature.momentaryLenient(null, "security-auditing", License.OperationMode.GOLD);
358+
public static final LicensedFeature.Momentary TOKEN_SERVICE_FEATURE =
359+
LicensedFeature.momentaryLenient(null, "security-token-service", License.OperationMode.STANDARD);
356360

357361
private static final String REALMS_FEATURE_FAMILY = "security-realms";
358362
// Builtin realms (file/native) realms are Basic licensed, so don't need to be checked or tracked
@@ -630,7 +634,7 @@ Collection<Object> createComponents(Client client, ThreadPool threadPool, Cluste
630634
);
631635
final CompositeRolesStore allRolesStore = new CompositeRolesStore(settings, roleProviders,
632636
privilegeStore, threadPool.getThreadContext(), getLicenseState(), fieldPermissionsCache, apiKeyService,
633-
serviceAccountService, dlsBitsetCache.get(),
637+
serviceAccountService, dlsBitsetCache.get(),
634638
new DeprecationRoleDescriptorConsumer(clusterService, threadPool));
635639
securityIndex.get().addStateListener(allRolesStore::onSecurityIndexStateChange);
636640

x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/TokenService.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
import org.elasticsearch.xpack.core.security.authc.TokenMetadata;
9494
import org.elasticsearch.xpack.core.security.authc.support.Hasher;
9595
import org.elasticsearch.xpack.core.security.authc.support.TokensInvalidationResult;
96+
import org.elasticsearch.xpack.security.Security;
9697
import org.elasticsearch.xpack.security.support.FeatureNotEnabledException;
9798
import org.elasticsearch.xpack.security.support.FeatureNotEnabledException.Feature;
9899
import org.elasticsearch.xpack.security.support.SecurityIndexManager;
@@ -1591,12 +1592,12 @@ private static String getTokenIdFromDocumentId(String docId) {
15911592

15921593
private boolean isEnabled() {
15931594
return enabled && licenseState.isSecurityEnabled() &&
1594-
licenseState.checkFeature(XPackLicenseState.Feature.SECURITY_TOKEN_SERVICE);
1595+
Security.TOKEN_SERVICE_FEATURE.check(licenseState);
15951596
}
15961597

15971598
private void ensureEnabled() {
15981599
if (licenseState.isSecurityEnabled() == false ||
1599-
licenseState.checkFeature(XPackLicenseState.Feature.SECURITY_TOKEN_SERVICE) == false) {
1600+
Security.TOKEN_SERVICE_FEATURE.check(licenseState) == false) {
16001601
throw LicenseUtils.newComplianceException("security tokens");
16011602
}
16021603
if (enabled == false) {

x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/oauth2/TokenBaseRestHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
import org.elasticsearch.common.settings.Settings;
1313
import org.elasticsearch.license.LicenseUtils;
1414
import org.elasticsearch.license.XPackLicenseState;
15-
import org.elasticsearch.license.XPackLicenseState.Feature;
1615
import org.elasticsearch.rest.RestRequest;
16+
import org.elasticsearch.xpack.security.Security;
1717
import org.elasticsearch.xpack.security.rest.action.SecurityBaseRestHandler;
1818

1919
/**
@@ -32,7 +32,7 @@ protected Exception checkFeatureAvailable(RestRequest request) {
3232
Exception failedFeature = super.checkFeatureAvailable(request);
3333
if (failedFeature != null) {
3434
return failedFeature;
35-
} else if (licenseState.checkFeature(Feature.SECURITY_TOKEN_SERVICE)) {
35+
} else if (Security.TOKEN_SERVICE_FEATURE.check(licenseState)) {
3636
return null;
3737
} else {
3838
logger.info("Security tokens are not available under the current [{}] license", licenseState.getOperationMode().description());

x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/oidc/TransportOpenIdConnectLogoutActionTests.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
package org.elasticsearch.xpack.security.action.oidc;
88

99
import com.nimbusds.jwt.JWT;
10+
1011
import org.elasticsearch.action.ActionListener;
1112
import org.elasticsearch.action.bulk.BulkAction;
1213
import org.elasticsearch.action.bulk.BulkItemResponse;
@@ -32,8 +33,7 @@
3233
import org.elasticsearch.env.Environment;
3334
import org.elasticsearch.env.TestEnvironment;
3435
import org.elasticsearch.index.shard.ShardId;
35-
import org.elasticsearch.license.XPackLicenseState;
36-
import org.elasticsearch.license.XPackLicenseState.Feature;
36+
import org.elasticsearch.license.MockLicenseState;
3737
import org.elasticsearch.tasks.Task;
3838
import org.elasticsearch.test.ClusterServiceUtils;
3939
import org.elasticsearch.threadpool.ThreadPool;
@@ -47,13 +47,14 @@
4747
import org.elasticsearch.xpack.core.security.authc.Authentication;
4848
import org.elasticsearch.xpack.core.security.authc.RealmConfig;
4949
import org.elasticsearch.xpack.core.security.authc.oidc.OpenIdConnectRealmSettings;
50+
import org.elasticsearch.xpack.core.security.authc.support.UserRoleMapper;
5051
import org.elasticsearch.xpack.core.security.user.User;
5152
import org.elasticsearch.xpack.core.ssl.SSLService;
53+
import org.elasticsearch.xpack.security.Security;
5254
import org.elasticsearch.xpack.security.authc.Realms;
5355
import org.elasticsearch.xpack.security.authc.TokenService;
5456
import org.elasticsearch.xpack.security.authc.oidc.OpenIdConnectRealm;
5557
import org.elasticsearch.xpack.security.authc.oidc.OpenIdConnectTestCase;
56-
import org.elasticsearch.xpack.core.security.authc.support.UserRoleMapper;
5758
import org.elasticsearch.xpack.security.support.SecurityIndexManager;
5859
import org.junit.After;
5960
import org.junit.Before;
@@ -181,9 +182,9 @@ public void setup() throws Exception {
181182

182183
final ClusterService clusterService = ClusterServiceUtils.createClusterService(threadPool);
183184

184-
final XPackLicenseState licenseState = mock(XPackLicenseState.class);
185+
final MockLicenseState licenseState = mock(MockLicenseState.class);
185186
when(licenseState.isSecurityEnabled()).thenReturn(true);
186-
when(licenseState.checkFeature(Feature.SECURITY_TOKEN_SERVICE)).thenReturn(true);
187+
when(licenseState.isAllowed(Security.TOKEN_SERVICE_FEATURE)).thenReturn(true);
187188

188189
tokenService = new TokenService(settings, Clock.systemUTC(), client, licenseState, new SecurityContext(settings, threadContext),
189190
securityIndex, securityIndex, clusterService);

x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/saml/TransportSamlInvalidateSessionActionTests.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88

99
import org.apache.lucene.search.TotalHits;
1010
import org.elasticsearch.ExceptionsHelper;
11-
import org.elasticsearch.action.ActionType;
1211
import org.elasticsearch.action.ActionListener;
1312
import org.elasticsearch.action.ActionRequest;
1413
import org.elasticsearch.action.ActionResponse;
14+
import org.elasticsearch.action.ActionType;
1515
import org.elasticsearch.action.bulk.BulkAction;
1616
import org.elasticsearch.action.bulk.BulkItemResponse;
1717
import org.elasticsearch.action.bulk.BulkRequest;
@@ -35,20 +35,16 @@
3535
import org.elasticsearch.cluster.service.ClusterService;
3636
import org.elasticsearch.common.UUIDs;
3737
import org.elasticsearch.common.bytes.BytesReference;
38-
import org.elasticsearch.core.PathUtils;
3938
import org.elasticsearch.common.settings.Settings;
4039
import org.elasticsearch.common.util.concurrent.ThreadContext;
41-
import org.elasticsearch.xcontent.DeprecationHandler;
42-
import org.elasticsearch.xcontent.NamedXContentRegistry;
43-
import org.elasticsearch.xcontent.XContentType;
40+
import org.elasticsearch.core.PathUtils;
4441
import org.elasticsearch.env.Environment;
4542
import org.elasticsearch.env.TestEnvironment;
4643
import org.elasticsearch.index.query.BoolQueryBuilder;
4744
import org.elasticsearch.index.query.QueryBuilder;
4845
import org.elasticsearch.index.query.TermQueryBuilder;
4946
import org.elasticsearch.index.shard.ShardId;
50-
import org.elasticsearch.license.XPackLicenseState;
51-
import org.elasticsearch.license.XPackLicenseState.Feature;
47+
import org.elasticsearch.license.MockLicenseState;
5248
import org.elasticsearch.search.SearchHit;
5349
import org.elasticsearch.search.SearchHits;
5450
import org.elasticsearch.tasks.Task;
@@ -57,6 +53,9 @@
5753
import org.elasticsearch.threadpool.ThreadPool;
5854
import org.elasticsearch.transport.Transport;
5955
import org.elasticsearch.transport.TransportService;
56+
import org.elasticsearch.xcontent.DeprecationHandler;
57+
import org.elasticsearch.xcontent.NamedXContentRegistry;
58+
import org.elasticsearch.xcontent.XContentType;
6059
import org.elasticsearch.xpack.core.XPackSettings;
6160
import org.elasticsearch.xpack.core.security.SecurityContext;
6261
import org.elasticsearch.xpack.core.security.action.saml.SamlInvalidateSessionRequest;
@@ -68,6 +67,7 @@
6867
import org.elasticsearch.xpack.core.security.authc.esnative.NativeRealmSettings;
6968
import org.elasticsearch.xpack.core.security.authc.saml.SamlRealmSettings;
7069
import org.elasticsearch.xpack.core.security.user.User;
70+
import org.elasticsearch.xpack.security.Security;
7171
import org.elasticsearch.xpack.security.authc.Realms;
7272
import org.elasticsearch.xpack.security.authc.TokenService;
7373
import org.elasticsearch.xpack.security.authc.saml.SamlLogoutRequestHandler;
@@ -206,9 +206,9 @@ void doExecute(ActionType<Response> action, Request request, ActionListener<Resp
206206
when(securityIndex.aliasName()).thenReturn(".security");
207207
when(securityIndex.freeze()).thenReturn(securityIndex);
208208

209-
final XPackLicenseState licenseState = mock(XPackLicenseState.class);
209+
final MockLicenseState licenseState = mock(MockLicenseState.class);
210210
when(licenseState.isSecurityEnabled()).thenReturn(true);
211-
when(licenseState.checkFeature(Feature.SECURITY_TOKEN_SERVICE)).thenReturn(true);
211+
when(licenseState.isAllowed(Security.TOKEN_SERVICE_FEATURE)).thenReturn(true);
212212

213213
final ClusterService clusterService = ClusterServiceUtils.createClusterService(threadPool);
214214
final SecurityContext securityContext = new SecurityContext(settings, threadContext);

x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/saml/TransportSamlLogoutActionTests.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,13 @@
3333
import org.elasticsearch.cluster.service.ClusterService;
3434
import org.elasticsearch.common.UUIDs;
3535
import org.elasticsearch.common.collect.MapBuilder;
36-
import org.elasticsearch.core.PathUtils;
3736
import org.elasticsearch.common.settings.Settings;
3837
import org.elasticsearch.common.util.concurrent.ThreadContext;
38+
import org.elasticsearch.core.PathUtils;
3939
import org.elasticsearch.env.Environment;
4040
import org.elasticsearch.env.TestEnvironment;
4141
import org.elasticsearch.index.shard.ShardId;
42-
import org.elasticsearch.license.XPackLicenseState;
43-
import org.elasticsearch.license.XPackLicenseState.Feature;
42+
import org.elasticsearch.license.MockLicenseState;
4443
import org.elasticsearch.tasks.Task;
4544
import org.elasticsearch.test.ClusterServiceUtils;
4645
import org.elasticsearch.threadpool.ThreadPool;
@@ -55,15 +54,16 @@
5554
import org.elasticsearch.xpack.core.security.authc.RealmConfig;
5655
import org.elasticsearch.xpack.core.security.authc.RealmConfig.RealmIdentifier;
5756
import org.elasticsearch.xpack.core.security.authc.saml.SamlRealmSettings;
57+
import org.elasticsearch.xpack.core.security.authc.support.UserRoleMapper;
5858
import org.elasticsearch.xpack.core.security.user.User;
5959
import org.elasticsearch.xpack.core.ssl.SSLService;
60+
import org.elasticsearch.xpack.security.Security;
6061
import org.elasticsearch.xpack.security.authc.Realms;
6162
import org.elasticsearch.xpack.security.authc.TokenService;
6263
import org.elasticsearch.xpack.security.authc.saml.SamlNameId;
6364
import org.elasticsearch.xpack.security.authc.saml.SamlRealm;
6465
import org.elasticsearch.xpack.security.authc.saml.SamlRealmTests;
6566
import org.elasticsearch.xpack.security.authc.saml.SamlTestCase;
66-
import org.elasticsearch.xpack.core.security.authc.support.UserRoleMapper;
6767
import org.elasticsearch.xpack.security.support.SecurityIndexManager;
6868
import org.junit.After;
6969
import org.junit.Before;
@@ -208,9 +208,9 @@ public void setup() throws Exception {
208208
when(securityIndex.isAvailable()).thenReturn(true);
209209
when(securityIndex.freeze()).thenReturn(securityIndex);
210210

211-
final XPackLicenseState licenseState = mock(XPackLicenseState.class);
211+
final MockLicenseState licenseState = mock(MockLicenseState.class);
212212
when(licenseState.isSecurityEnabled()).thenReturn(true);
213-
when(licenseState.checkFeature(Feature.SECURITY_TOKEN_SERVICE)).thenReturn(true);
213+
when(licenseState.isAllowed(Security.TOKEN_SERVICE_FEATURE)).thenReturn(true);
214214
final ClusterService clusterService = ClusterServiceUtils.createClusterService(threadPool);
215215
final SecurityContext securityContext = new SecurityContext(settings, threadContext);
216216
tokenService = new TokenService(settings, Clock.systemUTC(), client, licenseState, securityContext, securityIndex, securityIndex,

x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/token/TransportCreateTokenActionTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@
3333
import org.elasticsearch.common.settings.SecureString;
3434
import org.elasticsearch.common.settings.Settings;
3535
import org.elasticsearch.index.shard.ShardId;
36-
import org.elasticsearch.license.XPackLicenseState;
37-
import org.elasticsearch.license.XPackLicenseState.Feature;
36+
import org.elasticsearch.license.MockLicenseState;
3837
import org.elasticsearch.mock.orig.Mockito;
3938
import org.elasticsearch.node.Node;
4039
import org.elasticsearch.rest.RestStatus;
@@ -52,6 +51,7 @@
5251
import org.elasticsearch.xpack.core.security.authc.AuthenticationToken;
5352
import org.elasticsearch.xpack.core.security.authc.support.UsernamePasswordToken;
5453
import org.elasticsearch.xpack.core.security.user.User;
54+
import org.elasticsearch.xpack.security.Security;
5555
import org.elasticsearch.xpack.security.authc.AuthenticationService;
5656
import org.elasticsearch.xpack.security.authc.TokenService;
5757
import org.elasticsearch.xpack.security.authc.kerberos.KerberosAuthenticationToken;
@@ -89,7 +89,7 @@ public class TransportCreateTokenActionTests extends ESTestCase {
8989
private ClusterService clusterService;
9090
private AtomicReference<IndexRequest> idxReqReference;
9191
private AuthenticationService authenticationService;
92-
private XPackLicenseState license;
92+
private MockLicenseState license;
9393
private SecurityContext securityContext;
9494

9595
@Before
@@ -178,9 +178,9 @@ && new String((byte[]) token.credentials(), StandardCharsets.UTF_8).equals("fail
178178

179179
this.clusterService = ClusterServiceUtils.createClusterService(threadPool);
180180

181-
this.license = mock(XPackLicenseState.class);
181+
this.license = mock(MockLicenseState.class);
182182
when(license.isSecurityEnabled()).thenReturn(true);
183-
when(license.checkFeature(Feature.SECURITY_TOKEN_SERVICE)).thenReturn(true);
183+
when(license.isAllowed(Security.TOKEN_SERVICE_FEATURE)).thenReturn(true);
184184
}
185185

186186
@After

x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/token/TransportInvalidateTokenActionTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
import org.elasticsearch.common.settings.Settings;
2020
import org.elasticsearch.index.Index;
2121
import org.elasticsearch.indices.IndexClosedException;
22-
import org.elasticsearch.license.XPackLicenseState;
23-
import org.elasticsearch.license.XPackLicenseState.Feature;
22+
import org.elasticsearch.license.MockLicenseState;
2423
import org.elasticsearch.node.Node;
2524
import org.elasticsearch.rest.RestStatus;
2625
import org.elasticsearch.test.ClusterServiceUtils;
@@ -32,6 +31,7 @@
3231
import org.elasticsearch.xpack.core.security.SecurityContext;
3332
import org.elasticsearch.xpack.core.security.action.token.InvalidateTokenRequest;
3433
import org.elasticsearch.xpack.core.security.action.token.InvalidateTokenResponse;
34+
import org.elasticsearch.xpack.security.Security;
3535
import org.elasticsearch.xpack.security.authc.TokenService;
3636
import org.elasticsearch.xpack.security.support.SecurityIndexManager;
3737
import org.junit.After;
@@ -58,7 +58,7 @@ public class TransportInvalidateTokenActionTests extends ESTestCase {
5858
private Client client;
5959
private SecurityIndexManager securityIndex;
6060
private ClusterService clusterService;
61-
private XPackLicenseState license;
61+
private MockLicenseState license;
6262
private SecurityContext securityContext;
6363

6464
@Before
@@ -70,9 +70,9 @@ public void setup() {
7070
when(client.settings()).thenReturn(SETTINGS);
7171
securityIndex = mock(SecurityIndexManager.class);
7272
this.clusterService = ClusterServiceUtils.createClusterService(threadPool);
73-
this.license = mock(XPackLicenseState.class);
73+
this.license = mock(MockLicenseState.class);
7474
when(license.isSecurityEnabled()).thenReturn(true);
75-
when(license.checkFeature(Feature.SECURITY_TOKEN_SERVICE)).thenReturn(true);
75+
when(license.isAllowed(Security.TOKEN_SERVICE_FEATURE)).thenReturn(true);
7676
}
7777

7878
public void testInvalidateTokensWhenIndexUnavailable() throws Exception {

x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/AuthenticationServiceTests.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,8 @@
3232
import org.elasticsearch.cluster.health.ClusterHealthStatus;
3333
import org.elasticsearch.cluster.metadata.IndexMetadata;
3434
import org.elasticsearch.cluster.service.ClusterService;
35-
import org.elasticsearch.core.SuppressForbidden;
3635
import org.elasticsearch.common.UUIDs;
3736
import org.elasticsearch.common.bytes.BytesReference;
38-
import org.elasticsearch.core.Tuple;
3937
import org.elasticsearch.common.io.stream.BytesStreamOutput;
4038
import org.elasticsearch.common.io.stream.StreamInput;
4139
import org.elasticsearch.common.io.stream.StreamOutput;
@@ -44,8 +42,8 @@
4442
import org.elasticsearch.common.settings.Settings;
4543
import org.elasticsearch.common.transport.TransportAddress;
4644
import org.elasticsearch.common.util.concurrent.ThreadContext;
47-
import org.elasticsearch.xcontent.NamedXContentRegistry;
48-
import org.elasticsearch.xcontent.json.JsonXContent;
45+
import org.elasticsearch.core.SuppressForbidden;
46+
import org.elasticsearch.core.Tuple;
4947
import org.elasticsearch.env.Environment;
5048
import org.elasticsearch.env.TestEnvironment;
5149
import org.elasticsearch.index.get.GetResult;
@@ -55,7 +53,6 @@
5553
import org.elasticsearch.license.LicensedFeature;
5654
import org.elasticsearch.license.MockLicenseState;
5755
import org.elasticsearch.license.XPackLicenseState;
58-
import org.elasticsearch.license.XPackLicenseState.Feature;
5956
import org.elasticsearch.rest.RestRequest;
6057
import org.elasticsearch.rest.RestStatus;
6158
import org.elasticsearch.test.ClusterServiceUtils;
@@ -66,6 +63,8 @@
6663
import org.elasticsearch.threadpool.TestThreadPool;
6764
import org.elasticsearch.threadpool.ThreadPool;
6865
import org.elasticsearch.transport.TransportRequest;
66+
import org.elasticsearch.xcontent.NamedXContentRegistry;
67+
import org.elasticsearch.xcontent.json.JsonXContent;
6968
import org.elasticsearch.xpack.core.XPackField;
7069
import org.elasticsearch.xpack.core.XPackSettings;
7170
import org.elasticsearch.xpack.core.security.SecurityContext;
@@ -227,7 +226,7 @@ public void init() throws Exception {
227226
}
228227
}
229228
when(licenseState.isAllowed(Security.CUSTOM_REALMS_FEATURE)).thenReturn(true);
230-
when(licenseState.checkFeature(Feature.SECURITY_TOKEN_SERVICE)).thenReturn(true);
229+
when(licenseState.isAllowed(Security.TOKEN_SERVICE_FEATURE)).thenReturn(true);
231230
when(licenseState.copyCurrentLicenseState()).thenReturn(licenseState);
232231
when(licenseState.isAllowed(Security.AUDITING_FEATURE)).thenReturn(true);
233232
when(licenseState.getOperationMode()).thenReturn(randomFrom(License.OperationMode.ENTERPRISE, License.OperationMode.PLATINUM));

0 commit comments

Comments
 (0)