<commit_before>require 'spec_helper'

describe Puppet::Type.type(:firewall) do
  before :each do
    @resource = Puppet::Type.type(:firewall).new({
      :name => 'new_resource',
      :chain => 'INPUT',
      :jump => 'ACCEPT'
    })
  end

  it 'should accept a name' do
    @resource[:name] = '000-test-foo'
    @resource[:name].should == '000-test-foo'
  end

  it 'should accept a dport' do
    @resource[:dport] = '22'
    @resource[:dport].should == [22]
  end
end<commit_msg>add test for name, table, chain, dport, and sport parameters<commit_after>require 'spec_helper'

describe Puppet::Type.type(:firewall) do
  before :each do
    @resource = Puppet::Type.type(:firewall).new({
      :name => 'new_resource',
      :chain => 'INPUT',
      :jump => 'ACCEPT'
    })
  end

  describe ':name' do
    it 'should accept a name' do
      @resource[:name] = '000-test-foo'
      @resource[:name].should == '000-test-foo'
    end

    it 'should not accept a name with non-ASCII chars' do
      @resource[:name] = '%*#^(#$'
      @resource[:name].should raise_error(Puppet::Type::Firewall)
    end
  end

  describe ':chain' do
    [:INPUT, :FORWARD, :OUTPUT, :PREROUTING, :POSTROUTING].each do |chain|
      it "should accept chain value #{chain}" do
        @resource[:chain] = chain
        @resource[:chain].should == chain
      end
    end
  end

  describe ':table' do
    [:nat, :mangle, :filter, :raw].each do |table|
      it "should accept table value #{table}" do
        @resource[:table] = table
        @resource[:table].should == table
      end
    end
  end

  describe ':dport/sport' do
    [:dport, :sport].each do |port|
      it "should accept a #{port} as string" do
        @resource[port] = '22'
        @resource[port].should == [22]
      end

      it "should accept a #{port} as an array" do
        @resource[port] = ['22','23']
        @resource[port].should == [22,23]
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.15675116399379202, 'fraction_numerical': 0.014485256078634247, 'mean_word_length': 2.7408123791102517, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '529013', 'n_tokens_mistral': 682, 'n_tokens_neox': 643, 'n_words': 178}