integrity 0.1.9.1 → 0.1.9.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +12 -0
- data/CHANGES +28 -0
- data/README.markdown +6 -0
- data/Rakefile +44 -83
- data/config/heroku/.gems +0 -3
- data/config/heroku/integrity-config.rb +4 -1
- data/integrity.gemspec +18 -6
- data/lib/integrity.rb +9 -5
- data/lib/integrity/app.rb +8 -8
- data/lib/integrity/build.rb +7 -7
- data/lib/integrity/helpers/authorization.rb +1 -1
- data/lib/integrity/helpers/breadcrumbs.rb +1 -1
- data/lib/integrity/helpers/rendering.rb +8 -2
- data/lib/integrity/helpers/urls.rb +33 -23
- data/lib/integrity/installer.rb +18 -17
- data/lib/integrity/notifier/base.rb +7 -2
- data/lib/integrity/project.rb +2 -2
- data/test/acceptance/api_test.rb +1 -1
- data/test/acceptance/browse_project_builds_test.rb +1 -1
- data/test/acceptance/browse_project_test.rb +1 -1
- data/test/acceptance/build_notifications_test.rb +1 -1
- data/test/acceptance/create_project_test.rb +1 -1
- data/test/acceptance/delete_project_test.rb +1 -1
- data/test/acceptance/edit_project_test.rb +1 -1
- data/test/acceptance/error_page_test.rb +1 -1
- data/test/acceptance/installer_test.rb +2 -6
- data/test/acceptance/manual_build_project_test.rb +1 -1
- data/test/acceptance/not_found_page_test.rb +29 -0
- data/test/acceptance/notifier_test.rb +1 -1
- data/test/acceptance/project_syndication_test.rb +1 -1
- data/test/acceptance/stylesheet_test.rb +10 -2
- data/test/acceptance/unauthorized_page_test.rb +20 -0
- data/test/helpers.rb +13 -7
- data/test/helpers/acceptance.rb +1 -0
- data/test/unit/build_test.rb +10 -0
- data/test/unit/helpers_test.rb +63 -20
- data/test/unit/integrity_test.rb +23 -6
- data/test/unit/notifier_test.rb +5 -0
- data/test/unit/project_test.rb +5 -0
- data/views/home.haml +2 -2
- data/views/layout.haml +6 -5
- data/views/new.haml +1 -1
- data/views/not_found.haml +2 -2
- data/views/unauthorized.haml +4 -4
- metadata +105 -6
- data/test/acceptance/helpers.rb +0 -2
- data/vendor/sinatra-ditties/README.rdoc +0 -3
- data/vendor/sinatra-ditties/lib/sinatra/ditties.rb +0 -12
- data/vendor/sinatra-ditties/lib/sinatra/ditties/authorization.rb +0 -61
- data/vendor/sinatra-ditties/lib/sinatra/ditties/mailer.rb +0 -146
@@ -1,61 +0,0 @@
|
|
1
|
-
module Sinatra
|
2
|
-
# HTTP Authorization helpers for Sinatra.
|
3
|
-
#
|
4
|
-
# In your helpers module, include Sinatra::Authorization and then define
|
5
|
-
# a +authorize(user, password)+ method to handle user provided
|
6
|
-
# credentials.
|
7
|
-
#
|
8
|
-
# Inside your events, call +login_required+ to trigger the HTTP
|
9
|
-
# Authorization window to pop up in the browser.
|
10
|
-
#
|
11
|
-
# Code adapted from Ryan Tomayko <http://tomayko.com> and Christopher
|
12
|
-
# Schneid <http://gittr.com>, shared under an MIT License
|
13
|
-
module Authorization
|
14
|
-
# Redefine this method on your helpers block to actually contain
|
15
|
-
# your authorization logic.
|
16
|
-
def authorize(username, password)
|
17
|
-
false
|
18
|
-
end
|
19
|
-
|
20
|
-
# From you app, call set :authorization_realm, "my app" to set this
|
21
|
-
# or define a `authorization_realm` method in your helpers block.
|
22
|
-
def authorization_realm
|
23
|
-
Sinatra::Default.authorization_realm
|
24
|
-
end
|
25
|
-
|
26
|
-
# Call in any event that requires authentication
|
27
|
-
def login_required
|
28
|
-
return if authorized?
|
29
|
-
unauthorized! unless auth.provided?
|
30
|
-
bad_request! unless auth.basic?
|
31
|
-
unauthorized! unless authorize(*auth.credentials)
|
32
|
-
request.env['REMOTE_USER'] = auth.username
|
33
|
-
end
|
34
|
-
|
35
|
-
# Convenience method to determine if a user is logged in
|
36
|
-
def authorized?
|
37
|
-
!!request.env['REMOTE_USER']
|
38
|
-
end
|
39
|
-
alias :logged_in? :authorized?
|
40
|
-
|
41
|
-
# Name provided by the current user to log in
|
42
|
-
def current_user
|
43
|
-
request.env['REMOTE_USER']
|
44
|
-
end
|
45
|
-
|
46
|
-
private
|
47
|
-
|
48
|
-
def auth
|
49
|
-
@auth ||= Rack::Auth::Basic::Request.new(request.env)
|
50
|
-
end
|
51
|
-
|
52
|
-
def unauthorized!(realm=authorization_realm)
|
53
|
-
response["WWW-Authenticate"] = %(Basic realm="#{realm}")
|
54
|
-
throw :halt, [ 401, 'Authorization Required' ]
|
55
|
-
end
|
56
|
-
|
57
|
-
def bad_request!
|
58
|
-
throw :halt, [ 400, 'Bad Request' ]
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
@@ -1,146 +0,0 @@
|
|
1
|
-
# Shamelssly stolen from Merb::Mailer
|
2
|
-
# http://merbivore.com
|
3
|
-
|
4
|
-
require 'net/smtp'
|
5
|
-
require 'rubygems'
|
6
|
-
require 'mailfactory'
|
7
|
-
require 'tlsmail'
|
8
|
-
|
9
|
-
Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE)
|
10
|
-
|
11
|
-
class MailFactory
|
12
|
-
attr_reader :html, :text
|
13
|
-
end
|
14
|
-
|
15
|
-
module Sinatra
|
16
|
-
# = Sinatra::Mailer
|
17
|
-
#
|
18
|
-
# Adds an #email method to your email handlers, that receives a hash of
|
19
|
-
# values to create your email.
|
20
|
-
#
|
21
|
-
# For example:
|
22
|
-
#
|
23
|
-
# post "/signup" do
|
24
|
-
# # sign up the user, and then:
|
25
|
-
# email :to => @user.email,
|
26
|
-
# :from => "awesomeness@example.com",
|
27
|
-
# :subject => "Welcome to Awesomeness!",
|
28
|
-
# :body => haml(:some_template)
|
29
|
-
# end
|
30
|
-
#
|
31
|
-
# == Configuration
|
32
|
-
#
|
33
|
-
# This plugin is very dirty yet :) Since it's just a port to Sinatra of
|
34
|
-
# Merb::Mailer[merbivore.com/documentation/1.0/doc/rdoc/merb-mailer-1.0].
|
35
|
-
# So the configuration is not Sinatra-y, yet. But we'll get to that.
|
36
|
-
#
|
37
|
-
# == Using SMTP
|
38
|
-
#
|
39
|
-
# Sinatra::Mailer.config = {
|
40
|
-
# :host => 'smtp.yourserver.com',
|
41
|
-
# :port => '25',
|
42
|
-
# :user => 'user',
|
43
|
-
# :pass => 'pass',
|
44
|
-
# :auth => :plain # :plain, :login, :cram_md5, the default is no auth
|
45
|
-
# :domain => "localhost.localdomain" # HELO domain provided by the client
|
46
|
-
# }
|
47
|
-
#
|
48
|
-
# == Using Gmail SMTP
|
49
|
-
#
|
50
|
-
# You need smtp-tls[http://github.com/ambethia/smtp-tls], a gem that improves
|
51
|
-
# Net::HTTP to add support for secure servers such as Gmail.
|
52
|
-
#
|
53
|
-
# require "smtp-tls"
|
54
|
-
#
|
55
|
-
# Sinatra::Mailer.config = {
|
56
|
-
# :host => 'smtp.gmail.com',
|
57
|
-
# :port => '587',
|
58
|
-
# :user => 'user@gmail.com',
|
59
|
-
# :pass => 'pass',
|
60
|
-
# :auth => :plain
|
61
|
-
# }
|
62
|
-
#
|
63
|
-
# Make sure that when you call your #email method you pass the
|
64
|
-
# +:text+ option and not +:body+.
|
65
|
-
#
|
66
|
-
# == Using sendmail
|
67
|
-
#
|
68
|
-
# Sinatra::Mailer.config = {:sendmail_path => '/somewhere/odd'}
|
69
|
-
# Sinatra::Mailer.delivery_method = :sendmail
|
70
|
-
#
|
71
|
-
# == Credits
|
72
|
-
#
|
73
|
-
# This has been blatantly adapted from
|
74
|
-
# Merb::Mailer[merbivore.com/documentation/1.0/doc/rdoc/merb-mailer-1.0]
|
75
|
-
# so all credit is theirs, I just ported it to Sinatra.
|
76
|
-
module Mailer
|
77
|
-
class << self
|
78
|
-
attr_accessor :config, :delivery_method
|
79
|
-
end
|
80
|
-
|
81
|
-
def email(mail_options={})
|
82
|
-
Email.new(mail_options).deliver!
|
83
|
-
end
|
84
|
-
|
85
|
-
class Email
|
86
|
-
attr_accessor :mail, :config
|
87
|
-
|
88
|
-
# Sends the mail using sendmail.
|
89
|
-
def sendmail
|
90
|
-
sendmail = IO.popen("#{config[:sendmail_path]} #{@mail.to}", 'w+')
|
91
|
-
sendmail.puts @mail.to_s
|
92
|
-
sendmail.close
|
93
|
-
end
|
94
|
-
|
95
|
-
# Sends the mail using SMTP.
|
96
|
-
def net_smtp
|
97
|
-
Net::SMTP.start(config[:host], config[:port].to_i, config[:domain],
|
98
|
-
config[:user], config[:pass], config[:auth]) { |smtp|
|
99
|
-
smtp.send_message(@mail.to_s, @mail.from.first, @mail.to.to_s.split(/[,;]/))
|
100
|
-
}
|
101
|
-
end
|
102
|
-
|
103
|
-
# Delivers the mail with the specified delivery method, defaulting to
|
104
|
-
# net_smtp.
|
105
|
-
def deliver!
|
106
|
-
send(Mailer.delivery_method || :net_smtp)
|
107
|
-
end
|
108
|
-
|
109
|
-
# ==== Parameters
|
110
|
-
# file_or_files<File, Array[File]>:: File(s) to attach.
|
111
|
-
# filename<String>::
|
112
|
-
# type<~to_s>::
|
113
|
-
# The attachment MIME type. If left out, it will be determined from
|
114
|
-
# file_or_files.
|
115
|
-
# headers<String, Array>:: Additional attachment headers.
|
116
|
-
#
|
117
|
-
# ==== Raises
|
118
|
-
# ArgumentError::
|
119
|
-
# file_or_files was not a File or an Array of File instances.
|
120
|
-
def attach(file_or_files, filename = file_or_files.is_a?(File) ? File.basename(file_or_files.path) : nil,
|
121
|
-
type = nil, headers = nil)
|
122
|
-
if file_or_files.is_a?(Array)
|
123
|
-
file_or_files.each {|k,v| @mail.add_attachment_as k, *v}
|
124
|
-
else
|
125
|
-
raise ArgumentError, "You did not pass in a file. Instead, you sent a #{file_or_files.class}" if !file_or_files.is_a?(File)
|
126
|
-
@mail.add_attachment_as(file_or_files, filename, type, headers)
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
# ==== Parameters
|
131
|
-
# o<Hash{~to_s => Object}>:: Configuration commands to send to MailFactory.
|
132
|
-
def initialize(o={})
|
133
|
-
self.config = Mailer.config || {:sendmail_path => '/usr/sbin/sendmail'}
|
134
|
-
o[:rawhtml] = o.delete(:html)
|
135
|
-
m = MailFactory.new()
|
136
|
-
o.each { |k,v| m.send "#{k}=", v }
|
137
|
-
@mail = m
|
138
|
-
end
|
139
|
-
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
class EventContext
|
144
|
-
include Mailer
|
145
|
-
end
|
146
|
-
end
|