e6ad09a7ec5d4fd57c57d92ce57a55700499b6fc
[mirror/dsa-puppet.git] / 3rdparty / modules / archive / spec / functions / artifactory_checksum_spec.rb
1 require 'spec_helper'
2
3 describe 'archive::artifactory_checksum' do
4   it { is_expected.not_to eq(nil) }
5   it { is_expected.to run.with_params.and_raise_error(ArgumentError) }
6   it { is_expected.to run.with_params('not_a_url').and_raise_error(ArgumentError) }
7
8   example_json = File.read(fixtures('checksum', 'artifactory.json'))
9   url = 'https://repo.jfrog.org/artifactory/distributions/images/Artifactory_120x75.png'
10   uri = URI(url.sub('/artifactory/', '/artifactory/api/storage/'))
11
12   it 'defaults to and parses sha1' do
13     PuppetX::Bodeco::Util.stubs(:content).with(uri).returns(example_json)
14     is_expected.to run.with_params(url).and_return('a359e93636e81f9dd844b2dfb4b89fa876e5d4fa')
15   end
16
17   it 'parses md5' do
18     PuppetX::Bodeco::Util.stubs(:content).with(uri).returns(example_json)
19     is_expected.to run.with_params(url, 'md5').and_return('00f32568be85929fe95be38f9f5f3519')
20   end
21 end