mirror of
https://github.com/astuto/astuto.git
synced 2025-12-16 11:47:56 +01:00
Add OAuth2 authentication (#147)
- Added Site settings > Authentication section - Create/edit/delete your custom oauth2 configurations - Login or signup with oauth2
This commit is contained in:
committed by
GitHub
parent
3bda6dee08
commit
4c73b398e8
64
spec/models/o_auth_spec.rb
Normal file
64
spec/models/o_auth_spec.rb
Normal file
@@ -0,0 +1,64 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe OAuth, type: :model do
|
||||
let(:o_auth) { FactoryBot.create(:o_auth) }
|
||||
|
||||
it 'should be valid' do
|
||||
expect(o_auth).to be_valid
|
||||
end
|
||||
|
||||
it 'has a non-nil unique name' do
|
||||
o_auth2 = FactoryBot.build_stubbed(:o_auth, name: o_auth.name)
|
||||
|
||||
expect(o_auth2).to be_invalid
|
||||
end
|
||||
|
||||
it 'is disabled by default' do
|
||||
o_auth = OAuth.new
|
||||
|
||||
expect(o_auth.is_enabled).to eq(false)
|
||||
end
|
||||
|
||||
it 'has a boolean enabled status' do
|
||||
o_auth = FactoryBot.build_stubbed(:o_auth, is_enabled: nil)
|
||||
expect(o_auth).to be_invalid
|
||||
|
||||
o_auth = FactoryBot.build_stubbed(:o_auth, is_enabled: true)
|
||||
expect(o_auth).to be_valid
|
||||
|
||||
o_auth = FactoryBot.build_stubbed(:o_auth, is_enabled: false)
|
||||
expect(o_auth).to be_valid
|
||||
end
|
||||
|
||||
it 'has non-nil client credentials' do
|
||||
o_auth = FactoryBot.build_stubbed(:o_auth, client_id: nil)
|
||||
expect(o_auth).to be_invalid
|
||||
|
||||
o_auth = FactoryBot.build_stubbed(:o_auth, client_secret: nil)
|
||||
expect(o_auth).to be_invalid
|
||||
end
|
||||
|
||||
it 'has non-nil urls' do
|
||||
o_auth = FactoryBot.build_stubbed(:o_auth, authorize_url: nil)
|
||||
expect(o_auth).to be_invalid
|
||||
|
||||
o_auth = FactoryBot.build_stubbed(:o_auth, token_url: nil)
|
||||
expect(o_auth).to be_invalid
|
||||
|
||||
o_auth = FactoryBot.build_stubbed(:o_auth, profile_url: nil)
|
||||
expect(o_auth).to be_invalid
|
||||
end
|
||||
|
||||
it 'has a non-nil scope' do
|
||||
o_auth = FactoryBot.build_stubbed(:o_auth, scope: nil)
|
||||
expect(o_auth).to be_invalid
|
||||
end
|
||||
|
||||
it 'has a non-nil json user email path and a nullable name path' do
|
||||
o_auth = FactoryBot.build_stubbed(:o_auth, json_user_email_path: nil)
|
||||
expect(o_auth).to be_invalid
|
||||
|
||||
o_auth = FactoryBot.build_stubbed(:o_auth, json_user_name_path: nil)
|
||||
expect(o_auth).to be_valid
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user