Skip to content

Commit 4d17aad

Browse files
committed
Use a consistent ordering in policy manager exclulsive tests
1 parent 8aaca61 commit 4d17aad

File tree

1 file changed

+30
-28
lines changed

1 file changed

+30
-28
lines changed

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

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import java.net.URLClassLoader;
3030
import java.nio.file.Path;
3131
import java.util.Arrays;
32+
import java.util.LinkedHashMap;
3233
import java.util.List;
3334
import java.util.Map;
3435
import java.util.Set;
@@ -448,41 +449,42 @@ public void testFilesEntitlementsWithExclusive() {
448449
var baseTestPath = Path.of("/base").toAbsolutePath();
449450
var testPath1 = Path.of("/base/test").toAbsolutePath();
450451
var testPath2 = Path.of("/base/test/foo").toAbsolutePath();
451-
var iae = expectThrows(
452-
IllegalArgumentException.class,
453-
() -> new PolicyManager(
454-
createEmptyTestServerPolicy(),
455-
List.of(),
456-
Map.of(
457-
"plugin1",
458-
new Policy(
459-
"test",
452+
var plugins = new LinkedHashMap<String, Policy>();
453+
plugins.put("plugin1",
454+
new Policy(
455+
"test",
456+
List.of(
457+
new Scope(
458+
"test.module1",
460459
List.of(
461-
new Scope(
462-
"test.module1",
463-
List.of(
464-
new FilesEntitlement(
465-
List.of(FilesEntitlement.FileData.ofPath(testPath1, FilesEntitlement.Mode.READ).withExclusive(true))
466-
)
467-
)
460+
new FilesEntitlement(
461+
List.of(FilesEntitlement.FileData.ofPath(testPath1, FilesEntitlement.Mode.READ).withExclusive(true))
468462
)
469463
)
470-
),
471-
"plugin2",
472-
new Policy(
473-
"test",
464+
)
465+
)
466+
));
467+
plugins.put(
468+
"plugin2",
469+
new Policy(
470+
"test",
471+
List.of(
472+
new Scope(
473+
"test.module2",
474474
List.of(
475-
new Scope(
476-
"test.module2",
477-
List.of(
478-
new FilesEntitlement(
479-
List.of(FilesEntitlement.FileData.ofPath(testPath1, FilesEntitlement.Mode.READ).withExclusive(true))
480-
)
481-
)
475+
new FilesEntitlement(
476+
List.of(FilesEntitlement.FileData.ofPath(testPath1, FilesEntitlement.Mode.READ).withExclusive(true))
482477
)
483478
)
484479
)
485-
),
480+
)
481+
));
482+
var iae = expectThrows(
483+
IllegalArgumentException.class,
484+
() -> new PolicyManager(
485+
createEmptyTestServerPolicy(),
486+
List.of(),
487+
plugins,
486488
c -> "",
487489
Map.of("plugin1", Path.of("modules", "plugin1"), "plugin2", Path.of("modules", "plugin2")),
488490
TEST_AGENTS_PACKAGE_NAME,

0 commit comments

Comments
 (0)