knife-ionoscloud 5.1.0 → 6.0.0.alpha.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (192) hide show
  1. checksums.yaml +4 -4
  2. data/knife-ionoscloud.gemspec +1 -1
  3. data/lib/chef/knife/ionoscloud_backupunit_create.rb +1 -1
  4. data/lib/chef/knife/ionoscloud_backupunit_delete.rb +1 -1
  5. data/lib/chef/knife/ionoscloud_backupunit_list.rb +1 -1
  6. data/lib/chef/knife/ionoscloud_backupunit_ssourl.rb +1 -1
  7. data/lib/chef/knife/ionoscloud_base.rb +1 -1
  8. data/lib/chef/knife/ionoscloud_composite_server_create.rb +25 -23
  9. data/lib/chef/knife/ionoscloud_contract_list.rb +32 -23
  10. data/lib/chef/knife/ionoscloud_cube_server_create.rb +215 -0
  11. data/lib/chef/knife/ionoscloud_datacenter_create.rb +1 -1
  12. data/lib/chef/knife/ionoscloud_datacenter_delete.rb +1 -1
  13. data/lib/chef/knife/ionoscloud_datacenter_list.rb +4 -2
  14. data/lib/chef/knife/ionoscloud_firewall_create.rb +11 -4
  15. data/lib/chef/knife/ionoscloud_firewall_delete.rb +4 -3
  16. data/lib/chef/knife/ionoscloud_firewall_list.rb +5 -3
  17. data/lib/chef/knife/ionoscloud_flowlog_create.rb +121 -0
  18. data/lib/chef/knife/ionoscloud_flowlog_delete.rb +106 -0
  19. data/lib/chef/knife/ionoscloud_flowlog_list.rb +100 -0
  20. data/lib/chef/knife/ionoscloud_group_create.rb +35 -14
  21. data/lib/chef/knife/ionoscloud_group_delete.rb +7 -0
  22. data/lib/chef/knife/ionoscloud_group_get.rb +6 -0
  23. data/lib/chef/knife/ionoscloud_group_list.rb +19 -7
  24. data/lib/chef/knife/ionoscloud_image_list.rb +1 -1
  25. data/lib/chef/knife/ionoscloud_ipfailover_add.rb +1 -1
  26. data/lib/chef/knife/ionoscloud_ipfailover_remove.rb +1 -1
  27. data/lib/chef/knife/ionoscloud_k8s_delete.rb +5 -2
  28. data/lib/chef/knife/ionoscloud_label_add.rb +1 -1
  29. data/lib/chef/knife/ionoscloud_label_list.rb +1 -1
  30. data/lib/chef/knife/ionoscloud_label_remove.rb +1 -1
  31. data/lib/chef/knife/ionoscloud_lan_create.rb +1 -1
  32. data/lib/chef/knife/ionoscloud_lan_delete.rb +1 -1
  33. data/lib/chef/knife/ionoscloud_lan_list.rb +1 -1
  34. data/lib/chef/knife/ionoscloud_loadbalancer_create.rb +1 -1
  35. data/lib/chef/knife/ionoscloud_loadbalancer_delete.rb +1 -1
  36. data/lib/chef/knife/ionoscloud_loadbalancer_get.rb +1 -1
  37. data/lib/chef/knife/ionoscloud_loadbalancer_list.rb +1 -1
  38. data/lib/chef/knife/ionoscloud_loadbalancer_nic_add.rb +1 -1
  39. data/lib/chef/knife/ionoscloud_loadbalancer_nic_remove.rb +1 -1
  40. data/lib/chef/knife/ionoscloud_location_list.rb +5 -3
  41. data/lib/chef/knife/ionoscloud_natgateway_create.rb +71 -0
  42. data/lib/chef/knife/ionoscloud_natgateway_delete.rb +69 -0
  43. data/lib/chef/knife/ionoscloud_natgateway_lan_add.rb +82 -0
  44. data/lib/chef/knife/ionoscloud_natgateway_lan_remove.rb +58 -0
  45. data/lib/chef/knife/ionoscloud_natgateway_list.rb +49 -0
  46. data/lib/chef/knife/ionoscloud_natgateway_rule_add.rb +124 -0
  47. data/lib/chef/knife/ionoscloud_natgateway_rule_list.rb +63 -0
  48. data/lib/chef/knife/ionoscloud_natgateway_rule_remove.rb +72 -0
  49. data/lib/chef/knife/ionoscloud_networkloadbalancer_create.rb +95 -0
  50. data/lib/chef/knife/ionoscloud_networkloadbalancer_delete.rb +81 -0
  51. data/lib/chef/knife/ionoscloud_networkloadbalancer_list.rb +56 -0
  52. data/lib/chef/knife/ionoscloud_networkloadbalancer_rule_add.rb +150 -0
  53. data/lib/chef/knife/ionoscloud_networkloadbalancer_rule_list.rb +63 -0
  54. data/lib/chef/knife/ionoscloud_networkloadbalancer_rule_remove.rb +78 -0
  55. data/lib/chef/knife/ionoscloud_networkloadbalancer_rule_target_add.rb +141 -0
  56. data/lib/chef/knife/ionoscloud_networkloadbalancer_rule_target_list.rb +68 -0
  57. data/lib/chef/knife/ionoscloud_networkloadbalancer_rule_target_remove.rb +105 -0
  58. data/lib/chef/knife/ionoscloud_nic_create.rb +14 -9
  59. data/lib/chef/knife/ionoscloud_nic_delete.rb +4 -2
  60. data/lib/chef/knife/ionoscloud_nic_list.rb +9 -5
  61. data/lib/chef/knife/ionoscloud_node_list.rb +0 -1
  62. data/lib/chef/knife/ionoscloud_nodepool_create.rb +42 -16
  63. data/lib/chef/knife/ionoscloud_nodepool_delete.rb +25 -0
  64. data/lib/chef/knife/ionoscloud_nodepool_lan_add.rb +130 -0
  65. data/lib/chef/knife/ionoscloud_nodepool_lan_remove.rb +96 -0
  66. data/lib/chef/knife/ionoscloud_nodepool_list.rb +3 -1
  67. data/lib/chef/knife/ionoscloud_pcc_create.rb +2 -2
  68. data/lib/chef/knife/ionoscloud_pcc_delete.rb +1 -1
  69. data/lib/chef/knife/ionoscloud_pcc_list.rb +1 -1
  70. data/lib/chef/knife/ionoscloud_request_list.rb +1 -1
  71. data/lib/chef/knife/ionoscloud_request_status.rb +1 -1
  72. data/lib/chef/knife/ionoscloud_s3key_create.rb +2 -2
  73. data/lib/chef/knife/ionoscloud_s3key_delete.rb +3 -3
  74. data/lib/chef/knife/ionoscloud_s3key_list.rb +2 -2
  75. data/lib/chef/knife/ionoscloud_server_console.rb +42 -0
  76. data/lib/chef/knife/ionoscloud_server_create.rb +8 -8
  77. data/lib/chef/knife/ionoscloud_server_delete.rb +1 -1
  78. data/lib/chef/knife/ionoscloud_server_list.rb +16 -5
  79. data/lib/chef/knife/ionoscloud_server_reboot.rb +1 -1
  80. data/lib/chef/knife/ionoscloud_server_resume.rb +43 -0
  81. data/lib/chef/knife/ionoscloud_server_start.rb +1 -1
  82. data/lib/chef/knife/ionoscloud_server_stop.rb +1 -1
  83. data/lib/chef/knife/ionoscloud_server_suspend.rb +44 -0
  84. data/lib/chef/knife/ionoscloud_server_token.rb +42 -0
  85. data/lib/chef/knife/ionoscloud_server_upgrade.rb +44 -0
  86. data/lib/chef/knife/ionoscloud_snapshot_create.rb +2 -2
  87. data/lib/chef/knife/ionoscloud_snapshot_delete.rb +1 -1
  88. data/lib/chef/knife/ionoscloud_snapshot_list.rb +1 -1
  89. data/lib/chef/knife/ionoscloud_snapshot_restore.rb +2 -2
  90. data/lib/chef/knife/ionoscloud_template_list.rb +46 -0
  91. data/lib/chef/knife/ionoscloud_user_ssourl.rb +1 -1
  92. data/lib/chef/knife/ionoscloud_volume_attach.rb +1 -1
  93. data/lib/chef/knife/ionoscloud_volume_create.rb +33 -35
  94. data/lib/chef/knife/ionoscloud_volume_delete.rb +1 -1
  95. data/lib/chef/knife/ionoscloud_volume_detach.rb +1 -1
  96. data/lib/chef/knife/ionoscloud_volume_list.rb +2 -2
  97. data/lib/knife-ionoscloud/version.rb +1 -1
  98. data/spec/chef/knife/ionoscloud_backupunit_create_spec.rb +2 -2
  99. data/spec/chef/knife/ionoscloud_backupunit_delete_spec.rb +5 -5
  100. data/spec/chef/knife/ionoscloud_backupunit_list_spec.rb +1 -1
  101. data/spec/chef/knife/ionoscloud_backupunit_ssourl_spec.rb +3 -3
  102. data/spec/chef/knife/ionoscloud_base_spec.rb +4 -4
  103. data/spec/chef/knife/ionoscloud_composite_server_create_spec.rb +11 -8
  104. data/spec/chef/knife/ionoscloud_contract_list_spec.rb +32 -27
  105. data/spec/chef/knife/ionoscloud_cube_server_create_spec.rb +249 -0
  106. data/spec/chef/knife/ionoscloud_datacenter_create_spec.rb +3 -2
  107. data/spec/chef/knife/ionoscloud_datacenter_delete_spec.rb +5 -5
  108. data/spec/chef/knife/ionoscloud_datacenter_list_spec.rb +5 -3
  109. data/spec/chef/knife/ionoscloud_firewall_create_spec.rb +5 -3
  110. data/spec/chef/knife/ionoscloud_firewall_delete_spec.rb +6 -5
  111. data/spec/chef/knife/ionoscloud_firewall_list_spec.rb +5 -3
  112. data/spec/chef/knife/ionoscloud_flowlog_create_spec.rb +254 -0
  113. data/spec/chef/knife/ionoscloud_flowlog_delete_spec.rb +360 -0
  114. data/spec/chef/knife/ionoscloud_flowlog_list_spec.rb +264 -0
  115. data/spec/chef/knife/ionoscloud_group_create_spec.rb +6 -0
  116. data/spec/chef/knife/ionoscloud_group_delete_spec.rb +6 -0
  117. data/spec/chef/knife/ionoscloud_group_get_spec.rb +6 -0
  118. data/spec/chef/knife/ionoscloud_group_list_spec.rb +26 -8
  119. data/spec/chef/knife/ionoscloud_image_list_spec.rb +2 -2
  120. data/spec/chef/knife/ionoscloud_ipfailover_add_spec.rb +3 -3
  121. data/spec/chef/knife/ionoscloud_ipfailover_remove_spec.rb +4 -4
  122. data/spec/chef/knife/ionoscloud_k8s_delete_spec.rb +5 -2
  123. data/spec/chef/knife/ionoscloud_kubeconfig_get_spec.rb +2 -2
  124. data/spec/chef/knife/ionoscloud_label_add_spec.rb +10 -10
  125. data/spec/chef/knife/ionoscloud_label_list_spec.rb +14 -14
  126. data/spec/chef/knife/ionoscloud_label_remove_spec.rb +20 -20
  127. data/spec/chef/knife/ionoscloud_lan_create_spec.rb +3 -3
  128. data/spec/chef/knife/ionoscloud_lan_delete_spec.rb +5 -5
  129. data/spec/chef/knife/ionoscloud_lan_list_spec.rb +2 -2
  130. data/spec/chef/knife/ionoscloud_loadbalancer_create_spec.rb +3 -3
  131. data/spec/chef/knife/ionoscloud_loadbalancer_delete_spec.rb +5 -5
  132. data/spec/chef/knife/ionoscloud_loadbalancer_get_spec.rb +2 -2
  133. data/spec/chef/knife/ionoscloud_loadbalancer_list_spec.rb +2 -2
  134. data/spec/chef/knife/ionoscloud_loadbalancer_nic_add_spec.rb +6 -6
  135. data/spec/chef/knife/ionoscloud_loadbalancer_nic_remove_spec.rb +6 -6
  136. data/spec/chef/knife/ionoscloud_location_list_spec.rb +5 -3
  137. data/spec/chef/knife/ionoscloud_natgateway_create_spec.rb +77 -0
  138. data/spec/chef/knife/ionoscloud_natgateway_delete_spec.rb +118 -0
  139. data/spec/chef/knife/ionoscloud_natgateway_lan_add_spec.rb +143 -0
  140. data/spec/chef/knife/ionoscloud_natgateway_lan_remove_spec.rb +194 -0
  141. data/spec/chef/knife/ionoscloud_natgateway_list_spec.rb +79 -0
  142. data/spec/chef/knife/ionoscloud_natgateway_rule_add_spec.rb +98 -0
  143. data/spec/chef/knife/ionoscloud_natgateway_rule_list_spec.rb +92 -0
  144. data/spec/chef/knife/ionoscloud_natgateway_rule_remove_spec.rb +77 -0
  145. data/spec/chef/knife/ionoscloud_networkloadbalancer_create_spec.rb +80 -0
  146. data/spec/chef/knife/ionoscloud_networkloadbalancer_delete_spec.rb +119 -0
  147. data/spec/chef/knife/ionoscloud_networkloadbalancer_list_spec.rb +88 -0
  148. data/spec/chef/knife/ionoscloud_networkloadbalancer_rule_add_spec.rb +104 -0
  149. data/spec/chef/knife/ionoscloud_networkloadbalancer_rule_list_spec.rb +89 -0
  150. data/spec/chef/knife/ionoscloud_networkloadbalancer_rule_remove_spec.rb +124 -0
  151. data/spec/chef/knife/ionoscloud_networkloadbalancer_rule_target_add_spec.rb +109 -0
  152. data/spec/chef/knife/ionoscloud_networkloadbalancer_rule_target_list_spec.rb +85 -0
  153. data/spec/chef/knife/ionoscloud_networkloadbalancer_rule_target_remove_spec.rb +263 -0
  154. data/spec/chef/knife/ionoscloud_nic_create_spec.rb +9 -5
  155. data/spec/chef/knife/ionoscloud_nic_delete_spec.rb +8 -6
  156. data/spec/chef/knife/ionoscloud_nic_list_spec.rb +12 -6
  157. data/spec/chef/knife/ionoscloud_nodepool_create_spec.rb +15 -1
  158. data/spec/chef/knife/ionoscloud_nodepool_lan_add_spec.rb +226 -0
  159. data/spec/chef/knife/ionoscloud_nodepool_lan_remove.rb +199 -0
  160. data/spec/chef/knife/ionoscloud_nodepool_list_spec.rb +3 -1
  161. data/spec/chef/knife/ionoscloud_pcc_create_spec.rb +6 -6
  162. data/spec/chef/knife/ionoscloud_pcc_delete_spec.rb +5 -5
  163. data/spec/chef/knife/ionoscloud_pcc_list_spec.rb +2 -2
  164. data/spec/chef/knife/ionoscloud_request_list_spec.rb +16 -16
  165. data/spec/chef/knife/ionoscloud_request_status_spec.rb +3 -3
  166. data/spec/chef/knife/ionoscloud_s3key_create_spec.rb +2 -2
  167. data/spec/chef/knife/ionoscloud_s3key_delete_spec.rb +5 -5
  168. data/spec/chef/knife/ionoscloud_s3key_list_spec.rb +2 -2
  169. data/spec/chef/knife/ionoscloud_server_console_spec.rb +97 -0
  170. data/spec/chef/knife/ionoscloud_server_create_spec.rb +3 -3
  171. data/spec/chef/knife/ionoscloud_server_delete_spec.rb +5 -5
  172. data/spec/chef/knife/ionoscloud_server_list_spec.rb +63 -5
  173. data/spec/chef/knife/ionoscloud_server_reboot_spec.rb +3 -5
  174. data/spec/chef/knife/ionoscloud_server_resume_spec.rb +93 -0
  175. data/spec/chef/knife/ionoscloud_server_start_spec.rb +3 -5
  176. data/spec/chef/knife/ionoscloud_server_stop_spec.rb +3 -5
  177. data/spec/chef/knife/ionoscloud_server_suspend_spec.rb +93 -0
  178. data/spec/chef/knife/ionoscloud_server_token_spec.rb +97 -0
  179. data/spec/chef/knife/ionoscloud_server_upgrade_spec.rb +96 -0
  180. data/spec/chef/knife/ionoscloud_snapshot_create_spec.rb +3 -3
  181. data/spec/chef/knife/ionoscloud_snapshot_delete_spec.rb +5 -5
  182. data/spec/chef/knife/ionoscloud_snapshot_list_spec.rb +2 -2
  183. data/spec/chef/knife/ionoscloud_snapshot_restore_spec.rb +3 -3
  184. data/spec/chef/knife/ionoscloud_template_list_spec.rb +78 -0
  185. data/spec/chef/knife/ionoscloud_user_ssourl_spec.rb +3 -3
  186. data/spec/chef/knife/ionoscloud_volume_attach_spec.rb +4 -4
  187. data/spec/chef/knife/ionoscloud_volume_create_spec.rb +6 -58
  188. data/spec/chef/knife/ionoscloud_volume_delete_spec.rb +5 -5
  189. data/spec/chef/knife/ionoscloud_volume_detach_spec.rb +5 -5
  190. data/spec/chef/knife/ionoscloud_volume_list_spec.rb +4 -4
  191. data/spec/spec_helper.rb +223 -29
  192. metadata +93 -6
