Skip to content

Commit

Permalink
Merge even more from upstream
Browse files Browse the repository at this point in the history
Merge commit 'ce9fb48633fd9bef5c6fbc019e7bd34df8b0bc2a'

Conflicts:
	.gitmodules
	app.rb
	integrity.gemspec
	test/acceptance/edit_project_test.rb
  • Loading branch information
mislav committed Feb 13, 2009
2 parents 1db1fd0 + ce9fb48 commit ad3a703
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 18 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
@@ -1,6 +1,3 @@
[submodule "vendor/webrat"]
path = vendor/webrat
url = git://github.com/brynary/webrat.git
[submodule "vendor/sinatra"]
path = vendor/sinatra
url = git://github.com/rtomayko/sinatra.git
Expand Down
3 changes: 2 additions & 1 deletion Rakefile
Expand Up @@ -118,6 +118,7 @@ else
s.add_dependency 'do_sqlite3', ['>= 0.9.5']
s.add_dependency 'json'
s.add_dependency 'thor'
s.add_dependency 'bcrypt-ruby'
s.add_dependency 'uuidtools' # required by dm-types
s.add_dependency 'bcrypt-ruby' # required by dm-types
end
end
4 changes: 2 additions & 2 deletions app.rb
Expand Up @@ -74,7 +74,7 @@

get "/:project.atom" do
login_required unless current_project.public?
response.headers["Content-Type"] = "application/atom+xml; charset=utf-8"
response["Content-Type"] = "application/rss+xml; charset=utf-8"
builder :project
end

Expand Down Expand Up @@ -128,7 +128,7 @@
end

get "/integrity.css" do
response.headers["Content-Type"] = "text/css; charset=utf-8"
response["Content-Type"] = "text/css; charset=utf-8"
sass :integrity
end

Expand Down
1 change: 1 addition & 0 deletions config/config.sample.ru
Expand Up @@ -27,4 +27,5 @@ set :port, 8910
set :env, :production
disable :run, :reload

use Rack::CommonLogger, Integrity.logger if Integrity.config[:log_debug_info]
run Sinatra.application
4 changes: 4 additions & 0 deletions config/config.sample.yml
Expand Up @@ -16,6 +16,10 @@
# Path to the integrity log file
:log: /var/log/integrity.log

# Enable/Disable debug logging. Turning this on will log queries made to the
# database and web requests (if using the provided rackup file)
:log_debug_info: false

