foreman_acd 0.6.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (197) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -5
  3. data/app/controllers/foreman_acd/ansible_playbooks_controller.rb +90 -0
  4. data/app/controllers/foreman_acd/app_definitions_controller.rb +104 -7
  5. data/app/controllers/foreman_acd/app_instances_controller.rb +34 -32
  6. data/app/controllers/foreman_acd/concerns/ansible_playbook_parameters.rb +1 -1
  7. data/app/controllers/foreman_acd/concerns/app_instance_mixins.rb +36 -0
  8. data/app/controllers/foreman_acd/remote_execution_controller.rb +37 -21
  9. data/app/controllers/ui_acd_controller.rb +42 -3
  10. data/app/lib/actions/foreman_acd/deploy_all_hosts.rb +12 -7
  11. data/app/lib/actions/foreman_acd/run_configurator.rb +11 -7
  12. data/app/models/concerns/foreman_acd/host_managed_extensions.rb +41 -28
  13. data/app/models/foreman_acd/acd_provider.rb +7 -1
  14. data/app/models/foreman_acd/ansible_playbook.rb +2 -1
  15. data/app/models/foreman_acd/app_instance.rb +48 -3
  16. data/app/models/foreman_acd/foreman_host.rb +8 -0
  17. data/app/services/foreman_acd/acd_proxy_proxy_selector.rb +17 -0
  18. data/app/services/foreman_acd/app_configurator.rb +59 -15
  19. data/app/services/foreman_acd/app_deployer.rb +27 -4
  20. data/app/services/foreman_acd/inventory_creator.rb +25 -1
  21. data/app/views/foreman_acd/ansible_playbooks/_form.html.erb +41 -7
  22. data/app/views/foreman_acd/app_definitions/_form.html.erb +5 -1
  23. data/app/views/foreman_acd/app_definitions/import.html.erb +20 -1
  24. data/app/views/foreman_acd/app_definitions/index.html.erb +3 -6
  25. data/app/views/foreman_acd/app_instances/_form.html.erb +5 -1
  26. data/app/views/foreman_acd/app_instances/index.html.erb +18 -12
  27. data/app/views/foreman_acd/app_instances/report.html.erb +8 -3
  28. data/app/views/templates/job/run_acd_ansible_playbook.erb +1 -1
  29. data/app/views/ui_acd/host_report.json.rabl +4 -0
  30. data/app/views/ui_acd/report_data.json.rabl +10 -0
  31. data/app/views/ui_acd/validate_hostname.json.rabl +6 -0
  32. data/config/routes.rb +6 -0
  33. data/db/migrate/20210316151145_add_git_commit_to_ansible_playbooks.rb +8 -0
  34. data/db/migrate/20210503122809_add_git_url_to_ansible_playbooks.rb +8 -0
  35. data/db/migrate/20210818125913_add_is_existing_host_to_foreman_host.rb +8 -0
  36. data/db/migrate/20210902110645_add_initial_configure_task.rb +8 -0
  37. data/db/seeds.d/75-job_templates.rb +1 -1
  38. data/lib/foreman_acd/engine.rb +26 -4
  39. data/lib/foreman_acd/plugin.rb +9 -18
  40. data/lib/foreman_acd/version.rb +1 -1
  41. data/lib/foreman_acd.rb +30 -0
  42. data/lib/tasks/foreman_acd_tasks.rake +0 -12
  43. data/package.json +8 -22
  44. data/test/controllers/ansible_playbooks_controller_test.rb +1 -1
  45. data/test/controllers/app_instances_controller_test.rb +8 -3
  46. data/test/controllers/ui_acd_controller_test.rb +25 -6
  47. data/test/factories/foreman_acd_factories.rb +18 -4
  48. data/test/models/acd_provider_test.rb +37 -0
  49. data/test/models/ansible_playbook_test.rb +11 -0
  50. data/test/models/app_definition_test.rb +1 -1
  51. data/test/models/app_instance_test.rb +2 -0
  52. data/test/models/concerns/host_extensions_test.rb +26 -0
  53. data/test/models/foreman_host_test.rb +12 -0
  54. data/webpack/__mocks__/foremanReact/API.js +2 -0
  55. data/webpack/__mocks__/foremanReact/common/I18n.js +3 -0
  56. data/webpack/__mocks__/foremanReact/common/helpers.js +2 -0
  57. data/webpack/__mocks__/foremanReact/components/ForemanModal/ForemanModalActions.js +2 -0
  58. data/webpack/__mocks__/foremanReact/components/ForemanModal.js +7 -0
  59. data/webpack/__mocks__/foremanReact/components/common/forms/CommonForm.js +2 -0
  60. data/webpack/__mocks__/foremanReact/components/common/forms/TextInput.js +2 -0
  61. data/webpack/__mocks__/foremanReact/components/hosts/powerStatus.js +1 -0
  62. data/webpack/__snapshots__/helper.test.js.snap +14 -0
  63. data/webpack/components/ApplicationDefinition/ApplicationDefinition.js +35 -11
  64. data/webpack/components/ApplicationDefinition/ApplicationDefinitionActions.js +12 -0
  65. data/webpack/components/ApplicationDefinition/ApplicationDefinitionConstants.js +1 -0
  66. data/webpack/components/ApplicationDefinition/ApplicationDefinitionReducer.js +30 -9
  67. data/webpack/components/ApplicationDefinition/ApplicationDefinitionSelectors.js +4 -0
  68. data/webpack/components/ApplicationDefinition/__fixtures__/applicationDefinitionConfData_1.fixtures.js +288 -0
  69. data/webpack/components/ApplicationDefinition/__fixtures__/applicationDefinitionReducer.fixtures.js +79 -0
  70. data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinition.test.js +26 -0
  71. data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionReducer.test.js +119 -0
  72. data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionSelectors.test.js +53 -0
  73. data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinition.test.js.snap +226 -0
  74. data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinitionReducer.test.js.snap +3033 -0
  75. data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinitionSelectors.test.js.snap +307 -0
  76. data/webpack/components/ApplicationDefinition/components/AnsiblePlaybookSelector.js +2 -1
  77. data/webpack/components/ApplicationDefinition/components/__tests__/AnsiblePlaybookSelector.test.js +41 -0
  78. data/webpack/components/ApplicationDefinition/components/__tests__/__snapshots__/AnsiblePlaybookSelector.test.js.snap +121 -0
  79. data/webpack/components/ApplicationDefinition/index.js +8 -0
  80. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImport.js +214 -0
  81. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImport.scss +1 -0
  82. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportActions.js +161 -0
  83. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportConstants.js +6 -0
  84. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportReducer.js +79 -0
  85. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportSelectors.js +8 -0
  86. data/webpack/components/ApplicationDefinitionImport/__fixtures__/applicationDefinitionImportConfData_1.fixtures.js +129 -0
  87. data/webpack/components/ApplicationDefinitionImport/__fixtures__/applicationDefinitionImportReducer.fixtures.js +29 -0
  88. data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImport.test.js +20 -0
  89. data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImportReducer.test.js +43 -0
  90. data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImportSelectors.test.js +29 -0
  91. data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImport.test.js.snap +62 -0
  92. data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImportReducer.test.js.snap +362 -0
  93. data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImportSelectors.test.js.snap +130 -0
  94. data/webpack/components/ApplicationDefinitionImport/index.js +32 -0
  95. data/webpack/components/ApplicationInstance/ApplicationInstance.js +105 -31
  96. data/webpack/components/ApplicationInstance/ApplicationInstanceActions.js +118 -6
  97. data/webpack/components/ApplicationInstance/ApplicationInstanceConstants.js +4 -0
  98. data/webpack/components/ApplicationInstance/ApplicationInstanceHelper.js +15 -0
  99. data/webpack/components/ApplicationInstance/ApplicationInstanceReducer.js +71 -30
  100. data/webpack/components/ApplicationInstance/ApplicationInstanceSelectors.js +4 -0
  101. data/webpack/components/ApplicationInstance/__fixtures__/applicationInstanceConfData_1.fixtures.js +263 -0
  102. data/webpack/components/ApplicationInstance/__fixtures__/applicationInstanceReducer.fixtures.js +80 -0
  103. data/webpack/components/ApplicationInstance/__tests__/ApplicationInstance.test.js +24 -0
  104. data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceReducer.test.js +131 -0
  105. data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceSelectors.test.js +56 -0
  106. data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstance.test.js.snap +300 -0
  107. data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstanceReducer.test.js.snap +2990 -0
  108. data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstanceSelectors.test.js.snap +284 -0
  109. data/webpack/components/ApplicationInstance/components/AppDefinitionSelector.js +1 -0
  110. data/webpack/components/ApplicationInstance/components/ServiceCounter.js +1 -1
  111. data/webpack/components/ApplicationInstance/helper.js +0 -0
  112. data/webpack/components/ApplicationInstance/index.js +8 -0
  113. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.js +81 -6
  114. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportActions.js +35 -1
  115. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportConstants.js +3 -0
  116. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportReducer.js +19 -0
  117. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportSelectors.js +4 -0
  118. data/webpack/components/ApplicationInstanceReport/__fixtures__/applicationInstanceReportData_1.fixtures.js +349 -0
  119. data/webpack/components/ApplicationInstanceReport/__fixtures__/applicationInstanceReportReducer.fixtures.js +20 -0
  120. data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReport.test.js +47 -0
  121. data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReportReducer.test.js +41 -0
  122. data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReportSelectors.test.js +26 -0
  123. data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReport.test.js.snap +7 -0
  124. data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReportReducer.test.js.snap +718 -0
  125. data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReportSelectors.test.js.snap +347 -0
  126. data/webpack/components/ApplicationInstanceReport/components/__tests__/ReportViewer.test.js +24 -0
  127. data/webpack/components/ApplicationInstanceReport/components/__tests__/__snapshots__/ReportViewer.test.js.snap +24 -0
  128. data/webpack/components/ApplicationInstanceReport/index.js +8 -1
  129. data/webpack/components/ExistingHostSelection/ExistingHostSelection.js +104 -0
  130. data/webpack/components/ExistingHostSelection/ExistingHostSelection.scss +15 -0
  131. data/webpack/components/ExistingHostSelection/ExistingHostSelectionActions.js +71 -0
  132. data/webpack/components/ExistingHostSelection/ExistingHostSelectionConstants.js +4 -0
  133. data/webpack/components/ExistingHostSelection/ExistingHostSelectionHelper.js +0 -0
  134. data/webpack/components/ExistingHostSelection/ExistingHostSelectionReducer.js +90 -0
  135. data/webpack/components/ExistingHostSelection/ExistingHostSelectionSelectors.js +8 -0
  136. data/webpack/components/ExistingHostSelection/__fixtures__/existingHostSelectionConfData_1.fixtures.js +191 -0
  137. data/webpack/components/ExistingHostSelection/__fixtures__/existingHostSelectionReducer.fixtures.js +203 -0
  138. data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelection.test.js +19 -0
  139. data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelectionReducer.test.js +59 -0
  140. data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelectionSelectors.test.js +36 -0
  141. data/webpack/components/ExistingHostSelection/__tests__/__snapshots__/ExistingHostSelection.test.js.snap +35 -0
  142. data/webpack/components/ExistingHostSelection/__tests__/__snapshots__/ExistingHostSelectionReducer.test.js.snap +614 -0
  143. data/webpack/components/ExistingHostSelection/__tests__/__snapshots__/ExistingHostSelectionSelectors.test.js.snap +27 -0
  144. data/webpack/components/ExistingHostSelection/components/ServiceSelector.js +48 -0
  145. data/webpack/components/ExistingHostSelection/components/__tests__/ServiceSelector.test.js +35 -0
  146. data/webpack/components/ExistingHostSelection/components/__tests__/__snapshots__/ServiceSelector.test.js.snap +77 -0
  147. data/webpack/components/ExistingHostSelection/index.js +26 -0
  148. data/webpack/components/ParameterSelection/ParameterSelection.js +103 -1
  149. data/webpack/components/ParameterSelection/ParameterSelection.scss +7 -0
  150. data/webpack/components/ParameterSelection/ParameterSelectionActions.js +46 -4
  151. data/webpack/components/ParameterSelection/ParameterSelectionConstants.js +2 -0
  152. data/webpack/components/ParameterSelection/ParameterSelectionHelper.js +5 -1
  153. data/webpack/components/ParameterSelection/ParameterSelectionReducer.js +51 -29
  154. data/webpack/components/ParameterSelection/ParameterSelectionSelectors.js +2 -0
  155. data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionData_1.fixtures.js +124 -84
  156. data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionReducer.fixtures.js +10 -4
  157. data/webpack/components/ParameterSelection/__tests__/ParameterSelection.test.js +36 -46
  158. data/webpack/components/ParameterSelection/__tests__/ParameterSelectionReducer.test.js +33 -25
  159. data/webpack/components/ParameterSelection/__tests__/ParameterSelectionSelectors.test.js +12 -6
  160. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelection.test.js.snap +84 -112
  161. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionReducer.test.js.snap +1589 -878
  162. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionSelectors.test.js.snap +130 -79
  163. data/webpack/components/ParameterSelection/index.js +4 -1
  164. data/webpack/components/SyncGitRepo/SyncGitRepo.js +202 -0
  165. data/webpack/components/SyncGitRepo/SyncGitRepo.scss +1 -0
  166. data/webpack/components/SyncGitRepo/SyncGitRepoActions.js +123 -0
  167. data/webpack/components/SyncGitRepo/SyncGitRepoConstants.js +8 -0
  168. data/webpack/components/SyncGitRepo/SyncGitRepoReducer.js +80 -0
  169. data/webpack/components/SyncGitRepo/SyncGitRepoSelectors.js +6 -0
  170. data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoConfData_1.fixtures.js +7 -0
  171. data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoReducer.fixtures.js +44 -0
  172. data/webpack/components/SyncGitRepo/__tests__/SyncGitRepo.test.js +27 -0
  173. data/webpack/components/SyncGitRepo/__tests__/SyncGitRepoReducer.test.js +95 -0
  174. data/webpack/components/SyncGitRepo/__tests__/SyncGitRepoSelectors.test.js +32 -0
  175. data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepo.test.js.snap +31 -0
  176. data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepoReducer.test.js.snap +137 -0
  177. data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepoSelectors.test.js.snap +13 -0
  178. data/webpack/components/SyncGitRepo/components/FormTextInput.js +42 -0
  179. data/webpack/components/SyncGitRepo/components/ScmTypeSelector.js +47 -0
  180. data/webpack/components/SyncGitRepo/index.js +28 -0
  181. data/webpack/components/common/DeleteTableEntry.js +16 -2
  182. data/webpack/components/common/ExtTextInput.js +43 -0
  183. data/webpack/components/common/__tests__/EditTableEntry.test.js +53 -0
  184. data/webpack/components/common/__tests__/LockTableEntry.test.js +35 -0
  185. data/webpack/components/common/__tests__/__snapshots__/DeleteTableEntry.test.js.snap +40 -2
  186. data/webpack/components/common/__tests__/__snapshots__/EditTableEntry.test.js.snap +81 -0
  187. data/webpack/components/common/__tests__/__snapshots__/LockTableEntry.test.js.snap +60 -0
  188. data/webpack/helper.js +35 -1
  189. data/webpack/helper.test.js +56 -0
  190. data/webpack/index.js +7 -0
  191. data/webpack/js-yaml.js +3874 -0
  192. data/webpack/reducer.js +16 -1
  193. data/webpack/test_setup.js +0 -2
  194. metadata +136 -11
  195. data/webpack/components/common/EasyHeaderFormatter.js +0 -18
  196. data/webpack/components/common/__tests__/__snapshots__/AddParameter.test.js.snap +0 -35
  197. data/webpack/components/common/__tests__/__snapshots__/DeleteParameter.test.js.snap +0 -41
