<commit_before>require File.join(File.dirname(__FILE__), "../spec_helper.rb")

describe Threshold::Suppression do

#Standard SID and GID test with no additional data
  it 'prints a valid configuration line' do
    suppression = Threshold::Suppression.new
    suppression.sid=123
    suppression.gid=456
    expect(suppression.to_s).to eq 'suppress gen_id 456, sig_id 123'
  end

#Standard SID GID Track by_src and IP test
  it 'prints a valid configuration line' do
    suppression = Threshold::Suppression.new
    suppression.sid=123
    suppression.gid=456
    suppression.track_by='src'
    suppression.ip='1.2.3.4'
    expect(suppression.to_s).to eq 'suppress gen_id 456, sig_id 123, track by_src, ip 1.2.3.4'
  end

#Standard SID GID Track by_dst and IP test
 it 'prints a valid configuration line' do
    suppression = Threshold::Suppression.new
    suppression.sid=123
    suppression.gid=456
    suppression.track_by='dst'
    suppression.ip='1.2.3.4'
    expect(suppression.to_s).to eq 'suppress gen_id 456, sig_id 123, track by_dst, ip 1.2.3.4'
  end

 #Standard SID GID Track by_dst and full IP length test
 it 'prints a valid configuration line' do
    suppression = Threshold::Suppression.new
    suppression.sid=123
    suppression.gid=456
    suppression.track_by='dst'
    suppression.ip='172.16.17.32'
    expect(suppression.to_s).to eq 'suppress gen_id 456, sig_id 123, track by_dst, ip 172.16.17.32'
  end

#Standard SID GID Track by_src and double digit CIRD IP test
  it 'prints a valid configuration line' do
    suppression = Threshold::Suppression.new
    suppression.sid=123
    suppression.gid=456
    suppression.track_by='src'
    suppression.ip='1.2.3.4/20'
    expect(suppression.to_s).to eq 'suppress gen_id 456, sig_id 123, track by_src, ip 1.2.3.4/20'
  end

#Standard SID GID Track by_src and single digit CIRD IP test
  it 'prints a valid configuration line' do
    suppression = Threshold::Suppression.new
    suppression.sid=123
    suppression.gid=456
    suppression.track_by='src'
    suppression.ip='1.2.3.4/8'
    expect(suppression.to_s).to eq 'suppress gen_id 456, sig_id 123, track by_src, ip 1.2.3.4/8'
  end

#Test failure if CIDR is too long
it 'prints a valid configuration line' do
    suppression = Threshold::Suppression.new
    suppression.sid=123
    suppression.gid=456
    suppression.track_by='src'
    suppression.ip='1.2.3.4/208'
    expect { suppression.to_s }.to raise_error(Threshold::InvalidSuppressionObject)
  end


#Test failure of no IP set but Track by_ set
  it 'should raise an Invalid Suppression Object Error' do
    suppression = Threshold::Suppression.new
    suppression.sid=123
    suppression.gid=456
    suppression.track_by='src'
    suppression.ip=''
    expect { suppression.to_s }.to raise_error(Threshold::InvalidSuppressionObject)
  end

#Test failure on SID and Track by_ set with no GID or IP set
  it 'should raise an Invalid Suppression Object Error' do
    suppression = Threshold::Suppression.new
    suppression.sid=123
    suppression.track_by='src'
    expect { suppression.to_s }.to raise_error(Threshold::InvalidSuppressionObject)
  end

#Test failure on SID set but no GID
    it 'should raise an Invalid Suppression Object Error' do
    suppression = Threshold::Suppression.new
    suppression.sid=123
    expect { suppression.to_s }.to raise_error(Threshold::InvalidSuppressionObject)
  end

#Test failure on GID set with no SID
    it 'should raise an Invalid Suppression Object Error' do
    suppression = Threshold::Suppression.new
    suppression.gid=234
    expect { suppression.to_s }.to raise_error(Threshold::InvalidSuppressionObject)
  end

#Test failure on too many octects in IP
  it 'should raise an Invalid Suppression Object Error' do
    suppression = Threshold::Suppression.new
    suppression.sid=123
    suppression.gid=456
    suppression.track_by='src'
    suppression.ip='1.2.3.4.5'
    expect { suppression.to_s }.to raise_error(Threshold::InvalidSuppressionObject)
  end

#Test failure on invalid IP address
  it 'should raise an Invalid Suppression Object Error' do
    suppression = Threshold::Suppression.new
    suppression.sid=123
    suppression.gid=456
    suppression.track_by='src'
    suppression.ip='100.200.300.400'
    expect { suppression.to_s }.to raise_error(Threshold::InvalidSuppressionObject)
  end

#Test failure on invalid CIDR range of 0
  it 'should raise an Invalid Suppression Object Error' do
    suppression = Threshold::Suppression.new
    suppression.sid=123
    suppression.gid=456
    suppression.track_by='src'
    suppression.ip='1.2.3.4/0'
    expect { suppression.to_s }.to raise_error(Threshold::InvalidSuppressionObject)
  end

end

<commit_msg>added additional SID and GID validation<commit_after>require File.join(File.dirname(__FILE__), "../spec_helper.rb")

describe Threshold::Suppression do

#Standard SID and GID test with no additional data
  it 'prints a valid configuration line' do
    suppression = Threshold::Suppression.new
    suppression.sid=123
    suppression.gid=456
    expect(suppression.to_s).to eq 'suppress gen_id 456, sig_id 123'
  end

