hammer_cli_katello 1.4.1 → 1.5.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/content_export_complete.rb +8 -0
- data/lib/hammer_cli_katello/content_export_helper.rb +55 -3
- data/lib/hammer_cli_katello/content_export_incremental.rb +8 -0
- data/lib/hammer_cli_katello/content_import.rb +9 -0
- data/lib/hammer_cli_katello/host_collection.rb +2 -0
- data/lib/hammer_cli_katello/id_resolver.rb +3 -2
- data/lib/hammer_cli_katello/organization.rb +11 -0
- data/lib/hammer_cli_katello/repository.rb +39 -2
- data/lib/hammer_cli_katello/version.rb +1 -1
- metadata +4 -398
- data/test/data/2.5/foreman_api.json +0 -1
- data/test/data/3.0/foreman_api.json +0 -1
- data/test/data/3.10/foreman_api.json +0 -1
- data/test/data/3.11/foreman_api.json +0 -1
- data/test/data/3.12/foreman_api.json +0 -1
- data/test/data/3.13/foreman_api.json +0 -1
- data/test/data/3.14/foreman_api.json +0 -1
- data/test/data/3.15/foreman_api.json +0 -1
- data/test/data/3.16/foreman_api.json +0 -1
- data/test/data/3.17/foreman_api.json +0 -1
- data/test/data/3.18/foreman_api.json +0 -1
- data/test/data/3.19/foreman_api.json +0 -1
- data/test/data/3.2/foreman_api.json +0 -1
- data/test/data/3.4/foreman_api.json +0 -1
- data/test/data/3.5/foreman_api.json +0 -1
- data/test/data/3.6/foreman_api.json +0 -1
- data/test/data/3.7/foreman_api.json +0 -1
- data/test/data/3.8/foreman_api.json +0 -1
- data/test/data/3.9/foreman_api.json +0 -1
- data/test/data/4.0/foreman_api.json +0 -1
- data/test/data/4.1/foreman_api.json +0 -1
- data/test/data/4.3/foreman_api.json +0 -1
- data/test/data/4.4/foreman_api.json +0 -1
- data/test/data/Readme.md +0 -5
- data/test/functional/activation_key/add_host_collection_test.rb +0 -62
- data/test/functional/activation_key/content_override_test.rb +0 -92
- data/test/functional/activation_key/create_test.rb +0 -33
- data/test/functional/activation_key/data/activation_key.json +0 -17
- data/test/functional/activation_key/info_test.rb +0 -29
- data/test/functional/activation_key/list_test.rb +0 -68
- data/test/functional/activation_key/product_content_test.rb +0 -23
- data/test/functional/activation_key/remove_host_collection_test.rb +0 -62
- data/test/functional/activation_key/subscriptions_test.rb +0 -74
- data/test/functional/activation_key/update_test.rb +0 -26
- data/test/functional/apipie_helper_test.rb +0 -31
- data/test/functional/capsule/capsule_helpers.rb +0 -13
- data/test/functional/capsule/content/add_lifecycle_environment_test.rb +0 -40
- data/test/functional/capsule/content/cancel_synchronization_test.rb +0 -42
- data/test/functional/capsule/content/capsule_content_helpers.rb +0 -24
- data/test/functional/capsule/content/data/library_env.json +0 -47
- data/test/functional/capsule/content/data/sync_status.json +0 -6
- data/test/functional/capsule/content/data/sync_tasks.json +0 -62
- data/test/functional/capsule/content/info_test.rb +0 -61
- data/test/functional/capsule/content/lifecycle_environments_test.rb +0 -19
- data/test/functional/capsule/content/remove_lifecycle_environment_test.rb +0 -40
- data/test/functional/capsule/content/synchronization_status_test.rb +0 -107
- data/test/functional/capsule/info_test.rb +0 -25
- data/test/functional/capsule/list_test.rb +0 -24
- data/test/functional/content_credentials/create_test.rb +0 -32
- data/test/functional/content_credentials/data/test_cert.json +0 -43
- data/test/functional/content_credentials/info_test.rb +0 -50
- data/test/functional/content_credentials/list_test.rb +0 -66
- data/test/functional/content_export/complete/library_test.rb +0 -155
- data/test/functional/content_export/complete/version_test.rb +0 -252
- data/test/functional/content_export/content_export_helpers.rb +0 -26
- data/test/functional/content_export/generate_metadata_test.rb +0 -64
- data/test/functional/content_export/incremental/library_test.rb +0 -172
- data/test/functional/content_export/incremental/version_test.rb +0 -268
- data/test/functional/content_export/list_test.rb +0 -64
- data/test/functional/content_import/library_test.rb +0 -85
- data/test/functional/content_import/list_test.rb +0 -65
- data/test/functional/content_import/metadata.json +0 -1
- data/test/functional/content_import/version_test.rb +0 -85
- data/test/functional/content_units/info_test.rb +0 -29
- data/test/functional/content_units/list_test.rb +0 -106
- data/test/functional/content_view/add_content_view_version_test.rb +0 -88
- data/test/functional/content_view/add_repository_test.rb +0 -21
- data/test/functional/content_view/component/add_test.rb +0 -177
- data/test/functional/content_view/component/list_test.rb +0 -55
- data/test/functional/content_view/component/remove_test.rb +0 -107
- data/test/functional/content_view/component/update_test.rb +0 -134
- data/test/functional/content_view/content_view_helpers.rb +0 -20
- data/test/functional/content_view/copy_test.rb +0 -53
- data/test/functional/content_view/create_test.rb +0 -34
- data/test/functional/content_view/delete_test.rb +0 -62
- data/test/functional/content_view/filter/create_test.rb +0 -57
- data/test/functional/content_view/filter/delete_test.rb +0 -90
- data/test/functional/content_view/filter/info_test.rb +0 -89
- data/test/functional/content_view/filter/list_test.rb +0 -98
- data/test/functional/content_view/filter/update_test.rb +0 -91
- data/test/functional/content_view/list_test.rb +0 -68
- data/test/functional/content_view/publish_test.rb +0 -24
- data/test/functional/content_view/purge_test.rb +0 -97
- data/test/functional/content_view/remove_content_view_version_test.rb +0 -88
- data/test/functional/content_view/remove_test.rb +0 -79
- data/test/functional/content_view/update_test.rb +0 -53
- data/test/functional/content_view/version/incremental_update_test.rb +0 -108
- data/test/functional/content_view/version/list_test.rb +0 -44
- data/test/functional/content_view/version/promote_test.rb +0 -75
- data/test/functional/content_view/version/republish_repositories_test.rb +0 -34
- data/test/functional/content_view/version/update_test.rb +0 -48
- data/test/functional/erratum/erratum_helpers.rb +0 -91
- data/test/functional/erratum/info_test.rb +0 -29
- data/test/functional/erratum/list_test.rb +0 -108
- data/test/functional/file/file_helpers.rb +0 -13
- data/test/functional/file/info_test.rb +0 -162
- data/test/functional/file/list_test.rb +0 -112
- data/test/functional/filter_rule/create_test.rb +0 -99
- data/test/functional/filter_rule/delete_test.rb +0 -104
- data/test/functional/filter_rule/filter_rule_helpers.rb +0 -12
- data/test/functional/filter_rule/info_test.rb +0 -104
- data/test/functional/filter_rule/list_test.rb +0 -91
- data/test/functional/filter_rule/update_test.rb +0 -104
- data/test/functional/host/errata/apply_test.rb +0 -45
- data/test/functional/host/errata/info_test.rb +0 -27
- data/test/functional/host/errata/list_test.rb +0 -49
- data/test/functional/host/errata/recalculate_test.rb +0 -26
- data/test/functional/host/extensions/create_test.rb +0 -95
- data/test/functional/host/extensions/data/host.json +0 -320
- data/test/functional/host/extensions/data/host_list.json +0 -117
- data/test/functional/host/extensions/info_test.rb +0 -35
- data/test/functional/host/extensions/list_test.rb +0 -21
- data/test/functional/host/extensions/update_test.rb +0 -70
- data/test/functional/host/host_helpers.rb +0 -8
- data/test/functional/host/subscription/attach_test.rb +0 -54
- data/test/functional/host/subscription/auto_attach_test.rb +0 -35
- data/test/functional/host/subscription/content_override_test.rb +0 -96
- data/test/functional/host/subscription/product_content_test.rb +0 -27
- data/test/functional/host/subscription/register_test.rb +0 -53
- data/test/functional/host/subscription/remove_test.rb +0 -52
- data/test/functional/host/subscription/unregister_test.rb +0 -37
- data/test/functional/host/traces/list_test.rb +0 -37
- data/test/functional/host/traces/resolve_test.rb +0 -31
- data/test/functional/host_collection/add_host_test.rb +0 -90
- data/test/functional/host_collection/content_api_expectations.rb +0 -35
- data/test/functional/host_collection/content_install_test.rb +0 -62
- data/test/functional/host_collection/content_remove_test.rb +0 -37
- data/test/functional/host_collection/content_update_test.rb +0 -37
- data/test/functional/host_collection/copy_test.rb +0 -64
- data/test/functional/host_collection/create_test.rb +0 -54
- data/test/functional/host_collection/delete_test.rb +0 -57
- data/test/functional/host_collection/hosts_test.rb +0 -39
- data/test/functional/host_collection/info_test.rb +0 -57
- data/test/functional/host_collection/list_test.rb +0 -63
- data/test/functional/host_collection/remove_host_test.rb +0 -90
- data/test/functional/host_collection/update_test.rb +0 -57
- data/test/functional/hostgroup/create_test.rb +0 -112
- data/test/functional/hostgroup/data/hostgroup.json +0 -50
- data/test/functional/hostgroup/info_test.rb +0 -33
- data/test/functional/hostgroup/update_test.rb +0 -120
- data/test/functional/lifecycle_environment/create_test.rb +0 -14
- data/test/functional/lifecycle_environment/lifecycle_environment_helpers.rb +0 -18
- data/test/functional/lifecycle_environment/list_test.rb +0 -38
- data/test/functional/lifecycle_environment/update_test.rb +0 -14
- data/test/functional/local_helper_test.rb +0 -30
- data/test/functional/module_stream/info_test.rb +0 -58
- data/test/functional/module_stream/list_test.rb +0 -53
- data/test/functional/organization/cdn_configuration_test.rb +0 -45
- data/test/functional/organization/delete_test.rb +0 -26
- data/test/functional/organization/info_test.rb +0 -39
- data/test/functional/organization/organization_helpers.rb +0 -10
- data/test/functional/package/list_test.rb +0 -160
- data/test/functional/package_group/list_test.rb +0 -38
- data/test/functional/ping_test.rb +0 -61
- data/test/functional/product/create_test.rb +0 -54
- data/test/functional/product/delete_test.rb +0 -41
- data/test/functional/product/info_test.rb +0 -33
- data/test/functional/product/list_test.rb +0 -58
- data/test/functional/product/product_helpers.rb +0 -24
- data/test/functional/product/remove_sync_plan_test.rb +0 -35
- data/test/functional/product/set_sync_plan_test.rb +0 -49
- data/test/functional/product/update_proxy.rb +0 -48
- data/test/functional/product/update_test.rb +0 -46
- data/test/functional/repository/create_test.rb +0 -21
- data/test/functional/repository/delete_test.rb +0 -95
- data/test/functional/repository/info_test.rb +0 -162
- data/test/functional/repository/list_test.rb +0 -68
- data/test/functional/repository/reclaim_space_test.rb +0 -105
- data/test/functional/repository/remove_content_test.rb +0 -108
- data/test/functional/repository/repository_helpers.rb +0 -18
- data/test/functional/repository/synchronize_test.rb +0 -57
- data/test/functional/repository/update_test.rb +0 -149
- data/test/functional/repository/upload_test.rb +0 -368
- data/test/functional/repository_set/available_repositories_test.rb +0 -18
- data/test/functional/repository_set/disable_test.rb +0 -42
- data/test/functional/repository_set/enable_test.rb +0 -42
- data/test/functional/repository_set/info_test.rb +0 -17
- data/test/functional/repository_set/list_test.rb +0 -18
- data/test/functional/repository_set/repository_set_helpers.rb +0 -20
- data/test/functional/search_helpers.rb +0 -17
- data/test/functional/simple_content_access/disable_test.rb +0 -48
- data/test/functional/simple_content_access/enable_test.rb +0 -46
- data/test/functional/srpm/list_test.rb +0 -92
- data/test/functional/subscription/list_test.rb +0 -86
- data/test/functional/sync_plan/create_test.rb +0 -60
- data/test/functional/sync_plan/delete_test.rb +0 -46
- data/test/functional/sync_plan/info_test.rb +0 -37
- data/test/functional/sync_plan/list_test.rb +0 -31
- data/test/functional/sync_plan/sync_plan_helpers.rb +0 -8
- data/test/functional/sync_plan/update_test.rb +0 -44
- data/test/functional/test_helper.rb +0 -24
- data/test/task_helper.rb +0 -7
- data/test/test_helper.rb +0 -38
- data/test/unit/id_name_options_validator_test.rb +0 -96
- data/test/unit/id_resolver_test.rb +0 -58
- data/test/unit/messages_test.rb +0 -7
- data/test/unit/search_options_creators_test.rb +0 -145
@@ -1,149 +0,0 @@
|
|
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
|
-
ex = api_expects(:content_uploads, :create)
|
31
|
-
.with_params('repository_id' => repo_id, :size => 0)
|
32
|
-
|
33
|
-
ex.returns(upload_response)
|
34
|
-
ex2 = api_expects(:repositories, :import_uploads, 'Take in an upload')
|
35
|
-
.with_params(:id => repo_id, :sync_capsule => true, :publish_repository => true,
|
36
|
-
:uploads => [{
|
37
|
-
:id => '1234',
|
38
|
-
:name => tag_name,
|
39
|
-
:digest => digest
|
40
|
-
}],
|
41
|
-
:content_type => "docker_tag"
|
42
|
-
)
|
43
|
-
|
44
|
-
ex2.returns("")
|
45
|
-
|
46
|
-
ex3 = api_expects(:content_uploads, :destroy, "Delete the upload")
|
47
|
-
.with_params('id' => upload_id, 'repository_id' => repo_id)
|
48
|
-
|
49
|
-
ex3.returns("")
|
50
|
-
# rubocop:disable LineLength
|
51
|
-
result = run_cmd(%W(repository update --id #{repo_id} --docker-tag #{tag_name} --docker-digest #{digest}))
|
52
|
-
# rubocop:enable LineLength
|
53
|
-
assert_equal(result.exit_code, 0)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
describe 'resolves repository ID' do
|
58
|
-
it 'by requiring product' do
|
59
|
-
api_expects_no_call
|
60
|
-
result = run_cmd(%w(repository update --name repo1 --new-name rep1))
|
61
|
-
assert(result.err[/--product, --product-id is required/], 'Incorrect error message')
|
62
|
-
end
|
63
|
-
|
64
|
-
it 'by product ID' do
|
65
|
-
ex = api_expects(:repositories, :index) do |p|
|
66
|
-
p['name'] == 'repo1' && p['product_id'] == 3
|
67
|
-
end
|
68
|
-
ex.returns(index_response([{'id' => 1}]))
|
69
|
-
|
70
|
-
api_expects(:repositories, :update) do |p|
|
71
|
-
p['id'] == 1 && p['name'] == 'rep1'
|
72
|
-
end
|
73
|
-
|
74
|
-
run_cmd(%w(repository update --name repo1 --product-id 3 --new-name rep1))
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
describe 'resolves product ID' do
|
79
|
-
it 'by requiring organization options' do
|
80
|
-
api_expects_no_call
|
81
|
-
result = run_cmd(%w(repository update --name repo1 --product prod1 --new-name rep1))
|
82
|
-
assert(result.err[/--organization-id, --organization, --organization-label is required/],
|
83
|
-
"Organization option requirements must be validated")
|
84
|
-
end
|
85
|
-
|
86
|
-
it 'by organization ID' do
|
87
|
-
ex = api_expects(:products, :index) do |p|
|
88
|
-
p['name'] == 'prod3' && p['organization_id'] == '5'
|
89
|
-
end
|
90
|
-
ex.returns(index_response([{'id' => 3}]))
|
91
|
-
|
92
|
-
ex = api_expects(:repositories, :index) do |p|
|
93
|
-
p['name'] == 'repo1' && p['product_id'] == 3
|
94
|
-
end
|
95
|
-
ex.returns(index_response([{'id' => 1}]))
|
96
|
-
|
97
|
-
api_expects(:repositories, :update) do |p|
|
98
|
-
p['id'] == 1 && p['name'] == 'rep1'
|
99
|
-
end
|
100
|
-
|
101
|
-
run_cmd(%w(repository update --name repo1 --product prod3 --organization-id 5
|
102
|
-
--new-name rep1))
|
103
|
-
end
|
104
|
-
|
105
|
-
it 'by organization name' do
|
106
|
-
expect_organization_search('org5', 5)
|
107
|
-
|
108
|
-
ex = api_expects(:products, :index) do |p|
|
109
|
-
p['name'] == 'prod3' && p['organization_id'] == 5
|
110
|
-
end
|
111
|
-
ex.returns(index_response([{'id' => 3}]))
|
112
|
-
|
113
|
-
ex = api_expects(:repositories, :index) do |p|
|
114
|
-
p['name'] == 'repo1' && p['product_id'] == 3
|
115
|
-
end
|
116
|
-
ex.returns(index_response([{'id' => 1}]))
|
117
|
-
|
118
|
-
api_expects(:repositories, :update) do |p|
|
119
|
-
p['id'] == 1 && p['name'] == 'rep1'
|
120
|
-
end
|
121
|
-
|
122
|
-
run_cmd(%w(repository update --name repo1 --product prod3 --organization org5
|
123
|
-
--new-name rep1))
|
124
|
-
end
|
125
|
-
|
126
|
-
it 'by organization label' do
|
127
|
-
expect_organization_search('org5', 5, field: 'label')
|
128
|
-
|
129
|
-
ex = api_expects(:products, :index) do |p|
|
130
|
-
p['name'] == 'prod3' && p['organization_id'] == 5
|
131
|
-
end
|
132
|
-
ex.returns(index_response([{'id' => 3}]))
|
133
|
-
|
134
|
-
ex = api_expects(:repositories, :index) do |p|
|
135
|
-
p['name'] == 'repo1' && p['product_id'] == 3
|
136
|
-
end
|
137
|
-
ex.returns(index_response([{'id' => 1}]))
|
138
|
-
|
139
|
-
api_expects(:repositories, :update) do |p|
|
140
|
-
p['id'] == 1 && p['name'] == 'rep1'
|
141
|
-
end
|
142
|
-
|
143
|
-
run_cmd(%w(repository update --name repo1 --product prod3 --organization-label org5
|
144
|
-
--new-name rep1))
|
145
|
-
end
|
146
|
-
end
|
147
|
-
end
|
148
|
-
end
|
149
|
-
# rubocop:enable ModuleLength
|
@@ -1,368 +0,0 @@
|
|
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
|
@@ -1,18 +0,0 @@
|
|
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
|
@@ -1,42 +0,0 @@
|
|
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
|
-
expect_repository_set_search('reposet1', 1, product_id: 3)
|
36
|
-
api_expects(:repository_sets, :disable)
|
37
|
-
.with_params('id' => 1)
|
38
|
-
assert_success run_cmd(%w(repository-set disable --name reposet1 --product-id 3))
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,42 +0,0 @@
|
|
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
|
@@ -1,17 +0,0 @@
|
|
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
|
@@ -1,18 +0,0 @@
|
|
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
|
@@ -1,20 +0,0 @@
|
|
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
|