hammer_cli_foreman 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (364) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +5 -0
  3. data/README.md +1 -15
  4. data/doc/configuration.md +38 -0
  5. data/doc/developer_docs.md +4 -3
  6. data/doc/release_notes.md +18 -0
  7. data/doc/testing.md +133 -0
  8. data/lib/hammer_cli_foreman.rb +4 -2
  9. data/lib/hammer_cli_foreman/api/connection.rb +21 -7
  10. data/lib/hammer_cli_foreman/api/interactive_basic_auth.rb +1 -1
  11. data/lib/hammer_cli_foreman/api/session_authenticator_wrapper.rb +6 -1
  12. data/lib/hammer_cli_foreman/api/void_auth.rb +8 -0
  13. data/lib/hammer_cli_foreman/auth.rb +1 -1
  14. data/lib/hammer_cli_foreman/common_parameter.rb +1 -0
  15. data/lib/hammer_cli_foreman/config_group.rb +45 -0
  16. data/lib/hammer_cli_foreman/defaults.rb +6 -3
  17. data/lib/hammer_cli_foreman/exception_handler.rb +36 -7
  18. data/lib/hammer_cli_foreman/filter.rb +61 -0
  19. data/lib/hammer_cli_foreman/host.rb +7 -5
  20. data/lib/hammer_cli_foreman/hosts/common_update_options.rb +17 -2
  21. data/lib/hammer_cli_foreman/output/fields.rb +3 -2
  22. data/lib/hammer_cli_foreman/output/formatters.rb +3 -2
  23. data/lib/hammer_cli_foreman/parameter.rb +5 -2
  24. data/lib/hammer_cli_foreman/references.rb +1 -1
  25. data/lib/hammer_cli_foreman/role.rb +18 -1
  26. data/lib/hammer_cli_foreman/template.rb +10 -10
  27. data/lib/hammer_cli_foreman/testing/api_expectations.rb +108 -8
  28. data/lib/hammer_cli_foreman/user.rb +25 -0
  29. data/lib/hammer_cli_foreman/version.rb +1 -1
  30. data/locale/ca/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  31. data/locale/de/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  32. data/locale/en/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  33. data/locale/en_GB/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  34. data/locale/es/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  35. data/locale/fr/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  36. data/locale/it/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  37. data/locale/ja/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  38. data/locale/ko/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  39. data/locale/pt_BR/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  40. data/locale/ru/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  41. data/locale/zh_CN/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  42. data/locale/zh_TW/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  43. data/test/data/1.14/_foreman_api.json +1 -0
  44. data/test/data/1.14/foreman_api.json +1 -0
  45. data/test/data/1.15/foreman_api.json +1 -0
  46. data/test/functional/host_test.rb +69 -1
  47. data/test/functional/role_test.rb +69 -0
  48. data/test/functional/template_test.rb +4 -4
  49. data/test/functional/test_helper.rb +0 -3
  50. data/test/functional/user_test.rb +85 -0
  51. data/test/test_helper.rb +4 -6
  52. data/test/unit/api/interactive_basic_auth_test.rb +2 -3
  53. data/test/unit/api/session_authenticator_wrapper_test.rb +24 -0
  54. data/test/unit/apipie_resource_mock.rb +180 -0
  55. data/test/unit/architecture_test.rb +3 -0
  56. data/test/unit/auth_source_ldap_test.rb +3 -0
  57. data/test/unit/commands_test.rb +2 -0
  58. data/test/unit/common_parameter_test.rb +13 -7
  59. data/test/unit/compute_resource_test.rb +6 -0
  60. data/test/unit/config_group_test.rb +72 -0
  61. data/test/unit/defaults_test.rb +28 -24
  62. data/test/unit/domain_test.rb +3 -0
  63. data/test/unit/environment_test.rb +3 -0
  64. data/test/unit/filter_test.rb +10 -2
  65. data/test/unit/host_test.rb +14 -1
  66. data/test/unit/hostgroup_test.rb +3 -0
  67. data/test/unit/image_test.rb +3 -0
  68. data/test/unit/media_test.rb +3 -0
  69. data/test/unit/model_test.rb +3 -0
  70. data/test/unit/partition_table_test.rb +3 -0
  71. data/test/unit/puppet_class_test.rb +3 -0
  72. data/test/unit/realm_test.rb +3 -0
  73. data/test/unit/report_test.rb +3 -0
  74. data/test/unit/smart_proxy_test.rb +3 -0
  75. data/test/unit/smart_variable_test.rb +0 -1
  76. data/test/unit/subnet_test.rb +3 -0
  77. data/test/unit/template_test.rb +9 -3
  78. data/test/unit/user_test.rb +6 -0
  79. data/test/unit/usergroup_test.rb +3 -0
  80. metadata +69 -577
  81. data/locale/Makefile +0 -57
  82. data/locale/README.md +0 -18
  83. data/locale/ca/hammer-cli-foreman.edit.po +0 -2910
  84. data/locale/ca/hammer-cli-foreman.po +0 -2823
  85. data/locale/ca/hammer-cli-foreman.po.time_stamp +0 -0
  86. data/locale/de/hammer-cli-foreman.edit.po +0 -2921
  87. data/locale/de/hammer-cli-foreman.po +0 -2827
  88. data/locale/de/hammer-cli-foreman.po.time_stamp +0 -0
  89. data/locale/en/hammer-cli-foreman.edit.po +0 -2865
  90. data/locale/en/hammer-cli-foreman.po +0 -2167
  91. data/locale/en/hammer-cli-foreman.po.time_stamp +0 -0
  92. data/locale/en_GB/hammer-cli-foreman.edit.po +0 -2888
  93. data/locale/en_GB/hammer-cli-foreman.po +0 -2825
  94. data/locale/en_GB/hammer-cli-foreman.po.time_stamp +0 -0
  95. data/locale/es/hammer-cli-foreman.edit.po +0 -2924
  96. data/locale/es/hammer-cli-foreman.po +0 -2829
  97. data/locale/es/hammer-cli-foreman.po.time_stamp +0 -0
  98. data/locale/fr/hammer-cli-foreman.edit.po +0 -2919
  99. data/locale/fr/hammer-cli-foreman.po +0 -2825
  100. data/locale/fr/hammer-cli-foreman.po.time_stamp +0 -0
  101. data/locale/hammer-cli-foreman.pot +0 -3080
  102. data/locale/it/hammer-cli-foreman.edit.po +0 -2909
  103. data/locale/it/hammer-cli-foreman.po +0 -2824
  104. data/locale/it/hammer-cli-foreman.po.time_stamp +0 -0
  105. data/locale/ja/hammer-cli-foreman.edit.po +0 -2919
  106. data/locale/ja/hammer-cli-foreman.po +0 -2824
  107. data/locale/ja/hammer-cli-foreman.po.time_stamp +0 -0
  108. data/locale/ko/hammer-cli-foreman.edit.po +0 -2917
  109. data/locale/ko/hammer-cli-foreman.po +0 -2823
  110. data/locale/ko/hammer-cli-foreman.po.time_stamp +0 -0
  111. data/locale/pt_BR/hammer-cli-foreman.edit.po +0 -2921
  112. data/locale/pt_BR/hammer-cli-foreman.po +0 -2826
  113. data/locale/pt_BR/hammer-cli-foreman.po.time_stamp +0 -0
  114. data/locale/ru/hammer-cli-foreman.edit.po +0 -2921
  115. data/locale/ru/hammer-cli-foreman.po +0 -2824
  116. data/locale/ru/hammer-cli-foreman.po.time_stamp +0 -0
  117. data/locale/zanata.xml +0 -28
  118. data/locale/zh_CN/hammer-cli-foreman.edit.po +0 -2917
  119. data/locale/zh_CN/hammer-cli-foreman.po +0 -2822
  120. data/locale/zh_CN/hammer-cli-foreman.po.time_stamp +0 -0
  121. data/locale/zh_TW/hammer-cli-foreman.edit.po +0 -2917
  122. data/locale/zh_TW/hammer-cli-foreman.po +0 -2822
  123. data/locale/zh_TW/hammer-cli-foreman.po.time_stamp +0 -0
  124. data/test/reports/TEST-HammerCLIForeman-Architecture-CreateCommand-parameters.xml +0 -11
  125. data/test/reports/TEST-HammerCLIForeman-Architecture-CreateCommand.xml +0 -7
  126. data/test/reports/TEST-HammerCLIForeman-Architecture-DeleteCommand-parameters.xml +0 -13
  127. data/test/reports/TEST-HammerCLIForeman-Architecture-DeleteCommand.xml +0 -7
  128. data/test/reports/TEST-HammerCLIForeman-Architecture-InfoCommand-output.xml +0 -13
  129. data/test/reports/TEST-HammerCLIForeman-Architecture-InfoCommand-parameters.xml +0 -13
  130. data/test/reports/TEST-HammerCLIForeman-Architecture-InfoCommand.xml +0 -7
  131. data/test/reports/TEST-HammerCLIForeman-Architecture-ListCommand-output.xml +0 -13
  132. data/test/reports/TEST-HammerCLIForeman-Architecture-ListCommand-parameters.xml +0 -17
  133. data/test/reports/TEST-HammerCLIForeman-Architecture-ListCommand.xml +0 -7
  134. data/test/reports/TEST-HammerCLIForeman-Architecture-UpdateCommand-parameters.xml +0 -15
  135. data/test/reports/TEST-HammerCLIForeman-Architecture-UpdateCommand.xml +0 -7
  136. data/test/reports/TEST-HammerCLIForeman-Architecture.xml +0 -7
  137. data/test/reports/TEST-HammerCLIForeman-CommonParameter-DeleteCommand-parameters.xml +0 -11
  138. data/test/reports/TEST-HammerCLIForeman-CommonParameter-DeleteCommand.xml +0 -7
  139. data/test/reports/TEST-HammerCLIForeman-CommonParameter-ListCommand-output.xml +0 -13
  140. data/test/reports/TEST-HammerCLIForeman-CommonParameter-ListCommand-parameters.xml +0 -17
  141. data/test/reports/TEST-HammerCLIForeman-CommonParameter-ListCommand.xml +0 -7
  142. data/test/reports/TEST-HammerCLIForeman-CommonParameter-SetCommand-parameters.xml +0 -13
  143. data/test/reports/TEST-HammerCLIForeman-CommonParameter-SetCommand.xml +0 -7
  144. data/test/reports/TEST-HammerCLIForeman-CommonParameter.xml +0 -7
  145. data/test/reports/TEST-HammerCLIForeman-ComputeResource-CreateCommand-parameters.xml +0 -15
  146. data/test/reports/TEST-HammerCLIForeman-ComputeResource-CreateCommand.xml +0 -7
  147. data/test/reports/TEST-HammerCLIForeman-ComputeResource-DeleteCommand-parameters.xml +0 -13
  148. data/test/reports/TEST-HammerCLIForeman-ComputeResource-DeleteCommand.xml +0 -7
  149. data/test/reports/TEST-HammerCLIForeman-ComputeResource-InfoCommand-output.xml +0 -17
  150. data/test/reports/TEST-HammerCLIForeman-ComputeResource-InfoCommand-parameters.xml +0 -13
  151. data/test/reports/TEST-HammerCLIForeman-ComputeResource-InfoCommand.xml +0 -7
  152. data/test/reports/TEST-HammerCLIForeman-ComputeResource-ListCommand-output.xml +0 -15
  153. data/test/reports/TEST-HammerCLIForeman-ComputeResource-ListCommand-parameters.xml +0 -17
  154. data/test/reports/TEST-HammerCLIForeman-ComputeResource-ListCommand.xml +0 -7
  155. data/test/reports/TEST-HammerCLIForeman-ComputeResource-UpdateCommand-parameters.xml +0 -15
  156. data/test/reports/TEST-HammerCLIForeman-ComputeResource-UpdateCommand.xml +0 -7
  157. data/test/reports/TEST-HammerCLIForeman-ComputeResource.xml +0 -7
  158. data/test/reports/TEST-HammerCLIForeman-Domain-CreateCommand-parameters.xml +0 -11
  159. data/test/reports/TEST-HammerCLIForeman-Domain-CreateCommand.xml +0 -7
  160. data/test/reports/TEST-HammerCLIForeman-Domain-DeleteCommand-parameters.xml +0 -13
  161. data/test/reports/TEST-HammerCLIForeman-Domain-DeleteCommand.xml +0 -7
  162. data/test/reports/TEST-HammerCLIForeman-Domain-DeleteParameterCommand-parameters.xml +0 -15
  163. data/test/reports/TEST-HammerCLIForeman-Domain-DeleteParameterCommand.xml +0 -7
  164. data/test/reports/TEST-HammerCLIForeman-Domain-InfoCommand-output.xml +0 -21
  165. data/test/reports/TEST-HammerCLIForeman-Domain-InfoCommand-parameters.xml +0 -13
  166. data/test/reports/TEST-HammerCLIForeman-Domain-InfoCommand.xml +0 -7
  167. data/test/reports/TEST-HammerCLIForeman-Domain-ListCommand-output.xml +0 -13
  168. data/test/reports/TEST-HammerCLIForeman-Domain-ListCommand-parameters.xml +0 -17
  169. data/test/reports/TEST-HammerCLIForeman-Domain-ListCommand.xml +0 -7
  170. data/test/reports/TEST-HammerCLIForeman-Domain-SetParameterCommand-parameters.xml +0 -17
  171. data/test/reports/TEST-HammerCLIForeman-Domain-SetParameterCommand.xml +0 -7
  172. data/test/reports/TEST-HammerCLIForeman-Domain-UpdateCommand-parameters.xml +0 -15
  173. data/test/reports/TEST-HammerCLIForeman-Domain-UpdateCommand.xml +0 -7
  174. data/test/reports/TEST-HammerCLIForeman-Domain.xml +0 -7
  175. data/test/reports/TEST-HammerCLIForeman-Environment-CreateCommand-parameters.xml +0 -11
  176. data/test/reports/TEST-HammerCLIForeman-Environment-CreateCommand.xml +0 -7
  177. data/test/reports/TEST-HammerCLIForeman-Environment-DeleteCommand-parameters.xml +0 -13
  178. data/test/reports/TEST-HammerCLIForeman-Environment-DeleteCommand.xml +0 -7
  179. data/test/reports/TEST-HammerCLIForeman-Environment-InfoCommand-output.xml +0 -17
  180. data/test/reports/TEST-HammerCLIForeman-Environment-InfoCommand-parameters.xml +0 -13
  181. data/test/reports/TEST-HammerCLIForeman-Environment-InfoCommand.xml +0 -7
  182. data/test/reports/TEST-HammerCLIForeman-Environment-ListCommand-output.xml +0 -13
  183. data/test/reports/TEST-HammerCLIForeman-Environment-ListCommand-parameters.xml +0 -17
  184. data/test/reports/TEST-HammerCLIForeman-Environment-ListCommand.xml +0 -7
  185. data/test/reports/TEST-HammerCLIForeman-Environment-UpdateCommand-parameters.xml +0 -15
  186. data/test/reports/TEST-HammerCLIForeman-Environment-UpdateCommand.xml +0 -7
  187. data/test/reports/TEST-HammerCLIForeman-Environment.xml +0 -7
  188. data/test/reports/TEST-HammerCLIForeman-ExceptionHandler.xml +0 -13
  189. data/test/reports/TEST-HammerCLIForeman-Host-CreateCommand-parameters.xml +0 -46
  190. data/test/reports/TEST-HammerCLIForeman-Host-CreateCommand.xml +0 -7
  191. data/test/reports/TEST-HammerCLIForeman-Host-DeleteCommand-parameters.xml +0 -13
  192. data/test/reports/TEST-HammerCLIForeman-Host-DeleteCommand.xml +0 -7
  193. data/test/reports/TEST-HammerCLIForeman-Host-DeleteParameterCommand-parameters.xml +0 -15
  194. data/test/reports/TEST-HammerCLIForeman-Host-DeleteParameterCommand.xml +0 -7
  195. data/test/reports/TEST-HammerCLIForeman-Host-InfoCommand-output.xml +0 -85
  196. data/test/reports/TEST-HammerCLIForeman-Host-InfoCommand-parameters.xml +0 -13
  197. data/test/reports/TEST-HammerCLIForeman-Host-InfoCommand.xml +0 -7
  198. data/test/reports/TEST-HammerCLIForeman-Host-ListCommand-output.xml +0 -21
  199. data/test/reports/TEST-HammerCLIForeman-Host-ListCommand-parameters.xml +0 -17
  200. data/test/reports/TEST-HammerCLIForeman-Host-ListCommand.xml +0 -7
  201. data/test/reports/TEST-HammerCLIForeman-Host-PuppetRunCommand-output.xml +0 -9
  202. data/test/reports/TEST-HammerCLIForeman-Host-PuppetRunCommand.xml +0 -7
  203. data/test/reports/TEST-HammerCLIForeman-Host-SetParameterCommand-parameters.xml +0 -17
  204. data/test/reports/TEST-HammerCLIForeman-Host-SetParameterCommand.xml +0 -7
  205. data/test/reports/TEST-HammerCLIForeman-Host-StatusCommand-output.xml +0 -9
  206. data/test/reports/TEST-HammerCLIForeman-Host-StatusCommand.xml +0 -7
  207. data/test/reports/TEST-HammerCLIForeman-Host-UpdateCommand-parameters.xml +0 -40
  208. data/test/reports/TEST-HammerCLIForeman-Host-UpdateCommand.xml +0 -7
  209. data/test/reports/TEST-HammerCLIForeman-Host.xml +0 -7
  210. data/test/reports/TEST-HammerCLIForeman-Hostgroup-CreateCommand-parameters.xml +0 -11
  211. data/test/reports/TEST-HammerCLIForeman-Hostgroup-CreateCommand.xml +0 -7
  212. data/test/reports/TEST-HammerCLIForeman-Hostgroup-DeleteCommand-parameters.xml +0 -11
  213. data/test/reports/TEST-HammerCLIForeman-Hostgroup-DeleteCommand.xml +0 -7
  214. data/test/reports/TEST-HammerCLIForeman-Hostgroup-DeleteParameterCommand-parameters.xml +0 -13
  215. data/test/reports/TEST-HammerCLIForeman-Hostgroup-DeleteParameterCommand.xml +0 -7
  216. data/test/reports/TEST-HammerCLIForeman-Hostgroup-InfoCommand-output.xml +0 -29
  217. data/test/reports/TEST-HammerCLIForeman-Hostgroup-InfoCommand-parameters.xml +0 -11
  218. data/test/reports/TEST-HammerCLIForeman-Hostgroup-InfoCommand.xml +0 -7
  219. data/test/reports/TEST-HammerCLIForeman-Hostgroup-ListCommand-output.xml +0 -27
  220. data/test/reports/TEST-HammerCLIForeman-Hostgroup-ListCommand-parameters.xml +0 -17
  221. data/test/reports/TEST-HammerCLIForeman-Hostgroup-ListCommand.xml +0 -7
  222. data/test/reports/TEST-HammerCLIForeman-Hostgroup-SetParameterCommand-parameters.xml +0 -15
  223. data/test/reports/TEST-HammerCLIForeman-Hostgroup-SetParameterCommand.xml +0 -7
  224. data/test/reports/TEST-HammerCLIForeman-Hostgroup-UpdateCommand-parameters.xml +0 -13
  225. data/test/reports/TEST-HammerCLIForeman-Hostgroup-UpdateCommand.xml +0 -7
  226. data/test/reports/TEST-HammerCLIForeman-Hostgroup.xml +0 -7
  227. data/test/reports/TEST-HammerCLIForeman-Location-CreateCommand-parameters.xml +0 -11
  228. data/test/reports/TEST-HammerCLIForeman-Location-CreateCommand-resource-disabled.xml +0 -11
  229. data/test/reports/TEST-HammerCLIForeman-Location-CreateCommand.xml +0 -7
  230. data/test/reports/TEST-HammerCLIForeman-Location-DeleteCommand-parameters.xml +0 -13
  231. data/test/reports/TEST-HammerCLIForeman-Location-DeleteCommand-resource-disabled.xml +0 -11
  232. data/test/reports/TEST-HammerCLIForeman-Location-DeleteCommand.xml +0 -7
  233. data/test/reports/TEST-HammerCLIForeman-Location-InfoCommand-output.xml +0 -17
  234. data/test/reports/TEST-HammerCLIForeman-Location-InfoCommand-parameters.xml +0 -13
  235. data/test/reports/TEST-HammerCLIForeman-Location-InfoCommand-resource-disabled.xml +0 -11
  236. data/test/reports/TEST-HammerCLIForeman-Location-InfoCommand.xml +0 -7
  237. data/test/reports/TEST-HammerCLIForeman-Location-ListCommand-output.xml +0 -13
  238. data/test/reports/TEST-HammerCLIForeman-Location-ListCommand-parameters.xml +0 -17
  239. data/test/reports/TEST-HammerCLIForeman-Location-ListCommand-resource-disabled.xml +0 -11
  240. data/test/reports/TEST-HammerCLIForeman-Location-ListCommand.xml +0 -7
  241. data/test/reports/TEST-HammerCLIForeman-Location-UpdateCommand-parameters.xml +0 -15
  242. data/test/reports/TEST-HammerCLIForeman-Location-UpdateCommand-resource-disabled.xml +0 -11
  243. data/test/reports/TEST-HammerCLIForeman-Location-UpdateCommand.xml +0 -7
  244. data/test/reports/TEST-HammerCLIForeman-Location.xml +0 -7
  245. data/test/reports/TEST-HammerCLIForeman-Medium-CreateCommand-parameters.xml +0 -13
  246. data/test/reports/TEST-HammerCLIForeman-Medium-CreateCommand.xml +0 -7
  247. data/test/reports/TEST-HammerCLIForeman-Medium-DeleteCommand-parameters.xml +0 -13
  248. data/test/reports/TEST-HammerCLIForeman-Medium-DeleteCommand.xml +0 -7
  249. data/test/reports/TEST-HammerCLIForeman-Medium-InfoCommand-output.xml +0 -23
  250. data/test/reports/TEST-HammerCLIForeman-Medium-InfoCommand-parameters.xml +0 -13
  251. data/test/reports/TEST-HammerCLIForeman-Medium-InfoCommand.xml +0 -7
  252. data/test/reports/TEST-HammerCLIForeman-Medium-ListCommand-output.xml +0 -15
  253. data/test/reports/TEST-HammerCLIForeman-Medium-ListCommand-parameters.xml +0 -17
  254. data/test/reports/TEST-HammerCLIForeman-Medium-ListCommand.xml +0 -7
  255. data/test/reports/TEST-HammerCLIForeman-Medium-UpdateCommand-parameters.xml +0 -17
  256. data/test/reports/TEST-HammerCLIForeman-Medium-UpdateCommand.xml +0 -7
  257. data/test/reports/TEST-HammerCLIForeman-Medium.xml +0 -7
  258. data/test/reports/TEST-HammerCLIForeman-OperatingSystem-CreateCommand-parameters.xml +0 -11
  259. data/test/reports/TEST-HammerCLIForeman-OperatingSystem-CreateCommand.xml +0 -7
  260. data/test/reports/TEST-HammerCLIForeman-OperatingSystem-DeleteCommand-parameters.xml +0 -13
  261. data/test/reports/TEST-HammerCLIForeman-OperatingSystem-DeleteCommand.xml +0 -7
  262. data/test/reports/TEST-HammerCLIForeman-OperatingSystem-DeleteParameterCommand-parameters.xml +0 -13
  263. data/test/reports/TEST-HammerCLIForeman-OperatingSystem-DeleteParameterCommand.xml +0 -7
  264. data/test/reports/TEST-HammerCLIForeman-OperatingSystem-InfoCommand-output.xml +0 -27
  265. data/test/reports/TEST-HammerCLIForeman-OperatingSystem-InfoCommand-parameters.xml +0 -13
  266. data/test/reports/TEST-HammerCLIForeman-OperatingSystem-InfoCommand.xml +0 -7
  267. data/test/reports/TEST-HammerCLIForeman-OperatingSystem-ListCommand-output.xml +0 -17
  268. data/test/reports/TEST-HammerCLIForeman-OperatingSystem-ListCommand-parameters.xml +0 -17
  269. data/test/reports/TEST-HammerCLIForeman-OperatingSystem-ListCommand.xml +0 -7
  270. data/test/reports/TEST-HammerCLIForeman-OperatingSystem-SetParameterCommand-parameters.xml +0 -15
  271. data/test/reports/TEST-HammerCLIForeman-OperatingSystem-SetParameterCommand.xml +0 -7
  272. data/test/reports/TEST-HammerCLIForeman-OperatingSystem-UpdateCommand-parameters.xml +0 -17
  273. data/test/reports/TEST-HammerCLIForeman-OperatingSystem-UpdateCommand.xml +0 -7
  274. data/test/reports/TEST-HammerCLIForeman-OperatingSystem.xml +0 -7
  275. data/test/reports/TEST-HammerCLIForeman-Organization-CreateCommand-parameters.xml +0 -11
  276. data/test/reports/TEST-HammerCLIForeman-Organization-CreateCommand-resource-disabled.xml +0 -11
  277. data/test/reports/TEST-HammerCLIForeman-Organization-CreateCommand.xml +0 -7
  278. data/test/reports/TEST-HammerCLIForeman-Organization-DeleteCommand-parameters.xml +0 -13
  279. data/test/reports/TEST-HammerCLIForeman-Organization-DeleteCommand-resource-disabled.xml +0 -11
  280. data/test/reports/TEST-HammerCLIForeman-Organization-DeleteCommand.xml +0 -7
  281. data/test/reports/TEST-HammerCLIForeman-Organization-InfoCommand-output.xml +0 -17
  282. data/test/reports/TEST-HammerCLIForeman-Organization-InfoCommand-parameters.xml +0 -13
  283. data/test/reports/TEST-HammerCLIForeman-Organization-InfoCommand-resource-disabled.xml +0 -11
  284. data/test/reports/TEST-HammerCLIForeman-Organization-InfoCommand.xml +0 -7
  285. data/test/reports/TEST-HammerCLIForeman-Organization-ListCommand-output.xml +0 -13
  286. data/test/reports/TEST-HammerCLIForeman-Organization-ListCommand-parameters.xml +0 -17
  287. data/test/reports/TEST-HammerCLIForeman-Organization-ListCommand-resource-disabled.xml +0 -11
  288. data/test/reports/TEST-HammerCLIForeman-Organization-ListCommand.xml +0 -7
  289. data/test/reports/TEST-HammerCLIForeman-Organization-UpdateCommand-parameters.xml +0 -15
  290. data/test/reports/TEST-HammerCLIForeman-Organization-UpdateCommand-resource-disabled.xml +0 -11
  291. data/test/reports/TEST-HammerCLIForeman-Organization-UpdateCommand.xml +0 -7
  292. data/test/reports/TEST-HammerCLIForeman-Organization.xml +0 -7
  293. data/test/reports/TEST-HammerCLIForeman-PartitionTable-CreateCommand-parameters.xml +0 -13
  294. data/test/reports/TEST-HammerCLIForeman-PartitionTable-CreateCommand.xml +0 -7
  295. data/test/reports/TEST-HammerCLIForeman-PartitionTable-DeleteCommand-parameters.xml +0 -13
  296. data/test/reports/TEST-HammerCLIForeman-PartitionTable-DeleteCommand.xml +0 -7
  297. data/test/reports/TEST-HammerCLIForeman-PartitionTable-DumpCommand-parameters.xml +0 -15
  298. data/test/reports/TEST-HammerCLIForeman-PartitionTable-DumpCommand.xml +0 -7
  299. data/test/reports/TEST-HammerCLIForeman-PartitionTable-InfoCommand-output.xml +0 -19
  300. data/test/reports/TEST-HammerCLIForeman-PartitionTable-InfoCommand-parameters.xml +0 -13
  301. data/test/reports/TEST-HammerCLIForeman-PartitionTable-InfoCommand.xml +0 -7
  302. data/test/reports/TEST-HammerCLIForeman-PartitionTable-ListCommand-output.xml +0 -15
  303. data/test/reports/TEST-HammerCLIForeman-PartitionTable-ListCommand-parameters.xml +0 -17
  304. data/test/reports/TEST-HammerCLIForeman-PartitionTable-ListCommand.xml +0 -7
  305. data/test/reports/TEST-HammerCLIForeman-PartitionTable-UpdateCommand-parameters.xml +0 -13
  306. data/test/reports/TEST-HammerCLIForeman-PartitionTable-UpdateCommand.xml +0 -7
  307. data/test/reports/TEST-HammerCLIForeman-PartitionTable.xml +0 -7
  308. data/test/reports/TEST-HammerCLIForeman-SmartProxy-CreateCommand-parameters.xml +0 -13
  309. data/test/reports/TEST-HammerCLIForeman-SmartProxy-CreateCommand.xml +0 -7
  310. data/test/reports/TEST-HammerCLIForeman-SmartProxy-DeleteCommand-parameters.xml +0 -13
  311. data/test/reports/TEST-HammerCLIForeman-SmartProxy-DeleteCommand.xml +0 -7
  312. data/test/reports/TEST-HammerCLIForeman-SmartProxy-InfoCommand-output.xml +0 -21
  313. data/test/reports/TEST-HammerCLIForeman-SmartProxy-InfoCommand-parameters.xml +0 -13
  314. data/test/reports/TEST-HammerCLIForeman-SmartProxy-InfoCommand.xml +0 -7
  315. data/test/reports/TEST-HammerCLIForeman-SmartProxy-ListCommand-output.xml +0 -15
  316. data/test/reports/TEST-HammerCLIForeman-SmartProxy-ListCommand-parameters.xml +0 -11
  317. data/test/reports/TEST-HammerCLIForeman-SmartProxy-ListCommand.xml +0 -7
  318. data/test/reports/TEST-HammerCLIForeman-SmartProxy-UpdateCommand-parameters.xml +0 -15
  319. data/test/reports/TEST-HammerCLIForeman-SmartProxy-UpdateCommand.xml +0 -7
  320. data/test/reports/TEST-HammerCLIForeman-SmartProxy.xml +0 -7
  321. data/test/reports/TEST-HammerCLIForeman-Subnet-CreateCommand-parameters.xml +0 -15
  322. data/test/reports/TEST-HammerCLIForeman-Subnet-CreateCommand.xml +0 -7
  323. data/test/reports/TEST-HammerCLIForeman-Subnet-DeleteCommand-parameters.xml +0 -13
  324. data/test/reports/TEST-HammerCLIForeman-Subnet-DeleteCommand.xml +0 -7
  325. data/test/reports/TEST-HammerCLIForeman-Subnet-InfoCommand-output.xml +0 -43
  326. data/test/reports/TEST-HammerCLIForeman-Subnet-InfoCommand-parameters.xml +0 -13
  327. data/test/reports/TEST-HammerCLIForeman-Subnet-InfoCommand.xml +0 -7
  328. data/test/reports/TEST-HammerCLIForeman-Subnet-ListCommand-output.xml +0 -17
  329. data/test/reports/TEST-HammerCLIForeman-Subnet-ListCommand-parameters.xml +0 -17
  330. data/test/reports/TEST-HammerCLIForeman-Subnet-ListCommand.xml +0 -7
  331. data/test/reports/TEST-HammerCLIForeman-Subnet-UpdateCommand-parameters.xml +0 -15
  332. data/test/reports/TEST-HammerCLIForeman-Subnet-UpdateCommand.xml +0 -7
  333. data/test/reports/TEST-HammerCLIForeman-Subnet.xml +0 -7
  334. data/test/reports/TEST-HammerCLIForeman-Template-CreateCommand-parameters.xml +0 -15
  335. data/test/reports/TEST-HammerCLIForeman-Template-CreateCommand.xml +0 -7
  336. data/test/reports/TEST-HammerCLIForeman-Template-DeleteCommand-parameters.xml +0 -11
  337. data/test/reports/TEST-HammerCLIForeman-Template-DeleteCommand.xml +0 -7
  338. data/test/reports/TEST-HammerCLIForeman-Template-DumpCommand-parameters.xml +0 -12
  339. data/test/reports/TEST-HammerCLIForeman-Template-DumpCommand.xml +0 -7
  340. data/test/reports/TEST-HammerCLIForeman-Template-InfoCommand-output.xml +0 -17
  341. data/test/reports/TEST-HammerCLIForeman-Template-InfoCommand-parameters.xml +0 -11
  342. data/test/reports/TEST-HammerCLIForeman-Template-InfoCommand.xml +0 -7
  343. data/test/reports/TEST-HammerCLIForeman-Template-ListCommand-output.xml +0 -15
  344. data/test/reports/TEST-HammerCLIForeman-Template-ListCommand-parameters.xml +0 -17
  345. data/test/reports/TEST-HammerCLIForeman-Template-ListCommand.xml +0 -7
  346. data/test/reports/TEST-HammerCLIForeman-Template-ListKindsCommand-parameters.xml +0 -9
  347. data/test/reports/TEST-HammerCLIForeman-Template-ListKindsCommand.xml +0 -7
  348. data/test/reports/TEST-HammerCLIForeman-Template-UpdateCommand-parameters.xml +0 -11
  349. data/test/reports/TEST-HammerCLIForeman-Template-UpdateCommand.xml +0 -7
  350. data/test/reports/TEST-HammerCLIForeman-Template.xml +0 -7
  351. data/test/reports/TEST-HammerCLIForeman-User-CreateCommand-parameters.xml +0 -19
  352. data/test/reports/TEST-HammerCLIForeman-User-CreateCommand.xml +0 -7
  353. data/test/reports/TEST-HammerCLIForeman-User-DeleteCommand-parameters.xml +0 -11
  354. data/test/reports/TEST-HammerCLIForeman-User-DeleteCommand.xml +0 -7
  355. data/test/reports/TEST-HammerCLIForeman-User-InfoCommand-output.xml +0 -23
  356. data/test/reports/TEST-HammerCLIForeman-User-InfoCommand-parameters.xml +0 -11
  357. data/test/reports/TEST-HammerCLIForeman-User-InfoCommand.xml +0 -7
  358. data/test/reports/TEST-HammerCLIForeman-User-ListCommand-output.xml +0 -17
  359. data/test/reports/TEST-HammerCLIForeman-User-ListCommand-parameters.xml +0 -17
  360. data/test/reports/TEST-HammerCLIForeman-User-ListCommand.xml +0 -7
  361. data/test/reports/TEST-HammerCLIForeman-User-UpdateCommand-parameters.xml +0 -11
  362. data/test/reports/TEST-HammerCLIForeman-User-UpdateCommand.xml +0 -7
  363. data/test/reports/TEST-HammerCLIForeman-User.xml +0 -7
  364. data/test/reports/TEST-MiniTest-Spec.xml +0 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c8dbe72d7f0cdd60461bcb2ceedbdb241791e9ba
