<commit_before>require 'spec_helper'
Awspec::Stub.load 'security_group'

describe security_group('sg-1a2b3cd4') do
  it { should exist }
  its(:inbound) { should be_opened(80) }
  its(:inbound) { should be_opened(80).protocol('tcp').for('192.168.3.11/32') }
  its(:inbound) { should be_opened(80).protocol('tcp').for('172.16.31.10/25') }
  its(:inbound) { should be_opened(80).protocol('tcp').for('172.16.31.10/32') }
  its(:inbound) { should_not be_opened(80).protocol('tcp').for('192.168.127.12/16') }
  its(:inbound) { should be_opened(22) }
  its(:inbound) { should be_opened(22).protocol('tcp').for('sg-5a6b7cd8') }
  its(:inbound) { should be_opened('50000-50009').protocol('tcp').for('192.168.127.12/32') }
  its(:inbound) { should_not be_opened('50000-50019').protocol('tcp').for('192.168.127.12/32') }
  its(:outbound) { should be_opened(50_000) }
  its(:outbound) { should be_opened(8080).protocol('tcp').for('sg-9a8b7c6d') }
  its(:outbound) { should be_opened(8080).protocol('tcp').for('group-in-other-aws-account-with-vpc-peering') }
  its(:inbound) { should be_opened_only(60_000).protocol('tcp').for('172.16.31.10/32') }
  its(:inbound) { should be_opened_only(70_000).protocol('tcp').for(['172.16.31.10/32', '172.16.31.10/32']) }
  its(:outbound) { should be_opened_only(50_000).protocol('tcp').for('172.16.31.10/32') }
  its(:inbound) { should be_opened.protocol('all').for('sg-3a4b5cd6') }
  its(:outbound) { should be_opened.protocol('tcp').for('pl-a5321fa3') }
  its(:inbound_permissions_count) { should eq 7 }
  its(:ip_permissions_count) { should eq 7 }
  its(:outbound_permissions_count) { should eq 3 }
  its(:ip_permissions_egress_count) { should eq 3 }
  its(:inbound_rule_count) { should eq 8 }
  its(:outbound_rule_count) { should eq 2 }

  it { should have_inbound_rule( { ip_protocol: "tcp", from_port: 80, to_port: 80, ip_range: "172.16.31.10/24" })}
  it { should have_inbound_rule( { ip_protocol: "tcp", from_port: 80, to_port: 80, ip_range: "192.168.3.11/32" })}
  it { should have_inbound_rule( { ip_protocol: "tcp", from_port: 22, to_port: 22, group_pair: { group_id: "sg-5a6b7cd8" }})}
  it { should have_inbound_rule( { ip_protocol: "tcp", from_port: 22, to_port: 22, group_pair: { group_name: "group-name-sg" }})}
  it { should have_inbound_rule( { ip_protocol: "tcp", from_port: 60000, to_port: 60000, ip_range: "172.16.31.10/32" })}
  it { should have_inbound_rule( { ip_protocol: "tcp", from_port: 70000, to_port: 70000, ip_range: "172.16.31.10/32" })}
  it { should have_inbound_rule( { ip_protocol: "tcp", from_port: 70000, to_port: 70000, ip_range: "172.16.31.10/32" })}
  it { should have_inbound_rule( { ip_protocol: "tcp", from_port: 50000, to_port: 50009, ip_range: "192.168.127.12/32" })}
  it { should have_inbound_rule( { ip_protocol: "all", group_pair: {group_id: "sg-3a4b5cd6", user_id: "1234567890" }})}<commit_msg>revert test change<commit_after>require 'spec_helper'
Awspec::Stub.load 'security_group'

describe security_group('sg-1a2b3cd4') do
  it { should exist }
  its(:inbound) { should be_opened(80) }
  its(:inbound) { should be_opened(80).protocol('tcp').for('192.168.3.11/32') }
  its(:inbound) { should be_opened(80).protocol('tcp').for('172.16.31.10/25') }
  its(:inbound) { should be_opened(80).protocol('tcp').for('172.16.31.10/32') }
  its(:inbound) { should_not be_opened(80).protocol('tcp').for('192.168.127.12/16') }
  its(:inbound) { should be_opened(22) }
  its(:inbound) { should be_opened(22).protocol('tcp').for('sg-5a6b7cd8') }
  its(:inbound) { should be_opened('50000-50009').protocol('tcp').for('192.168.127.12/32') }
  its(:inbound) { should_not be_opened('50010-50019').protocol('tcp').for('192.168.127.12/32') }
  its(:outbound) { should be_opened(50_000) }
  its(:outbound) { should be_opened(8080).protocol('tcp').for('sg-9a8b7c6d') }
  its(:outbound) { should be_opened(8080).protocol('tcp').for('group-in-other-aws-account-with-vpc-peering') }
  its(:inbound) { should be_opened_only(60_000).protocol('tcp').for('172.16.31.10/32') }
  its(:inbound) { should be_opened_only(70_000).protocol('tcp').for(['172.16.31.10/32', '172.16.31.10/32']) }
  its(:outbound) { should be_opened_only(50_000).protocol('tcp').for('172.16.31.10/32') }
  its(:inbound) { should be_opened.protocol('all').for('sg-3a4b5cd6') }
  its(:outbound) { should be_opened.protocol('tcp').for('pl-a5321fa3') }
  its(:inbound_permissions_count) { should eq 7 }
  its(:ip_permissions_count) { should eq 7 }
  its(:outbound_permissions_count) { should eq 3 }
  its(:ip_permissions_egress_count) { should eq 3 }
  its(:inbound_rule_count) { should eq 8 }
  its(:outbound_rule_count) { should eq 2 }

  it { should have_inbound_rule( { ip_protocol: "tcp", from_port: 80, to_port: 80, ip_range: "172.16.31.10/24" })}
  it { should have_inbound_rule( { ip_protocol: "tcp", from_port: 80, to_port: 80, ip_range: "192.168.3.11/32" })}
  it { should have_inbound_rule( { ip_protocol: "tcp", from_port: 22, to_port: 22, group_pair: { group_id: "sg-5a6b7cd8" }})}
  it { should have_inbound_rule( { ip_protocol: "tcp", from_port: 22, to_port: 22, group_pair: { group_name: "group-name-sg" }})}
  it { should have_inbound_rule( { ip_protocol: "tcp", from_port: 60000, to_port: 60000, ip_range: "172.16.31.10/32" })}
  it { should have_inbound_rule( { ip_protocol: "tcp", from_port: 70000, to_port: 70000, ip_range: "172.16.31.10/32" })}
  it { should have_inbound_rule( { ip_protocol: "tcp", from_port: 70000, to_port: 70000, ip_range: "172.16.31.10/32" })}
  it { should have_inbound_rule( { ip_protocol: "tcp", from_port: 50000, to_port: 50009, ip_range: "192.168.127.12/32" })}
  it { should have_inbound_rule( { ip_protocol: "all", group_pair: {group_id: "sg-3a4b5cd6", user_id: "1234567890" }})}
{'fraction_non_alphanumeric': 0.1928633594429939, 'fraction_numerical': 0.12080069625761532, 'mean_word_length': 5.492655367231638, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 32, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2625534', 'n_tokens_mistral': 2742, 'n_tokens_neox': 2295, 'n_words': 374}