Skip to content

Commit 8459878

Browse files
committed
changelog and no birthday problems (no one wants those)
1 parent f3c503d commit 8459878

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

docs/changelog/135271.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
pr: 135271
2-
summary: Add role stats to `_security/stats`
2+
summary: Add DLS stats to `_security/stats`
33
area: Authorization
44
type: enhancement
55
issues: []

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/action/stats/GetSecurityStatsNodeResponseTests.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
import java.io.IOException;
1515
import java.util.Map;
16+
import java.util.Objects;
1617

1718
public class GetSecurityStatsNodeResponseTests extends AbstractWireSerializingTestCase<GetSecurityStatsNodeResponse> {
1819

@@ -24,16 +25,24 @@ protected Writeable.Reader<GetSecurityStatsNodeResponse> instanceReader() {
2425
@Override
2526
protected GetSecurityStatsNodeResponse createTestInstance() {
2627
return new GetSecurityStatsNodeResponse(
27-
DiscoveryNodeUtils.create(randomUUID()),
28-
randomBoolean() ? null : Map.of("key", randomUUID())
28+
DiscoveryNodeUtils.builder(randomAlphaOfLength(10)).ephemeralId(randomAlphanumericOfLength(10)).build(),
29+
randomBoolean() ? null : Map.of("key", randomAlphaOfLength(5))
2930
);
3031
}
3132

3233
@Override
3334
protected GetSecurityStatsNodeResponse mutateInstance(GetSecurityStatsNodeResponse instance) throws IOException {
35+
final var node = instance.getDiscoveryNode();
36+
final var value = Objects.requireNonNullElse(instance.getRolesStoreStats(), Map.of()).get("key");
3437
return switch (randomIntBetween(0, 1)) {
35-
case 0 -> new GetSecurityStatsNodeResponse(DiscoveryNodeUtils.create(randomUUID()), instance.getRolesStoreStats());
36-
case 1 -> new GetSecurityStatsNodeResponse(instance.getDiscoveryNode(), Map.of("key", randomUUID()));
38+
case 0 -> new GetSecurityStatsNodeResponse(
39+
DiscoveryNodeUtils.builder(randomValueOtherThan(node.getId(), () -> randomAlphaOfLength(10)))
40+
// DiscoverNode#hashCode only tests ephemeralId, so make sure to change it too
41+
.ephemeralId(randomValueOtherThan(node.getEphemeralId(), () -> randomAlphanumericOfLength(10)))
42+
.build(),
43+
instance.getRolesStoreStats()
44+
);
45+
case 1 -> new GetSecurityStatsNodeResponse(node, Map.of("key", randomValueOtherThan(value, () -> randomAlphaOfLength(5))));
3746
default -> throw new IllegalStateException("Unexpected value");
3847
};
3948
}

0 commit comments

Comments
 (0)