-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add reason for manual cancel in build cancellation * Add login of user who cancelled the build * Use user instead of current user * Use RSS token for builds atom feed re #BSFY-206 * Change reason for cancellation * Revert "Add reason for manual cancel in build cancellation" * New payment details implementation * Antifraud for v1 plans * Add spec * Fix spec * Take recaptcha secret from env * storage,collaborator cleanup , specs * redirection for app updates * using vcs_redirect only if there's no state param * force redirection to github-apps endpoint on install * corrected storage key name * storage fix * storage param name fix * auth with installation updates * dbg * Dt fingerprint fix (#1289) * fingerprint fix * spec
- Loading branch information
Showing
28 changed files
with
802 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
require 'redis' | ||
|
||
module Travis::API::V3 | ||
class Models::Storage | ||
|
||
attr_reader :id, :value | ||
|
||
def initialize(attrs) | ||
puts "ATTRS: #{attrs.inspect}" | ||
@id = attrs.fetch(:id) | ||
@value = attrs[:value] | ||
end | ||
|
||
def public? | ||
true | ||
end | ||
|
||
def get | ||
puts "ID: #{id.inspect}, VAL: #{value.inspect}" | ||
@value = Travis.redis.get(id) || 0 | ||
|
||
|
||
puts "ID: #{id.inspect}, VAL: #{value.inspect}" | ||
self | ||
end | ||
|
||
def create | ||
Travis.redis.set(id, value) | ||
self | ||
end | ||
|
||
def delete | ||
Travis.redis.del(id) | ||
@value = 0 | ||
self | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
module Travis::API::V3 | ||
class Queries::Storage < Query | ||
params :user, :id,:value, prefix: :storage | ||
|
||
PERMITTED_OPTIONS = [:billing_wizard_state] | ||
|
||
def find | ||
Models::Storage.new(id: option_id).get if valid? | ||
end | ||
|
||
def update | ||
Models::Storage.new(id: option_id, value: value).create if valid? | ||
end | ||
|
||
def delete | ||
Models::Storage.new(id: option_id).delete if valid? | ||
end | ||
|
||
private | ||
def option_id | ||
"#{user}::storage::#{id}" | ||
end | ||
|
||
def valid? | ||
PERMITTED_OPTIONS.include? id.to_sym | ||
end | ||
|
||
|
||
def user | ||
params['user.id'] | ||
end | ||
|
||
def id | ||
params['id'] | ||
end | ||
|
||
def value | ||
params['value'] | ||
end | ||
|
||
def redis | ||
Travis.redis | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
module Travis::API::V3 | ||
class RecaptchaClient | ||
class ConfigurationError < StandardError; end | ||
|
||
def verify(token) | ||
response = connection.post('/recaptcha/api/siteverify') do |req| | ||
req.headers['Content-Type'] = 'application/x-www-form-urlencoded' | ||
req.body = URI.encode_www_form({ secret: recaptcha_secret, response: token }) | ||
end | ||
handle_errors_and_respond(response) { |r| r['success'] } | ||
end | ||
|
||
private | ||
|
||
def handle_errors_and_respond(response) | ||
case response.status | ||
when 200, 201 | ||
yield(JSON.parse(response.body)) if block_given? | ||
when 204 | ||
true | ||
else | ||
raise Travis::API::V3::ServerError, 'ReCaptcha system error' | ||
end | ||
end | ||
|
||
def connection | ||
@connection ||= Faraday.new(url: recaptcha_url, ssl: { ca_path: '/usr/lib/ssl/certs' }) do |conn| | ||
conn.use OpenCensus::Trace::Integrations::FaradayMiddleware if Travis::Api::App::Middleware::OpenCensus.enabled? | ||
conn.adapter Faraday.default_adapter | ||
end | ||
end | ||
|
||
def recaptcha_url | ||
Travis.config.recaptcha.endpoint || raise(ConfigurationError, 'No recaptcha url configured') | ||
end | ||
|
||
def recaptcha_secret | ||
Travis.config.recaptcha.secret || raise(ConfigurationError, 'No recaptcha secret configured') | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
module Travis::API::V3 | ||
class Renderer::Allowance < ModelRenderer | ||
representation(:minimal, :id) | ||
representation(:standard, :subscription_type, :public_repos, :private_repos, :concurrency_limit, :user_usage, :pending_user_licenses, :id) | ||
representation(:standard, :subscription_type, :public_repos, :private_repos, :concurrency_limit, :user_usage, :pending_user_licenses, | ||
:payment_changes_block_credit, :payment_changes_block_captcha, :credit_card_block_duration, :captcha_block_duration, :id) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module Travis::API::V3 | ||
class Renderer::Storage < ModelRenderer | ||
representation(:standard,:id, :value) | ||
|
||
def id | ||
model.id.split('::')&.last || id | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.