Added mcollective 2.3.1 package
[packages/trusty/mcollective.git] / spec / unit / plugins / mcollective / validator / shellsafe_validator_spec.rb
1 #!/usr/bin/env rspec
2 require 'spec_helper'
3 require File.dirname(__FILE__) + '/../../../../../plugins/mcollective/validator/shellsafe_validator.rb'
4
5 module MCollective
6   module Validator
7     describe "#validate" do
8       it "should raise an exception if the given string is not shellsafe" do
9         ['`', '$', ';', '|', '&&', '>', '<'].each do |chr|
10           expect{
11             ShellsafeValidator.validate("#{chr}test")
12           }.to raise_error(ValidatorError, "value should not have #{chr} in it")
13         end
14       end
15
16       it "should not raise an exception if the given string is shellsafe" do
17         ShellsafeValidator.validate("test")
18       end
19     end
20   end
21 end