For option arguments that must be members of an array, do the check in the option parsing by providing an array of allowed option arguments (e.g. vm create -s bad). Emit better errors for options arguments that should be integers (e.g. fw add-rule -s/-e), and for regular arguments that should be integers (e.g. lb create src-port/dst-port). Include help output in additional cases: * invalid id formats with slashes * invalid/duplicate/missing fields used when multiple fields separated by a comma is allowed * invalid object references when using post subcommands * invalid location for list -l option
26 lines
785 B
Ruby
26 lines
785 B
Ruby
# frozen_string_literal: true
|
|
|
|
require_relative "../spec_helper"
|
|
|
|
RSpec.describe Clover, "cli fw add-rule" do
|
|
before do
|
|
cli(%w[fw eu-central-h1/test-fw create])
|
|
@fw = Firewall.first
|
|
@fw.firewall_rules_dataset.destroy
|
|
cli(%w[fw eu-central-h1/test-fw add-rule 1.2.3.0/24])
|
|
@fwr = FirewallRule.first
|
|
end
|
|
|
|
it "deletes rule from firewall" do
|
|
2.times do
|
|
expect(cli(%W[fw eu-central-h1/test-fw delete-rule #{@fwr.ubid}])).to eq "Firewall rule, if it existed, has been deleted\n"
|
|
expect(FirewallRule.count).to eq 0
|
|
end
|
|
end
|
|
|
|
it "errors for invalid rule id format" do
|
|
expect(cli(%W[fw eu-central-h1/test-fw delete-rule #{@fwr.ubid}/], status: 400)).to start_with "! Invalid rule id format\n"
|
|
expect(FirewallRule.count).to eq 1
|
|
end
|
|
end
|