Skip to content

Commit 02cbdb2

Browse files
authored
[Test] Fix remote indices handling for release tests (#95432)
Remote indices is behind feature flag and should be conditionally handled for release tests. Relates: #94817, #94714
1 parent 3bd41b2 commit 02cbdb2

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/store/FileRolesStoreTests.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ public void testParseFileWithFLSAndDLSDisabled() throws Exception {
361361
assertThat(roles.get("role_query_fields"), nullValue());
362362
assertThat(roles.get("role_query_invalid"), nullValue());
363363

364-
assertThat(events, hasSize(4));
364+
assertThat(events, hasSize(TcpTransport.isUntrustedRemoteClusterEnabled() ? 4 : 5));
365365
assertThat(
366366
events.get(0),
367367
startsWith(
@@ -394,6 +394,9 @@ public void testParseFileWithFLSAndDLSDisabled() throws Exception {
394394
+ "]. document and field level security is not enabled."
395395
)
396396
);
397+
if (false == TcpTransport.isUntrustedRemoteClusterEnabled()) {
398+
assertThat(events.get(4), startsWith("failed to parse role [role_remote_indices]. unexpected field [remote_indices]"));
399+
}
397400
}
398401

399402
public void testParseFileWithFLSAndDLSUnlicensed() throws Exception {

x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/store/NativeRolesStoreTests.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import org.elasticsearch.test.VersionUtils;
3939
import org.elasticsearch.threadpool.TestThreadPool;
4040
import org.elasticsearch.threadpool.ThreadPool;
41+
import org.elasticsearch.transport.TcpTransport;
4142
import org.elasticsearch.xcontent.ToXContent;
4243
import org.elasticsearch.xcontent.XContentBuilder;
4344
import org.elasticsearch.xcontent.XContentType;
@@ -116,7 +117,7 @@ public void testRoleDescriptorWithFlsDlsLicensing() throws IOException {
116117
generateRandomStringArray(5, randomIntBetween(2, 8), true, true),
117118
RoleDescriptorTests.randomRoleDescriptorMetadata(ESTestCase.randomBoolean()),
118119
null,
119-
RoleDescriptorTests.randomRemoteIndicesPrivileges(1, 2)
120+
TcpTransport.isUntrustedRemoteClusterEnabled() ? RoleDescriptorTests.randomRemoteIndicesPrivileges(1, 2) : null
120121
);
121122
assertFalse(flsRole.getTransientMetadata().containsKey("unlicensed_features"));
122123

@@ -131,7 +132,7 @@ public void testRoleDescriptorWithFlsDlsLicensing() throws IOException {
131132
generateRandomStringArray(5, randomIntBetween(2, 8), true, true),
132133
RoleDescriptorTests.randomRoleDescriptorMetadata(ESTestCase.randomBoolean()),
133134
null,
134-
RoleDescriptorTests.randomRemoteIndicesPrivileges(1, 2)
135+
TcpTransport.isUntrustedRemoteClusterEnabled() ? RoleDescriptorTests.randomRemoteIndicesPrivileges(1, 2) : null
135136
);
136137
assertFalse(dlsRole.getTransientMetadata().containsKey("unlicensed_features"));
137138

@@ -151,7 +152,7 @@ public void testRoleDescriptorWithFlsDlsLicensing() throws IOException {
151152
generateRandomStringArray(5, randomIntBetween(2, 8), true, true),
152153
RoleDescriptorTests.randomRoleDescriptorMetadata(ESTestCase.randomBoolean()),
153154
null,
154-
RoleDescriptorTests.randomRemoteIndicesPrivileges(1, 2)
155+
TcpTransport.isUntrustedRemoteClusterEnabled() ? RoleDescriptorTests.randomRemoteIndicesPrivileges(1, 2) : null
155156
);
156157
assertFalse(flsDlsRole.getTransientMetadata().containsKey("unlicensed_features"));
157158

@@ -164,7 +165,7 @@ public void testRoleDescriptorWithFlsDlsLicensing() throws IOException {
164165
generateRandomStringArray(5, randomIntBetween(2, 8), false, true),
165166
RoleDescriptorTests.randomRoleDescriptorMetadata(ESTestCase.randomBoolean()),
166167
null,
167-
RoleDescriptorTests.randomRemoteIndicesPrivileges(1, 2)
168+
TcpTransport.isUntrustedRemoteClusterEnabled() ? RoleDescriptorTests.randomRemoteIndicesPrivileges(1, 2) : null
168169
);
169170
assertFalse(noFlsDlsRole.getTransientMetadata().containsKey("unlicensed_features"));
170171

0 commit comments

Comments
 (0)