omniauth-rails 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +71 -0
- data/Rakefile +41 -0
- data/app/assets/config/omniauth_rails_manifest.js +1 -0
- data/app/assets/stylesheets/omniauth/rails/application.css +19 -0
- data/app/controllers/omniauth/rails/application_controller.rb +8 -0
- data/app/controllers/omniauth/rails/flash.rb +46 -0
- data/app/controllers/omniauth/rails/require_authentication.rb +26 -0
- data/app/controllers/omniauth/rails/require_authorization.rb +32 -0
- data/app/controllers/omniauth/rails/sessions_controller.rb +55 -0
- data/app/helpers/omniauth/rails/application_helper.rb +16 -0
- data/app/models/omniauth/rails/authentication_data_store.rb +31 -0
- data/app/models/omniauth/rails/authentication_request.rb +28 -0
- data/app/models/omniauth/rails/authentication_session.rb +53 -0
- data/app/models/omniauth/rails/authorization_checker.rb +28 -0
- data/app/models/omniauth/rails/authorization_types/base.rb +17 -0
- data/app/models/omniauth/rails/authorization_types/domains.rb +22 -0
- data/app/models/omniauth/rails/authorization_types/emails.rb +18 -0
- data/app/models/omniauth/rails/authorization_types/regex.rb +18 -0
- data/app/models/omniauth/rails/omni_auth_route_builder.rb +18 -0
- data/app/views/omniauth/rails/sessions/destroy.html.erb +6 -0
- data/config/initializers/omniauth_rails.rb +35 -0
- data/config/routes.rb +6 -0
- data/lib/omniauth/rails/configuration.rb +15 -0
- data/lib/omniauth/rails/engine.rb +22 -0
- data/lib/omniauth/rails/test/controller_helpers.rb +17 -0
- data/lib/omniauth/rails/test/request_helpers.rb +25 -0
- data/lib/omniauth/rails/version.rb +6 -0
- data/lib/omniauth/rails.rb +9 -0
- data/spec/controllers/application_controller_spec.rb +9 -0
- data/spec/examples.txt +19 -0
- data/spec/models/omniauth/rails/authorization_types/emails_spec.rb +28 -0
- data/spec/models/omniauth/rails/authorization_types/regex_spec.rb +28 -0
- data/spec/omniauth_rails_spec.rb +10 -0
- data/spec/rails_helper_for_engine.rb +62 -0
- data/spec/spec_helper.rb +93 -0
- data/spec/test_app/Rakefile +12 -0
- data/spec/test_app/app/assets/config/manifest.js +4 -0
- data/spec/test_app/app/assets/javascripts/application.js +13 -0
- data/spec/test_app/app/assets/stylesheets/application.css +15 -0
- data/spec/test_app/app/controllers/application_controller.rb +4 -0
- data/spec/test_app/app/controllers/private_controller.rb +9 -0
- data/spec/test_app/app/controllers/public_controller.rb +6 -0
- data/spec/test_app/app/helpers/application_helper.rb +3 -0
- data/spec/test_app/app/mailers/application_mailer.rb +5 -0
- data/spec/test_app/app/models/application_record.rb +4 -0
- data/spec/test_app/app/views/layouts/application.html.erb +24 -0
- data/spec/test_app/app/views/private/show.html.erb +1 -0
- data/spec/test_app/app/views/public/show.html.erb +1 -0
- data/spec/test_app/bin/bundle +4 -0
- data/spec/test_app/bin/rails +5 -0
- data/spec/test_app/bin/rake +5 -0
- data/spec/test_app/bin/setup +35 -0
- data/spec/test_app/bin/update +30 -0
- data/spec/test_app/config/application.rb +23 -0
- data/spec/test_app/config/boot.rb +6 -0
- data/spec/test_app/config/environment.rb +6 -0
- data/spec/test_app/config/environments/development.rb +55 -0
- data/spec/test_app/config/environments/production.rb +89 -0
- data/spec/test_app/config/environments/test.rb +43 -0
- data/spec/test_app/config/initializers/application_controller_renderer.rb +7 -0
- data/spec/test_app/config/initializers/assets.rb +12 -0
- data/spec/test_app/config/initializers/backtrace_silencers.rb +10 -0
- data/spec/test_app/config/initializers/cookies_serializer.rb +6 -0
- data/spec/test_app/config/initializers/filter_parameter_logging.rb +5 -0
- data/spec/test_app/config/initializers/inflections.rb +17 -0
- data/spec/test_app/config/initializers/mime_types.rb +5 -0
- data/spec/test_app/config/initializers/session_store.rb +4 -0
- data/spec/test_app/config/initializers/wrap_parameters.rb +15 -0
- data/spec/test_app/config/locales/en.yml +23 -0
- data/spec/test_app/config/omniauth_rails.yml +16 -0
- data/spec/test_app/config/puma.rb +48 -0
- data/spec/test_app/config/routes.rb +8 -0
- data/spec/test_app/config/secrets.yml +22 -0
- data/spec/test_app/config/spring.rb +7 -0
- data/spec/test_app/config.ru +6 -0
- data/spec/test_app/log/development.log +4451 -0
- data/spec/test_app/log/test.log +7601 -0
- data/spec/test_app/public/404.html +67 -0
- data/spec/test_app/public/422.html +67 -0
- data/spec/test_app/public/500.html +66 -0
- data/spec/test_app/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/test_app/public/apple-touch-icon.png +0 -0
- data/spec/test_app/public/favicon.ico +0 -0
- data/spec/test_app/spec/controllers/private_controller_spec.rb +19 -0
- data/spec/test_app/spec/rails_helper.rb +54 -0
- data/spec/test_app/spec/requests/private_controller_spec.rb +26 -0
- data/spec/test_app/spec/requests/public_controller_spec.rb +13 -0
- data/spec/test_app/spec/requests/sessions_controller_spec.rb +87 -0
- data/spec/test_app/spec/spec_helper.rb +99 -0
- data/spec/test_app/tmp/cache/assets/sprockets/v3.0/-5/-528MPRmC3ByNiAzVD1hs-NG3Muhf9FsYPaDbo4qIpI.cache +1 -0
- data/spec/test_app/tmp/cache/assets/sprockets/v3.0/3v/3voyTxS8FmTTGPrz-QQ23N6AgGate2o7X5ZnZeTkQbs.cache +0 -0
- data/spec/test_app/tmp/cache/assets/sprockets/v3.0/5V/5VAABbvE5t5bCDKmKjLivvfe1CqYdD4n4vtZQiMa4I0.cache +0 -0
- data/spec/test_app/tmp/cache/assets/sprockets/v3.0/64/64siRwVaDPAW5fTe1O4rlGaq-0ExxAWA0-csPcik-uM.cache +0 -0
- data/spec/test_app/tmp/cache/assets/sprockets/v3.0/Aa/AasprW2BgqWDcmZnsPRxs-R5D0VGpL7dHYMwtsC1tmE.cache +0 -0
- data/spec/test_app/tmp/cache/assets/sprockets/v3.0/An/An3DVlfO1pzT7FAnm09q3Ok_2PmGYhiAvxuW9OgG9wc.cache +0 -0
- data/spec/test_app/tmp/cache/assets/sprockets/v3.0/C-/C-_kx_I8fFV2TrLPw8CNFy1uLrN6G4yLPg_4vOhlohQ.cache +0 -0
- data/spec/test_app/tmp/cache/assets/sprockets/v3.0/EG/EGN6771mS8m_7wi-Cr-GgFKv9U9IE3gpo9JQ-N3AYlQ.cache +0 -0
- data/spec/test_app/tmp/cache/assets/sprockets/v3.0/Hl/HlzBaGDQ4NV3ctlz-qlmStUWDCELhxzVK1-SgLkPCH0.cache +0 -0
- data/spec/test_app/tmp/cache/assets/sprockets/v3.0/IB/IBoXb9_P8EU8f7aPVNE8cWJybcus8fS7KGvi4HxKdMU.cache +1 -0
- data/spec/test_app/tmp/cache/assets/sprockets/v3.0/K2/K28c2b37N3eRA-Pckb3MO3D3BvGXfbxDGNeRYIXG8Cg.cache +1 -0
- data/spec/test_app/tmp/cache/assets/sprockets/v3.0/KJ/KJdFFU6zb4YpQWEm8bsXxx8kdQ01BdK0F0h6TTzpOiY.cache +0 -0
- data/spec/test_app/tmp/cache/assets/sprockets/v3.0/KW/KWwCiQwwI6oqiIHZg_Qg2nrs1zXJISos9799GIL5viU.cache +0 -0
- data/spec/test_app/tmp/cache/assets/sprockets/v3.0/Kh/KhKDGOFwOEJlSwLMaG8Yak8AktHsnEr-fUwLpl9d0tc.cache +1 -0
- data/spec/test_app/tmp/cache/assets/sprockets/v3.0/NX/NXZl3HljnPNJmh2CNpp0skcYvQx4eSEp6vuG5o3lqqY.cache +0 -0
- data/spec/test_app/tmp/cache/assets/sprockets/v3.0/NX/nxTv3sKVUQZADJyM3dPaVmUA78MIsMLD_K279yN_GsI.cache +0 -0
- data/spec/test_app/tmp/cache/assets/sprockets/v3.0/Ob/ObDGu7gmDzQuH86CeAdhWRPf0sfv9Qo3CoxGK3VOYWI.cache +0 -0
- data/spec/test_app/tmp/cache/assets/sprockets/v3.0/QG/QGjnK1OGVhAWzpma8R60Qdcr6v46sAWmpwQpeoWltX8.cache +1 -0
- data/spec/test_app/tmp/cache/assets/sprockets/v3.0/Qn/Qn2TRz8mMz8dPVvXgHUfqXC19EPZQgG3XDqm5W_E-A0.cache +1 -0
- data/spec/test_app/tmp/cache/assets/sprockets/v3.0/WC/WCTd8gm1KmkPKRB14gd1wwFv3x9NwMsmquXet4Z1DTU.cache +2 -0
- data/spec/test_app/tmp/cache/assets/sprockets/v3.0/Z-/Z-3hfqbx8r350iW9zFPz_OdVHX0X4Z4bMk9YbS1eha8.cache +0 -0
- data/spec/test_app/tmp/cache/assets/sprockets/v3.0/Z2/Z2DJdVm4jsJXg0HzuQVyAAmjJbVdzKntXlmd14iNVbU.cache +0 -0
- data/spec/test_app/tmp/cache/assets/sprockets/v3.0/ZA/ZAzUlqsc-uLa_zcjt1t6EBkPqI8PkEoxz40i4FgrRlQ.cache +1 -0
- data/spec/test_app/tmp/cache/assets/sprockets/v3.0/bN/bNCmkb6T3JKDzd6s7ZxOLn_WdC6gUnRARnBDHrMFS7o.cache +1 -0
- data/spec/test_app/tmp/cache/assets/sprockets/v3.0/b_/b_Itlk9QZZd7Rvf8kcA4yLP1R5Acu7jB-m1xQiSU0qE.cache +0 -0
- data/spec/test_app/tmp/cache/assets/sprockets/v3.0/d6/d6PosAq3dbPqxxvjAcaLgePkRuQ8w__EA-M42WarK_0.cache +1 -0
- data/spec/test_app/tmp/cache/assets/sprockets/v3.0/fD/fDbKpwc4jlsYlnxTT3vnhsiBcSJF3imnAGUBp9nq_Bw.cache +1 -0
- data/spec/test_app/tmp/cache/assets/sprockets/v3.0/fE/fEHvM7gLiXuJB6lDj2KNzgAx5L3BBn2NSsuodvPAryI.cache +0 -0
- data/spec/test_app/tmp/cache/assets/sprockets/v3.0/fg/fgbqfgH_CvzP2H744Q3ywDzlqLRSgSw0AH6ifkC7roo.cache +1 -0
- data/spec/test_app/tmp/cache/assets/sprockets/v3.0/g4/g4TbkEUbvKBMpO8z4ioPbq8ArdLl-scuF3pVaLJhmVI.cache +1 -0
- data/spec/test_app/tmp/cache/assets/sprockets/v3.0/id/idcyFsf20F5Vd3GC1XtM_PxlNnROM6CxO1j11NG3RWk.cache +1 -0
- data/spec/test_app/tmp/cache/assets/sprockets/v3.0/ih/ihflBRw1ToLzP0q8oKAJl_a6EHHbTdJUcVR5DANsIuA.cache +0 -0
- data/spec/test_app/tmp/cache/assets/sprockets/v3.0/jz/jzXohzOyfczV5wKfQVQWgE1H0IMN4jaxEM3XlhHNgvk.cache +0 -0
- data/spec/test_app/tmp/cache/assets/sprockets/v3.0/lH/lHLoBOtMavo_6UnfOn0DVLI2JQBT1W9sGR3IZzOD6o8.cache +2 -0
- data/spec/test_app/tmp/cache/assets/sprockets/v3.0/mD/mDmWU5fLvNY4uggphc1wqYVQDn_w_U6Jz2XRSf59jDc.cache +0 -0
- data/spec/test_app/tmp/cache/assets/sprockets/v3.0/mX/mX1nlsL_SWOB4y22W5FheRX0YEONKyOY7xUeIvRiHco.cache +0 -0
- data/spec/test_app/tmp/cache/assets/sprockets/v3.0/n5/n5FDaqgvLV4Rc1Xm6TykMEFanDhSJJ77HPuPCEgCDQM.cache +1 -0
- data/spec/test_app/tmp/cache/assets/sprockets/v3.0/n9/n9Nzbk_dEL3fNO-u56owqnrG7YQmhcvDgJ2fWWE_9jE.cache +0 -0
- data/spec/test_app/tmp/cache/assets/sprockets/v3.0/nU/nUDR2L4CaIx5IszaYaaaACw519TTTzvpxsp7NMl6KyQ.cache +1 -0
- data/spec/test_app/tmp/cache/assets/sprockets/v3.0/n_/n_xYqQYhwEMQknb3jFQnjlxxBE9TzMNHCdJ-bEyZFIw.cache +0 -0
- data/spec/test_app/tmp/cache/assets/sprockets/v3.0/pc/pcFf9fij5Xa__QoHi-QzN_0Q_UGLhv6gihTXnoFX3sg.cache +1 -0
- data/spec/test_app/tmp/cache/assets/sprockets/v3.0/q-/q-721tFv_0DZO9GZ_kHYUD_jn6GNRC09vb51mwyxbuI.cache +1 -0
- data/spec/test_app/tmp/cache/assets/sprockets/v3.0/r6/r6saZ-BJCnX2-U353od1DgtZIGy5kXrCuXatXntMcTE.cache +0 -0
- data/spec/test_app/tmp/cache/assets/sprockets/v3.0/wY/wYWiPwDGlToFGYId__oKg8QMPEeuRZoP1FhQahshfOo.cache +1 -0
- data/spec/test_app/tmp/cache/assets/sprockets/v3.0/yD/yDj60NQvsiwl1QWQXH-iC4pgF1cmHkUFo-kkXBSjsIQ.cache +1 -0
- data/spec/test_app/tmp/cache/assets/sprockets/v3.0/ym/ymCwqEVBkEs6bYteLf70KCA5pCKZtqjQ3TbZQzrIs3M.cache +0 -0
- data/spec/test_app/tmp/cache/assets/sprockets/v3.0/z0/z041WxjoEQvRhtSLORbkRlsNTgi68Rwx7XUyaDbPn0M.cache +1 -0
- data/spec/test_app/tmp/pids/server.pid +1 -0
- metadata +453 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
module Omniauth
|
|
3
|
+
module Rails
|
|
4
|
+
class Engine < ::Rails::Engine
|
|
5
|
+
require "omniauth"
|
|
6
|
+
require "omniauth-google-oauth2"
|
|
7
|
+
isolate_namespace Omniauth::Rails
|
|
8
|
+
|
|
9
|
+
initializer "omniauth_rails.action_controller" do |_app|
|
|
10
|
+
ActiveSupport.on_load :action_controller do
|
|
11
|
+
helper Omniauth::Rails::ApplicationHelper
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
config.generators do |g|
|
|
16
|
+
g.test_framework :rspec, fixture: false
|
|
17
|
+
g.assets false
|
|
18
|
+
g.helper false
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
module Omniauth
|
|
3
|
+
module Rails
|
|
4
|
+
module Test
|
|
5
|
+
module ControllerHelpers
|
|
6
|
+
def sign_in(email)
|
|
7
|
+
session["OmniauthRailsAuthData"] = { "email" => email }
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def authenticated?
|
|
11
|
+
session["OmniauthRailsAuthData"].present? &&
|
|
12
|
+
session["OmniauthRailsAuthData"]["email"].present?
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
module Omniauth
|
|
3
|
+
module Rails
|
|
4
|
+
module Test
|
|
5
|
+
module RequestHelpers
|
|
6
|
+
# Another option for mocking this, is to use something like this:
|
|
7
|
+
# before do
|
|
8
|
+
# Rails.application.env_config["omniauth.auth"] = OmniAuth.config.mock_auth[:google_oauth2]
|
|
9
|
+
# end
|
|
10
|
+
|
|
11
|
+
def sign_in(email)
|
|
12
|
+
fake_session = {}
|
|
13
|
+
data_store = Omniauth::Rails::AuthenticationDataStore.new(fake_session)
|
|
14
|
+
data_store.set("email", email)
|
|
15
|
+
allow(AuthenticationDataStore).to receive(:new).and_return(data_store)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def authenticated?
|
|
19
|
+
get "/private"
|
|
20
|
+
response.status == 200
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "rails_helper_for_engine"
|
|
4
|
+
require_relative "../../app/controllers/omniauth/rails/application_controller"
|
|
5
|
+
|
|
6
|
+
# This empty describe doesn't do anything. But for some reason it convinces
|
|
7
|
+
# simplecov that the ApplicationController is covered.
|
|
8
|
+
RSpec.describe Omniauth::Rails::ApplicationController do
|
|
9
|
+
end
|
data/spec/examples.txt
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
example_id | status | run_time |
|
|
2
|
+
------------------------------------------------------------------------ | ------ | --------------- |
|
|
3
|
+
./spec/controllers/application_controller_spec.rb[1:1] | passed | 0.00035 seconds |
|
|
4
|
+
./spec/models/omniauth/rails/authorization_types/emails_spec.rb[1:1:1:1] | passed | 0.00009 seconds |
|
|
5
|
+
./spec/models/omniauth/rails/authorization_types/emails_spec.rb[1:1:2:1] | passed | 0.00051 seconds |
|
|
6
|
+
./spec/models/omniauth/rails/authorization_types/regex_spec.rb[1:1:1:1] | passed | 0.00019 seconds |
|
|
7
|
+
./spec/models/omniauth/rails/authorization_types/regex_spec.rb[1:1:2:1] | passed | 0.00012 seconds |
|
|
8
|
+
./spec/omniauth_rails_spec.rb[1:1] | passed | 0.00043 seconds |
|
|
9
|
+
./spec/test_app/spec/controllers/private_controller_spec.rb[1:1:1:1] | passed | 0.00652 seconds |
|
|
10
|
+
./spec/test_app/spec/requests/private_controller_spec.rb[1:1:1:1] | passed | 0.01215 seconds |
|
|
11
|
+
./spec/test_app/spec/requests/private_controller_spec.rb[1:1:2:1] | passed | 0.17193 seconds |
|
|
12
|
+
./spec/test_app/spec/requests/public_controller_spec.rb[1:1:1] | passed | 0.00821 seconds |
|
|
13
|
+
./spec/test_app/spec/requests/sessions_controller_spec.rb[1:1:1] | passed | 0.00263 seconds |
|
|
14
|
+
./spec/test_app/spec/requests/sessions_controller_spec.rb[1:1:2:1] | passed | 0.00228 seconds |
|
|
15
|
+
./spec/test_app/spec/requests/sessions_controller_spec.rb[1:2:1:1] | passed | 0.01283 seconds |
|
|
16
|
+
./spec/test_app/spec/requests/sessions_controller_spec.rb[1:2:1:2:1] | passed | 0.0042 seconds |
|
|
17
|
+
./spec/test_app/spec/requests/sessions_controller_spec.rb[1:3:1:1] | passed | 0.00124 seconds |
|
|
18
|
+
./spec/test_app/spec/requests/sessions_controller_spec.rb[1:3:2:1] | passed | 0.0011 seconds |
|
|
19
|
+
./spec/test_app/spec/requests/sessions_controller_spec.rb[1:3:3:1] | passed | 0.00288 seconds |
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "rails_helper_for_engine"
|
|
4
|
+
require_relative "../../../../../app/models/omniauth/rails/authorization_types/base"
|
|
5
|
+
require_relative "../../../../../app/models/omniauth/rails/authorization_types/emails"
|
|
6
|
+
|
|
7
|
+
RSpec.describe Omniauth::Rails::AuthorizationTypes::Emails do
|
|
8
|
+
let(:email) { "foo@bar.com" }
|
|
9
|
+
let(:emails) { %w(foo@bar.com baz@bar.com) }
|
|
10
|
+
|
|
11
|
+
let(:subject) { Omniauth::Rails::AuthorizationTypes::Emails.new(email: email, value: emails) }
|
|
12
|
+
|
|
13
|
+
describe "#authorized?" do
|
|
14
|
+
context "a match" do
|
|
15
|
+
it "returns true" do
|
|
16
|
+
expect(subject.authorized?).to eq(true)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
context "a miss" do
|
|
21
|
+
let(:email) { "foo99@bar.com" }
|
|
22
|
+
|
|
23
|
+
it "returns false" do
|
|
24
|
+
expect(subject.authorized?).to eq(false)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "rails_helper_for_engine"
|
|
4
|
+
require_relative "../../../../../app/models/omniauth/rails/authorization_types/base"
|
|
5
|
+
require_relative "../../../../../app/models/omniauth/rails/authorization_types/regex"
|
|
6
|
+
|
|
7
|
+
RSpec.describe Omniauth::Rails::AuthorizationTypes::Regex do
|
|
8
|
+
let(:email) { "foo@bar.com" }
|
|
9
|
+
let(:regex) { /\Afo\w@bar.com\z/i }
|
|
10
|
+
|
|
11
|
+
let(:subject) { Omniauth::Rails::AuthorizationTypes::Regex.new(email: email, value: regex) }
|
|
12
|
+
|
|
13
|
+
describe "#authorized?" do
|
|
14
|
+
context "a match" do
|
|
15
|
+
it "returns true" do
|
|
16
|
+
expect(subject.authorized?).to eq(true)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
context "a miss" do
|
|
21
|
+
let(:email) { "baz@bar.com" }
|
|
22
|
+
|
|
23
|
+
it "returns false" do
|
|
24
|
+
expect(subject.authorized?).to eq(false)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "../lib/omniauth/rails/version"
|
|
4
|
+
|
|
5
|
+
RSpec.describe Omniauth::Rails do
|
|
6
|
+
# This silly spec ensures that the Omniauth::Rails::VERSION has code coverage
|
|
7
|
+
it "has a version" do
|
|
8
|
+
expect(Omniauth::Rails::VERSION).to be_a(String)
|
|
9
|
+
end
|
|
10
|
+
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
|
4
|
+
ENV["RAILS_ENV"] ||= "test"
|
|
5
|
+
# require File.expand_path('../../config/environment', __FILE__)
|
|
6
|
+
# Prevent database truncation if the environment is production
|
|
7
|
+
# abort("The Rails environment is running in production mode!") if Rails.env.production?
|
|
8
|
+
require "spec_helper"
|
|
9
|
+
require "action_view/railtie"
|
|
10
|
+
require "action_controller/railtie"
|
|
11
|
+
require "rspec/rails"
|
|
12
|
+
require "omniauth/rails"
|
|
13
|
+
# Add additional requires below this line. Rails is not loaded until this point!
|
|
14
|
+
|
|
15
|
+
# Requires supporting ruby files with custom matchers and macros, etc, in
|
|
16
|
+
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
|
|
17
|
+
# run as spec files by default. This means that files in spec/support that end
|
|
18
|
+
# in _spec.rb will both be required and run as specs, causing the specs to be
|
|
19
|
+
# run twice. It is recommended that you do not name files matching this glob to
|
|
20
|
+
# end with _spec.rb. You can configure this pattern with the --pattern
|
|
21
|
+
# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
|
|
22
|
+
#
|
|
23
|
+
# The following line is provided for convenience purposes. It has the downside
|
|
24
|
+
# of increasing the boot-up time by auto-requiring all files in the support
|
|
25
|
+
# directory. Alternatively, in the individual `*_spec.rb` files, manually
|
|
26
|
+
# require only the support files necessary.
|
|
27
|
+
#
|
|
28
|
+
# Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
|
|
29
|
+
|
|
30
|
+
# Checks for pending migration and applies them before tests are run.
|
|
31
|
+
# If you are not using ActiveRecord, you can remove this line.
|
|
32
|
+
# ActiveRecord::Migration.maintain_test_schema!
|
|
33
|
+
|
|
34
|
+
RSpec.configure do |config|
|
|
35
|
+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
|
36
|
+
# config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
|
37
|
+
|
|
38
|
+
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
|
39
|
+
# examples within a transaction, remove the following line or assign false
|
|
40
|
+
# instead of true.
|
|
41
|
+
# config.use_transactional_fixtures = true
|
|
42
|
+
|
|
43
|
+
# RSpec Rails can automatically mix in different behaviours to your tests
|
|
44
|
+
# based on their file location, for example enabling you to call `get` and
|
|
45
|
+
# `post` in specs under `spec/controllers`.
|
|
46
|
+
#
|
|
47
|
+
# You can disable this behaviour by removing the line below, and instead
|
|
48
|
+
# explicitly tag your specs with their type, e.g.:
|
|
49
|
+
#
|
|
50
|
+
# RSpec.describe UsersController, :type => :controller do
|
|
51
|
+
# # ...
|
|
52
|
+
# end
|
|
53
|
+
#
|
|
54
|
+
# The different available types are documented in the features, such as in
|
|
55
|
+
# https://relishapp.com/rspec/rspec-rails/docs
|
|
56
|
+
config.infer_spec_type_from_file_location!
|
|
57
|
+
|
|
58
|
+
# Filter lines from Rails gems in backtraces.
|
|
59
|
+
config.filter_rails_from_backtrace!
|
|
60
|
+
# arbitrary gems may also be filtered via:
|
|
61
|
+
# config.filter_gems_from_backtrace("gem name")
|
|
62
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Hack to remove VERSION (which is loaded/required via Gemfile -> mogl.gemspec) before simplecov
|
|
4
|
+
# Without this, simplecov reports the VERSION is not covered by specs.
|
|
5
|
+
::Omniauth::Rails.send(:remove_const, "VERSION")
|
|
6
|
+
$LOADED_FEATURES.delete_if { |s| s.include?("omniauth/rails/version") }
|
|
7
|
+
|
|
8
|
+
require "simplecov"
|
|
9
|
+
require "byebug"
|
|
10
|
+
require "awesome_print" # Useful for debugging
|
|
11
|
+
require "dotenv"
|
|
12
|
+
Dotenv.load
|
|
13
|
+
|
|
14
|
+
RSpec.configure do |config|
|
|
15
|
+
# rspec-expectations config goes here. You can use an alternate
|
|
16
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
|
17
|
+
# assertions if you prefer.
|
|
18
|
+
config.expect_with :rspec do |expectations|
|
|
19
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
|
20
|
+
# and `failure_message` of custom matchers include text for helper methods
|
|
21
|
+
# defined using `chain`, e.g.:
|
|
22
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
|
23
|
+
# # => "be bigger than 2 and smaller than 4"
|
|
24
|
+
# ...rather than:
|
|
25
|
+
# # => "be bigger than 2"
|
|
26
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
|
30
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
|
31
|
+
config.mock_with :rspec do |mocks|
|
|
32
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
|
33
|
+
# a real object. This is generally recommended, and will default to
|
|
34
|
+
# `true` in RSpec 4.
|
|
35
|
+
mocks.verify_partial_doubles = true
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
|
|
39
|
+
# have no way to turn it off -- the option exists only for backwards
|
|
40
|
+
# compatibility in RSpec 3). It causes shared context metadata to be
|
|
41
|
+
# inherited by the metadata hash of host groups and examples, rather than
|
|
42
|
+
# triggering implicit auto-inclusion in groups with matching metadata.
|
|
43
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
|
44
|
+
|
|
45
|
+
# The settings below are suggested to provide a good initial experience
|
|
46
|
+
# with RSpec, but feel free to customize to your heart's content.
|
|
47
|
+
|
|
48
|
+
# This allows you to limit a spec run to individual examples or groups
|
|
49
|
+
# you care about by tagging them with `:focus` metadata. When nothing
|
|
50
|
+
# is tagged with `:focus`, all examples get run. RSpec also provides
|
|
51
|
+
# aliases for `it`, `describe`, and `context` that include `:focus`
|
|
52
|
+
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
|
53
|
+
config.filter_run_when_matching :focus
|
|
54
|
+
|
|
55
|
+
# Allows RSpec to persist some state between runs in order to support
|
|
56
|
+
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
|
57
|
+
# you configure your source control system to ignore this file.
|
|
58
|
+
config.example_status_persistence_file_path = "spec/examples.txt"
|
|
59
|
+
|
|
60
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
|
61
|
+
# recommended. For more details, see:
|
|
62
|
+
# - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
|
|
63
|
+
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
|
64
|
+
# - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
|
|
65
|
+
config.disable_monkey_patching!
|
|
66
|
+
|
|
67
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
|
68
|
+
# file, and it's useful to allow more verbose output when running an
|
|
69
|
+
# individual spec file.
|
|
70
|
+
if config.files_to_run.one?
|
|
71
|
+
# Use the documentation formatter for detailed output,
|
|
72
|
+
# unless a formatter has already been configured
|
|
73
|
+
# (e.g. via a command-line flag).
|
|
74
|
+
config.default_formatter = "doc"
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Print the 10 slowest examples and example groups at the
|
|
78
|
+
# end of the spec run, to help surface which specs are running
|
|
79
|
+
# particularly slow.
|
|
80
|
+
# config.profile_examples = 10
|
|
81
|
+
|
|
82
|
+
# Run specs in random order to surface order dependencies. If you find an
|
|
83
|
+
# order dependency and want to debug it, you can fix the order by providing
|
|
84
|
+
# the seed, which is printed after each run.
|
|
85
|
+
# --seed 1234
|
|
86
|
+
config.order = :random
|
|
87
|
+
|
|
88
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
|
89
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
|
90
|
+
# test failures related to randomization by passing the same `--seed` value
|
|
91
|
+
# as the one that triggered the failure.
|
|
92
|
+
Kernel.srand config.seed
|
|
93
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
|
3
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
|
4
|
+
|
|
5
|
+
require_relative "config/application"
|
|
6
|
+
|
|
7
|
+
Rails.application.load_tasks
|
|
8
|
+
|
|
9
|
+
task("spec").clear
|
|
10
|
+
RSpec::Core::RakeTask.new do |t|
|
|
11
|
+
t.verbose = false
|
|
12
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
|
2
|
+
// listed below.
|
|
3
|
+
//
|
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
|
6
|
+
//
|
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
|
8
|
+
// compiled file. JavaScript code in this file should be added after the last require_* statement.
|
|
9
|
+
//
|
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
|
11
|
+
// about supported directives.
|
|
12
|
+
//
|
|
13
|
+
//= require_tree .
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
|
3
|
+
* listed below.
|
|
4
|
+
*
|
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
|
7
|
+
*
|
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
|
11
|
+
* It is generally better to create a new file per style scope.
|
|
12
|
+
*
|
|
13
|
+
*= require_tree .
|
|
14
|
+
*= require_self
|
|
15
|
+
*/
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>TestApp</title>
|
|
5
|
+
<%= stylesheet_link_tag "omniauth/rails/application.css", media: "all" %>
|
|
6
|
+
<%= csrf_meta_tags %>
|
|
7
|
+
</head>
|
|
8
|
+
|
|
9
|
+
<body>
|
|
10
|
+
Navigation:
|
|
11
|
+
<ul>
|
|
12
|
+
<li><%= link_to "Public page", public_path %></li>
|
|
13
|
+
<li><%= link_to "Private page", private_path %></li>
|
|
14
|
+
</ul>
|
|
15
|
+
|
|
16
|
+
<% if authenticated? %>
|
|
17
|
+
Logged in as <%= authenticated_email %>
|
|
18
|
+
|
|
|
19
|
+
<%= button_to "Logout", omniauth_rails.sign_out_url, method: :delete %>
|
|
20
|
+
<% end %>
|
|
21
|
+
|
|
22
|
+
<%= yield %>
|
|
23
|
+
</body>
|
|
24
|
+
</html>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<h1>This is a private page</h1>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<h1>This is a public page</h1>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
require "pathname"
|
|
4
|
+
require "fileutils"
|
|
5
|
+
include FileUtils
|
|
6
|
+
|
|
7
|
+
# path to your application root.
|
|
8
|
+
APP_ROOT = Pathname.new File.expand_path("../../", __FILE__)
|
|
9
|
+
|
|
10
|
+
def system!(*args)
|
|
11
|
+
system(*args) || abort("\n== Command #{args} failed ==")
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
chdir APP_ROOT do
|
|
15
|
+
# This script is a starting point to setup your application.
|
|
16
|
+
# Add necessary setup steps to this file.
|
|
17
|
+
|
|
18
|
+
puts "== Installing dependencies =="
|
|
19
|
+
system! "gem install bundler --conservative"
|
|
20
|
+
system("bundle check") || system!("bundle install")
|
|
21
|
+
|
|
22
|
+
# puts "\n== Copying sample files =="
|
|
23
|
+
# unless File.exist?('config/database.yml')
|
|
24
|
+
# cp 'config/database.yml.sample', 'config/database.yml'
|
|
25
|
+
# end
|
|
26
|
+
|
|
27
|
+
puts "\n== Preparing database =="
|
|
28
|
+
system! "bin/rails db:setup"
|
|
29
|
+
|
|
30
|
+
puts "\n== Removing old logs and tempfiles =="
|
|
31
|
+
system! "bin/rails log:clear tmp:clear"
|
|
32
|
+
|
|
33
|
+
puts "\n== Restarting application server =="
|
|
34
|
+
system! "bin/rails restart"
|
|
35
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
require "pathname"
|
|
4
|
+
require "fileutils"
|
|
5
|
+
include FileUtils
|
|
6
|
+
|
|
7
|
+
# path to your application root.
|
|
8
|
+
APP_ROOT = Pathname.new File.expand_path("../../", __FILE__)
|
|
9
|
+
|
|
10
|
+
def system!(*args)
|
|
11
|
+
system(*args) || abort("\n== Command #{args} failed ==")
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
chdir APP_ROOT do
|
|
15
|
+
# This script is a way to update your development environment automatically.
|
|
16
|
+
# Add necessary update steps to this file.
|
|
17
|
+
|
|
18
|
+
puts "== Installing dependencies =="
|
|
19
|
+
system! "gem install bundler --conservative"
|
|
20
|
+
system("bundle check") || system!("bundle install")
|
|
21
|
+
|
|
22
|
+
puts "\n== Updating database =="
|
|
23
|
+
system! "bin/rails db:migrate"
|
|
24
|
+
|
|
25
|
+
puts "\n== Removing old logs and tempfiles =="
|
|
26
|
+
system! "bin/rails log:clear tmp:clear"
|
|
27
|
+
|
|
28
|
+
puts "\n== Restarting application server =="
|
|
29
|
+
system! "bin/rails restart"
|
|
30
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require_relative "boot"
|
|
3
|
+
|
|
4
|
+
# Pick the frameworks you want:
|
|
5
|
+
# require "active_record/railtie"
|
|
6
|
+
require "action_controller/railtie"
|
|
7
|
+
require "action_view/railtie"
|
|
8
|
+
# require "action_mailer/railtie"
|
|
9
|
+
# require "active_job/railtie"
|
|
10
|
+
# require "action_cable/engine"
|
|
11
|
+
# require "rails/test_unit/railtie"
|
|
12
|
+
require "sprockets/railtie"
|
|
13
|
+
|
|
14
|
+
Bundler.require(*Rails.groups)
|
|
15
|
+
require "omniauth/rails"
|
|
16
|
+
|
|
17
|
+
module TestApp
|
|
18
|
+
class Application < Rails::Application
|
|
19
|
+
# Settings in config/environments/* take precedence over those specified here.
|
|
20
|
+
# Application configuration should go into files in config/initializers
|
|
21
|
+
# -- all .rb files in that directory are automatically loaded.
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# Set up gems listed in the Gemfile.
|
|
3
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../Gemfile", __dir__)
|
|
4
|
+
|
|
5
|
+
require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])
|
|
6
|
+
$LOAD_PATH.unshift File.expand_path("../../../lib", __dir__)
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
Rails.application.configure do
|
|
3
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
|
4
|
+
|
|
5
|
+
# In the development environment your application's code is reloaded on
|
|
6
|
+
# every request. This slows down response time but is perfect for development
|
|
7
|
+
# since you don't have to restart the web server when you make code changes.
|
|
8
|
+
config.cache_classes = false
|
|
9
|
+
|
|
10
|
+
# Do not eager load code on boot.
|
|
11
|
+
config.eager_load = false
|
|
12
|
+
|
|
13
|
+
# Show full error reports.
|
|
14
|
+
config.consider_all_requests_local = true
|
|
15
|
+
|
|
16
|
+
# Enable/disable caching. By default caching is disabled.
|
|
17
|
+
if Rails.root.join("tmp/caching-dev.txt").exist?
|
|
18
|
+
config.action_controller.perform_caching = true
|
|
19
|
+
|
|
20
|
+
config.cache_store = :memory_store
|
|
21
|
+
config.public_file_server.headers = {
|
|
22
|
+
"Cache-Control" => "public, max-age=172800",
|
|
23
|
+
}
|
|
24
|
+
else
|
|
25
|
+
config.action_controller.perform_caching = false
|
|
26
|
+
|
|
27
|
+
config.cache_store = :null_store
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Don't care if the mailer can't send.
|
|
31
|
+
# config.action_mailer.raise_delivery_errors = false
|
|
32
|
+
|
|
33
|
+
# config.action_mailer.perform_caching = false
|
|
34
|
+
|
|
35
|
+
# Print deprecation notices to the Rails logger.
|
|
36
|
+
config.active_support.deprecation = :log
|
|
37
|
+
|
|
38
|
+
# Raise an error on page load if there are pending migrations.
|
|
39
|
+
# config.active_record.migration_error = :page_load
|
|
40
|
+
|
|
41
|
+
# Debug mode disables concatenation and preprocessing of assets.
|
|
42
|
+
# This option may cause significant delays in view rendering with a large
|
|
43
|
+
# number of complex assets.
|
|
44
|
+
# config.assets.debug = true
|
|
45
|
+
|
|
46
|
+
# Suppress logger output for asset requests.
|
|
47
|
+
# config.assets.quiet = true
|
|
48
|
+
|
|
49
|
+
# Raises error for missing translations
|
|
50
|
+
# config.action_view.raise_on_missing_translations = true
|
|
51
|
+
|
|
52
|
+
# Use an evented file watcher to asynchronously detect changes in source code,
|
|
53
|
+
# routes, locales, etc. This feature depends on the listen gem.
|
|
54
|
+
# config.file_watcher = ActiveSupport::EventedFileUpdateChecker
|
|
55
|
+
end
|