Skip to content

Commit

Permalink
Merge pull request #1 from ignaciojonas/rubocop
Browse files Browse the repository at this point in the history
Integrate Rubocop
  • Loading branch information
ignaciojonas committed Dec 3, 2015
2 parents b154414 + 8d3de89 commit 82efe64
Show file tree
Hide file tree
Showing 56 changed files with 1,138 additions and 1,011 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
bin/
vendor/
.DS_Store
.ruby-version
coverage
*.gem
Expand Down
7 changes: 7 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
inherit_from: .rubocop_todo.yml
AllCops:
RunRailsCops: true
Exclude:
- bin/**/*
- vendor/**/*
- auth0.gemspec
7 changes: 7 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 15

# Configuration parameters: AllowURI, URISchemes.
Metrics/LineLength:
Max: 121
5 changes: 3 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
source "http://rubygems.org"
source 'http://rubygems.org'

# Specify your gem's dependencies in auth0.gemspec
gemspec

group :development do
gem 'terminal-notifier-guard', require: false
gem 'coveralls', require: false
end
gem 'rubocop', require: false
end
23 changes: 13 additions & 10 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -1,34 +1,37 @@
scope group: :unit_test

group :unit_test do
guard 'rspec', cmd: "bundle exec rspec -P \"spec/lib/auth0/**/*#{ENV['PATTERN']}*_spec.rb\" --drb --format Fuubar --color" do
guard 'rspec', cmd:
"bundle exec rspec -P \"spec/lib/auth0/**/*#{ENV['PATTERN']}*_spec.rb\"--drb --format Fuubar --color" do
# run every updated spec file
watch(%r{^spec/.+_spec\.rb$})
# run the lib specs when a file in lib/ changes
watch(%r{^lib/(.+)\.rb$}) { "spec" }
watch(%r{^lib/(.+)\.rb$}) { 'spec' }
# run all test for helper changes
watch('spec/spec_helper.rb') { "spec" }
watch('spec/spec_helper.rb') { 'spec' }
end
end

group :integration do
guard 'rspec', cmd: "MODE=full bundle exec rspec -P \"spec/integration/**/*#{ENV['PATTERN']}*_spec.rb\" --drb --format Fuubar --color" do
guard 'rspec', cmd:
"MODE=full bundle exec rspec -P \"spec/integration/**/*#{ENV['PATTERN']}*_spec.rb\" --drb --format Fuubar --color" do
# run every updated spec file
watch(%r{^spec/.+_spec\.rb$})
# run the lib specs when a file in lib/ changes
watch(%r{^lib/(.+)\.rb$}) { "spec" }
watch(%r{^lib/(.+)\.rb$}) { 'spec' }
# run all test for helper changes
watch('spec/spec_helper.rb') { "spec" }
watch('spec/spec_helper.rb') { 'spec' }
end
end

group :full do
guard 'rspec', cmd: "MODE=full bundle exec rspec --drb --format Fuubar --color" do
guard 'rspec', cmd:
'MODE=full bundle exec rspec --drb --format Fuubar --color' do
# run every updated spec file
watch(%r{^spec/.+_spec\.rb$})
# run the lib specs when a file in lib/ changes
watch(%r{^lib/(.+)\.rb$}) { "spec" }
watch(%r{^lib/(.+)\.rb$}) { 'spec' }
# run all test for helper changes
watch('spec/spec_helper.rb') { "spec" }
watch('spec/spec_helper.rb') { 'spec' }
end
end
end
16 changes: 9 additions & 7 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
#!/usr/bin/env rake
require "bundler/gem_tasks"
require 'bundler/gem_tasks'

begin
require 'rubocop/rake_task'
RuboCop::RakeTask.new

require 'rspec/core/rake_task'

desc "Run Integration Tests"
desc 'Run Integration Tests'
RSpec::Core::RakeTask.new(:integration) do |t|
t.pattern = FileList["spec/integration/**/*#{ENV['PATTERN']}*_spec.rb"]
end


desc "Run Unit Tests"
desc 'Run Unit Tests'
RSpec::Core::RakeTask.new(:spec) do |t|
t.pattern = FileList["spec/lib/auth0/**/*#{ENV['PATTERN']}*_spec.rb"]
end

desc "Run All Suites"
desc 'Run All Suites'
RSpec::Core::RakeTask.new(:all)

