Skip to content

Commit 159181f

Browse files
committed
Adding acceptance tests for license file.
1 parent 5d8e8dd commit 159181f

File tree

3 files changed

+99
-13
lines changed

3 files changed

+99
-13
lines changed

manifests/license.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
validate_absolute_path($home)
1818

19-
if $license_key == undef {
19+
if $ensure == 'present' and $license_key == undef {
2020
fail('License key must be specified.')
2121
}
2222

spec/acceptance/acceptance_spec.rb

Lines changed: 76 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ class { \"java\" : }
6868
aem::instance { \"publish\" :
6969
source => \"/tmp/aem-quickstart.jar\",
7070
home => \"/opt/aem/publish\",
71-
user => \"aem\",
72-
group => \"aem\",
7371
manage_home => false,
7472
manage_user => false,
7573
manage_group => false,
@@ -88,6 +86,26 @@ class { \"java\" : }
8886
file { \"/opt/aem/publish\" :
8987
ensure => \"directory\",
9088
}
89+
90+
Aem::License {
91+
customer => \"Vagrant Test\",
92+
license_key => \"fake-key-for-testing\",
93+
version => \"6.1.0\",
94+
}
95+
96+
aem::license { \"author\" :
97+
group => \"vagrant\",
98+
user => \"vagrant\",
99+
home => \"/opt/aem/author\",
100+
}
101+
102+
aem::license { \"publish\" :
103+
home => \"/opt/aem/publish\",
104+
}
105+
106+
Aem::Instance[\"author\"] -> Aem::License[\"author\"]
107+
Aem::Instance[\"publish\"] -> Aem::License[\"publish\"]
108+
91109
}'
92110
93111
MANIFEST
@@ -193,6 +211,62 @@ class { \"java\" : }
193211
end
194212
end
195213

214+
context 'license' do
215+
context 'author' do
216+
it 'should have license file' do
217+
shell("test -f /opt/aem/publish/license.properties", :acceptable_exit_codes => 0)
218+
end
219+
220+
it 'should have correct owner:group' do
221+
shell('stat -c "%U:%G" /opt/aem/author/license.properties') do |result|
222+
expect(result.stdout).to match('vagrant:vagrant')
223+
end
224+
end
225+
226+
it 'should contain customer' do
227+
shell('grep "license.customer.name=Vagrant Test" /opt/aem/author/license.properties',
228+
:acceptable_exit_codes => 0)
229+
end
230+
231+
it 'should contain licnese_key' do
232+
shell('grep "license.downloadID=fake-key-for-testing" /opt/aem/author/license.properties',
233+
:acceptable_exit_codes => 0)
234+
end
235+
236+
it 'should contain version' do
237+
shell('grep "license.product.version=6.1.0" /opt/aem/publish/license.properties',
238+
:acceptable_exit_codes => 0)
239+
end
240+
end
241+
242+
context 'publish' do
243+
it 'should have license file' do
244+
shell("test -f /opt/aem/publish/license.properties", :acceptable_exit_codes => 0)
245+
end
246+
247+
it 'should have correct owner:group' do
248+
shell('stat -c "%U:%G" /opt/aem/publish/license.properties') do |result|
249+
expect(result.stdout).to match('aem:aem')
250+
end
251+
end
252+
253+
it 'should contain customer' do
254+
shell('grep "license.customer.name=Vagrant Test" /opt/aem/publish/license.properties',
255+
:acceptable_exit_codes => 0)
256+
end
257+
258+
it 'should contain licnese_key' do
259+
shell('grep "license.downloadID=fake-key-for-testing" /opt/aem/publish/license.properties',
260+
:acceptable_exit_codes => 0)
261+
end
262+
263+
it 'should contain version' do
264+
shell('grep "license.product.version=6.1.0" /opt/aem/publish/license.properties',
265+
:acceptable_exit_codes => 0)
266+
end
267+
end
268+
end
269+
196270
context 'running instances' do
197271
it 'should start author with correct port and context root' do
198272
shell('sudo -u vagrant -g vagrant /opt/aem/author/crx-quickstart/bin/start')

spec/defines/aem_license_spec.rb

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,29 @@
6363

6464
end
6565

66+
context 'license' do
67+
68+
context 'not specified' do
69+
let :params do
70+
tmp = default_params.clone
71+
tmp.delete(:license_key)
72+
tmp
73+
end
74+
it { expect { is_expected.to compile }.to raise_error(/License key must be specified./) }
75+
end
76+
77+
context 'ensure absent but not specifed' do
78+
let :params do
79+
tmp = default_params.merge(:ensure => 'absent')
80+
tmp.delete(:license_key)
81+
tmp
82+
end
83+
it { is_expected.to compile }
84+
end
85+
end
86+
6687
end
67-
88+
6889
describe 'creates the file' do
6990

7091
let :params do
@@ -118,17 +139,8 @@
118139
end
119140

120141
context 'license key' do
121-
context 'not specified' do
122-
let :params do
123-
tmp = default_params.clone
124-
tmp.delete(:license_key)
125-
tmp
126-
end
127-
it { expect { is_expected.to compile }.to raise_error(/License key must be specified./) }
128-
end
129142

130143
it do
131-
132144
val = params[:license_key]
133145

134146
is_expected.to contain_file(

0 commit comments

Comments
 (0)