spec/acceptance/securitygroup_spec.rb
# a fairly naive matching algorithm, since the shape of ip_permissions is
# quite different than the shape of our ingress rules
a fairly naive matching algorithm, since the shape of ip_permissions is
quite different than the shape of our ingress rules
a fairly naive matching algorithm since the shape of ip_permissions is quite different than the shape of our ingress rules
def has_ingress_rule(rule, ip_permissions)
    if (rule.has_key? :security_group)
      group_name = rule[:security_group]
      tcp_perm = get_group_permission(ip_permissions, group_name, 'tcp')
      udp_perm = get_group_permission(ip_permissions, group_name, 'udp')
      icmp_perm = get_group_permission(ip_permissions, group_name, 'icmp')
      match = !tcp_perm.nil? && !udp_perm.nil? && !icmp_perm.nil?
      expect(match).to eq(true), "Could not find ingress rule for #{group_name}"
    else
      match = ip_permissions.any? do |perm|
        rule[:protocol] == perm[:ip_protocol] &&
        rule[:port] == perm[:from_port] &&
        rule[:port] == perm[:to_port] &&
        perm[:ip_ranges].any? { |ip| ip[:cidr_ip] == rule[:cidr] }
      end
      msg = "Could not find ingress rule for #{rule[:protocol]} port #{rule[:port]} and CIDR #{rule[:cidr]}"
      expect(match).to eq(true), msg
    end
  end
def has_ingress_rule ( rule , ip_permissions ) if ( rule . has_key? :security_group ) group_name = rule [ :security_group ] tcp_perm = get_group_permission ( ip_permissions , group_name , 'tcp' ) udp_perm = get_group_permission ( ip_permissions , group_name , 'udp' ) icmp_perm = get_group_permission ( ip_permissions , group_name , 'icmp' ) match = ! tcp_perm . nil? && ! udp_perm . nil? && ! icmp_perm . nil? expect ( match ) . to eq ( true ) , "Could not find ingress rule for #{group_name}" else match = ip_permissions . any? do | perm | rule [ :protocol ] == perm [ :ip_protocol ] && rule [ :port ] == perm [ :from_port ] && rule [ :port ] == perm [ :to_port ] && perm [ :ip_ranges ] . any? { | ip | ip [ :cidr_ip ] == rule [ :cidr ] } end msg = "Could not find ingress rule for #{rule[:protocol]} port #{rule[:port]} and CIDR #{rule[:cidr]}" expect ( match ) . to eq ( true ) , msg end end
a fairly naive matching algorithm, since the shape of ip_permissions is
quite different than the shape of our ingress rules
a fairly naive matching algorithm since the shape of ip_permissions is quite different than the shape of our ingress rules
# a match occurs when AWS has a TCP / UDP / ICMP perm setup for group
rule
ip_permissions