Port RS auth job removal to Solid Queue
This commit is contained in:
parent
d1eea85b04
commit
ee5c6d86d0
@ -69,11 +69,19 @@ class RemoteStorageAuthorization < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def remove_token_expiry_job
|
def remove_token_expiry_job
|
||||||
queue = Sidekiq::Queue.new(RemoteStorageExpireAuthorizationJob.queue_name)
|
job_class = RemoteStorageExpireAuthorizationJob
|
||||||
queue.each do |job|
|
job_args = [id]
|
||||||
next unless job.display_class == "RemoteStorageExpireAuthorizationJob"
|
|
||||||
job.delete if job.display_args == [id]
|
query = SolidQueue::Job.where(class_name: job_class.to_s)
|
||||||
end
|
|
||||||
|
case ActiveRecord::Base.connection.adapter_name.downcase
|
||||||
|
when /sqlite/
|
||||||
|
query.where("json_extract(arguments, '$.arguments') = ?", job_args.to_json)
|
||||||
|
when /postgres/
|
||||||
|
query.where("arguments->>'arguments' = ?", job_args.to_json)
|
||||||
|
else
|
||||||
|
raise "Unsupported database adapter"
|
||||||
|
end.destroy_all
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_or_create_web_app
|
def find_or_create_web_app
|
||||||
|
@ -5,6 +5,7 @@ RSpec.describe Rs::OauthController, type: :controller do
|
|||||||
|
|
||||||
before do
|
before do
|
||||||
allow_any_instance_of(AppCatalog::WebApp).to receive(:update_metadata).and_return(true)
|
allow_any_instance_of(AppCatalog::WebApp).to receive(:update_metadata).and_return(true)
|
||||||
|
allow_any_instance_of(RemoteStorageAuthorization).to receive(:remove_token_expiry_job).and_return(nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "GET /rs/oauth/:username" do
|
describe "GET /rs/oauth/:username" do
|
||||||
|
@ -5,6 +5,7 @@ RSpec.describe Services::RsAuthsController, type: :controller do
|
|||||||
|
|
||||||
before do
|
before do
|
||||||
allow_any_instance_of(AppCatalog::WebApp).to receive(:update_metadata).and_return(true)
|
allow_any_instance_of(AppCatalog::WebApp).to receive(:update_metadata).and_return(true)
|
||||||
|
allow_any_instance_of(RemoteStorageAuthorization).to receive(:remove_token_expiry_job).and_return(nil)
|
||||||
allow_any_instance_of(Flipper).to receive(:enabled?).and_return(true)
|
allow_any_instance_of(Flipper).to receive(:enabled?).and_return(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -5,6 +5,9 @@ RSpec.describe RemoteStorageExpireAuthorizationJob, type: :job do
|
|||||||
allow_any_instance_of(AppCatalog::WebApp).to(
|
allow_any_instance_of(AppCatalog::WebApp).to(
|
||||||
receive(:update_metadata).and_return(true)
|
receive(:update_metadata).and_return(true)
|
||||||
)
|
)
|
||||||
|
allow_any_instance_of(RemoteStorageAuthorization).to(
|
||||||
|
receive(:remove_token_expiry_job).and_return(nil)
|
||||||
|
)
|
||||||
|
|
||||||
@user = create :user, cn: "ronald", ou: "kosmos.org"
|
@user = create :user, cn: "ronald", ou: "kosmos.org"
|
||||||
@rs_authorization = create :remote_storage_authorization,
|
@rs_authorization = create :remote_storage_authorization,
|
||||||
|
@ -7,6 +7,7 @@ RSpec.describe RemoteStorageAuthorization, type: :model do
|
|||||||
|
|
||||||
before do
|
before do
|
||||||
allow_any_instance_of(AppCatalog::WebApp).to receive(:update_metadata).and_return(true)
|
allow_any_instance_of(AppCatalog::WebApp).to receive(:update_metadata).and_return(true)
|
||||||
|
allow_any_instance_of(RemoteStorageAuthorization).to receive(:remove_token_expiry_job).and_return(nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#create" do
|
describe "#create" do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user