Skip to content

Commit 797085b

Browse files
committed
fix assertions on messages to work with windows paths too
1 parent 8baba58 commit 797085b

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

libs/entitlement/src/test/java/org/elasticsearch/entitlement/runtime/policy/PolicyManagerTests.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
package org.elasticsearch.entitlement.runtime.policy;
1111

1212
import org.elasticsearch.common.settings.Settings;
13+
import org.elasticsearch.core.Strings;
1314
import org.elasticsearch.entitlement.runtime.policy.PolicyManager.ModuleEntitlements;
1415
import org.elasticsearch.entitlement.runtime.policy.agent.TestAgent;
1516
import org.elasticsearch.entitlement.runtime.policy.agent.inner.TestInnerAgent;
@@ -411,6 +412,9 @@ public void testDuplicateEntitlements() {
411412
}
412413

413414
public void testFilesEntitlementsWithExclusive() {
415+
var baseTestPath = Path.of("/tmp").toAbsolutePath();
416+
var testPath1 = Path.of("/tmp/test").toAbsolutePath();
417+
var testPath2 = Path.of("/tmp/test/foo").toAbsolutePath();
414418
var iae = expectThrows(
415419
IllegalArgumentException.class,
416420
() -> new PolicyManager(
@@ -426,7 +430,7 @@ public void testFilesEntitlementsWithExclusive() {
426430
List.of(
427431
new FilesEntitlement(
428432
List.of(
429-
FilesEntitlement.FileData.ofPath(Path.of("/tmp/test"), FilesEntitlement.Mode.READ)
433+
FilesEntitlement.FileData.ofPath(testPath1, FilesEntitlement.Mode.READ)
430434
.withExclusive(true)
431435
)
432436
)
@@ -443,7 +447,7 @@ public void testFilesEntitlementsWithExclusive() {
443447
List.of(
444448
new FilesEntitlement(
445449
List.of(
446-
FilesEntitlement.FileData.ofPath(Path.of("/tmp/test"), FilesEntitlement.Mode.READ)
450+
FilesEntitlement.FileData.ofPath(testPath1, FilesEntitlement.Mode.READ)
447451
.withExclusive(true)
448452
)
449453
)
@@ -460,7 +464,7 @@ public void testFilesEntitlementsWithExclusive() {
460464
)
461465
);
462466
assertTrue(iae.getMessage().contains("duplicate/overlapping exclusive paths found in files entitlements:"));
463-
assertTrue(iae.getMessage().contains("[test] [/tmp/test]]"));
467+
assertTrue(iae.getMessage().contains(Strings.format("[test] [%s]]", testPath1.toString())));
464468

465469
iae = expectThrows(
466470
IllegalArgumentException.class,
@@ -473,9 +477,9 @@ public void testFilesEntitlementsWithExclusive() {
473477
List.of(
474478
new FilesEntitlement(
475479
List.of(
476-
FilesEntitlement.FileData.ofPath(Path.of("/tmp/test/foo"), FilesEntitlement.Mode.READ)
480+
FilesEntitlement.FileData.ofPath(testPath2, FilesEntitlement.Mode.READ)
477481
.withExclusive(true),
478-
FilesEntitlement.FileData.ofPath(Path.of("/tmp/"), FilesEntitlement.Mode.READ)
482+
FilesEntitlement.FileData.ofPath(baseTestPath, FilesEntitlement.Mode.READ)
479483
)
480484
)
481485
)
@@ -493,7 +497,7 @@ public void testFilesEntitlementsWithExclusive() {
493497
List.of(
494498
new FilesEntitlement(
495499
List.of(
496-
FilesEntitlement.FileData.ofPath(Path.of("/tmp/test"), FilesEntitlement.Mode.READ)
500+
FilesEntitlement.FileData.ofPath(testPath1, FilesEntitlement.Mode.READ)
497501
.withExclusive(true)
498502
)
499503
)
@@ -510,8 +514,8 @@ public void testFilesEntitlementsWithExclusive() {
510514
)
511515
);
512516
assertEquals(
513-
"duplicate/overlapping exclusive paths found in files entitlements: "
514-
+ "[[plugin1] [test] [/tmp/test]] and [[(server)] [test] [/tmp/test/foo]]",
517+
Strings.format("duplicate/overlapping exclusive paths found in files entitlements: "
518+
+ "[[plugin1] [test] [%s]] and [[(server)] [test] [%s]]", testPath1, testPath2),
515519
iae.getMessage()
516520
);
517521
}

muted-tests.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,9 +329,6 @@ tests:
329329
- class: org.elasticsearch.action.admin.cluster.node.tasks.CancellableTasksIT
330330
method: testChildrenTasksCancelledOnTimeout
331331
issue: https://github.com/elastic/elasticsearch/issues/123568
332-
- class: org.elasticsearch.entitlement.runtime.policy.PolicyManagerTests
333-
method: testFilesEntitlementsWithExclusive
334-
issue: https://github.com/elastic/elasticsearch/issues/123657
335332
- class: org.elasticsearch.test.rest.yaml.RcsCcsCommonYamlTestSuiteIT
336333
method: test {p0=search.vectors/41_knn_search_bbq_hnsw/Test knn search}
337334
issue: https://github.com/elastic/elasticsearch/issues/123727

0 commit comments

Comments
 (0)