task :default => :spec
task default: [:rubocop, :spec]
rescue LoadError
#No RSpec
puts 'Load Error - No RSpec'
end
22 changes: 11 additions & 11 deletions auth0.gemspec
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "auth0/version"
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
require 'auth0/version'

Gem::Specification.new do |s|
s.name = "auth0"
s.name = 'auth0'
s.version = Auth0::VERSION
s.authors = ["Auth0", "Jose Romaniello", "Ivan Petroe", "Patrik Ragnarsson"]
s.email = ["[email protected]"]
s.homepage = "https://github.com/auth0/ruby-auth0"
s.summary = %q{Auth0 API Client}
s.description = %q{Ruby client library for the Auth0 API.}
s.authors = ['Auth0', 'Jose Romaniello', 'Ivan Petroe', 'Patrik Ragnarsson']
s.email = ['[email protected]']
s.homepage = 'https://github.com/auth0/ruby-auth0'
s.summary = 'Auth0 API Client'
s.description = 'Ruby client library for the Auth0 API.'

s.rubyforge_project = "auth0"
s.rubyforge_project = 'auth0'

s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
s.require_paths = ['lib']

s.add_runtime_dependency 'httparty', '~> 0.13'

Expand Down
10 changes: 5 additions & 5 deletions lib/auth0.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require "auth0/version"
require "auth0/mixins"
require "auth0/exception"
require "auth0/client"
require "auth0_client"
require 'auth0/version'
require 'auth0/mixins'
require 'auth0/exception'
require 'auth0/client'
require 'auth0_client'
# Namespace for ruby-auth0 logic
module Auth0
end
39 changes: 21 additions & 18 deletions lib/auth0/api/authentication_endpoints.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,86 +3,89 @@ module Api
# {https://auth0.com/docs/auth-api}
# Describing functionality of auth0 authentication endpoints
module AuthenticationEndpoints
UP_AUTH = 'Username-Password-Authentication'

# {https://auth0.com/docs/auth-api#!#post--oauth-access_token}
def obtain_access_token
request_params = {
client_id: @client_id,
client_secret: @client_secret,
grant_type: 'client_credentials'
}
post("/oauth/token", request_params)["access_token"]
post('/oauth/token', request_params)['access_token']
end

# {https://auth0.com/docs/auth-api#!#post--delegation}
def delegation(id_token, target, scope = "openid", api_type = "app", extra_parameters = {})
def delegation(id_token, target, scope = 'openid', api_type = 'app', extra_parameters = {})
request_params = {
client_id: @client_id,
grant_type: "urn:ietf:params:oauth:grant-type:jwt-bearer",
grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer',
id_token: id_token,
target: target,
api_type: api_type,
scope: scope
}.merge(extra_parameters)
post("/delegation", request_params)
post('/delegation', request_params)
end

# {https://auth0.com/docs/auth-api#!#post--users--user_id--impersonate}
def impersonate(user_id, app_client_id, impersonator_id, options)
request_params = {
protocol: options.fetch(:protocol, "oauth2"),
protocol: options.fetch(:protocol, 'oauth2'),
impersonator_id: impersonator_id,
client_id: app_client_id,
ttl: options.fetch(:ttl, 120),
additionalParameters: {
response_type: options.fetch(:response_type, "code"),
state: options.fetch(:state, ""),
scope: options.fetch(:scope, "openid"),
callback_url: options.fetch(:callback_url, ""),
response_type: options.fetch(:response_type, 'code'),
state: options.fetch(:state, ''),
scope: options.fetch(:scope, 'openid'),
callback_url: options.fetch(:callback_url, '')
}
}
post("/users/#{user_id}/impersonate", request_params)
end

# {https://auth0.com/docs/auth-api#!#post--oauth-ro}
def login(username, password, scope = "openid", id_token=nil, connection_name="Username-Password-Authentication")

def login(username, password, scope = 'openid', id_token = nil, connection_name = UP_AUTH)
request_params = {
client_id: @client_id,
username: username,
password: password,
scope: scope,
connection: connection_name,
grant_type: "password",
grant_type: 'password',
id_token: id_token
}
post("/oauth/ro", request_params)
post('/oauth/ro', request_params)
end

# {https://auth0.com/docs/auth-api#!#post--dbconnections-signup}
def signup(email, password, connection_name= "Username-Password-Authentication")
def signup(email, password, connection_name = UP_AUTH)
request_params = {
client_id: @client_id,
email: email,
connection: connection_name,
password: password
}
post("/dbconnections/signup", request_params)
post('/dbconnections/signup', request_params)
end

