Added symlink check to load_config.

This commit is contained in:
ethicalhack3r
2013-02-24 15:44:24 +01:00
parent 52b7aba348
commit 3c6292e9b4
2 changed files with 13 additions and 2 deletions

View File

@@ -137,7 +137,11 @@ class Browser
def load_config(config_file = nil)
@config_file = config_file || @config_file
data = JSON.parse(File.read(@config_file))
if File.symlink?(@config_file)
raise "[ERROR] #{config_file} is a symlink."
else
data = JSON.parse(File.read(@config_file))
end
ACCESSOR_OPTIONS.each do |option|
option_name = option.to_s

View File

@@ -200,7 +200,14 @@ describe Browser do
# TODO
describe '#load_config' do
it 'should raise an error if file is a symlink' do
symlink = './rspec_symlink'
browser = Browser.instance
File.symlink('./testfile', symlink)
expect { browser.load_config(symlink) }.to raise_error
File.unlink(symlink)
end
end
describe '#merge_request_params without proxy' do