From d828bc1c96137dbfef725bef7b6be8452f2a9a80 Mon Sep 17 00:00:00 2001 From: Maciej Mensfeld Date: Mon, 4 Sep 2023 14:35:57 +0200 Subject: [PATCH] update installer --- lib/karafka/web/management/extend_boot_file.rb | 4 ++-- .../karafka/web/management/extend_boot_file_spec.rb | 11 +++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/karafka/web/management/extend_boot_file.rb b/lib/karafka/web/management/extend_boot_file.rb index aa81419b..226b44c9 100644 --- a/lib/karafka/web/management/extend_boot_file.rb +++ b/lib/karafka/web/management/extend_boot_file.rb @@ -12,8 +12,8 @@ class ExtendBootFile < Base # Session secret needs to be set per user and per env SETUP_TEMPLATE = <<~CONFIG Karafka::Web.setup do |config| - # You may want to set it per ENV - config.ui.sessions.secret = '#{SecureRandom.hex(64)}' + # You may want to set it per ENV. This value was randomly generated. + config.ui.sessions.secret = '#{SecureRandom.hex(32)}' end #{ENABLER_CODE} diff --git a/spec/lib/karafka/web/management/extend_boot_file_spec.rb b/spec/lib/karafka/web/management/extend_boot_file_spec.rb index 8a9ef8c4..d513368b 100644 --- a/spec/lib/karafka/web/management/extend_boot_file_spec.rb +++ b/spec/lib/karafka/web/management/extend_boot_file_spec.rb @@ -34,9 +34,16 @@ before { File.write(boot_file, content) } - it 'expect to add it at the end' do + it 'expect to add the enabled' do extend_boot_file - expect(File.read(boot_file)).to eq("#{content}\nKarafka::Web.enable!\n") + expect(File.read(boot_file)).to include("\nKarafka::Web.enable!\n") + end + + it 'expect to add the configurator' do + extend_boot_file + updated = File.read(boot_file) + expect(updated).to include('config.ui.sessions.secret') + expect(updated).to include('Karafka::Web.setup do |config|') end end end