chef 16.0.287-universal-mingw32 → 16.2.73-universal-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -3
- data/README.md +3 -3
- data/Rakefile +3 -2
- data/chef.gemspec +5 -5
- data/distro/powershell/chef/chef.psm1 +3 -3
- data/distro/templates/powershell/chef/chef.psm1.erb +3 -3
- data/lib/chef/application/apply.rb +2 -1
- data/lib/chef/application/base.rb +1 -1
- data/lib/chef/application/client.rb +1 -1
- data/lib/chef/application/windows_service_manager.rb +1 -1
- data/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/acls_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb +2 -2
- data/lib/chef/chef_fs/file_system/repository/directory.rb +1 -1
- data/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb +1 -1
- data/lib/chef/chef_fs/path_utils.rb +4 -4
- data/lib/chef/cookbook/chefignore.rb +1 -1
- data/lib/chef/cookbook/file_system_file_vendor.rb +1 -1
- data/lib/chef/cookbook/metadata.rb +2 -2
- data/lib/chef/cookbook_loader.rb +1 -1
- data/lib/chef/cookbook_manifest.rb +1 -1
- data/lib/chef/cookbook_site_streaming_uploader.rb +1 -1
- data/lib/chef/cookbook_version.rb +4 -4
- data/lib/chef/data_bag.rb +4 -4
- data/lib/chef/data_collector.rb +1 -1
- data/lib/chef/data_collector/error_handlers.rb +1 -1
- data/lib/chef/decorator/lazy_array.rb +2 -2
- data/lib/chef/deprecated.rb +4 -0
- data/lib/chef/digester.rb +5 -4
- data/lib/chef/dsl/declare_resource.rb +1 -1
- data/lib/chef/encrypted_data_bag_item/decryptor.rb +1 -1
- data/lib/chef/encrypted_data_bag_item/encryptor.rb +1 -1
- data/lib/chef/file_access_control.rb +1 -1
- data/lib/chef/file_access_control/windows.rb +2 -2
- data/lib/chef/file_content_management/deploy/mv_unix.rb +1 -1
- data/lib/chef/formatters/base.rb +1 -1
- data/lib/chef/formatters/error_inspectors/compile_error_inspector.rb +1 -1
- data/lib/chef/formatters/error_inspectors/node_load_error_inspector.rb +2 -2
- data/lib/chef/formatters/error_inspectors/registration_error_inspector.rb +7 -7
- data/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb +3 -3
- data/lib/chef/http.rb +19 -4
- data/lib/chef/http/decompressor.rb +1 -1
- data/lib/chef/http/http_request.rb +1 -1
- data/lib/chef/http/json_output.rb +1 -1
- data/lib/chef/http/ssl_policies.rb +18 -0
- data/lib/chef/json_compat.rb +1 -1
- data/lib/chef/key.rb +1 -1
- data/lib/chef/knife.rb +2 -2
- data/lib/chef/knife/bootstrap.rb +20 -14
- data/lib/chef/knife/bootstrap/chef_vault_handler.rb +1 -1
- data/lib/chef/knife/bootstrap/client_builder.rb +1 -1
- data/lib/chef/knife/bootstrap/templates/chef-full.erb +9 -9
- data/lib/chef/knife/bootstrap/templates/windows-chef-client-msi.erb +3 -1
- data/lib/chef/knife/client_bulk_delete.rb +1 -1
- data/lib/chef/knife/config_get.rb +1 -1
- data/lib/chef/knife/config_use_profile.rb +15 -5
- data/lib/chef/knife/cookbook_delete.rb +1 -1
- data/lib/chef/knife/cookbook_upload.rb +1 -4
- data/lib/chef/knife/core/bootstrap_context.rb +1 -1
- data/lib/chef/knife/core/cookbook_scm_repo.rb +1 -1
- data/lib/chef/knife/core/hashed_command_loader.rb +1 -1
- data/lib/chef/knife/core/node_presenter.rb +1 -1
- data/lib/chef/knife/core/status_presenter.rb +1 -1
- data/lib/chef/knife/core/subcommand_loader.rb +1 -1
- data/lib/chef/knife/core/windows_bootstrap_context.rb +19 -4
- data/lib/chef/knife/data_bag_create.rb +1 -1
- data/lib/chef/knife/key_create_base.rb +1 -1
- data/lib/chef/knife/key_edit_base.rb +1 -1
- data/lib/chef/knife/node_bulk_delete.rb +1 -1
- data/lib/chef/knife/node_run_list_remove.rb +1 -1
- data/lib/chef/knife/role_bulk_delete.rb +1 -1
- data/lib/chef/knife/ssh.rb +2 -2
- data/lib/chef/knife/supermarket_share.rb +1 -1
- data/lib/chef/knife/supermarket_unshare.rb +1 -1
- data/lib/chef/log.rb +1 -1
- data/lib/chef/mixin/api_version_request_handling.rb +1 -1
- data/lib/chef/mixin/checksum.rb +0 -1
- data/lib/chef/mixin/openssl_helper.rb +4 -4
- data/lib/chef/mixin/properties.rb +2 -2
- data/lib/chef/mixin/securable.rb +2 -2
- data/lib/chef/mixin/shell_out.rb +1 -1
- data/lib/chef/node/attribute.rb +2 -2
- data/lib/chef/node/immutable_collections.rb +1 -1
- data/lib/chef/policy_builder/policyfile.rb +1 -1
- data/lib/chef/powershell.rb +1 -1
- data/lib/chef/property.rb +2 -2
- data/lib/chef/provider.rb +3 -3
- data/lib/chef/provider/batch.rb +3 -10
- data/lib/chef/provider/cron.rb +2 -14
- data/lib/chef/provider/directory.rb +1 -1
- data/lib/chef/provider/execute.rb +2 -1
- data/lib/chef/provider/file.rb +1 -1
- data/lib/chef/provider/group/dscl.rb +2 -2
- data/lib/chef/provider/group/windows.rb +1 -1
- data/lib/chef/provider/ifconfig.rb +7 -7
- data/lib/chef/provider/launchd.rb +11 -9
- data/lib/chef/provider/mount/aix.rb +1 -1
- data/lib/chef/provider/mount/windows.rb +2 -2
- data/lib/chef/provider/noop.rb +1 -1
- data/lib/chef/provider/package/cab.rb +1 -1
- data/lib/chef/provider/package/chocolatey.rb +1 -1
- data/lib/chef/provider/package/dpkg.rb +1 -1
- data/lib/chef/provider/package/openbsd.rb +1 -1
- data/lib/chef/provider/package/portage.rb +3 -2
- data/lib/chef/provider/package/powershell.rb +6 -2
- data/lib/chef/provider/package/rubygems.rb +3 -3
- data/lib/chef/provider/package/snap.rb +96 -27
- data/lib/chef/provider/package/windows.rb +2 -2
- data/lib/chef/provider/package/windows/msi.rb +3 -3
- data/lib/chef/provider/package/windows/registry_uninstall_entry.rb +1 -1
- data/lib/chef/provider/package/yum.rb +1 -1
- data/lib/chef/provider/package/yum/yum_cache.rb +1 -1
- data/lib/chef/provider/powershell_script.rb +11 -15
- data/lib/chef/provider/remote_directory.rb +2 -2
- data/lib/chef/provider/remote_file/http.rb +4 -1
- data/lib/chef/provider/script.rb +4 -75
- data/lib/chef/provider/service/arch.rb +2 -2
- data/lib/chef/provider/service/debian.rb +2 -2
- data/lib/chef/provider/service/macosx.rb +9 -0
- data/lib/chef/provider/service/openbsd.rb +4 -4
- data/lib/chef/provider/service/redhat.rb +1 -1
- data/lib/chef/provider/service/upstart.rb +1 -1
- data/lib/chef/provider/service/windows.rb +1 -1
- data/lib/chef/provider/subversion.rb +2 -2
- data/lib/chef/provider/user/aix.rb +1 -1
- data/lib/chef/provider/user/dscl.rb +6 -6
- data/lib/chef/provider/user/linux.rb +3 -3
- data/lib/chef/provider/user/mac.rb +15 -11
- data/lib/chef/provider/windows_script.rb +87 -25
- data/lib/chef/provider/windows_task.rb +4 -2
- data/lib/chef/provider/zypper_repository.rb +30 -10
- data/lib/chef/resource.rb +25 -14
- data/lib/chef/resource/alternatives.rb +1 -1
- data/lib/chef/resource/apt_package.rb +1 -1
- data/lib/chef/resource/archive_file.rb +28 -8
- data/lib/chef/resource/bash.rb +0 -1
- data/lib/chef/resource/batch.rb +4 -2
- data/lib/chef/resource/chef_client_scheduled_task.rb +13 -1
- data/lib/chef/resource/chef_gem.rb +57 -21
- data/lib/chef/resource/chef_handler.rb +2 -2
- data/lib/chef/resource/chef_vault_secret.rb +1 -1
- data/lib/chef/resource/cron/_cron_shared.rb +98 -0
- data/lib/chef/resource/cron/cron.rb +46 -0
- data/lib/chef/resource/{cron_d.rb → cron/cron_d.rb} +7 -87
- data/lib/chef/resource/cron_access.rb +11 -3
- data/lib/chef/resource/csh.rb +0 -1
- data/lib/chef/resource/dmg_package.rb +2 -2
- data/lib/chef/resource/execute.rb +478 -8
- data/lib/chef/resource/file.rb +10 -8
- data/lib/chef/resource/freebsd_package.rb +1 -1
- data/lib/chef/resource/gem_package.rb +35 -2
- data/lib/chef/resource/helpers/cron_validations.rb +6 -3
- data/lib/chef/resource/homebrew_package.rb +30 -1
- data/lib/chef/resource/homebrew_update.rb +107 -0
- data/lib/chef/resource/hostname.rb +7 -20
- data/lib/chef/resource/kernel_module.rb +14 -1
- data/lib/chef/resource/launchd.rb +1 -1
- data/lib/chef/resource/locale.rb +3 -3
- data/lib/chef/resource/macos_userdefaults.rb +11 -6
- data/lib/chef/resource/mount.rb +1 -1
- data/lib/chef/resource/perl.rb +0 -1
- data/lib/chef/resource/plist.rb +23 -4
- data/lib/chef/resource/powershell_script.rb +4 -2
- data/lib/chef/resource/python.rb +0 -1
- data/lib/chef/resource/remote_file.rb +26 -10
- data/lib/chef/resource/ruby.rb +0 -1
- data/lib/chef/resource/scm/git.rb +1 -1
- data/lib/chef/resource/ssh_known_hosts_entry.rb +15 -0
- data/lib/chef/resource/sudo.rb +29 -2
- data/lib/chef/resource/swap_file.rb +17 -0
- data/lib/chef/resource/template.rb +1 -1
- data/lib/chef/resource/timezone.rb +15 -0
- data/lib/chef/resource/windows_ad_join.rb +30 -1
- data/lib/chef/resource/windows_audit_policy.rb +227 -0
- data/lib/chef/resource/windows_auto_run.rb +11 -0
- data/lib/chef/resource/windows_certificate.rb +27 -1
- data/lib/chef/resource/windows_dfs_server.rb +1 -1
- data/lib/chef/resource/windows_font.rb +3 -3
- data/lib/chef/resource/windows_package.rb +1 -1
- data/lib/chef/resource/windows_pagefile.rb +2 -2
- data/lib/chef/resource/windows_script.rb +2 -16
- data/lib/chef/resource/windows_security_policy.rb +47 -16
- data/lib/chef/resource/windows_shortcut.rb +1 -2
- data/lib/chef/resource/windows_task.rb +10 -10
- data/lib/chef/resource/windows_user_privilege.rb +70 -5
- data/lib/chef/resource/yum_repository.rb +9 -9
- data/lib/chef/resource_inspector.rb +4 -3
- data/lib/chef/resources.rb +4 -2
- data/lib/chef/run_context/cookbook_compiler.rb +1 -1
- data/lib/chef/search/query.rb +1 -1
- data/lib/chef/shell/ext.rb +1 -1
- data/lib/chef/util/diff.rb +2 -2
- data/lib/chef/util/windows/net_user.rb +1 -1
- data/lib/chef/util/windows/volume.rb +1 -1
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/api.rb +2 -2
- data/lib/chef/win32/api/error.rb +3 -1
- data/lib/chef/win32/api/file.rb +1 -1
- data/lib/chef/win32/api/net.rb +1 -0
- data/lib/chef/win32/file.rb +1 -1
- data/lib/chef/win32/mutex.rb +1 -1
- data/lib/chef/win32/net.rb +1 -0
- data/lib/chef/win32/registry.rb +2 -2
- data/lib/chef/win32/security.rb +1 -1
- data/lib/chef/win32/security/sid.rb +4 -4
- data/spec/data/lwrp/providers/buck_passer.rb +1 -1
- data/spec/data/lwrp/providers/buck_passer_2.rb +1 -1
- data/spec/data/lwrp/providers/embedded_resource_accesses_providers_scope.rb +1 -1
- data/spec/functional/knife/configure_spec.rb +1 -1
- data/spec/functional/resource/aix_service_spec.rb +10 -1
- data/spec/functional/resource/aixinit_service_spec.rb +1 -1
- data/spec/functional/resource/bash_spec.rb +3 -2
- data/spec/functional/resource/bff_spec.rb +1 -1
- data/spec/functional/resource/chocolatey_package_spec.rb +4 -0
- data/spec/functional/resource/cron_spec.rb +20 -1
- data/spec/functional/resource/dnf_package_spec.rb +6 -3
- data/spec/functional/resource/execute_spec.rb +1 -1
- data/spec/functional/resource/git_spec.rb +6 -6
- data/spec/functional/resource/group_spec.rb +9 -1
- data/spec/functional/resource/ifconfig_spec.rb +9 -1
- data/spec/functional/resource/insserv_spec.rb +3 -2
- data/spec/functional/resource/launchd_spec.rb +232 -0
- data/spec/functional/resource/link_spec.rb +2 -5
- data/spec/functional/resource/mount_spec.rb +9 -1
- data/spec/functional/resource/msu_package_spec.rb +9 -3
- data/spec/functional/resource/powershell_script_spec.rb +4 -4
- data/spec/functional/resource/remote_file_spec.rb +8 -8
- data/spec/functional/resource/rpm_spec.rb +1 -1
- data/spec/functional/resource/timezone_spec.rb +2 -0
- data/spec/functional/resource/windows_package_spec.rb +0 -1
- data/spec/functional/resource/windows_path_spec.rb +4 -0
- data/spec/functional/resource/windows_security_policy_spec.rb +0 -1
- data/spec/functional/resource/windows_service_spec.rb +4 -0
- data/spec/functional/resource/windows_task_spec.rb +16 -15
- data/spec/functional/resource/windows_user_privilege_spec.rb +0 -1
- data/spec/functional/resource/yum_package_spec.rb +4 -1
- data/spec/functional/resource/zypper_package_spec.rb +4 -1
- data/spec/functional/shell_spec.rb +0 -1
- data/spec/functional/win32/crypto_spec.rb +1 -1
- data/spec/integration/knife/config_use_profile_spec.rb +55 -2
- data/spec/integration/knife/cookbook_upload_spec.rb +1 -1
- data/spec/integration/knife/data_bag_from_file_spec.rb +1 -1
- data/spec/integration/knife/environment_from_file_spec.rb +1 -1
- data/spec/integration/knife/node_from_file_spec.rb +1 -1
- data/spec/integration/knife/role_from_file_spec.rb +1 -1
- data/spec/integration/recipes/recipe_dsl_spec.rb +4 -0
- data/spec/integration/recipes/resource_load_spec.rb +2 -2
- data/spec/support/chef_helpers.rb +1 -1
- data/spec/support/platform_helpers.rb +1 -1
- data/spec/support/platforms/win32/spec_service.rb +1 -1
- data/spec/support/shared/functional/execute_resource.rb +1 -1
- data/spec/support/shared/functional/securable_resource.rb +1 -2
- data/spec/support/shared/functional/securable_resource_with_reporting.rb +0 -1
- data/spec/support/shared/functional/windows_script.rb +3 -3
- data/spec/support/shared/unit/execute_resource.rb +1 -1
- data/spec/support/shared/unit/provider/file.rb +12 -8
- data/spec/support/shared/unit/provider/useradd_based_user_provider.rb +4 -4
- data/spec/unit/application/solo_spec.rb +4 -2
- data/spec/unit/application_spec.rb +7 -0
- data/spec/unit/chef_fs/config_spec.rb +2 -2
- data/spec/unit/chef_fs/diff_spec.rb +8 -8
- data/spec/unit/client_spec.rb +4 -1
- data/spec/unit/cookbook/synchronizer_spec.rb +26 -24
- data/spec/unit/data_bag_spec.rb +6 -3
- data/spec/unit/decorator_spec.rb +23 -23
- data/spec/unit/environment_spec.rb +5 -1
- data/spec/unit/guard_interpreter_spec.rb +1 -1
- data/spec/unit/http/api_versions_spec.rb +1 -1
- data/spec/unit/http/ssl_policies_spec.rb +20 -0
- data/spec/unit/knife/bootstrap_spec.rb +3 -2
- data/spec/unit/knife/cookbook_download_spec.rb +2 -2
- data/spec/unit/knife/cookbook_show_spec.rb +6 -7
- data/spec/unit/knife/core/windows_bootstrap_context_spec.rb +7 -1
- data/spec/unit/knife/data_bag_edit_spec.rb +1 -1
- data/spec/unit/lwrp_spec.rb +5 -2
- data/spec/unit/mixin/openssl_helper_spec.rb +4 -4
- data/spec/unit/mixin/powershell_out_spec.rb +2 -4
- data/spec/unit/mixin/powershell_type_coercions_spec.rb +1 -1
- data/spec/unit/mixin/subclass_directive_spec.rb +2 -2
- data/spec/unit/mixin/unformatter_spec.rb +2 -2
- data/spec/unit/mixin/uris_spec.rb +1 -1
- data/spec/unit/mixin/user_context_spec.rb +1 -9
- data/spec/unit/node/attribute_spec.rb +1 -1
- data/spec/unit/property_spec.rb +1 -1
- data/spec/unit/provider/batch_spec.rb +130 -0
- data/spec/unit/provider/cron/unix_spec.rb +1 -1
- data/spec/unit/provider/cron_spec.rb +9 -49
- data/spec/unit/provider/dsc_resource_spec.rb +22 -38
- data/spec/unit/provider/dsc_script_spec.rb +10 -10
- data/spec/unit/provider/execute_spec.rb +1 -1
- data/spec/unit/provider/git_spec.rb +3 -3
- data/spec/unit/provider/group/groupadd_spec.rb +1 -1
- data/spec/unit/provider/launchd_spec.rb +0 -42
- data/spec/unit/provider/mdadm_spec.rb +1 -3
- data/spec/unit/provider/package/openbsd_spec.rb +1 -1
- data/spec/unit/provider/package/pacman_spec.rb +17 -20
- data/spec/unit/provider/package/portage_spec.rb +2 -2
- data/spec/unit/provider/package/powershell_spec.rb +96 -87
- data/spec/unit/provider/package/snap_spec.rb +1 -1
- data/spec/unit/provider/package/windows/registry_uninstall_entry_spec.rb +3 -3
- data/spec/unit/provider/powershell_script_spec.rb +3 -45
- data/spec/unit/provider/script_spec.rb +20 -110
- data/spec/unit/provider/user/dscl_spec.rb +2 -2
- data/spec/unit/provider/windows_env_spec.rb +5 -4
- data/spec/unit/provider/zypper_repository_spec.rb +60 -10
- data/spec/unit/resource/archive_file_spec.rb +11 -2
- data/spec/unit/resource/chef_client_cron_spec.rb +23 -7
- data/spec/unit/resource/chef_client_scheduled_task_spec.rb +17 -7
- data/spec/unit/resource/chef_client_systemd_timer_spec.rb +7 -4
- data/spec/unit/resource/cron_spec.rb +2 -2
- data/spec/unit/resource/file/verification_spec.rb +2 -1
- data/spec/unit/resource/helpers/cron_validations_spec.rb +5 -1
- data/spec/unit/resource/homebrew_update_spec.rb +30 -0
- data/spec/unit/resource/powershell_script_spec.rb +10 -15
- data/spec/unit/resource/timezone_spec.rb +1 -1
- data/spec/unit/resource/windows_audit_policy_spec.rb +64 -0
- data/spec/unit/resource/windows_dns_record_spec.rb +3 -3
- data/spec/unit/resource/windows_dns_zone_spec.rb +2 -2
- data/spec/unit/resource/windows_task_spec.rb +1 -1
- data/spec/unit/resource/windows_uac_spec.rb +2 -2
- data/spec/unit/resource/yum_repository_spec.rb +21 -21
- data/spec/unit/resource_spec.rb +84 -1
- data/spec/unit/role_spec.rb +23 -21
- data/spec/unit/util/backup_spec.rb +1 -1
- data/spec/unit/util/dsc/configuration_generator_spec.rb +1 -1
- data/spec/unit/util/powershell/ps_credential_spec.rb +2 -2
- data/spec/unit/util/selinux_spec.rb +2 -1
- data/spec/unit/util/threaded_job_queue_spec.rb +9 -0
- data/spec/unit/win32/registry_spec.rb +1 -1
- metadata +37 -31
- data/lib/chef/resource/cron.rb +0 -157
- data/spec/functional/resource/base.rb +0 -28
@@ -118,13 +118,13 @@ describe Chef::Provider::Package::Portage, "load_current_resource" do
|
|
118
118
|
expect { @provider.candidate_version }.to raise_error(Chef::Exceptions::Package)
|
119
119
|
end
|
120
120
|
|
121
|
-
it "should find the candidate_version if a category is
|
121
|
+
it "should find the candidate_version if a category is specified and there are no duplicates" do
|
122
122
|
status = double(stdout: "dev-vcs/git-2.16.2", exitstatus: 0)
|
123
123
|
expect(@provider).to receive(:shell_out_compacted).and_return(status)
|
124
124
|
expect(@provider.candidate_version).to eq("2.16.2")
|
125
125
|
end
|
126
126
|
|
127
|
-
it "should find the candidate_version if a category is not
|
127
|
+
it "should find the candidate_version if a category is not specified and there are no duplicates" do
|
128
128
|
status = double(stdout: "dev-vcs/git-2.16.2", exitstatus: 0)
|
129
129
|
@provider = Chef::Provider::Package::Portage.new(@new_resource_without_category, @run_context)
|
130
130
|
expect(@provider).to receive(:shell_out_compacted).and_return(status)
|
@@ -94,19 +94,19 @@ describe Chef::Provider::Package::Powershell, :windows_only do
|
|
94
94
|
double("powershell_out", stdout: "5")
|
95
95
|
end
|
96
96
|
|
97
|
-
let(:generated_command) { "( Get-Package posh-git -Force -ForceBootstrap ).Version" }
|
98
|
-
let(:generated_get_cmdlet) { "( Get-Package xNetworking -Force -ForceBootstrap ).Version" }
|
99
|
-
let(:generated_get_cmdlet_with_version) { "( Get-Package xNetworking -Force -ForceBootstrap -RequiredVersion 1.0.0.0 ).Version" }
|
100
|
-
let(:generated_find_cmdlet) { "( Find-Package xNetworking -Force -ForceBootstrap ).Version" }
|
101
|
-
let(:generated_find_cmdlet_with_version) { "( Find-Package xNetworking -Force -ForceBootstrap -RequiredVersion 1.0.0.0 ).Version" }
|
102
|
-
let(:generated_find_cmdlet_with_source) { "( Find-Package xNetworking -Force -ForceBootstrap -Source MyGallery ).Version" }
|
103
|
-
let(:generated_find_cmdlet_with_source_and_version) { "( Find-Package xNetworking -Force -ForceBootstrap -RequiredVersion 1.0.0.0 -Source MyGallery ).Version" }
|
104
|
-
let(:generated_install_cmdlet) { "( Install-Package xNetworking -Force -ForceBootstrap ).Version" }
|
105
|
-
let(:generated_install_cmdlet_with_version) { "( Install-Package xNetworking -Force -ForceBootstrap -RequiredVersion 1.0.0.0 ).Version" }
|
106
|
-
let(:generated_install_cmdlet_with_source) { "( Install-Package xNetworking -Force -ForceBootstrap -Source MyGallery ).Version" }
|
107
|
-
let(:generated_install_cmdlet_with_source_and_version) { "( Install-Package xNetworking -Force -ForceBootstrap -RequiredVersion 1.0.0.0 -Source MyGallery ).Version" }
|
108
|
-
let(:generated_uninstall_cmdlet) { "( Uninstall-Package xNetworking -Force -ForceBootstrap ).Version" }
|
109
|
-
let(:generated_uninstall_cmdlet_with_version) { "( Uninstall-Package xNetworking -Force -ForceBootstrap -RequiredVersion 1.0.0.0 ).Version" }
|
97
|
+
let(:generated_command) { "( Get-Package posh-git -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version" }
|
98
|
+
let(:generated_get_cmdlet) { "( Get-Package xNetworking -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version" }
|
99
|
+
let(:generated_get_cmdlet_with_version) { "( Get-Package xNetworking -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 1.0.0.0 ).Version" }
|
100
|
+
let(:generated_find_cmdlet) { "( Find-Package xNetworking -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version" }
|
101
|
+
let(:generated_find_cmdlet_with_version) { "( Find-Package xNetworking -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 1.0.0.0 ).Version" }
|
102
|
+
let(:generated_find_cmdlet_with_source) { "( Find-Package xNetworking -Force -ForceBootstrap -WarningAction SilentlyContinue -Source MyGallery ).Version" }
|
103
|
+
let(:generated_find_cmdlet_with_source_and_version) { "( Find-Package xNetworking -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 1.0.0.0 -Source MyGallery ).Version" }
|
104
|
+
let(:generated_install_cmdlet) { "( Install-Package xNetworking -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version" }
|
105
|
+
let(:generated_install_cmdlet_with_version) { "( Install-Package xNetworking -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 1.0.0.0 ).Version" }
|
106
|
+
let(:generated_install_cmdlet_with_source) { "( Install-Package xNetworking -Force -ForceBootstrap -WarningAction SilentlyContinue -Source MyGallery ).Version" }
|
107
|
+
let(:generated_install_cmdlet_with_source_and_version) { "( Install-Package xNetworking -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 1.0.0.0 -Source MyGallery ).Version" }
|
108
|
+
let(:generated_uninstall_cmdlet) { "( Uninstall-Package xNetworking -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version" }
|
109
|
+
let(:generated_uninstall_cmdlet_with_version) { "( Uninstall-Package xNetworking -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 1.0.0.0 ).Version" }
|
110
110
|
|
111
111
|
describe "#initialize" do
|
112
112
|
it "should return the correct class" do
|
@@ -117,75 +117,75 @@ describe Chef::Provider::Package::Powershell, :windows_only do
|
|
117
117
|
describe "#candidate_version" do
|
118
118
|
|
119
119
|
it "should set the candidate_version to the latest version when not pinning" do
|
120
|
-
allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
|
120
|
+
allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
|
121
121
|
new_resource.package_name(["xNetworking"])
|
122
122
|
new_resource.version(nil)
|
123
123
|
expect(provider.candidate_version).to eql(["2.12.0.0"])
|
124
124
|
end
|
125
125
|
|
126
126
|
it "should use the candidate_version from the correct source" do
|
127
|
-
allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -Source MyGallery ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
|
127
|
+
allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue -Source MyGallery ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
|
128
128
|
new_resource.package_name(["xNetworking"])
|
129
129
|
new_resource.version(nil)
|
130
130
|
new_resource.source("MyGallery")
|
131
131
|
expect(provider.candidate_version).to eql(["2.12.0.0"])
|
132
132
|
end
|
133
133
|
|
134
|
-
it "should set the candidate_version to the latest version when not pinning and package name is space
|
135
|
-
allow(provider).to receive(:powershell_out).with("( Find-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_7zip_available)
|
134
|
+
it "should set the candidate_version to the latest version when not pinning and package name is space separated" do
|
135
|
+
allow(provider).to receive(:powershell_out).with("( Find-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_7zip_available)
|
136
136
|
new_resource.package_name(["7-Zip 16.02 (x64)"])
|
137
137
|
new_resource.version(nil)
|
138
138
|
expect(provider.candidate_version).to eql(["16.02"])
|
139
139
|
end
|
140
140
|
|
141
141
|
it "should set the candidate_version to pinned version if available" do
|
142
|
-
allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.0.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available_2_0_0_0)
|
142
|
+
allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.0.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available_2_0_0_0)
|
143
143
|
new_resource.package_name(["xCertificate"])
|
144
144
|
new_resource.version(["2.0.0.0"])
|
145
145
|
expect(provider.candidate_version).to eql(["2.0.0.0"])
|
146
146
|
end
|
147
147
|
|
148
148
|
it "should set the candidate_version to nil if there is no candidate" do
|
149
|
-
allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
|
149
|
+
allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
|
150
150
|
new_resource.package_name(["xCertificate"])
|
151
151
|
expect(provider.candidate_version).to eql([nil])
|
152
152
|
end
|
153
153
|
|
154
154
|
it "should set the candidate_version correctly when there are two packages to install" do
|
155
|
-
allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
156
|
-
allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
|
155
|
+
allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
156
|
+
allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
|
157
157
|
new_resource.package_name(%w{xCertificate xNetworking})
|
158
158
|
new_resource.version(nil)
|
159
159
|
expect(provider.candidate_version).to eql(["2.1.0.0", "2.12.0.0"])
|
160
160
|
end
|
161
161
|
|
162
162
|
it "should set the candidate_version correctly when only the first is installable" do
|
163
|
-
allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
164
|
-
allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
|
163
|
+
allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
164
|
+
allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
|
165
165
|
new_resource.package_name(%w{xCertificate xNetworking})
|
166
166
|
new_resource.version(nil)
|
167
167
|
expect(provider.candidate_version).to eql(["2.1.0.0", nil])
|
168
168
|
end
|
169
169
|
|
170
170
|
it "should set the candidate_version correctly when only the last is installable" do
|
171
|
-
allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
|
172
|
-
allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
|
171
|
+
allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
|
172
|
+
allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
|
173
173
|
new_resource.package_name(%w{xCertificate xNetworking})
|
174
174
|
new_resource.version(nil)
|
175
175
|
expect(provider.candidate_version).to eql([nil, "2.12.0.0"])
|
176
176
|
end
|
177
177
|
|
178
178
|
it "should set the candidate_version correctly when neither are is installable and version is passed as nil array" do
|
179
|
-
allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
|
180
|
-
allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
|
179
|
+
allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
|
180
|
+
allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
|
181
181
|
new_resource.package_name(%w{xNetworking xCertificate})
|
182
182
|
new_resource.version([nil, nil])
|
183
183
|
expect(provider.candidate_version).to eql([nil, nil])
|
184
184
|
end
|
185
185
|
|
186
186
|
it "should set the candidate_version correctly when neither are is installable and version is not passed" do
|
187
|
-
allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
|
188
|
-
allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
|
187
|
+
allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
|
188
|
+
allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
|
189
189
|
new_resource.package_name(%w{xNetworking xCertificate})
|
190
190
|
new_resource.version(nil)
|
191
191
|
expect(provider.candidate_version).to eql([nil, nil])
|
@@ -284,10 +284,11 @@ describe Chef::Provider::Package::Powershell, :windows_only do
|
|
284
284
|
provider.load_current_resource
|
285
285
|
new_resource.package_name(["xCertificate"])
|
286
286
|
new_resource.version(nil)
|
287
|
-
allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
288
|
-
allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
|
287
|
+
allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
288
|
+
allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
|
289
289
|
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
|
290
|
-
|
290
|
+
allow(provider).to receive(:powershell_out).with("[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12")
|
291
|
+
expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
|
291
292
|
provider.run_action(:install)
|
292
293
|
expect(new_resource).to be_updated_by_last_action
|
293
294
|
end
|
@@ -297,10 +298,11 @@ describe Chef::Provider::Package::Powershell, :windows_only do
|
|
297
298
|
new_resource.package_name(["xCertificate"])
|
298
299
|
new_resource.version(nil)
|
299
300
|
new_resource.source("MyGallery")
|
300
|
-
allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -Source MyGallery ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
301
|
-
allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
|
301
|
+
allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -Source MyGallery ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
302
|
+
allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
|
302
303
|
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
|
303
|
-
|
304
|
+
allow(provider).to receive(:powershell_out).with("[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12")
|
305
|
+
expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 -Source MyGallery ).Version", { timeout: new_resource.timeout })
|
304
306
|
provider.run_action(:install)
|
305
307
|
expect(new_resource).to be_updated_by_last_action
|
306
308
|
end
|
@@ -310,10 +312,11 @@ describe Chef::Provider::Package::Powershell, :windows_only do
|
|
310
312
|
new_resource.package_name(["xCertificate"])
|
311
313
|
new_resource.version(nil)
|
312
314
|
new_resource.skip_publisher_check(true)
|
313
|
-
allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
314
|
-
allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -SkipPublisherCheck ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
|
315
|
+
allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
316
|
+
allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -SkipPublisherCheck ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
|
315
317
|
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
|
316
|
-
|
318
|
+
allow(provider).to receive(:powershell_out).with("[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12")
|
319
|
+
expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 -SkipPublisherCheck ).Version", { timeout: new_resource.timeout })
|
317
320
|
provider.run_action(:install)
|
318
321
|
expect(new_resource).to be_updated_by_last_action
|
319
322
|
end
|
@@ -322,10 +325,11 @@ describe Chef::Provider::Package::Powershell, :windows_only do
|
|
322
325
|
provider.load_current_resource
|
323
326
|
new_resource.package_name(["7-Zip 16.02 (x64)"])
|
324
327
|
new_resource.version(nil)
|
325
|
-
allow(provider).to receive(:powershell_out).with("( Find-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_7zip_available)
|
326
|
-
allow(provider).to receive(:powershell_out).with("( Get-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_7zip_not_installed)
|
328
|
+
allow(provider).to receive(:powershell_out).with("( Find-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_7zip_available)
|
329
|
+
allow(provider).to receive(:powershell_out).with("( Get-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_7zip_not_installed)
|
327
330
|
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
|
328
|
-
|
331
|
+
allow(provider).to receive(:powershell_out).with("[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12")
|
332
|
+
expect(provider).to receive(:powershell_out).with("( Install-Package '7-Zip 16.02 (x64)' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 16.02 ).Version", { timeout: new_resource.timeout })
|
329
333
|
provider.run_action(:install)
|
330
334
|
expect(new_resource).to be_updated_by_last_action
|
331
335
|
end
|
@@ -337,10 +341,11 @@ describe Chef::Provider::Package::Powershell, :windows_only do
|
|
337
341
|
provider.load_current_resource
|
338
342
|
new_resource.package_name(["xCertificate"])
|
339
343
|
new_resource.version(nil)
|
340
|
-
allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
341
|
-
allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
|
344
|
+
allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
345
|
+
allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
|
342
346
|
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
|
343
|
-
|
347
|
+
allow(provider).to receive(:powershell_out).with("[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12")
|
348
|
+
expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
|
344
349
|
provider.run_action(:install)
|
345
350
|
expect(new_resource).to be_updated_by_last_action
|
346
351
|
end
|
@@ -349,8 +354,8 @@ describe Chef::Provider::Package::Powershell, :windows_only do
|
|
349
354
|
it "should not install packages that are up-to-date" do
|
350
355
|
new_resource.package_name(["xCertificate"])
|
351
356
|
new_resource.version(nil)
|
352
|
-
allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
353
|
-
allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
357
|
+
allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
358
|
+
allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
354
359
|
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
|
355
360
|
provider.load_current_resource
|
356
361
|
expect(provider).not_to receive(:install_package)
|
@@ -361,8 +366,8 @@ describe Chef::Provider::Package::Powershell, :windows_only do
|
|
361
366
|
it "should not install packages that are up-to-date" do
|
362
367
|
new_resource.package_name(["xNetworking"])
|
363
368
|
new_resource.version(["2.11.0.0"])
|
364
|
-
allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.11.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
365
|
-
allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.11.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available_2_11_0_0)
|
369
|
+
allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.11.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
370
|
+
allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.11.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available_2_11_0_0)
|
366
371
|
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
|
367
372
|
provider.load_current_resource
|
368
373
|
expect(provider).not_to receive(:install_package)
|
@@ -375,13 +380,14 @@ describe Chef::Provider::Package::Powershell, :windows_only do
|
|
375
380
|
# new_version.resource[0]
|
376
381
|
new_resource.package_name(%w{xCertificate xNetworking})
|
377
382
|
new_resource.version([nil, "2.11.0.0"])
|
378
|
-
allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
379
|
-
allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
|
380
|
-
allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.11.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available_2_11_0_0)
|
381
|
-
allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap -RequiredVersion 2.11.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
|
383
|
+
allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
384
|
+
allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
|
385
|
+
allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.11.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available_2_11_0_0)
|
386
|
+
allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.11.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
|
382
387
|
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
|
383
|
-
|
384
|
-
expect(provider).to receive(:powershell_out).with("( Install-Package '
|
388
|
+
allow(provider).to receive(:powershell_out).with("[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12")
|
389
|
+
expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
|
390
|
+
expect(provider).to receive(:powershell_out).with("( Install-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.11.0.0 ).Version", { timeout: new_resource.timeout })
|
385
391
|
provider.load_current_resource
|
386
392
|
provider.run_action(:install)
|
387
393
|
expect(new_resource).to be_updated_by_last_action
|
@@ -390,13 +396,14 @@ describe Chef::Provider::Package::Powershell, :windows_only do
|
|
390
396
|
it "should split up commands when given two packages, one with a version pin" do
|
391
397
|
new_resource.package_name(%w{xCertificate xNetworking})
|
392
398
|
new_resource.version(["2.1.0.0", nil])
|
393
|
-
allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
394
|
-
allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
|
395
|
-
allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
|
396
|
-
allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
|
399
|
+
allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
400
|
+
allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
|
401
|
+
allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
|
402
|
+
allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
|
397
403
|
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
|
398
|
-
|
399
|
-
expect(provider).to receive(:powershell_out).with("( Install-Package '
|
404
|
+
allow(provider).to receive(:powershell_out).with("[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12")
|
405
|
+
expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
|
406
|
+
expect(provider).to receive(:powershell_out).with("( Install-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.12.0.0 ).Version", { timeout: new_resource.timeout })
|
400
407
|
|
401
408
|
provider.load_current_resource
|
402
409
|
provider.run_action(:install)
|
@@ -406,13 +413,14 @@ describe Chef::Provider::Package::Powershell, :windows_only do
|
|
406
413
|
it "should do multipackage installs when given two packages without constraints" do
|
407
414
|
new_resource.package_name(%w{xCertificate xNetworking})
|
408
415
|
new_resource.version(nil)
|
409
|
-
allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
410
|
-
allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
|
411
|
-
allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
|
412
|
-
allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
|
416
|
+
allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
417
|
+
allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
|
418
|
+
allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
|
419
|
+
allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
|
413
420
|
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
|
414
|
-
|
415
|
-
expect(provider).to receive(:powershell_out).with("( Install-Package '
|
421
|
+
allow(provider).to receive(:powershell_out).with("[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12")
|
422
|
+
expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
|
423
|
+
expect(provider).to receive(:powershell_out).with("( Install-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.12.0.0 ).Version", { timeout: new_resource.timeout })
|
416
424
|
provider.load_current_resource
|
417
425
|
provider.run_action(:install)
|
418
426
|
expect(new_resource).to be_updated_by_last_action
|
@@ -422,13 +430,14 @@ describe Chef::Provider::Package::Powershell, :windows_only do
|
|
422
430
|
new_resource.package_name(%w{xCertificate xNetworking})
|
423
431
|
new_resource.version(nil)
|
424
432
|
new_resource.source("MyGallery")
|
425
|
-
allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -Source MyGallery ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
426
|
-
allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
|
427
|
-
allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -Source MyGallery ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
|
428
|
-
allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
|
433
|
+
allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -Source MyGallery ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
434
|
+
allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
|
435
|
+
allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue -Source MyGallery ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
|
436
|
+
allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
|
429
437
|
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
|
430
|
-
|
431
|
-
expect(provider).to receive(:powershell_out).with("( Install-Package '
|
438
|
+
allow(provider).to receive(:powershell_out).with("[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12")
|
439
|
+
expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 -Source MyGallery ).Version", { timeout: new_resource.timeout })
|
440
|
+
expect(provider).to receive(:powershell_out).with("( Install-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.12.0.0 -Source MyGallery ).Version", { timeout: new_resource.timeout })
|
432
441
|
provider.load_current_resource
|
433
442
|
provider.run_action(:install)
|
434
443
|
expect(new_resource).to be_updated_by_last_action
|
@@ -440,8 +449,8 @@ describe Chef::Provider::Package::Powershell, :windows_only do
|
|
440
449
|
provider.load_current_resource
|
441
450
|
new_resource.package_name(["xCertificate"])
|
442
451
|
new_resource.version(["2.1.0.0"])
|
443
|
-
allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
444
|
-
allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
|
452
|
+
allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
453
|
+
allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
|
445
454
|
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
|
446
455
|
expect(provider).not_to receive(:remove_package)
|
447
456
|
provider.run_action(:remove)
|
@@ -452,11 +461,11 @@ describe Chef::Provider::Package::Powershell, :windows_only do
|
|
452
461
|
new_resource.package_name(["xCertificate"])
|
453
462
|
new_resource.version(["2.1.0.0"])
|
454
463
|
new_resource.source("MyGallery")
|
455
|
-
allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 -Source MyGallery).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
456
|
-
allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
464
|
+
allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 -Source MyGallery).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
465
|
+
allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
457
466
|
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
|
458
467
|
provider.load_current_resource
|
459
|
-
expect(provider).to receive(:powershell_out).with("( Uninstall-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
|
468
|
+
expect(provider).to receive(:powershell_out).with("( Uninstall-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
|
460
469
|
provider.run_action(:remove)
|
461
470
|
expect(new_resource).to be_updated_by_last_action
|
462
471
|
end
|
@@ -464,10 +473,10 @@ describe Chef::Provider::Package::Powershell, :windows_only do
|
|
464
473
|
it "does nothing when all the packages are already removed" do
|
465
474
|
new_resource.package_name(%w{xCertificate xNetworking})
|
466
475
|
new_resource.version(nil)
|
467
|
-
allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
468
|
-
allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
|
469
|
-
allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
|
470
|
-
allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
|
476
|
+
allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
477
|
+
allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
|
478
|
+
allow(provider).to receive(:powershell_out).with("( Find-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_available)
|
479
|
+
allow(provider).to receive(:powershell_out).with("( Get-Package 'xNetworking' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xnetworking_not_available)
|
471
480
|
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
|
472
481
|
provider.load_current_resource
|
473
482
|
expect(provider).not_to receive(:remove_package)
|
@@ -478,11 +487,11 @@ describe Chef::Provider::Package::Powershell, :windows_only do
|
|
478
487
|
it "removes a package when version is specified" do
|
479
488
|
new_resource.package_name(["xCertificate"])
|
480
489
|
new_resource.version(["2.1.0.0"])
|
481
|
-
allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
482
|
-
allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
490
|
+
allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
491
|
+
allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
483
492
|
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
|
484
493
|
provider.load_current_resource
|
485
|
-
expect(provider).to receive(:powershell_out).with("( Uninstall-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
|
494
|
+
expect(provider).to receive(:powershell_out).with("( Uninstall-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue -RequiredVersion 2.1.0.0 ).Version", { timeout: new_resource.timeout })
|
486
495
|
provider.run_action(:remove)
|
487
496
|
expect(new_resource).to be_updated_by_last_action
|
488
497
|
end
|
@@ -490,11 +499,11 @@ describe Chef::Provider::Package::Powershell, :windows_only do
|
|
490
499
|
it "removes a package when version is not specified" do
|
491
500
|
new_resource.package_name(["xCertificate"])
|
492
501
|
new_resource.version(nil)
|
493
|
-
allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
494
|
-
allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
502
|
+
allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
503
|
+
allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_available)
|
495
504
|
allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version)
|
496
505
|
provider.load_current_resource
|
497
|
-
expect(provider).to receive(:powershell_out).with("( Uninstall-Package 'xCertificate' -Force -ForceBootstrap ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
|
506
|
+
expect(provider).to receive(:powershell_out).with("( Uninstall-Package 'xCertificate' -Force -ForceBootstrap -WarningAction SilentlyContinue ).Version", { timeout: new_resource.timeout }).and_return(package_xcertificate_not_available)
|
498
507
|
provider.run_action(:remove)
|
499
508
|
expect(new_resource).to be_updated_by_last_action
|
500
509
|
end
|
@@ -169,7 +169,7 @@ describe Chef::Provider::Package::Snap do
|
|
169
169
|
|
170
170
|
it "does not throw an error if installed version not found" do
|
171
171
|
provider.load_current_resource
|
172
|
-
expect(provider.get_current_versions).to eq([
|
172
|
+
expect(provider.get_current_versions).to eq([])
|
173
173
|
end
|
174
174
|
end
|
175
175
|
end
|
@@ -8,7 +8,7 @@ describe Chef::Provider::Package::Windows::RegistryUninstallEntry do
|
|
8
8
|
|
9
9
|
describe "when QuietUninstallString key not present" do
|
10
10
|
let(:quiet_uninstall_string) { nil }
|
11
|
-
let
|
11
|
+
let(:quiet_uninstall_string_key) { Chef::Provider::Package::Windows::RegistryUninstallEntry.quiet_uninstall_string_key?(quiet_uninstall_string, hkey, key, entry).uninstall_string }
|
12
12
|
it "returns UninstallString key value" do
|
13
13
|
expect(quiet_uninstall_string_key).to eql "UninstallStringPath"
|
14
14
|
end
|
@@ -16,14 +16,14 @@ describe Chef::Provider::Package::Windows::RegistryUninstallEntry do
|
|
16
16
|
|
17
17
|
describe "when QuietUninstallString key present" do
|
18
18
|
let(:quiet_uninstall_string) { "QuietUninstallString" }
|
19
|
-
let
|
19
|
+
let(:quiet_uninstall_string_key) { Chef::Provider::Package::Windows::RegistryUninstallEntry.quiet_uninstall_string_key?(quiet_uninstall_string, hkey, key, entry).uninstall_string }
|
20
20
|
it "returns QuietUninstallString key value" do
|
21
21
|
expect(quiet_uninstall_string_key).to eql "QuietUninstallStringPath"
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
25
|
describe ".find_entries", :windows_only do
|
26
|
-
let
|
26
|
+
let(:registry_uninstall_entry) { Chef::Provider::Package::Windows::RegistryUninstallEntry }
|
27
27
|
before(:each) do
|
28
28
|
allow_any_instance_of(::Win32::Registry).to receive(:open).and_return("::Win32::Registry::HKEY_CURRENT_USER")
|
29
29
|
end
|
@@ -18,34 +18,12 @@
|
|
18
18
|
|
19
19
|
require "spec_helper"
|
20
20
|
describe Chef::Provider::PowershellScript, "action_run" do
|
21
|
-
|
22
|
-
let(:powershell_version) { nil }
|
23
|
-
let(:node) do
|
24
|
-
node = Chef::Node.new
|
25
|
-
node.default["kernel"] = {}
|
26
|
-
node.default["kernel"][:machine] = :x86_64.to_s
|
27
|
-
unless powershell_version.nil?
|
28
|
-
node.default[:languages] = { powershell: { version: powershell_version } }
|
29
|
-
end
|
30
|
-
node
|
31
|
-
end
|
32
|
-
|
33
|
-
# code block is mandatory for the powershell provider
|
34
|
-
let(:code) { "" }
|
35
|
-
|
36
21
|
let(:events) { Chef::EventDispatch::Dispatcher.new }
|
37
22
|
|
38
|
-
let(:run_context) {
|
23
|
+
let(:run_context) { Chef::RunContext.new(Chef::Node.new, {}, events) }
|
39
24
|
|
40
25
|
let(:new_resource) do
|
41
|
-
|
42
|
-
new_resource.code code
|
43
|
-
new_resource
|
44
|
-
end
|
45
|
-
|
46
|
-
def set_user_defined_flag
|
47
|
-
new_resource.flags "-ExecutionPolicy RemoteSigned"
|
48
|
-
provider
|
26
|
+
Chef::Resource::PowershellScript.new("run some powershell code", run_context)
|
49
27
|
end
|
50
28
|
|
51
29
|
let(:provider) do
|
@@ -54,32 +32,12 @@ describe Chef::Provider::PowershellScript, "action_run" do
|
|
54
32
|
|
55
33
|
context "when setting interpreter flags" do
|
56
34
|
before(:each) do
|
57
|
-
allow(provider).to receive(:
|
58
|
-
os_info_double = double("os_info")
|
59
|
-
allow(provider.run_context.node["kernel"]).to receive(:[]).with("os_info").and_return(os_info_double)
|
60
|
-
allow(os_info_double).to receive(:[]).with("system_directory").and_return("C:\\Windows\\system32")
|
35
|
+
allow(provider).to receive(:basepath).and_return("C:\\Windows\\system32")
|
61
36
|
end
|
62
37
|
|
63
38
|
it "sets the -File flag as the last flag" do
|
64
39
|
flags = provider.command.split(" ").keep_if { |flag| flag =~ /^-/ }
|
65
40
|
expect(flags.pop).to eq("-File")
|
66
41
|
end
|
67
|
-
|
68
|
-
let(:execution_policy_flag) do
|
69
|
-
provider_flags = provider.flags.split(" ")
|
70
|
-
# Last occurance of "executionpolicy"
|
71
|
-
execution_policy_index = provider_flags.map(&:downcase).rindex("-executionpolicy")
|
72
|
-
|
73
|
-
execution_policy_index ? provider_flags[execution_policy_index + 1] : nil
|
74
|
-
end
|
75
|
-
|
76
|
-
it "sets default -ExecutionPolicy flag to 'Bypass'" do
|
77
|
-
expect(execution_policy_flag).to eq("Bypass")
|
78
|
-
end
|
79
|
-
|
80
|
-
it "sets user defined -ExecutionPolicy flag to 'RemoteSigned'" do
|
81
|
-
set_user_defined_flag
|
82
|
-
expect(execution_policy_flag).to eq("RemoteSigned")
|
83
|
-
end
|
84
42
|
end
|
85
43
|
end
|