foreman_ansible 17.0.8 → 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: b6cd8765eae0204e9dec617d7d3e267abfffc55d402d87026812deadcb720049
4
- data.tar.gz: 47d5ba9efc868bcf4164dc28106a67ee42010a74017bf70551e00b856a696b33
3
+ metadata.gz: 154b2cf224c606205a5880bd26a3f3ede0a0bb2fc219fba71d112d15599c04e2
4
+ data.tar.gz: 314a5ddf9b316c2128ba4a25ba431dac0adcfcc49435d35e213e65f4eb201186
5
5
  SHA512:
6
- metadata.gz: 3aac0662ea3b05bcdae57b8aa80a5bc51b7008b775686c39f024e24c1c294ea51404965e5bf699b888a7a436862255162b9085e8fdd706e5297177e732ad13a9
7
- data.tar.gz: 4feef7c8a25d8688d24d5e05826d994050bfbfbc6407480ccd773eaae862fdde5a30ba899f0c9e85e51c5cd3a788313cf6802d39be1cdd225e5391247de3de3c
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.8'
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.8
4
+ version: 17.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Lobato Garcia
@@ -64,9 +64,6 @@ dependencies:
64
64
  - - ">="
65
65
  - !ruby/object:Gem::Version
66
66
  version: '10.0'
67
- - - "<"
68
- - !ruby/object:Gem::Version
69
- version: '13'
70
67
  type: :runtime
71
68
  prerelease: false
72
69
  version_requirements: !ruby/object:Gem::Requirement
@@ -74,9 +71,6 @@ dependencies:
74
71
  - - ">="
75
72
  - !ruby/object:Gem::Version
76
73
  version: '10.0'
77
- - - "<"
78
- - !ruby/object:Gem::Version
79
- version: '13'
80
74
  description: Ansible integration with Foreman
81
75
  email:
82
76
  - elobatocs@gmail.com
@@ -476,7 +470,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
476
470
  - !ruby/object:Gem::Version
477
471
  version: '0'
478
472
  requirements: []
479
- rubygems_version: 4.0.10
473
+ rubygems_version: 4.0.20
480
474
  specification_version: 4
481
475
  summary: Ansible integration with Foreman (theforeman.org)
482
476
  test_files: