Merge branch 'feature/nostr-remote_signing' into live
This commit is contained in:
3 files changed
+50
-1
No files matched your search
@@ -0,0 +1,7 @@
|
||||
class PurgeRsAuthorizationCodesJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform
|
||||
RsAuthorizationCode.where(expires_at: ..1.hour.ago).delete_all
|
||||
end
|
||||
end
|
||||
@@ -16,7 +16,10 @@ development:
|
||||
|
||||
production:
|
||||
purge_rs_authorization_codes:
|
||||
command: "RsAuthorizationCode.where(expires_at: ..1.hour.ago).delete_all"
|
||||
class: PurgeRsAuthorizationCodesJob
|
||||
schedule: every hour
|
||||
cleanup_nostr_signer_sessions:
|
||||
class: NostrSignerCleanupJob
|
||||
schedule: every hour
|
||||
cleanup_nostr_signer_sessions:
|
||||
class: NostrSignerCleanupJob
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe PurgeRsAuthorizationCodesJob, type: :job do
|
||||
let(:user) { create :user }
|
||||
|
||||
def create_code(**attrs)
|
||||
RsAuthorizationCode.create!(
|
||||
user: user,
|
||||
client_id: "example.com",
|
||||
redirect_uri: "https://example.com",
|
||||
permissions: %w(documents:rw),
|
||||
code_challenge: "E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM",
|
||||
code_challenge_method: "S256",
|
||||
**attrs
|
||||
)
|
||||
end
|
||||
|
||||
it "deletes codes expired beyond the grace period" do
|
||||
expired = create_code(expires_at: 2.hours.ago)
|
||||
|
||||
expect {
|
||||
perform_enqueued_jobs { described_class.perform_later }
|
||||
}.to change(RsAuthorizationCode, :count).by(-1)
|
||||
|
||||
expect(RsAuthorizationCode.exists?(expired.id)).to be(false)
|
||||
end
|
||||
|
||||
it "keeps recently expired and still active codes" do
|
||||
recently_expired = create_code(expires_at: 30.minutes.ago)
|
||||
active = create_code(expires_at: 10.minutes.from_now)
|
||||
|
||||
expect {
|
||||
perform_enqueued_jobs { described_class.perform_later }
|
||||
}.not_to change(RsAuthorizationCode, :count)
|
||||
|
||||
expect(RsAuthorizationCode.exists?(recently_expired.id)).to be(true)
|
||||
expect(RsAuthorizationCode.exists?(active.id)).to be(true)
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user