@@ -259,12 +259,12 @@ static void writePluginSecurityPolicy(Path pluginDir, String... permissions) thr
259259
260260 static Path createPlugin (String name , Path structure , String ... additionalProps ) throws IOException {
261261 writePlugin (name , structure , additionalProps );
262- return writeZip (structure , "elasticsearch" );
262+ return writeZip (structure , null );
263263 }
264264
265265 static Path createMetaPlugin (String name , Path structure ) throws IOException {
266266 writeMetaPlugin (name , structure );
267- return writeZip (structure , "elasticsearch" );
267+ return writeZip (structure , null );
268268 }
269269
270270 void installPlugin (String pluginUrl , Path home ) throws Exception {
@@ -811,7 +811,7 @@ public void testMissingDescriptor() throws Exception {
811811 Path pluginDir = metaDir .resolve ("fake" );
812812 Files .createDirectory (pluginDir );
813813 Files .createFile (pluginDir .resolve ("fake.yml" ));
814- String pluginZip = writeZip (pluginDir , "elasticsearch" ).toUri ().toURL ().toString ();
814+ String pluginZip = writeZip (pluginDir , null ).toUri ().toURL ().toString ();
815815 NoSuchFileException e = expectThrows (NoSuchFileException .class , () -> installPlugin (pluginZip , env .v1 ()));
816816 assertTrue (e .getMessage (), e .getMessage ().contains ("plugin-descriptor.properties" ));
817817 assertInstallCleaned (env .v2 ());
@@ -822,35 +822,36 @@ public void testMissingDescriptor() throws Exception {
822822 assertInstallCleaned (env .v2 ());
823823 }
824824
825- public void testMissingDirectory () throws Exception {
825+ public void testContainsIntermediateDirectory () throws Exception {
826826 Tuple <Path , Environment > env = createEnv (fs , temp );
827827 Path pluginDir = createPluginDir (temp );
828828 Files .createFile (pluginDir .resolve (PluginInfo .ES_PLUGIN_PROPERTIES ));
829- String pluginZip = writeZip (pluginDir , null ).toUri ().toURL ().toString ();
829+ String pluginZip = writeZip (pluginDir , "elasticsearch" ).toUri ().toURL ().toString ();
830830 UserException e = expectThrows (UserException .class , () -> installPlugin (pluginZip , env .v1 ()));
831- assertTrue (e .getMessage (), e . getMessage (). contains ( "`elasticsearch` directory is missing in the plugin zip " ));
831+ assertThat (e .getMessage (), containsString ( "This plugin was built with an older plugin structure " ));
832832 assertInstallCleaned (env .v2 ());
833833 }
834834
835- public void testMissingDirectoryMeta () throws Exception {
835+ public void testContainsIntermediateDirectoryMeta () throws Exception {
836836 Tuple <Path , Environment > env = createEnv (fs , temp );
837837 Path pluginDir = createPluginDir (temp );
838838 Files .createFile (pluginDir .resolve (MetaPluginInfo .ES_META_PLUGIN_PROPERTIES ));
839- String pluginZip = writeZip (pluginDir , null ).toUri ().toURL ().toString ();
839+ String pluginZip = writeZip (pluginDir , "elasticsearch" ).toUri ().toURL ().toString ();
840840 UserException e = expectThrows (UserException .class , () -> installPlugin (pluginZip , env .v1 ()));
841- assertTrue (e .getMessage (), e . getMessage (). contains ( "`elasticsearch` directory is missing in the plugin zip " ));
841+ assertThat (e .getMessage (), containsString ( "This plugin was built with an older plugin structure " ));
842842 assertInstallCleaned (env .v2 ());
843843 }
844844
845845 public void testZipRelativeOutsideEntryName () throws Exception {
846846 Tuple <Path , Environment > env = createEnv (fs , temp );
847847 Path zip = createTempDir ().resolve ("broken.zip" );
848848 try (ZipOutputStream stream = new ZipOutputStream (Files .newOutputStream (zip ))) {
849- stream .putNextEntry (new ZipEntry ("elasticsearch/ ../blah" ));
849+ stream .putNextEntry (new ZipEntry ("../blah" ));
850850 }
851851 String pluginZip = zip .toUri ().toURL ().toString ();
852852 UserException e = expectThrows (UserException .class , () -> installPlugin (pluginZip , env .v1 ()));
853853 assertTrue (e .getMessage (), e .getMessage ().contains ("resolving outside of plugin directory" ));
854+ assertInstallCleaned (env .v2 ());
854855 }
855856
856857 public void testOfficialPluginsHelpSorted () throws Exception {
0 commit comments