@@ -12,7 +12,7 @@ describe Chef::Knife::IonoscloudFirewallDelete do
12
12
  end
13
13
 
14
14
  describe '#run' do
15
- it 'should call NicApi.datacenters_servers_nics_firewallrules_firewallrules_delete when the ID is valid' do
15
+ it 'should call FirewallRulesApi.datacenters_servers_nics_firewallrules_firewallrules_delete when the ID is valid' do
16
16
  firewall = firewall_mock
17
17
  subject_config = {
18
18
  ionoscloud_username: 'email',
@@ -36,6 +36,7 @@ describe Chef::Knife::IonoscloudFirewallDelete do
36
36
  expect(subject).to receive(:puts).with("Port Range End: #{firewall.properties.port_range_end}")
37
37
  expect(subject).to receive(:puts).with("ICMP Type: #{firewall.properties.icmp_type}")
38
38
  expect(subject).to receive(:puts).with("ICMP Code: #{firewall.properties.icmp_code}")
39
+ expect(subject).to receive(:puts).with("Type: #{firewall.properties.type}")
39
40
  expect(subject.ui).to receive(:warn).with("Deleted Firewall rule #{firewall.id}. Request ID: ")
40
41
 
41
42
  expect(subject.api_client).not_to receive(:wait_for)
@@ -47,7 +48,7 @@ describe Chef::Knife::IonoscloudFirewallDelete do
47
48
  method: 'GET',
48
49
  path: "/datacenters/#{subject_config[:datacenter_id]}/servers/#{subject_config[:server_id]}/"\
49
50
  "nics/#{subject_config[:nic_id]}/firewallrules/#{firewall.id}",
50
- operation: :'NicApi.datacenters_servers_nics_firewallrules_find_by_id',
51
+ operation: :'FirewallRulesApi.datacenters_servers_nics_firewallrules_find_by_id',
51
52
  return_type: 'FirewallRule',
52
53
  result: firewall,
53
54
  },
