-
Notifications
You must be signed in to change notification settings - Fork 375
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3531 from DataDog/ivoanjo/gem-file-permission-val…
…idation [NO-TICKET] Add validation for gem file permissions
- Loading branch information
Showing
3 changed files
with
49 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
require 'rubygems' | ||
require 'rubygems/package' | ||
require 'rubygems/package/tar_reader' | ||
|
||
RSpec.describe 'gem release process (after packaging)' do | ||
# TODO: This will need to be updated for the 2.0 branch | ||
let(:gem_name) { 'ddtrace' } | ||
let(:gem_version) { DDTrace::VERSION::STRING } | ||
let(:packaged_gem_file) { "pkg/#{gem_name}-#{gem_version}.gem" } | ||
let(:executable_permissions) { ['bin/ddprofrb', 'bin/ddtracerb'] } | ||
|
||
it 'sets the right permissions on the gem files' do | ||
gem_files = Dir.glob('pkg/*.gem') | ||
expect(gem_files).to include(packaged_gem_file) | ||
|
||
gem_files.each do |gem_file| | ||
Gem::Package::TarReader.new(File.open(gem_file)) do |tar| | ||
data = tar.find { |entry| entry.header.name == 'data.tar.gz' } | ||
|
||
Gem::Package::TarReader.new(Zlib::GzipReader.new(StringIO.new(data.read))) do |data_tar| | ||
data_tar.each do |entry| | ||
filename = entry.header.name | ||
octal_permissions = entry.header.mode.to_s(8)[-3..-1] | ||
|
||
expected_permissions = executable_permissions.include?(filename) ? '755' : '644' | ||
|
||
expect(octal_permissions).to eq(expected_permissions), | ||
"Unexpected permissions for #{filename} inside #{gem_file} (got #{octal_permissions}, " \ | ||
"expected #{expected_permissions})" | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters