hammer_cli_katello 1.5.0 → 1.6.0
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/lib/hammer_cli_katello/acs.rb +82 -0
- data/lib/hammer_cli_katello/activation_key.rb +8 -2
- data/lib/hammer_cli_katello/content_export.rb +39 -0
- data/lib/hammer_cli_katello/content_export_helper.rb +64 -6
- data/lib/hammer_cli_katello/host_subscription.rb +32 -0
- data/lib/hammer_cli_katello/organization.rb +4 -0
- data/lib/hammer_cli_katello/repository.rb +1 -1
- data/lib/hammer_cli_katello/simple_content_access.rb +10 -0
- data/lib/hammer_cli_katello/version.rb +1 -1
- data/lib/hammer_cli_katello.rb +5 -0
- data/test/data/2.5/foreman_api.json +1 -0
- data/test/data/3.0/foreman_api.json +1 -0
- data/test/data/3.10/foreman_api.json +1 -0
- data/test/data/3.11/foreman_api.json +1 -0
- data/test/data/3.12/foreman_api.json +1 -0
- data/test/data/3.13/foreman_api.json +1 -0
- data/test/data/3.14/foreman_api.json +1 -0
- data/test/data/3.15/foreman_api.json +1 -0
- data/test/data/3.16/foreman_api.json +1 -0
- data/test/data/3.17/foreman_api.json +1 -0
- data/test/data/3.18/foreman_api.json +1 -0
- data/test/data/3.19/foreman_api.json +1 -0
- data/test/data/3.2/foreman_api.json +1 -0
- data/test/data/3.4/foreman_api.json +1 -0
- data/test/data/3.5/foreman_api.json +1 -0
- data/test/data/3.6/foreman_api.json +1 -0
- data/test/data/3.7/foreman_api.json +1 -0
- data/test/data/3.8/foreman_api.json +1 -0
- data/test/data/3.9/foreman_api.json +1 -0
- data/test/data/4.0/foreman_api.json +1 -0
- data/test/data/4.1/foreman_api.json +1 -0
- data/test/data/4.3/foreman_api.json +1 -0
- data/test/data/4.4/foreman_api.json +1 -0
- data/test/data/4.5/foreman_api.json +1 -0
- data/test/data/4.6/foreman_api.json +1 -0
- data/test/data/Readme.md +5 -0
- data/test/functional/acs/create_test.rb +27 -0
- data/test/functional/acs/delete_test.rb +13 -0
- data/test/functional/acs/info_test.rb +94 -0
- data/test/functional/acs/list_test.rb +62 -0
- data/test/functional/acs/update_test.rb +23 -0
- data/test/functional/activation_key/add_host_collection_test.rb +62 -0
- data/test/functional/activation_key/content_override_test.rb +92 -0
- data/test/functional/activation_key/create_test.rb +33 -0
- data/test/functional/activation_key/data/activation_key.json +17 -0
- data/test/functional/activation_key/info_test.rb +29 -0
- data/test/functional/activation_key/list_test.rb +68 -0
- data/test/functional/activation_key/product_content_test.rb +23 -0
- data/test/functional/activation_key/remove_host_collection_test.rb +62 -0
- data/test/functional/activation_key/subscriptions_test.rb +74 -0
- data/test/functional/activation_key/update_test.rb +26 -0
- data/test/functional/apipie_helper_test.rb +31 -0
- data/test/functional/capsule/capsule_helpers.rb +13 -0
- data/test/functional/capsule/content/add_lifecycle_environment_test.rb +40 -0
- data/test/functional/capsule/content/cancel_synchronization_test.rb +42 -0
- data/test/functional/capsule/content/capsule_content_helpers.rb +24 -0
- data/test/functional/capsule/content/data/library_env.json +47 -0
- data/test/functional/capsule/content/data/sync_status.json +6 -0
- data/test/functional/capsule/content/data/sync_tasks.json +62 -0
- data/test/functional/capsule/content/info_test.rb +61 -0
- data/test/functional/capsule/content/lifecycle_environments_test.rb +19 -0
- data/test/functional/capsule/content/remove_lifecycle_environment_test.rb +40 -0
- data/test/functional/capsule/content/synchronization_status_test.rb +107 -0
- data/test/functional/capsule/info_test.rb +25 -0
- data/test/functional/capsule/list_test.rb +24 -0
- data/test/functional/content_credentials/create_test.rb +32 -0
- data/test/functional/content_credentials/data/test_cert.json +43 -0
- data/test/functional/content_credentials/info_test.rb +50 -0
- data/test/functional/content_credentials/list_test.rb +66 -0
- data/test/functional/content_export/complete/library_test.rb +155 -0
- data/test/functional/content_export/complete/repository_test.rb +226 -0
- data/test/functional/content_export/complete/version_test.rb +297 -0
- data/test/functional/content_export/content_export_helpers.rb +33 -0
- data/test/functional/content_export/generate_listing_test.rb +62 -0
- data/test/functional/content_export/generate_metadata_test.rb +64 -0
- data/test/functional/content_export/incremental/library_test.rb +172 -0
- data/test/functional/content_export/incremental/repository_test.rb +212 -0
- data/test/functional/content_export/incremental/version_test.rb +268 -0
- data/test/functional/content_export/list_test.rb +64 -0
- data/test/functional/content_import/library_test.rb +85 -0
- data/test/functional/content_import/list_test.rb +65 -0
- data/test/functional/content_import/metadata.json +1 -0
- data/test/functional/content_import/version_test.rb +85 -0
- data/test/functional/content_units/info_test.rb +29 -0
- data/test/functional/content_units/list_test.rb +106 -0
- data/test/functional/content_view/add_content_view_version_test.rb +88 -0
- data/test/functional/content_view/add_repository_test.rb +21 -0
- data/test/functional/content_view/component/add_test.rb +177 -0
- data/test/functional/content_view/component/list_test.rb +55 -0
- data/test/functional/content_view/component/remove_test.rb +107 -0
- data/test/functional/content_view/component/update_test.rb +134 -0
- data/test/functional/content_view/content_view_helpers.rb +20 -0
- data/test/functional/content_view/copy_test.rb +53 -0
- data/test/functional/content_view/create_test.rb +34 -0
- data/test/functional/content_view/delete_test.rb +62 -0
- data/test/functional/content_view/filter/create_test.rb +57 -0
- data/test/functional/content_view/filter/delete_test.rb +90 -0
- data/test/functional/content_view/filter/info_test.rb +89 -0
- data/test/functional/content_view/filter/list_test.rb +98 -0
- data/test/functional/content_view/filter/update_test.rb +91 -0
- data/test/functional/content_view/list_test.rb +68 -0
- data/test/functional/content_view/publish_test.rb +24 -0
- data/test/functional/content_view/purge_test.rb +97 -0
- data/test/functional/content_view/remove_content_view_version_test.rb +88 -0
- data/test/functional/content_view/remove_test.rb +79 -0
- data/test/functional/content_view/update_test.rb +53 -0
- data/test/functional/content_view/version/incremental_update_test.rb +108 -0
- data/test/functional/content_view/version/list_test.rb +44 -0
- data/test/functional/content_view/version/promote_test.rb +75 -0
- data/test/functional/content_view/version/republish_repositories_test.rb +34 -0
- data/test/functional/content_view/version/update_test.rb +48 -0
- data/test/functional/erratum/erratum_helpers.rb +91 -0
- data/test/functional/erratum/info_test.rb +29 -0
- data/test/functional/erratum/list_test.rb +108 -0
- data/test/functional/file/file_helpers.rb +13 -0
- data/test/functional/file/info_test.rb +162 -0
- data/test/functional/file/list_test.rb +112 -0
- data/test/functional/filter_rule/create_test.rb +99 -0
- data/test/functional/filter_rule/delete_test.rb +104 -0
- data/test/functional/filter_rule/filter_rule_helpers.rb +12 -0
- data/test/functional/filter_rule/info_test.rb +104 -0
- data/test/functional/filter_rule/list_test.rb +91 -0
- data/test/functional/filter_rule/update_test.rb +104 -0
- data/test/functional/host/errata/apply_test.rb +45 -0
- data/test/functional/host/errata/info_test.rb +27 -0
- data/test/functional/host/errata/list_test.rb +49 -0
- data/test/functional/host/errata/recalculate_test.rb +26 -0
- data/test/functional/host/extensions/create_test.rb +95 -0
- data/test/functional/host/extensions/data/host.json +320 -0
- data/test/functional/host/extensions/data/host_list.json +117 -0
- data/test/functional/host/extensions/info_test.rb +35 -0
- data/test/functional/host/extensions/list_test.rb +21 -0
- data/test/functional/host/extensions/update_test.rb +70 -0
- data/test/functional/host/host_helpers.rb +8 -0
- data/test/functional/host/subscription/attach_test.rb +54 -0
- data/test/functional/host/subscription/auto_attach_test.rb +35 -0
- data/test/functional/host/subscription/content_override_test.rb +96 -0
- data/test/functional/host/subscription/enabled_repositories_test.rb +39 -0
- data/test/functional/host/subscription/product_content_test.rb +27 -0
- data/test/functional/host/subscription/register_test.rb +53 -0
- data/test/functional/host/subscription/remove_test.rb +52 -0
- data/test/functional/host/subscription/unregister_test.rb +37 -0
- data/test/functional/host/traces/list_test.rb +37 -0
- data/test/functional/host/traces/resolve_test.rb +31 -0
- data/test/functional/host_collection/add_host_test.rb +90 -0
- data/test/functional/host_collection/content_api_expectations.rb +35 -0
- data/test/functional/host_collection/content_install_test.rb +62 -0
- data/test/functional/host_collection/content_remove_test.rb +37 -0
- data/test/functional/host_collection/content_update_test.rb +37 -0
- data/test/functional/host_collection/copy_test.rb +64 -0
- data/test/functional/host_collection/create_test.rb +54 -0
- data/test/functional/host_collection/delete_test.rb +57 -0
- data/test/functional/host_collection/hosts_test.rb +39 -0
- data/test/functional/host_collection/info_test.rb +57 -0
- data/test/functional/host_collection/list_test.rb +63 -0
- data/test/functional/host_collection/remove_host_test.rb +90 -0
- data/test/functional/host_collection/update_test.rb +57 -0
- data/test/functional/hostgroup/create_test.rb +112 -0
- data/test/functional/hostgroup/data/hostgroup.json +50 -0
- data/test/functional/hostgroup/info_test.rb +33 -0
- data/test/functional/hostgroup/update_test.rb +120 -0
- data/test/functional/lifecycle_environment/create_test.rb +14 -0
- data/test/functional/lifecycle_environment/lifecycle_environment_helpers.rb +18 -0
- data/test/functional/lifecycle_environment/list_test.rb +38 -0
- data/test/functional/lifecycle_environment/update_test.rb +14 -0
- data/test/functional/local_helper_test.rb +30 -0
- data/test/functional/module_stream/info_test.rb +58 -0
- data/test/functional/module_stream/list_test.rb +53 -0
- data/test/functional/organization/cdn_configuration_test.rb +45 -0
- data/test/functional/organization/delete_test.rb +26 -0
- data/test/functional/organization/info_test.rb +45 -0
- data/test/functional/organization/organization_helpers.rb +10 -0
- data/test/functional/package/list_test.rb +160 -0
- data/test/functional/package_group/list_test.rb +38 -0
- data/test/functional/ping_test.rb +61 -0
- data/test/functional/product/create_test.rb +54 -0
- data/test/functional/product/delete_test.rb +41 -0
- data/test/functional/product/info_test.rb +33 -0
- data/test/functional/product/list_test.rb +58 -0
- data/test/functional/product/product_helpers.rb +24 -0
- data/test/functional/product/remove_sync_plan_test.rb +35 -0
- data/test/functional/product/set_sync_plan_test.rb +49 -0
- data/test/functional/product/update_proxy.rb +48 -0
- data/test/functional/product/update_test.rb +46 -0
- data/test/functional/repository/create_test.rb +21 -0
- data/test/functional/repository/delete_test.rb +95 -0
- data/test/functional/repository/info_test.rb +156 -0
- data/test/functional/repository/list_test.rb +68 -0
- data/test/functional/repository/reclaim_space_test.rb +105 -0
- data/test/functional/repository/remove_content_test.rb +108 -0
- data/test/functional/repository/repository_helpers.rb +18 -0
- data/test/functional/repository/republish_test.rb +37 -0
- data/test/functional/repository/synchronize_test.rb +57 -0
- data/test/functional/repository/update_test.rb +150 -0
- data/test/functional/repository/upload_test.rb +368 -0
- data/test/functional/repository_set/available_repositories_test.rb +18 -0
- data/test/functional/repository_set/disable_test.rb +48 -0
- data/test/functional/repository_set/enable_test.rb +42 -0
- data/test/functional/repository_set/info_test.rb +17 -0
- data/test/functional/repository_set/list_test.rb +18 -0
- data/test/functional/repository_set/repository_set_helpers.rb +20 -0
- data/test/functional/search_helpers.rb +17 -0
- data/test/functional/simple_content_access/disable_test.rb +48 -0
- data/test/functional/simple_content_access/enable_test.rb +46 -0
- data/test/functional/simple_content_access/status_test.rb +29 -0
- data/test/functional/srpm/list_test.rb +92 -0
- data/test/functional/subscription/list_test.rb +86 -0
- data/test/functional/sync_plan/create_test.rb +60 -0
- data/test/functional/sync_plan/delete_test.rb +46 -0
- data/test/functional/sync_plan/info_test.rb +37 -0
- data/test/functional/sync_plan/list_test.rb +31 -0
- data/test/functional/sync_plan/sync_plan_helpers.rb +8 -0
- data/test/functional/sync_plan/update_test.rb +44 -0
- data/test/functional/test_helper.rb +24 -0
- data/test/task_helper.rb +7 -0
- data/test/test_helper.rb +38 -0
- data/test/unit/id_name_options_validator_test.rb +96 -0
- data/test/unit/id_resolver_test.rb +58 -0
- data/test/unit/messages_test.rb +7 -0
- data/test/unit/search_options_creators_test.rb +145 -0
- metadata +425 -4
@@ -0,0 +1,95 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'hammer_cli_katello/repository'
|
3
|
+
|
4
|
+
module HammerCLIKatello
|
5
|
+
describe Repository::DeleteCommand do
|
6
|
+
it 'allows minimal parameters' do
|
7
|
+
api_expects(:repositories, :destroy) { |p| p['id'] == 1 }
|
8
|
+
run_cmd(%w(repository delete --id 1))
|
9
|
+
end
|
10
|
+
|
11
|
+
describe 'product options' do
|
12
|
+
it 'are required to resolve repository name' do
|
13
|
+
api_expects_no_call
|
14
|
+
result = run_cmd(%w(repository delete --name repo1))
|
15
|
+
assert_includes(result.err, 'At least one of options --product, --product-id is required')
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'can be specified via product id' do
|
19
|
+
api_expects(:repositories, :index)
|
20
|
+
.with_params('product_id' => 3, 'name' => 'repo1')
|
21
|
+
.returns(index_response([{'id' => 1}]))
|
22
|
+
|
23
|
+
api_expects(:repositories, :destroy) { |p| p['id'] == 1 }
|
24
|
+
|
25
|
+
run_cmd(%w(repository delete --name repo1 --product-id 3))
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'can be specified via product name' do
|
29
|
+
api_expects(:products, :index)
|
30
|
+
.with_params('organization_id' => '6', 'name' => 'product3')
|
31
|
+
.returns(index_response([{'id' => 3}]))
|
32
|
+
|
33
|
+
api_expects(:repositories, :index)
|
34
|
+
.with_params('product_id' => 3, 'name' => 'repo1')
|
35
|
+
.returns(index_response([{'id' => 1}]))
|
36
|
+
|
37
|
+
api_expects(:repositories, :destroy) { |p| p['id'] == 1 }
|
38
|
+
|
39
|
+
run_cmd(%w(repository delete --name repo1 --product product3 --organization-id 6))
|
40
|
+
end
|
41
|
+
|
42
|
+
describe 'organization options' do
|
43
|
+
it 'can be specified by organization id' do
|
44
|
+
api_expects(:products, :index)
|
45
|
+
.with_params('organization_id' => '6', 'name' => 'product3')
|
46
|
+
.returns(index_response([{'id' => 3}]))
|
47
|
+
|
48
|
+
api_expects(:repositories, :index)
|
49
|
+
.with_params('product_id' => 3, 'name' => 'repo1')
|
50
|
+
.returns(index_response([{'id' => 1}]))
|
51
|
+
|
52
|
+
api_expects(:repositories, :destroy) { |p| p['id'] == 1 }
|
53
|
+
|
54
|
+
run_cmd(%w(repository delete --name repo1 --product product3 --organization-id 6))
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'can be specified by organization name' do
|
58
|
+
api_expects(:organizations, :index)
|
59
|
+
.with_params(:search => "name = \"org6\"")
|
60
|
+
.returns(index_response([{'id' => 6}]))
|
61
|
+
|
62
|
+
api_expects(:products, :index)
|
63
|
+
.with_params('organization_id' => 6, 'name' => 'product3')
|
64
|
+
.returns(index_response([{'id' => 3}]))
|
65
|
+
|
66
|
+
api_expects(:repositories, :index)
|
67
|
+
.with_params('product_id' => 3, 'name' => 'repo1')
|
68
|
+
.returns(index_response([{'id' => 1}]))
|
69
|
+
|
70
|
+
api_expects(:repositories, :destroy) { |p| p['id'] == 1 }
|
71
|
+
|
72
|
+
run_cmd(%w(repository delete --name repo1 --product product3 --organization org6))
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'can be specified by organization label' do
|
76
|
+
api_expects(:organizations, :index)
|
77
|
+
.with_params(:search => "label = \"org6\"")
|
78
|
+
.returns(index_response([{'id' => 6}]))
|
79
|
+
|
80
|
+
api_expects(:products, :index)
|
81
|
+
.with_params('organization_id' => 6, 'name' => 'product3')
|
82
|
+
.returns(index_response([{'id' => 3}]))
|
83
|
+
|
84
|
+
api_expects(:repositories, :index)
|
85
|
+
.with_params('product_id' => 3, 'name' => 'repo1')
|
86
|
+
.returns(index_response([{'id' => 1}]))
|
87
|
+
|
88
|
+
api_expects(:repositories, :destroy) { |p| p['id'] == 1 }
|
89
|
+
|
90
|
+
run_cmd(%w(repository delete --name repo1 --product product3 --organization-label org6))
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,156 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../test_helper')
|
2
|
+
require File.join(File.dirname(__FILE__), '../product/product_helpers')
|
3
|
+
require File.join(File.dirname(__FILE__), './repository_helpers')
|
4
|
+
require 'hammer_cli_katello/associating_commands'
|
5
|
+
|
6
|
+
describe "get repository info" do
|
7
|
+
include ProductHelpers
|
8
|
+
include RepositoryHelpers
|
9
|
+
|
10
|
+
before do
|
11
|
+
@cmd = %w(repository info)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "shows repository info by id" do
|
15
|
+
params = ['--id=1']
|
16
|
+
ex = api_expects(:repositories, :show, "Get info")
|
17
|
+
ex.returns(
|
18
|
+
'id' => 1,
|
19
|
+
'name' => 'Test Repo',
|
20
|
+
'label' => 'Test_Repo',
|
21
|
+
'description' => 'hammertime',
|
22
|
+
'organization' => {
|
23
|
+
'name' => 'Default Organization',
|
24
|
+
'label' => 'Default_Organization',
|
25
|
+
'id' => 1
|
26
|
+
},
|
27
|
+
'created_at' => '2020-08-05 15:35:36 UTC',
|
28
|
+
'updated_at' => '2020-08-05 15:35:36 UTC',
|
29
|
+
'content_type' => 'yum',
|
30
|
+
'product' => {
|
31
|
+
'id' => 79,
|
32
|
+
'name' => 'test'
|
33
|
+
},
|
34
|
+
'download_policy' => 'immediate',
|
35
|
+
'unprotected' => true,
|
36
|
+
'last_sync_words' => '3 minutes',
|
37
|
+
'mirroring_policy' => 'additive',
|
38
|
+
'relative_path' => 'Default_Organization/Library/Test_Repo',
|
39
|
+
'content_counts' => {
|
40
|
+
'rpm' => 1,
|
41
|
+
'srpm' => 0,
|
42
|
+
'package_group' => 0,
|
43
|
+
'erratum' => 1,
|
44
|
+
'module_stream' => 0
|
45
|
+
}
|
46
|
+
)
|
47
|
+
result = run_cmd(@cmd + params)
|
48
|
+
# rubocop:disable Style/WordArray
|
49
|
+
expected_fields = [['Id', '1'],
|
50
|
+
['Name', 'Test Repo'],
|
51
|
+
['Label', 'Test_Repo'],
|
52
|
+
['Description', 'hammertime'],
|
53
|
+
['Organization', 'Default Organization'],
|
54
|
+
['Red Hat Repository', 'no'],
|
55
|
+
['Content Type', 'yum'],
|
56
|
+
['Mirroring Policy', 'Additive'],
|
57
|
+
['Publish Via HTTP', 'yes'],
|
58
|
+
['Relative Path', 'Default_Organization/Library/Test_Repo'],
|
59
|
+
['Download Policy', 'immediate'],
|
60
|
+
['HTTP Proxy', ''],
|
61
|
+
['Product', ''],
|
62
|
+
['Id', '79'],
|
63
|
+
['Name', 'test'],
|
64
|
+
['GPG Key', ''],
|
65
|
+
['Sync', ''],
|
66
|
+
['Status', 'Not Synced'],
|
67
|
+
['Last Sync Date', '3 minutes'],
|
68
|
+
['Created', '2020/08/05 15:35:36'],
|
69
|
+
['Updated', '2020/08/05 15:35:36'],
|
70
|
+
['Content Counts', ''],
|
71
|
+
['Packages', '1'],
|
72
|
+
['Source RPMS', '0'],
|
73
|
+
['Package Groups', '0'],
|
74
|
+
['Errata', '1'],
|
75
|
+
['Module Streams', '0']]
|
76
|
+
# rubocop:enable Style/WordArray
|
77
|
+
expected_results = expected_fields.map { |field| success_result(FieldMatcher.new(*field)) }
|
78
|
+
expected_results.each { |expected| assert_cmd(expected, result) }
|
79
|
+
end
|
80
|
+
|
81
|
+
it "Shows information about a repository with organization-id and product name" do
|
82
|
+
org_id = 1
|
83
|
+
product_id = 2
|
84
|
+
repo_id = 3
|
85
|
+
params = ["--name=Test_Repo", "--product=Test_Product", "--organization-id=1"]
|
86
|
+
|
87
|
+
expect_product_search(org_id, 'Test_Product', product_id)
|
88
|
+
|
89
|
+
expect_repository_search(product_id, 'Test_Repo', repo_id)
|
90
|
+
|
91
|
+
ex = api_expects(:repositories, :show, "Get info")
|
92
|
+
|
93
|
+
ex.returns(
|
94
|
+
'id' => 1,
|
95
|
+
'name' => 'Test Repo',
|
96
|
+
'label' => 'Test_Repo',
|
97
|
+
'description' => 'hammertime',
|
98
|
+
'organization' => {
|
99
|
+
'name' => 'Default Organization',
|
100
|
+
'label' => 'Default_Organization',
|
101
|
+
'id' => 1
|
102
|
+
},
|
103
|
+
'created_at' => '2020-08-05 15:35:36 UTC',
|
104
|
+
'updated_at' => '2020-08-05 15:35:36 UTC',
|
105
|
+
'content_type' => 'yum',
|
106
|
+
'product' => {
|
107
|
+
'id' => 79,
|
108
|
+
'name' => 'Test_Product'
|
109
|
+
},
|
110
|
+
'download_policy' => 'immediate',
|
111
|
+
'unprotected' => true,
|
112
|
+
'last_sync_words' => '3 minutes',
|
113
|
+
'mirroring_policy' => 'mirror_complete',
|
114
|
+
'relative_path' => 'Default_Organization/Library/Test_Repo',
|
115
|
+
'content_counts' => {
|
116
|
+
'rpm' => 1,
|
117
|
+
'srpm' => 0,
|
118
|
+
'package_group' => 0,
|
119
|
+
'erratum' => 1,
|
120
|
+
'module_stream' => 0
|
121
|
+
}
|
122
|
+
)
|
123
|
+
result = run_cmd(@cmd + params)
|
124
|
+
# rubocop:disable Style/WordArray
|
125
|
+
expected_fields = [['Id', '1'],
|
126
|
+
['Name', 'Test Repo'],
|
127
|
+
['Label', 'Test_Repo'],
|
128
|
+
['Description', 'hammertime'],
|
129
|
+
['Organization', 'Default Organization'],
|
130
|
+
['Red Hat Repository', 'no'],
|
131
|
+
['Content Type', 'yum'],
|
132
|
+
['Mirroring Policy', 'Complete Mirroring'],
|
133
|
+
['Publish Via HTTP', 'yes'],
|
134
|
+
['Relative Path', 'Default_Organization/Library/Test_Repo'],
|
135
|
+
['Download Policy', 'immediate'],
|
136
|
+
['HTTP Proxy', ''],
|
137
|
+
['Product', ''],
|
138
|
+
['Id', '79'],
|
139
|
+
['Name', 'Test_Product'],
|
140
|
+
['GPG Key', ''],
|
141
|
+
['Sync', ''],
|
142
|
+
['Status', 'Not Synced'],
|
143
|
+
['Last Sync Date', '3 minutes'],
|
144
|
+
['Created', '2020/08/05 15:35:36'],
|
145
|
+
['Updated', '2020/08/05 15:35:36'],
|
146
|
+
['Content Counts', ''],
|
147
|
+
['Packages', '1'],
|
148
|
+
['Source RPMS', '0'],
|
149
|
+
['Package Groups', '0'],
|
150
|
+
['Errata', '1'],
|
151
|
+
['Module Streams', '0']]
|
152
|
+
# rubocop:enable Style/WordArray
|
153
|
+
expected_results = expected_fields.map { |field| success_result(FieldMatcher.new(*field)) }
|
154
|
+
expected_results.each { |expected| assert_cmd(expected, result) }
|
155
|
+
end
|
156
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../test_helper')
|
2
|
+
require File.join(File.dirname(__FILE__), '../lifecycle_environment/lifecycle_environment_helpers')
|
3
|
+
|
4
|
+
describe 'listing repositories' do
|
5
|
+
include LifecycleEnvironmentHelpers
|
6
|
+
|
7
|
+
before do
|
8
|
+
@cmd = %w(repository list)
|
9
|
+
end
|
10
|
+
|
11
|
+
let(:org_id) { 1 }
|
12
|
+
let(:lifecycle_env_id) { 1 }
|
13
|
+
let(:empty_response) do
|
14
|
+
{
|
15
|
+
"total" => 0,
|
16
|
+
"subtotal" => 0,
|
17
|
+
"page" => "1",
|
18
|
+
"per_page" => "1000",
|
19
|
+
"error" => nil,
|
20
|
+
"search" => nil,
|
21
|
+
"sort" => {
|
22
|
+
"by" => nil,
|
23
|
+
"order" => nil
|
24
|
+
},
|
25
|
+
"results" => []
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
it "lists an organizations repositories" do
|
30
|
+
params = ["--organization-id=#{org_id}"]
|
31
|
+
|
32
|
+
ex = api_expects(:repositories, :index, 'Organizations repositories list') do |par|
|
33
|
+
par['organization_id'] == org_id && par['page'] == 1 &&
|
34
|
+
par['per_page'] == 1000
|
35
|
+
end
|
36
|
+
|
37
|
+
ex.returns(empty_response)
|
38
|
+
|
39
|
+
expected_result = success_result("---|------|---------|--------------|----
|
40
|
+
ID | NAME | PRODUCT | CONTENT TYPE | URL
|
41
|
+
---|------|---------|--------------|----
|
42
|
+
")
|
43
|
+
|
44
|
+
result = run_cmd(@cmd + params)
|
45
|
+
assert_cmd(expected_result, result)
|
46
|
+
end
|
47
|
+
|
48
|
+
it "lists the repositories belonging to a lifecycle-environment by name" do
|
49
|
+
params = ['--organization-id=1', '--environment=test']
|
50
|
+
|
51
|
+
expect_lifecycle_environment_search(org_id, 'test', lifecycle_env_id)
|
52
|
+
|
53
|
+
ex = api_expects(:repositories, :index, 'lifecycle repositories list') do |par|
|
54
|
+
par['organization_id'] == org_id && par['page'] == 1 &&
|
55
|
+
par['per_page'] == 1000
|
56
|
+
end
|
57
|
+
|
58
|
+
ex.returns(empty_response)
|
59
|
+
|
60
|
+
expected_result = CommandExpectation.new("---|------|---------|--------------|----
|
61
|
+
ID | NAME | PRODUCT | CONTENT TYPE | URL
|
62
|
+
---|------|---------|--------------|----
|
63
|
+
", "Warning: Option --environment is deprecated. Use --lifecycle-environment instead\n")
|
64
|
+
|
65
|
+
result = run_cmd(@cmd + params)
|
66
|
+
assert_cmd(expected_result, result)
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require_relative '../organization/organization_helpers'
|
3
|
+
require 'hammer_cli_katello/repository'
|
4
|
+
module HammerCLIKatello
|
5
|
+
describe Repository::ReclaimSpaceCommand do
|
6
|
+
include OrganizationHelpers
|
7
|
+
it 'allows minimal options' do
|
8
|
+
api_expects(:repositories, :reclaim_space) do |p|
|
9
|
+
p['id'] == 1
|
10
|
+
end
|
11
|
+
run_cmd(%w(repository reclaim-space --id 1))
|
12
|
+
end
|
13
|
+
|
14
|
+
describe 'resolves repository ID' do
|
15
|
+
it 'by requiring product' do
|
16
|
+
api_expects_no_call
|
17
|
+
result = run_cmd(%w(repository reclaim-space --name repo1))
|
18
|
+
assert(result.err[/--product, --product-id is required/], 'Incorrect error message')
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'by product ID' do
|
22
|
+
ex = api_expects(:repositories, :index) do |p|
|
23
|
+
p['name'] == 'repo1' && p['product_id'] == 3
|
24
|
+
end
|
25
|
+
ex.returns(index_response([{'id' => 1}]))
|
26
|
+
|
27
|
+
api_expects(:repositories, :reclaim_space) do |p|
|
28
|
+
p['id'] == 1
|
29
|
+
end
|
30
|
+
|
31
|
+
run_cmd(%w(repository reclaim-space --name repo1 --product-id 3))
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe 'resolves product ID' do
|
36
|
+
it 'by requiring organization options' do
|
37
|
+
api_expects_no_call
|
38
|
+
result = run_cmd(%w(repository reclaim-space --name repo1 --product prod1))
|
39
|
+
assert(result.err[/--organization-id, --organization, --organization-label is required/],
|
40
|
+
"Organization option requirements must be validated")
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'by organization ID' do
|
44
|
+
ex = api_expects(:products, :index) do |p|
|
45
|
+
p['name'] == 'prod3' && p['organization_id'] == '5'
|
46
|
+
end
|
47
|
+
ex.returns(index_response([{'id' => 3}]))
|
48
|
+
|
49
|
+
ex = api_expects(:repositories, :index) do |p|
|
50
|
+
p['name'] == 'repo1' && p['product_id'] == 3
|
51
|
+
end
|
52
|
+
ex.returns(index_response([{'id' => 1}]))
|
53
|
+
|
54
|
+
api_expects(:repositories, :reclaim_space) do |p|
|
55
|
+
p['id'] == 1
|
56
|
+
end
|
57
|
+
|
58
|
+
run_cmd(%w(repository reclaim-space --name repo1 --product prod3 --organization-id 5
|
59
|
+
))
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'by organization name' do
|
63
|
+
expect_organization_search('org5', 5)
|
64
|
+
|
65
|
+
ex = api_expects(:products, :index) do |p|
|
66
|
+
p['name'] == 'prod3' && p['organization_id'] == 5
|
67
|
+
end
|
68
|
+
ex.returns(index_response([{'id' => 3}]))
|
69
|
+
|
70
|
+
ex = api_expects(:repositories, :index) do |p|
|
71
|
+
p['name'] == 'repo1' && p['product_id'] == 3
|
72
|
+
end
|
73
|
+
ex.returns(index_response([{'id' => 1}]))
|
74
|
+
|
75
|
+
api_expects(:repositories, :reclaim_space) do |p|
|
76
|
+
p['id'] == 1
|
77
|
+
end
|
78
|
+
|
79
|
+
run_cmd(%w(repository reclaim-space --name repo1 --product prod3 --organization org5
|
80
|
+
))
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'by organization label' do
|
84
|
+
expect_organization_search('org5', 5, field: 'label')
|
85
|
+
|
86
|
+
ex = api_expects(:products, :index) do |p|
|
87
|
+
p['name'] == 'prod3' && p['organization_id'] == 5
|
88
|
+
end
|
89
|
+
ex.returns(index_response([{'id' => 3}]))
|
90
|
+
|
91
|
+
ex = api_expects(:repositories, :index) do |p|
|
92
|
+
p['name'] == 'repo1' && p['product_id'] == 3
|
93
|
+
end
|
94
|
+
ex.returns(index_response([{'id' => 1}]))
|
95
|
+
|
96
|
+
api_expects(:repositories, :reclaim_space) do |p|
|
97
|
+
p['id'] == 1
|
98
|
+
end
|
99
|
+
|
100
|
+
run_cmd(%w(repository reclaim-space --name repo1 --product prod3 --organization-label org5
|
101
|
+
))
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require_relative '../organization/organization_helpers'
|
3
|
+
require 'hammer_cli_katello/repository'
|
4
|
+
|
5
|
+
module HammerCLIKatello
|
6
|
+
describe Repository::RemoveContentCommand do
|
7
|
+
include OrganizationHelpers
|
8
|
+
|
9
|
+
it 'allows minimal options' do
|
10
|
+
api_expects(:repositories, :remove_content) do |p|
|
11
|
+
p['id'] == 1 && p['ids'] == %w(20 21 22)
|
12
|
+
end
|
13
|
+
|
14
|
+
run_cmd(%w(repository remove-content --id 1 --ids 20,21,22))
|
15
|
+
end
|
16
|
+
|
17
|
+
describe 'resolves repository ID' do
|
18
|
+
it 'by requiring product' do
|
19
|
+
api_expects_no_call
|
20
|
+
result = run_cmd(%w(repository remove-content --name repo1 --ids 20,21,22))
|
21
|
+
assert(result.err[/--product, --product-id is required/], 'Incorrect error message')
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'by product ID' do
|
25
|
+
ex = api_expects(:repositories, :index) do |p|
|
26
|
+
p['name'] == 'repo1' && p['product_id'] == 3
|
27
|
+
end
|
28
|
+
ex.returns(index_response([{'id' => 1}]))
|
29
|
+
|
30
|
+
api_expects(:repositories, :remove_content) do |p|
|
31
|
+
p['id'] == 1 && p['ids'] == %w(20 21 22)
|
32
|
+
end
|
33
|
+
|
34
|
+
run_cmd(%w(repository remove-content --name repo1 --product-id 3 --ids 20,21,22))
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe 'resolves product ID' do
|
39
|
+
it 'by requiring organization options' do
|
40
|
+
api_expects_no_call
|
41
|
+
result = run_cmd(%w(repository remove-content --name repo1 --product prod1 --ids 20,21,22))
|
42
|
+
assert(result.err[/--organization-id, --organization, --organization-label is required/],
|
43
|
+
"Organization option requirements must be validated")
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'by organization ID' do
|
47
|
+
ex = api_expects(:products, :index) do |p|
|
48
|
+
p['name'] == 'prod3' && p['organization_id'] == '5'
|
49
|
+
end
|
50
|
+
ex.returns(index_response([{'id' => 3}]))
|
51
|
+
|
52
|
+
ex = api_expects(:repositories, :index) do |p|
|
53
|
+
p['name'] == 'repo1' && p['product_id'] == 3
|
54
|
+
end
|
55
|
+
ex.returns(index_response([{'id' => 1}]))
|
56
|
+
|
57
|
+
api_expects(:repositories, :remove_content) do |p|
|
58
|
+
p['id'] == 1 && p['ids'] == %w(20 21 22)
|
59
|
+
end
|
60
|
+
|
61
|
+
run_cmd(%w(repository remove-content --name repo1 --product prod3 --organization-id 5
|
62
|
+
--ids 20,21,22))
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'by organization name' do
|
66
|
+
expect_organization_search('org5', 5)
|
67
|
+
|
68
|
+
ex = api_expects(:products, :index) do |p|
|
69
|
+
p['name'] == 'prod3' && p['organization_id'] == 5
|
70
|
+
end
|
71
|
+
ex.returns(index_response([{'id' => 3}]))
|
72
|
+
|
73
|
+
ex = api_expects(:repositories, :index) do |p|
|
74
|
+
p['name'] == 'repo1' && p['product_id'] == 3
|
75
|
+
end
|
76
|
+
ex.returns(index_response([{'id' => 1}]))
|
77
|
+
|
78
|
+
api_expects(:repositories, :remove_content) do |p|
|
79
|
+
p['id'] == 1 && p['ids'] == %w(20 21 22)
|
80
|
+
end
|
81
|
+
|
82
|
+
run_cmd(%w(repository remove-content --name repo1 --product prod3 --organization org5
|
83
|
+
--ids 20,21,22))
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'by organization label' do
|
87
|
+
expect_organization_search('org5', 5, field: 'label')
|
88
|
+
|
89
|
+
ex = api_expects(:products, :index) do |p|
|
90
|
+
p['name'] == 'prod3' && p['organization_id'] == 5
|
91
|
+
end
|
92
|
+
ex.returns(index_response([{'id' => 3}]))
|
93
|
+
|
94
|
+
ex = api_expects(:repositories, :index) do |p|
|
95
|
+
p['name'] == 'repo1' && p['product_id'] == 3
|
96
|
+
end
|
97
|
+
ex.returns(index_response([{'id' => 1}]))
|
98
|
+
|
99
|
+
api_expects(:repositories, :remove_content) do |p|
|
100
|
+
p['id'] == 1 && p['ids'] == %w(20 21 22)
|
101
|
+
end
|
102
|
+
|
103
|
+
run_cmd(%w(repository remove-content --name repo1 --product prod3 --organization-label org5
|
104
|
+
--ids 20,21,22))
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module RepositoryHelpers
|
2
|
+
def expect_repository_search(product_id, name, id)
|
3
|
+
api_expects(:repositories, :index, 'Find a repository')
|
4
|
+
.with_params('name' => name, 'product_id' => product_id)
|
5
|
+
.returns(index_response([{'id' => id}]))
|
6
|
+
end
|
7
|
+
|
8
|
+
def expect_repositories_search(org_id, names, ids)
|
9
|
+
expect_generic_repositories_search({'names' => names, 'organization_id' => org_id},
|
10
|
+
ids.zip(names).map { |id, name| { 'id' => id, 'name' => name } })
|
11
|
+
end
|
12
|
+
|
13
|
+
def expect_generic_repositories_search(params = {}, returns = [])
|
14
|
+
api_expects(:repositories, :index, 'Find repositories')
|
15
|
+
.with_params(params)
|
16
|
+
.returns(index_response(returns))
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../test_helper')
|
2
|
+
require File.join(File.dirname(__FILE__), './repository_helpers')
|
3
|
+
require File.join(File.dirname(__FILE__), '../product/product_helpers')
|
4
|
+
|
5
|
+
describe 'Republish a repository' do
|
6
|
+
include RepositoryHelpers
|
7
|
+
include ForemanTaskHelpers
|
8
|
+
include ProductHelpers
|
9
|
+
|
10
|
+
before do
|
11
|
+
@cmd = %w(repository republish)
|
12
|
+
end
|
13
|
+
|
14
|
+
let(:repo_id) { 1 }
|
15
|
+
let(:sync_response) do
|
16
|
+
{
|
17
|
+
'id' => repo_id.to_s,
|
18
|
+
'label' => 'Actions::Katello::Repository::MetadataGenerate',
|
19
|
+
'state' => 'planned'
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
it "republishes a repository" do
|
24
|
+
params = ["--id=#{repo_id}", "--force=true"]
|
25
|
+
|
26
|
+
ex = api_expects(:repositories, :republish, 'Repository republished.') do |par|
|
27
|
+
par['id'] == repo_id && par['force'] == true
|
28
|
+
end
|
29
|
+
|
30
|
+
ex.returns(sync_response)
|
31
|
+
|
32
|
+
expect_foreman_task('3')
|
33
|
+
|
34
|
+
result = run_cmd(@cmd + params)
|
35
|
+
assert_equal(result.exit_code, 0)
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../test_helper')
|
2
|
+
require File.join(File.dirname(__FILE__), '../product/product_helpers')
|
3
|
+
require File.join(File.dirname(__FILE__), './repository_helpers')
|
4
|
+
|
5
|
+
describe 'Synchronize a repository' do
|
6
|
+
include ForemanTaskHelpers
|
7
|
+
include ProductHelpers
|
8
|
+
include RepositoryHelpers
|
9
|
+
|
10
|
+
before do
|
11
|
+
@cmd = %w(repository synchronize)
|
12
|
+
end
|
13
|
+
|
14
|
+
let(:org_id) { 1 }
|
15
|
+
let(:repo_id) { 2 }
|
16
|
+
let(:product_id) { 3 }
|
17
|
+
let(:sync_response) do
|
18
|
+
{
|
19
|
+
'id' => repo_id.to_s,
|
20
|
+
'state' => 'planned'
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
it "synchronizes a repository" do
|
25
|
+
params = ["--id=#{repo_id}"]
|
26
|
+
|
27
|
+
ex = api_expects(:repositories, :sync, 'Repository is synced') do |par|
|
28
|
+
par['id'] == repo_id
|
29
|
+
end
|
30
|
+
|
31
|
+
ex.returns(sync_response)
|
32
|
+
|
33
|
+
expect_foreman_task('3')
|
34
|
+
|
35
|
+
result = run_cmd(@cmd + params)
|
36
|
+
assert_equal(result.exit_code, 0)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "synchronizes a repository with a repository name" do
|
40
|
+
params = ["--name=test_repo", "--product=test_product", "--organization-id=#{org_id}"]
|
41
|
+
|
42
|
+
expect_product_search(org_id, "test_product", product_id)
|
43
|
+
|
44
|
+
expect_repository_search(product_id, "test_repo", repo_id)
|
45
|
+
|
46
|
+
ex = api_expects(:repositories, :sync, 'Repository is synced') do |par|
|
47
|
+
par['id'] == repo_id
|
48
|
+
end
|
49
|
+
|
50
|
+
ex.returns(sync_response)
|
51
|
+
|
52
|
+
expect_foreman_task('3')
|
53
|
+
|
54
|
+
result = run_cmd(@cmd + params)
|
55
|
+
assert_equal(result.exit_code, 0)
|
56
|
+
end
|
57
|
+
end
|