Add puppet/archive module, required for newer puppet/rabbitmq
[mirror/dsa-puppet.git] / 3rdparty / modules / archive / spec / defines / nexus_spec.rb
1 require 'spec_helper'
2
3 describe 'archive::nexus' do
4   let(:facts) { { os: { family: 'RedHat' }, puppetversion: '4.4.0' } }
5
6   context 'nexus archive with defaults' do
7     let(:title) { '/tmp/hawtio.war' }
8
9     let(:params) do
10       {
11         url: 'https://oss.sonatype.org',
12         gav: 'io.hawt:hawtio-web:1.4.36',
13         repository: 'releases',
14         packaging: 'war'
15       }
16     end
17
18     it do
19       is_expected.to contain_archive('/tmp/hawtio.war').with(
20         source: 'https://oss.sonatype.org/service/local/artifact/maven/content?g=io.hawt&a=hawtio-web&v=1.4.36&r=releases&p=war',
21         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'
22       )
23     end
24
25     it do
26       is_expected.to contain_file('/tmp/hawtio.war').that_requires('Archive[/tmp/hawtio.war]').with(
27         owner: '0',
28         group: '0'
29       )
30     end
31   end
32
33   context 'nexus archive with overwritten parameters' do
34     let(:title) { '/tmp/artifact.war' }
35
36     let(:params) do
37       {
38         url: 'https://oss.sonatype.org',
39         gav: 'io.hawt:hawtio-web:1.4.36',
40         repository: 'releases',
41         owner: 'tom',
42         group: 'worker',
43         user: 'tom',
44         extract: true,
45         extract_path: '/opt',
46         creates: '/opt/artifact/WEB-INF',
47         cleanup: true
48       }
49     end
50
51     it do
52       is_expected.to contain_archive('/tmp/artifact.war').with(
53         'user' => 'tom',
54         'group' => 'worker',
55         'extract' => true,
56         'extract_path' => '/opt',
57         'creates' => '/opt/artifact/WEB-INF',
58         'cleanup' => true
59       )
60     end
61
62     it do
63       is_expected.to contain_file('/tmp/artifact.war').that_requires('Archive[/tmp/artifact.war]').with(
64         'owner' => 'tom',
65         'group' => 'worker'
66       )
67     end
68   end
69
70   context 'nexus archive with checksum_verify => false' do
71     let :title do
72       '/tmp/artifact.war'
73     end
74
75     let :params do
76       {
77         url: 'https://oss.sonatype.org',
78         gav: 'io.hawt:hawtio-web:1.4.36',
79         repository: 'releases',
80         owner: 'tom',
81         group: 'worker',
82         user: 'tom',
83         extract: true,
84         extract_path: '/opt',
85         creates: '/opt/artifact/WEB-INF',
86         cleanup: true,
87         checksum_verify: false
88       }
89     end
90
91     it do
92       is_expected.to contain_archive('/tmp/artifact.war').with(
93         'user' => 'tom',
94         'group' => 'worker',
95         'extract' => true,
96         'extract_path' => '/opt',
97         'creates' => '/opt/artifact/WEB-INF',
98         'cleanup' => true,
99         'checksum_verify' => false
100       )
101     end
102
103     it do
104       is_expected.to contain_file('/tmp/artifact.war').that_requires('Archive[/tmp/artifact.war]').with(
105         'owner' => 'tom',
106         'group' => 'worker'
107       )
108     end
109   end
110   context 'nexus archive with allow_insecure => true' do
111     let(:title) { '/tmp/artifact.war' }
112
113     let(:params) do
114       {
115         url: 'https://oss.sonatype.org',
116         gav: 'io.hawt:hawtio-web:1.4.36',
117         repository: 'releases',
118         packaging: 'war',
119         allow_insecure: true
120       }
121     end
122
123     it { is_expected.to contain_archive('/tmp/artifact.war').with_allow_insecure(true) }
124   end
125   context 'nexus archive with allow_insecure => false' do
126     let(:title) { '/tmp/artifact.war' }
127
128     let(:params) do
129       {
130         url: 'https://oss.sonatype.org',
131         gav: 'io.hawt:hawtio-web:1.4.36',
132         repository: 'releases',
133         packaging: 'war',
134         allow_insecure: false
135       }
136     end
137
138     it { is_expected.to contain_archive('/tmp/artifact.war').with_allow_insecure(false) }
139   end
140   context 'nexus archive with allow_insecure => \'foobar\'' do
141     let(:title) { '/tmp/artifact.war' }
142
143     let(:params) do
144       {
145         url: 'https://oss.sonatype.org',
146         gav: 'io.hawt:hawtio-web:1.4.36',
147         repository: 'releases',
148         packaging: 'war',
149         allow_insecure: 'foobar'
150       }
151     end
152
153     it { is_expected.to compile.and_raise_error(%r{parameter 'allow_insecure' expects a value of type Undef or Boolean, got String}) }
154   end
155   context 'nexus archive with use_nexus3_urls => false' do
156     let(:title) { '/tmp/artifact.war' }
157
158     let(:params) do
159       {
160         url: 'https://oss.sonatype.org',
161         gav: 'io.hawt:hawtio-web:1.4.36',
162         repository: 'releases',
163         packaging: 'war',
164         use_nexus3_urls: false
165       }
166     end
167
168     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') }
169   end
170   context 'nexus archive with use_nexus3_urls => true' do
171     let(:title) { '/tmp/artifact.war' }
172
173     let(:params) do
174       {
175         url: 'https://oss.sonatype.org',
176         gav: 'io.hawt:hawtio-web:1.4.36',
177         repository: 'releases',
178         packaging: 'war',
179         use_nexus3_urls: true
180       }
181     end
182
183     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') }
184   end
185 end