hammer_cli_katello 0.0.26 → 0.1.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/activation_key.rb +23 -43
- data/lib/hammer_cli_katello/associating_commands.rb +3 -5
- data/lib/hammer_cli_katello/capsule.rb +1 -3
- data/lib/hammer_cli_katello/commands.rb +1 -7
- data/lib/hammer_cli_katello/content_view.rb +6 -3
- data/lib/hammer_cli_katello/content_view_name_resolvable.rb +21 -0
- data/lib/hammer_cli_katello/content_view_puppet_module.rb +11 -7
- data/lib/hammer_cli_katello/content_view_version.rb +30 -29
- data/lib/hammer_cli_katello/erratum.rb +0 -1
- data/lib/hammer_cli_katello/exception_handler.rb +0 -2
- data/lib/hammer_cli_katello/filter.rb +11 -3
- data/lib/hammer_cli_katello/filter_rule.rb +8 -2
- data/lib/hammer_cli_katello/foreman_search_options_creators.rb +71 -0
- data/lib/hammer_cli_katello/gpg_key.rb +0 -5
- data/lib/hammer_cli_katello/host.rb +1 -0
- data/lib/hammer_cli_katello/host_collection.rb +48 -16
- data/lib/hammer_cli_katello/host_errata.rb +0 -1
- data/lib/hammer_cli_katello/host_extensions.rb +56 -0
- data/lib/hammer_cli_katello/host_package.rb +0 -3
- data/lib/hammer_cli_katello/host_package_group.rb +0 -3
- data/lib/hammer_cli_katello/host_subscription.rb +67 -1
- data/lib/hammer_cli_katello/hostgroup.rb +2 -0
- data/lib/hammer_cli_katello/hostgroup_extensions.rb +48 -0
- data/lib/hammer_cli_katello/i18n.rb +0 -3
- data/lib/hammer_cli_katello/id_resolver.rb +25 -16
- data/lib/hammer_cli_katello/katello_environment_name_resolvable.rb +4 -3
- data/lib/hammer_cli_katello/lifecycle_environment.rb +0 -3
- data/lib/hammer_cli_katello/lifecycle_environment_name_resolvable.rb +4 -3
- data/lib/hammer_cli_katello/organization.rb +0 -3
- data/lib/hammer_cli_katello/organization_options.rb +12 -0
- data/lib/hammer_cli_katello/ostree_branch.rb +0 -1
- data/lib/hammer_cli_katello/output/fields.rb +0 -2
- data/lib/hammer_cli_katello/output/formatters.rb +0 -4
- data/lib/hammer_cli_katello/package.rb +0 -1
- data/lib/hammer_cli_katello/package_group.rb +0 -1
- data/lib/hammer_cli_katello/ping.rb +0 -6
- data/lib/hammer_cli_katello/product.rb +1 -7
- data/lib/hammer_cli_katello/puppet_module.rb +0 -1
- data/lib/hammer_cli_katello/repository.rb +36 -35
- data/lib/hammer_cli_katello/repository_scoped_to_product.rb +0 -4
- data/lib/hammer_cli_katello/repository_set.rb +0 -3
- data/lib/hammer_cli_katello/search_options_creators.rb +40 -18
- data/lib/hammer_cli_katello/subscription.rb +20 -13
- data/lib/hammer_cli_katello/sync_plan.rb +4 -8
- data/lib/hammer_cli_katello/version.rb +1 -1
- data/lib/hammer_cli_katello.rb +21 -26
- data/test/data/3.0/foreman_api.json +1 -1
- data/test/data/3.2/foreman_api.json +1 -0
- data/test/data/Readme.md +5 -0
- data/test/functional/activaton_key/add_host_collection_test.rb +62 -0
- data/test/functional/activaton_key/create_test.rb +33 -0
- data/test/functional/activaton_key/list_test.rb +15 -16
- data/test/functional/activaton_key/product_content_test.rb +23 -0
- data/test/functional/activaton_key/remove_host_collection_test.rb +62 -0
- data/test/functional/activaton_key/subscriptions_test.rb +57 -0
- data/test/functional/activaton_key/update_test.rb +26 -0
- data/test/functional/capsule/content/cancel_synchronization_test.rb +1 -1
- data/test/functional/capsule/content/capsule_content_helpers.rb +0 -2
- data/test/functional/content_view/add_content_view_version_test.rb +34 -0
- data/test/functional/content_view/add_repository_test.rb +20 -0
- data/test/functional/content_view/content_view_helpers.rb +0 -2
- data/test/functional/content_view/create_test.rb +3 -3
- data/test/functional/content_view/filter/create_test.rb +63 -0
- data/test/functional/content_view/list_test.rb +23 -20
- data/test/functional/content_view/publish_test.rb +23 -0
- data/test/functional/content_view/puppet_module/add_test.rb +23 -0
- data/test/functional/content_view/remove_content_view_version_test.rb +34 -0
- data/test/functional/content_view/version/incremental_update_test.rb +4 -4
- data/test/functional/content_view/version/list_test.rb +44 -0
- data/test/functional/content_view/version/promote_test.rb +35 -0
- data/test/functional/filter_rule/create_test.rb +20 -0
- data/test/functional/host/errata/apply_test.rb +5 -4
- data/test/functional/host/extensions/data/host.json +310 -0
- data/test/functional/host/extensions/data/host_list.json +115 -0
- data/test/functional/host/extensions/info_test.rb +27 -0
- data/test/functional/host/extensions/list_test.rb +21 -0
- data/test/functional/host/host_helpers.rb +0 -2
- 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/register_test.rb +2 -2
- data/test/functional/host/subscription/remove_test.rb +52 -0
- data/test/functional/host_collection/add_host_test.rb +57 -0
- data/test/functional/host_collection/copy_test.rb +64 -0
- data/test/functional/host_collection/create_test.rb +43 -0
- data/test/functional/host_collection/delete_test.rb +57 -0
- data/test/functional/host_collection/hosts_test.rb +40 -0
- data/test/functional/host_collection/info_test.rb +57 -0
- data/test/functional/host_collection/list_test.rb +42 -0
- data/test/functional/host_collection/remove_host_test.rb +57 -0
- data/test/functional/host_collection/update_test.rb +57 -0
- data/test/functional/hostgroup/create_test.rb +55 -0
- data/test/functional/hostgroup/data/hostgroup.json +48 -0
- data/test/functional/hostgroup/info_test.rb +30 -0
- data/test/functional/hostgroup/update_test.rb +55 -0
- data/test/functional/lifecycle_environment/lifecycle_environment_helpers.rb +0 -2
- data/test/functional/organization/organization_helpers.rb +0 -2
- 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 +14 -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_test.rb +46 -0
- data/test/functional/repository/info_test.rb +3 -3
- data/test/functional/repository/list_test.rb +14 -13
- data/test/functional/repository/remove_content_test.rb +18 -0
- data/test/functional/repository/repository_helpers.rb +9 -3
- data/test/functional/repository/synchronize_test.rb +3 -3
- data/test/functional/repository/upload_test.rb +17 -5
- data/test/functional/subscription/list_test.rb +92 -0
- data/test/functional/sync_plan/sync_plan_helpers.rb +8 -0
- data/test/test_helper.rb +3 -3
- data/test/unit/id_resolver_test.rb +17 -2
- data/test/unit/search_options_creators_test.rb +49 -12
- metadata +105 -7
- data/lib/hammer_cli_katello/content_host.rb +0 -111
data/test/data/Readme.md
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'hammer_cli_katello/associating_commands'
|
3
|
+
|
4
|
+
module HammerCLIKatello
|
5
|
+
module AssociatingCommands
|
6
|
+
module HostCollection
|
7
|
+
describe AddHostCollectionCommand do
|
8
|
+
it 'allows minimal options' do
|
9
|
+
ex = api_expects(:activation_keys, :show) do |p|
|
10
|
+
p[:id] == '1'
|
11
|
+
end
|
12
|
+
ex.returns('id' => 1, host_collections: [{}])
|
13
|
+
|
14
|
+
api_expects(:activation_keys, :update) do |p|
|
15
|
+
p['id'] == '1' && p['organization_id'] == 1 && p['host_collection_ids'] == ['3']
|
16
|
+
end
|
17
|
+
|
18
|
+
run_cmd(%w(activation-key add-host-collection --organization-id 1
|
19
|
+
--host-collection-id 3 --id 1))
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'allows resolving host collection name' do
|
23
|
+
ex = api_expects(:host_collections, :index) do |p|
|
24
|
+
p['name'] == 'hc3' && p['organization_id'] == 1
|
25
|
+
end
|
26
|
+
ex.returns(index_response([{'id' => 3}]))
|
27
|
+
|
28
|
+
ex = api_expects(:activation_keys, :show) do |p|
|
29
|
+
p[:id] == '1'
|
30
|
+
end
|
31
|
+
ex.returns(id: 1, host_collection_ids: [])
|
32
|
+
|
33
|
+
api_expects(:activation_keys, :update) do |p|
|
34
|
+
p['id'] == '1' && p['organization_id'] == 1 && p['host_collection_ids'] == ['3']
|
35
|
+
end
|
36
|
+
|
37
|
+
run_cmd(%w(activation-key add-host-collection --organization-id 1
|
38
|
+
--host-collection hc3 --id 1))
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'allows resolving activation key name' do
|
42
|
+
ex = api_expects(:activation_keys, :index) do |p|
|
43
|
+
p['name'] == 'ak1' && p['organization_id'] == 1
|
44
|
+
end
|
45
|
+
ex.at_least_once.returns(index_response([{'id' => 1}]))
|
46
|
+
|
47
|
+
ex = api_expects(:activation_keys, :show) do |p|
|
48
|
+
p[:id] == 1
|
49
|
+
end
|
50
|
+
ex.returns(id: 1, host_collections: [])
|
51
|
+
|
52
|
+
api_expects(:activation_keys, :update) do |p|
|
53
|
+
p['id'] == 1 && p['organization_id'] == 1 && p['host_collection_ids'] == ['3']
|
54
|
+
end
|
55
|
+
|
56
|
+
run_cmd(%w(activation-key add-host-collection --organization-id 1
|
57
|
+
--host-collection-id 3 --name ak1))
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'hammer_cli_katello/activation_key'
|
3
|
+
|
4
|
+
module HammerCLIKatello
|
5
|
+
describe ActivationKeyCommand do
|
6
|
+
describe CreateCommand do
|
7
|
+
it 'allows promoting a content view' do
|
8
|
+
ex = api_expects(:organizations, :index) do |p|
|
9
|
+
p[:search] == "name = \"org1\""
|
10
|
+
end
|
11
|
+
ex.at_least_once.returns(index_response([{'id' => 1}]))
|
12
|
+
|
13
|
+
ex = api_expects(:lifecycle_environments, :index) do |p|
|
14
|
+
p['organization_id'] == 1 && p['name'] == 'test'
|
15
|
+
end
|
16
|
+
ex.returns(index_response([{'id' => 9}]))
|
17
|
+
|
18
|
+
ex = api_expects(:content_views, :index) do |p|
|
19
|
+
p['name'] == 'cv' && p['organization_id'] == 1
|
20
|
+
end
|
21
|
+
ex.returns(index_response([{'id' => 3}]))
|
22
|
+
|
23
|
+
api_expects(:activation_keys, :create) do |p|
|
24
|
+
p['name'] == 'ak' && p['environment_id'] == 9 && p['organization_id'] == 1 &&
|
25
|
+
p['content_view_id'] == 3
|
26
|
+
end
|
27
|
+
|
28
|
+
run_cmd(%w(activation-key create --organization org1 --name ak --content-view cv
|
29
|
+
--lifecycle-environment test --unlimited-hosts))
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -1,8 +1,6 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), '../test_helper')
|
2
2
|
require File.join(File.dirname(__FILE__), '../lifecycle_environment/lifecycle_environment_helpers')
|
3
3
|
|
4
|
-
require 'hammer_cli_katello/content_view_puppet_module'
|
5
|
-
|
6
4
|
describe 'listing activation-keys' do
|
7
5
|
include LifecycleEnvironmentHelpers
|
8
6
|
|
@@ -12,19 +10,20 @@ describe 'listing activation-keys' do
|
|
12
10
|
|
13
11
|
let(:org_id) { 1 }
|
14
12
|
let(:lifecycle_env_id) { 1 }
|
15
|
-
let(:empty_response) do
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
"
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
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
|
+
}
|
28
27
|
end
|
29
28
|
|
30
29
|
it "lists an organizations activation-keys" do
|
@@ -49,7 +48,7 @@ ID | NAME | HOST LIMIT | LIFECYCLE ENVIRONMENT | CONTENT VIEW
|
|
49
48
|
it "lists the activation-keys belonging to a lifecycle environment by name" do
|
50
49
|
params = ["--organization-id=#{org_id}", '--lifecycle-environment=test']
|
51
50
|
|
52
|
-
expect_lifecycle_environment_search(org_id, 'test', lifecycle_env_id)
|
51
|
+
expect_lifecycle_environment_search(org_id, 'test', lifecycle_env_id)
|
53
52
|
|
54
53
|
ex = api_expects(:activation_keys, :index, 'lifecycle activation-key list') do |par|
|
55
54
|
par['organization_id'] == org_id && par['page'] == 1 &&
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../test_helper')
|
2
|
+
|
3
|
+
describe 'listing available product content' do
|
4
|
+
let(:activation_key_id) { 1 }
|
5
|
+
let(:empty_response_table) do
|
6
|
+
<<eostring
|
7
|
+
---|------|------|-----|---------|-------|----------|---------
|
8
|
+
ID | NAME | TYPE | URL | GPG KEY | LABEL | ENABLED? | OVERRIDE
|
9
|
+
---|------|------|-----|---------|-------|----------|---------
|
10
|
+
eostring
|
11
|
+
end
|
12
|
+
|
13
|
+
it "lists content available for an activation key" do
|
14
|
+
ex = api_expects(:activation_keys, :product_content) do |p|
|
15
|
+
p['id'] = activation_key_id
|
16
|
+
end
|
17
|
+
ex.returns(index_response([]))
|
18
|
+
assert_cmd(
|
19
|
+
success_result(empty_response_table),
|
20
|
+
run_cmd(%w(activation-key product-content --id 1))
|
21
|
+
)
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'hammer_cli_katello/associating_commands'
|
3
|
+
|
4
|
+
module HammerCLIKatello
|
5
|
+
module AssociatingCommands
|
6
|
+
module HostCollection
|
7
|
+
describe RemoveHostCollectionCommand do
|
8
|
+
it 'allows minimal options' do
|
9
|
+
ex = api_expects(:activation_keys, :show) do |p|
|
10
|
+
p[:id] == '1'
|
11
|
+
end
|
12
|
+
ex.returns('id' => 1, host_collections: [{'id' => 3}])
|
13
|
+
|
14
|
+
api_expects(:activation_keys, :update) do |p|
|
15
|
+
p['id'] == '1' && p['organization_id'] == 1 && p['host_collection_ids'] == []
|
16
|
+
end
|
17
|
+
|
18
|
+
run_cmd(%w(activation-key remove-host-collection --organization-id 1
|
19
|
+
--host-collection-id 3 --id 1))
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'allows resolving host collection name' do
|
23
|
+
ex = api_expects(:host_collections, :index) do |p|
|
24
|
+
p['name'] == 'hc3' && p['organization_id'] == 1
|
25
|
+
end
|
26
|
+
ex.returns(index_response([{id: 1}]))
|
27
|
+
|
28
|
+
ex = api_expects(:activation_keys, :show) do |p|
|
29
|
+
p[:id] == '1'
|
30
|
+
end
|
31
|
+
ex.returns(id: 1, host_collections: [{'id' => 3}])
|
32
|
+
|
33
|
+
api_expects(:activation_keys, :update) do |p|
|
34
|
+
p['id'] == '1' && p['organization_id'] == 1 && p['host_collection_ids'] == []
|
35
|
+
end
|
36
|
+
|
37
|
+
run_cmd(%w(activation-key remove-host-collection --organization-id 1
|
38
|
+
--host-collection hc3 --id 1))
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'allows resolving activation key name' do
|
42
|
+
ex = api_expects(:activation_keys, :index) do |p|
|
43
|
+
p['name'] == 'ak1' && p['organization_id'] == 1
|
44
|
+
end
|
45
|
+
ex.at_least_once.returns(index_response([{'id' => 1}]))
|
46
|
+
|
47
|
+
ex = api_expects(:activation_keys, :show) do |p|
|
48
|
+
p[:id] == 1
|
49
|
+
end
|
50
|
+
ex.returns(id: 1, host_collections: [{'id' => 3}])
|
51
|
+
|
52
|
+
api_expects(:activation_keys, :update) do |p|
|
53
|
+
p['id'] == 1 && p['organization_id'] == 1 && p['host_collection_ids'] == []
|
54
|
+
end
|
55
|
+
|
56
|
+
run_cmd(%w(activation-key remove-host-collection --organization-id 1
|
57
|
+
--host-collection-id 3 --name ak1))
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'hammer_cli_katello/activation_key'
|
3
|
+
|
4
|
+
module HammerCLIKatello
|
5
|
+
describe ActivationKeyCommand::SubscriptionsCommand do
|
6
|
+
it 'requires organization options' do
|
7
|
+
expected_error = "Could not find organization"
|
8
|
+
result = run_cmd(%w(activation-key subscriptions --id 1))
|
9
|
+
assert_equal(result.err[/#{expected_error}/], expected_error)
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'allows organization name' do
|
13
|
+
api_expects(:organizations, :index) { |par| par[:search] == "name = \"org1\"" }
|
14
|
+
.returns(index_response([{'id' => 1}]))
|
15
|
+
|
16
|
+
api_expects(:subscriptions, :index) { |par| par['organization_id'].to_i == 1 }
|
17
|
+
|
18
|
+
run_cmd(%w(activation-key subscriptions --id 1 --organization org1))
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'allows organization label' do
|
22
|
+
api_expects(:organizations, :index) { |par| par[:search] == "label = \"org1\"" }
|
23
|
+
.returns(index_response([{'id' => 1}]))
|
24
|
+
|
25
|
+
api_expects(:subscriptions, :index) { |par| par['organization_id'].to_i == 1 }
|
26
|
+
|
27
|
+
run_cmd(%w(activation-key subscriptions --id 1 --organization-label org1))
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'lists subscriptions available for the activation key' do
|
31
|
+
api_expects(:subscriptions, :index) do |p|
|
32
|
+
p['available_for'] == 'activation_key'
|
33
|
+
end
|
34
|
+
run_cmd(%w(activation-key subscriptions --organization-id 1 --id 1
|
35
|
+
--available-for activation_key))
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'lists subscriptions used by the activation key' do
|
39
|
+
api_expects(:subscriptions, :index) { |p| p['activation_key_id'] == 1 }
|
40
|
+
run_cmd(%w(activation-key subscriptions --organization-id 1 --id 1))
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'allows activation_key_name' do
|
44
|
+
api_expects(:activation_keys, :index) { |p| p['name'] == 'ak1' }
|
45
|
+
.returns(index_response([{'id' => 1}]))
|
46
|
+
api_expects(:subscriptions, :index) { |p| p['activation_key_id'] == 1 }
|
47
|
+
run_cmd(%w(activation-key subscriptions --organization-id 1 --name ak1))
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'allows subscriptions to be added to an activation key' do
|
51
|
+
api_expects(:activation_keys, :add_subscriptions) do |p|
|
52
|
+
p['id'] == '1' && p['subscription_id'] == '3'
|
53
|
+
end
|
54
|
+
run_cmd(%w(activation-key add-subscription --id 1 --subscription-id 3))
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'hammer_cli_katello/activation_key'
|
3
|
+
|
4
|
+
module HammerCLIKatello
|
5
|
+
describe ActivationKeyCommand do
|
6
|
+
describe UpdateCommand do
|
7
|
+
it 'allows promoting a content view' do
|
8
|
+
ex = api_expects(:organizations, :index) do |p|
|
9
|
+
p[:search] == "name = \"org1\""
|
10
|
+
end
|
11
|
+
ex.at_least_once.returns(index_response([{'id' => 1}]))
|
12
|
+
|
13
|
+
ex = api_expects(:activation_keys, :index) do |p|
|
14
|
+
p['name'] == 'ak' && p['organization_id'] == 1
|
15
|
+
end
|
16
|
+
ex.returns(index_response([{'id' => 6}]))
|
17
|
+
|
18
|
+
api_expects(:activation_keys, :update) do |p|
|
19
|
+
p['id'] == 6 && p['organization_id'] == 1
|
20
|
+
end
|
21
|
+
|
22
|
+
run_cmd(%w(activation-key update --organization org1 --name ak --auto-attach false))
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -8,7 +8,7 @@ describe 'capsule content cancel-synchronization' do
|
|
8
8
|
@cmd = ['capsule', 'content', 'cancel-synchronization']
|
9
9
|
end
|
10
10
|
|
11
|
-
MESSAGE = "There's no running synchronization for this capsule."
|
11
|
+
MESSAGE = "There's no running synchronization for this capsule.".freeze
|
12
12
|
|
13
13
|
it "triggers the cancel" do
|
14
14
|
expected_result = success_result("#{MESSAGE}\n")
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'hammer_cli_katello/content_view'
|
3
|
+
|
4
|
+
module HammerCLIKatello
|
5
|
+
describe ContentView::AddContentViewVersionCommand do
|
6
|
+
it 'allows minimal options' do
|
7
|
+
ex = api_expects(:content_views, :show) do |p|
|
8
|
+
p[:id] == '1'
|
9
|
+
end
|
10
|
+
ex.returns('id' => 1, 'component_ids' => [1, 3])
|
11
|
+
api_expects(:content_views, :update) do |p|
|
12
|
+
p['id'] == '1' && p['component_ids'] == %w(1 3 6)
|
13
|
+
end
|
14
|
+
run_cmd(%w(content-view add-version --id 1 --content-view-version-id 6))
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'resolves content view version ID' do
|
18
|
+
ex = api_expects(:content_view_versions, :index) do |p|
|
19
|
+
p['content_view_id'] == '3' && p['version'] == '2.1'
|
20
|
+
end
|
21
|
+
ex.returns(index_response([{'id' => 6}]))
|
22
|
+
ex.returns('id' => 1, 'component_ids' => [1, 3])
|
23
|
+
ex = api_expects(:content_views, :show) do |p|
|
24
|
+
p[:id] == '1'
|
25
|
+
end
|
26
|
+
ex.returns('id' => 1, 'component_ids' => [1, 3])
|
27
|
+
api_expects(:content_views, :update) do |p|
|
28
|
+
p['id'] == '1' && p['component_ids'] == %w(1 3 6)
|
29
|
+
end
|
30
|
+
run_cmd(%w(content-view add-version --id 1 --content-view-version-content-view-id 3
|
31
|
+
--content-view-version 2.1))
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
|
3
|
+
module HammerCLIKatello
|
4
|
+
describe ContentView do
|
5
|
+
describe 'AddRepositoryCommand' do
|
6
|
+
it 'allows adding a repository by ID' do
|
7
|
+
ex = api_expects(:organizations, :index) do |p|
|
8
|
+
p[:search] == "name = \"org1\""
|
9
|
+
end
|
10
|
+
ex.returns(index_response([{'id' => 1}]))
|
11
|
+
|
12
|
+
api_expects(:content_views, :index) do |p|
|
13
|
+
p['name'] == 'cv' && p['organization_id'] == 1
|
14
|
+
end
|
15
|
+
|
16
|
+
run_cmd(%w(content-view add-repository --organization org1 --name cv --repository-id 1))
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -1,10 +1,8 @@
|
|
1
1
|
module ContentViewHelpers
|
2
|
-
|
3
2
|
def expect_content_view_search(org_id, name, id)
|
4
3
|
ex = api_expects(:content_views, :index, 'Find the content view') do |par|
|
5
4
|
par['name'] == name && par['organization_id'] == org_id
|
6
5
|
end
|
7
6
|
ex.returns(index_response([{'id' => id}]))
|
8
7
|
end
|
9
|
-
|
10
8
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require_relative '../test_helper'
|
2
2
|
|
3
3
|
# Workaround for issue #14289
|
4
4
|
require 'hammer_cli_katello/content_view_puppet_module'
|
@@ -46,7 +46,7 @@ describe 'content-view create' do
|
|
46
46
|
|
47
47
|
api_repositories = api_expects(:repositories, :index,
|
48
48
|
'Find repositories belonging to product') do |par|
|
49
|
-
par['product_id'] == product['id']
|
49
|
+
par['product_id'] == product['id']
|
50
50
|
end
|
51
51
|
api_repositories.returns(repositories)
|
52
52
|
|
@@ -74,7 +74,7 @@ describe 'content-view create' do
|
|
74
74
|
|
75
75
|
api_repositories = api_expects(:repositories, :index,
|
76
76
|
'Find repositories belonging to product') do |par|
|
77
|
-
par['product_id'] == product['id']
|
77
|
+
par['product_id'] == product['id']
|
78
78
|
end
|
79
79
|
api_repositories.returns(repositories)
|
80
80
|
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require_relative '../../test_helper'
|
2
|
+
require_relative '../../repository/repository_helpers'
|
3
|
+
|
4
|
+
describe 'content-view filter create' do
|
5
|
+
include RepositoryHelpers
|
6
|
+
before do
|
7
|
+
@cmd = %w(content-view filter create)
|
8
|
+
@base_params = ["--organization-id=#{org_id}", "--name=#{filter_name}", \
|
9
|
+
"--content-view-id=#{content_view_id}", "--type=rpm"]
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:org_id) { 1 }
|
13
|
+
let(:filter_name) { 'test_filter' }
|
14
|
+
let(:content_view_id) { 1 }
|
15
|
+
let(:repositories) do
|
16
|
+
[
|
17
|
+
{'name' => 'repo-1', 'id' => 1},
|
18
|
+
{'name' => 'repo-2', 'id' => 2},
|
19
|
+
{'name' => 'repo-3', 'id' => 3}
|
20
|
+
]
|
21
|
+
end
|
22
|
+
let(:repo_ids) { repositories.map { |repo| repo['id'] } }
|
23
|
+
let(:repo_names) { repositories.map { |repo| repo['name'] } }
|
24
|
+
|
25
|
+
it 'creates a content-view filter with repository ids' do
|
26
|
+
ids = repo_ids.join(',')
|
27
|
+
params = %W(--repository-ids=#{ids})
|
28
|
+
|
29
|
+
ex = api_expects(:content_view_filters, :create, 'Create content-view filter') do |par|
|
30
|
+
par['name'] == filter_name && par['repository_ids'] == repo_ids
|
31
|
+
true
|
32
|
+
end
|
33
|
+
|
34
|
+
ex.returns({})
|
35
|
+
|
36
|
+
expected_result = success_result("Filter created\n")
|
37
|
+
result = run_cmd(@cmd + @base_params + params)
|
38
|
+
assert_cmd(expected_result, result)
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'creates a content-view filter with repository names' do
|
42
|
+
params = %W(--repositories=#{repo_names.join(',')})
|
43
|
+
|
44
|
+
expect_repositories_search(org_id.to_s, repo_names, repo_ids)
|
45
|
+
|
46
|
+
api_expects(:content_view_filters, :create, "Create content-view filter") do |par|
|
47
|
+
par['name'] == filter_name && par['repository_ids'] == repo_ids &&
|
48
|
+
par['type'] == 'rpm'
|
49
|
+
end
|
50
|
+
|
51
|
+
expected_result = success_result("Filter created\n")
|
52
|
+
result = run_cmd(@cmd + @base_params + params)
|
53
|
+
assert_cmd(expected_result, result)
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should fail with no organization specified' do
|
57
|
+
ids = repo_ids.join(',')
|
58
|
+
params = ["--repositories=#{ids}", "--name=#{filter_name}", \
|
59
|
+
"--content-view-id=#{content_view_id}", "--type=rpm"]
|
60
|
+
result = run_cmd(@cmd + params)
|
61
|
+
assert(result.err[/--organization-id, --organization, --organization-label is required/])
|
62
|
+
end
|
63
|
+
end
|
@@ -12,19 +12,20 @@ describe 'listing content-views' do
|
|
12
12
|
|
13
13
|
let(:org_id) { 1 }
|
14
14
|
let(:lifecycle_env_id) { 1 }
|
15
|
-
let(:empty_response) do
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
"
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
15
|
+
let(:empty_response) do
|
16
|
+
{
|
17
|
+
"total" => 0,
|
18
|
+
"subtotal" => 0,
|
19
|
+
"page" => "1",
|
20
|
+
"per_page" => "1000",
|
21
|
+
"error" => nil,
|
22
|
+
"search" => nil,
|
23
|
+
"sort" => {
|
24
|
+
"by" => nil,
|
25
|
+
"order" => nil
|
26
|
+
},
|
27
|
+
"results" => []
|
28
|
+
}
|
28
29
|
end
|
29
30
|
|
30
31
|
it "lists an organizations content-views" do
|
@@ -36,9 +37,10 @@ describe 'listing content-views' do
|
|
36
37
|
end
|
37
38
|
|
38
39
|
ex.returns(empty_response)
|
39
|
-
expected_result = success_result(
|
40
|
-
|
41
|
-
|
40
|
+
expected_result = success_result(
|
41
|
+
"----------------|------|-------|-----------|----------------|---------------
|
42
|
+
CONTENT VIEW ID | NAME | LABEL | COMPOSITE | LAST PUBLISHED | REPOSITORY IDS
|
43
|
+
----------------|------|-------|-----------|----------------|---------------
|
42
44
|
")
|
43
45
|
|
44
46
|
result = run_cmd(@cmd + params)
|
@@ -48,7 +50,7 @@ CONTENT VIEW ID | NAME | LABEL | COMPOSITE | REPOSITORY IDS
|
|
48
50
|
it "lists the content-views belonging to a lifecycle-environment by name" do
|
49
51
|
params = ["--organization-id=#{org_id}", '--lifecycle-environment=test']
|
50
52
|
|
51
|
-
expect_lifecycle_environment_search(org_id, 'test', lifecycle_env_id)
|
53
|
+
expect_lifecycle_environment_search(org_id, 'test', lifecycle_env_id)
|
52
54
|
|
53
55
|
ex = api_expects(:content_views, :index, 'lifecycles content-views list') do |par|
|
54
56
|
par['organization_id'] == org_id && par['page'] == 1 &&
|
@@ -56,9 +58,10 @@ CONTENT VIEW ID | NAME | LABEL | COMPOSITE | REPOSITORY IDS
|
|
56
58
|
end
|
57
59
|
|
58
60
|
ex.returns(empty_response)
|
59
|
-
expected_result = success_result(
|
60
|
-
|
61
|
-
|
61
|
+
expected_result = success_result(
|
62
|
+
"----------------|------|-------|-----------|----------------|---------------
|
63
|
+
CONTENT VIEW ID | NAME | LABEL | COMPOSITE | LAST PUBLISHED | REPOSITORY IDS
|
64
|
+
----------------|------|-------|-----------|----------------|---------------
|
62
65
|
")
|
63
66
|
|
64
67
|
result = run_cmd(@cmd + params)
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
|
3
|
+
module HammerCLIKatello
|
4
|
+
describe ContentViewPuppetModule do
|
5
|
+
it 'allows adding a puppet module' do
|
6
|
+
ex = api_expects(:organizations, :index) do |p|
|
7
|
+
p[:search] == "name = \"org1\""
|
8
|
+
end
|
9
|
+
ex.returns(index_response([{'id' => 1}]))
|
10
|
+
|
11
|
+
ex = api_expects(:content_views, :index) do |p|
|
12
|
+
p['name'] == 'cv' && p['organization_id'] == 1
|
13
|
+
end
|
14
|
+
ex.returns(index_response([{'id' => 3}]))
|
15
|
+
|
16
|
+
api_expects(:content_views, :publish) do |p|
|
17
|
+
p['id'] == 3
|
18
|
+
end
|
19
|
+
|
20
|
+
run_cmd(%w(content-view publish --organization org1 --name cv --async))
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require_relative '../../test_helper'
|
2
|
+
|
3
|
+
module HammerCLIKatello
|
4
|
+
describe ContentViewPuppetModule do
|
5
|
+
it 'allows adding a puppet module' do
|
6
|
+
ex = api_expects(:organizations, :index) do |p|
|
7
|
+
p[:search] == "name = \"org1\""
|
8
|
+
end
|
9
|
+
ex.returns(index_response([{'id' => 1}]))
|
10
|
+
|
11
|
+
ex = api_expects(:content_views, :index) do |p|
|
12
|
+
p['name'] == 'cv' && p['organization_id'] == 1
|
13
|
+
end
|
14
|
+
ex.returns(index_response([{'id' => 3}]))
|
15
|
+
|
16
|
+
api_expects(:content_view_puppet_modules, :create) do |p|
|
17
|
+
p['content_view_id'] == 3
|
18
|
+
end
|
19
|
+
|
20
|
+
run_cmd(%w(content-view puppet-module add --organization org1 --content-view cv --id 1))
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'hammer_cli_katello/content_view'
|
3
|
+
|
4
|
+
module HammerCLIKatello
|
5
|
+
describe ContentView::RemoveContentViewVersionCommand do
|
6
|
+
it 'allows minimal options' do
|
7
|
+
ex = api_expects(:content_views, :show) do |p|
|
8
|
+
p[:id] == '1'
|
9
|
+
end
|
10
|
+
ex.returns('id' => 1, 'component_ids' => [1, 3, 6])
|
11
|
+
api_expects(:content_views, :update) do |p|
|
12
|
+
p['id'] == '1' && p['component_ids'] == %w(1 3)
|
13
|
+
end
|
14
|
+
run_cmd(%w(content-view remove-version --id 1 --content-view-version-id 6))
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'resolves content view version ID' do
|
18
|
+
ex = api_expects(:content_view_versions, :index) do |p|
|
19
|
+
p['content_view_id'] == '3' && p['version'] == '2.1'
|
20
|
+
end
|
21
|
+
ex.returns(index_response([{'id' => 6}]))
|
22
|
+
ex.returns('id' => 1, 'component_ids' => [1, 3, 6])
|
23
|
+
ex = api_expects(:content_views, :show) do |p|
|
24
|
+
p[:id] == '1'
|
25
|
+
end
|
26
|
+
ex.returns('id' => 1, 'component_ids' => [1, 3])
|
27
|
+
api_expects(:content_views, :update) do |p|
|
28
|
+
p['id'] == '1' && p['component_ids'] == %w(1 3)
|
29
|
+
end
|
30
|
+
run_cmd(%w(content-view remove-version --id 1 --content-view-version-content-view-id 3
|
31
|
+
--content-view-version 2.1))
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|