@@ -55,7 +56,7 @@ describe Chef::Knife::IonoscloudFirewallDelete do
55
56
  method: 'DELETE',
56
57
  path: "/datacenters/#{subject_config[:datacenter_id]}/servers/#{subject_config[:server_id]}/"\
57
58
  "nics/#{subject_config[:nic_id]}/firewallrules/#{firewall.id}",
58
- operation: :'NicApi.datacenters_servers_nics_firewallrules_delete',
59
+ operation: :'FirewallRulesApi.datacenters_servers_nics_firewallrules_delete',
59
60
  },
60
61
  ],
61
62
  )
@@ -63,7 +64,7 @@ describe Chef::Knife::IonoscloudFirewallDelete do
63
64
  expect { subject.run }.not_to raise_error(Exception)
64
65
  end
65
66
 
66
- it 'should not call NicApi.datacenters_servers_nics_firewallrules_delete when the user ID is not valid' do
67
+ it 'should not call FirewallRulesApi.datacenters_servers_nics_firewallrules_delete when the user ID is not valid' do
67
68
  firewall_id = 'invalid_id'
68
69
  subject_config = {
69
70
  ionoscloud_username: 'email',
@@ -86,7 +87,7 @@ describe Chef::Knife::IonoscloudFirewallDelete do
86
87
  method: 'GET',
87
88
  path: "/datacenters/#{subject_config[:datacenter_id]}/servers/#{subject_config[:server_id]}/"\
88
89
  "nics/#{subject_config[:nic_id]}/firewallrules/#{firewall_id}",
89
- operation: :'NicApi.datacenters_servers_nics_firewallrules_find_by_id',
90
+ operation: :'FirewallRulesApi.datacenters_servers_nics_firewallrules_find_by_id',
90
91
  return_type: 'FirewallRule',
91
92
  exception: Ionoscloud::ApiError.new(code: 404),
92
93
  },
