Skip to content

Commit

Permalink
Updated fixtures to include dependencies
Browse files Browse the repository at this point in the history
Fixed reuse of user_domain variable
Added spec tests
  • Loading branch information
Tony Thayer committed May 31, 2018
1 parent c7aa800 commit 5342940
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
4 changes: 3 additions & 1 deletion .fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ fixtures:
repositories:
stdlib:
repo: "git://github.com/puppetlabs/puppetlabs-stdlib"
ref: "4.3.2"
ref: "a656880f13cc13a30baa892dcc4c8e3efefcc867"
reboot: "git://github.com/puppetlabs/puppetlabs-reboot"
powershell: "git://github.com/puppetlabs/puppetlabs-powershell"
symlinks:
domain_membership: "#{source_dir}"
File renamed without changes.
7 changes: 4 additions & 3 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@
#
class domain_membership (
Stdlib::Fqdn $domain,
Optional[Stdlib::Fqdn] $user_domain,
String $username,
String $password,
Optional[Stdlib::Fqdn] $user_domain = undef,
Boolean $secure_password = false,
String $machine_ou = '$null',
Boolean $resetpw = true,
Expand All @@ -72,15 +72,16 @@

# Allow an optional user_domain to accomodate multi-domain AD forests
if $user_domain {
$_user_domain = $user_domain
$_reset_username = "${user_domain}\\${username}"
} else {
$user_domain = $domain
$_user_domain = $domain
$_reset_username = $username
}

exec { 'join_domain':
environment => [ "Password=${_password}" ],
command => "exit (Get-WmiObject -Class Win32_ComputerSystem).JoinDomainOrWorkGroup('${domain}',\$Password,'${username}@${user_domain}',${machine_ou},${join_options}).ReturnValue",
command => "exit (Get-WmiObject -Class Win32_ComputerSystem).JoinDomainOrWorkGroup('${domain}',\$Password,'${username}@${_user_domain}',${machine_ou},${join_options}).ReturnValue",
unless => "if((Get-WmiObject -Class Win32_ComputerSystem).domain -ne '${domain}'){ exit 1 }",
provider => powershell,
}
Expand Down
19 changes: 19 additions & 0 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require 'spec_helper'
require 'puppetlabs_spec_helper/module_spec_helper'

describe 'domain_membership' do
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) { facts }
let(:params) do
{
domain: 'test.domain',
username: 'testuser',
password: 'password1',
}
end

it { is_expected.to compile.with_all_deps }
end
end
end

0 comments on commit 5342940

Please sign in to comment.