foreman_ansible 18.0.7 → 18.0.8
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2a1485bfb32cba640512f2308bfccfc26898267294af235c157b0ab1739977f4
|
|
4
|
+
data.tar.gz: 81c2e94035d1c6e65b91f6439f499e2e2d5c33686c710448aaadccfe6a656645
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9575226215daa07566c74c43918d1dd9312e297ce5d1e57e492c59000dd39000c89da12a59a14ee8a22a861ae6b01dc7601b6a66e682da2d466b6c835901f6a0
|
|
7
|
+
data.tar.gz: 564e63afb96cb2d52e81b8f3eca979f06114a583161e8add151e81374b28e6883a1d9257ddb5279fe93bd4c13c51ebb975e4ea5dd6aff8ddd899cf627dcab9e5
|
|
@@ -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
|
-
|
|
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
|
|
@@ -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)
|