@@ -12,7 +12,7 @@ describe Chef::Knife::IonoscloudFirewallList do
12
12
  end
13
13
 
14
14
  describe '#run' do
15
- it 'should call NicApi.datacenters_servers_nics_firewallrules_get' do
15
+ it 'should call FirewallRulesApi.datacenters_servers_nics_firewallrules_get' do
16
16
  firewalls = firewalls_mock
17
17
  subject_config = {
18
18
  ionoscloud_username: 'email',
@@ -35,6 +35,7 @@ describe Chef::Knife::IonoscloudFirewallList do
35
35
  subject.ui.color('Port Range End', :bold),
36
36
  subject.ui.color('ICMP Type', :bold),
37
37
  subject.ui.color('ICMP CODE', :bold),
38
+ subject.ui.color('Type', :bold),
38
39
  ]
39
40
 
40
41
  firewalls.items.each do |firewall|
@@ -48,9 +49,10 @@ describe Chef::Knife::IonoscloudFirewallList do
48
49
  firewall_list << firewall.properties.port_range_end.to_s
49
50
  firewall_list << firewall.properties.icmp_type.to_s
50
51
  firewall_list << firewall.properties.icmp_code.to_s
52
+ firewall_list << firewall.properties.type.to_s
51
53
  end
52
54
 
53
- expect(subject.ui).to receive(:list).with(firewall_list, :uneven_columns_across, 10)
55
+ expect(subject.ui).to receive(:list).with(firewall_list, :uneven_columns_across, 11)
54
56
 
55
57
  mock_call_api(
56
58
  subject,
@@ -59,7 +61,7 @@ describe Chef::Knife::IonoscloudFirewallList do
59
61
  method: 'GET',
60
62
  path: "/datacenters/#{subject_config[:datacenter_id]}/servers/#{subject_config[:server_id]}/"\
61
63
  "nics/#{subject_config[:nic_id]}/firewallrules",
62
- operation: :'NicApi.datacenters_servers_nics_firewallrules_get',
64
+ operation: :'FirewallRulesApi.datacenters_servers_nics_firewallrules_get',
63
65
  return_type: 'FirewallRules',
64
66
  result: firewalls,
65
67
  },
