Skip to content

Commit bf3d46b

Browse files
committed
Simlify
1 parent 8fcb15c commit bf3d46b

File tree

3 files changed

+12
-46
lines changed

3 files changed

+12
-46
lines changed

x-pack/plugin/security/qa/multi-cluster/src/javaRestTest/java/org/elasticsearch/xpack/remotecluster/RemoteClusterSecurityFcActionAuthorizationIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ public void testUpdateCrossClusterApiKey() throws Exception {
483483
+ "for user [foo] with assigned roles [role] authenticated by API key id ["
484484
+ apiKeyId
485485
+ "] of user [test_user] on indices [index], this action is granted by the index privileges "
486-
+ "[view_index_metadata,manage,all]"
486+
+ "[view_index_metadata,manage,read,all]"
487487
)
488488
);
489489
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,10 @@ public void testSecurityIndicesAreRestrictedForDefaultRole() {
187187
}
188188

189189
public void testSecurityIndicesAreNotRemovedFromUnrestrictedRole() {
190-
Role.Builder builder = Role.builder(RESTRICTED_INDICES, randomAlphaOfLength(8));
191-
Role role = builder.add(FieldPermissions.DEFAULT, null, IndexPrivilege.ALL, true, "*").cluster(Set.of("all"), Set.of()).build();
190+
Role role = Role.builder(RESTRICTED_INDICES, randomAlphaOfLength(8))
191+
.add(FieldPermissions.DEFAULT, null, IndexPrivilege.ALL, true, "*")
192+
.cluster(Set.of("all"), Set.of())
193+
.build();
192194
Settings indexSettings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build();
193195
final String internalSecurityIndex = randomFrom(
194196
TestRestrictedIndices.INTERNAL_SECURITY_MAIN_INDEX_6,

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

Lines changed: 7 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@
8686
import org.elasticsearch.xpack.core.security.authz.privilege.ApplicationPrivilegeTests;
8787
import org.elasticsearch.xpack.core.security.authz.privilege.ClusterPrivilegeResolver;
8888
import org.elasticsearch.xpack.core.security.authz.privilege.ConfigurableClusterPrivilege;
89-
import org.elasticsearch.xpack.core.security.authz.privilege.IndexComponentSelectorPrivilege;
9089
import org.elasticsearch.xpack.core.security.authz.privilege.IndexPrivilege;
9190
import org.elasticsearch.xpack.core.security.authz.restriction.Workflow;
9291
import org.elasticsearch.xpack.core.security.authz.restriction.WorkflowResolver;
@@ -1270,7 +1269,6 @@ public void testBuildRoleWithFlsAndDlsInRemoteIndicesDefinition() {
12701269
false,
12711270
"{\"match\":{\"field\":\"a\"}}",
12721271
new FieldPermissionsDefinition.FieldGrantExcludeGroup(new String[] { "field" }, null),
1273-
IndexComponentSelectorPrivilege.DATA,
12741272
"index-1"
12751273
)
12761274
);
@@ -1306,15 +1304,13 @@ public void testBuildRoleWithFlsAndDlsInRemoteIndicesDefinition() {
13061304
false,
13071305
"{\"match\":{\"field\":\"a\"}}",
13081306
new FieldPermissionsDefinition.FieldGrantExcludeGroup(new String[] { "field" }, null),
1309-
IndexComponentSelectorPrivilege.DATA,
13101307
"index-1"
13111308
),
13121309
indexGroup(
13131310
IndexPrivilege.READ,
13141311
false,
13151312
"{\"match\":{\"field\":\"b\"}}",
13161313
new FieldPermissionsDefinition.FieldGrantExcludeGroup(new String[] { "other" }, null),
1317-
IndexComponentSelectorPrivilege.DATA,
13181314
"index-1"
13191315
)
13201316
);
@@ -1542,10 +1538,7 @@ public void testBuildRoleWithReadFailureStorePrivilegeOnly() {
15421538
new IndicesPrivileges[] { IndicesPrivileges.builder().indices(indexPattern).privileges("read_failure_store").build() }
15431539
)
15441540
);
1545-
assertHasIndexGroups(
1546-
role.indices(),
1547-
indexGroup(IndexPrivilege.READ_FAILURE_STORE, false, IndexComponentSelectorPrivilege.FAILURES, indexPattern)
1548-
);
1541+
assertHasIndexGroups(role.indices(), indexGroup(IndexPrivilege.READ_FAILURE_STORE, false, indexPattern));
15491542
}
15501543

15511544
public void testBuildRoleWithReadFailureStorePrivilegeDuplicatesMerged() {
@@ -1558,10 +1551,7 @@ public void testBuildRoleWithReadFailureStorePrivilegeDuplicatesMerged() {
15581551
IndicesPrivileges.builder().indices(indexPattern).privileges("read_failure_store").build() }
15591552
)
15601553
);
1561-
assertHasIndexGroups(
1562-
role.indices(),
1563-
indexGroup(IndexPrivilege.READ_FAILURE_STORE, false, IndexComponentSelectorPrivilege.FAILURES, indexPattern)
1564-
);
1554+
assertHasIndexGroups(role.indices(), indexGroup(IndexPrivilege.READ_FAILURE_STORE, false, indexPattern));
15651555
}
15661556

