source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | ahx/openapi_first | https://github.com/ahx/openapi_first | spec/test/coverage_spec.rb | Ruby | mit | 215 | main | 2,922 | # frozen_string_literal: true
RSpec.describe OpenapiFirst::Test::Coverage do
let(:definition) do
OpenapiFirst.parse(YAML.load(%(
openapi: 3.1.0
info:
title: Dice
version: 1
paths:
"/roll":
post:
responses:
'200':
conten... |
github | ahx/openapi_first | https://github.com/ahx/openapi_first | spec/test/methods_spec.rb | Ruby | mit | 215 | main | 7,833 | # frozen_string_literal: true
require 'minitest'
RSpec.describe OpenapiFirst::Test::Methods do
it 'includes PlainHelpers when included' do
test_class = Class.new do
include OpenapiFirst::Test::Methods
end
expect(test_class.included_modules).to include(OpenapiFirst::Test::PlainHelpers)
end
it ... |
github | ahx/openapi_first | https://github.com/ahx/openapi_first | spec/middlewares/request_validation_spec.rb | Ruby | mit | 215 | main | 7,529 | # frozen_string_literal: true
require_relative '../spec_helper'
require 'rack'
require 'rack/test'
require 'openapi_first'
RSpec.describe OpenapiFirst::Middlewares::RequestValidation do
include Rack::Test::Methods
let(:app) do
OpenapiFirst.configure do |config|
config.register File.expand_path('../data... |
github | ahx/openapi_first | https://github.com/ahx/openapi_first | spec/middlewares/response_validation_spec.rb | Ruby | mit | 215 | main | 12,145 | # frozen_string_literal: true
require 'rack'
require 'rack/test'
require 'openapi_first'
RSpec.describe OpenapiFirst::Middlewares::ResponseValidation do
include Rack::Test::Methods
let(:app) do
res = response
OpenapiFirst.configure do |config|
config.register spec
end
Rack::Builder.app do
... |
github | ahx/openapi_first | https://github.com/ahx/openapi_first | spec/middlewares/response_validation/response_header_validation_spec.rb | Ruby | mit | 215 | main | 1,941 | # frozen_string_literal: true
require 'rack'
require 'rack/test'
require 'openapi_first'
RSpec.describe 'Response Header validation' do
include Rack::Test::Methods
let(:app) do
Rack::Builder.app do
use OpenapiFirst::Middlewares::ResponseValidation, spec: './spec/data/response-header.yaml'
run(lam... |
github | ahx/openapi_first | https://github.com/ahx/openapi_first | spec/middlewares/request_validation/cookie_parameter_validation_spec.rb | Ruby | mit | 215 | main | 1,694 | # frozen_string_literal: true
require 'rack'
require 'rack/test'
require 'openapi_first'
RSpec.describe 'Cookie Parameter validation' do
include Rack::Test::Methods
let(:app) do
Rack::Builder.app do
use OpenapiFirst::Middlewares::RequestValidation,
spec: File.expand_path('spec/data/cookie-par... |
github | ahx/openapi_first | https://github.com/ahx/openapi_first | spec/middlewares/request_validation/path_parameter_validation_spec.rb | Ruby | mit | 215 | main | 2,032 | # frozen_string_literal: true
require 'rack'
require 'rack/test'
require 'openapi_first'
RSpec.describe 'Path Parameter validation' do
include Rack::Test::Methods
let(:raise_error_option) { false }
let(:app) do
raise_error = raise_error_option
Rack::Builder.app do
use OpenapiFirst::Middlewares::... |
github | ahx/openapi_first | https://github.com/ahx/openapi_first | spec/middlewares/request_validation/request_body_validation_spec.rb | Ruby | mit | 215 | main | 15,322 | # frozen_string_literal: true
require 'rack'
require 'rack/test'
require 'openapi_first'
RSpec.describe 'Request body validation' do
let(:path) do
'/pets'
end
def fixture_path(name)
Pathname.new(Dir.pwd).join('spec', 'data', name).realpath
end
describe '#call' do
include Rack::Test::Methods
... |
github | ahx/openapi_first | https://github.com/ahx/openapi_first | spec/middlewares/request_validation/header_parameter_validation_spec.rb | Ruby | mit | 215 | main | 1,864 | # frozen_string_literal: true
require 'rack'
require 'rack/test'
require 'openapi_first'
RSpec.describe 'Header Parameter validation' do
include Rack::Test::Methods
let(:app) do
Rack::Builder.app do
use OpenapiFirst::Middlewares::RequestValidation,
spec: File.expand_path('spec/data/header-par... |
github | ahx/openapi_first | https://github.com/ahx/openapi_first | spec/middlewares/request_validation/query_parameter_validation_spec.rb | Ruby | mit | 215 | main | 11,171 | # frozen_string_literal: true
require 'rack'
require 'rack/test'
require 'openapi_first'
RSpec.describe 'Query Parameter validation' do
include Rack::Test::Methods
let(:spec) { OpenapiFirst.load('spec/data/query-parameter-validation.yaml') }
let(:raise_error_option) { false }
let(:app) do
oas = spec
... |
github | ahx/openapi_first | https://github.com/ahx/openapi_first | spec/router/path_template_spec.rb | Ruby | mit | 215 | main | 2,198 | # frozen_string_literal: true
RSpec.describe OpenapiFirst::Router::PathTemplate do
describe '.template?' do
specify do
expect(described_class.template?('/totally/static')).to be(false)
expect(described_class.template?('/some/{thing}')).to be(true)
end
end
describe '#to_s' do
specify do
... |
github | ahx/openapi_first | https://github.com/ahx/openapi_first | spec/router/find_content_spec.rb | Ruby | mit | 215 | main | 1,918 | # frozen_string_literal: true
RSpec.describe OpenapiFirst::Router::FindContent do
describe '#[]' do
let(:requests) do
[
double(content_type: 'application/json'),
double(content_type: 'application/xml'),
double(content_type: 'application/json; profile=custom'),
double(content... |
github | ahx/openapi_first | https://github.com/ahx/openapi_first | spec/router/find_response_spec.rb | Ruby | mit | 215 | main | 3,753 | # frozen_string_literal: true
RSpec.describe OpenapiFirst::Router::FindResponse do
describe '.find' do
def find(responses, status, content_type)
groups = responses.each_with_object({}) do |response, hash|
(hash[response.status] ||= {})[response.content_type] = response
end
described_cla... |
github | ahx/openapi_first | https://github.com/ahx/openapi_first | spec/schema/hash_spec.rb | Ruby | mit | 215 | main | 867 | # frozen_string_literal: true
RSpec.describe OpenapiFirst::Schema::Hash do
it 'validates all schemas' do
a_schema = JSONSchemer.schema({ 'type' => 'integer' })
b_schema = JSONSchemer.schema({ 'type' => 'string' })
schema_hash = described_class.new({ 'a' => a_schema, 'b' => b_schema })
errors = schem... |
github | ahx/openapi_first | https://github.com/ahx/openapi_first | spec/error_responses/default_spec.rb | Ruby | mit | 215 | main | 7,878 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe OpenapiFirst::ErrorResponses::Default do
let(:env) { {} }
let(:validation_result) do
validation = JSONSchemer.schema(schema).validate(data)
OpenapiFirst::Schema::ValidationResult.new(validation)
end
it 'returns application/problem+jso... |
github | ahx/openapi_first | https://github.com/ahx/openapi_first | spec/error_responses/jsonapi_spec.rb | Ruby | mit | 215 | main | 7,853 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe OpenapiFirst::ErrorResponses::Jsonapi do
let(:env) { {} }
let(:validation_result) do
validation = JSONSchemer.schema(schema).validate(data)
OpenapiFirst::Schema::ValidationResult.new(validation)
end
it 'returns application/problem+jso... |
github | ahx/openapi_first | https://github.com/ahx/openapi_first | examples/rack_handler.rb | Ruby | mit | 215 | main | 716 | # frozen_string_literal: true
require 'rack'
# This example is a bit contrived, but it shows what you could do with the middlewares
App = Rack::Builder.new do
spec = OpenapiFirst.load(File.expand_path('./openapi.yaml', __dir__))
use(OpenapiFirst::Middlewares::RequestValidation, spec:)
not_found = ->(_request)... |
github | ahx/openapi_first | https://github.com/ahx/openapi_first | examples/rails_app/Gemfile | Ruby | mit | 215 | main | 1,355 | source 'https://rubygems.org'
ruby '3.3.0'
# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem 'rails', '~> 7.2.0'
# Use the Puma web server [https://github.com/puma/puma]
gem 'puma', '>= 5.0'
# Build JSON APIs with ease [https://github.com/rails/jbuilder]
# gem "jbuilder"
# Use Red... |
github | ahx/openapi_first | https://github.com/ahx/openapi_first | examples/rails_app/app/controllers/stations_controller.rb | Ruby | mit | 215 | main | 239 | class StationsController < ApplicationController
def index
render json: {
data: [{ id: 'efdbb9d1-02c2-4bc3-afb7-6788d8782b1e', name: 'Leipzig', address: 'Bahnhofstraße 12',
country_code: 'DE' }]
}
end
end |
github | ahx/openapi_first | https://github.com/ahx/openapi_first | examples/rails_app/engines/weather/Gemfile | Ruby | mit | 215 | main | 352 | source "https://rubygems.org"
# Specify your gem's dependencies in weather.gemspec.
gemspec
gem "puma"
gem "sqlite3"
gem "sprockets-rails"
# Omakase Ruby styling [https://github.com/rails/rubocop-rails-omakase/]
gem "rubocop-rails-omakase", require: false
# Start debugger with binding.b [https://github.com/ruby/d... |
github | ahx/openapi_first | https://github.com/ahx/openapi_first | examples/rails_app/engines/weather/weather.gemspec | Ruby | mit | 215 | main | 928 | require_relative "lib/weather/version"
Gem::Specification.new do |spec|
spec.name = "weather"
spec.version = Weather::VERSION
spec.authors = [ "Joshua Studt" ]
spec.email = [ "fake.email@example.com" ]
spec.homepage = "http://mygemserver.com"
spec.summary = "Summary of Weather."... |
github | ahx/openapi_first | https://github.com/ahx/openapi_first | examples/rails_app/engines/weather/test/dummy/config/environments/test.rb | Ruby | mit | 215 | main | 2,923 | require "active_support/core_ext/integer/time"
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data the... |
github | ahx/openapi_first | https://github.com/ahx/openapi_first | examples/rails_app/engines/weather/test/dummy/config/environments/production.rb | Ruby | mit | 215 | main | 4,655 | require "active_support/core_ext/integer/time"
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.enable_reloading = false
# Eager load code on boot. This eager loads most of Rails and
# your app... |
github | ahx/openapi_first | https://github.com/ahx/openapi_first | examples/rails_app/engines/weather/test/dummy/config/environments/development.rb | Ruby | mit | 215 | main | 2,840 | require "active_support/core_ext/integer/time"
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded any time
# it changes. This slows down response time but is perfect for developme... |
github | ahx/openapi_first | https://github.com/ahx/openapi_first | examples/rails_app/engines/weather/test/controllers/temperature_controller_test.rb | Ruby | mit | 215 | main | 756 | # frozen_string_literal: true
require "test_helper"
class Weather::TemperatureControllerTest < ActionDispatch::IntegrationTest
# def openapi_first_default_api = :weather
include OpenapiFirst::Test::Methods[TrainTravel::Application, api: :weather]
test "it returns temperature data for given latitude and longitu... |
github | ahx/openapi_first | https://github.com/ahx/openapi_first | examples/rails_app/engines/weather/app/controllers/weather/temperature_controller.rb | Ruby | mit | 215 | main | 362 | module Weather
class TemperatureController < ApplicationController
def index
render status: :ok, json: {
latitude:, longitude:, temperature: {
celsius: "11.94",
fahrenheit: "53.5"
}
}
end
private
def latitude = params.require(:latitude)
def longitu... |
github | ahx/openapi_first | https://github.com/ahx/openapi_first | examples/rails_app/test/test_helper.rb | Ruby | mit | 215 | main | 757 | ENV['RAILS_ENV'] ||= 'test'
require_relative '../config/environment'
require 'openapi_first'
OpenapiFirst::Test.setup do |test|
test.register Rails.root.join('../../spec/data/train-travel-api/openapi.yaml')
test.register Rails.root.join('../../spec/data/attachments_openapi.yaml'), as: :attachments
test.register... |
github | ahx/openapi_first | https://github.com/ahx/openapi_first | examples/rails_app/test/integration/attachments_api_test.rb | Ruby | mit | 215 | main | 378 | # frozen_string_literal: true
require 'test_helper'
class AttachmentsApiTest < ActionDispatch::IntegrationTest
# def openapi_first_default_api = :attachments
include OpenapiFirst::Test::Methods[TrainTravel::Application, api: :attachments]
test 'GET /attachments/{attachment_id}' do
get '/attachments/42abc',... |
github | ahx/openapi_first | https://github.com/ahx/openapi_first | examples/rails_app/test/integration/trips_api_test.rb | Ruby | mit | 215 | main | 332 | require 'test_helper'
class TripsApiTest < ActionDispatch::IntegrationTest
test 'GET /trips' do
get '/trips',
params: { origin: 'efdbb9d1-02c2-4bc3-afb7-6788d8782b1e', destination: 'b2e783e1-c824-4d63-b37a-d8d698862f1d',
date: '2024-07-02T09:00:00Z' }
assert_api_conform(status: 200... |
github | ahx/openapi_first | https://github.com/ahx/openapi_first | examples/rails_app/test/integration/stations_api_test.rb | Ruby | mit | 215 | main | 203 | # frozen_string_literal: true
require 'test_helper'
class StationsApiTest < ActionDispatch::IntegrationTest
test 'GET /stations' do
get '/stations'
assert_api_conform(status: 200)
end
end |
github | ahx/openapi_first | https://github.com/ahx/openapi_first | examples/rails_app/config/application.rb | Ruby | mit | 215 | main | 1,622 | require_relative "boot"
require "rails"
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
# require "active_record/railtie"
# require "active_storage/engine"
require "action_controller/railtie"
require "action_mailer/railtie"
# require "action_mailbox/engine"
# require "action... |
github | ahx/openapi_first | https://github.com/ahx/openapi_first | examples/rails_app/config/routes.rb | Ruby | mit | 215 | main | 620 | Rails.application.routes.draw do
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
# Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500.
# Can be used by load balancers and uptime monitors to verify that the app is live.
get... |
github | ahx/openapi_first | https://github.com/ahx/openapi_first | examples/rails_app/config/environments/test.rb | Ruby | mit | 215 | main | 2,806 | require "active_support/core_ext/integer/time"
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data the... |
github | ahx/openapi_first | https://github.com/ahx/openapi_first | examples/rails_app/config/environments/production.rb | Ruby | mit | 215 | main | 4,088 | require "active_support/core_ext/integer/time"
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.enable_reloading = false
# Eager load code on boot. This eager loads most of Rails and
# your app... |
github | ahx/openapi_first | https://github.com/ahx/openapi_first | examples/rails_app/config/environments/development.rb | Ruby | mit | 215 | main | 2,286 | require "active_support/core_ext/integer/time"
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded any time
# it changes. This slows down response time but is perfect for developme... |
github | ahx/openapi_first | https://github.com/ahx/openapi_first | examples/rails_app/config/initializers/cors.rb | Ruby | mit | 215 | main | 504 | # Be sure to restart your server when you modify this file.
# Avoid CORS issues when API is called from the frontend app.
# Handle Cross-Origin Resource Sharing (CORS) in order to accept cross-origin Ajax requests.
# Read more: https://github.com/cyu/rack-cors
# Rails.application.config.middleware.insert_before 0, R... |
github | ahx/openapi_first | https://github.com/ahx/openapi_first | benchmarks/profile.rb | Ruby | mit | 215 | main | 439 | # frozen_string_literal: true
require 'vernier'
require 'rack'
require 'openapi_first'
definition = OpenapiFirst.load('./apps/openapi.yaml')
env = Rack::MockRequest.env_for('/hello?filter[id]=1,2')
definition.validate_request(Rack::Request.new(env), raise_error: true)
Vernier.trace(out: 'profiles/request_validation_... |
github | ahx/openapi_first | https://github.com/ahx/openapi_first | benchmarks/Gemfile | Ruby | mit | 215 | main | 255 | # frozen_string_literal: true
source 'https://rubygems.org'
gem 'benchmark'
gem 'benchmark-ips'
gem 'benchmark-memory'
gem 'committee'
gem 'openapi_first', path: '../'
gem 'openapi_parameters'
gem 'profile-viewer'
gem 'puma'
gem 'sinatra'
gem 'vernier' |
github | ahx/openapi_first | https://github.com/ahx/openapi_first | benchmarks/large.rb | Ruby | mit | 215 | main | 294 | # frozen_string_literal: true
require 'benchmark/memory'
require 'openapi_first'
Benchmark.memory do |x|
x.report do
oad = OpenapiFirst.load('../spec/data/large.yaml')
request = Rack::Request.new(Rack::MockRequest.env_for('/workspaces'))
oad.validate_request(request)
end
end |
github | ahx/openapi_first | https://github.com/ahx/openapi_first | benchmarks/benchmarks.rb | Ruby | mit | 215 | main | 1,350 | # frozen_string_literal: true
require 'benchmark'
require 'benchmark/ips'
require 'benchmark/memory'
require 'rack'
require 'json'
ENV['RACK_ENV'] = 'production'
examples = [
[Rack::MockRequest.env_for('/hello'), 200],
[Rack::MockRequest.env_for('/unknown'), 404],
[
Rack::MockRequest.env_for('/hello', metho... |
github | ahx/openapi_first | https://github.com/ahx/openapi_first | benchmarks/apps/committee_with_response_validation.ru | Ruby | mit | 215 | main | 457 | # frozen_string_literal: true
require 'json'
require 'committee'
require_relative 'app'
use Committee::Middleware::RequestValidation,
schema_path: File.absolute_path('./openapi.yaml', __dir__),
parse_response_by_content_type: true,
strict_reference_validation: true
use Committee::Middleware::ResponseVali... |
github | ahx/openapi_first | https://github.com/ahx/openapi_first | benchmarks/apps/app.rb | Ruby | mit | 215 | main | 413 | # frozen_string_literal: true
require 'sinatra/base'
class App < Sinatra::Base
set :environment, :production
get '/hello/:id' do
content_type :json
JSON.generate(hello: 'world', id: params.fetch('id'))
end
get '/hello' do
content_type :json
JSON.generate([{ hello: 'world' }])
end
post '... |
github | ahx/openapi_first | https://github.com/ahx/openapi_first | benchmarks/apps/committee.ru | Ruby | mit | 215 | main | 289 | # frozen_string_literal: true
require 'json'
require 'committee'
require_relative 'app'
use Committee::Middleware::RequestValidation,
schema_path: File.absolute_path('./openapi.yaml', __dir__),
parse_response_by_content_type: true,
strict_reference_validation: true
run App |
github | ahx/openapi_first | https://github.com/ahx/openapi_first | benchmarks/apps/openapi_first.ru | Ruby | mit | 215 | main | 220 | # frozen_string_literal: true
require 'json'
require 'openapi_first'
require_relative 'app'
OpenapiFirst.register File.absolute_path('./openapi.yaml', __dir__)
use OpenapiFirst::Middlewares::RequestValidation
run App |
github | ahx/openapi_first | https://github.com/ahx/openapi_first | benchmarks/apps/openapi_first_with_response_validation.ru | Ruby | mit | 215 | main | 290 | # frozen_string_literal: true
require 'json'
require 'openapi_first'
require_relative 'app'
OpenapiFirst.register File.absolute_path('./openapi.yaml', __dir__), as: :v1
use OpenapiFirst::Middlewares::RequestValidation, :v1
use OpenapiFirst::Middlewares::ResponseValidation, :v1
run App |
github | AsteriskLabs/devise_google_authenticator | https://github.com/AsteriskLabs/devise_google_authenticator | Gemfile | Ruby | mit | 215 | master | 392 | source 'https://rubygems.org'
gemspec
group :test do
gem 'activerecord', '~> 3.0'
gem "sqlite3", "~> 1.3.5"
gem "bson_ext", "~> 1.3"
gem "capybara", "~> 1.1.0"
gem 'shoulda', '~> 2.11.3'
gem 'mocha', '~> 0.13.0'
gem 'factory_girl_rails', '~> 1.2'
gem 'nokogiri', '< 1.6.0', :platforms => :ruby_18
gem... |
github | AsteriskLabs/devise_google_authenticator | https://github.com/AsteriskLabs/devise_google_authenticator | devise_google_authenticator.gemspec | Ruby | mit | 215 | master | 1,111 | $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
Gem::Specification.new do |s|
s.name = "devise_google_authenticator"
s.version = "0.3.16"
s.authors = ["Christian Frichot"]
s.date = "2015-02-08"
s.description = "Devise Google Authenticator Extension, for adding Google's OTP to your Rails apps!"
s.em... |
github | AsteriskLabs/devise_google_authenticator | https://github.com/AsteriskLabs/devise_google_authenticator | Rakefile | Ruby | mit | 215 | master | 516 | require 'rake'
require 'bundler'
Bundler::GemHelper.install_tasks
require 'rake/testtask'
Rake::TestTask.new(:test) do |test|
test.libs << 'lib' << 'test'
test.pattern = 'test/**/*_test.rb'
test.verbose = true
end
desc 'Default: run tests for all ORMs.'
task :default => :tests
desc 'Run Devise tests for all OR... |
github | AsteriskLabs/devise_google_authenticator | https://github.com/AsteriskLabs/devise_google_authenticator | lib/devise_google_authenticator.rb | Ruby | mit | 215 | master | 1,247 | require 'active_record/connection_adapters/abstract/schema_definitions'
require 'active_support/core_ext/integer'
require 'active_support/core_ext/string'
require 'active_support/ordered_hash'
require 'active_support/concern'
require 'devise'
module Devise # :nodoc:
mattr_accessor :ga_timeout
@@ga_timeout = 3.minute... |
github | AsteriskLabs/devise_google_authenticator | https://github.com/AsteriskLabs/devise_google_authenticator | lib/devise_google_authenticatable/patches.rb | Ruby | mit | 215 | master | 404 | module DeviseGoogleAuthenticator
module Patches
autoload :DisplayQR, 'devise_google_authenticatable/patches/display_qr'
autoload :CheckGA, 'devise_google_authenticatable/patches/check_ga'
class << self
def apply
Devise::RegistrationsController.send(:include, Patches::DisplayQR)
Devi... |
github | AsteriskLabs/devise_google_authenticator | https://github.com/AsteriskLabs/devise_google_authenticator | lib/devise_google_authenticatable/routes.rb | Ruby | mit | 215 | master | 542 | module ActionDispatch::Routing # :nodoc:
class Mapper # :nodoc:
protected
# route for handle expired passwords
def devise_displayqr(mapping, controllers)
resource :displayqr, :only => [:show, :update], :path => mapping.path_names[:displayqr], :controller => controllers[:displayqr] do
post :... |
github | AsteriskLabs/devise_google_authenticator | https://github.com/AsteriskLabs/devise_google_authenticator | lib/devise_google_authenticatable/schema.rb | Ruby | mit | 215 | master | 896 | module DeviseGoogleAuthenticator
# add schema helper for migrations
module Schema
# Add gauth_secret columns in the resource's database tables
#
# Examples
#
# # For a new resource migration:
# create_table :the_resources do |t|
# t.gauth_secret
# t.gauth_enabled
# ...
# ... |
github | AsteriskLabs/devise_google_authenticator | https://github.com/AsteriskLabs/devise_google_authenticator | lib/devise_google_authenticatable/controllers/helpers.rb | Ruby | mit | 215 | master | 861 | module DeviseGoogleAuthenticator
module Controllers # :nodoc:
module Helpers # :nodoc:
def google_authenticator_qrcode(user, qualifier=nil, issuer=nil)
username = username_from_email(user.email)
app = user.class.ga_appname || Rails.application.class.parent_name
data = "otpauth://totp... |
github | AsteriskLabs/devise_google_authenticator | https://github.com/AsteriskLabs/devise_google_authenticator | lib/devise_google_authenticatable/models/google_authenticatable.rb | Ruby | mit | 215 | master | 2,802 | require 'rotp'
module Devise # :nodoc:
module Models # :nodoc:
module GoogleAuthenticatable
def self.included(base) # :nodoc:
base.extend ClassMethods
base.class_eval do
before_validation :assign_auth_secret, :on => :create
include InstanceMethods
end
en... |
github | AsteriskLabs/devise_google_authenticator | https://github.com/AsteriskLabs/devise_google_authenticator | lib/devise_google_authenticatable/orm/active_record.rb | Ruby | mit | 215 | master | 561 | module DeviseGoogleAuthenticator
module Orm
# This module contains handle schema (migrations):
#
# create_table :accounts do |t|
# t.gauth_secret
# t.gauth_enabled
# end
#
module ActiveRecord
module Schema
include DeviseGoogleAuthenticator::Schema
end
e... |
github | AsteriskLabs/devise_google_authenticator | https://github.com/AsteriskLabs/devise_google_authenticator | lib/devise_google_authenticatable/patches/display_qr.rb | Ruby | mit | 215 | master | 1,387 | module DeviseGoogleAuthenticator::Patches
# patch Registrations controller to display the QR code
module DisplayQR
extend ActiveSupport::Concern
included do
#arrr be the patch
alias_method :create_original, :create
define_method :create do
build_resource(sign_up_params)
... |
github | AsteriskLabs/devise_google_authenticator | https://github.com/AsteriskLabs/devise_google_authenticator | lib/devise_google_authenticatable/patches/check_ga.rb | Ruby | mit | 215 | master | 1,678 | module DeviseGoogleAuthenticator::Patches
# patch Sessions controller to check that the OTP is accurate
module CheckGA
extend ActiveSupport::Concern
included do
# here the patch
alias_method :create_original, :create
define_method :checkga_resource_path_name do |resource, id|
name ... |
github | AsteriskLabs/devise_google_authenticator | https://github.com/AsteriskLabs/devise_google_authenticator | lib/generators/mongoid/devise_google_authenticator_generator.rb | Ruby | mit | 215 | master | 658 | require 'rails/generators/named_base'
require 'generators/devise/orm_helpers'
module Mongoid
module Generators
class DeviseGoogleAuthenticatorGenerator < Rails::Generators::NamedBase
include Devise::Generators::OrmHelpers
def inject_field_types
inject_into_file model_path, migration_data, :a... |
github | AsteriskLabs/devise_google_authenticator | https://github.com/AsteriskLabs/devise_google_authenticator | lib/generators/devise_google_authenticator/install_generator.rb | Ruby | mit | 215 | master | 1,753 | module DeviseGoogleAuthenticator
module Generators # :nodoc:
# Install Generator
class InstallGenerator < Rails::Generators::Base
source_root File.expand_path("../../templates", __FILE__)
desc "Install the devise google authenticator extension"
def add_configs
inject_into_file "con... |
github | AsteriskLabs/devise_google_authenticator | https://github.com/AsteriskLabs/devise_google_authenticator | lib/generators/devise_google_authenticator/devise_google_authenticator_generator.rb | Ruby | mit | 215 | master | 1,090 | module DeviseGoogleAuthenticator
module Generators
class DeviseGoogleAuthenticatorGenerator < Rails::Generators::NamedBase
namespace "devise_google_authenticator"
desc "Add :google_authenticatable directive in the given model, plus accessors. Also generate migration for ActiveRecord"
def inje... |
github | AsteriskLabs/devise_google_authenticator | https://github.com/AsteriskLabs/devise_google_authenticator | lib/generators/devise_google_authenticator/views_generator.rb | Ruby | mit | 215 | master | 597 | require 'generators/devise/views_generator'
module DeviseGoogleAuthenticator
module Generators
class ViewsGenerator < Rails::Generators::Base
desc 'Copies all Devise Google Authenticator views to your application.'
argument :scope, :required => false, :default => nil,
:desc =>... |
github | AsteriskLabs/devise_google_authenticator | https://github.com/AsteriskLabs/devise_google_authenticator | lib/generators/active_record/devise_google_authenticator_generator.rb | Ruby | mit | 215 | master | 390 | require 'rails/generators/active_record'
module ActiveRecord
module Generators
class DeviseGoogleAuthenticatorGenerator < ActiveRecord::Generators::Base
source_root File.expand_path("../templates", __FILE__)
def copy_devise_migration
migration_template "migration.rb", "db/migrate/devise_goog... |
github | AsteriskLabs/devise_google_authenticator | https://github.com/AsteriskLabs/devise_google_authenticator | lib/generators/active_record/templates/migration.rb | Ruby | mit | 215 | master | 462 | class DeviseGoogleAuthenticatorAddTo<%= table_name.camelize %> < ActiveRecord::Migration
def self.up
change_table :<%= table_name %> do |t|
t.string :gauth_secret
t.string :gauth_enabled, :default => "f"
t.string :gauth_tmp
t.datetime :gauth_tmp_datetime
end
end
def self.do... |
github | AsteriskLabs/devise_google_authenticator | https://github.com/AsteriskLabs/devise_google_authenticator | app/controllers/devise/displayqr_controller.rb | Ruby | mit | 215 | master | 1,728 | class Devise::DisplayqrController < DeviseController
prepend_before_filter :authenticate_scope!, :only => [:show, :update, :refresh]
include Devise::Controllers::Helpers
# GET /resource/displayqr
def show
if resource.nil? || resource.gauth_secret.nil?
sign_in resource_class.new, resource
redir... |
github | AsteriskLabs/devise_google_authenticator | https://github.com/AsteriskLabs/devise_google_authenticator | app/controllers/devise/checkga_controller.rb | Ruby | mit | 215 | master | 1,436 | class Devise::CheckgaController < Devise::SessionsController
prepend_before_filter :devise_resource, :only => [:show]
prepend_before_filter :require_no_authentication, :only => [ :show, :update ]
include Devise::Controllers::Helpers
def show
@tmpid = params[:id]
if @tmpid.nil?
redirect_to :root
... |
github | AsteriskLabs/devise_google_authenticator | https://github.com/AsteriskLabs/devise_google_authenticator | test/generators_test.rb | Ruby | mit | 215 | master | 904 | $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..'))
require 'test_helper'
require 'rails/generators'
require 'generators/devise_google_authenticator/devise_google_authenticator_generator'
class GeneratorsTest < ActiveSupport::TestCase
RAILS_APP_PATH = File.expand_path("../rails_app", __FILE__)
test "rails... |
github | AsteriskLabs/devise_google_authenticator | https://github.com/AsteriskLabs/devise_google_authenticator | test/integration_tests_helper.rb | Ruby | mit | 215 | master | 1,080 | class ActionController::IntegrationTest
def warden
request.env['warden']
end
def create_full_user
@@user ||= begin
user = User.create!(
:username => 'usertest',
:email => 'fulluser@test.com',
:password => '123456',
:passwo... |
github | AsteriskLabs/devise_google_authenticator | https://github.com/AsteriskLabs/devise_google_authenticator | test/test_helper.rb | Ruby | mit | 215 | master | 608 | ENV["RAILS_ENV"] = "test"
DEVISE_ORM = (ENV["DEVISE_ORM"] || :active_record).to_sym
$:.unshift File.dirname(__FILE__)
puts "\n==> Devise.orm = #{DEVISE_ORM.inspect}"
require "rails_app/config/environment"
include Devise::TestHelpers
require "orm/#{DEVISE_ORM}"
require 'rails/test_help'
require 'capybara/rails'
require... |
github | AsteriskLabs/devise_google_authenticator | https://github.com/AsteriskLabs/devise_google_authenticator | test/model_tests_helper.rb | Ruby | mit | 215 | master | 479 | class ActiveSupport::TestCase
# Helpers for creating new users
#
def generate_unique_email
@@email_count ||= 0
@@email_count += 1
"test#{@@email_count}@email.com"
end
def valid_attributes(attributes={})
{ :email => generate_unique_email,
:password => '123456',
:password_confirma... |
github | AsteriskLabs/devise_google_authenticator | https://github.com/AsteriskLabs/devise_google_authenticator | test/models_test.rb | Ruby | mit | 215 | master | 1,726 | require 'test_helper'
class ModelsTest < ActiveSupport::TestCase
def include_module?(klass, mod)
klass.devise_modules.include?(mod) &&
klass.included_modules.include?(Devise::Models::const_get(mod.to_s.classify))
end
def assert_include_modules(klass, *modules)
modules.each do |mod|
assert incl... |
github | AsteriskLabs/devise_google_authenticator | https://github.com/AsteriskLabs/devise_google_authenticator | test/integration/gauth_test.rb | Ruby | mit | 215 | master | 6,316 | require 'test_helper'
require 'integration_tests_helper'
class InvitationTest < ActionDispatch::IntegrationTest
self.use_transactional_fixtures = false
def teardown
Capybara.reset_sessions!
Timecop.return
end
test 'register new user - confirm that we get a display qr page after registering' do
vi... |
github | AsteriskLabs/devise_google_authenticator | https://github.com/AsteriskLabs/devise_google_authenticator | test/models/google_authenticatable_test.rb | Ruby | mit | 215 | master | 1,913 | require 'test_helper'
require 'model_tests_helper'
class GoogleAuthenticatableTest < ActiveSupport::TestCase
def setup
new_user
end
test 'new users have a non-nil secret set' do
assert_not_nil User.find(1).gauth_secret
end
test 'new users should have gauth_enabled disabled by default' do
assert_equal 0, ... |
github | AsteriskLabs/devise_google_authenticator | https://github.com/AsteriskLabs/devise_google_authenticator | test/rails_app/app/controllers/posts_controller.rb | Ruby | mit | 215 | master | 1,838 | class PostsController < ApplicationController
# GET /posts
# GET /posts.json
def index
@posts = Post.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @posts }
end
end
# GET /posts/1
# GET /posts/1.json
def show
@post = Post.find(params[:id])
... |
github | AsteriskLabs/devise_google_authenticator | https://github.com/AsteriskLabs/devise_google_authenticator | test/rails_app/app/models/user.rb | Ruby | mit | 215 | master | 517 | class User < PARENT_MODEL_CLASS
# Include default devise modules. Others available are:
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
devise :google_authenticatable, :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :valid... |
github | AsteriskLabs/devise_google_authenticator | https://github.com/AsteriskLabs/devise_google_authenticator | test/rails_app/config/boot.rb | Ruby | mit | 215 | master | 277 | unless defined?(DEVISE_ORM)
DEVISE_ORM = (ENV["DEVISE_ORM"] || :active_record).to_sym
end
begin
require File.expand_path("../../../../.bundle/environment", __FILE__)
rescue LoadError
require 'rubygems'
require 'bundler'
Bundler.setup :default, :test, DEVISE_ORM
end |
github | AsteriskLabs/devise_google_authenticator | https://github.com/AsteriskLabs/devise_google_authenticator | test/rails_app/config/application.rb | Ruby | mit | 215 | master | 460 | require File.expand_path('../boot', __FILE__)
require "action_controller/railtie"
require "action_mailer/railtie"
require "rails/test_unit/railtie"
begin
require "#{DEVISE_ORM}/railtie"
rescue LoadError
end
PARENT_MODEL_CLASS = DEVISE_ORM == :active_record ? ActiveRecord::Base : Object
require "devise"
require "d... |
github | AsteriskLabs/devise_google_authenticator | https://github.com/AsteriskLabs/devise_google_authenticator | test/rails_app/config/environments/development.rb | Ruby | mit | 215 | master | 988 | RailsApp::Application.configure do
# Settings specified here will take precedence over those in config/environment.rb
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the webs... |
github | AsteriskLabs/devise_google_authenticator | https://github.com/AsteriskLabs/devise_google_authenticator | test/rails_app/config/environments/test.rb | Ruby | mit | 215 | master | 1,513 | RailsApp::Application.configure do
# Settings specified here will take precedence over those in config/environment.rb
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test... |
github | AsteriskLabs/devise_google_authenticator | https://github.com/AsteriskLabs/devise_google_authenticator | test/rails_app/config/initializers/session_store.rb | Ruby | mit | 215 | master | 419 | # Be sure to restart your server when you modify this file.
RailsApp::Application.config.session_store :cookie_store, key: '_gauth-app2_session'
# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
# (create the session table with "rai... |
github | AsteriskLabs/devise_google_authenticator | https://github.com/AsteriskLabs/devise_google_authenticator | test/rails_app/config/initializers/devise.rb | Ruby | mit | 215 | master | 10,536 | # Use this hook to configure devise mailer, warden hooks and so forth.
# Many of these configuration options can be set straight in your model.
Devise.setup do |config|
# ==> Mailer Configuration
# Configure the e-mail address which will be shown in Devise::Mailer,
# note that it will be overwritten if you use yo... |
github | AsteriskLabs/devise_google_authenticator | https://github.com/AsteriskLabs/devise_google_authenticator | test/rails_app/config/initializers/secret_token.rb | Ruby | mit | 215 | master | 499 | # Be sure to restart your server when you modify this file.
# Your secret key for verifying the integrity of signed cookies.
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attac... |
github | AsteriskLabs/devise_google_authenticator | https://github.com/AsteriskLabs/devise_google_authenticator | test/rails_app/db/migrate/20120122053518_devise_google_authenticator_add_to_users.rb | Ruby | mit | 215 | master | 431 | class DeviseGoogleAuthenticatorAddToUsers < ActiveRecord::Migration
def self.up
change_table :users do |t|
t.string :gauth_secret, :gauth_token
t.string :gauth_enabled, :default => "f"
t.string :gauth_tmp
t.datetime :gauth_tmp_datetime
end
end
def self.down
change_table... |
github | AsteriskLabs/devise_google_authenticator | https://github.com/AsteriskLabs/devise_google_authenticator | test/rails_app/db/migrate/20120122052528_devise_create_users.rb | Ruby | mit | 215 | master | 1,850 | class DeviseCreateUsers < ActiveRecord::Migration
def change
create_table(:users) do |t|
## Database authenticatable
t.string :email, :null => false, :default => ""
t.string :encrypted_password, :null => false, :default => ""
## Recoverable
t.string :reset_password_t... |
github | AsteriskLabs/devise_google_authenticator | https://github.com/AsteriskLabs/devise_google_authenticator | test/lib/patches/check_ga_test.rb | Ruby | mit | 215 | master | 594 | require 'test_helper'
require 'devise_google_authenticatable/patches/check_ga.rb'
class MockCheckGA
def create
end
include DeviseGoogleAuthenticator::Patches::CheckGA
end
module Nested
class Admin
end
end
class User
end
class CheckGaTest < ActiveSupport::TestCase
test 'handles namespaces' do
a... |
github | AsteriskLabs/devise_google_authenticator | https://github.com/AsteriskLabs/devise_google_authenticator | test/lib/devise_google_authenticatable/controllers/helpers_test.rb | Ruby | mit | 215 | master | 1,660 | require 'test_helper'
require 'devise_google_authenticatable/controllers/helpers'
class HelpersTest < ActiveSupport::TestCase
include DeviseGoogleAuthenticator::Controllers::Helpers
def setup
@user = User.new(valid_attributes({:email => 'helpers_test@test.com' }))
end
test "can get username from user'... |
github | carmen-ruby/carmen-rails | https://github.com/carmen-ruby/carmen-rails | carmen-rails.gemspec | Ruby | mit | 214 | master | 665 | $:.push File.expand_path("../lib", __FILE__)
require "carmen/rails/version"
Gem::Specification.new do |s|
s.name = "carmen-rails"
s.version = Carmen::Rails::VERSION
s.authors = ["Jim Benton"]
s.email = ["jim@autonomousmachine.com"]
s.homepage = "http://github.com/jim/carmen-rails"
... |
github | carmen-ruby/carmen-rails | https://github.com/carmen-ruby/carmen-rails | Rakefile | Ruby | mit | 214 | master | 321 | require "rubygems"
require 'bundler/setup'
require 'rake'
require 'rake/testtask'
require 'rdoc/task'
Bundler::GemHelper.install_tasks
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end
desc 'Default: run unit tests.'
task :default => :test |
github | carmen-ruby/carmen-rails | https://github.com/carmen-ruby/carmen-rails | test/test_helper.rb | Ruby | mit | 214 | master | 1,172 | lib_path = File.expand_path('../../lib', __FILE__)
$LOAD_PATH.unshift(lib_path)
require 'minitest/autorun'
require 'minitest/spec'
require 'action_view/test_case'
require 'rails'
require 'carmen-rails'
require 'ostruct'
require 'debugger'
MiniTest::Spec.register_spec_type(/.*/, ActionView::TestCase)
Carmen.clear_d... |
github | carmen-ruby/carmen-rails | https://github.com/carmen-ruby/carmen-rails | test/carmen/action_view/helpers/form_helper_test.rb | Ruby | mit | 214 | master | 9,966 | require 'test_helper'
class CarmenViewHelperTest < MiniTest::Unit::TestCase
include ActionView::Helpers::FormOptionsHelper
include ActionView::Helpers::FormTagHelper
include ActionDispatch::Assertions::SelectorAssertions
def setup
@object = OpenStruct.new
def @object.to_s; 'object'; end
end
def r... |
github | carmen-ruby/carmen-rails | https://github.com/carmen-ruby/carmen-rails | lib/carmen-rails.rb | Ruby | mit | 214 | master | 535 | require 'carmen'
require 'carmen/rails/action_view/form_helper'
require 'carmen/rails/version'
module Carmen
module Rails
class Railtie < ::Rails::Railtie
# Add Carmen's locale paths to the Rails backend
paths = Carmen.i18n_backend.locale_paths.map { |path|
Dir[path + '**/*.yml']
}.flat... |
github | carmen-ruby/carmen-rails | https://github.com/carmen-ruby/carmen-rails | lib/carmen/rails/action_view/form_helper.rb | Ruby | mit | 214 | master | 11,114 | module ActionView
module Helpers
module FormOptionsHelper
# Generate select and subregion option tags for the given object and method. A
# common use of this would be to allow users to select a state subregion within
# a given country.
#
# object - The model object to generate... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/Rakefile | Ruby | apache-2.0 | 214 | main | 741 | # Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path("config/application", __dir__)
Supermarket::Application.load_tasks
if !Rails.env.production?
require "chefstyle"
require "rubocop/... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/Gemfile | Ruby | apache-2.0 | 214 | main | 2,583 | source "https://rubygems.org"
gem "fieri", path: "engines/fieri"
gem "rails", "~> 7.1.5.2"
gem "rack", ">= 2.2.14"
gem "omniauth", "~> 2.1.1"
gem "omniauth-chef-oauth2"
gem "omniauth-github", "~> 2.0.0"
gem "omniauth-oauth2", "~> 1.7.3"
gem "omniauth-rails_csrf_protection"
gem "coderay" # markdown doc - syntax highli... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/Guardfile | Ruby | apache-2.0 | 214 | main | 1,704 | # This group allows to skip running RuboCop when RSpec failed.
group :red_green_refactor, halt_on_fail: true do
guard :rspec, all_on_start: true,
cmd: "bundle exec rspec --format documentation",
run_all: { cmd: "bundle exec rspec --format progress" } do
require "guard/rspec/dsl"
... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/config.rb | Ruby | apache-2.0 | 214 | main | 782 | # Require any additional compass plugins here.
require "sass-globbing"
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "app/assets/stylesheets"
sass_dir = "app/assets/stylesheets"
images_dir = "app/assets/images"
javascripts_dir = "app/assets/javascripts"
# You can select your preferre... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/app/workers/cookbook_notify_worker.rb | Ruby | apache-2.0 | 214 | main | 1,303 | class CookbookNotifyWorker
include Sidekiq::Worker
#
# Notify all followers that a new version of the specified +Cookbook+ has been updated.
# This will only email the follower if the user has email notifications turned on.
# This will not email users with an OCID oauth token of 'imported' to prevent migrate... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/app/workers/oauth_token_refresh_schedule_worker.rb | Ruby | apache-2.0 | 214 | main | 384 | class OauthTokenRefreshScheduleWorker
include Sidekiq::Worker
#
# Queue jobs for OauthTokenRefreshWorker.
#
# Accounts whose OAuth tokens will expire in the next 25 minutes will have
# their tokens refreshed.
#
#
def perform
Account.tokens_expiring_soon(Time.zone.now).each do |account|
Oaut... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/app/workers/fieri_notify_worker.rb | Ruby | apache-2.0 | 214 | main | 954 | require "net/http"
require "uri"
class FieriNotifyWorker
include Sidekiq::Worker
include Rails.application.routes.url_helpers
#
# Send a POST request to the configured +FIERI_URL+ when a Cookbook Version
# is shared.
#
# @param [Integer] cookbook_version_id the id for the Cookbook
#
# @return [Boole... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/app/workers/oauth_token_refresh_worker.rb | Ruby | apache-2.0 | 214 | main | 1,278 | class OauthTokenRefreshWorker
include Sidekiq::Worker
#
# Refresh the OAuth token of the given account
#
# @param [Integer] account_id the ID for the Account
#
def perform(account_id)
account = Account.find(account_id)
strategy = OmniAuth::Strategies::ChefOAuth2.new(
Rails.application,
... |
github | chef/supermarket | https://github.com/chef/supermarket | src/supermarket/app/workers/cookbook_deletion_worker.rb | Ruby | apache-2.0 | 214 | main | 1,049 | class CookbookDeletionWorker
include Sidekiq::Worker
#
# Notify anyone that was a follower or a collaborator on this cookbook that
# it has been deleted. This will only email users with email notifications
# turned on.
#
# @param [Hash] cookbook a hash representation of the cookbook to delete
#
def p... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.