Commit 746bf485 authored by Stan Hu's avatar Stan Hu

Merge branch 'workhorse-secret-trailing-newline' into 'master'

Allow trailing newline in secret base64 data

Fixes https://gitlab.com/gitlab-org/omnibus-gitlab/issues/1575

See merge request !6327
parents acc7f7c6 11f54caa
......@@ -102,7 +102,7 @@ module Gitlab
def secret
@secret ||= begin
bytes = Base64.strict_decode64(File.read(secret_path))
bytes = Base64.strict_decode64(File.read(secret_path).chomp)
raise "#{secret_path} does not contain #{SECRET_LENGTH} bytes" if bytes.length != SECRET_LENGTH
bytes
end
......
......@@ -30,6 +30,11 @@ describe Gitlab::Workhorse, lib: true do
expect(subject.encoding).to eq(Encoding::ASCII_8BIT)
end
it 'accepts a trailing newline' do
open(described_class.secret_path, 'a') { |f| f.write "\n" }
expect(subject.length).to eq(32)
end
it 'raises an exception if the secret file cannot be read' do
File.delete(described_class.secret_path)
expect { subject }.to raise_exception(Errno::ENOENT)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment