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 +4 -4
- data/README.md +9 -0
- data/app/controllers/api/v2/ansible_inventories_controller.rb +2 -1
- data/lib/foreman_ansible/register.rb +1 -1
- data/lib/foreman_ansible/version.rb +1 -1
- data/package.json +0 -19
- data/test/functional/api/v2/ansible_inventories_controller_test.rb +40 -0
- data/webpack/testHelper.js +4 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dfe3ee3f0656ba448571ca78e4fb5bc4a36f2cb2babbd8b4f0d9feebfdf36e93
|
|
4
|
+
data.tar.gz: f2d9cb41b5b6cf9eb3ff0881f56dfcc48a9782bf689dc26a4374d3e7b779e669
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
|
|
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
|
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)
|
data/webpack/testHelper.js
CHANGED
|
@@ -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
|
-
|
|
13
|
+
|
|
14
|
+
const { getForemanContext } = jest.requireActual(
|
|
15
|
+
'foremanReact/Root/Context/ForemanContext'
|
|
16
|
+
);
|
|
14
17
|
|
|
15
18
|
const reducers = combineReducers({ ...apiReducer, ...confirmModalReducers });
|
|
16
19
|
|