Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -365,17 +365,17 @@ public void testDuplicatePrunedPaths() {

public void testDuplicateExclusivePaths() {
// Bunch o' handy definitions
var originalFileData = FileData.ofPath(path("/a/b"), READ).withExclusive(true);
var fileDataWithWriteMode = FileData.ofPath(path("/a/b"), READ_WRITE).withExclusive(true);
var pathAB = path("/a/b");
var pathCD = path("/c/d");
var originalFileData = FileData.ofPath(pathAB, READ).withExclusive(true);
var fileDataWithWriteMode = FileData.ofPath(pathAB, READ_WRITE).withExclusive(true);
var original = new ExclusiveFileEntitlement("component1", "module1", new FilesEntitlement(List.of(originalFileData)));
var differentComponent = new ExclusiveFileEntitlement("component2", original.moduleName(), original.filesEntitlement());
var differentModule = new ExclusiveFileEntitlement(original.componentName(), "module2", original.filesEntitlement());
var differentPath = new ExclusiveFileEntitlement(
original.componentName(),
original.moduleName(),
new FilesEntitlement(
List.of(FileData.ofPath(path("/c/d"), originalFileData.mode()).withExclusive(originalFileData.exclusive()))
)
new FilesEntitlement(List.of(FileData.ofPath(pathCD, originalFileData.mode()).withExclusive(originalFileData.exclusive())))
);
var differentMode = new ExclusiveFileEntitlement(
original.componentName(),
Expand All @@ -387,7 +387,7 @@ public void testDuplicateExclusivePaths() {
original.moduleName(),
new FilesEntitlement(List.of(originalFileData.withPlatform(WINDOWS)))
);
var originalExclusivePath = new ExclusivePath("component1", Set.of("module1"), normalizePath(path("/a/b")));
var originalExclusivePath = new ExclusivePath("component1", Set.of("module1"), normalizePath(pathAB));

// Some basic tests

Expand All @@ -409,12 +409,17 @@ public void testDuplicateExclusivePaths() {
originalExclusivePath,
new ExclusivePath("component2", Set.of(original.moduleName()), originalExclusivePath.path()),
new ExclusivePath(original.componentName(), Set.of("module2"), originalExclusivePath.path()),
new ExclusivePath(original.componentName(), Set.of(original.moduleName()), normalizePath(path("/c/d")))
new ExclusivePath(original.componentName(), Set.of(original.moduleName()), normalizePath(pathCD))
);
var iae = expectThrows(IllegalArgumentException.class, () -> buildExclusivePathList(distinctEntitlements, TEST_PATH_LOOKUP));
var pathABString = pathAB.toAbsolutePath().toString();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh the fix is this toAbsolutePath() call?

assertThat(
iae.getMessage(),
equalTo("Path [/a/b] is already exclusive to [component1][module1], cannot add exclusive access for [component2][module1]")
equalTo(
"Path ["
+ pathABString
+ "] is already exclusive to [component1][module1], cannot add exclusive access for [component2][module1]"
)
);

var equivalentEntitlements = List.of(original, differentMode, differentPlatform);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,9 @@ public void testDuplicateEntitlements() {
public void testFilesEntitlementsWithExclusive() {
var baseTestPath = Path.of("/base").toAbsolutePath();
var testPath1 = Path.of("/base/test").toAbsolutePath();
var testPath1String = testPath1.toString();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought these toString calls are not needed if the Strings.format call is using %s?

var testPath2 = Path.of("/base/test/foo").toAbsolutePath();
var testPath2String = testPath2.toAbsolutePath();
var iae = expectThrows(
IllegalArgumentException.class,
() -> new PolicyManager(
Expand Down Expand Up @@ -494,7 +496,9 @@ public void testFilesEntitlementsWithExclusive() {
assertThat(
iae.getMessage(),
equalTo(
"Path [/base/test] is already exclusive to [plugin1][test.module1],"
"Path ["
+ testPath1String
+ "] is already exclusive to [plugin1][test.module1],"
+ " cannot add exclusive access for [plugin2][test.module2]"
)
);
Expand Down Expand Up @@ -547,8 +551,8 @@ public void testFilesEntitlementsWithExclusive() {
Strings.format(
"duplicate/overlapping exclusive paths found in files entitlements: "
+ "[[plugin1] [test] [%s]] and [[(server)] [test] [%s]]",
testPath1,
testPath2
testPath1String,
testPath2String
),
iae.getMessage()
);
Expand Down
6 changes: 0 additions & 6 deletions muted-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -360,12 +360,6 @@ tests:
- class: org.elasticsearch.env.NodeEnvironmentTests
method: testIndexCompatibilityChecks
issue: https://github.com/elastic/elasticsearch/issues/124388
- class: org.elasticsearch.entitlement.runtime.policy.PolicyManagerTests
method: testFilesEntitlementsWithExclusive
issue: https://github.com/elastic/elasticsearch/issues/124420
- class: org.elasticsearch.entitlement.runtime.policy.FileAccessTreeTests
method: testDuplicateExclusivePaths
issue: https://github.com/elastic/elasticsearch/issues/124437
- class: org.elasticsearch.xpack.restart.FullClusterRestartIT
method: testWatcherWithApiKey {cluster=UPGRADED}
issue: https://github.com/elastic/elasticsearch/issues/124159
Expand Down