From 113585d4a57cc5e9fc2dd3f0147f305ed49f23fc Mon Sep 17 00:00:00 2001 From: Nicole Albee <2642763+a03nikki@users.noreply.github.com> Date: Tue, 5 Nov 2024 08:21:15 -0600 Subject: [PATCH] Anchor the `-java` match pattern at the end of the string. (#16626) This fixes the offline install problem of the logstash-input-java_filter_example off-line install. --- lib/pluginmanager/pack_installer/pack.rb | 2 +- .../pack_installer/pack_spec.rb | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/pluginmanager/pack_installer/pack.rb b/lib/pluginmanager/pack_installer/pack.rb index 7b05db5988f..fd3c67ea6c2 100644 --- a/lib/pluginmanager/pack_installer/pack.rb +++ b/lib/pluginmanager/pack_installer/pack.rb @@ -39,7 +39,7 @@ class Pack class GemInformation EXTENSION = ".gem" SPLIT_CHAR = "-" - JAVA_PLATFORM_RE = /-java/ + JAVA_PLATFORM_RE = /-java$/ DEPENDENCIES_DIR_RE = /dependencies/ attr_reader :file, :name, :version, :platform diff --git a/spec/unit/plugin_manager/pack_installer/pack_spec.rb b/spec/unit/plugin_manager/pack_installer/pack_spec.rb index 5467dd2f835..de73a8cf174 100644 --- a/spec/unit/plugin_manager/pack_installer/pack_spec.rb +++ b/spec/unit/plugin_manager/pack_installer/pack_spec.rb @@ -113,4 +113,24 @@ expect(subject.plugin?).to be_falsey end end + + context "when it is Java plugin example from an offline zip file" do + let(:gem) { "/tmp/randomValue/randomValue2/logstash/logstash-filter-java_filter_example-1.0.5.gem"} + + it "#dependency? return false" do + expect(subject.dependency?).to be_falsey + end + + it "#plugin? return true" do + expect(subject.plugin?).to be_truthy + end + + it "returns the version" do + expect(subject.version).to eq("1.0.5") + end + + it "returns the name" do + expect(subject.name).to eq("logstash-filter-java_filter_example") + end + end end