hammer_cli_foreman_puppet 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -25,7 +25,7 @@ module HammerCLIForemanPuppet
25
25
  p[:search] == 'name = "env1"'
26
26
  end.returns(index_response([{ 'id' => 1 }]))
27
27
  api_expects(:hosts, :create) do |p|
28
- p['host']['environment_id'] == 1 &&
28
+ p['host']['puppet_attributes']['environment_id'] == 1 &&
29
29
  p['host']['name'] == 'hst1'
30
30
  end
31
31
  run_cmd(cmd + minimal_params_without_hostgroup + params)
@@ -59,7 +59,7 @@ module HammerCLIForemanPuppet
59
59
  it 'allows puppet class ids' do
60
60
  params = %w[--puppet-class-ids=1,2]
61
61
  api_expects(:hosts, :create) do |p|
62
- p['host']['puppetclass_ids'] == %w[1 2] &&
62
+ p['host']['puppet_attributes']['puppetclass_ids'] == %w[1 2] &&
63
63
  p['host']['name'] == 'hst1'
64
64
  end
65
65
  run_cmd(cmd + minimal_params_without_hostgroup + params)
@@ -81,7 +81,7 @@ module HammerCLIForemanPuppet
81
81
  {'id' => 2, 'name' => 'pc2'}
82
82
  ]))
83
83
  api_expects(:hosts, :create) do |p|
84
- p['host']['puppetclass_ids'] == [1,2] &&
84
+ p['host']['puppet_attributes']['puppetclass_ids'] == [1,2] &&
85
85
  p['host']['name'] == 'hst1'
86
86
  end
87
87
  run_cmd(cmd + minimal_params_without_hostgroup + params)
@@ -130,7 +130,7 @@ module HammerCLIForemanPuppet
130
130
 
131
131
  api_expects(:hosts, :create) do |p|
132
132
  p['host']['name'] == 'hst1' &&
133
- p['host']['puppetclass_ids'] == ids
133
+ p['host']['puppet_attributes']['puppetclass_ids'] == ids
134
134
  end
135
135
  run_cmd(cmd + minimal_params_without_hostgroup + params)
136
136
  end
@@ -159,6 +159,37 @@ module HammerCLIForemanPuppet
159
159
  end
160
160
  run_cmd(cmd + minimal_params_without_hostgroup + params)
161
161
  end
162
+
163
+ it 'allows config group ids' do
164
+ params = %w[--config-group-ids=1,2]
165
+ api_expects(:hosts, :create) do |p|
166
+ p['host']['puppet_attributes']['config_group_ids'] == %w[1 2] &&
167
+ p['host']['name'] == 'hst1'
168
+ end
169
+ run_cmd(cmd + minimal_params_without_hostgroup + params)
170
+ end
171
+
172
+ it 'allows config group names' do
173
+ params = %w[--config-groups=cg1,cg2]
174
+ api_expects(:config_groups, :index) do |p|
175
+ p[:search] = 'name = "cg1" or name = "cg2"'
176
+ end.returns(index_response([
177
+ {'id' => 1, 'name' => 'cg1'},
178
+ {'id' => 2, 'name' => 'cg2'}
179
+ ]))
180
+ # FIXME: Called twice because of config_group_ids being mentioned twice in the docs
181
+ api_expects(:config_groups, :index) do |p|
182
+ p[:search] = 'name = "cg1" or name = "cg2"'
183
+ end.returns(index_response([
184
+ {'id' => 1, 'name' => 'cg1'},
185
+ {'id' => 2, 'name' => 'cg2'}
186
+ ]))
187
+ api_expects(:hosts, :create) do |p|
188
+ p['host']['puppet_attributes']['config_group_ids'] == [1, 2] &&
189
+ p['host']['name'] == 'hst1'
190
+ end
191
+ run_cmd(cmd + minimal_params_without_hostgroup + params)
192
+ end
162
193
  end
163
194
  end
164
195
  end
@@ -5,7 +5,7 @@ module HammerCLIForemanPuppet
5
5
  describe UpdateCommand do
6
6
  it 'allows environment id' do
7
7
  api_expects(:hosts, :update) do |p|
8
- p['host']['environment_id'] == 1 &&
8
+ p['host']['puppet_attributes']['environment_id'] == 1 &&
9
9
  p['id'] == '1'
10
10
  end
11
11
  run_cmd(%w(host update --id 1 --puppet-environment-id 1))
