chef-cli 5.6.23 → 6.1.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +20 -12
- data/Rakefile +13 -17
- data/bin/chef-cli +1 -1
- data/chef-cli.gemspec +6 -4
- data/lib/chef-cli/authenticated_http.rb +1 -1
- data/lib/chef-cli/builtin_commands.rb +7 -6
- data/lib/chef-cli/chef_runner.rb +1 -1
- data/lib/chef-cli/chef_server_api_multi.rb +1 -1
- data/lib/chef-cli/cli.rb +1 -1
- data/lib/chef-cli/command/base.rb +1 -1
- data/lib/chef-cli/command/clean_policy_cookbooks.rb +1 -1
- data/lib/chef-cli/command/clean_policy_revisions.rb +1 -1
- data/lib/chef-cli/command/delete_policy.rb +3 -3
- data/lib/chef-cli/command/delete_policy_group.rb +3 -3
- data/lib/chef-cli/command/describe_cookbook.rb +1 -1
- data/lib/chef-cli/command/diff.rb +5 -5
- data/lib/chef-cli/command/env.rb +38 -13
- data/lib/chef-cli/command/exec.rb +3 -2
- data/lib/chef-cli/command/export.rb +1 -1
- data/lib/chef-cli/command/gem.rb +2 -2
- data/lib/chef-cli/command/generate.rb +1 -1
- data/lib/chef-cli/command/generator_commands/attribute.rb +1 -1
- data/lib/chef-cli/command/generator_commands/base.rb +1 -1
- data/lib/chef-cli/command/generator_commands/chef_exts/generator_desc_resource.rb +1 -1
- data/lib/chef-cli/command/generator_commands/chef_exts/quieter_doc_formatter.rb +1 -1
- data/lib/chef-cli/command/generator_commands/chef_exts/recipe_dsl_ext.rb +1 -1
- data/lib/chef-cli/command/generator_commands/cookbook.rb +1 -1
- data/lib/chef-cli/command/generator_commands/cookbook_code_file.rb +1 -1
- data/lib/chef-cli/command/generator_commands/cookbook_file.rb +1 -1
- data/lib/chef-cli/command/generator_commands/generator_generator.rb +1 -1
- data/lib/chef-cli/command/generator_commands/helpers.rb +1 -1
- data/lib/chef-cli/command/generator_commands/input.rb +1 -1
- data/lib/chef-cli/command/generator_commands/policyfile.rb +1 -1
- data/lib/chef-cli/command/generator_commands/profile.rb +1 -1
- data/lib/chef-cli/command/generator_commands/recipe.rb +1 -1
- data/lib/chef-cli/command/generator_commands/repo.rb +1 -1
- data/lib/chef-cli/command/generator_commands/resource.rb +1 -1
- data/lib/chef-cli/command/generator_commands/template.rb +1 -1
- data/lib/chef-cli/command/generator_commands/waiver.rb +1 -1
- data/lib/chef-cli/command/generator_commands.rb +1 -1
- data/lib/chef-cli/command/install.rb +1 -1
- data/lib/chef-cli/command/license.rb +111 -0
- data/lib/chef-cli/command/push.rb +5 -5
- data/lib/chef-cli/command/push_archive.rb +1 -1
- data/lib/chef-cli/command/shell_init.rb +7 -2
- data/lib/chef-cli/command/show_policy.rb +7 -7
- data/lib/chef-cli/command/undelete.rb +3 -3
- data/lib/chef-cli/command/update.rb +1 -1
- data/lib/chef-cli/commands_map.rb +1 -1
- data/lib/chef-cli/completions/bash.sh.erb +1 -1
- data/lib/chef-cli/completions/chef.fish.erb +1 -1
- data/lib/chef-cli/completions/zsh.zsh.erb +1 -1
- data/lib/chef-cli/configurable.rb +1 -1
- data/lib/chef-cli/cookbook_metadata.rb +1 -1
- data/lib/chef-cli/cookbook_omnifetch.rb +3 -3
- data/lib/chef-cli/cookbook_profiler/git.rb +1 -1
- data/lib/chef-cli/cookbook_profiler/identifiers.rb +1 -1
- data/lib/chef-cli/cookbook_profiler/null_scm.rb +1 -1
- data/lib/chef-cli/dist.rb +6 -0
- data/lib/chef-cli/exceptions.rb +1 -1
- data/lib/chef-cli/generator.rb +1 -1
- data/lib/chef-cli/helpers.rb +100 -5
- data/lib/chef-cli/licensing/base.rb +42 -0
- data/lib/chef-cli/licensing/config.rb +26 -0
- data/lib/chef-cli/pager.rb +1 -1
- data/lib/chef-cli/policyfile/artifactory_cookbook_source.rb +1 -1
- data/lib/chef-cli/policyfile/attribute_merge_checker.rb +1 -1
- data/lib/chef-cli/policyfile/chef_repo_cookbook_source.rb +1 -1
- data/lib/chef-cli/policyfile/chef_server_cookbook_source.rb +1 -1
- data/lib/chef-cli/policyfile/chef_server_lock_fetcher.rb +1 -1
- data/lib/chef-cli/policyfile/community_cookbook_source.rb +1 -1
- data/lib/chef-cli/policyfile/comparison_base.rb +1 -1
- data/lib/chef-cli/policyfile/cookbook_location_specification.rb +3 -2
- data/lib/chef-cli/policyfile/cookbook_locks.rb +1 -1
- data/lib/chef-cli/policyfile/cookbook_sources.rb +1 -1
- data/lib/chef-cli/policyfile/delivery_supermarket_source.rb +1 -1
- data/lib/chef-cli/policyfile/differ.rb +1 -1
- data/lib/chef-cli/policyfile/dsl.rb +7 -5
- data/lib/chef-cli/policyfile/git_lock_fetcher.rb +2 -2
- data/lib/chef-cli/policyfile/included_policies_cookbook_source.rb +1 -1
- data/lib/chef-cli/policyfile/lister.rb +1 -1
- data/lib/chef-cli/policyfile/local_lock_fetcher.rb +1 -1
- data/lib/chef-cli/policyfile/lock_applier.rb +1 -1
- data/lib/chef-cli/policyfile/lock_fetcher_mixin.rb +1 -1
- data/lib/chef-cli/policyfile/null_cookbook_source.rb +1 -1
- data/lib/chef-cli/policyfile/policyfile_location_specification.rb +1 -1
- data/lib/chef-cli/policyfile/read_cookbook_for_compat_mode_upload.rb +1 -1
- data/lib/chef-cli/policyfile/remote_lock_fetcher.rb +1 -1
- data/lib/chef-cli/policyfile/reports/install.rb +1 -1
- data/lib/chef-cli/policyfile/reports/table_printer.rb +1 -1
- data/lib/chef-cli/policyfile/reports/upload.rb +1 -1
- data/lib/chef-cli/policyfile/solution_dependencies.rb +1 -1
- data/lib/chef-cli/policyfile/source_uri.rb +1 -1
- data/lib/chef-cli/policyfile/storage_config.rb +1 -1
- data/lib/chef-cli/policyfile/undo_record.rb +1 -1
- data/lib/chef-cli/policyfile/undo_stack.rb +1 -1
- data/lib/chef-cli/policyfile/uploader.rb +1 -1
- data/lib/chef-cli/policyfile_compiler.rb +5 -2
- data/lib/chef-cli/policyfile_lock.rb +1 -1
- data/lib/chef-cli/policyfile_services/clean_policies.rb +1 -1
- data/lib/chef-cli/policyfile_services/clean_policy_cookbooks.rb +1 -1
- data/lib/chef-cli/policyfile_services/export_repo.rb +1 -1
- data/lib/chef-cli/policyfile_services/install.rb +1 -1
- data/lib/chef-cli/policyfile_services/push.rb +1 -1
- data/lib/chef-cli/policyfile_services/push_archive.rb +1 -1
- data/lib/chef-cli/policyfile_services/rm_policy.rb +1 -1
- data/lib/chef-cli/policyfile_services/rm_policy_group.rb +1 -1
- data/lib/chef-cli/policyfile_services/show_policy.rb +1 -1
- data/lib/chef-cli/policyfile_services/undelete.rb +1 -1
- data/lib/chef-cli/policyfile_services/update_attributes.rb +1 -1
- data/lib/chef-cli/service_exception_inspectors/base.rb +1 -1
- data/lib/chef-cli/service_exception_inspectors/http.rb +1 -1
- data/lib/chef-cli/service_exception_inspectors.rb +1 -1
- data/lib/chef-cli/service_exceptions.rb +1 -1
- data/lib/chef-cli/shell_out.rb +1 -1
- data/lib/chef-cli/skeletons/code_generator/files/default/cookbook_readmes/README.md +3 -0
- data/lib/chef-cli/skeletons/code_generator/recipes/cookbook.rb +5 -5
- data/lib/chef-cli/skeletons/code_generator/recipes/profile.rb +1 -1
- data/lib/chef-cli/ui.rb +1 -1
- data/lib/chef-cli/version.rb +2 -2
- data/lib/chef-cli.rb +1 -1
- data/lib/kitchen/provisioner/chef_zero_capture.rb +2 -2
- data/lib/kitchen/provisioner/policyfile_zero.rb +2 -2
- data/spec/shared/fixture_cookbook_checksums.rb +1 -1
- data/spec/shared/setup_git_committer_config.rb +1 -1
- data/spec/shared/setup_git_cookbooks.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/test_helpers.rb +1 -1
- data/spec/unit/chef_runner_spec.rb +1 -1
- data/spec/unit/chef_server_api_multi_spec.rb +1 -1
- data/spec/unit/cli_spec.rb +3 -1
- data/spec/unit/command/base_spec.rb +1 -1
- data/spec/unit/command/clean_policy_cookbooks_spec.rb +1 -1
- data/spec/unit/command/clean_policy_revisions_spec.rb +1 -1
- data/spec/unit/command/delete_policy_group_spec.rb +1 -1
- data/spec/unit/command/delete_policy_spec.rb +1 -1
- data/spec/unit/command/diff_spec.rb +1 -1
- data/spec/unit/command/env_spec.rb +132 -2
- data/spec/unit/command/exec_spec.rb +2 -1
- data/spec/unit/command/export_spec.rb +1 -1
- data/spec/unit/command/generate_spec.rb +1 -1
- data/spec/unit/command/generator_commands/attribute_spec.rb +1 -1
- data/spec/unit/command/generator_commands/base_spec.rb +1 -1
- data/spec/unit/command/generator_commands/chef_exts/generator_desc_resource_spec.rb +1 -1
- data/spec/unit/command/generator_commands/chef_exts/recipe_dsl_ext_spec.rb +1 -1
- data/spec/unit/command/generator_commands/cookbook_file_spec.rb +1 -1
- data/spec/unit/command/generator_commands/cookbook_spec.rb +1 -1
- data/spec/unit/command/generator_commands/generator_generator_spec.rb +1 -1
- data/spec/unit/command/generator_commands/helpers_spec.rb +1 -1
- data/spec/unit/command/generator_commands/input_spec.rb +1 -1
- data/spec/unit/command/generator_commands/policyfile_spec.rb +1 -1
- data/spec/unit/command/generator_commands/profile_spec.rb +1 -1
- data/spec/unit/command/generator_commands/recipe_spec.rb +1 -1
- data/spec/unit/command/generator_commands/repo_spec.rb +1 -1
- data/spec/unit/command/generator_commands/resource_spec.rb +1 -1
- data/spec/unit/command/generator_commands/template_spec.rb +1 -1
- data/spec/unit/command/generator_commands/waiver_spec.rb +1 -1
- data/spec/unit/command/install_spec.rb +1 -1
- data/spec/unit/command/license_spec.rb +162 -0
- data/spec/unit/command/push_archive_spec.rb +1 -1
- data/spec/unit/command/push_spec.rb +1 -1
- data/spec/unit/command/shell_init_spec.rb +99 -1
- data/spec/unit/command/show_policy_spec.rb +1 -1
- data/spec/unit/command/undelete_spec.rb +1 -1
- data/spec/unit/command/update_spec.rb +1 -1
- data/spec/unit/commands_map_spec.rb +1 -1
- data/spec/unit/configurable_spec.rb +1 -1
- data/spec/unit/cookbook_metadata_spec.rb +1 -1
- data/spec/unit/cookbook_omnifetch.rb +1 -1
- data/spec/unit/cookbook_profiler/git_spec.rb +1 -1
- data/spec/unit/cookbook_profiler/identifiers_spec.rb +1 -1
- data/spec/unit/generator_spec.rb +1 -1
- data/spec/unit/helpers_spec.rb +35 -2
- data/spec/unit/kitchen/provisioner/chef_zero_capture_spec.rb +1 -1
- data/spec/unit/pager_spec.rb +1 -1
- data/spec/unit/policyfile/artifactory_cookbook_source_spec.rb +1 -1
- data/spec/unit/policyfile/attribute_merge_checker_spec.rb +1 -1
- data/spec/unit/policyfile/chef_repo_cookbook_source_spec.rb +1 -1
- data/spec/unit/policyfile/chef_server_cookbook_source_spec.rb +1 -1
- data/spec/unit/policyfile/chef_server_lock_fetcher_spec.rb +1 -1
- data/spec/unit/policyfile/community_cookbook_source_spec.rb +1 -1
- data/spec/unit/policyfile/comparison_base_spec.rb +1 -1
- data/spec/unit/policyfile/cookbook_location_specification_spec.rb +1 -1
- data/spec/unit/policyfile/cookbook_locks_spec.rb +1 -1
- data/spec/unit/policyfile/delivery_supermarket_source_spec.rb +1 -1
- data/spec/unit/policyfile/differ_spec.rb +7 -7
- data/spec/unit/policyfile/git_lock_fetcher_spec.rb +1 -1
- data/spec/unit/policyfile/included_policies_cookbook_source_spec.rb +1 -1
- data/spec/unit/policyfile/lister_spec.rb +1 -1
- data/spec/unit/policyfile/local_lock_fetcher_spec.rb +1 -1
- data/spec/unit/policyfile/lock_applier_spec.rb +1 -1
- data/spec/unit/policyfile/lock_fetcher_mixin_spec.rb +1 -1
- data/spec/unit/policyfile/null_cookbook_source_spec.rb +1 -1
- data/spec/unit/policyfile/read_cookbook_for_compat_mode_upload_spec.rb +1 -1
- data/spec/unit/policyfile/remote_lock_fetcher_spec.rb +1 -1
- data/spec/unit/policyfile/reports/install_spec.rb +1 -1
- data/spec/unit/policyfile/reports/upload_spec.rb +1 -1
- data/spec/unit/policyfile/solution_dependencies_spec.rb +1 -1
- data/spec/unit/policyfile/source_uri_spec.rb +1 -1
- data/spec/unit/policyfile/storage_config_spec.rb +1 -1
- data/spec/unit/policyfile/undo_record_spec.rb +1 -1
- data/spec/unit/policyfile/undo_stack_spec.rb +1 -1
- data/spec/unit/policyfile/uploader_spec.rb +1 -1
- data/spec/unit/policyfile_demands_spec.rb +3 -1
- data/spec/unit/policyfile_evaluation_spec.rb +1 -1
- data/spec/unit/policyfile_includes_dsl_spec.rb +1 -1
- data/spec/unit/policyfile_includes_spec.rb +1 -1
- data/spec/unit/policyfile_install_with_includes_spec.rb +1 -1
- data/spec/unit/policyfile_lock_build_spec.rb +1 -1
- data/spec/unit/policyfile_lock_install_spec.rb +1 -1
- data/spec/unit/policyfile_lock_serialization_spec.rb +1 -1
- data/spec/unit/policyfile_lock_validation_spec.rb +1 -1
- data/spec/unit/policyfile_services/clean_policies_spec.rb +3 -3
- data/spec/unit/policyfile_services/clean_policy_cookbooks_spec.rb +1 -1
- data/spec/unit/policyfile_services/export_repo_spec.rb +1 -1
- data/spec/unit/policyfile_services/install_spec.rb +1 -1
- data/spec/unit/policyfile_services/push_archive_spec.rb +1 -1
- data/spec/unit/policyfile_services/push_spec.rb +1 -1
- data/spec/unit/policyfile_services/rm_policy_group_spec.rb +1 -1
- data/spec/unit/policyfile_services/rm_policy_spec.rb +1 -1
- data/spec/unit/policyfile_services/show_policy_spec.rb +1 -1
- data/spec/unit/policyfile_services/undelete_spec.rb +1 -1
- data/spec/unit/policyfile_services/update_attributes_spec.rb +1 -1
- data/spec/unit/policyfile_services/update_spec.rb +1 -1
- data/spec/unit/service_exception_inspectors/base_spec.rb +1 -1
- data/spec/unit/service_exception_inspectors/http_spec.rb +1 -1
- data/spec/unit/shell_out_spec.rb +1 -1
- metadata +53 -26
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#
|
|
2
|
-
#
|
|
2
|
+
# Copyright (c) 2019-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
|
|
3
3
|
# License:: Apache License, Version 2.0
|
|
4
4
|
#
|
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
require "spec_helper"
|
|
19
19
|
autoload :YAML, "yaml"
|
|
20
20
|
require "chef-cli/command/env"
|
|
21
|
-
|
|
22
21
|
describe ChefCLI::Command::Env do
|
|
23
22
|
let(:ui) { TestHelpers::TestUI.new }
|
|
24
23
|
let(:command_instance) { ChefCLI::Command::Env.new }
|
|
@@ -35,9 +34,11 @@ describe ChefCLI::Command::Env do
|
|
|
35
34
|
|
|
36
35
|
describe "when running from within an omnibus install" do
|
|
37
36
|
before do
|
|
37
|
+
allow(command_instance).to receive(:habitat_install?).and_return false
|
|
38
38
|
allow(command_instance).to receive(:omnibus_install?).and_return true
|
|
39
39
|
allow(command_instance).to receive(:omnibus_embedded_bin_dir).and_return(omnibus_embedded_bin_dir)
|
|
40
40
|
allow(command_instance).to receive(:omnibus_bin_dir).and_return(omnibus_bin_dir)
|
|
41
|
+
allow(command_instance).to receive(:get_product_info).and_return(ChefCLI::Dist::PRODUCT)
|
|
41
42
|
command_instance.ui = ui
|
|
42
43
|
end
|
|
43
44
|
|
|
@@ -57,6 +58,7 @@ describe ChefCLI::Command::Env do
|
|
|
57
58
|
end
|
|
58
59
|
describe "when running locally" do
|
|
59
60
|
before do
|
|
61
|
+
allow(command_instance).to receive(:habitat_install?).and_return false
|
|
60
62
|
allow(command_instance).to receive(:omnibus_install?).and_return false
|
|
61
63
|
command_instance.ui = ui
|
|
62
64
|
end
|
|
@@ -79,6 +81,134 @@ describe ChefCLI::Command::Env do
|
|
|
79
81
|
end
|
|
80
82
|
end
|
|
81
83
|
end
|
|
84
|
+
|
|
85
|
+
describe "when running in a Chef-cli Habitat Standalone package" do
|
|
86
|
+
let(:standalone_pkg_base) { "/hab/pkgs/chef/chef-cli" }
|
|
87
|
+
let(:standalone_pkg_version) { "1.0.0" }
|
|
88
|
+
let(:standalone_pkg_build) { "20240210120000" }
|
|
89
|
+
let(:standalone_pkg_path) { "#{standalone_pkg_base}/#{standalone_pkg_version}/#{standalone_pkg_build}" }
|
|
90
|
+
|
|
91
|
+
let(:ruby_version) { "3.1.0" }
|
|
92
|
+
let(:ruby_base) { "/hab/pkgs/core/ruby/#{ruby_version}/20240101000000/lib/ruby/gems" }
|
|
93
|
+
let(:cli_gem_home) { "/hab/pkgs/chef/chef-cli/#{standalone_pkg_version}/20240210121000/vendor/bundle/ruby/#{ruby_version}" }
|
|
94
|
+
|
|
95
|
+
before do
|
|
96
|
+
allow(command_instance).to receive(:habitat_install?).and_return(true)
|
|
97
|
+
allow(command_instance).to receive(:habitat_standalone?).and_return(true)
|
|
98
|
+
allow(command_instance).to receive(:habitat_chef_dke?).and_return(false)
|
|
99
|
+
allow(command_instance).to receive(:omnibus_install?).and_return(false)
|
|
100
|
+
allow(command_instance).to receive(:get_product_info).and_return(ChefCLI::Dist::CHEF_CLI_PACKAGE)
|
|
101
|
+
|
|
102
|
+
allow(command_instance).to receive(:get_pkg_install_path).and_return(standalone_pkg_path)
|
|
103
|
+
|
|
104
|
+
allow(command_instance).to receive(:habitat_env).and_return({
|
|
105
|
+
"GEM_ROOT" => ruby_base,
|
|
106
|
+
"GEM_HOME" => cli_gem_home,
|
|
107
|
+
"GEM_PATH" => cli_gem_home,
|
|
108
|
+
"PATH" => "#{standalone_pkg_path}/bin:/usr/local/bin:/usr/bin"
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
command_instance.ui = ui
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
describe "and the env command is run" do
|
|
115
|
+
let(:yaml) { YAML.load(ui.output) }
|
|
116
|
+
|
|
117
|
+
before :each do
|
|
118
|
+
run_command
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
it "should include correct chef-cli hab pkg name" do
|
|
122
|
+
expect(yaml).to have_key(ChefCLI::Dist::CHEF_CLI_PACKAGE)
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
it "should include correct chef-cli hab pkg version info" do
|
|
126
|
+
expect(yaml[ChefCLI::Dist::CHEF_CLI_PACKAGE]["Version"]).to eql ChefCLI::VERSION
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
it "should include correct Habitat installation path" do
|
|
130
|
+
expect(yaml[ChefCLI::Dist::CHEF_CLI_PACKAGE]["Install Directory"]).to eql standalone_pkg_path
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
it "should include correct GEM_ROOT path" do
|
|
134
|
+
expect(yaml["Ruby"]["RubyGems"]["Gem Environment"]["GEM ROOT"]).to eql ruby_base
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
it "should include correct GEM_HOME path" do
|
|
138
|
+
expect(yaml["Ruby"]["RubyGems"]["Gem Environment"]["GEM HOME"]).to eql cli_gem_home
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
it "should include correct GEM_PATH paths" do
|
|
142
|
+
expect(yaml["Ruby"]["RubyGems"]["Gem Environment"]["GEM PATHS"]).to eql [cli_gem_home]
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
describe "when running chef-cli coming with chef-workstation Habitat package" do
|
|
148
|
+
let(:hab_pkg_base) { "/hab/pkgs/chef/chef-workstation" }
|
|
149
|
+
let(:hab_pkg_version) { "1.0.0" }
|
|
150
|
+
let(:hab_pkg_build) { "20240210120000" }
|
|
151
|
+
let(:hab_pkg_path) { "#{hab_pkg_base}/#{hab_pkg_version}/#{hab_pkg_build}" }
|
|
152
|
+
|
|
153
|
+
let(:ruby_version) { "3.1.0" }
|
|
154
|
+
let(:ruby_base) { "/hab/pkgs/core/ruby/#{ruby_version}/20240101000000/lib/ruby/gems" }
|
|
155
|
+
let(:cli_gem_home) { "/hab/pkgs/chef/chef-cli/#{hab_pkg_version}/20240210121000/vendor/bundle/ruby/#{ruby_version}" }
|
|
156
|
+
|
|
157
|
+
before do
|
|
158
|
+
# Mock all Habitat-related methods
|
|
159
|
+
allow(command_instance).to receive(:habitat_install?).and_return true
|
|
160
|
+
allow(command_instance).to receive(:habitat_chef_dke?).and_return true
|
|
161
|
+
allow(command_instance).to receive(:habitat_standalone?).and_return false
|
|
162
|
+
allow(command_instance).to receive(:omnibus_install?).and_return false
|
|
163
|
+
allow(command_instance).to receive(:get_product_info).and_return(ChefCLI::Dist::CHEF_DK_CLI_PACKAGE)
|
|
164
|
+
|
|
165
|
+
# Mock Habitat package paths
|
|
166
|
+
allow(command_instance).to receive(:get_pkg_install_path).and_return(hab_pkg_path)
|
|
167
|
+
|
|
168
|
+
# Mock habitat_env to reflect correct GEM paths
|
|
169
|
+
allow(command_instance).to receive(:habitat_env).and_return({
|
|
170
|
+
"GEM_ROOT" => ruby_base,
|
|
171
|
+
"GEM_HOME" => cli_gem_home,
|
|
172
|
+
"GEM_PATH" => cli_gem_home,
|
|
173
|
+
"PATH" => "#{hab_pkg_path}/bin:/usr/local/bin:/usr/bin"
|
|
174
|
+
})
|
|
175
|
+
|
|
176
|
+
command_instance.ui = ui
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
describe "and the env command is run" do
|
|
180
|
+
let(:yaml) { YAML.load(ui.output) }
|
|
181
|
+
|
|
182
|
+
before :each do
|
|
183
|
+
run_command
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
it "should include correct product name for chef-workstation Habitat package" do
|
|
187
|
+
expect(yaml).to have_key(ChefCLI::Dist::CHEF_DK_CLI_PACKAGE)
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
it "should include correct version" do
|
|
191
|
+
expect(yaml[ChefCLI::Dist::CHEF_DK_CLI_PACKAGE]["Version"]).to eql ChefCLI::VERSION
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
it "should include correct Habitat installation path" do
|
|
195
|
+
expect(yaml[ChefCLI::Dist::CHEF_DK_CLI_PACKAGE]["Install Directory"]).to eql hab_pkg_path
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
it "should include correct GEM_ROOT path" do
|
|
199
|
+
expect(yaml["Ruby"]["RubyGems"]["Gem Environment"]["GEM ROOT"]).to eql ruby_base
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
it "should include correct GEM_HOME path" do
|
|
203
|
+
expect(yaml["Ruby"]["RubyGems"]["Gem Environment"]["GEM HOME"]).to eql cli_gem_home
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
it "should include correct GEM_PATH paths" do
|
|
207
|
+
expect(yaml["Ruby"]["RubyGems"]["Gem Environment"]["GEM PATHS"]).to eql [cli_gem_home]
|
|
208
|
+
end
|
|
209
|
+
end
|
|
210
|
+
end
|
|
211
|
+
|
|
82
212
|
def run_command
|
|
83
213
|
command_instance.run_with_default_options(false, command_options)
|
|
84
214
|
end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#
|
|
2
|
-
#
|
|
2
|
+
# Copyright (c) 2019-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
|
|
3
3
|
# License:: Apache License, Version 2.0
|
|
4
4
|
#
|
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -57,6 +57,7 @@ describe ChefCLI::Command::Exec do
|
|
|
57
57
|
let(:ruby_path) { File.join(fixtures_path, "eg_omnibus_dir/valid/embedded/bin/ruby") }
|
|
58
58
|
|
|
59
59
|
before do
|
|
60
|
+
allow(command_instance).to receive(:habitat_install?).and_return(false)
|
|
60
61
|
allow(Gem).to receive(:ruby).and_return(ruby_path)
|
|
61
62
|
|
|
62
63
|
# Using a fake path separator to keep to prevent people from accidentally
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#
|
|
2
|
-
# Copyright:: Copyright (c)
|
|
2
|
+
# Copyright:: Copyright (c) 2019-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
|
|
3
3
|
# License:: Apache License, Version 2.0
|
|
4
4
|
#
|
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#
|
|
2
|
-
# Copyright:: Copyright (c)
|
|
2
|
+
# Copyright:: Copyright (c) 2019-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
|
|
3
3
|
# License:: Apache License, Version 2.0
|
|
4
4
|
#
|
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright:: Copyright (c) 2019-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
|
|
3
|
+
# License:: Apache License, Version 2.0
|
|
4
|
+
#
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
#
|
|
17
|
+
|
|
18
|
+
require "spec_helper"
|
|
19
|
+
require "chef-cli/command/license"
|
|
20
|
+
require "shared/command_with_ui_object"
|
|
21
|
+
require "chef-cli/licensing/base"
|
|
22
|
+
|
|
23
|
+
describe ChefCLI::Command::License do
|
|
24
|
+
it_behaves_like "a command with a UI object"
|
|
25
|
+
|
|
26
|
+
let(:params) { [] }
|
|
27
|
+
let(:ui) { TestHelpers::TestUI.new }
|
|
28
|
+
|
|
29
|
+
before do
|
|
30
|
+
# Disable the access of local licenses
|
|
31
|
+
allow_any_instance_of(ChefLicensing::LicenseKeyFetcher).to receive(:fetch_license_key_from_arg).and_return([])
|
|
32
|
+
allow_any_instance_of(ChefLicensing::LicenseKeyFetcher).to receive(:fetch_license_key_from_env).and_return([])
|
|
33
|
+
allow_any_instance_of(ChefLicensing::LicensingService::Local).to receive(:detected?).and_return(false)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
let(:command) do
|
|
37
|
+
c = described_class.new
|
|
38
|
+
c.validate_params!(params)
|
|
39
|
+
c.ui = ui
|
|
40
|
+
c
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it "disables debug by default" do
|
|
44
|
+
expect(command.debug?).to be(false)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
context "invalid parameters passed" do
|
|
48
|
+
let(:multiple_params) { %w{add list} }
|
|
49
|
+
let(:invalid_command) { %w{not_a_subcommand} }
|
|
50
|
+
|
|
51
|
+
it "should fail with errors when multiple subcommands passed" do
|
|
52
|
+
expect(command.run(multiple_params)).to eq(1)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it "should fail for invalid argument" do
|
|
56
|
+
expect(command.run(invalid_command)).to eq(1)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
context "license command" do
|
|
61
|
+
context "when pre-accepted license exists" do
|
|
62
|
+
let(:license_keys) { %w{tsmc-abcd} }
|
|
63
|
+
|
|
64
|
+
before(:each) do
|
|
65
|
+
allow(ChefLicensing).to receive(:fetch_and_persist).and_return(license_keys)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it "should be successful" do
|
|
69
|
+
expect { command.run(params) }.not_to raise_exception
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it "should return the correct license key" do
|
|
73
|
+
expect(command.run(params)).to eq(license_keys)
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
context "when no licenses are accepted previously" do
|
|
78
|
+
let(:new_key) { ["tsmc-123456789"] }
|
|
79
|
+
before(:each) do
|
|
80
|
+
ChefLicensing.configure do |config|
|
|
81
|
+
config.license_server_url = "https://license.test"
|
|
82
|
+
config.chef_product_name = "chef"
|
|
83
|
+
config.chef_entitlement_id = "chef-entitled-id"
|
|
84
|
+
config.chef_executable_name = "chef"
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# Disable the active license check
|
|
88
|
+
allow_any_instance_of(ChefLicensing::LicenseKeyFetcher).to receive(:licenses_active?).and_return(false)
|
|
89
|
+
# Disable the UI engine
|
|
90
|
+
allow_any_instance_of(ChefLicensing::LicenseKeyFetcher).to receive(:append_extra_info_to_tui_engine)
|
|
91
|
+
# Disable the API call to fetch the license type
|
|
92
|
+
allow_any_instance_of(ChefLicensing::LicenseKeyFetcher).to receive(:get_license_type).and_return("free")
|
|
93
|
+
# Disable the overwriting to the license.yml file
|
|
94
|
+
allow_any_instance_of(ChefLicensing::LicenseKeyFetcher::File).to receive(:persist)
|
|
95
|
+
|
|
96
|
+
# Mocks the user prompt to enter the license
|
|
97
|
+
allow_any_instance_of(ChefLicensing::LicenseKeyFetcher::Prompt).to receive(:fetch).and_return(new_key)
|
|
98
|
+
allow(ChefLicensing).to receive(:fetch_and_persist).and_return(new_key)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
it "should create and stores the new license" do
|
|
102
|
+
expect { command.run(params) }.not_to raise_exception
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
it "should be same as the user entered license" do
|
|
106
|
+
expect(command.run(params)).to include(new_key.first)
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
context "chef license list command" do
|
|
112
|
+
let(:params) { %w{list} }
|
|
113
|
+
let(:license_key) { "tsmn-123123" }
|
|
114
|
+
|
|
115
|
+
before do
|
|
116
|
+
command.ui = ui
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
context "when no licenses are accepted" do
|
|
120
|
+
before do
|
|
121
|
+
allow_any_instance_of(ChefLicensing::ListLicenseKeys).to receive(:fetch_license_keys).and_return([])
|
|
122
|
+
allow_any_instance_of(ChefLicensing::ListLicenseKeys).to receive(:fetch_licenses_metadata).and_return([])
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
it "should return the correct error message" do
|
|
126
|
+
expect(command.run(params)).to eq([])
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
context "when there is a valid license" do
|
|
131
|
+
before do
|
|
132
|
+
allow(ChefLicensing).to receive(:list_license_keys_info).and_return(license_key)
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
it "should print the license details" do
|
|
136
|
+
expect(command.run(params)).to eq(license_key)
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
context "chef license add command" do
|
|
142
|
+
let(:params) { %w{add} }
|
|
143
|
+
let(:license_key) { ["tsmn-123123"] }
|
|
144
|
+
|
|
145
|
+
before do
|
|
146
|
+
# Disable the API call to fetch the license type
|
|
147
|
+
allow_any_instance_of(ChefLicensing::LicenseKeyFetcher).to receive(:get_license_type).and_return("free")
|
|
148
|
+
# Disable the overwriting to the license.yml file
|
|
149
|
+
allow_any_instance_of(ChefLicensing::LicenseKeyFetcher::File).to receive(:persist)
|
|
150
|
+
# Mocks the user prompt to enter the license
|
|
151
|
+
allow_any_instance_of(ChefLicensing::LicenseKeyFetcher::Prompt).to receive(:fetch).and_return(license_key)
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
it "should not raise any errors" do
|
|
155
|
+
expect { command.run(params) }.not_to raise_exception
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
it "should create and store the new license" do
|
|
159
|
+
expect(command.run(params)).to include(license_key.first)
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
end
|