2019-04-29 20:27:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-10-09 09:52:48 -04:00
|
|
|
Fabricator(:user_api_key) do
|
|
|
|
user
|
2024-11-08 12:05:03 -05:00
|
|
|
|
|
|
|
after_create do |key, transients|
|
|
|
|
if key.client.blank?
|
|
|
|
client = Fabricate(:user_api_key_client)
|
|
|
|
key.user_api_key_client_id = client.id
|
|
|
|
key.save!
|
|
|
|
end
|
|
|
|
end
|
2020-10-09 09:52:48 -04:00
|
|
|
end
|
|
|
|
|
2020-09-29 05:57:48 -04:00
|
|
|
Fabricator(:user_api_key_scope)
|
|
|
|
|
2024-11-19 15:28:04 -05:00
|
|
|
Fabricator(:user_api_key_client_scope)
|
|
|
|
|
2024-11-08 12:05:03 -05:00
|
|
|
Fabricator(:user_api_key_client) do
|
2024-11-19 15:28:04 -05:00
|
|
|
transient :scopes
|
|
|
|
|
2024-11-08 12:05:03 -05:00
|
|
|
client_id { SecureRandom.hex }
|
|
|
|
application_name "some app"
|
2024-11-19 15:28:04 -05:00
|
|
|
|
|
|
|
after_create do |client, transients|
|
|
|
|
if transients[:scopes].present?
|
|
|
|
[*transients[:scopes]].each { |scope| client.scopes.create!(name: scope) }
|
|
|
|
end
|
|
|
|
end
|
2024-11-08 12:05:03 -05:00
|
|
|
end
|
|
|
|
|
2016-09-02 02:57:41 -04:00
|
|
|
Fabricator(:readonly_user_api_key, from: :user_api_key) do
|
2020-09-29 05:57:48 -04:00
|
|
|
scopes { [Fabricate.build(:user_api_key_scope, name: "read")] }
|
2016-09-02 02:57:41 -04:00
|
|
|
end
|
2020-10-08 12:38:54 -04:00
|
|
|
|
|
|
|
Fabricator(:bookmarks_calendar_user_api_key, from: :user_api_key) do
|
|
|
|
scopes { [Fabricate.build(:user_api_key_scope, name: "bookmarks_calendar")] }
|
|
|
|
end
|