X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=3rdparty%2Fmodules%2Farchive%2Fspec%2Fdefines%2Fnexus_spec.rb;fp=3rdparty%2Fmodules%2Farchive%2Fspec%2Fdefines%2Fnexus_spec.rb;h=0000cb257faaaf0d53baadfc392126e9674a0feb;hb=ce70d6baf887ae03a2a6a7f5e73eb2e2c3dea208;hp=0000000000000000000000000000000000000000;hpb=0ba93256399fbad7ed8fabfa39c24dd47169dde3;p=mirror%2Fdsa-puppet.git diff --git a/3rdparty/modules/archive/spec/defines/nexus_spec.rb b/3rdparty/modules/archive/spec/defines/nexus_spec.rb new file mode 100644 index 000000000..0000cb257 --- /dev/null +++ b/3rdparty/modules/archive/spec/defines/nexus_spec.rb @@ -0,0 +1,185 @@ +require 'spec_helper' + +describe 'archive::nexus' do + let(:facts) { { os: { family: 'RedHat' }, puppetversion: '4.4.0' } } + + context 'nexus archive with defaults' do + let(:title) { '/tmp/hawtio.war' } + + let(:params) do + { + url: 'https://oss.sonatype.org', + gav: 'io.hawt:hawtio-web:1.4.36', + repository: 'releases', + packaging: 'war' + } + end + + it do + is_expected.to contain_archive('/tmp/hawtio.war').with( + source: 'https://oss.sonatype.org/service/local/artifact/maven/content?g=io.hawt&a=hawtio-web&v=1.4.36&r=releases&p=war', + checksum_url: 'https://oss.sonatype.org/service/local/artifact/maven/content?g=io.hawt&a=hawtio-web&v=1.4.36&r=releases&p=war.md5' + ) + end + + it do + is_expected.to contain_file('/tmp/hawtio.war').that_requires('Archive[/tmp/hawtio.war]').with( + owner: '0', + group: '0' + ) + end + end + + context 'nexus archive with overwritten parameters' do + let(:title) { '/tmp/artifact.war' } + + let(:params) do + { + url: 'https://oss.sonatype.org', + gav: 'io.hawt:hawtio-web:1.4.36', + repository: 'releases', + owner: 'tom', + group: 'worker', + user: 'tom', + extract: true, + extract_path: '/opt', + creates: '/opt/artifact/WEB-INF', + cleanup: true + } + end + + it do + is_expected.to contain_archive('/tmp/artifact.war').with( + 'user' => 'tom', + 'group' => 'worker', + 'extract' => true, + 'extract_path' => '/opt', + 'creates' => '/opt/artifact/WEB-INF', + 'cleanup' => true + ) + end + + it do + is_expected.to contain_file('/tmp/artifact.war').that_requires('Archive[/tmp/artifact.war]').with( + 'owner' => 'tom', + 'group' => 'worker' + ) + end + end + + context 'nexus archive with checksum_verify => false' do + let :title do + '/tmp/artifact.war' + end + + let :params do + { + url: 'https://oss.sonatype.org', + gav: 'io.hawt:hawtio-web:1.4.36', + repository: 'releases', + owner: 'tom', + group: 'worker', + user: 'tom', + extract: true, + extract_path: '/opt', + creates: '/opt/artifact/WEB-INF', + cleanup: true, + checksum_verify: false + } + end + + it do + is_expected.to contain_archive('/tmp/artifact.war').with( + 'user' => 'tom', + 'group' => 'worker', + 'extract' => true, + 'extract_path' => '/opt', + 'creates' => '/opt/artifact/WEB-INF', + 'cleanup' => true, + 'checksum_verify' => false + ) + end + + it do + is_expected.to contain_file('/tmp/artifact.war').that_requires('Archive[/tmp/artifact.war]').with( + 'owner' => 'tom', + 'group' => 'worker' + ) + end + end + context 'nexus archive with allow_insecure => true' do + let(:title) { '/tmp/artifact.war' } + + let(:params) do + { + url: 'https://oss.sonatype.org', + gav: 'io.hawt:hawtio-web:1.4.36', + repository: 'releases', + packaging: 'war', + allow_insecure: true + } + end + + it { is_expected.to contain_archive('/tmp/artifact.war').with_allow_insecure(true) } + end + context 'nexus archive with allow_insecure => false' do + let(:title) { '/tmp/artifact.war' } + + let(:params) do + { + url: 'https://oss.sonatype.org', + gav: 'io.hawt:hawtio-web:1.4.36', + repository: 'releases', + packaging: 'war', + allow_insecure: false + } + end + + it { is_expected.to contain_archive('/tmp/artifact.war').with_allow_insecure(false) } + end + context 'nexus archive with allow_insecure => \'foobar\'' do + let(:title) { '/tmp/artifact.war' } + + let(:params) do + { + url: 'https://oss.sonatype.org', + gav: 'io.hawt:hawtio-web:1.4.36', + repository: 'releases', + packaging: 'war', + allow_insecure: 'foobar' + } + end + + it { is_expected.to compile.and_raise_error(%r{parameter 'allow_insecure' expects a value of type Undef or Boolean, got String}) } + end + context 'nexus archive with use_nexus3_urls => false' do + let(:title) { '/tmp/artifact.war' } + + let(:params) do + { + url: 'https://oss.sonatype.org', + gav: 'io.hawt:hawtio-web:1.4.36', + repository: 'releases', + packaging: 'war', + use_nexus3_urls: false + } + end + + it { is_expected.to contain_archive('/tmp/artifact.war').with_source('https://oss.sonatype.org/service/local/artifact/maven/content?g=io.hawt&a=hawtio-web&v=1.4.36&r=releases&p=war') } + end + context 'nexus archive with use_nexus3_urls => true' do + let(:title) { '/tmp/artifact.war' } + + let(:params) do + { + url: 'https://oss.sonatype.org', + gav: 'io.hawt:hawtio-web:1.4.36', + repository: 'releases', + packaging: 'war', + use_nexus3_urls: true + } + end + + it { is_expected.to contain_archive('/tmp/artifact.war').with_source('https://oss.sonatype.org/repository/releases/io/hawt/hawtio-web/1.4.36/hawtio-web-1.4.36.war') } + end +end