@@ -0,0 +1,254 @@
1
+ require 'spec_helper'
2
+ require 'ionoscloud_flowlog_create'
3
+
4
+ Chef::Knife::IonoscloudFlowlogCreate.load_deps
5
+
6
+ describe Chef::Knife::IonoscloudFlowlogCreate do
7
+ before :each do
8
+ subject { Chef::Knife::IonoscloudFlowlogCreate.new }
9
+
10
+ allow(subject).to receive(:puts)
11
+ allow(subject).to receive(:print)
12
+ end
13
+
14
+ describe '#run' do
15
+ it 'should call FlowLogsApi.datacenters_servers_nics_flowlogs_post with the expected arguments and output based on what it receives' do
16
+ flowlog = flowlog_mock
17
+ subject_config = {
18
+ ionoscloud_username: 'email',
19
+ ionoscloud_password: 'password',
20
+ datacenter_id: 'datacenter_id',
21
+ server_id: 'server_id',
22
+ nic_id: 'nic_id',
23
+ type: 'nic',
24
+ name: flowlog.properties.name,
25
+ action: flowlog.properties.action,
26
+ direction: flowlog.properties.direction,
27
+ bucket: flowlog.properties.bucket,
28
+ }
29
+
30
+ subject_config.each { |key, value| subject.config[key] = value }
31
+
32
+ expect(subject).to receive(:puts).with("ID: #{flowlog.id}")
33
+ expect(subject).to receive(:puts).with("Name: #{flowlog.properties.name}")
34
+ expect(subject).to receive(:puts).with("Action: #{flowlog.properties.action}")
35
+ expect(subject).to receive(:puts).with("Direction: #{flowlog.properties.direction}")
36
+ expect(subject).to receive(:puts).with("Bucket: #{flowlog.properties.bucket}")
37
+
38
+ mock_wait_for(subject)
39
+ mock_call_api(
40
+ subject,
41
+ [
42
+ {
43
+ method: 'POST',
44
+ path: "/datacenters/#{subject_config[:datacenter_id]}/servers/#{subject_config[:server_id]}/nics/#{subject_config[:nic_id]}/flowlogs",
45
+ operation: :'FlowLogsApi.datacenters_servers_nics_flowlogs_post',
46
+ return_type: 'FlowLog',
47
+ body: { properties: flowlog.properties.to_hash },
48
+ result: flowlog,
49
+ },
50
+ ],
51
+ )
52
+
53
+ expect { subject.run }.not_to raise_error(Exception)
54
+ end
55
+
56
+ it 'should not call FlowLogsApi.datacenters_servers_nics_flowlogs_post when server_id and nic_id are not given' do
57
+ flowlog = flowlog_mock
58
+ subject_config = {
59
+ ionoscloud_username: 'email',
60
+ ionoscloud_password: 'password',
61
+ datacenter_id: 'datacenter_id',
62
+ type: 'nic',
63
+ name: flowlog.properties.name,
64
+ action: flowlog.properties.action,
65
+ direction: flowlog.properties.direction,
66
+ bucket: flowlog.properties.bucket,
67
+ }
68
+
69
+ subject_config.each { |key, value| subject.config[key] = value }
70
+
71
+ expect(subject).to receive(:puts).with("Missing required parameters #{[:server_id, :nic_id]}")
72
+
73
+ expect(subject.api_client).not_to receive(:call_api)
74
+
75
+ expect { subject.run }.to raise_error(SystemExit) do |error|
76
+ expect(error.status).to eq(1)
77
+ end
78
+ end
79
+
80
+ it 'should call NATGatewaysApi.datacenters_natgateways_flowlogs_post with the expected arguments and output based on what it receives' do
81
+ flowlog = flowlog_mock
82
+ subject_config = {
83
+ ionoscloud_username: 'email',
84
+ ionoscloud_password: 'password',
85
+ datacenter_id: 'datacenter_id',
86
+ natgateway_id: 'natgateway_id',
87
+ type: 'natgateway',
88
+ name: flowlog.properties.name,
89
+ action: flowlog.properties.action,
90
+ direction: flowlog.properties.direction,
91
+ bucket: flowlog.properties.bucket,
92
+ }
93
+
94
+ subject_config.each { |key, value| subject.config[key] = value }
95
+
96
+ expect(subject).to receive(:puts).with("ID: #{flowlog.id}")
97
+ expect(subject).to receive(:puts).with("Name: #{flowlog.properties.name}")
98
+ expect(subject).to receive(:puts).with("Action: #{flowlog.properties.action}")
99
+ expect(subject).to receive(:puts).with("Direction: #{flowlog.properties.direction}")
100
+ expect(subject).to receive(:puts).with("Bucket: #{flowlog.properties.bucket}")
101
+
102
+ mock_wait_for(subject)
103
+ mock_call_api(
104
+ subject,
105
+ [
106
+ {
107
+ method: 'POST',
108
+ path: "/datacenters/#{subject_config[:datacenter_id]}/natgateways/#{subject_config[:natgateway_id]}/flowlogs",
109
+ operation: :'NATGatewaysApi.datacenters_natgateways_flowlogs_post',
110
+ return_type: 'FlowLog',
111
+ body: { properties: flowlog.properties.to_hash },
112
+ result: flowlog,
113
+ },
114
+ ],
115
+ )
116
+
117
+ expect { subject.run }.not_to raise_error(Exception)
118
+ end
119
+
120
+ it 'should not call NATGatewaysApi.datacenters_natgateways_flowlogs_post when natgateway_id is not given' do
121
+ flowlog = flowlog_mock
122
+ subject_config = {
123
+ ionoscloud_username: 'email',
124
+ ionoscloud_password: 'password',
125
+ datacenter_id: 'datacenter_id',
126
+ type: 'natgateway',
127
+ name: flowlog.properties.name,
128
+ action: flowlog.properties.action,
129
+ direction: flowlog.properties.direction,
130
+ bucket: flowlog.properties.bucket,
131
+ }
132
+
133
+ subject_config.each { |key, value| subject.config[key] = value }
134
+
135
+ expect(subject).to receive(:puts).with("Missing required parameters #{[:natgateway_id]}")
136
+
137
+ expect(subject.api_client).not_to receive(:call_api)
138
+
139
+ expect { subject.run }.to raise_error(SystemExit) do |error|
140
+ expect(error.status).to eq(1)
141
+ end
142
+ end
143
+
144
+ it 'should call NetworkLoadBalancersApi.datacenters_networkloadbalancers_flowlogs_post with the expected arguments and output based on what it receives' do
145
+ flowlog = flowlog_mock
146
+ subject_config = {
147
+ ionoscloud_username: 'email',
148
+ ionoscloud_password: 'password',
149
+ datacenter_id: 'datacenter_id',
150
+ network_loadbalancer_id: 'network_loadbalancer_id',
151
+ type: 'loadbalancer',
152
+ name: flowlog.properties.name,
153
+ action: flowlog.properties.action,
154
+ direction: flowlog.properties.direction,
155
+ bucket: flowlog.properties.bucket,
156
+ }
157
+
158
+ subject_config.each { |key, value| subject.config[key] = value }
159
+
160
+ expect(subject).to receive(:puts).with("ID: #{flowlog.id}")
161
+ expect(subject).to receive(:puts).with("Name: #{flowlog.properties.name}")
162
+ expect(subject).to receive(:puts).with("Action: #{flowlog.properties.action}")
163
+ expect(subject).to receive(:puts).with("Direction: #{flowlog.properties.direction}")
164
+ expect(subject).to receive(:puts).with("Bucket: #{flowlog.properties.bucket}")
165
+
166
+ mock_wait_for(subject)
167
+ mock_call_api(
168
+ subject,
169
+ [
170
+ {
171
+ method: 'POST',
172
+ path: "/datacenters/#{subject_config[:datacenter_id]}/networkloadbalancers/#{subject_config[:network_loadbalancer_id]}/flowlogs",
173
+ operation: :'NetworkLoadBalancersApi.datacenters_networkloadbalancers_flowlogs_post',
174
+ return_type: 'FlowLog',
175
+ body: { properties: flowlog.properties.to_hash },
176
+ result: flowlog,
177
+ },
178
+ ],
179
+ )
180
+
181
+ expect { subject.run }.not_to raise_error(Exception)
182
+ end
183
+
184
+ it 'should not call NetworkLoadBalancersApi.datacenters_networkloadbalancers_flowlogs_post when network_loadbalancer_id is not given' do
185
+ flowlog = flowlog_mock
186
+ subject_config = {
187
+ ionoscloud_username: 'email',
188
+ ionoscloud_password: 'password',
189
+ datacenter_id: 'datacenter_id',
190
+ type: 'loadbalancer',
191
+ name: flowlog.properties.name,
192
+ action: flowlog.properties.action,
193
+ direction: flowlog.properties.direction,
194
+ bucket: flowlog.properties.bucket,
195
+ }
196
+
197
+ subject_config.each { |key, value| subject.config[key] = value }
198
+
199
+ expect(subject).to receive(:puts).with("Missing required parameters #{[:network_loadbalancer_id]}")
200
+
201
+ expect(subject.api_client).not_to receive(:call_api)
202
+
203
+ expect { subject.run }.to raise_error(SystemExit) do |error|
204
+ expect(error.status).to eq(1)
205
+ end
206
+ end
207
+
208
+ it 'should not call anything when the wrong type is given' do
209
+ flowlog = flowlog_mock
210
+ subject_config = {
211
+ ionoscloud_username: 'email',
212
+ ionoscloud_password: 'password',
213
+ datacenter_id: 'datacenter_id',
214
+ server_id: 'server_id',
215
+ natgateway_id: 'natgateway_id',
216
+ network_loadbalancer_id: 'network_loadbalancer_id',
217
+ nic_id: 'nic_id',
218
+ type: 'other',
219
+ name: flowlog.properties.name,
220
+ action: flowlog.properties.action,
221
+ direction: flowlog.properties.direction,
222
+ bucket: flowlog.properties.bucket,
223
+ }
224
+
225
+ subject_config.each { |key, value| subject.config[key] = value }
226
+
227
+ expect(subject.ui).to receive(:error).with("Flow log cannot belong to #{subject_config[:type]}. Value must be one of ['nic', 'natgateway', 'loadbalancer']")
228
+
229
+ expect(subject.api_client).not_to receive(:call_api)
230
+
231
+ expect { subject.run }.to raise_error(SystemExit) do |error|
232
+ expect(error.status).to eq(1)
233
+ end
234
+ end
235
+
236
+ it 'should not make any call if any required option is missing' do
237
+ required_options = subject.instance_variable_get(:@required_options)
238
+
239
+ arrays_without_one_element(required_options).each do |test_case|
240
+
241
+ test_case[:array].each { |value| subject.config[value] = 'test' }
242
+
243
+ expect(subject).to receive(:puts).with("Missing required parameters #{test_case[:removed]}")
244
+ expect(subject.api_client).not_to receive(:call_api)
245
+
246
+ expect { subject.run }.to raise_error(SystemExit) do |error|
247
+ expect(error.status).to eq(1)
248
+ end
249
+
250
+ required_options.each { |value| subject.config[value] = nil }
251
+ end
252
+ end
253
+ end
254
+ end
@@ -0,0 +1,360 @@
1
+ require 'spec_helper'
2
+ require 'ionoscloud_flowlog_delete'
3
+
4
+ Chef::Knife::IonoscloudFlowlogDelete.load_deps
5
+
6
+ describe Chef::Knife::IonoscloudFlowlogDelete do
7
+ before :each do
8
+ subject { Chef::Knife::IonoscloudFlowlogDelete.new }
9
+
10
+ allow(subject).to receive(:puts)
11
+ allow(subject).to receive(:print)
12
+ end
13
+
14
+ describe '#run' do
15
+ it 'should call FlowLogsApi.datacenters_servers_nics_flowlogs_flowlogs_delete when the ID is valid' do
16
+ flowlog = flowlog_mock
17
+ subject_config = {
18
+ ionoscloud_username: 'email',
19
+ ionoscloud_password: 'password',
20
+ datacenter_id: 'datacenter_id',
21
+ server_id: 'server_id',
22
+ nic_id: 'nic_id',
23
+ type: 'nic',
24
+ yes: true,
25
+ }
26
+
27
+ subject_config.each { |key, value| subject.config[key] = value }
28
+ subject.name_args = [flowlog.id]
29
+
30
+ expect(subject).to receive(:puts).with("ID: #{flowlog.id}")
31
+ expect(subject).to receive(:puts).with("Name: #{flowlog.properties.name}")
32
+ expect(subject).to receive(:puts).with("Action: #{flowlog.properties.action}")
33
+ expect(subject).to receive(:puts).with("Direction: #{flowlog.properties.direction}")
34
+ expect(subject).to receive(:puts).with("Bucket: #{flowlog.properties.bucket}")
35
+ expect(subject.ui).to receive(:warn).with("Deleted flow log #{flowlog.id}. Request ID: ")
36
+
37
+ expect(subject.api_client).not_to receive(:wait_for)
38
+ expect(subject).to receive(:get_request_id).once
39
+ mock_call_api(
40
+ subject,
41
+ [
42
+ {
43
+ method: 'GET',
44
+ path: "/datacenters/#{subject_config[:datacenter_id]}/servers/#{subject_config[:server_id]}/"\
45
+ "nics/#{subject_config[:nic_id]}/flowlogs/#{flowlog.id}",
46
+ operation: :'FlowLogsApi.datacenters_servers_nics_flowlogs_find_by_id',
47
+ return_type: 'FlowLog',
48
+ result: flowlog,
49
+ },
50
+ {
51
+ method: 'DELETE',
52
+ path: "/datacenters/#{subject_config[:datacenter_id]}/servers/#{subject_config[:server_id]}/"\
53
+ "nics/#{subject_config[:nic_id]}/flowlogs/#{flowlog.id}",
54
+ operation: :'FlowLogsApi.datacenters_servers_nics_flowlogs_delete',
55
+ },
56
+ ],
57
+ )
58
+
59
+ expect { subject.run }.not_to raise_error(Exception)
60
+ end
61
+
62
+ it 'should not call FlowLogsApi.datacenters_servers_nics_flowlogs_delete when the ID is not valid' do
63
+ flowlog_id = 'invalid_id'
64
+ subject_config = {
65
+ ionoscloud_username: 'email',
66
+ ionoscloud_password: 'password',
67
+ datacenter_id: 'datacenter_id',
68
+ server_id: 'server_id',
69
+ nic_id: 'nic_id',
70
+ type: 'nic',
71
+ }
72
+
73
+ subject_config.each { |key, value| subject.config[key] = value }
74
+ subject.name_args = [flowlog_id]
75
+
76
+ expect(subject.ui).to receive(:error).with("Flow log ID #{flowlog_id} not found. Skipping.")
77
+
78
+ expect(subject.api_client).not_to receive(:wait_for)
79
+ mock_call_api(
80
+ subject,
81
+ [
82
+ {
83
+ method: 'GET',
84
+ path: "/datacenters/#{subject_config[:datacenter_id]}/servers/#{subject_config[:server_id]}/"\
85
+ "nics/#{subject_config[:nic_id]}/flowlogs/#{flowlog_id}",
86
+ operation: :'FlowLogsApi.datacenters_servers_nics_flowlogs_find_by_id',
87
+ return_type: 'FlowLog',
88
+ exception: Ionoscloud::ApiError.new(code: 404),
89
+ },
90
+ ],
91
+ )
92
+
93
+ expect { subject.run }.not_to raise_error(Exception)
94
+ end
95
+
96
+ it 'should not call FlowLogsApi.datacenters_servers_nics_flowlogs_delete when server_id and nic_id are not given' do
97
+ flowlog_id = 'invalid_id'
98
+ subject_config = {
99
+ ionoscloud_username: 'email',
100
+ ionoscloud_password: 'password',
101
+ datacenter_id: 'datacenter_id',
102
+ type: 'nic',
103
+ }
104
+
105
+ subject_config.each { |key, value| subject.config[key] = value }
106
+ subject.name_args = [flowlog_id]
107
+
108
+ expect(subject).to receive(:puts).with("Missing required parameters #{[:server_id, :nic_id]}")
109
+
110
+ expect(subject.api_client).not_to receive(:call_api)
111
+
112
+ expect { subject.run }.to raise_error(SystemExit) do |error|
113
+ expect(error.status).to eq(1)
114
+ end
115
+ end
116
+
117
+ it 'should call NATGatewaysApi.datacenters_natgateways_flowlogs_flowlogs_delete when the ID is valid' do
118
+ flowlog = flowlog_mock
119
+ subject_config = {
120
+ ionoscloud_username: 'email',
121
+ ionoscloud_password: 'password',
122
+ datacenter_id: 'datacenter_id',
123
+ natgateway_id: 'natgateway_id',
124
+ type: 'natgateway',
125
+ yes: true,
126
+ }
127
+
128
+ subject_config.each { |key, value| subject.config[key] = value }
129
+ subject.name_args = [flowlog.id]
130
+
131
+ expect(subject).to receive(:puts).with("ID: #{flowlog.id}")
132
+ expect(subject).to receive(:puts).with("Name: #{flowlog.properties.name}")
133
+ expect(subject).to receive(:puts).with("Action: #{flowlog.properties.action}")
134
+ expect(subject).to receive(:puts).with("Direction: #{flowlog.properties.direction}")
135
+ expect(subject).to receive(:puts).with("Bucket: #{flowlog.properties.bucket}")
136
+ expect(subject.ui).to receive(:warn).with("Deleted flow log #{flowlog.id}. Request ID: ")
137
+
138
+ expect(subject.api_client).not_to receive(:wait_for)
139
+ expect(subject).to receive(:get_request_id).once
140
+ mock_call_api(
141
+ subject,
142
+ [
143
+ {
144
+ method: 'GET',
145
+ path: "/datacenters/#{subject_config[:datacenter_id]}/natgateways/#{subject_config[:natgateway_id]}/flowlogs/#{flowlog.id}",
146
+ operation: :'NATGatewaysApi.datacenters_natgateways_flowlogs_find_by_flow_log_id',
147
+ return_type: 'FlowLog',
148
+ result: flowlog,
149
+ },
150
+ {
151
+ method: 'DELETE',
152
+ path: "/datacenters/#{subject_config[:datacenter_id]}/natgateways/#{subject_config[:natgateway_id]}/flowlogs/#{flowlog.id}",
153
+ operation: :'NATGatewaysApi.datacenters_natgateways_flowlogs_delete',
154
+ },
155
+ ],
156
+ )
157
+
158
+ expect { subject.run }.not_to raise_error(Exception)
159
+ end
160
+
161
+ it 'should not call NATGatewaysApi.datacenters_natgateways_flowlogs_delete when the ID is not valid' do
162
+ flowlog_id = 'invalid_id'
163
+ subject_config = {
164
+ ionoscloud_username: 'email',
165
+ ionoscloud_password: 'password',
166
+ datacenter_id: 'datacenter_id',
167
+ natgateway_id: 'natgateway_id',
168
+ type: 'natgateway',
169
+ }
170
+
171
+ subject_config.each { |key, value| subject.config[key] = value }
172
+ subject.name_args = [flowlog_id]
173
+
174
+ expect(subject.ui).to receive(:error).with("Flow log ID #{flowlog_id} not found. Skipping.")
175
+
176
+ expect(subject.api_client).not_to receive(:wait_for)
177
+ mock_call_api(
178
+ subject,
179
+ [
180
+ {
181
+ method: 'GET',
182
+ path: "/datacenters/#{subject_config[:datacenter_id]}/natgateways/#{subject_config[:natgateway_id]}/flowlogs/#{flowlog_id}",
183
+ operation: :'NATGatewaysApi.datacenters_natgateways_flowlogs_find_by_flow_log_id',
184
+ return_type: 'FlowLog',
185
+ exception: Ionoscloud::ApiError.new(code: 404),
186
+ },
187
+ ],
188
+ )
189
+
190
+ expect { subject.run }.not_to raise_error(Exception)
191
+ end
192
+
193
+ it 'should not call NATGatewaysApi.datacenters_natgateways_flowlogs_delete when natgateway_id is not given' do
194
+ flowlog_id = 'invalid_id'
195
+ subject_config = {
196
+ ionoscloud_username: 'email',
197
+ ionoscloud_password: 'password',
198
+ datacenter_id: 'datacenter_id',
199
+ type: 'natgateway',
200
+ }
201
+
202
+ subject_config.each { |key, value| subject.config[key] = value }
203
+ subject.name_args = [flowlog_id]
204
+
205
+ expect(subject).to receive(:puts).with("Missing required parameters #{[:natgateway_id]}")
206
+
207
+ expect(subject.api_client).not_to receive(:call_api)
208
+
209
+ expect { subject.run }.to raise_error(SystemExit) do |error|
210
+ expect(error.status).to eq(1)
211
+ end
212
+ end
213
+
214
+ it 'should call NetworkLoadBalancersApi.datacenters_networkloadbalancers_flowlogs_flowlogs_delete when the ID is valid' do
215
+ flowlog = flowlog_mock
216
+ subject_config = {
217
+ ionoscloud_username: 'email',
218
+ ionoscloud_password: 'password',
219
+ datacenter_id: 'datacenter_id',
220
+ network_loadbalancer_id: 'network_loadbalancer_id',
221
+ type: 'loadbalancer',
222
+ yes: true,
223
+ }
224
+
225
+ subject_config.each { |key, value| subject.config[key] = value }
226
+ subject.name_args = [flowlog.id]
227
+
228
+ expect(subject).to receive(:puts).with("ID: #{flowlog.id}")
229
+ expect(subject).to receive(:puts).with("Name: #{flowlog.properties.name}")
230
+ expect(subject).to receive(:puts).with("Action: #{flowlog.properties.action}")
231
+ expect(subject).to receive(:puts).with("Direction: #{flowlog.properties.direction}")
232
+ expect(subject).to receive(:puts).with("Bucket: #{flowlog.properties.bucket}")
233
+ expect(subject.ui).to receive(:warn).with("Deleted flow log #{flowlog.id}. Request ID: ")
234
+
235
+ expect(subject.api_client).not_to receive(:wait_for)
236
+ expect(subject).to receive(:get_request_id).once
237
+ mock_call_api(
238
+ subject,
239
+ [
240
+ {
241
+ method: 'GET',
242
+ nic_id: 'nic_id',
243
+ path: "/datacenters/#{subject_config[:datacenter_id]}/networkloadbalancers/#{subject_config[:network_loadbalancer_id]}/flowlogs/#{flowlog.id}",
244
+ operation: :'NetworkLoadBalancersApi.datacenters_networkloadbalancers_flowlogs_find_by_flow_log_id',
245
+ return_type: 'FlowLog',
246
+ result: flowlog,
247
+ },
248
+ {
249
+ method: 'DELETE',
250
+ nic_id: 'nic_id',
251
+ path: "/datacenters/#{subject_config[:datacenter_id]}/networkloadbalancers/#{subject_config[:network_loadbalancer_id]}/flowlogs/#{flowlog.id}",
252
+ operation: :'NetworkLoadBalancersApi.datacenters_networkloadbalancers_flowlogs_delete',
253
+ },
254
+ ],
255
+ )
256
+
257
+ expect { subject.run }.not_to raise_error(Exception)
258
+ end
259
+
260
+ it 'should not call NetworkLoadBalancersApi.datacenters_networkloadbalancers_flowlogs_delete when the ID is not valid' do
261
+ flowlog_id = 'invalid_id'
262
+ subject_config = {
263
+ ionoscloud_username: 'email',
264
+ ionoscloud_password: 'password',
265
+ datacenter_id: 'datacenter_id',
266
+ network_loadbalancer_id: 'network_loadbalancer_id',
267
+ type: 'loadbalancer',
268
+ }
269
+
270
+ subject_config.each { |key, value| subject.config[key] = value }
271
+ subject.name_args = [flowlog_id]
272
+
273
+ expect(subject.ui).to receive(:error).with("Flow log ID #{flowlog_id} not found. Skipping.")
274
+
275
+ expect(subject.api_client).not_to receive(:wait_for)
276
+ mock_call_api(
277
+ subject,
278
+ [
279
+ {
280
+ method: 'GET',
281
+ nic_id: 'nic_id',
282
+ path: "/datacenters/#{subject_config[:datacenter_id]}/networkloadbalancers/#{subject_config[:network_loadbalancer_id]}/flowlogs/#{flowlog_id}",
283
+ operation: :'NetworkLoadBalancersApi.datacenters_networkloadbalancers_flowlogs_find_by_flow_log_id',
284
+ return_type: 'FlowLog',
285
+ exception: Ionoscloud::ApiError.new(code: 404),
286
+ },
287
+ ],
288
+ )
289
+
290
+ expect { subject.run }.not_to raise_error(Exception)
291
+ end
292
+
293
+ it 'should not call NetworkLoadBalancersApi.datacenters_networkloadbalancers_flowlogs_delete when network_loadbalancer_id is not given' do
294
+ flowlog_id = 'invalid_id'
295
+ subject_config = {
296
+ ionoscloud_username: 'email',
297
+ ionoscloud_password: 'password',
298
+ datacenter_id: 'datacenter_id',
299
+ type: 'loadbalancer',
300
+ }
301
+
302
+ subject_config.each { |key, value| subject.config[key] = value }
303
+ subject.name_args = [flowlog_id]
304
+
305
+ expect(subject).to receive(:puts).with("Missing required parameters #{[:network_loadbalancer_id]}")
306
+
307
+ expect(subject.api_client).not_to receive(:call_api)
308
+
309
+ expect { subject.run }.to raise_error(SystemExit) do |error|
310
+ expect(error.status).to eq(1)
311
+ end
312
+ end
313
+
314
+ it 'should not call anything when the wrong type is given' do
315
+ flowlog = flowlog_mock
316
+ subject_config = {
317
+ ionoscloud_username: 'email',
318
+ ionoscloud_password: 'password',
319
+ datacenter_id: 'datacenter_id',
320
+ server_id: 'server_id',
321
+ natgateway_id: 'natgateway_id',
322
+ network_loadbalancer_id: 'network_loadbalancer_id',
323
+ nic_id: 'nic_id',
324
+ type: 'other',
325
+ name: flowlog.properties.name,
326
+ action: flowlog.properties.action,
327
+ direction: flowlog.properties.direction,
328
+ bucket: flowlog.properties.bucket,
329
+ }
330
+
331
+ subject_config.each { |key, value| subject.config[key] = value }
332
+
333
+ expect(subject.ui).to receive(:error).with("Flow log cannot belong to #{subject_config[:type]}. Value must be one of ['nic', 'natgateway', 'loadbalancer']")
334
+
335
+ expect(subject.api_client).not_to receive(:call_api)
336
+
337
+ expect { subject.run }.to raise_error(SystemExit) do |error|
338
+ expect(error.status).to eq(1)
339
+ end
340
+ end
341
+
342
+ it 'should not make any call if any required option is missing' do
343
+ required_options = subject.instance_variable_get(:@required_options)
344
+
345
+ arrays_without_one_element(required_options).each do |test_case|
346
+
347
+ test_case[:array].each { |value| subject.config[value] = 'test' }
348
+
349
+ expect(subject).to receive(:puts).with("Missing required parameters #{test_case[:removed]}")
350
+ expect(subject.api_client).not_to receive(:call_api)
351
+
352
+ expect { subject.run }.to raise_error(SystemExit) do |error|
353
+ expect(error.status).to eq(1)
354
+ end
355
+
356
+ required_options.each { |value| subject.config[value] = nil }
357
+ end
358
+ end
359
+ end
360
+ end