Skip to content
This repository has been archived by the owner on Jun 2, 2019. It is now read-only.

Commit

Permalink
Merge pull request #61 from madelaney/master
Browse files Browse the repository at this point in the history
-- #60: adding support for the Maven security file
  • Loading branch information
carlossg authored Oct 12, 2016
2 parents 0a8dbfc + 9a34651 commit b53fdc3
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 2 deletions.
13 changes: 11 additions & 2 deletions manifests/settings.pp
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@
#
# activeProfiles => [ 'profile1', 'profile2', ...]
#
define maven::settings( $home = undef, $user = 'root', $group = 'root',
define maven::settings($home = undef, $user = 'root', $group = 'root',
$servers = [], $mirrors = [], $default_repo_config = undef, $repos = [],
$properties = {}, $local_repo = '', $dir_mask = '700', $file_mask = '600',
$proxies = [], $profiles = {}, $active_profiles = []) {
$proxies = [], $profiles = {}, $active_profiles = [], $master_password = undef) {

if $home == undef {
$home_real = $user ? {
Expand All @@ -156,4 +156,13 @@
content => template('maven/settings.xml.erb'),
}

unless $master_password == undef {
file { "${home_real}/.m2/settings-security.xml":
owner => $user,
group => $group,
mode => $file_mask,
content => template('maven/settings-security.xml.erb'),
require => File["${home_real}/.m2"],
}
}
}
3 changes: 3 additions & 0 deletions spec/defines/default-settings-security.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<settingsSecurity>
<master>{7837*#&$*i878283mkjdksf=}</master>
</settingsSecurity>
24 changes: 24 additions & 0 deletions spec/defines/settings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@ def read_file(filename)
end
end

shared_examples :maven_settings_security do |expected_file|

def read_file(filename)
IO.read(File.expand_path(filename, File.dirname(__FILE__)))
end

it { should contain_file(expected_filename).with_owner('u') }

it 'should generate valid settings.xml' do
should contain_file(expected_filename).with_content(read_file(expected_file))
end
end

describe "maven::settings" do
let(:title) { 'settings' }
let(:params) { {
Expand Down Expand Up @@ -244,4 +257,15 @@ def read_file(filename)

it_behaves_like :maven_settings, "active-profiles-settings.xml"
end

context "with master password", :compile do
let(:expected_filename) { '/home/u/.m2/settings-security.xml' }
let(:params) {{
:user => "u",
:home => "/home/u",
:master_password => '{7837*#&$*i878283mkjdksf=}'
}}

it_behaves_like :maven_settings_security, "default-settings-security.xml"
end
end
3 changes: 3 additions & 0 deletions templates/settings-security.xml.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<settingsSecurity>
<master><%= @master_password %></master>
</settingsSecurity>

0 comments on commit b53fdc3

Please sign in to comment.