|
| 1 | +require 'spec_helper' |
| 2 | +require 'cfn-model/parser/cfn_parser' |
| 3 | + |
| 4 | +describe CfnParser do |
| 5 | + before :each do |
| 6 | + @cfn_parser = CfnParser.new |
| 7 | + end |
| 8 | + |
| 9 | + context 'Network ACL that has one egress entry' do |
| 10 | + it 'returns a Network ACL with one egress entry' do |
| 11 | + expected_nacls = network_acl_with_one_egress_entry(cfn_model: CfnModel.new) |
| 12 | + yaml_test_templates('ec2_network_acl/nacl_with_one_egress_entry').each do |test_template| |
| 13 | + cfn_model = @cfn_parser.parse IO.read(test_template) |
| 14 | + nacls = cfn_model.resources_by_type 'AWS::EC2::NetworkAcl' |
| 15 | + |
| 16 | + expect(nacls.size).to eq 1 |
| 17 | + expect(nacls[0]).to eq expected_nacls |
| 18 | + expect(nacls[0].network_acl_egress_entries).to eq expected_nacls.network_acl_egress_entries |
| 19 | + expect(nacls[0].network_acl_egress_entries).not_to be_empty |
| 20 | + end |
| 21 | + end |
| 22 | + end |
| 23 | + |
| 24 | + context 'Network ACL that has one ingress entry' do |
| 25 | + it 'returns a Network ACL with one ingress entry' do |
| 26 | + expected_nacls = network_acl_with_one_ingress_entry(cfn_model: CfnModel.new) |
| 27 | + yaml_test_templates('ec2_network_acl/nacl_with_one_ingress_entry').each do |test_template| |
| 28 | + cfn_model = @cfn_parser.parse IO.read(test_template) |
| 29 | + nacls = cfn_model.resources_by_type 'AWS::EC2::NetworkAcl' |
| 30 | + |
| 31 | + expect(nacls.size).to eq 1 |
| 32 | + expect(nacls[0]).to eq expected_nacls |
| 33 | + expect(nacls[0].network_acl_ingress_entries).to eq expected_nacls.network_acl_ingress_entries |
| 34 | + expect(nacls[0].network_acl_ingress_entries).not_to be_empty |
| 35 | + end |
| 36 | + end |
| 37 | + end |
| 38 | + |
| 39 | + context 'Network ACL that has two egress entries' do |
| 40 | + it 'returns a Network ACL with two egress entries' do |
| 41 | + expected_nacls = network_acl_with_two_egress_entries(cfn_model: CfnModel.new) |
| 42 | + yaml_test_templates('ec2_network_acl/nacl_with_two_egress_entries').each do |test_template| |
| 43 | + cfn_model = @cfn_parser.parse IO.read(test_template) |
| 44 | + nacls = cfn_model.resources_by_type 'AWS::EC2::NetworkAcl' |
| 45 | + |
| 46 | + expect(nacls.size).to eq 1 |
| 47 | + expect(nacls[0]).to eq expected_nacls |
| 48 | + expect(nacls[0].network_acl_egress_entries).to eq expected_nacls.network_acl_egress_entries |
| 49 | + expect(nacls[0].network_acl_egress_entries).not_to be_empty |
| 50 | + end |
| 51 | + end |
| 52 | + end |
| 53 | + |
| 54 | + context 'Network ACL that has two ingress entries' do |
| 55 | + it 'returns a Network ACL with two ingress entries' do |
| 56 | + expected_nacls = network_acl_with_two_ingress_entries(cfn_model: CfnModel.new) |
| 57 | + yaml_test_templates('ec2_network_acl/nacl_with_two_ingress_entries').each do |test_template| |
| 58 | + cfn_model = @cfn_parser.parse IO.read(test_template) |
| 59 | + nacls = cfn_model.resources_by_type 'AWS::EC2::NetworkAcl' |
| 60 | + |
| 61 | + expect(nacls.size).to eq 1 |
| 62 | + expect(nacls[0]).to eq expected_nacls |
| 63 | + expect(nacls[0].network_acl_ingress_entries).to eq expected_nacls.network_acl_ingress_entries |
| 64 | + expect(nacls[0].network_acl_ingress_entries).not_to be_empty |
| 65 | + end |
| 66 | + end |
| 67 | + end |
| 68 | + context 'Network ACL that has one egress and ingress entry' do |
| 69 | + it 'returns a Network ACL with one egress and ingress entry' do |
| 70 | + expected_nacls = network_acl_with_egress_and_ingress_entries(cfn_model: CfnModel.new) |
| 71 | + yaml_test_templates('ec2_network_acl/nacl_with_one_egress_and_ingress_entry').each do |test_template| |
| 72 | + cfn_model = @cfn_parser.parse IO.read(test_template) |
| 73 | + nacls = cfn_model.resources_by_type 'AWS::EC2::NetworkAcl' |
| 74 | + |
| 75 | + expect(nacls.size).to eq 1 |
| 76 | + expect(nacls[0]).to eq expected_nacls |
| 77 | + expect(nacls[0].network_acl_egress_entries).to eq expected_nacls.network_acl_egress_entries |
| 78 | + expect(nacls[0].network_acl_ingress_entries).to eq expected_nacls.network_acl_ingress_entries |
| 79 | + expect(nacls[0].network_acl_egress_entries).not_to be_empty |
| 80 | + expect(nacls[0].network_acl_ingress_entries).not_to be_empty |
| 81 | + end |
| 82 | + end |
| 83 | + end |
| 84 | +end |
0 commit comments