# Enable or disable HTTP authentication for the app. BE AWARE that if you
# disable this anyone can delete and alter projects, so do it only if your
# app is running in a controlled environment (ie, behind your company's
Expand Down
10 changes: 9 additions & 1 deletion integrity.gemspec
Expand Up @@ -6,14 +6,16 @@ Gem::Specification.new do |s|

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Nicol\303\241s Sanguinetti", "Simon Rozet"]
s.date = %q{2009-01-19}
s.date = %q{2009-02-13}
s.default_executable = %q{integrity}
s.description = %q{Your Friendly Continuous Integration server. Easy, fun and painless!}
s.email = %q{contacto@nicolassanguinetti.info}
s.executables = ["integrity"]
s.files = ["README.markdown", "Rakefile", "VERSION.yml", "app.rb", "bin/integrity", "config/config.sample.ru", "config/config.sample.yml", "config/thin.sample.yml", "integrity.gemspec", "lib/integrity.rb", "lib/integrity/build.rb", "lib/integrity/core_ext/object.rb", "lib/integrity/core_ext/string.rb", "lib/integrity/helpers.rb", "lib/integrity/installer.rb", "lib/integrity/migrations.rb", "lib/integrity/notifier.rb", "lib/integrity/notifier/base.rb", "lib/integrity/project.rb", "lib/integrity/project_builder.rb", "lib/integrity/scm.rb", "lib/integrity/scm/git.rb", "lib/integrity/scm/git/uri.rb", "public/buttons.css", "public/reset.css", "public/spinner.gif", "vendor/integrity-email", "vendor/sinatra", "vendor/sinatra-diddies", "views/_build_info.haml", "views/build.haml", "views/error.haml", "views/home.haml", "views/integrity.sass", "views/layout.haml", "views/new.haml", "views/not_found.haml", "views/notifier.haml", "views/project.builder", "views/project.haml", "views/unauthorized.haml", "vendor/sinatra/lib/sinatra", "vendor/sinatra/lib/sinatra/base.rb", "vendor/sinatra/lib/sinatra/compat.rb", "vendor/sinatra/lib/sinatra/images", "vendor/sinatra/lib/sinatra/images/404.png", "vendor/sinatra/lib/sinatra/images/500.png", "vendor/sinatra/lib/sinatra/main.rb", "vendor/sinatra/lib/sinatra/test", "vendor/sinatra/lib/sinatra/test/bacon.rb", "vendor/sinatra/lib/sinatra/test/rspec.rb", "vendor/sinatra/lib/sinatra/test/spec.rb", "vendor/sinatra/lib/sinatra/test/unit.rb", "vendor/sinatra/lib/sinatra/test.rb", "vendor/sinatra/lib/sinatra.rb", "vendor/sinatra-diddies/lib/diddies", "vendor/sinatra-diddies/lib/diddies/authorization.rb", "vendor/sinatra-diddies/lib/diddies/mailer.rb", "vendor/sinatra-diddies/lib/diddies.rb", "vendor/integrity-email/lib/notifier", "vendor/integrity-email/lib/notifier/config.haml", "vendor/integrity-email/lib/notifier/email.rb"]
s.has_rdoc = true
s.homepage = %q{http://integrityapp.com}
s.post_install_message = %q{Run `integrity help` for information on how to setup Integrity.}
s.rdoc_options = ["--inline-source", "--charset=UTF-8"]
s.require_paths = ["lib"]
s.rubyforge_project = %q{integrity}
s.rubygems_version = %q{1.3.1}
Expand All @@ -24,6 +26,7 @@ Gem::Specification.new do |s|
s.specification_version = 2

if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
s.add_runtime_dependency(%q<sinatra>, [">= 0.9.0.3"])
s.add_runtime_dependency(%q<haml>, [">= 0"])
s.add_runtime_dependency(%q<dm-core>, [">= 0.9.5"])
s.add_runtime_dependency(%q<dm-validations>, [">= 0.9.5"])
Expand All @@ -35,8 +38,10 @@ Gem::Specification.new do |s|
s.add_runtime_dependency(%q<do_sqlite3>, [">= 0.9.5"])
s.add_runtime_dependency(%q<json>, [">= 0"])
s.add_runtime_dependency(%q<thor>, [">= 0"])
s.add_runtime_dependency(%q<uuidtools>, [">= 0"])
s.add_runtime_dependency(%q<bcrypt-ruby>, [">= 0"])
else
s.add_dependency(%q<sinatra>, [">= 0.9.0.3"])
s.add_dependency(%q<haml>, [">= 0"])
s.add_dependency(%q<dm-core>, [">= 0.9.5"])
s.add_dependency(%q<dm-validations>, [">= 0.9.5"])
Expand All @@ -48,9 +53,11 @@ Gem::Specification.new do |s|
s.add_dependency(%q<do_sqlite3>, [">= 0.9.5"])
s.add_dependency(%q<json>, [">= 0"])
s.add_dependency(%q<thor>, [">= 0"])
s.add_dependency(%q<uuidtools>, [">= 0"])
s.add_dependency(%q<bcrypt-ruby>, [">= 0"])
end
else
s.add_dependency(%q<sinatra>, [">= 0.9.0.3"])
s.add_dependency(%q<haml>, [">= 0"])
s.add_dependency(%q<dm-core>, [">= 0.9.5"])
s.add_dependency(%q<dm-validations>, [">= 0.9.5"])
Expand All @@ -62,6 +69,7 @@ Gem::Specification.new do |s|
s.add_dependency(%q<do_sqlite3>, [">= 0.9.5"])
s.add_dependency(%q<json>, [">= 0"])
s.add_dependency(%q<thor>, [">= 0"])
s.add_dependency(%q<uuidtools>, [">= 0"])
s.add_dependency(%q<bcrypt-ruby>, [">= 0"])
end
end
5 changes: 3 additions & 2 deletions lib/integrity.rb
Expand Up @@ -26,7 +26,7 @@
module Integrity
def self.new(config_file = nil)
self.config = config_file unless config_file.nil?
DataMapper.logger = self.logger
DataMapper.logger = self.logger if config[:log_debug_info]
DataMapper.setup(:default, config[:database_uri])
end

Expand All @@ -40,7 +40,8 @@ def self.default_configuration
:log => STDOUT,
:base_uri => "http://localhost:8910",
:use_basic_auth => false,
:build_all_commits => true }
:build_all_commits => true,
:log_debug_info => false }
end