@@ -0,0 +1,79 @@
1
+ import Immutable from 'seamless-immutable';
2
+ import {
3
+ cloneDeep,
4
+ findIndex,
5
+ findLastIndex,
6
+ } from 'lodash';
7
+
8
+ import {
9
+ applicationDefinitionConfData_1,
10
+ } from '../__fixtures__/applicationDefinitionConfData_1.fixtures';
11
+
12
+ export const successState = Immutable(applicationDefinitionConfData_1);
13
+
14
+ const EDIT_ROW_ID = 2;
15
+
16
+ const editClone = applicationDefinitionConfData_1;
17
+ const editIndex = findIndex(editClone.services, { id: EDIT_ROW_ID })
18
+ editClone["services"][editIndex].backup = cloneDeep(editClone["services"][editIndex]);
19
+ export const editState = Immutable(editClone);
20
+
21
+ // Payload Data
22
+ export const initApplicationDefinitionPayload = applicationDefinitionConfData_1;
23
+ export const addServicePayload = { };
24
+ export const deleteServicePayload = {
25
+ rowData: {
26
+ id: EDIT_ROW_ID,
27
+ },
28
+ };
29
+ export const activateEditServicePayload = {
30
+ rowData: {
31
+ id: EDIT_ROW_ID,
32
+ },
33
+ };
34
+ export const confirmEditServicePayload = {
35
+ rowData: {
36
+ id: EDIT_ROW_ID,
37
+ },
38
+ };
39
+ export const cancelEditServicePayload = {
40
+ rowData: {
41
+ id: EDIT_ROW_ID,
42
+ },
43
+ };
44
+ export const changeEditServicePayload = {
45
+ value: "helloworld",
46
+ property: "name",
47
+ rowData: {
48
+ id: EDIT_ROW_ID,
49
+ }
50
+ };
51
+
52
+ export const loadAnsibleDataRequestPayload = {
53
+ clearRows: false,
54
+ };
55
+
56
+ export const loadAnsibleDataSuccessPayload = {
57
+ id: 2,
58
+ name: "LAMP",
59
+ groups: {
60
+ webservers: {
61
+ dummy_var: "0"
62
+ },
63
+ dbservers: {
64
+ mysqlservice: "mysqld",
65
+ mysql_port: "3306",
66
+ dbuser: "webapp",
67
+ dbname: "ANSAP01",
68
+ upassword: "Bond@007",
69
+ masterpassword: "MySQL@007"
70
+ },
71
+ all: {
72
+ repository: "https://github.com/bennojoy/mywebapp.git"
73
+ }
74
+ }
75
+ };
76
+
77
+ export const loadAnsibleDataFailurePayload = {
78
+ error: "Something really bad happend",
79
+ };
@@ -0,0 +1,26 @@
1
+ import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
2
+
3
+ import ApplicationDefinition from '../ApplicationDefinition';
4
+
5
+ const noop = () => {};
6
+
7
+ const fixtures = {
8
+ 'should render application definition': {
9
+ data: {
10
+ location: "Default Location",
11
+ organization: "Default Organization",
12
+ hostgroups: [],
13
+ foremanDataUrl: "url/does/not/exist",
14
+ ansibleDataUrl: "url/does/not/exist",
15
+ services: [],
16
+ ansibleVarsAll: [],
17
+ },
18
+ closeAlertModal: noop,
19
+ loadAnsibleData: noop,
20
+ initApplicationDefinition: noop,
21
+ addApplicationDefinitionService: noop,
22
+ },
23
+ };
24
+
25
+ describe('ApplicationDefinition', () =>
26
+ testComponentSnapshotsWithFixtures(ApplicationDefinition, fixtures));
@@ -0,0 +1,119 @@
1
+ import { testReducerSnapshotWithFixtures } from 'react-redux-test-utils';
2
+ import reducer, { initialState } from '../ApplicationDefinitionReducer';
3
+
4
+ import {
5
+ successState,
6
+ editState,
7
+ initApplicationDefinitionPayload,
8
+ addServicePayload,
9
+ deleteServicePayload,
10
+ activateEditServicePayload,
11
+ confirmEditServicePayload,
12
+ cancelEditServicePayload,
13
+ changeEditServicePayload,
14
+ loadAnsibleDataRequestPayload,
15
+ loadAnsibleDataSuccessPayload,
16
+ loadAnsibleDataFailurePayload,
17
+ } from '../__fixtures__/applicationDefinitionReducer.fixtures';
18
+
19
+ import {
20
+ APPLICATION_DEFINITION_INIT,
21
+ APPLICATION_DEFINITION_LOAD_ANSIBLE_DATA_REQUEST,
22
+ APPLICATION_DEFINITION_LOAD_ANSIBLE_DATA_SUCCESS,
23
+ APPLICATION_DEFINITION_LOAD_ANSIBLE_DATA_FAILURE,
24
+ APPLICATION_DEFINITION_SERVICE_DELETE,
25
+ APPLICATION_DEFINITION_SERVICE_ADD,
26
+ APPLICATION_DEFINITION_SERVICE_EDIT_ACTIVATE,
27
+ APPLICATION_DEFINITION_SERVICE_EDIT_CONFIRM,
28
+ APPLICATION_DEFINITION_SERVICE_EDIT_CHANGE,
29
+ APPLICATION_DEFINITION_SERVICE_EDIT_CANCEL,
30
+ APPLICATION_DEFINITION_FOREMAN_PARAMETER_SELECTION_MODAL_OPEN,
31
+ APPLICATION_DEFINITION_FOREMAN_PARAMETER_SELECTION_MODAL_CLOSE,
32
+ APPLICATION_DEFINITION_ANSIBLE_PARAMETER_SELECTION_MODAL_OPEN,
33
+ APPLICATION_DEFINITION_ANSIBLE_PARAMETER_SELECTION_MODAL_CLOSE,
34
+ APPLICATION_DEFINITION_CHANGE_PARAMETER_SELECTION_MODE,
35
+ } from '../ApplicationDefinitionConstants';
36
+
37
+ const fixtures = {
38
+ 'should return initial state': {
39
+ state: initialState,
40
+ action: {
41
+ type: undefined,
42
+ payload: {},
43
+ },
44
+ },
45
+
46
+ 'should initialize component': {
47
+ state: initialState,
48
+ action: {
49
+ type: APPLICATION_DEFINITION_INIT,
50
+ payload: initApplicationDefinitionPayload,
51
+ },
52
+ },
53
+ 'should add a service': {
54
+ state: successState,
55
+ action: {
56
+ type: APPLICATION_DEFINITION_SERVICE_ADD,
57
+ payload: addServicePayload,
58
+ },
59
+ },
60
+ 'should delete a service': {
61
+ state: successState,
62
+ action: {
63
+ type: APPLICATION_DEFINITION_SERVICE_DELETE,
64
+ payload: deleteServicePayload,
65
+ },
66
+ },
67
+ 'should activate edit service': {
68
+ state: successState,
69
+ action: {
70
+ type: APPLICATION_DEFINITION_SERVICE_EDIT_ACTIVATE,
71
+ payload: activateEditServicePayload,
72
+ },
73
+ },
74
+ 'should change edit service': {
75
+ state: editState,
76
+ action: {
77
+ type: APPLICATION_DEFINITION_SERVICE_EDIT_CHANGE,
78
+ payload: changeEditServicePayload,
79
+ },
80
+ },
81
+ 'should confirm edit service': {
82
+ state: editState,
83
+ action: {
84
+ type: APPLICATION_DEFINITION_SERVICE_EDIT_CONFIRM,
85
+ payload: confirmEditServicePayload,
86
+ },
87
+ },
88
+ 'should cancel edit service': {
89
+ state: editState,
90
+ action: {
91
+ type: APPLICATION_DEFINITION_SERVICE_EDIT_CANCEL,
92
+ payload: cancelEditServicePayload,
93
+ },
94
+ },
95
+ 'should request load param data': {
96
+ state: successState,
97
+ action: {
98
+ type: APPLICATION_DEFINITION_LOAD_ANSIBLE_DATA_REQUEST,
99
+ payload: loadAnsibleDataRequestPayload,
100
+ },
101
+ },
102
+ 'should load param data be successful': {
103
+ state: successState,
104
+ action: {
105
+ type: APPLICATION_DEFINITION_LOAD_ANSIBLE_DATA_SUCCESS,
106
+ payload: loadAnsibleDataSuccessPayload,
107
+ },
108
+ },
109
+ 'should load param data be erroneous': {
110
+ state: successState,
111
+ action: {
112
+ type: APPLICATION_DEFINITION_LOAD_ANSIBLE_DATA_FAILURE,
113
+ payload: loadAnsibleDataFailurePayload,
114
+ },
115
+ },
116
+ };
117
+
118
+ describe('ApplicationDefintionReducer', () =>
119
+ testReducerSnapshotWithFixtures(reducer, fixtures));
@@ -0,0 +1,53 @@
1
+ import { testSelectorsSnapshotWithFixtures } from 'react-redux-test-utils';
2
+
3
+ import {
4
+ selectShowAlertModal,
5
+ selectAlertModalText,
6
+ selectAlertModalTitle,
7
+ selectEditMode,
8
+ selectAnsiblePlaybook,
9
+ selectServices,
10
+ selectColumns,
11
+ selectHiddenForemanParameterTypes,
12
+ selectParametersData,
13
+ selectAnsibleVarsAll,
14
+ selectParamEditMode,
15
+ } from '../ApplicationDefinitionSelectors';
16
+
17
+ import {
18
+ applicationDefinitionConfData_1,
19
+ } from '../__fixtures__/applicationDefinitionConfData_1.fixtures';
20
+
21
+ const stateFactory = obj => ({
22
+ foremanAcd: {
23
+ applicationDefinitionConf: obj,
24
+ },
25
+ });
26
+
27
+ const fixtures = {
28
+ 'should return showAlertModal from applicationDefinitionConfData_1 fixtures': () =>
29
+ selectShowAlertModal(stateFactory(applicationDefinitionConfData_1)),
30
+ 'should return alertModalText from applicationDefinitionConfData_1 fixtures': () =>
31
+ selectAlertModalText(stateFactory(applicationDefinitionConfData_1)),
32
+ 'should return alertModalTitle from applicationDefinitionConfData_1 fixtures': () =>
33
+ selectAlertModalTitle(stateFactory(applicationDefinitionConfData_1)),
34
+ 'should return editMode from applicationDefinitionConfData_1 fixtures': () =>
35
+ selectEditMode(stateFactory(applicationDefinitionConfData_1)),
36
+ 'should return ansiblePlaybook from applicationDefinitionConfData_1 fixtures': () =>
37
+ selectAnsiblePlaybook(stateFactory(applicationDefinitionConfData_1)),
38
+ 'should return services from applicationDefinitionConfData_1 fixtures': () =>
39
+ selectServices(stateFactory(applicationDefinitionConfData_1)),
40
+ 'should return parametersData from applicationDefinitionConfData_1 fixtures': () =>
41
+ selectParametersData(stateFactory(applicationDefinitionConfData_1)),
42
+ 'should return columns from applicationDefinitionConfData_1 fixtures': () =>
43
+ selectColumns(stateFactory(applicationDefinitionConfData_1)),
44
+ 'should return hiddenForemanParameterTypes from applicationDefinitionConfData_1 fixtures': () =>
45
+ selectHiddenForemanParameterTypes(stateFactory(applicationDefinitionConfData_1)),
46
+ 'should return ansibleVarsAll from applicationDefinitionConfData_1 fixtures': () =>
47
+ selectAnsibleVarsAll(stateFactory(applicationDefinitionConfData_1)),
48
+ 'should return ParamEditMode from applicationDefinitionConfData_1 fixtures': () =>
49
+ selectParamEditMode(stateFactory(applicationDefinitionConfData_1)),
50
+ };
51
+
52
+ describe('ApplicationDefinitionSelectors', () =>
53
+ testSelectorsSnapshotWithFixtures(fixtures));
@@ -0,0 +1,226 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`ApplicationDefinition should render application definition 1`] = `
4
+ <span>
5
+ <MessageDialog
6
+ accessibleDescription=""
7
+ accessibleName=""
8
+ className=""
9
+ enforceFocus={true}
10
+ footer={null}
11
+ icon={
12
+ <Icon
13
+ name="error-circle-o"
14
+ type="pf"
15
+ />
16
+ }
17
+ onHide={[Function]}
18
+ primaryAction={[Function]}
19
+ primaryActionButtonBsStyle="danger"
20
+ primaryActionButtonContent="OK"
21
+ primaryContent=""
22
+ secondaryAction={[Function]}
23
+ secondaryActionButtonBsStyle="default"
24
+ secondaryActionButtonContent={null}
25
+ secondaryContent={null}
26
+ show={false}
27
+ title=""
28
+ />
29
+ <div>
30
+ <AnsiblePlaybookSelector
31
+ additionalData={
32
+ Object {
33
+ "url": "url/does/not/exist",
34
+ }
35
+ }
36
+ editable={false}
37
+ hidden={false}
38
+ label="Ansible Playbook"
39
+ onChange={[Function]}
40
+ selectValue=""
41
+ viewText=""
42
+ />
43
+ <div
44
+ style={
45
+ Object {
46
+ "paddingTop": 25,
47
+ }
48
+ }
49
+ >
50
+ <pre>
51
+ Ansible Playbook can't be blank
52
+ </pre>
53
+ </div>
54
+ </div>
55
+ <div
56
+ className="form-group"
57
+ >
58
+ <TablePfProvider
59
+ bordered={true}
60
+ className=""
61
+ columns={Array []}
62
+ components={
63
+ Object {
64
+ "body": Object {
65
+ "cell": [Function],
66
+ "row": [Function],
67
+ },
68
+ }
69
+ }
70
+ condensed={false}
71
+ dataTable={true}
72
+ hover={true}
73
+ inlineEdit={true}
74
+ striped={true}
75
+ >
76
+ <Header
77
+ headerRows={
78
+ Array [
79
+ Array [],
80
+ ]
81
+ }
82
+ />
83
+ <Body
84
+ onRow={[Function]}
85
+ rowKey="id"
86
+ rows={Array []}
87
+ />
88
+ </TablePfProvider>
89
+ <AddTableEntry
90
+ disabled={true}
91
+ hidden={false}
92
+ onAddTableEntry={[Function]}
93
+ />
94
+ <span
95
+ style={
96
+ Object {
97
+ "marginLeft": 30,
98
+ }
99
+ }
100
+ >
101
+ Ansible group vars 'all':
102
+ <Button
103
+ active={false}
104
+ block={false}
105
+ bsClass="btn"
106
+ bsStyle="default"
107
+ disabled={false}
108
+ onClick={[Function]}
109
+ style={
110
+ Object {
111
+ "marginLeft": 10,
112
+ }
113
+ }
114
+ >
115
+ <span
116
+ title="Change ansible variables for 'all'"
117
+ >
118
+ A
119
+ </span>
120
+ </Button>
121
+ </span>
122
+ </div>
123
+ <div>
124
+ <ForemanModal
125
+ dialogClassName="param_selection_modal"
126
+ id="AppDefinitionForemanParamSelection"
127
+ title="Foreman Parameter definition for Application Definition"
128
+ >
129
+ <Header
130
+ closeButton={false}
131
+ >
132
+ Parameter definition
133
+ </Header>
134
+ <Connect(ParameterSelection)
135
+ data={Object {}}
136
+ editModeCallback={[Function]}
137
+ hiddenParameterTypes={Array []}
138
+ location="Default Location"
139
+ organization="Default Organization"
140
+ paramDataUrl="url/does/not/exist"
141
+ paramType="PARAMETER_SELECTION_PARAM_TYPE_FOREMAN"
142
+ />
143
+ <Footer>
144
+ <div>
145
+ <Button
146
+ active={false}
147
+ block={false}
148
+ bsClass="btn"
149
+ bsStyle="primary"
150
+ disabled={false}
151
+ onClick={[Function]}
152
+ >
153
+ Save
154
+ </Button>
155
+ <Button
156
+ active={false}
157
+ block={false}
158
+ bsClass="btn"
159
+ bsStyle="default"
160
+ disabled={false}
161
+ onClick={[Function]}
162
+ >
163
+ Cancel
164
+ </Button>
165
+ </div>
166
+ </Footer>
167
+ </ForemanModal>
168
+ </div>
169
+ <div>
170
+ <ForemanModal
171
+ dialogClassName="param_selection_modal"
172
+ id="AppDefinitionAnsibleParamSelection"
173
+ title="Ansible variables for Application Definition"
174
+ >
175
+ <Header
176
+ closeButton={false}
177
+ >
178
+ Parameter definition
179
+ </Header>
180
+ <Connect(ParameterSelection)
181
+ data={Object {}}
182
+ editModeCallback={[Function]}
183
+ location="Default Location"
184
+ organization="Default Organization"
185
+ paramType="PARAMETER_SELECTION_PARAM_TYPE_ANSIBLE"
186
+ />
187
+ <Footer>
188
+ <div>
189
+ <Button
190
+ active={false}
191
+ block={false}
192
+ bsClass="btn"
193
+ bsStyle="primary"
194
+ disabled={false}
195
+ onClick={[Function]}
196
+ >
197
+ Save
198
+ </Button>
199
+ <Button
200
+ active={false}
201
+ block={false}
202
+ bsClass="btn"
203
+ bsStyle="default"
204
+ disabled={false}
205
+ onClick={[Function]}
206
+ >
207
+ Cancel
208
+ </Button>
209
+ </div>
210
+ </Footer>
211
+ </ForemanModal>
212
+ </div>
213
+ <RailsData
214
+ key="application_definition_services_data"
215
+ parameter="services"
216
+ value="[]"
217
+ view="app_definition"
218
+ />
219
+ <RailsData
220
+ key="application_definition_ansible_data"
221
+ parameter="ansible_vars_all"
222
+ value="[]"
223
+ view="app_definition"
224
+ />
225
+ </span>
226
+ `;