hammer_cli_katello 0.1.2 → 0.1.3
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/filter_rule.rb +10 -0
- data/lib/hammer_cli_katello/repository.rb +11 -11
- data/lib/hammer_cli_katello/version.rb +1 -1
- data/test/functional/filter_rule/create_test.rb +79 -0
- data/test/functional/filter_rule/delete_test.rb +104 -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
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7777a95f65993c11aafcdf3e93bd4e62e05a71c
|
4
|
+
data.tar.gz: 10751c77ff38e730bd28edf8a393387ae5ac4551
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 483606e3bfe638f29d98185eb2dc38f2a0704f3e16de14cc4e89aff942f1ad8ea7f5fd60a7939ea17a91a57b56449e3dd3618c9e2e009b92d048dc8774872342
|
7
|
+
data.tar.gz: b043a18647859bba0dadfa79103085f23a3de85a2fb332cff57b082ed20efd3b1b86a69b705148110f0028d7b682dade57ef6fce691b27c681b147831b15be18
|
@@ -5,6 +5,8 @@ module HammerCLIKatello
|
|
5
5
|
desc 'View and manage filter rules'
|
6
6
|
|
7
7
|
class ListCommand < HammerCLIKatello::ListCommand
|
8
|
+
include OrganizationOptions
|
9
|
+
|
8
10
|
output do
|
9
11
|
field :id, _("Rule ID")
|
10
12
|
field :content_view_filter_id, _("Filter ID")
|
@@ -22,6 +24,8 @@ module HammerCLIKatello
|
|
22
24
|
end
|
23
25
|
|
24
26
|
class InfoCommand < HammerCLIKatello::InfoCommand
|
27
|
+
include OrganizationOptions
|
28
|
+
|
25
29
|
output do
|
26
30
|
field :id, _("Rule ID")
|
27
31
|
field :content_view_filter_id, _("Filter ID")
|
@@ -43,6 +47,8 @@ module HammerCLIKatello
|
|
43
47
|
end
|
44
48
|
|
45
49
|
class CreateCommand < HammerCLIKatello::CreateCommand
|
50
|
+
include OrganizationOptions
|
51
|
+
|
46
52
|
success_message _("Filter rule created")
|
47
53
|
failure_message _("Could not create the filter rule")
|
48
54
|
|
@@ -58,6 +64,8 @@ module HammerCLIKatello
|
|
58
64
|
end
|
59
65
|
|
60
66
|
class UpdateCommand < HammerCLIKatello::UpdateCommand
|
67
|
+
include OrganizationOptions
|
68
|
+
|
61
69
|
success_message _("Filter rule updated")
|
62
70
|
failure_message _("Could not update the filter rule")
|
63
71
|
|
@@ -65,6 +73,8 @@ module HammerCLIKatello
|
|
65
73
|
end
|
66
74
|
|
67
75
|
class DeleteCommand < HammerCLIKatello::DeleteCommand
|
76
|
+
include OrganizationOptions
|
77
|
+
|
68
78
|
success_message _("Filter rule deleted")
|
69
79
|
failure_message _("Could not delete the filter rule")
|
70
80
|
|
@@ -29,6 +29,7 @@ module HammerCLIKatello
|
|
29
29
|
field :_redhat_repo, _("Red Hat Repository")
|
30
30
|
field :content_type, _("Content Type")
|
31
31
|
field :checksum_type, _("Checksum Type"), Fields::Field, :hide_blank => true
|
32
|
+
field :_mirror_on_sync, _("Mirror on Sync")
|
32
33
|
field :url, _("URL")
|
33
34
|
field :_publish_via_http, _("Publish Via HTTP")
|
34
35
|
field :full_path, _("Published At")
|
@@ -73,18 +74,22 @@ module HammerCLIKatello
|
|
73
74
|
end
|
74
75
|
|
75
76
|
def extend_data(data)
|
76
|
-
data["_redhat_repo"] = data["product_type"] == "redhat" ? _("yes") : _("no")
|
77
|
-
data["_publish_via_http"] = data["unprotected"] ? _("yes") : _("no")
|
78
|
-
|
79
77
|
if data["content_type"] == "yum" && data["gpg_key"]
|
80
78
|
data["gpg_key_name"] = data["gpg_key"]["name"]
|
81
79
|
end
|
82
80
|
|
83
81
|
setup_sync_state(data)
|
82
|
+
setup_booleans(data)
|
84
83
|
setup_content_counts(data) if data["content_counts"]
|
85
84
|
data
|
86
85
|
end
|
87
86
|
|
87
|
+
def setup_booleans(data)
|
88
|
+
data["_redhat_repo"] = data["product_type"] == "redhat" ? _("yes") : _("no")
|
89
|
+
data["_publish_via_http"] = data["unprotected"] ? _("yes") : _("no")
|
90
|
+
data["_mirror_on_sync"] = data["mirror_on_sync"] ? _("yes") : _("no")
|
91
|
+
end
|
92
|
+
|
88
93
|
def setup_sync_state(data)
|
89
94
|
if data['last_sync']
|
90
95
|
data['_sync_state'] = get_sync_status(data["last_sync"]["result"])
|
@@ -113,14 +118,9 @@ module HammerCLIKatello
|
|
113
118
|
|
114
119
|
def get_sync_status(state)
|
115
120
|
sync_states = {
|
116
|
-
"failed" => _("Failed"),
|
117
|
-
"
|
118
|
-
"
|
119
|
-
"error" => _("Error"),
|
120
|
-
"running" => _("Running"),
|
121
|
-
"waiting" => _("Waiting"),
|
122
|
-
"canceled" => _("Canceled"),
|
123
|
-
"not_synced" => _("Not Synced")
|
121
|
+
"failed" => _("Failed"), "success" => _("Success"), "finished" => _("Finished"),
|
122
|
+
"error" => _("Error"), "running" => _("Running"), "waiting" => _("Waiting"),
|
123
|
+
"canceled" => _("Canceled"), "not_synced" => _("Not Synced")
|
124
124
|
}
|
125
125
|
sync_states[state]
|
126
126
|
end
|
@@ -16,5 +16,84 @@ module HammerCLIKatello
|
|
16
16
|
end
|
17
17
|
run_cmd(%w(content-view filter rule create --content-view-filter-id 1 --names rpm1,rpm2))
|
18
18
|
end
|
19
|
+
|
20
|
+
it 'allows name resolution of filter with content-view-id' do
|
21
|
+
ex = api_expects(:content_view_filters, :index) do |p|
|
22
|
+
p['name'] == 'cvf1' && p['content_view_id'] == 3
|
23
|
+
end
|
24
|
+
ex.returns(index_response([{'id' => 1}]))
|
25
|
+
|
26
|
+
api_expects(:content_view_filter_rules, :create) do |p|
|
27
|
+
p['content_view_filter_id'] == 1 && p['name'] == %w(rule9)
|
28
|
+
end
|
29
|
+
run_cmd(%w(content-view filter rule create --content-view-filter cvf1 --content-view-id 3
|
30
|
+
--name rule9))
|
31
|
+
end
|
32
|
+
|
33
|
+
describe 'organization' do
|
34
|
+
it 'ID can be specified to resolve content view name' do
|
35
|
+
ex = api_expects(:content_views, :index) do |p|
|
36
|
+
p['name'] == 'cv3' && p['organization_id'] == '6'
|
37
|
+
end
|
38
|
+
ex.returns(index_response([{'id' => 3}]))
|
39
|
+
|
40
|
+
ex = api_expects(:content_view_filters, :index) do |p|
|
41
|
+
p['name'] == 'cvf1' && p['content_view_id'] == 3
|
42
|
+
end
|
43
|
+
ex.returns(index_response([{'id' => 1}]))
|
44
|
+
|
45
|
+
api_expects(:content_view_filter_rules, :create) do |p|
|
46
|
+
p['content_view_filter_id'] == 1 && p['name'] == %w(rule9)
|
47
|
+
end
|
48
|
+
run_cmd(%w(content-view filter rule create --content-view-filter cvf1 --organization-id 6
|
49
|
+
--content-view cv3 --name rule9))
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'name can be specified to resolve content view name' do
|
53
|
+
ex = api_expects(:organizations, :index) do |p|
|
54
|
+
p[:search] == "name = \"org6\""
|
55
|
+
end
|
56
|
+
ex.returns(index_response([{'id' => 6}]))
|
57
|
+
|
58
|
+
ex = api_expects(:content_views, :index) do |p|
|
59
|
+
p['name'] == 'cv3' && p['organization_id'] == 6
|
60
|
+
end
|
61
|
+
ex.returns(index_response([{'id' => 3}]))
|
62
|
+
|
63
|
+
ex = api_expects(:content_view_filters, :index) do |p|
|
64
|
+
p['name'] == 'cvf1' && p['content_view_id'] == 3
|
65
|
+
end
|
66
|
+
ex.returns(index_response([{'id' => 1}]))
|
67
|
+
|
68
|
+
api_expects(:content_view_filter_rules, :create) do |p|
|
69
|
+
p['content_view_filter_id'] == 1 && p['name'] == %w(rule9)
|
70
|
+
end
|
71
|
+
run_cmd(%w(content-view filter rule create --content-view-filter cvf1 --organization org6
|
72
|
+
--content-view cv3 --name rule9))
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'label can be specified to resolve content view name' do
|
76
|
+
ex = api_expects(:organizations, :index) do |p|
|
77
|
+
p[:search] == "label = \"org6\""
|
78
|
+
end
|
79
|
+
ex.returns(index_response([{'id' => 6}]))
|
80
|
+
|
81
|
+
ex = api_expects(:content_views, :index) do |p|
|
82
|
+
p['name'] == 'cv3' && p['organization_id'] == 6
|
83
|
+
end
|
84
|
+
ex.returns(index_response([{'id' => 3}]))
|
85
|
+
|
86
|
+
ex = api_expects(:content_view_filters, :index) do |p|
|
87
|
+
p['name'] == 'cvf1' && p['content_view_id'] == 3
|
88
|
+
end
|
89
|
+
ex.returns(index_response([{'id' => 1}]))
|
90
|
+
|
91
|
+
api_expects(:content_view_filter_rules, :create) do |p|
|
92
|
+
p['content_view_filter_id'] == 1 && p['name'] == %w(rule9)
|
93
|
+
end
|
94
|
+
run_cmd(%w(content-view filter rule create --content-view-filter cvf1 --organization-label
|
95
|
+
org6 --content-view cv3 --name rule9))
|
96
|
+
end
|
97
|
+
end
|
19
98
|
end
|
20
99
|
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'hammer_cli_katello/filter_rule'
|
3
|
+
|
4
|
+
module HammerCLIKatello
|
5
|
+
describe FilterRule::DeleteCommand do
|
6
|
+
it 'allows minimal options' do
|
7
|
+
api_expects(:content_view_filter_rules, :destroy) do |p|
|
8
|
+
p['content_view_filter_id'] == 1 && p['id'] == '9'
|
9
|
+
end
|
10
|
+
run_cmd(%w(content-view filter rule delete --content-view-filter-id 1 --id 9))
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'resolves rule ID from rule name and filter ID' do
|
14
|
+
ex = api_expects(:content_view_filter_rules, :index) do |p|
|
15
|
+
p['content_view_filter_id'] == 1 && p['name'] == 'rule9'
|
16
|
+
end
|
17
|
+
ex.returns(index_response([{'id' => 9}]))
|
18
|
+
|
19
|
+
api_expects(:content_view_filter_rules, :destroy) do |p|
|
20
|
+
p['content_view_filter_id'] == 1 && p['id'] == 9
|
21
|
+
end
|
22
|
+
run_cmd(%w(content-view filter rule delete --content-view-filter-id 1 --name rule9))
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'allows name resolution of filter with content-view-id' do
|
26
|
+
ex = api_expects(:content_view_filters, :index) do |p|
|
27
|
+
p['name'] == 'cvf1' && p['content_view_id'] == 3
|
28
|
+
end
|
29
|
+
ex.returns(index_response([{'id' => 1}]))
|
30
|
+
|
31
|
+
api_expects(:content_view_filter_rules, :destroy) do |p|
|
32
|
+
p['content_view_filter_id'] == 1 && p['id'] == '9'
|
33
|
+
end
|
34
|
+
run_cmd(%w(content-view filter rule delete --content-view-filter cvf1 --content-view-id 3
|
35
|
+
--id 9))
|
36
|
+
end
|
37
|
+
|
38
|
+
describe 'organization' do
|
39
|
+
it 'ID can be specified to resolve content view name' do
|
40
|
+
ex = api_expects(:content_views, :index) do |p|
|
41
|
+
p['name'] == 'cv3' && p['organization_id'] == '6'
|
42
|
+
end
|
43
|
+
ex.returns(index_response([{'id' => 3}]))
|
44
|
+
|
45
|
+
ex = api_expects(:content_view_filters, :index) do |p|
|
46
|
+
p['name'] == 'cvf1' && p['content_view_id'] == 3
|
47
|
+
end
|
48
|
+
ex.returns(index_response([{'id' => 1}]))
|
49
|
+
|
50
|
+
api_expects(:content_view_filter_rules, :destroy) do |p|
|
51
|
+
p['content_view_filter_id'] == 1 && p['id'] == '9'
|
52
|
+
end
|
53
|
+
run_cmd(%w(content-view filter rule delete --content-view-filter cvf1 --organization-id 6
|
54
|
+
--content-view cv3 --id 9))
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'name can be specified to resolve content view name' do
|
58
|
+
ex = api_expects(:organizations, :index) do |p|
|
59
|
+
p[:search] == "name = \"org6\""
|
60
|
+
end
|
61
|
+
ex.returns(index_response([{'id' => 6}]))
|
62
|
+
|
63
|
+
ex = api_expects(:content_views, :index) do |p|
|
64
|
+
p['name'] == 'cv3' && p['organization_id'] == 6
|
65
|
+
end
|
66
|
+
ex.returns(index_response([{'id' => 3}]))
|
67
|
+
|
68
|
+
ex = api_expects(:content_view_filters, :index) do |p|
|
69
|
+
p['name'] == 'cvf1' && p['content_view_id'] == 3
|
70
|
+
end
|
71
|
+
ex.returns(index_response([{'id' => 1}]))
|
72
|
+
|
73
|
+
api_expects(:content_view_filter_rules, :destroy) do |p|
|
74
|
+
p['content_view_filter_id'] == 1 && p['id'] == '9'
|
75
|
+
end
|
76
|
+
run_cmd(%w(content-view filter rule delete --content-view-filter cvf1 --organization org6
|
77
|
+
--content-view cv3 --id 9))
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'label can be specified to resolve content view name' do
|
81
|
+
ex = api_expects(:organizations, :index) do |p|
|
82
|
+
p[:search] == "label = \"org6\""
|
83
|
+
end
|
84
|
+
ex.returns(index_response([{'id' => 6}]))
|
85
|
+
|
86
|
+
ex = api_expects(:content_views, :index) do |p|
|
87
|
+
p['name'] == 'cv3' && p['organization_id'] == 6
|
88
|
+
end
|
89
|
+
ex.returns(index_response([{'id' => 3}]))
|
90
|
+
|
91
|
+
ex = api_expects(:content_view_filters, :index) do |p|
|
92
|
+
p['name'] == 'cvf1' && p['content_view_id'] == 3
|
93
|
+
end
|
94
|
+
ex.returns(index_response([{'id' => 1}]))
|
95
|
+
|
96
|
+
api_expects(:content_view_filter_rules, :destroy) do |p|
|
97
|
+
p['content_view_filter_id'] == 1 && p['id'] == '9'
|
98
|
+
end
|
99
|
+
run_cmd(%w(content-view filter rule delete --content-view-filter cvf1 --organization-label
|
100
|
+
org6 --content-view cv3 --id 9))
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'hammer_cli_katello/filter_rule'
|
3
|
+
|
4
|
+
module HammerCLIKatello
|
5
|
+
describe FilterRule::InfoCommand do
|
6
|
+
it 'allows minimal options' do
|
7
|
+
api_expects(:content_view_filter_rules, :show) do |p|
|
8
|
+
p['content_view_filter_id'] == 1 && p['id'] == '9'
|
9
|
+
end
|
10
|
+
run_cmd(%w(content-view filter rule info --content-view-filter-id 1 --id 9))
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'resolves rule ID from rule name and filter ID' do
|
14
|
+
ex = api_expects(:content_view_filter_rules, :index) do |p|
|
15
|
+
p['content_view_filter_id'] == 1 && p['name'] == 'rule9'
|
16
|
+
end
|
17
|
+
ex.returns(index_response([{'id' => 9}]))
|
18
|
+
|
19
|
+
api_expects(:content_view_filter_rules, :show) do |p|
|
20
|
+
p['content_view_filter_id'] == 1 && p['id'] == 9
|
21
|
+
end
|
22
|
+
run_cmd(%w(content-view filter rule info --content-view-filter-id 1 --name rule9))
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'allows name resolution of filter with content-view-id' do
|
26
|
+
ex = api_expects(:content_view_filters, :index) do |p|
|
27
|
+
p['name'] == 'cvf1' && p['content_view_id'] == 3
|
28
|
+
end
|
29
|
+
ex.returns(index_response([{'id' => 1}]))
|
30
|
+
|
31
|
+
api_expects(:content_view_filter_rules, :show) do |p|
|
32
|
+
p['content_view_filter_id'] == 1 && p['id'] == '9'
|
33
|
+
end
|
34
|
+
run_cmd(%w(content-view filter rule info --content-view-filter cvf1 --content-view-id 3
|
35
|
+
--id 9))
|
36
|
+
end
|
37
|
+
|
38
|
+
describe 'organization' do
|
39
|
+
it 'ID can be specified to resolve content view name' do
|
40
|
+
ex = api_expects(:content_views, :index) do |p|
|
41
|
+
p['name'] == 'cv3' && p['organization_id'] == '6'
|
42
|
+
end
|
43
|
+
ex.returns(index_response([{'id' => 3}]))
|
44
|
+
|
45
|
+
ex = api_expects(:content_view_filters, :index) do |p|
|
46
|
+
p['name'] == 'cvf1' && p['content_view_id'] == 3
|
47
|
+
end
|
48
|
+
ex.returns(index_response([{'id' => 1}]))
|
49
|
+
|
50
|
+
api_expects(:content_view_filter_rules, :show) do |p|
|
51
|
+
p['content_view_filter_id'] == 1 && p['id'] == '9'
|
52
|
+
end
|
53
|
+
run_cmd(%w(content-view filter rule info --content-view-filter cvf1 --organization-id 6
|
54
|
+
--content-view cv3 --id 9))
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'name can be specified to resolve content view name' do
|
58
|
+
ex = api_expects(:organizations, :index) do |p|
|
59
|
+
p[:search] == "name = \"org6\""
|
60
|
+
end
|
61
|
+
ex.returns(index_response([{'id' => 6}]))
|
62
|
+
|
63
|
+
ex = api_expects(:content_views, :index) do |p|
|
64
|
+
p['name'] == 'cv3' && p['organization_id'] == 6
|
65
|
+
end
|
66
|
+
ex.returns(index_response([{'id' => 3}]))
|
67
|
+
|
68
|
+
ex = api_expects(:content_view_filters, :index) do |p|
|
69
|
+
p['name'] == 'cvf1' && p['content_view_id'] == 3
|
70
|
+
end
|
71
|
+
ex.returns(index_response([{'id' => 1}]))
|
72
|
+
|
73
|
+
api_expects(:content_view_filter_rules, :show) do |p|
|
74
|
+
p['content_view_filter_id'] == 1 && p['id'] == '9'
|
75
|
+
end
|
76
|
+
run_cmd(%w(content-view filter rule info --content-view-filter cvf1 --organization org6
|
77
|
+
--content-view cv3 --id 9))
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'label can be specified to resolve content view name' do
|
81
|
+
ex = api_expects(:organizations, :index) do |p|
|
82
|
+
p[:search] == "label = \"org6\""
|
83
|
+
end
|
84
|
+
ex.returns(index_response([{'id' => 6}]))
|
85
|
+
|
86
|
+
ex = api_expects(:content_views, :index) do |p|
|
87
|
+
p['name'] == 'cv3' && p['organization_id'] == 6
|
88
|
+
end
|
89
|
+
ex.returns(index_response([{'id' => 3}]))
|
90
|
+
|
91
|
+
ex = api_expects(:content_view_filters, :index) do |p|
|
92
|
+
p['name'] == 'cvf1' && p['content_view_id'] == 3
|
93
|
+
end
|
94
|
+
ex.returns(index_response([{'id' => 1}]))
|
95
|
+
|
96
|
+
api_expects(:content_view_filter_rules, :show) do |p|
|
97
|
+
p['content_view_filter_id'] == 1 && p['id'] == '9'
|
98
|
+
end
|
99
|
+
run_cmd(%w(content-view filter rule info --content-view-filter cvf1 --organization-label
|
100
|
+
org6 --content-view cv3 --id 9))
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'hammer_cli_katello/filter_rule'
|
3
|
+
|
4
|
+
module HammerCLIKatello
|
5
|
+
describe FilterRule::ListCommand do
|
6
|
+
it 'allows minimal options' do
|
7
|
+
api_expects(:content_view_filter_rules, :index) do |p|
|
8
|
+
p['content_view_filter_id'] == 1
|
9
|
+
end
|
10
|
+
run_cmd(%w(content-view filter rule list --content-view-filter-id 1))
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'allows name resolution with content-view-id' do
|
14
|
+
ex = api_expects(:content_view_filters, :index) do |p|
|
15
|
+
p['name'] == 'cvf1' && p['content_view_id'] == 3
|
16
|
+
end
|
17
|
+
ex.returns(index_response([{'id' => 1}]))
|
18
|
+
|
19
|
+
api_expects(:content_view_filter_rules, :index) do |p|
|
20
|
+
p['content_view_filter_id'] == 1
|
21
|
+
end
|
22
|
+
run_cmd(%w(content-view filter rule list --content-view-filter cvf1 --content-view-id 3))
|
23
|
+
end
|
24
|
+
|
25
|
+
describe 'organization' do
|
26
|
+
it 'ID can be specified to resolve content view name' do
|
27
|
+
ex = api_expects(:content_views, :index) do |p|
|
28
|
+
p['name'] == 'cv3' && p['organization_id'] == '6'
|
29
|
+
end
|
30
|
+
ex.returns(index_response([{'id' => 3}]))
|
31
|
+
|
32
|
+
ex = api_expects(:content_view_filters, :index) do |p|
|
33
|
+
p['name'] == 'cvf1' && p['content_view_id'] == 3
|
34
|
+
end
|
35
|
+
ex.returns(index_response([{'id' => 1}]))
|
36
|
+
|
37
|
+
api_expects(:content_view_filter_rules, :index) do |p|
|
38
|
+
p['content_view_filter_id'] == 1
|
39
|
+
end
|
40
|
+
run_cmd(%w(content-view filter rule list --content-view-filter cvf1 --organization-id 6
|
41
|
+
--content-view cv3))
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'name can be specified to resolve content view name' do
|
45
|
+
ex = api_expects(:organizations, :index) do |p|
|
46
|
+
p[:search] == "name = \"org6\""
|
47
|
+
end
|
48
|
+
ex.returns(index_response([{'id' => 6}]))
|
49
|
+
|
50
|
+
ex = api_expects(:content_views, :index) do |p|
|
51
|
+
p['name'] == 'cv3' && p['organization_id'] == 6
|
52
|
+
end
|
53
|
+
ex.returns(index_response([{'id' => 3}]))
|
54
|
+
|
55
|
+
ex = api_expects(:content_view_filters, :index) do |p|
|
56
|
+
p['name'] == 'cvf1' && p['content_view_id'] == 3
|
57
|
+
end
|
58
|
+
ex.returns(index_response([{'id' => 1}]))
|
59
|
+
|
60
|
+
api_expects(:content_view_filter_rules, :index) do |p|
|
61
|
+
p['content_view_filter_id'] == 1
|
62
|
+
end
|
63
|
+
run_cmd(%w(content-view filter rule list --content-view-filter cvf1 --organization org6
|
64
|
+
--content-view cv3))
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'label can be specified to resolve content view name' do
|
68
|
+
ex = api_expects(:organizations, :index) do |p|
|
69
|
+
p[:search] == "label = \"org6\""
|
70
|
+
end
|
71
|
+
ex.returns(index_response([{'id' => 6}]))
|
72
|
+
|
73
|
+
ex = api_expects(:content_views, :index) do |p|
|
74
|
+
p['name'] == 'cv3' && p['organization_id'] == 6
|
75
|
+
end
|
76
|
+
ex.returns(index_response([{'id' => 3}]))
|
77
|
+
|
78
|
+
ex = api_expects(:content_view_filters, :index) do |p|
|
79
|
+
p['name'] == 'cvf1' && p['content_view_id'] == 3
|
80
|
+
end
|
81
|
+
ex.returns(index_response([{'id' => 1}]))
|
82
|
+
|
83
|
+
api_expects(:content_view_filter_rules, :index) do |p|
|
84
|
+
p['content_view_filter_id'] == 1
|
85
|
+
end
|
86
|
+
run_cmd(%w(content-view filter rule list --content-view-filter cvf1 --organization-label
|
87
|
+
org6 --content-view cv3))
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'hammer_cli_katello/filter_rule'
|
3
|
+
|
4
|
+
module HammerCLIKatello
|
5
|
+
describe FilterRule::UpdateCommand do
|
6
|
+
it 'allows minimal options' do
|
7
|
+
api_expects(:content_view_filter_rules, :update) do |p|
|
8
|
+
p['content_view_filter_id'] == 1 && p['id'] == '9'
|
9
|
+
end
|
10
|
+
run_cmd(%w(content-view filter rule update --content-view-filter-id 1 --id 9))
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'resolves rule ID from rule name and filter ID' do
|
14
|
+
ex = api_expects(:content_view_filter_rules, :index) do |p|
|
15
|
+
p['content_view_filter_id'] == 1 && p['name'] == 'rule9'
|
16
|
+
end
|
17
|
+
ex.returns(index_response([{'id' => 9}]))
|
18
|
+
|
19
|
+
api_expects(:content_view_filter_rules, :update) do |p|
|
20
|
+
p['content_view_filter_id'] == 1 && p['id'] == 9
|
21
|
+
end
|
22
|
+
run_cmd(%w(content-view filter rule update --content-view-filter-id 1 --name rule9))
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'allows name resolution of filter with content-view-id' do
|
26
|
+
ex = api_expects(:content_view_filters, :index) do |p|
|
27
|
+
p['name'] == 'cvf1' && p['content_view_id'] == 3
|
28
|
+
end
|
29
|
+
ex.returns(index_response([{'id' => 1}]))
|
30
|
+
|
31
|
+
api_expects(:content_view_filter_rules, :update) do |p|
|
32
|
+
p['content_view_filter_id'] == 1 && p['id'] == '9'
|
33
|
+
end
|
34
|
+
run_cmd(%w(content-view filter rule update --content-view-filter cvf1 --content-view-id 3
|
35
|
+
--id 9))
|
36
|
+
end
|
37
|
+
|
38
|
+
describe 'organization' do
|
39
|
+
it 'ID can be specified to resolve content view name' do
|
40
|
+
ex = api_expects(:content_views, :index) do |p|
|
41
|
+
p['name'] == 'cv3' && p['organization_id'] == '6'
|
42
|
+
end
|
43
|
+
ex.returns(index_response([{'id' => 3}]))
|
44
|
+
|
45
|
+
ex = api_expects(:content_view_filters, :index) do |p|
|
46
|
+
p['name'] == 'cvf1' && p['content_view_id'] == 3
|
47
|
+
end
|
48
|
+
ex.returns(index_response([{'id' => 1}]))
|
49
|
+
|
50
|
+
api_expects(:content_view_filter_rules, :update) do |p|
|
51
|
+
p['content_view_filter_id'] == 1 && p['id'] == '9'
|
52
|
+
end
|
53
|
+
run_cmd(%w(content-view filter rule update --content-view-filter cvf1 --organization-id 6
|
54
|
+
--content-view cv3 --id 9))
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'name can be specified to resolve content view name' do
|
58
|
+
ex = api_expects(:organizations, :index) do |p|
|
59
|
+
p[:search] == "name = \"org6\""
|
60
|
+
end
|
61
|
+
ex.returns(index_response([{'id' => 6}]))
|
62
|
+
|
63
|
+
ex = api_expects(:content_views, :index) do |p|
|
64
|
+
p['name'] == 'cv3' && p['organization_id'] == 6
|
65
|
+
end
|
66
|
+
ex.returns(index_response([{'id' => 3}]))
|
67
|
+
|
68
|
+
ex = api_expects(:content_view_filters, :index) do |p|
|
69
|
+
p['name'] == 'cvf1' && p['content_view_id'] == 3
|
70
|
+
end
|
71
|
+
ex.returns(index_response([{'id' => 1}]))
|
72
|
+
|
73
|
+
api_expects(:content_view_filter_rules, :update) do |p|
|
74
|
+
p['content_view_filter_id'] == 1 && p['id'] == '9'
|
75
|
+
end
|
76
|
+
run_cmd(%w(content-view filter rule update --content-view-filter cvf1 --organization org6
|
77
|
+
--content-view cv3 --id 9))
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'label can be specified to resolve content view name' do
|
81
|
+
ex = api_expects(:organizations, :index) do |p|
|
82
|
+
p[:search] == "label = \"org6\""
|
83
|
+
end
|
84
|
+
ex.returns(index_response([{'id' => 6}]))
|
85
|
+
|
86
|
+
ex = api_expects(:content_views, :index) do |p|
|
87
|
+
p['name'] == 'cv3' && p['organization_id'] == 6
|
88
|
+
end
|
89
|
+
ex.returns(index_response([{'id' => 3}]))
|
90
|
+
|
91
|
+
ex = api_expects(:content_view_filters, :index) do |p|
|
92
|
+
p['name'] == 'cvf1' && p['content_view_id'] == 3
|
93
|
+
end
|
94
|
+
ex.returns(index_response([{'id' => 1}]))
|
95
|
+
|
96
|
+
api_expects(:content_view_filter_rules, :update) do |p|
|
97
|
+
p['content_view_filter_id'] == 1 && p['id'] == '9'
|
98
|
+
end
|
99
|
+
run_cmd(%w(content-view filter rule update --content-view-filter cvf1 --organization-label
|
100
|
+
org6 --content-view cv3 --id 9))
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hammer_cli_katello
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Price
|
@@ -34,7 +34,7 @@ authors:
|
|
34
34
|
autorequire:
|
35
35
|
bindir: bin
|
36
36
|
cert_chain: []
|
37
|
-
date: 2016-
|
37
|
+
date: 2016-12-13 00:00:00.000000000 Z
|
38
38
|
dependencies:
|
39
39
|
- !ruby/object:Gem::Dependency
|
40
40
|
name: hammer_cli_foreman
|
@@ -323,6 +323,10 @@ files:
|
|
323
323
|
- test/functional/content_view/version/list_test.rb
|
324
324
|
- test/functional/content_view/version/promote_test.rb
|
325
325
|
- test/functional/filter_rule/create_test.rb
|
326
|
+
- test/functional/filter_rule/delete_test.rb
|
327
|
+
- test/functional/filter_rule/info_test.rb
|
328
|
+
- test/functional/filter_rule/list_test.rb
|
329
|
+
- test/functional/filter_rule/update_test.rb
|
326
330
|
- test/functional/host/errata/apply_test.rb
|
327
331
|
- test/functional/host/extensions/data/host.json
|
328
332
|
- test/functional/host/extensions/data/host_list.json
|
@@ -430,6 +434,10 @@ test_files:
|
|
430
434
|
- test/functional/content_view/version/list_test.rb
|
431
435
|
- test/functional/content_view/version/promote_test.rb
|
432
436
|
- test/functional/filter_rule/create_test.rb
|
437
|
+
- test/functional/filter_rule/delete_test.rb
|
438
|
+
- test/functional/filter_rule/info_test.rb
|
439
|
+
- test/functional/filter_rule/list_test.rb
|
440
|
+
- test/functional/filter_rule/update_test.rb
|
433
441
|
- test/functional/host/errata/apply_test.rb
|
434
442
|
- test/functional/host/extensions/data/host.json
|
435
443
|
- test/functional/host/extensions/data/host_list.json
|