def self.config
Expand Down
18 changes: 12 additions & 6 deletions lib/integrity/helpers.rb
Expand Up @@ -26,7 +26,7 @@ def authorize(user, password)
end

def unauthorized!(realm=authorization_realm)
response.headers["WWW-Authenticate"] = %(Basic realm="#{realm}")
response["WWW-Authenticate"] = %(Basic realm="#{realm}")
throw :halt, [401, show(:unauthorized, :title => "incorrect credentials")]
end

Expand Down Expand Up @@ -71,19 +71,19 @@ def cycle(*values)
# def integrity_domain
# Addressable::URI.parse(Integrity.config[:base_uri]).to_s
# end

def url(path)
url = "#{request.scheme}://#{request.host}"

if request.scheme == "https" && request.port != 443 ||
request.scheme == "http" && request.port != 80
url << ":#{request.port}"
end

url << "/" unless path.index("/").zero?
url << path
end

def root_url
url("/")
end
Expand All @@ -97,7 +97,13 @@ def project_url(project, *path)
end

def push_url_for(project)
project_url(project, "push")
Addressable::URI.parse(project_url(project, "push")).tap do |url|
if Integrity.config[:use_basic_auth]
url.user = Integrity.config[:admin_username]
url.password = Integrity.config[:hash_admin_password] ?
"<password>" : Integrity.config[:admin_password]
end
end.to_s
end

def build_path(build)
Expand Down
4 changes: 2 additions & 2 deletions test/acceptance/api_test.rb
Expand Up @@ -33,7 +33,7 @@ class ApiTest < Test::Unit::AcceptanceTestCase
end
end

Project.gen(:my_test_project, :uri => repo.path)
Project.gen(:my_test_project, :uri => repo.path, :command => "echo successful")

lambda do
basic_auth "admin", "test"
Expand Down Expand Up @@ -71,7 +71,7 @@ class ApiTest < Test::Unit::AcceptanceTestCase
Project.gen(:my_test_project, :uri => git_repo(:my_test_project).path)
head = git_repo(:my_test_project).head
post "/my-test-project/push", :payload => payload(head, "master")

response_code.should == 401
end

Expand Down
12 changes: 11 additions & 1 deletion test/acceptance/edit_project_test.rb
Expand Up @@ -77,7 +77,17 @@ class EditProjectTest < Test::Unit::AcceptanceTestCase

response_body.should_not have_tag('input[@type="checkbox"][@checked][@name="project_data[public]"]')
end


scenario "an admin can see the push URL on the edit page" do
disable_auth!
Project.generate(:my_test_project)

visit "/my-test-project"
click_link "Edit Project"

response_body.should have_tag("#push_url", "http://integrity.example.org/my-test-project/push")
end

scenario "a user can't edit a project's information" do
Project.generate(:integrity)

Expand Down
30 changes: 30 additions & 0 deletions test/unit/helpers_test.rb
Expand Up @@ -21,4 +21,34 @@ class BrowsePublicProjectsTest < Test::Unit::TestCase
pretty_date(Time.mktime(1995, 12, 15)).should == "on Dec 15th"
pretty_date(Time.mktime(1995, 12, 15)).should == "on Dec 15th"
end

describe "#push_url_for" do
before(:each) do
setup_and_reset_database!
@project = Project.gen(:integrity)
Integrity.config[:admin_username] = "admin"
Integrity.config[:admin_password] = "test"
Integrity.config[:base_uri] = "http://integrity.example.org:1234"
end

test "with auth disabled" do
Integrity.config[:use_basic_auth] = false

push_url_for(@project).should == "http://integrity.example.org:1234/integrity/push"
end

test "with auth and hashing enabled" do
Integrity.config[:use_basic_auth] = true
Integrity.config[:hash_admin_password] = true

push_url_for(@project).should == "http://admin:<password>@integrity.example.org:1234/integrity/push"
end

test "with auth enabled and hashing disabled" do
Integrity.config[:use_basic_auth] = true
Integrity.config[:hash_admin_password] = false

push_url_for(@project).should == "http://admin:test@integrity.example.org:1234/integrity/push"
end
end
end

0 comments on commit ad3a703

Please sign in to comment.