#Standard SID GID Track by_src and IP test
  it 'prints a valid configuration line' do
    suppression = Threshold::Suppression.new
    suppression.sid=123
    suppression.gid=456
    suppression.track_by='src'
    suppression.ip='1.2.3.4'
    expect(suppression.to_s).to eq 'suppress gen_id 456, sig_id 123, track by_src, ip 1.2.3.4'
  end

#Standard SID GID Track by_dst and IP test
 it 'prints a valid configuration line' do
    suppression = Threshold::Suppression.new
    suppression.sid=123
    suppression.gid=456
    suppression.track_by='dst'
    suppression.ip='1.2.3.4'
    expect(suppression.to_s).to eq 'suppress gen_id 456, sig_id 123, track by_dst, ip 1.2.3.4'
  end

 #Standard SID GID Track by_dst and full IP length test
 it 'prints a valid configuration line' do
    suppression = Threshold::Suppression.new
    suppression.sid=123
    suppression.gid=456
    suppression.track_by='dst'
    suppression.ip='172.16.17.32'
    expect(suppression.to_s).to eq 'suppress gen_id 456, sig_id 123, track by_dst, ip 172.16.17.32'
  end

#Standard SID GID Track by_src and double digit CIRD IP test
  it 'prints a valid configuration line' do
    suppression = Threshold::Suppression.new
    suppression.sid=123
    suppression.gid=456
    suppression.track_by='src'
    suppression.ip='1.2.3.4/20'
    expect(suppression.to_s).to eq 'suppress gen_id 456, sig_id 123, track by_src, ip 1.2.3.4/20'
  end

#Standard SID GID Track by_src and single digit CIRD IP test
  it 'prints a valid configuration line' do
    suppression = Threshold::Suppression.new
    suppression.sid=123
    suppression.gid=456
    suppression.track_by='src'
    suppression.ip='1.2.3.4/8'
    expect(suppression.to_s).to eq 'suppress gen_id 456, sig_id 123, track by_src, ip 1.2.3.4/8'
  end

#Test failure if CIDR is too long
it 'prints a valid configuration line' do
    suppression = Threshold::Suppression.new
    suppression.sid=123
    suppression.gid=456
    suppression.track_by='src'
    suppression.ip='1.2.3.4/208'
    expect { suppression.to_s }.to raise_error(Threshold::InvalidSuppressionObject)
  end


#Test failure of no IP set but Track by_ set
  it 'should raise an Invalid Suppression Object Error' do
    suppression = Threshold::Suppression.new
    suppression.sid=123
    suppression.gid=456
    suppression.track_by='src'
    suppression.ip=''
    expect { suppression.to_s }.to raise_error(Threshold::InvalidSuppressionObject)
  end

#Test failure on SID and Track by_ set with no GID or IP set
  it 'should raise an Invalid Suppression Object Error' do
    suppression = Threshold::Suppression.new
    suppression.sid=123
    suppression.track_by='src'
    expect { suppression.to_s }.to raise_error(Threshold::InvalidSuppressionObject)
  end

#Test failure on SID set but no GID
    it 'should raise an Invalid Suppression Object Error' do
    suppression = Threshold::Suppression.new
    suppression.sid=123
    expect { suppression.to_s }.to raise_error(Threshold::InvalidSuppressionObject)
  end

#Test failure on GID set with no SID
    it 'should raise an Invalid Suppression Object Error' do
    suppression = Threshold::Suppression.new
    suppression.gid=234
    expect { suppression.to_s }.to raise_error(Threshold::InvalidSuppressionObject)
  end

#Test failure on too many octects in IP
  it 'should raise an Invalid Suppression Object Error' do
    suppression = Threshold::Suppression.new
    suppression.sid=123
    suppression.gid=456
    suppression.track_by='src'
    suppression.ip='1.2.3.4.5'
    expect { suppression.to_s }.to raise_error(Threshold::InvalidSuppressionObject)
  end

#Test failure on invalid IP address
  it 'should raise an Invalid Suppression Object Error' do
    suppression = Threshold::Suppression.new
    suppression.sid=123
    suppression.gid=456
    suppression.track_by='src'
    suppression.ip='100.200.300.400'
    expect { suppression.to_s }.to raise_error(Threshold::InvalidSuppressionObject)
  end

#Test failure on invalid CIDR range of 0
  it 'should raise an Invalid Suppression Object Error' do
    suppression = Threshold::Suppression.new
    suppression.sid=123
    suppression.gid=456
    suppression.track_by='src'
    suppression.ip='1.2.3.4/0'
    expect { suppression.to_s }.to raise_error(Threshold::InvalidSuppressionObject)
  end

#Test failure if SID contains letters
it 'prints a valid configuration line' do
    suppression = Threshold::Suppression.new
    suppression.sid='123a'
    suppression.gid=456
    suppression.track_by='src'
    suppression.ip='1.2.3.4'
    expect { suppression.to_s }.to raise_error(Threshold::InvalidSuppressionObject)
  end

  #Test failure if GID contains letters
it 'prints a valid configuration line' do
    suppression = Threshold::Suppression.new
    suppression.sid=123
    suppression.gid='456a'
    suppression.track_by='src'
    suppression.ip='1.2.3.4'
    expect { suppression.to_s }.to raise_error(Threshold::InvalidSuppressionObject)
  end

end


{'fraction_non_alphanumeric': 0.08862014274385409, 'fraction_numerical': 0.04103885804916733, 'mean_word_length': 3.8975728155339806, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 28, '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': '7574610', 'n_tokens_mistral': 3535, 'n_tokens_neox': 3242, 'n_words': 907}