15671557
public void testBuildRoleWithReadFailureStoreAndReadPrivilegeSplit() {
@@ -1575,8 +1565,8 @@ public void testBuildRoleWithReadFailureStoreAndReadPrivilegeSplit() {
15751565
);
15761566
assertHasIndexGroups(
15771567
role.indices(),
1578-
indexGroup(IndexPrivilege.READ_FAILURE_STORE, false, IndexComponentSelectorPrivilege.FAILURES, indexPattern),
1579-
indexGroup(IndexPrivilege.READ, false, IndexComponentSelectorPrivilege.DATA, indexPattern)
1568+
indexGroup(IndexPrivilege.READ_FAILURE_STORE, false, indexPattern),
1569+
indexGroup(IndexPrivilege.READ, false, indexPattern)
15801570
);
15811571
}
15821572

@@ -1592,8 +1582,8 @@ public void testBuildRoleWithMultipleReadFailureStoreAndReadPrivilegeSplit() {
15921582
);
15931583
assertHasIndexGroups(
15941584
role.indices(),
1595-
indexGroup(IndexPrivilege.READ_FAILURE_STORE, false, IndexComponentSelectorPrivilege.FAILURES, indexPattern),
1596-
indexGroup(IndexPrivilege.READ, false, IndexComponentSelectorPrivilege.DATA, indexPattern)
1585+
indexGroup(IndexPrivilege.READ_FAILURE_STORE, false, indexPattern),
1586+
indexGroup(IndexPrivilege.READ, false, indexPattern)
15971587
);
15981588
}
15991589

@@ -1609,12 +1599,7 @@ public void testBuildRoleWithAllPrivilegeIsNeverSplit() {
16091599
);
16101600
assertHasIndexGroups(
16111601
role.indices(),
1612-
indexGroup(
1613-
IndexPrivilege.get(Set.of("read", "read_failure_store", "all")),
1614-
false,
1615-
IndexComponentSelectorPrivilege.ALL,
1616-
indexPattern
1617-
)
1602+
indexGroup(IndexPrivilege.get(Set.of("read", "read_failure_store", "all")), false, indexPattern)
16181603
);
16191604
}
16201605

@@ -3470,23 +3455,6 @@ private static Matcher<IndicesPermission.Group> indexGroup(
34703455
allowRestrictedIndices,
34713456
null,
34723457
new FieldPermissionsDefinition.FieldGrantExcludeGroup(null, null),
3473-
IndexComponentSelectorPrivilege.DATA,
3474-
indices
3475-
);
3476-
}
3477-
3478-
private static Matcher<IndicesPermission.Group> indexGroup(
3479-
final IndexPrivilege privilege,
3480-
final boolean allowRestrictedIndices,
3481-
final IndexComponentSelectorPrivilege selectorPrivilege,
3482-
final String... indices
3483-
) {
3484-
return indexGroup(
3485-
privilege,
3486-
allowRestrictedIndices,
3487-
null,
3488-
new FieldPermissionsDefinition.FieldGrantExcludeGroup(null, null),
3489-
selectorPrivilege,
34903458
indices
34913459
);
34923460
}
@@ -3496,7 +3464,6 @@ private static Matcher<IndicesPermission.Group> indexGroup(
34963464
final boolean allowRestrictedIndices,
34973465
@Nullable final String query,
34983466
final FieldPermissionsDefinition.FieldGrantExcludeGroup flsGroup,
3499-
IndexComponentSelectorPrivilege selectorPrivilege,
35003467
final String... indices
35013468
) {
35023469
return new BaseMatcher<>() {
@@ -3510,7 +3477,6 @@ public boolean matches(Object o) {
35103477
&& equalTo(privilege).matches(group.privilege())
35113478
&& equalTo(allowRestrictedIndices).matches(group.allowRestrictedIndices())
35123479
&& equalTo(new FieldPermissions(new FieldPermissionsDefinition(Set.of(flsGroup)))).matches(group.getFieldPermissions())
3513-
&& equalTo(selectorPrivilege).matches(group.getSelectorPrivilege())
35143480
&& arrayContaining(indices).matches(group.indices());
35153481
}
35163482

@@ -3528,8 +3494,6 @@ public void describeTo(Description description) {
35283494
+ query
35293495
+ ", fieldGrantExcludeGroup="
35303496
+ flsGroup
3531-
+ ", selectorPrivilege="
3532-
+ selectorPrivilege
35333497
+ '}'
35343498
);
35353499
}

0 commit comments

Comments
 (0)