# {https://auth0.com/docs/auth-api#!#post--dbconnections-change_password}
def change_password(email, password, connection_name = "Username-Password-Authentication")
def change_password(email, password, connection_name = UP_AUTH)
request_params = {
client_id: @client_id,
email: email,
connection: connection_name,
password: password
}
post("/dbconnections/change_password", request_params)
post('/dbconnections/change_password', request_params)
end

# {https://auth0.com/docs/auth-api#!#post--tokeninfo}
def token_info(id_token)
request_params = { id_token: id_token}
post("/tokeninfo", request_params)
request_params = { id_token: id_token }
post('/tokeninfo', request_params)
end
end
end
Expand Down
10 changes: 5 additions & 5 deletions lib/auth0/api/v1.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require "auth0/api/v1/users"
require "auth0/api/v1/clients"
require "auth0/api/v1/connections"
require "auth0/api/v1/rules"
require "auth0/api/v1/logs"
require 'auth0/api/v1/users'
require 'auth0/api/v1/clients'
require 'auth0/api/v1/connections'
require 'auth0/api/v1/rules'
require 'auth0/api/v1/logs'
module Auth0
# Space for all API calls
module Api
Expand Down
14 changes: 7 additions & 7 deletions lib/auth0/api/v1/clients.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ module V1
module Clients
# {https://auth0.com/docs/api#!#get--api-clients}
def clients
path = "/api/clients"
path = '/api/clients'
get(path)
end

alias :get_clients :clients
alias_method :get_clients, :clients

# {https://auth0.com/docs/api#!#post--api-clients}
def create_client(name, callbacks="")
path = "/api/clients"
def create_client(name, callbacks = '')
path = '/api/clients'
request_params = {
name: name,
callbacks: callbacks
Expand All @@ -23,8 +23,8 @@ def create_client(name, callbacks="")

# @deprecated use {#patch_client}
# {https://auth0.com/docs/api#!#put--api-clients--client-id-}
def update_client(name, callbacks="", client_id=@client_id)
warn "This endpoint has been deprecated in favor of PATCH."
def update_client(name, callbacks = '', client_id = @client_id)
warn 'This endpoint has been deprecated in favor of PATCH.'
path = "/api/clients/#{client_id}"
request_params = {
name: name,
Expand All @@ -34,7 +34,7 @@ def update_client(name, callbacks="", client_id=@client_id)
end

# {https://auth0.com/docs/api#!#patch--api-clients--client-id-}
def patch_client(name, callbacks="", client_id=@client_id)
def patch_client(name, callbacks = '', client_id = @client_id)
path = "/api/clients/#{client_id}"
request_params = {
name: name,
Expand Down
19 changes: 9 additions & 10 deletions lib/auth0/api/v1/connections.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,38 @@ module V1
module Connections
# {https://auth0.com/docs/api#!#get--api-connections}
def connections
get("/api/connections")
get('/api/connections')
end
alias :get_connections :connections
alias_method :get_connections, :connections

# {https://auth0.com/docs/api#!#get--api-connections--connection-name-}
def connection(connection_name)
path = "/api/connections/#{connection_name.to_s}"
path = "/api/connections/#{connection_name}"
get(path)
end
alias :get_connection :connection
alias_method :get_connection, :connection

# {https://auth0.com/docs/api#!#delete--api-connections--connection-name-}
def delete_connection(connection_name)
path = "/api/connections/#{connection_name.to_s}"
path = "/api/connections/#{connection_name}"
delete(path)
end

# {https://auth0.com/docs/api#!#post--api-connections}
def create_connection(connection_name, strategy, tenant_domain, domain_aliases=nil)
path = "/api/connections"
def create_connection(connection_name, strategy, tenant_domain, domain_aliases = nil)
path = '/api/connections'
request_params = {
name: connection_name,
strategy: strategy,
options: {
tenant_domain: tenant_domain,
domain_aliases: domain_aliases
}
domain_aliases: domain_aliases }
}
post(path, request_params)
end

# {https://auth0.com/docs/api#!#put--api-connections--connection-name-}
def update_connection(connection_name, tenant_domain, status=true)
def update_connection(connection_name, tenant_domain, status = true)
path = "/api/connections/#{connection_name}"
request_params = {
status: status,
Expand Down
Loading

0 comments on commit 82efe64

Please sign in to comment.