@@ -20,7 +20,7 @@ module HammerCLIForemanPuppet
20
20
  p[:search] = "name = \"env1\""
21
21
  end.returns(index_response([{'id' => 1}]))
22
22
  api_expects(:hosts, :update) do |p|
23
- p['host']['environment_id'] == 1 &&
23
+ p['host']['puppet_attributes']['environment_id'] == 1 &&
24
24
  p['id'] == '1'
25
25
  end
26
26
  run_cmd(%w(host update --id 1 --puppet-environment env1))
@@ -47,7 +47,7 @@ module HammerCLIForemanPuppet
47
47
 
48
48
  it 'allows puppet class ids' do
49
49
  api_expects(:hosts, :update) do |p|
50
- p['host']['puppetclass_ids'] == ['1','2'] &&
50
+ p['host']['puppet_attributes']['puppetclass_ids'] == ['1','2'] &&
51
51
  p['id'] == '1'
52
52
  end
53
53
  run_cmd(%w(host update --id 1 --puppet-class-ids 1,2))
@@ -68,7 +68,7 @@ module HammerCLIForemanPuppet
68
68
  {'id' => 2, 'name' => 'pc2'}
69
69
  ]))
70
70
  api_expects(:hosts, :update) do |p|
71
- p['host']['puppetclass_ids'] == [1,2] &&
71
+ p['host']['puppet_attributes']['puppetclass_ids'] == [1,2] &&
72
72
  p['id'] == '1'
73
73
  end
74
74
  run_cmd(%w(host update --id 1 --puppet-classes pc1,pc2))
@@ -92,6 +92,35 @@ module HammerCLIForemanPuppet
92
92
  end
93
93
  run_cmd(%w(host update --id 1 --puppet-proxy sp1))
94
94
  end
95
+
96
+ it 'allows config group ids' do
97
+ api_expects(:hosts, :update) do |p|
98
+ p['host']['puppet_attributes']['config_group_ids'] == %w[1 2] &&
99
+ p['id'] == '1'
100
+ end
101
+ run_cmd(%w[host update --id 1 --config-group-ids=1,2])
102
+ end
103
+
104
+ it 'allows config group names' do
105
+ api_expects(:config_groups, :index) do |p|
106
+ p[:search] = 'name = "cg1" or name = "cg2"'
107
+ end.returns(index_response([
108
+ {'id' => 1, 'name' => 'cg1'},
109
+ {'id' => 2, 'name' => 'cg2'}
110
+ ]))
111
+ # FIXME: Called twice because of config_group_ids being mentioned twice in the docs
112
+ api_expects(:config_groups, :index) do |p|
113
+ p[:search] = 'name = "cg1" or name = "cg2"'
114
+ end.returns(index_response([
115
+ {'id' => 1, 'name' => 'cg1'},
116
+ {'id' => 2, 'name' => 'cg2'}
117
+ ]))
118
+ api_expects(:hosts, :update) do |p|
119
+ p['host']['puppet_attributes']['config_group_ids'] == [1, 2] &&
120
+ p['id'] == '1'
121
+ end
122
+ run_cmd(%w[host update --id 1 --config-groups=cg1,cg2])
123
+ end
95
124
  end
96
125
  end
97
126
  end
@@ -5,7 +5,7 @@ module HammerCLIForemanPuppet
5
5
  describe CreateCommand do
6
6
  it 'allows puppet environment id' do
7
7
  api_expects(:hostgroups, :create) do |p|
8
- p['hostgroup']['environment_id'] == 1 &&
8
+ p['hostgroup']['puppet_attributes']['environment_id'] == 1 &&
9
9
  p['hostgroup']['name'] == 'hg1'
10
10
  end
11
11
  run_cmd(%w[hostgroup create --name hg1 --puppet-environment-id 1])
@@ -20,7 +20,7 @@ module HammerCLIForemanPuppet
20
20
  p[:search] == 'name = "env1"'
21
21
  end.returns(index_response([{ 'id' => 1 }]))
22
22
  api_expects(:hostgroups, :create) do |p|
23
- p['hostgroup']['environment_id'] == 1 &&
23
+ p['hostgroup']['puppet_attributes']['environment_id'] == 1 &&
24
24
  p['hostgroup']['name'] == 'hg1'
25
25
  end
26
26
  run_cmd(%w[hostgroup create --name hg1 --puppet-environment env1])