4
- data.tar.gz: 7a93863b4b5dfa7e2318e8842df64ee23de005a1
3
+ metadata.gz: 9d37a2ec65a64506f68335f48ce44b78b113f26e
4
+ data.tar.gz: 7d4a6b52ec543e70fff320237fffaebdbe5adad7
5
5
  SHA512:
6
- metadata.gz: 645d647eec03ddee3afd4c4f61677fd1ecfa98b9981cf72d150ac8cb9d68f0adc7b5b1e88c30ad4da52d7fe3463a889a4ad6622b51716cb6ad315f3d3e61b1d3
7
- data.tar.gz: f2c39dccfb3949685b4a77703274aa7bcf683953a25ee271fcff63d9152f285ed833dcc00ec4cc3c61064ac92d21145d45ac9d7eb667e38945370b0eb8430533
6
+ metadata.gz: 79eaebf4bd95a1c7516fd08af892da46e752ae55c5f6f6815722f382b7c0bf0099bd84d8d0f17968c35283c2eb73ae3ef0befb11855c1c74ebfdfa3c53ae6fe3
7
+ data.tar.gz: 7dd25990c3bc04af071837f7b6bdaa3cfa00d6830310e09d123e03e82fe0143affe25814720f5a42db560df4147ceeeaffb4d4c21dc88be3fcd2fa8309f5971b
data/LICENSE ADDED
@@ -0,0 +1,5 @@
1
+ This program and entire repository is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.
2
+
3
+ This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
4
+
5
+ You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
data/README.md CHANGED
@@ -37,21 +37,7 @@ look at [the development documentation](doc/developer_docs.md#hammer-development
37
37
 
38
38
  How to test
39
39
  ------------
40
-
41
- ```bash
42
- $ bundle install
43
- $ bundle exec "rake test"
44
- ```
45
-
46
- Generated coverage reports are stored in ./coverage directory.
47
-
48
- There is support for testing against API documentation (and sample data) generated from different versions of Foreman.
49
- The required version of Foreman can be set in env variable `TEST_API_VERSION`. Make sure the requested data are
50
- in `test/unit/data/<version>/`.
51
-
52
- ```bash
53
- $ TEST_API_VERSION=1.10 bundle exec rake test
54
- ```
40
+ Please read our [testing documentation](doc/testing.md#testing-hammer-commands) for more information about how to write and run tests.
55
41
 
56
42
 
57
43
  License
data/doc/configuration.md CHANGED
@@ -11,3 +11,41 @@ from `config/foreman.yml`.
11
11
 
12
12
  See our [sample config file](https://github.com/theforeman/hammer-cli-foreman/blob/master/config/foreman.yml)
13
13
  that lists all available configuration options with descriptions.
14
+
15
+ ## Authentication
16
+ ### Basic auth
17
+ Basic authentication with username and password is currently the only supported method.
18
+
19
+ You can save your credentials into hammer config file in your home directory:
20
+ `~/.hammer/cli.modules.d/foreman.yml`
21
+ ```yaml
22
+ :foreman:
23
+ :username: 'admin'
24
+ :password: 'example'
25
+ ```
26
+
27
+ Credentials can be passed directly on the command line too:
28
+ ```bash
29
+ hammer -u admin -p example ...
30
+ ```
31
+
32
+ If there are no credentials in neither config files nor command line, hammer asks for them interactively:
33
+ ```
34
+ >> hammer host list
35
+ [Foreman] Username: admin
36
+ [Foreman] Password for admin:
37
+ ...
38
+ ```
39
+
40
+ **Sessions**
41
+
42
+ Hammer supports session authentication to reduce the need of entering credentials for each command.
43
+ It's disabled by default. To turn it on, put following into your config file:
44
+ ```yaml
45
+ :foreman:
46
+ :use_sessions: true
47
+ ```
48
+ Unfortunately retry on session expiry is yet to be implemented. Therefore you'll observe first command to fail
49
+ after the session expires.
50
+
51
+ The default session timeout is 1 hour. This can be changed in the Foreman: `Settings > Authentication > Idle timeout`
@@ -6,9 +6,10 @@ There's a lot of useful information in
6
6
  Studying it first can help you to understand the basic principles.
7
7
 
8
8
  Foreman plugin extends the Hammer Core in following areas:
9
- - [Using HammerCLIForeman::Command](using_hammer_cli_foreman_command.md)
10
- - [Building options](option_builder.md#option-builder)
11
- - [Automatic name resolution](name_id_resolution.md#name---id-resolution)
9
+ - [Using HammerCLIForeman::Command](using_hammer_cli_foreman_command.md#using-hammercliforeman)
10
+ - [Building options](option_builder.md#option-builders)
11
+ - [Automatic name resolution](name_id_resolution.md#name-to-id-resolution)
12
+ - [Testing commands](testing.md#testing-hammer-commands)
12
13
 
13
14
  It's recommended that you set `:refresh_cache: true` in the plugin settings if
14
15
  engaging in API development to enable aggressive apidoc cache checking.
data/doc/release_notes.md CHANGED
@@ -1,5 +1,23 @@
1
1
  Release notes
2
2
  =============
3
+
4
+ ### 0.10.0 (2017-03-28)
5
+ * Adding --hidden-value option to parameters (#290) ([#18878](http://projects.theforeman.org/issues/18878))
6
+ * Add command to clone user role ([#18318](http://projects.theforeman.org/issues/18318))
7
+ * Default organization/location work with authenticators ([#17936](http://projects.theforeman.org/issues/17936))
8
+ * Display hostgroup title on host actions ([#18739](http://projects.theforeman.org/issues/18739))
9
+ * Respect original request_params ([#18790](http://projects.theforeman.org/issues/18790))
10
+ * Rename config template to provisioning template ([#18654](http://projects.theforeman.org/issues/18654))
11
+ * User create/update accepts organization/location name ([#17923](http://projects.theforeman.org/issues/17923))
12
+ * Skip generating option --root-pass for host create ([#18337](http://projects.theforeman.org/issues/18337))
13
+ * Session authenticator keeps asking for user ([#18170](http://projects.theforeman.org/issues/18170))
14
+ * Host create uses name options ([#18339](http://projects.theforeman.org/issues/18339))
15
+ * Only include .mo files below locale/ ([#18439](http://projects.theforeman.org/issues/18439))
16
+ * Add config group commands ([#7520](http://projects.theforeman.org/issues/7520))
17
+ * Poweroff hosts when using --force option ([#18319](http://projects.theforeman.org/issues/18319))
18
+ * Resolve subnet and domain for host create/update (#273) ([#17247](http://projects.theforeman.org/issues/17247))
19
+ * Prevent from setting taxonomies for non-overriding filters ([#17730](http://projects.theforeman.org/issues/17730))
20
+
3
21
  ### 0.9.0 (2016-12-15)
4
22
  * Auth overrides only unauthorized exception ([PR #271](https://github.com/theforeman/hammer-cli-foreman/pull/271)) ([#17650](http://projects.theforeman.org/issues/17650))
5
23
  * Session auth in hammer ([PR #269](https://github.com/theforeman/hammer-cli-foreman/pull/269)) ([#8016](http://projects.theforeman.org/issues/8016))
data/doc/testing.md ADDED
@@ -0,0 +1,133 @@
1
+ # Testing hammer commands
2
+
3
+ Commands from `hammer-cli-foreman` are tested by two types of tests:
4
+ - *unit tests* - They're placed in `test/unit` and test only basic functionality of the commands like accepted options and field labels printed to stdout. Unit tests for commands are no longer extended.
5
+ - *functional tests* - They're placed in `test/functional` and aim to test commands in broader context. Functional tests require mocking the api calls and should also test output based on data returned from the api. This is preferable way of testing the commands.
6
+
7
+
8
+ ## Running the tests
9
+
10
+ ```bash
11
+ bundle install
12
+ bundle exec rake test
13
+ ```
14
+
15
+ Generated coverage reports are stored in ./coverage directory.
16
+
17
+ There is support for testing against API documentation generated from different versions of Foreman.
18
+ The required version of Foreman can be set in env variable `TEST_API_VERSION`. Make sure the requested data are in `test/unit/data/<version>/`.
19
+ ```bash
20
+ $ TEST_API_VERSION=1.13 bundle exec rake test
21
+ ```
22
+
23
+ ## Testing API expectations
24
+
25
+ `hammer-cli-foreman` comes with a set of helpers and extensions to [Mocha](https://github.com/freerange/mocha) library for easier testing and better error detection.
26
+
27
+ The extensions are included in `test/test_helper.rb` by default. It's also possible to include it elswhere when needed:
28
+ ```ruby
29
+ require 'hammer_cli_foreman/testing/api_expectations'
30
+ include HammerCLIForeman::Testing::APIExpectations
31
+ ```
32
+
33
+ ### Available helper functions
34
+
35
+ **`api_expects`**`(resource=nil, action=nil, note=nil, &block)`
36
+ * `resource` Symbol with plural name of the resource.
37
+ * `action` Symbol with action name.
38
+ * `note` String with description of the expected call to make its identification easier when the expectation fails.
39
+ * `&block` Optional block for testing parameters.
40
+
41
+ `api_expects` is often used together with `with_params` that set expectation on parameters that need to be included in the call:
42
+ ```ruby
43
+ describe 'hostgroup create' do
44
+ it 'passes architecture id' do
45
+ api_expects(:hostgroups, :create, 'Create hostgroup with architecture_id').with_params('hostgroup' => {
46
+ 'name' => 'hg1',
47
+ 'architecture_id' => 1
48
+ })
49
+
50
+ run_cmd(%w(hostgroup create --name hg1 --architecture-id 1))
51
+ end
52
+ end
53
+ ```
54
+
55
+ The expectation failure is reported with description of the call and expected parameters to make searching for mistakes easier:
56
+ ```
57
+ unexpected invocation: #<AnyInstance:ApipieBindings::API>.call_action(<Action hostgroups:create>, {'hostgroup' => {'name' => 'hg1', 'architecture_id' => 2}}, {}, {:fake_response => nil})
58
+ unsatisfied expectations:
59
+ - expected exactly once, not yet invoked: Create hostgroup with architecture_id
60
+ #<AnyInstance:ApipieBindings::API>.call_action(:hostgroups, :create, *any_argument)
61
+ expected params to include: {
62
+ "hostgroup": {
63
+ "name": "hg1",
64
+ "architecture_id": 1
65
+ }
66
+ }
67
+ ```
68
+
69
+ Alternatively parameters can be tested in a block:
70
+ ```ruby
71
+ describe 'hostgroup create' do
72
+ it 'passes architecture id' do
73
+ api_expects(:hostgroups, :create, 'Create hostgroup with architecture_id') do |p|
74
+ p['hostgroup']['architecture_id'] == 1 && p['hostgroup']['name'] == 'hg1'
75
+ end
76
+
77
+ run_cmd(%w(hostgroup create --name hg1 --architecture-id 1))
78
+ end
79
+ end
80
+ ```
81
+
82
+ This approach gives more freedom in what is tested and how but can't report what parameters were expected in case of failure.
83
+
84
+ **`api_expects_no_call`**
85
+
86
+ Makes sure no API call is performed.
87
+
88
+ Example:
89
+ ```ruby
90
+ describe 'hostgroup create' do
91
+ it "doesn't perform any api request when name is missing" do
92
+ api_expects_no_call
93
+ run_cmd(%w(hostgroup create))
94
+ end
95
+ end
96
+ ```
97
+
98
+ **`api_expects_search`**`(resource=nil, search_options={}, note=nil)`
99
+ * `resource` Symbol with plural name of the resource.
100
+ * `search_options` Either hash with options to search by (eg. `:name => 'x86_64'`) or a string with the search query.
101
+ * `note` String with description of the expected call to make its identification easier when the expectation fails.
102
+
103
+ Helper that sets expectation on searching for a resource when hammer translates from name of the resource to its id. It's often used together with `returns` that mocks result of the search query.
104
+
105
+ Example:
106
+ ```ruby
107
+ describe 'hostgroup create' do
108
+ let(:arch) {{'id' => 1, 'name' => 'arch1'}}
109
+
110
+ it 'resolves architecture name' do
111
+ api_expects_search(:architectures, { :name => 'arch1' }).returns(index_response([arch]))
112
+ run_cmd(%w(hostgroup create --name hg1 --architecture arch1))
113
+ end
114
+ end
115
+ ```
116
+
117
+ **`api_connection`**`(options={}, version = '1.15')`
118
+ * `options` Hash with options for the api connection.
119
+ * `version` Version of the Foreman apidoc. Available exported versions are located in subdirectories of `test/data/`.
120
+
121
+ The function returns instance of `FakeApiConnection` that makes `#authenticator` public and allows setting expectations on it. Useful for injection of api instances into tested objects.
122
+
123
+ **`APIExpectationsDecorator`**
124
+
125
+ Decorator class that adds helpers for setting expectations on the wrapped api instance.
126
+ Provides methods `expects_call`, `expects_no_call` and `expects_search` that behave similarly to the helpers described above.
127
+
128
+ Example usage:
129
+ ```ruby
130
+ connection = api_connection
131
+ api = APIExpectationsDecorator.new(connection.api)
132
+ api.expects_search(:users, 'login=admin')
133
+ ```
@@ -18,8 +18,6 @@ module HammerCLIForeman
18
18
  require 'hammer_cli_foreman/param_filters'
19
19
  require 'hammer_cli_foreman/id_resolver'
20
20
  require 'hammer_cli_foreman/dependency_resolver'
21
- require 'hammer_cli_foreman/defaults'
22
-
23
21
 
24
22
  begin
25
23
  require 'hammer_cli_foreman/commands'
@@ -27,6 +25,7 @@ module HammerCLIForeman
27
25
  require 'hammer_cli_foreman/references'
28
26
  require 'hammer_cli_foreman/parameter'
29
27
  require 'hammer_cli_foreman/common_parameter'
28
+ require 'hammer_cli_foreman/defaults'
30
29
 
31
30
  HammerCLI::MainCommand.lazy_subcommand('auth', _("Foreman connection login/logout."),
32
31
  'HammerCLIForeman::Auth', 'hammer_cli_foreman/auth'
@@ -140,6 +139,9 @@ module HammerCLIForeman
140
139
  'HammerCLIForeman::Usergroup', 'hammer_cli_foreman/usergroup'
141
140
  )
142
141
 
142
+ HammerCLI::MainCommand.lazy_subcommand('config-group', _("Manipulate config groups."),
143
+ 'HammerCLIForeman::ConfigGroup', 'hammer_cli_foreman/config_group'
144
+ )
143
145
 
144
146
  rescue => e
145
147
  handler = HammerCLIForeman::ExceptionHandler.new(:context => {}, :adapter => :base)
@@ -1,5 +1,6 @@
1
1
  require 'hammer_cli_foreman/api/session_authenticator_wrapper'
2
2
  require 'hammer_cli_foreman/api/interactive_basic_auth'
3
+ require 'hammer_cli_foreman/api/void_auth'
3
4
 
4
5
  module HammerCLIForeman
5
6
  module Api
@@ -30,14 +31,27 @@ module HammerCLIForeman
30
31
  protected
31
32
 
32
33
  def create_authenticator(uri, settings)
33
- return @authenticator unless @authenticator.nil?
34
+ return @authenticator if @authenticator
34
35
 
35
- @authenticator = InteractiveBasicAuth.new(
36
- settings.get(:_params, :username) || ENV['FOREMAN_USERNAME'] || settings.get(:foreman, :username),
37
- settings.get(:_params, :password) || ENV['FOREMAN_PASSWORD'] || settings.get(:foreman, :password)
38
- )
39
- @authenticator = SessionAuthenticatorWrapper.new(@authenticator, uri) if settings.get(:foreman, :use_sessions)
40
- @authenticator
36
+ if ssl_cert_authentication?(settings) && !use_basic_auth?(settings)
37
+ @authenticator = VoidAuth.new
38
+ else
39
+ @authenticator = InteractiveBasicAuth.new(
40
+ settings.get(:_params, :username) || ENV['FOREMAN_USERNAME'] || settings.get(:foreman, :username),
41
+ settings.get(:_params, :password) || ENV['FOREMAN_PASSWORD'] || settings.get(:foreman, :password)
42
+ )
43
+ @authenticator = SessionAuthenticatorWrapper.new(@authenticator, uri) if settings.get(:foreman, :use_sessions)
44
+ @authenticator
45
+ end
46
+ end
47
+
48
+ def ssl_cert_authentication?(settings)
49
+ (settings.get(:_params, :ssl_client_cert) || settings.get(:ssl, :ssl_client_cert)) &&
50
+ (settings.get(:_params, :ssl_client_key) || settings.get(:ssl, :ssl_client_key))
51
+ end
52
+
53
+ def use_basic_auth?(settings)
54
+ settings.get(:_params, :ssl_with_basic_auth) || settings.get(:ssl, :ssl_with_basic_auth)
41
55
  end
42
56
 
43
57
  def build_default_params(settings, logger, locale)
@@ -24,7 +24,7 @@ module HammerCLIForeman
24
24
  end
25
25
 
26
26
  def user
27
- get_user
27
+ @user
28
28
  end
29
29
 
30
30
  private
@@ -32,7 +32,8 @@ module HammerCLIForeman
32
32
  def authenticate(request, args)
33
33
  load_session
34
34
 
35
- destroy_session if (@authenticator.user != @user)
35
+ user = @authenticator.user
36
+ destroy_session if (user && user != @user)
36
37
 
37
38
  if @permissions_ok && @session_id
38
39
  jar = HTTP::CookieJar.new
@@ -62,6 +63,10 @@ module HammerCLIForeman
62
63
  @authenticator.response(r)
63
64
  end
64
65
 
66
+ def user
67
+ @authenticator.user if @authenticator.respond_to?(:user)
68
+ end
69
+
65
70
  protected
66
71
 
67
72
  def session_storage
@@ -0,0 +1,8 @@
1
+ require 'highline/import'
2
+
3
+ module HammerCLIForeman
4
+ module Api
5
+ class VoidAuth < ApipieBindings::Authenticators::Base
6
+ end
7
+ end
8
+ end
@@ -31,7 +31,7 @@ module HammerCLIForeman
31
31
  def execute
32
32
  HammerCLIForeman.foreman_api_connection.logout
33
33
  context[:api_connection].drop_all
34
- print_message(_("Credentials deleted."))
34
+ print_message(_("Logged out."))
35
35
  HammerCLI::EX_OK
36
36
  end
37
37
  end
@@ -26,6 +26,7 @@ module HammerCLIForeman
26
26
 
27
27
  option "--name", "NAME", _("parameter name"), :required => true
28
28
  option "--value", "VALUE", _("parameter value"), :required => true
29
+ option "--hidden-value", "HIDDEN_VALUE", _("should the value be hidden"), :format => HammerCLI::Options::Normalizers::Bool.new
29
30
 
30
31
  def action
31
32
  @action ||= parameter_exist? ? :update : :create
@@ -0,0 +1,45 @@
1
+ module HammerCLIForeman
2
+ class ConfigGroup < HammerCLIForeman::Command
3
+ resource :config_groups
4
+
5
+ class ListCommand < HammerCLIForeman::ListCommand
6
+ output do
7
+ field :id, _("ID")
8
+ field :name, _("Name")
9
+ end
10
+
11
+ build_options
12
+ end
13
+
14
+ class InfoCommand < HammerCLIForeman::InfoCommand
15
+ output ListCommand.output_definition do
16
+ HammerCLIForeman::References.puppetclasses(self)
17
+ end
18
+
19
+ build_options
20
+ end
21
+
22
+ class CreateCommand < HammerCLIForeman::CreateCommand
23
+ success_message _("Config group created")
24
+ failure_message _("Could not create the config group")
25
+
26
+ build_options
27
+ end
28
+
29
+ class UpdateCommand < HammerCLIForeman::UpdateCommand
30
+ success_message _("Config group updated")
31
+ failure_message _("Could not update the config group")
32
+
33
+ build_options
34
+ end
35
+
36
+ class DeleteCommand < HammerCLIForeman::DeleteCommand
37
+ success_message _("Config group has been deleted")
38
+ failure_message _("Could not delete the config group")
39
+
40
+ build_options
41
+ end
42
+
43
+ autoload_subcommands
44
+ end
45
+ end
@@ -1,7 +1,8 @@
1
1
  require 'hammer_cli'
2
2
  module HammerCLIForeman
3
3
  class Defaults < HammerCLI::BaseDefaultsProvider
4
- def initialize
4
+ def initialize(api_connection = HammerCLIForeman.foreman_api_connection)
5
+ @api_connection = api_connection
5
6
  @provider_name = 'foreman'
6
7
  @supported_defaults = [:organization_id, :location_id]
7
8
  @description = _('Use the default organization and/or location from the server')
@@ -21,9 +22,11 @@ module HammerCLIForeman
21
22
 
22
23
  private
23
24
  def get_user
24
- HammerCLIForeman.foreman_resource(:users).action(:index).call(:search =>"login="+HammerCLIForeman.credentials.username)
25
+ login = @api_connection.authenticator.user
26
+ users = @api_connection.resource(:users).action(:index).call(:search => "login=#{login}")
27
+ users
25
28
  end
26
29
  end
27
- HammerCLI.defaults.register_provider(Defaults.new())
28
30
 
31
+ HammerCLI.defaults.register_provider(Defaults.new)
29
32
  end