Sha256: 0c45097e77d5b946e40adc8517fa618259abfd0bbb343f3b52aee7b1f2f78256

Contents?: true

Size: 1.61 KB

Versions: 2

Compression:

Stored size: 1.61 KB

Contents

require 'spec_helper'

module Vcloud
  describe 'firewall_service_schema_validations' do
    context 'source and destination ips' do
      it 'should error if source_ip/destination_ip are invalid IPs' do
        config = {
          firewall_rules: [
            {
              id: '999',
              description: "A rule",
              destination_port_range: "22",
              destination_ip: "10.10",
              source_ip: "192.0",
            }
          ]

        }
        validator = Vcloud::Core::ConfigValidator.validate(:base, config, Vcloud::EdgeGateway::Schema::FIREWALL_SERVICE)
        expect(validator.valid?).to be false
        expect(validator.errors).to eq([
                                         "source_ip: 192.0 is not a valid IP address range. Valid values can be IP address, CIDR, IP range, 'Any','internal' and 'external'.",
                                         "destination_ip: 10.10 is not a valid IP address range. Valid values can be IP address, CIDR, IP range, 'Any','internal' and 'external'."
                                       ])
      end

      it 'should validate OK if source_ip/destination_ip are valid IPs' do
        config = {
          firewall_rules: [
            {
              id: '999',
              description: "A rule",
              destination_port_range: "22",
              destination_ip: "10.10.10.20",
              source_ip: "192.0.2.2",
            }
          ]

        }
        validator = Vcloud::Core::ConfigValidator.validate(:base, config, Vcloud::EdgeGateway::Schema::FIREWALL_SERVICE)
        expect(validator.valid?).to be true
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vcloud-edge_gateway-2.1.1 spec/vcloud/edge_gateway/firewall_schema_validation_spec.rb
vcloud-edge_gateway-2.1.0 spec/vcloud/edge_gateway/firewall_schema_validation_spec.rb