@@ -49,7 +49,7 @@ module HammerCLIForemanPuppet
49
49
 
50
50
  it 'allows puppet class ids' do
51
51
  api_expects(:hostgroups, :create) do |p|
52
- p['hostgroup']['puppetclass_ids'] == ['1','2'] &&
52
+ p['hostgroup']['puppet_attributes']['puppetclass_ids'] == ['1','2'] &&
53
53
  p['hostgroup']['name'] == 'hg1'
54
54
  end
55
55
  run_cmd(%w(hostgroup create --name hg1 --puppet-class-ids 1,2))
@@ -70,7 +70,7 @@ module HammerCLIForemanPuppet
70
70
  {'id' => 2, 'name' => 'pc2'}
71
71
  ]))
72
72
  api_expects(:hostgroups, :create) do |p|
73
- p['hostgroup']['puppetclass_ids'] == [1,2] &&
73
+ p['hostgroup']['puppet_attributes']['puppetclass_ids'] == [1,2] &&
74
74
  p['hostgroup']['name'] == 'hg1'
75
75
  end
76
76
  run_cmd(%w(hostgroup create --name hg1 --puppet-classes pc1,pc2))
@@ -118,7 +118,7 @@ module HammerCLIForemanPuppet
118
118
 
119
119
  api_expects(:hostgroups, :create) do |p|
120
120
  p['hostgroup']['name'] == 'hg1' &&
121
- p['hostgroup']['puppetclass_ids'] == ids
121
+ p['hostgroup']['puppet_attributes']['puppetclass_ids'] == ids
122
122
  end
123
123
 
124
124
  run_cmd(%w[hostgroup create --name hg1 --puppet-classes] << names.join(',').tr('"', ''))
@@ -144,6 +144,35 @@ module HammerCLIForemanPuppet
144
144
  end
145
145
  run_cmd(%w(hostgroup create --name hg1 --puppet-proxy sp1))
146
146
  end
147
+
148
+ it 'allows config group ids' do
149
+ api_expects(:hostgroups, :create) do |p|
150
+ p['hostgroup']['puppet_attributes']['config_group_ids'] == %w[1 2] &&
151
+ p['hostgroup']['name'] == 'hg1'
152
+ end
153
+ run_cmd(%w[hostgroup create --name hg1 --config-group-ids 1,2])
154
+ end
155
+
156
+ it 'allows config group names' do
157
+ api_expects(:config_groups, :index) do |p|
158
+ p[:search] = 'name = "cg1" or name = "cg2"'
159
+ end.returns(index_response([
160
+ {'id' => 1, 'name' => 'cg1'},
161
+ {'id' => 2, 'name' => 'cg2'}
162
+ ]))
163
+ # FIXME: Called twice because of config_group_ids being mentioned twice in the docs
164
+ api_expects(:config_groups, :index) do |p|
165
+ p[:search] = 'name = "cg1" or name = "cg2"'
166
+ end.returns(index_response([
167
+ {'id' => 1, 'name' => 'cg1'},
168
+ {'id' => 2, 'name' => 'cg2'}
169
+ ]))
170
+ api_expects(:hostgroups, :create) do |p|
171
+ p['hostgroup']['puppet_attributes']['config_group_ids'] == [1, 2] &&
172
+ p['hostgroup']['name'] == 'hg1'
173
+ end
174
+ run_cmd(%w[hostgroup create --name hg1 --config-groups cg1,cg2])
175
+ end
147
176
  end
148
177
  end
149
178
  end
@@ -5,7 +5,7 @@ module HammerCLIForemanPuppet
5
5
  describe UpdateCommand do
6
6
  it 'allows environment id' do
7
7
  api_expects(:hostgroups, :update) do |p|
8
- p['hostgroup']['environment_id'] == 1 &&
8
+ p['hostgroup']['puppet_attributes']['environment_id'] == 1 &&
9
9
  p['id'] == '1'
10
10
  end
11
11
  run_cmd(%w(hostgroup update --id 1 --puppet-environment-id 1))
@@ -20,7 +20,7 @@ module HammerCLIForemanPuppet
20
20
  p[:search] = "name = \"env1\""
21
21
  end.returns(index_response([{'id' => 1}]))
22
22
  api_expects(:hostgroups, :update) do |p|
23
- p['hostgroup']['environment_id'] == 1 &&
23
+ p['hostgroup']['puppet_attributes']['environment_id'] == 1 &&
24
24
  p['id'] == '1'
