1212import org .elasticsearch .bootstrap .TestBuildInfo ;
1313import org .elasticsearch .bootstrap .TestBuildInfoParser ;
1414import org .elasticsearch .bootstrap .TestScopeResolver ;
15+ import org .elasticsearch .core .Booleans ;
1516import org .elasticsearch .core .Nullable ;
17+ import org .elasticsearch .core .PathUtils ;
1618import org .elasticsearch .core .Strings ;
1719import org .elasticsearch .core .SuppressForbidden ;
1820import org .elasticsearch .entitlement .initialization .EntitlementInitialization ;
2527import org .elasticsearch .logging .Logger ;
2628import org .elasticsearch .plugins .PluginDescriptor ;
2729
28- import java .io .File ;
2930import java .io .IOException ;
3031import java .io .InputStream ;
3132import java .net .URL ;
@@ -74,7 +75,7 @@ private static <T> List<T> zeroOrOne(T item) {
7475 }
7576
7677 public static boolean isEnabledForTest () {
77- return Boolean . getBoolean ("es.entitlement.enableForTests" );
78+ return Booleans . parseBoolean ("es.entitlement.enableForTests" );
7879 }
7980
8081 public static void setActive (boolean newValue ) {
@@ -107,17 +108,20 @@ private static TestPolicyManager createPolicyManager(PathLookup pathLookup) thro
107108 .toList ();
108109 Map <String , Policy > pluginPolicies = parsePluginsPolicies (pluginsData );
109110
111+ String separator = System .getProperty ("path.separator" );
112+
110113 // In productions, plugins would have access to their respective bundle directories,
111114 // and so they'd be able to read from their jars. In testing, we approximate this
112115 // by considering the entire classpath to be "source paths" of all plugins. This
113116 // also has the effect of granting read access to everything on the test-only classpath,
114117 // which is fine, because any entitlement errors there could only be false positives.
115118 String classPathProperty = System .getProperty ("java.class.path" );
119+
116120 Set <Path > classPathEntries ;
117121 if (classPathProperty == null ) {
118122 classPathEntries = Set .of ();
119123 } else {
120- classPathEntries = Arrays .stream (classPathProperty .split (File . pathSeparator )).map (Path :: of ).collect (toCollection (TreeSet ::new ));
124+ classPathEntries = Arrays .stream (classPathProperty .split (separator )).map (PathUtils :: get ).collect (toCollection (TreeSet ::new ));
121125 }
122126 Map <String , Collection <Path >> pluginSourcePaths = pluginNames .stream ().collect (toMap (n -> n , n -> classPathEntries ));
123127
@@ -128,7 +132,7 @@ private static TestPolicyManager createPolicyManager(PathLookup pathLookup) thro
128132 if (testOnlyPathString == null ) {
129133 testOnlyClassPath = Set .of ();
130134 } else {
131- testOnlyClassPath = Arrays .stream (testOnlyPathString .split (File . pathSeparator )).collect (toCollection (TreeSet ::new ));
135+ testOnlyClassPath = Arrays .stream (testOnlyPathString .split (separator )).collect (toCollection (TreeSet ::new ));
132136 }
133137
134138 return new TestPolicyManager (
0 commit comments