Skip to content

Commit

Permalink
test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rjernst committed Mar 5, 2025
1 parent 39742f0 commit 1e34cd7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ record ExclusivePath(String componentName, Set<String> moduleNames, String path)

@Override
public String toString() {
return "[[" + componentName + "] [" + moduleNames + "] [" + path + "]]";
return "[[" + componentName + "] " + moduleNames + " [" + path + "]]";
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import static org.elasticsearch.entitlement.runtime.policy.PolicyManager.ALL_UNNAMED;
import static org.elasticsearch.entitlement.runtime.policy.PolicyManager.SERVER_COMPONENT_NAME;
import static org.hamcrest.Matchers.aMapWithSize;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;

Expand Down Expand Up @@ -412,9 +413,9 @@ public void testDuplicateEntitlements() {
}

public void testFilesEntitlementsWithExclusive() {
var baseTestPath = Path.of("/tmp").toAbsolutePath();
var testPath1 = Path.of("/tmp/test").toAbsolutePath();
var testPath2 = Path.of("/tmp/test/foo").toAbsolutePath();
var baseTestPath = Path.of("/base").toAbsolutePath();
var testPath1 = Path.of("/base/test").toAbsolutePath();
var testPath2 = Path.of("/base/test/foo").toAbsolutePath();
var iae = expectThrows(
IllegalArgumentException.class,
() -> new PolicyManager(
Expand All @@ -426,7 +427,7 @@ public void testFilesEntitlementsWithExclusive() {
"test",
List.of(
new Scope(
"test",
"test.module1",
List.of(
new FilesEntitlement(
List.of(FilesEntitlement.FileData.ofPath(testPath1, FilesEntitlement.Mode.READ).withExclusive(true))
Expand All @@ -440,7 +441,7 @@ public void testFilesEntitlementsWithExclusive() {
"test",
List.of(
new Scope(
"test",
"test.module2",
List.of(
new FilesEntitlement(
List.of(FilesEntitlement.FileData.ofPath(testPath1, FilesEntitlement.Mode.READ).withExclusive(true))
Expand All @@ -457,8 +458,8 @@ public void testFilesEntitlementsWithExclusive() {
Set.of()
)
);
assertTrue(iae.getMessage().contains("duplicate/overlapping exclusive paths found in files entitlements:"));
assertTrue(iae.getMessage().contains(Strings.format("[test] [%s]]", testPath1.toString())));
assertThat(iae.getMessage(),
containsString("Path [/base/test] is exclusive to plugin2/test.module2 and plugin1/[test.module1]"));

iae = expectThrows(
IllegalArgumentException.class,
Expand Down

0 comments on commit 1e34cd7

Please sign in to comment.