foreman_ansible 18.0.6 → 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: 95ba4dc9dc1a54f39ffe84c9d872a4fef4491b14f1833f1485be0a6ae2e098fa
4
- data.tar.gz: fafc9d8a23b8338a810fac6af244183311904168f977da5ab1617cc05d5ce008
3
+ metadata.gz: 2a1485bfb32cba640512f2308bfccfc26898267294af235c157b0ab1739977f4
4
+ data.tar.gz: 81c2e94035d1c6e65b91f6439f499e2e2d5c33686c710448aaadccfe6a656645
5
5
  SHA512:
6
- metadata.gz: 505d75176112a40d0442f686c57c7ec8319a66e453967e6f1a4d22da0f65e05052fcce883faedb18b5be5eff53dac40d4bb7067ab87de8c0be977ffb0a42b572
7
- data.tar.gz: '048cead5d8566cfeb65a935d25cecaeb6d7c3ff399570e9c3f2b9a3ab184392c818326893e82a4b6a707a308e8b8b18d747e37787c31a35d37bf7c68f8703327'
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
- 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 = '18.0.6'
7
+ VERSION = '18.0.8'
8
8
  end
data/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "@theforeman/vendor": ">= 12.0.1"
11
11
  },
12
12
  "dependencies": {
13
- "react-json-tree": "^0.11.0"
13
+ "react-json-tree": "^0.18.0"
14
14
  },
15
15
  "devDependencies": {
16
16
  "@babel/core": "^7.7.0",
@@ -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)
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import JSONTree from 'react-json-tree';
2
+ import { JSONTree } from 'react-json-tree';
3
3
  import PropTypes from 'prop-types';
4
4
 
5
5
  const theme = {
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: 18.0.6
4
+ version: 18.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Lobato Garcia