hammer_cli_katello 1.5.0 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,150 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require_relative '../organization/organization_helpers'
|
3
|
+
require 'hammer_cli_katello/repository'
|
4
|
+
|
5
|
+
module HammerCLIKatello # rubocop:disable Metrics/ModuleLength
|
6
|
+
describe Repository::UpdateCommand do
|
7
|
+
include OrganizationHelpers
|
8
|
+
|
9
|
+
it 'allows minimal options' do
|
10
|
+
api_expects(:repositories, :update) do |p|
|
11
|
+
p['id'] == 1 && p['name'] == 'rep1'
|
12
|
+
end
|
13
|
+
|
14
|
+
run_cmd(%w(repository update --id 1 --new-name rep1))
|
15
|
+
end
|
16
|
+
|
17
|
+
describe 'tags docker images' do
|
18
|
+
let(:repo_id) { 3 }
|
19
|
+
let(:tag_name) { "latest" }
|
20
|
+
let(:digest) { "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" }
|
21
|
+
let(:upload_id) { "1234" }
|
22
|
+
let(:_href) { "/pulp/api/v2/content/uploads/#{upload_id}" }
|
23
|
+
let(:upload_response) do
|
24
|
+
{
|
25
|
+
"upload_id" => upload_id,
|
26
|
+
"_href" => _href
|
27
|
+
}
|
28
|
+
end
|
29
|
+
it "adds a tag to an image" do
|
30
|
+
skip "Until we https://projects.theforeman.org/issues/34817 is resolved"
|
31
|
+
ex = api_expects(:content_uploads, :create)
|
32
|
+
.with_params('repository_id' => repo_id, :size => 0)
|
33
|
+
|
34
|
+
ex.returns(upload_response)
|
35
|
+
ex2 = api_expects(:repositories, :import_uploads, 'Take in an upload')
|
36
|
+
.with_params(:id => repo_id, :sync_capsule => true, :publish_repository => true,
|
37
|
+
:uploads => [{
|
38
|
+
:id => '1234',
|
39
|
+
:name => tag_name,
|
40
|
+
:digest => digest
|
41
|
+
}],
|
42
|
+
:content_type => "docker_tag"
|
43
|
+
)
|
44
|
+
|
45
|
+
ex2.returns("")
|
46
|
+
|
47
|
+
ex3 = api_expects(:content_uploads, :destroy, "Delete the upload")
|
48
|
+
.with_params('id' => upload_id, 'repository_id' => repo_id)
|
49
|
+
|
50
|
+
ex3.returns("")
|
51
|
+
# rubocop:disable LineLength
|
52
|
+
result = run_cmd(%W(repository update --id #{repo_id} --docker-tag #{tag_name} --docker-digest #{digest}))
|
53
|
+
# rubocop:enable LineLength
|
54
|
+
assert_equal(result.exit_code, 0)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe 'resolves repository ID' do
|
59
|
+
it 'by requiring product' do
|
60
|
+
api_expects_no_call
|
61
|
+
result = run_cmd(%w(repository update --name repo1 --new-name rep1))
|
62
|
+
assert(result.err[/--product, --product-id is required/], 'Incorrect error message')
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'by product ID' do
|
66
|
+
ex = api_expects(:repositories, :index) do |p|
|
67
|
+
p['name'] == 'repo1' && p['product_id'] == 3
|
68
|
+
end
|
69
|
+
ex.returns(index_response([{'id' => 1}]))
|
70
|
+
|
71
|
+
api_expects(:repositories, :update) do |p|
|
72
|
+
p['id'] == 1 && p['name'] == 'rep1'
|
73
|
+
end
|
74
|
+
|
75
|
+
run_cmd(%w(repository update --name repo1 --product-id 3 --new-name rep1))
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe 'resolves product ID' do
|
80
|
+
it 'by requiring organization options' do
|
81
|
+
api_expects_no_call
|
82
|
+
result = run_cmd(%w(repository update --name repo1 --product prod1 --new-name rep1))
|
83
|
+
assert(result.err[/--organization-id, --organization, --organization-label is required/],
|
84
|
+
"Organization option requirements must be validated")
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'by organization ID' do
|
88
|
+
ex = api_expects(:products, :index) do |p|
|
89
|
+
p['name'] == 'prod3' && p['organization_id'] == '5'
|
90
|
+
end
|
91
|
+
ex.returns(index_response([{'id' => 3}]))
|
92
|
+
|
93
|
+
ex = api_expects(:repositories, :index) do |p|
|
94
|
+
p['name'] == 'repo1' && p['product_id'] == 3
|
95
|
+
end
|
96
|
+
ex.returns(index_response([{'id' => 1}]))
|
97
|
+
|
98
|
+
api_expects(:repositories, :update) do |p|
|
99
|
+
p['id'] == 1 && p['name'] == 'rep1'
|
100
|
+
end
|
101
|
+
|
102
|
+
run_cmd(%w(repository update --name repo1 --product prod3 --organization-id 5
|
103
|
+
--new-name rep1))
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'by organization name' do
|
107
|
+
expect_organization_search('org5', 5)
|
108
|
+
|
109
|
+
ex = api_expects(:products, :index) do |p|
|
110
|
+
p['name'] == 'prod3' && p['organization_id'] == 5
|
111
|
+
end
|
112
|
+
ex.returns(index_response([{'id' => 3}]))
|
113
|
+
|
114
|
+
ex = api_expects(:repositories, :index) do |p|
|
115
|
+
p['name'] == 'repo1' && p['product_id'] == 3
|
116
|
+
end
|
117
|
+
ex.returns(index_response([{'id' => 1}]))
|
118
|
+
|
119
|
+
api_expects(:repositories, :update) do |p|
|
120
|
+
p['id'] == 1 && p['name'] == 'rep1'
|
121
|
+
end
|
122
|
+
|
123
|
+
run_cmd(%w(repository update --name repo1 --product prod3 --organization org5
|
124
|
+
--new-name rep1))
|
125
|
+
end
|
126
|
+
|
127
|
+
it 'by organization label' do
|
128
|
+
expect_organization_search('org5', 5, field: 'label')
|
129
|
+
|
130
|
+
ex = api_expects(:products, :index) do |p|
|
131
|
+
p['name'] == 'prod3' && p['organization_id'] == 5
|
132
|
+
end
|
133
|
+
ex.returns(index_response([{'id' => 3}]))
|
134
|
+
|
135
|
+
ex = api_expects(:repositories, :index) do |p|
|
136
|
+
p['name'] == 'repo1' && p['product_id'] == 3
|
137
|
+
end
|
138
|
+
ex.returns(index_response([{'id' => 1}]))
|
139
|
+
|
140
|
+
api_expects(:repositories, :update) do |p|
|
141
|
+
p['id'] == 1 && p['name'] == 'rep1'
|
142
|
+
end
|
143
|
+
|
144
|
+
run_cmd(%w(repository update --name repo1 --product prod3 --organization-label org5
|
145
|
+
--new-name rep1))
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
# rubocop:enable ModuleLength
|
@@ -0,0 +1,368 @@
|
|
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 'upload repository' do
|
6
|
+
include ProductHelpers
|
7
|
+
include RepositoryHelpers
|
8
|
+
include ForemanTaskHelpers
|
9
|
+
|
10
|
+
before do
|
11
|
+
@cmd = %w(repository upload-content)
|
12
|
+
end
|
13
|
+
|
14
|
+
let(:org_id) { 1 }
|
15
|
+
let(:product_id) { 2 }
|
16
|
+
let(:repo_id) { 3 }
|
17
|
+
let(:path) { "./test.rpm" }
|
18
|
+
let(:upload_id) { "1234" }
|
19
|
+
let(:_href) { "/pulp/api/v2/content/uploads/#{upload_id}" }
|
20
|
+
let(:task_id) { "2ea4f" }
|
21
|
+
let(:upload_response) do
|
22
|
+
{
|
23
|
+
"upload_id" => upload_id,
|
24
|
+
"href" => _href
|
25
|
+
}
|
26
|
+
end
|
27
|
+
let(:import_uploads_response) do
|
28
|
+
{
|
29
|
+
"id" => task_id
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
it "uploads a package" do
|
34
|
+
file = File.new("test.rpm", "w")
|
35
|
+
|
36
|
+
params = ["--id=#{repo_id}", "--path=#{path}"]
|
37
|
+
|
38
|
+
ex = api_expects(:content_uploads, :create, "Create upload for content")
|
39
|
+
.with_params('repository_id' => repo_id, :size => file.size)
|
40
|
+
|
41
|
+
ex.returns(upload_response)
|
42
|
+
|
43
|
+
# rubocop:disable LineLength
|
44
|
+
ex2 = api_expects(:repositories, :import_uploads, 'Take in an upload')
|
45
|
+
.with_params(:id => repo_id, :sync_capsule => true, :publish_repository => true, :async => true,
|
46
|
+
:uploads => [{
|
47
|
+
:id => '1234',
|
48
|
+
:name => 'test.rpm',
|
49
|
+
:size => 0,
|
50
|
+
:content_unit_id => nil,
|
51
|
+
:checksum => 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
|
52
|
+
}]
|
53
|
+
)
|
54
|
+
# rubocop:enable LineLength
|
55
|
+
|
56
|
+
ex2.returns(import_uploads_response)
|
57
|
+
expect_foreman_task(task_id)
|
58
|
+
expect_foreman_task(task_id)
|
59
|
+
|
60
|
+
ex3 = api_expects(:content_uploads, :destroy, "Delete the upload")
|
61
|
+
.with_params('id' => upload_id, 'repository_id' => repo_id)
|
62
|
+
|
63
|
+
ex3.returns("")
|
64
|
+
result = run_cmd(@cmd + params)
|
65
|
+
|
66
|
+
assert_equal(result.exit_code, 0)
|
67
|
+
File.delete("test.rpm")
|
68
|
+
end
|
69
|
+
|
70
|
+
it "uploads srpm with content-type" do
|
71
|
+
file = File.new("test.src.rpm", "w")
|
72
|
+
params = ["--id=#{repo_id}", '--path=./test.src.rpm', '--content-type=srpm']
|
73
|
+
|
74
|
+
ex = api_expects(:content_uploads, :create, "Create upload for content")
|
75
|
+
.with_params('repository_id' => repo_id, :content_type => 'srpm', :size => file.size)
|
76
|
+
|
77
|
+
ex.returns(upload_response)
|
78
|
+
|
79
|
+
# rubocop:disable LineLength
|
80
|
+
ex2 = api_expects(:repositories, :import_uploads, 'Take in an upload')
|
81
|
+
.with_params(:id => repo_id, :sync_capsule => true, :publish_repository => true, :content_type => 'srpm', :async => true,
|
82
|
+
:uploads => [{
|
83
|
+
:id => '1234',
|
84
|
+
:name => 'test.src.rpm',
|
85
|
+
:size => 0,
|
86
|
+
:content_unit_id => nil,
|
87
|
+
:checksum => 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
|
88
|
+
}]
|
89
|
+
)
|
90
|
+
# rubocop:enable LineLength
|
91
|
+
|
92
|
+
ex2.returns(import_uploads_response)
|
93
|
+
expect_foreman_task(task_id)
|
94
|
+
expect_foreman_task(task_id)
|
95
|
+
|
96
|
+
ex3 = api_expects(:content_uploads, :destroy, "Delete the upload")
|
97
|
+
.with_params(:id => upload_id, :repository_id => repo_id)
|
98
|
+
|
99
|
+
ex3.returns("")
|
100
|
+
|
101
|
+
result = run_cmd(@cmd + params)
|
102
|
+
assert_equal(result.exit_code, 0)
|
103
|
+
File.delete("test.src.rpm")
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'fails upload of srpm with no content-type' do
|
107
|
+
file = File.new("test.src.rpm", "w")
|
108
|
+
|
109
|
+
params = ["--id=#{repo_id}", '--path=./test.src.rpm']
|
110
|
+
|
111
|
+
ex = api_expects(:content_uploads, :create, "Create upload for content")
|
112
|
+
.with_params('repository_id' => repo_id, :size => file.size)
|
113
|
+
|
114
|
+
ex.returns(upload_response)
|
115
|
+
|
116
|
+
# rubocop:disable LineLength
|
117
|
+
ex2 = api_expects(:repositories, :import_uploads, 'Take in an upload')
|
118
|
+
.with_params(:id => repo_id, :sync_capsule => true, :publish_repository => true, :async => true,
|
119
|
+
:uploads => [{
|
120
|
+
:id => '1234',
|
121
|
+
:name => 'test.src.rpm',
|
122
|
+
:size => 0,
|
123
|
+
:content_unit_id => nil,
|
124
|
+
:checksum => 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
|
125
|
+
}]
|
126
|
+
)
|
127
|
+
# rubocop:enable LineLength
|
128
|
+
|
129
|
+
ex2.returns(400)
|
130
|
+
|
131
|
+
ex3 = api_expects(:content_uploads, :destroy, "Delete the upload")
|
132
|
+
.with_params(:id => upload_id, :repository_id => repo_id)
|
133
|
+
|
134
|
+
ex3.returns("")
|
135
|
+
|
136
|
+
result = run_cmd(@cmd + params)
|
137
|
+
assert_equal(result.exit_code, 70)
|
138
|
+
File.delete("test.src.rpm")
|
139
|
+
end
|
140
|
+
|
141
|
+
it "uploads a docker image" do
|
142
|
+
file = File.new("test.rpm", "w")
|
143
|
+
|
144
|
+
params = ["--id=#{repo_id}", "--path=#{path}"]
|
145
|
+
|
146
|
+
ex = api_expects(:content_uploads, :create, "Create upload for content")
|
147
|
+
.with_params(:repository_id => repo_id, :size => file.size)
|
148
|
+
|
149
|
+
ex.returns(upload_response)
|
150
|
+
|
151
|
+
# rubocop:disable LineLength
|
152
|
+
ex2 = api_expects(:repositories, :import_uploads, 'Take in an upload')
|
153
|
+
.with_params(:id => repo_id, :sync_capsule => true, :publish_repository => true, :async => true,
|
154
|
+
:uploads => [{
|
155
|
+
:id => '1234',
|
156
|
+
:name => 'test.rpm',
|
157
|
+
:size => 0,
|
158
|
+
:content_unit_id => nil,
|
159
|
+
:checksum => 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
|
160
|
+
}]
|
161
|
+
)
|
162
|
+
# rubocop:enable LineLength
|
163
|
+
|
164
|
+
ex2.returns(import_uploads_response)
|
165
|
+
expect_foreman_task(task_id)
|
166
|
+
|
167
|
+
ex3 = api_expects(:foreman_tasks, :show, 'Show task')
|
168
|
+
ex3.returns('id' => task_id, 'state' => 'stopped', 'progress' => 1,
|
169
|
+
'humanized' => {'output' => {'upload_results' => [{'type' => 'docker_manifest',
|
170
|
+
'digest' => 'sha256:1234'}]},
|
171
|
+
'errors' => ''})
|
172
|
+
|
173
|
+
ex4 = api_expects(:content_uploads, :destroy, "Delete the upload")
|
174
|
+
.with_params(:id => upload_id, :repository_id => repo_id)
|
175
|
+
|
176
|
+
ex4.returns("")
|
177
|
+
|
178
|
+
result = run_cmd(@cmd + params)
|
179
|
+
assert_equal(result.exit_code, 0)
|
180
|
+
File.delete("test.rpm")
|
181
|
+
end
|
182
|
+
|
183
|
+
it "uploads a package with an organization-id" do
|
184
|
+
file = File.new("test.rpm", "w")
|
185
|
+
|
186
|
+
params = ["--name=test_repo", "--product=test_product", "--organization-id=#{org_id}",
|
187
|
+
"--path=#{path}"]
|
188
|
+
|
189
|
+
expect_product_search(org_id, 'test_product', product_id)
|
190
|
+
|
191
|
+
expect_repository_search(product_id, 'test_repo', repo_id)
|
192
|
+
|
193
|
+
ex = api_expects(:content_uploads, :create, "Create upload for content")
|
194
|
+
.with_params(:repository_id => repo_id, :size => file.size)
|
195
|
+
|
196
|
+
ex.returns(upload_response)
|
197
|
+
|
198
|
+
# rubocop:disable LineLength
|
199
|
+
ex2 = api_expects(:repositories, :import_uploads, 'Take in an upload')
|
200
|
+
.with_params(:id => repo_id, :sync_capsule => true, :publish_repository => true, :async => true,
|
201
|
+
:uploads => [{
|
202
|
+
:id => '1234',
|
203
|
+
:name => 'test.rpm',
|
204
|
+
:size => 0,
|
205
|
+
:content_unit_id => nil,
|
206
|
+
:checksum => 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
|
207
|
+
}]
|
208
|
+
)
|
209
|
+
# rubocop:enable LineLength
|
210
|
+
|
211
|
+
ex2.returns(import_uploads_response)
|
212
|
+
expect_foreman_task(task_id)
|
213
|
+
expect_foreman_task(task_id)
|
214
|
+
|
215
|
+
ex3 = api_expects(:content_uploads, :destroy, "Delete the upload")
|
216
|
+
.with_params(:id => upload_id, :repository_id => repo_id)
|
217
|
+
|
218
|
+
ex3.returns("")
|
219
|
+
|
220
|
+
result = run_cmd(@cmd + params)
|
221
|
+
assert_equal(result.exit_code, 0)
|
222
|
+
File.delete("test.rpm")
|
223
|
+
end
|
224
|
+
|
225
|
+
it "supports globs" do
|
226
|
+
file = File.new("test.rpm", "w")
|
227
|
+
|
228
|
+
params = ["--id=#{repo_id}", "--path={test}.[r{1}]pm"]
|
229
|
+
|
230
|
+
ex = api_expects(:content_uploads, :create, "Create upload for content")
|
231
|
+
.with_params(:repository_id => repo_id, :size => file.size)
|
232
|
+
|
233
|
+
ex.returns(upload_response)
|
234
|
+
# rubocop:disable LineLength
|
235
|
+
ex2 = api_expects(:repositories, :import_uploads, 'Take in an upload')
|
236
|
+
.with_params(:id => repo_id, :sync_capsule => true, :publish_repository => true, :async => true,
|
237
|
+
:uploads => [{
|
238
|
+
:id => '1234',
|
239
|
+
:name => 'test.rpm',
|
240
|
+
:size => 0,
|
241
|
+
:content_unit_id => nil,
|
242
|
+
:checksum => 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
|
243
|
+
}]
|
244
|
+
)
|
245
|
+
# rubocop:enable LineLength
|
246
|
+
ex2.returns(import_uploads_response)
|
247
|
+
expect_foreman_task(task_id)
|
248
|
+
expect_foreman_task(task_id)
|
249
|
+
|
250
|
+
ex3 = api_expects(:content_uploads, :destroy, "Delete the upload")
|
251
|
+
.with_params(:id => upload_id, :repository_id => repo_id)
|
252
|
+
|
253
|
+
ex3.returns("")
|
254
|
+
|
255
|
+
result = run_cmd(@cmd + params)
|
256
|
+
assert_equal(result.exit_code, 0)
|
257
|
+
File.delete("test.rpm")
|
258
|
+
end
|
259
|
+
|
260
|
+
it "only syncs the capsule on the last file import" do
|
261
|
+
File.new("test1.rpm", "w")
|
262
|
+
File.new("test2.rpm", "w")
|
263
|
+
|
264
|
+
params = ["--id=#{repo_id}", "--path=test*.rpm"]
|
265
|
+
|
266
|
+
# Begin first upload cycle
|
267
|
+
|
268
|
+
ex = api_expects(:content_uploads, :create, "Create upload for content")
|
269
|
+
.with_params(:repository_id => repo_id)
|
270
|
+
|
271
|
+
ex.returns(upload_response)
|
272
|
+
|
273
|
+
# rubocop:disable LineLength
|
274
|
+
ex = api_expects(:repositories, :import_uploads, 'Take in an upload')
|
275
|
+
.with_params(:id => repo_id, :sync_capsule => false, :publish_repository => false, :async => true,
|
276
|
+
:uploads => [{
|
277
|
+
:id => '1234',
|
278
|
+
:name => 'test1.rpm',
|
279
|
+
:size => 0,
|
280
|
+
:content_unit_id => nil,
|
281
|
+
:checksum => 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
|
282
|
+
}]
|
283
|
+
)
|
284
|
+
# rubocop:enable LineLength
|
285
|
+
|
286
|
+
ex.returns(import_uploads_response)
|
287
|
+
expect_foreman_task(task_id)
|
288
|
+
expect_foreman_task(task_id)
|
289
|
+
|
290
|
+
ex = api_expects(:content_uploads, :destroy, "Delete the upload")
|
291
|
+
.with_params(:id => upload_id, :repository_id => repo_id)
|
292
|
+
|
293
|
+
ex.returns("")
|
294
|
+
|
295
|
+
# Begin second upload cycle
|
296
|
+
|
297
|
+
ex = api_expects(:content_uploads, :create, "Create upload for content")
|
298
|
+
.with_params(:repository_id => repo_id)
|
299
|
+
|
300
|
+
ex.returns(upload_response)
|
301
|
+
|
302
|
+
# rubocop:disable LineLength
|
303
|
+
ex = api_expects(:repositories, :import_uploads, 'Take in an upload')
|
304
|
+
.with_params(:id => repo_id, :sync_capsule => true, :publish_repository => true, :async => true,
|
305
|
+
:uploads => [{
|
306
|
+
:id => '1234',
|
307
|
+
:name => 'test2.rpm',
|
308
|
+
:size => 0,
|
309
|
+
:content_unit_id => nil,
|
310
|
+
:checksum => 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
|
311
|
+
}]
|
312
|
+
)
|
313
|
+
# rubocop:enable LineLength
|
314
|
+
|
315
|
+
ex.returns(import_uploads_response)
|
316
|
+
expect_foreman_task(task_id)
|
317
|
+
expect_foreman_task(task_id)
|
318
|
+
|
319
|
+
ex = api_expects(:content_uploads, :destroy, "Delete the upload")
|
320
|
+
.with_params(:id => upload_id, :repository_id => repo_id)
|
321
|
+
|
322
|
+
ex.returns("")
|
323
|
+
|
324
|
+
result = run_cmd(@cmd + params)
|
325
|
+
assert_equal(result.exit_code, 0)
|
326
|
+
File.delete("test1.rpm")
|
327
|
+
File.delete("test2.rpm")
|
328
|
+
end
|
329
|
+
|
330
|
+
it "errors if there are no matching files" do
|
331
|
+
params = ["--id=#{repo_id}", "--path=#{path}"]
|
332
|
+
|
333
|
+
result = run_cmd(@cmd + params)
|
334
|
+
|
335
|
+
assert_equal "Could not find any files matching PATH\n", result.err
|
336
|
+
assert_equal HammerCLI::EX_NOINPUT, result.exit_code
|
337
|
+
end
|
338
|
+
|
339
|
+
describe 'requires' do
|
340
|
+
it 'repository options' do
|
341
|
+
api_expects_no_call
|
342
|
+
error = run_cmd(@cmd + %W(--path #{path})).err
|
343
|
+
assert error.include?('--id, --name is required'), "Actual result: #{error}"
|
344
|
+
end
|
345
|
+
|
346
|
+
it 'product options when repository name is specified' do
|
347
|
+
api_expects_no_call
|
348
|
+
error = run_cmd(@cmd + %W(--name repo1 --path #{path})).err
|
349
|
+
assert(error.include?('--product, --product-id is required'), "Actual result: #{error}")
|
350
|
+
end
|
351
|
+
|
352
|
+
it 'organization options when product name is specified' do
|
353
|
+
api_expects_no_call
|
354
|
+
error = run_cmd(@cmd + %W(--name repo1 --product product2 --path #{path})).err
|
355
|
+
assert(error.include?('--organization-id, --organization, --organization-label is required'),
|
356
|
+
"Actual result: #{error}")
|
357
|
+
end
|
358
|
+
end
|
359
|
+
|
360
|
+
describe 'disallows' do
|
361
|
+
it 'product options when repository ID is specified' do
|
362
|
+
api_expects_no_call
|
363
|
+
error = run_cmd(@cmd + %W(--id 1 --product product2 --path #{path})).err
|
364
|
+
assert(error.include?('Cannot specify both product options and repository ID'),
|
365
|
+
"Actual result: #{error}")
|
366
|
+
end
|
367
|
+
end
|
368
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'hammer_cli_katello/repository_set'
|
3
|
+
|
4
|
+
module HammerCLIKatello
|
5
|
+
describe RepositorySetCommand::AvailableRepositoriesCommand do
|
6
|
+
it 'allows minimal options' do
|
7
|
+
api_expects(:repository_sets, :available_repositories)
|
8
|
+
.with_params('id' => 1)
|
9
|
+
.returns(index_response([]))
|
10
|
+
assert_success run_cmd(%w(repository-set available-repositories --id 1))
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'requires repository set options' do
|
14
|
+
api_expects_no_call
|
15
|
+
assert_failure run_cmd(%w(repository-set available-repositories)), /id.*name.*required/
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require_relative './repository_set_helpers'
|
3
|
+
require 'hammer_cli_katello/repository_set'
|
4
|
+
|
5
|
+
module HammerCLIKatello
|
6
|
+
describe RepositorySetCommand::DisableCommand do
|
7
|
+
include RepositorySetHelpers
|
8
|
+
|
9
|
+
it 'allows minimal options' do
|
10
|
+
api_expects(:repository_sets, :disable)
|
11
|
+
.with_params('id' => 1)
|
12
|
+
assert_success run_cmd(%w(repository-set disable --id 1))
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'requires repository set options' do
|
16
|
+
api_expects_no_call
|
17
|
+
assert_failure run_cmd(%w(repository-set disable)), /id.*name.*required/
|
18
|
+
end
|
19
|
+
|
20
|
+
describe 'resolves repository set ID' do
|
21
|
+
it 'by requiring organization or product options' do
|
22
|
+
api_expects_no_call
|
23
|
+
assert_failure run_cmd(%w(repository-set disable --name reposet1)),
|
24
|
+
/organization.*product.*required/
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'from organization options' do
|
28
|
+
expect_repository_set_search('reposet1', 1, organization_id: 2)
|
29
|
+
api_expects(:repository_sets, :disable)
|
30
|
+
.with_params('id' => 1)
|
31
|
+
assert_success run_cmd(%w(repository-set disable --name reposet1 --organization-id 2))
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'from product options' do
|
35
|
+
repo_id = 1001
|
36
|
+
product_id = 3
|
37
|
+
api_expects(:repositories, :index, 'Find a repository')
|
38
|
+
.with_params('product_id' => product_id)
|
39
|
+
.returns(index_response([{'id' => repo_id}]))
|
40
|
+
|
41
|
+
expect_repository_set_search('reposet1', 1, product_id: 3)
|
42
|
+
api_expects(:repository_sets, :disable)
|
43
|
+
.with_params('id' => 1, 'repository_id' => repo_id)
|
44
|
+
assert_success run_cmd(%w(repository-set disable --name reposet1 --product-id 3))
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require_relative './repository_set_helpers'
|
3
|
+
require 'hammer_cli_katello/repository_set'
|
4
|
+
|
5
|
+
module HammerCLIKatello
|
6
|
+
describe RepositorySetCommand::EnableCommand do
|
7
|
+
include RepositorySetHelpers
|
8
|
+
|
9
|
+
it 'allows minimal options' do
|
10
|
+
api_expects(:repository_sets, :enable)
|
11
|
+
.with_params('id' => 1)
|
12
|
+
assert_success run_cmd(%w(repository-set enable --id 1))
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'requires repository set options' do
|
16
|
+
api_expects_no_call
|
17
|
+
assert_failure run_cmd(%w(repository-set enable)), /id.*name.*required/
|
18
|
+
end
|
19
|
+
|
20
|
+
describe 'resolves repository set ID' do
|
21
|
+
it 'by requiring organization or product options' do
|
22
|
+
api_expects_no_call
|
23
|
+
assert_failure run_cmd(%w(repository-set enable --name reposet1)),
|
24
|
+
/organization.*product.*required/
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'from organization options' do
|
28
|
+
expect_repository_set_search('reposet1', 1, organization_id: 2)
|
29
|
+
api_expects(:repository_sets, :enable)
|
30
|
+
.with_params('id' => 1)
|
31
|
+
assert_success run_cmd(%w(repository-set enable --name reposet1 --organization-id 2))
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'from product options' do
|
35
|
+
expect_repository_set_search('reposet1', 1, product_id: 3)
|
36
|
+
api_expects(:repository_sets, :enable)
|
37
|
+
.with_params('id' => 1)
|
38
|
+
assert_success run_cmd(%w(repository-set enable --name reposet1 --product-id 3))
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'hammer_cli_katello/repository_set'
|
3
|
+
|
4
|
+
module HammerCLIKatello
|
5
|
+
describe RepositorySetCommand::InfoCommand do
|
6
|
+
it 'allows minimal options' do
|
7
|
+
api_expects(:repository_sets, :show)
|
8
|
+
.with_params('id' => 1)
|
9
|
+
assert_success run_cmd(%w(repository-set info --id 1))
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'requires repository set options' do
|
13
|
+
api_expects_no_call
|
14
|
+
assert_failure run_cmd(%w(repository-set info)), /id.*name.*required/
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'hammer_cli_katello/repository_set'
|
3
|
+
|
4
|
+
module HammerCLIKatello
|
5
|
+
describe RepositorySetCommand::ListCommand do
|
6
|
+
it 'allows minimal options' do
|
7
|
+
api_expects(:repository_sets, :index)
|
8
|
+
.with_params('organization_id' => 1)
|
9
|
+
.returns(index_response([]))
|
10
|
+
assert_success run_cmd(%w(repository-set list --organization-id 1))
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'requires organization options' do
|
14
|
+
api_expects_no_call
|
15
|
+
assert_failure run_cmd(%w(repository-set list)), /organization.*required/
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require_relative '../search_helpers'
|
2
|
+
|
3
|
+
module RepositorySetHelpers
|
4
|
+
include SearchHelpers
|
5
|
+
|
6
|
+
def expect_repository_set_search(name, id, organization_id: nil, product_id: nil)
|
7
|
+
params = {'name' => name}
|
8
|
+
params.merge(organization_id: organization_id) if organization_id.nil?
|
9
|
+
params.merge(product_id: product_id) if product_id.nil?
|
10
|
+
expect_generic_repository_sets_search(
|
11
|
+
params: params,
|
12
|
+
returns: {'id' => id})
|
13
|
+
end
|
14
|
+
|
15
|
+
def expect_generic_repository_sets_search(params: {}, returns: [])
|
16
|
+
api_expects(:repository_sets, :index, 'Find repository sets')
|
17
|
+
.with_params(params)
|
18
|
+
.returns(index_response(returns))
|
19
|
+
end
|
20
|
+
end
|