foreman_ansible 17.0.9 → 17.0.10

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cd2541b943e7880fe2ba5e0d324201353404cd66c4c5a290ea9674998587114b
4
- data.tar.gz: 50c6e9be97dce5a43db62fb490c2acaa4919c4ed0696beb6d24fa0b99bfdff5e
3
+ metadata.gz: 154b2cf224c606205a5880bd26a3f3ede0a0bb2fc219fba71d112d15599c04e2
4
+ data.tar.gz: 314a5ddf9b316c2128ba4a25ba431dac0adcfcc49435d35e213e65f4eb201186
5
5
  SHA512:
6
- metadata.gz: af34bb1ff7a20d37a84ceb972efcd4f7ff4468e979a1f5fbe992b43c88c426e18e2696aa54b828212ca6ceecdbadf8ff7f1b3b0b4e16c09ce8dc23766e36bdb7
7
- data.tar.gz: 7d354aad703f47f77404adb10effe366c42dc141d4dffb8dd4018a429f18410dc0e842dd655bf6cdf430fee8c366b66963c68ac6702764695b45370535bda7f5
6
+ metadata.gz: 124af894e947f5c5ec4eab2bdfcb8d7cdc45f559b9ba219a6380951540a9d9ed78910525dae385ce3253d51fb224ea79aced98c33a909a4753e3aa621ec998ef
7
+ data.tar.gz: 98136d0f7f392e5e05a8f15249f526f5db7bc88780ff500078b6eb1d38d7c0a97213905a1e1e30c99b2831c6e27db31a672eadb7456c8c552fa76290d4b73b0e
@@ -99,7 +99,8 @@ module Api
99
99
 
100
100
  def show_inventory(ids_key, condition_key)
101
101
  ids = params.fetch(ids_key, []).uniq
102
- render :json => ForemanAnsible::InventoryCreator.new(Host.where(condition_key => ids)).to_hash.to_json
102
+ hosts = Host.authorized(:view_hosts).where(condition_key => ids)
103
+ render :json => ForemanAnsible::InventoryCreator.new(hosts).to_hash.to_json
103
104
  end
104
105
  end
105
106
  end
@@ -4,5 +4,5 @@
4
4
  # This way other parts of Foreman can just call ForemanAnsible::VERSION
5
5
  # and detect what version the plugin is running.
6
6
  module ForemanAnsible
7
- VERSION = '17.0.9'
7
+ VERSION = '17.0.10'
8
8
  end
@@ -22,6 +22,46 @@ module Api
22
22
  hosts_inventory_assertions(hosts)
23
23
  end
24
24
 
25
+ test 'applies view_hosts filters to host inventory' do
26
+ setup_user('view', 'hosts', "hostgroup_id = #{@hostgroup.id}")
27
+
28
+ get :hosts, :params => { :host_ids => [@host1.id, @host3.id] },
29
+ :session => set_session_user(@one)
30
+
31
+ inventory = JSON.parse(@response.body)
32
+ hostvars = inventory['_meta']['hostvars']
33
+ assert_equal [@host1.name], inventory['all']['hosts']
34
+ assert_not hostvars.key?(@host3.name)
35
+
36
+ get :hosts, :params => { :host_ids => [@host3.id] },
37
+ :session => set_session_user(@one)
38
+
39
+ inventory = JSON.parse(@response.body)
40
+ assert_empty inventory['all']['hosts']
41
+ assert_empty inventory['_meta']['hostvars']
42
+ end
43
+
44
+ test 'applies view_hosts filters to hostgroup inventory' do
45
+ forbidden_hostgroup = FactoryBot.create(:hostgroup)
46
+ forbidden_host = FactoryBot.create(:host, :hostgroup_id => forbidden_hostgroup.id)
47
+ setup_user('view', 'hosts', "hostgroup_id = #{@hostgroup.id}")
48
+ setup_user('view', 'hostgroups')
49
+
50
+ get :hostgroups,
51
+ :params => { :hostgroup_ids => [@hostgroup.id, forbidden_hostgroup.id] },
52
+ :session => set_session_user(@one)
53
+
54
+ hosts_inventory_assertions(@hostgroup.hosts)
55
+ assert_not JSON.parse(@response.body)['_meta']['hostvars'].key?(forbidden_host.name)
56
+
57
+ get :hostgroups, :params => { :hostgroup_ids => [forbidden_hostgroup.id] },
58
+ :session => set_session_user(@one)
59
+
60
+ inventory = JSON.parse(@response.body)
61
+ assert_empty inventory['all']['hosts']
62
+ assert_empty inventory['_meta']['hostvars']
63
+ end
64
+
25
65
  test 'should show inventory for hostgroup by GET' do
26
66
  get :hostgroups, :params => { :hostgroup_ids => [@hostgroup.id] }, :session => set_session_user
27
67
  hosts_inventory_assertions(@hostgroup.hosts)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_ansible
3
3
  version: !ruby/object:Gem::Version
4
- version: 17.0.9
4
+ version: 17.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Lobato Garcia
@@ -470,7 +470,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
470
470
  - !ruby/object:Gem::Version
471
471
  version: '0'
472
472
  requirements: []
473
- rubygems_version: 4.0.10
473
+ rubygems_version: 4.0.20
474
474
  specification_version: 4
475
475
  summary: Ansible integration with Foreman (theforeman.org)
476
476
  test_files: