From a32a229e5dd33c063c41de5e3a942ff231bb281f Mon Sep 17 00:00:00 2001 From: Elfranne Date: Thu, 11 Apr 2024 10:06:27 -1000 Subject: [PATCH 1/3] Fix home dir detection on windows Add windows to the list of supported Operating Systems so that acceptance tests are also run on this platform. We need to set a clear-text password for the windows user provider to avoid an OLE error code:800708C5 in Active Directory (The password does not meet the password policy requirements). --- lib/puppet/provider/vcsrepo/git.rb | 4 ++-- metadata.json | 13 ++++++++++--- spec/acceptance/clone_repo_spec.rb | 2 ++ 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb index 306013d3..65778452 100644 --- a/lib/puppet/provider/vcsrepo/git.rb +++ b/lib/puppet/provider/vcsrepo/git.rb @@ -734,11 +734,11 @@ def exec_git(*args) exec_args = { failonfail: true, combine: true, - custom_environment: { 'HOME' => Etc.getpwuid(Process.uid).dir } + custom_environment: { 'HOME' => Dir.home }, } if @resource.value(:user) && @resource.value(:user) != Facter['id'].value - exec_args[:custom_environment] = { 'HOME' => Etc.getpwnam(@resource.value(:user)).dir } + exec_args[:custom_environment] = { 'HOME' => Dir.home(@resource.value(:user)) } exec_args[:uid] = @resource.value(:user) end withumask do diff --git a/metadata.json b/metadata.json index e6f904b0..021ecd2a 100644 --- a/metadata.json +++ b/metadata.json @@ -7,10 +7,17 @@ "source": "https://github.com/puppetlabs/puppetlabs-vcsrepo", "project_page": "https://github.com/puppetlabs/puppetlabs-vcsrepo", "issues_url": "https://github.com/puppetlabs/puppetlabs-vcsrepo/issues", - "dependencies": [ - - ], + "dependencies": [], "operatingsystem_support": [ + { + "operatingsystem": "Windows", + "operatingsystemrelease": [ + "10", + "11", + "2019", + "2022" + ] + }, { "operatingsystem": "RedHat", "operatingsystemrelease": [ diff --git a/spec/acceptance/clone_repo_spec.rb b/spec/acceptance/clone_repo_spec.rb index a63b860e..75fe7d0f 100644 --- a/spec/acceptance/clone_repo_spec.rb +++ b/spec/acceptance/clone_repo_spec.rb @@ -216,6 +216,7 @@ pp = <<-MANIFEST user { 'vagrant': ensure => present, + password => if ($facts['os']['family'] == 'windows') { 'CorrectHorseBatteryStaple0!' }, } MANIFEST @@ -369,6 +370,7 @@ user { 'testuser': ensure => present, groups => 'testuser', + password => if ($facts['os']['family'] == 'windows') { 'CorrectHorseBatteryStaple0!' }, } MANIFEST From 85d4b0a8539135c8febc916b9402507132969c45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Thu, 11 Apr 2024 10:52:16 -1000 Subject: [PATCH 2/3] Do not reuse the same name for user and group windows is such a supperior operating system it cannot create a group if a user with the same name already exist. We used `vagrant` for no real reason, so switch to obviously example names to fix CI on windows. While here, fix a few typos. --- spec/acceptance/clone_repo_spec.rb | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/spec/acceptance/clone_repo_spec.rb b/spec/acceptance/clone_repo_spec.rb index 75fe7d0f..fb5487d6 100644 --- a/spec/acceptance/clone_repo_spec.rb +++ b/spec/acceptance/clone_repo_spec.rb @@ -175,7 +175,7 @@ end end - context 'with with shallow clone' do + context 'with shallow clone' do pp = <<-MANIFEST vcsrepo { "#{tmpdir}/testrepo_shallow": ensure => present, @@ -212,9 +212,9 @@ end end - context 'with with an owner' do + context 'with an owner' do pp = <<-MANIFEST - user { 'vagrant': + user { 'customowner': ensure => present, password => if ($facts['os']['family'] == 'windows') { 'CorrectHorseBatteryStaple0!' }, } @@ -226,7 +226,7 @@ ensure => present, provider => git, source => "file://#{tmpdir}/testrepo.git", - owner => 'vagrant', + owner => 'customowner', safe_directory => true, } MANIFEST @@ -237,7 +237,7 @@ describe file("#{tmpdir}/testrepo_owner") do it { is_expected.to be_directory } - it { is_expected.to be_owned_by 'vagrant' } + it { is_expected.to be_owned_by 'customowner' } end describe file('/etc/gitconfig') do @@ -247,9 +247,9 @@ end end - context 'with with a group' do + context 'with a group' do pp = <<-MANIFEST - group { 'vagrant': + group { 'customgroup': ensure => present, } MANIFEST @@ -261,7 +261,7 @@ ensure => present, provider => git, source => "file://#{tmpdir}/testrepo.git", - group => 'vagrant', + group => 'customgroup', } MANIFEST it 'clones a repo' do @@ -271,11 +271,11 @@ describe file("#{tmpdir}/testrepo_group") do it { is_expected.to be_directory } - it { is_expected.to be_grouped_into 'vagrant' } + it { is_expected.to be_grouped_into 'customgroup' } end end - context 'with with excludes' do + context 'with excludes' do pp = <<-MANIFEST vcsrepo { "#{tmpdir}/testrepo_excludes": ensure => present, @@ -302,7 +302,7 @@ end end - context 'with with force' do + context 'with force' do before(:all) do run_shell("mkdir -p #{tmpdir}/testrepo_force/folder") run_shell("touch #{tmpdir}/testrepo_force/temp.txt") From 7716ce192436487922784d80af507c78e3b9fa4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Thu, 11 Apr 2024 11:11:53 -1000 Subject: [PATCH 3/3] Fix acceptance test helper --- spec/spec_helper_acceptance_local.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/spec_helper_acceptance_local.rb b/spec/spec_helper_acceptance_local.rb index e25b9f06..d4030d1e 100644 --- a/spec/spec_helper_acceptance_local.rb +++ b/spec/spec_helper_acceptance_local.rb @@ -43,11 +43,11 @@ def create_repo PP LitmusHelper.instance.apply_manifest(pp) else - unless run_bolt_task('package', 'action' => 'status', 'name' => 'git') + unless LitmusHelper.instance.run_bolt_task('package', 'action' => 'status', 'name' => 'git') puts 'Git package is required for this module' exit end - unless run_bolt_task('package', 'action' => 'status', 'name' => 'subversion') + unless LitmusHelper.instance.run_bolt_task('package', 'action' => 'status', 'name' => 'subversion') puts 'Subversion package is required for this module' exit end