mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-10 01:01:39 -05:00
* Implement OmniAuth GitHub authentication * Fix omniauth GitHub scope to include user email access * Remove margin-bottom * Implement Google OAuth2 authentication * Implement OIDC authentication for Dawarich using omniauth_openid_connect gem. * Add patreon account linking and patron checking service * Update docker-compose.yml to use boolean values instead of strings * Add support for KML files * Add tests * Update changelog * Remove patreon OAuth integration * Move omniauthable to a concern * Update an icon in integrations * Update changelog * Update app version * Fix family location sharing toggle * Move family location sharing to its own controller * Update changelog * Implement basic tagging functionality for places, allowing users to categorize and label places with custom tags. * Add places management API and tags feature * Add some changes related to places management feature * Fix some tests * Fix sometests * Add places layer * Update places layer to use Leaflet.Control.Layers.Tree for hierarchical layer control * Rework tag form * Add hashtag * Add privacy zones to tags * Add notes to places and manage place tags * Update changelog * Update e2e tests * Extract tag serializer to its own file * Fix some tests * Fix tags request specs * Fix some tests * Fix rest of the tests * Revert some changes * Add missing specs * Revert changes in place export/import code * Fix some specs * Fix PlaceFinder to only consider global places when finding existing places * Fix few more specs * Fix visits creator spec * Fix last tests * Update place creating modal * Add home location based on "Home" tagged place * Save enabled tag layers * Some fixes * Fix bug where enabling place tag layers would trigger saving enabled layers, overwriting with incomplete data * Update migration to use disable_ddl_transaction! and add up/down methods * Fix tag layers restoration and filtering logic * Update OIDC auto-registration and email/password registration settings * Fix potential xss
105 lines
2.7 KiB
Ruby
105 lines
2.7 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
OmniAuth.config.test_mode = true
|
|
|
|
module OmniauthHelpers
|
|
def mock_github_auth(email: 'test@github.com')
|
|
OmniAuth.config.mock_auth[:github] = OmniAuth::AuthHash.new({
|
|
provider: 'github',
|
|
uid: '123545',
|
|
info: {
|
|
email: email,
|
|
name: 'Test User',
|
|
image: 'https://avatars.githubusercontent.com/u/123545'
|
|
},
|
|
credentials: {
|
|
token: 'mock_token',
|
|
expires_at: Time.now + 1.week
|
|
},
|
|
extra: {
|
|
raw_info: {
|
|
login: 'testuser',
|
|
avatar_url: 'https://avatars.githubusercontent.com/u/123545',
|
|
name: 'Test User',
|
|
email: email
|
|
}
|
|
}
|
|
})
|
|
end
|
|
|
|
def mock_google_auth(email: 'test@gmail.com')
|
|
OmniAuth.config.mock_auth[:google_oauth2] = OmniAuth::AuthHash.new({
|
|
provider: 'google_oauth2',
|
|
uid: '123545',
|
|
info: {
|
|
email: email,
|
|
name: 'Test User',
|
|
image: 'https://lh3.googleusercontent.com/a/test'
|
|
},
|
|
credentials: {
|
|
token: 'mock_token',
|
|
refresh_token: 'mock_refresh_token',
|
|
expires_at: Time.now + 1.hour
|
|
},
|
|
extra: {
|
|
raw_info: {
|
|
email: email,
|
|
email_verified: true,
|
|
name: 'Test User',
|
|
given_name: 'Test',
|
|
family_name: 'User',
|
|
picture: 'https://lh3.googleusercontent.com/a/test'
|
|
}
|
|
}
|
|
})
|
|
end
|
|
|
|
def mock_openid_connect_auth(email: 'test@oidc.com', provider_name: 'Authelia')
|
|
OmniAuth.config.mock_auth[:openid_connect] = OmniAuth::AuthHash.new({
|
|
provider: 'openid_connect',
|
|
uid: '123545',
|
|
info: {
|
|
email: email,
|
|
name: 'Test User',
|
|
image: 'https://example.com/avatar.jpg'
|
|
},
|
|
credentials: {
|
|
token: 'mock_token',
|
|
refresh_token: 'mock_refresh_token',
|
|
expires_at: Time.now + 1.hour,
|
|
id_token: 'mock_id_token'
|
|
},
|
|
extra: {
|
|
raw_info: {
|
|
sub: '123545',
|
|
email: email,
|
|
email_verified: true,
|
|
name: 'Test User',
|
|
preferred_username: 'testuser',
|
|
given_name: 'Test',
|
|
family_name: 'User',
|
|
picture: 'https://example.com/avatar.jpg'
|
|
}
|
|
}
|
|
})
|
|
end
|
|
|
|
def mock_oauth_failure(provider)
|
|
OmniAuth.config.mock_auth[provider] = :invalid_credentials
|
|
end
|
|
end
|
|
|
|
RSpec.configure do |config|
|
|
config.include OmniauthHelpers, type: :request
|
|
config.include OmniauthHelpers, type: :system
|
|
|
|
config.before do
|
|
OmniAuth.config.test_mode = true
|
|
end
|
|
|
|
config.after do
|
|
OmniAuth.config.mock_auth[:github] = nil
|
|
OmniAuth.config.mock_auth[:google_oauth2] = nil
|
|
OmniAuth.config.mock_auth[:openid_connect] = nil
|
|
end
|
|
end
|