25
25
  end
26
26
  run_cmd(%w(hostgroup update --id 1 --puppet-environment env1))
@@ -47,7 +47,7 @@ module HammerCLIForemanPuppet
47
47
 
48
48
  it 'allows puppet class ids' do
49
49
  api_expects(:hostgroups, :update) do |p|
50
- p['hostgroup']['puppetclass_ids'] == ['1','2'] &&
50
+ p['hostgroup']['puppet_attributes']['puppetclass_ids'] == ['1','2'] &&
51
51
  p['id'] == '1'
52
52
  end
53
53
  run_cmd(%w(hostgroup update --id 1 --puppet-class-ids 1,2))
@@ -68,7 +68,7 @@ module HammerCLIForemanPuppet
68
68
  {'id' => 2, 'name' => 'pc2'}
69
69
  ]))
70
70
  api_expects(:hostgroups, :update) do |p|
71
- p['hostgroup']['puppetclass_ids'] == [1,2] &&
71
+ p['hostgroup']['puppet_attributes']['puppetclass_ids'] == [1,2] &&
72
72
  p['id'] == '1'
73
73
  end
74
74
  run_cmd(%w(hostgroup update --id 1 --puppet-classes pc1,pc2))
@@ -92,6 +92,35 @@ module HammerCLIForemanPuppet
92
92
  end
93
93
  run_cmd(%w(hostgroup update --id 1 --puppet-proxy sp1))
94
94
  end
95
+
96
+ it 'allows config group ids' do
97
+ api_expects(:hostgroups, :update) do |p|
98
+ p['hostgroup']['puppet_attributes']['config_group_ids'] == %w[1 2] &&
99
+ p['id'] == '1'
100
+ end
101
+ run_cmd(%w[hostgroup update --id 1 --config-group-ids 1,2])
102
+ end
103
+
104
+ it 'allows config group names' do
105
+ api_expects(:config_groups, :index) do |p|
106
+ p[:search] = 'name = "cg1" or name = "cg2"'
107
+ end.returns(index_response([
108
+ {'id' => 1, 'name' => 'cg1'},
109
+ {'id' => 2, 'name' => 'cg2'}
110
+ ]))
111
+ # FIXME: Called twice because of config_group_ids being mentioned twice in the docs
112
+ api_expects(:config_groups, :index) do |p|
113
+ p[:search] = 'name = "cg1" or name = "cg2"'
114
+ end.returns(index_response([
115
+ {'id' => 1, 'name' => 'cg1'},
116
+ {'id' => 2, 'name' => 'cg2'}
117
+ ]))
118
+ api_expects(:hostgroups, :update) do |p|
119
+ p['hostgroup']['puppet_attributes']['config_group_ids'] == [1, 2] &&
120
+ p['id'] == '1'
121
+ end
122
+ run_cmd(%w[hostgroup update --id 1 --config-groups cg1,cg2])
123
+ end
95
124
  end
96
125
  end
97
126
  end
data/test/test_helper.rb CHANGED
@@ -17,7 +17,7 @@ require "mocha/minitest"
17
17
  require 'hammer_cli'
18
18
  require 'hammer_cli/testing/command_assertions'
19
19
  require 'hammer_cli_foreman/testing/api_expectations'
20
- FOREMAN_VERSION = Gem::Version.new(ENV['TEST_API_VERSION'] || '3.0')
20
+ FOREMAN_VERSION = Gem::Version.new(ENV['TEST_API_VERSION'] || '3.3')
21
21
 
22
22
  include HammerCLI::Testing::CommandAssertions
23
23
  include HammerCLIForeman::Testing::APIExpectations
@@ -16,8 +16,6 @@ describe HammerCLIForemanPuppet::ConfigGroup do
16
16
  context "parameters" do
17
17
  it_should_accept "no arguments"
18
18
  it_should_accept_search_params
19
- it_should_accept 'organization', ['--organization-id=1']
20
- it_should_accept 'location', ['--location-id=1']
21
19
  end
22
20
 
23
21
  context "output" do
@@ -33,8 +31,6 @@ describe HammerCLIForemanPuppet::ConfigGroup do
33
31
  context "parameters" do
34
32
  it_should_accept "id", ["--id=1"]
35
33
  it_should_accept "name", ["--name=group_x"]
36
- it_should_accept 'organization', %w[--id=1 --organization-id=1]
37
- it_should_accept 'location', %w[--id=1 --location-id=1]
38
34
  end
