feat(ntfy): dispatch api_key_revoked from ApiKey#revoke!
This commit is contained in:
31
test/models/api_key_test.rb
Normal file
31
test/models/api_key_test.rb
Normal file
@@ -0,0 +1,31 @@
|
||||
require "test_helper"
|
||||
|
||||
class ApiKeyTest < ActiveSupport::TestCase
|
||||
include ActiveJob::TestHelper
|
||||
|
||||
setup do
|
||||
ActiveJob::Base.queue_adapter = :test
|
||||
@admin = AdminUser.create!(
|
||||
name: "Key Admin", email: "key@example.com",
|
||||
password: "password123",
|
||||
ntfy_topic: "key-topic", ntfy_token: "tk_key",
|
||||
ntfy_enabled: true, ntfy_server_url: "https://ntfy.example.com"
|
||||
)
|
||||
stub_request(:post, "https://ntfy.example.com/key-topic").to_return(status: 200)
|
||||
end
|
||||
|
||||
test "revoke! dispatches api_key_revoked notification" do
|
||||
api_key = ApiKey.create!(
|
||||
name: "Test Key",
|
||||
key_digest: "e" * 64,
|
||||
key_prefix: "api_live_ab",
|
||||
permissions: {}, active: true
|
||||
)
|
||||
|
||||
assert_enqueued_jobs 1 do
|
||||
api_key.revoke!
|
||||
end
|
||||
|
||||
assert_not api_key.reload.active
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user