[refs #777] fixed git trees specs

This commit is contained in:
Alexander Machehin 2012-12-18 21:59:18 +06:00
parent d421a2fa21
commit 1306a26884
2 changed files with 16 additions and 11 deletions

View File

@ -3,10 +3,6 @@ require 'spec_helper'
describe Projects::Git::TreesController do
def fill_project
%x(cp -Rf #{Rails.root}/spec/tests.git/* #{@project.repo.path}) # maybe FIXME ?
end
before(:each) do
stub_symlink_methods
@ -23,7 +19,7 @@ describe Projects::Git::TreesController do
get :archive, @params.merge(:format => 'tar.gz')
response.should be_success
end
it 'should not be able to perform archive action without anonymous acccess', :anonymous_access => false do
fill_project
get :archive, @params.merge(:format => 'tar.gz')
@ -39,25 +35,27 @@ describe Projects::Git::TreesController do
end
it 'should not be able to injection code with format' do
fill_project
@user = FactoryGirl.create(:user)
set_session_for(@user)
fill_project
expect { get :archive, @params.merge(:format => "tar.gz master > /dev/null; echo 'I am hacker!';\#") }.to raise_error(ActionController::RoutingError)
end
it 'should not be able to injection code with treeish' do
fill_project
@user = FactoryGirl.create(:user)
set_session_for(@user)
fill_project
expect { get :archive, @params.merge(:treeish => "master > /dev/null; echo 'I am hacker!';\#") }.to raise_error(ActionController::RoutingError)
end
it 'should be able to perform archive action' do
fill_project
@user = FactoryGirl.create(:user)
set_session_for(@user)
fill_project
get :archive, @params.merge(:format => 'tar.gz')
response.should be_success
end
end
after(:all) {clean_projects_dir}
end

View File

@ -60,6 +60,13 @@ end
Resque.inline = true
# Add testing root_path
%x(rm -Rf #{Rails.root}/tmp/test_root)
%x(mkdir -p #{Rails.root}/tmp/test_root)
APP_CONFIG['root_path'] = "#{Rails.root}/tmp/test_root"
%x(rm -Rf #{APP_CONFIG['git_path']})
%x(mkdir -p #{APP_CONFIG['git_path']})
def fill_project
%x(cp -Rf #{Rails.root}/spec/tests.git/* #{@project.path}) # maybe FIXME ?
end
def clean_projects_dir
FileUtils.rm_rf "#{APP_CONFIG['git_path']}"
end