39
35
 
40
36
  context "output" do
@@ -51,8 +47,8 @@ describe HammerCLIForemanPuppet::ConfigGroup do
51
47
  let(:cmd) { HammerCLIForemanPuppet::ConfigGroup::CreateCommand.new("", ctx) }
52
48
 
53
49
  context "parameters" do
54
- it_should_accept 'name, puppetclass ids, location, organization',
55
- %w[--name=first_group --puppet-class-ids=1,2 --location-id=1 --organization-id=1]
50
+ it_should_accept 'name, puppetclass ids',
51
+ %w[--name=first_group --puppet-class-ids=1,2]
56
52
  end
57
53
  end
58
54
 
@@ -62,8 +58,6 @@ describe HammerCLIForemanPuppet::ConfigGroup do
62
58
  context "parameters" do
63
59
  it_should_accept "name", ["--name=group_x"]
64
60
  it_should_accept "id", ["--id=1"]
65
- it_should_accept 'organization', %w[--id=1 --organization-id=1]
66
- it_should_accept 'location', %w[--id=1 --location-id=1]
67
61
  end
68
62
  end
69
63
 
@@ -74,8 +68,6 @@ describe HammerCLIForemanPuppet::ConfigGroup do
74
68
  context "parameters" do
75
69
  it_should_accept "name", ["--name=group_x"]
76
70
  it_should_accept "id", ["--id=1"]
77
- it_should_accept 'organization', %w[--id=1 --organization-id=1]
78
- it_should_accept 'location', %w[--id=1 --location-id=1]
79
71
  end
80
72
  end
81
73
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hammer_cli_foreman_puppet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Amir Fefer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-16 00:00:00.000000000 Z
11
+ date: 2022-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hammer_cli_foreman
@@ -70,6 +70,7 @@ files:
70
70
  - lib/hammer_cli_foreman_puppet/version.rb
71
71
  - test/data/2.1/foreman_api.json
72
72
  - test/data/3.0/foreman_api.json
73
+ - test/data/3.3/foreman_api.json
73
74
  - test/data/README.md
74
75
  - test/functional/config_group_test.rb
75
76
  - test/functional/host/create_test.rb
@@ -115,26 +116,27 @@ signing_key:
115
116
  specification_version: 4
116
117
  summary: Foreman Puppet plugin for Hammer CLI
117
118
  test_files:
118
- - test/data/2.1/foreman_api.json
119
- - test/data/3.0/foreman_api.json
120
- - test/data/README.md
121
- - test/test_helper.rb
122
- - test/unit/apipie_resource_mock.rb
119
+ - test/unit/config_group_test.rb
120
+ - test/unit/smart_class_parameter_test.rb
121
+ - test/unit/helpers/resource_disabled.rb
123
122
  - test/unit/helpers/command.rb
124
123
  - test/unit/helpers/fake_searchables.rb
125
- - test/unit/helpers/resource_disabled.rb
126
- - test/unit/puppet_class_test.rb
127
- - test/unit/puppet_environment_test.rb
128
- - test/unit/smart_class_parameter_test.rb
129
124
  - test/unit/test_helper.rb
130
125
  - test/unit/test_output_adapter.rb
131
- - test/unit/config_group_test.rb
126
+ - test/unit/apipie_resource_mock.rb
127
+ - test/unit/puppet_environment_test.rb
128
+ - test/unit/puppet_class_test.rb
132
129
  - test/functional/config_group_test.rb
133
- - test/functional/host/create_test.rb
134
- - test/functional/host/update_test.rb
135
- - test/functional/hostgroup/create_test.rb
136
- - test/functional/hostgroup/update_test.rb
137
- - test/functional/proxy_test.rb
138
130
  - test/functional/smart_class_parameter_test.rb
139
131
  - test/functional/test_helper.rb
140
132
  - test/functional/template_test.rb
133
+ - test/functional/hostgroup/create_test.rb
134
+ - test/functional/hostgroup/update_test.rb
135
+ - test/functional/host/create_test.rb
136
+ - test/functional/host/update_test.rb
137
+ - test/functional/proxy_test.rb
138
+ - test/test_helper.rb
139
+ - test/data/2.1/foreman_api.json
140
+ - test/data/3.0/foreman_api.json
141
+ - test/data/3.3/foreman_api.json
142
+ - test/data/README.md