Skip to content

Commit 6623cb1

Browse files
committed
add integration spec for fips_validation plugin
1 parent 0ee498f commit 6623cb1

File tree

5 files changed

+61
-4
lines changed

5 files changed

+61
-4
lines changed

Diff for: rakelib/artifacts.rake

+1-1
Original file line numberDiff line numberDiff line change
@@ -565,8 +565,8 @@ namespace "artifact" do
565565
Rake::Task['bootstrap'].invoke
566566
Rake::Task['plugin:install-default'].invoke
567567
Rake::Task['plugin:install'].invoke('logstash-filter-age')
568-
Rake::Task['plugin:install-fips-validation-plugin'].invoke
569568
Rake::Task['plugin:trim-for-observabilitySRE'].invoke
569+
Rake::Task['plugin:install-fips-validation-plugin'].invoke
570570
Rake::Task['artifact:clean-bundle-config'].invoke
571571
end
572572
end

Diff for: rakelib/plugin.rake

+15-2
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ namespace "plugin" do
124124
task.reenable # Allow this task to be run again
125125
end
126126

127-
task "install-fips-validation-plugin" do |task, _|
127+
task "build-fips-validation-plugin" do |task, _|
128128
puts("[plugin:install-fips-validation-plugin] installing fips_validation plugin")
129129

130130
with_merged_env("GEM_BUILD_VERSION" => get_versions.fetch("logstash")) do
@@ -134,12 +134,25 @@ namespace "plugin" do
134134
# ensure fresh GEM_BUILD_VERSION comes from the env
135135
path.glob("GEM_BUILD_VERSION").each(&:unlink)
136136

137-
Rake::Task["plugin:install-local-core-gem"].invoke(name, path.to_s)
137+
Rake::Task["plugin:build-local-core-gem"].invoke(name, path.to_s)
138138
end
139139

140140
task.reenable # Allow this task to be run again
141141
end
142142

143+
task "install-fips-validation-plugin" => "build-fips-validation-plugin" do |task, _|
144+
puts("[plugin:install-fips-validation-plugin] installing fips_validation plugin")
145+
146+
path = "build/gems"
147+
name = "logstash-integration-fips_validation"
148+
gems = Dir[File.join(path, "#{name}-*.gem")]
149+
abort("ERROR: #{name} gem not found in #{path}") if gems.size != 1
150+
puts("[plugin:install-fips-validation-plugin] Installing #{gems.first}")
151+
install_plugins("--no-verify", gems.first)
152+
153+
task.reenable # Allow this task to be run again
154+
end
155+
143156
task "clean-local-core-gem", [:name, :path] do |task, args|
144157
name = args[:name]
145158
path = args[:path]

Diff for: x-pack/build.gradle

+10
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
description = """Logstash X-Pack"""
88

9+
project.ext.LOGSTASH_CORE_PATH = "${projectDir}/../logstash-core"
10+
apply from: "../rubyUtils.gradle"
11+
912
repositories {
1013
mavenCentral()
1114
}
@@ -56,9 +59,16 @@ tasks.register("rubyIntegrationTests", Test) {
5659
jvmArgs = ['--add-opens', 'java.base/sun.nio.ch=ALL-UNNAMED', '--add-opens', 'java.base/java.io=ALL-UNNAMED']
5760
}
5861
dependsOn (":copyEs")
62+
dependsOn "buildFipsValidationGem"
5963
inputs.files fileTree("${projectDir}/qa")
6064
inputs.files fileTree("${projectDir}/lib")
6165
inputs.files fileTree("${projectDir}/modules")
6266
systemProperty 'logstash.root.dir', projectDir.parent
6367
include '/org/logstash/xpack/test/RSpecIntegrationTests.class'
6468
}
69+
70+
tasks.register("buildFipsValidationGem") {
71+
doLast {
72+
rake(rootProject.projectDir, rootProject.buildDir, 'plugin:build-fips-validation-plugin')
73+
}
74+
}

Diff for: x-pack/distributions/internal/observabilitySRE/plugin/logstash-integration-fips_validation/logstash-integration-fips_validation.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
2424
# Files
2525
s.files = Dir::glob("lib/**/*.rb") |
2626
Dir::glob("*.gemspec") |
27-
Dir.glob("VERSION")
27+
Dir.glob("GEM_BUILD_VERSION")
2828

2929
# Special flag to let us know this is actually a logstash plugin
3030
s.metadata = {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
require_relative "../spec_helper"
2+
3+
context "FipsValidation Integration Plugin" do
4+
5+
before(:all) do
6+
logstash_home = Pathname.new(get_logstash_path).cleanpath
7+
build_dir = (logstash_home / "build" / "gems")
8+
gems = build_dir.glob("logstash-integration-fips_validation-*.gem")
9+
fail("No FipsValidation Gem in #{build_dir}") if gems.none?
10+
fail("Multiple FipsValidation Gems in #{build_dir}") if gems.size > 1
11+
fips_validation_plugin = gems.first
12+
13+
response = logstash_plugin("install", fips_validation_plugin.to_s)
14+
aggregate_failures('setup') do
15+
expect(response).to be_successful
16+
expect(response.stdout_lines.map(&:chomp)).to include("Installation successful")
17+
end
18+
end
19+
after(:all) do
20+
response = logstash_plugin("remove", "logstash-integration-fips_validation")
21+
expect(response).to be_successful
22+
end
23+
24+
context "when running on stock Logstash" do
25+
it "prevents Logstash from running" do
26+
process = logstash_with_empty_default("bin/logstash --log.level=debug -e 'generator { count => 1 }'", timeout: 60)
27+
28+
aggregate_failures do
29+
expect(process).to_not be_successful
30+
expect(process.stdout_lines.join).to include("Logstash is not configured in a FIPS-compliant manner")
31+
end
32+
end
33+
end
34+
end

0 commit comments

Comments
 (0)