foreman_ansible 18.0.7 → 19.0.0

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: cac81a3b9ec2b4060facfd9748d91edb078c676c95eb927ef94db8bc4b010674
4
- data.tar.gz: 5c1e8d0a695692f0e8189586391b09a9954d318cba3f1d3ec5f808cd45f78977
3
+ metadata.gz: dfe3ee3f0656ba448571ca78e4fb5bc4a36f2cb2babbd8b4f0d9feebfdf36e93
4
+ data.tar.gz: f2d9cb41b5b6cf9eb3ff0881f56dfcc48a9782bf689dc26a4374d3e7b779e669
5
5
  SHA512:
6
- metadata.gz: 43fca640ea1535480be3555263e1e3b62163c4fd3613b275a1ceff30536397b7de47a0d21917af18187bef1c7a9136b04e7cc28ca2342408fc7bb285e5420fdf
7
- data.tar.gz: 1aa28d10a63bc2f6e962737e4311c7f1eca0fafbe662566534ee2f16546ff25e58c7e03db1f9c613e24bcf55a391a45f3bf5a7a06fb958059d9ee5d18745e9f1
6
+ metadata.gz: 7da81cd98b69c70509a0cbede30369d4b4cec6582803e4cfb73bc981681088f8ddfd8876dd70fccc996ce3e7f1fbb6d6773b361ea7b96675e7f9cbc1b8d6d0db
7
+ data.tar.gz: 39d1de3ffaea5dfc9f756bd0409248c99a535d904807065ad6c4445e7214852ac06b8e0be35c53eeaf2d02868a3ba83efaf39afd03b445520c70e73c187eda01
data/README.md CHANGED
@@ -51,6 +51,15 @@ Facts must contain the output of `ansible -m setup $HOSTNAME`, plus a '_type' an
51
51
 
52
52
  After that request, you should have a host registered in Foreman with the Ansible facts. It takes into account some facter and ohai facts if these are available on the system as well.
53
53
 
54
+ ### JavaScript testing and linting
55
+
56
+ Run the plugin's JavaScript checks from the Foreman core checkout, which provides the shared test and lint tools:
57
+
58
+ ```sh
59
+ npm run test:plugins foreman_ansible
60
+ npm run lint:plugins foreman_ansible
61
+ ```
62
+
54
63
  ## Copyright
55
64
 
56
65
  Copyright (c) Daniel Lobato Garcia
@@ -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
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  Foreman::Plugin.register :foreman_ansible do
4
- requires_foreman '>= 5.0'
4
+ requires_foreman '>= 5.1'
5
5
  register_gettext
6
6
 
7
7
  settings do
@@ -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.7'
7
+ VERSION = '19.0.0'
8
8
  end
data/package.json CHANGED
@@ -6,28 +6,9 @@
6
6
  "directories": {
7
7
  "test": "test"
8
8
  },
9
- "peerDependencies": {
10
- "@theforeman/vendor": ">= 12.0.1"
11
- },
12
9
  "dependencies": {
13
10
  "react-json-tree": "^0.18.0"
14
11
  },
15
- "devDependencies": {
16
- "@babel/core": "^7.7.0",
17
- "@testing-library/user-event": "^13.2.1",
18
- "@theforeman/builder": ">= 12.0.1",
19
- "@theforeman/eslint-plugin-foreman": ">= 12.0.1",
20
- "@theforeman/find-foreman": ">= 12.0.1",
21
- "@theforeman/test": ">= 12.0.1",
22
- "@theforeman/vendor-dev": ">= 12.0.1",
23
- "babel-eslint": "^10.0.3",
24
- "eslint": "^6.7.2",
25
- "prettier": "^1.13.5"
26
- },
27
- "scripts": {
28
- "test": "tfm-test --plugin --config jest.config.js",
29
- "lint": "tfm-lint --plugin -d webpack"
30
- },
31
12
  "repository": {
32
13
  "type": "git",
33
14
  "url": "git+https://github.com/theforeman/foreman_ansible.git"
@@ -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)
@@ -10,7 +10,10 @@ import { reducers as apiReducer, APIMiddleware } from 'foremanReact/redux/API';
10
10
  import ConfirmModal, {
11
11
  reducers as confirmModalReducers,
12
12
  } from 'foremanReact/components/ConfirmModal';
13
- import { getForemanContext } from 'foremanReact/Root/Context/ForemanContext';
13
+
14
+ const { getForemanContext } = jest.requireActual(
15
+ 'foremanReact/Root/Context/ForemanContext'
16
+ );
14
17
 
15
18
  const reducers = combineReducers({ ...apiReducer, ...confirmModalReducers });
16
19
 
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.7
4
+ version: 19.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Lobato Garcia