Files
fizzy/test/lib/web_push/persistent_request_test.rb
T
Kevin McConnell 23fe40fa81 Correctly initialise WebPush connection (#2417)
The `ipaddr` arg here is being interpreted as a positional arg (since
the keyword arg doesn't exist), which results in an invalid connection
object. This was causing push notifications to silently fail.

We should initialise the property on the object instead.
2026-01-22 12:03:02 -08:00

27 lines
756 B
Ruby

require "test_helper"
class WebPush::PersistentRequestTest < ActiveSupport::TestCase
PUBLIC_TEST_IP = "142.250.185.206"
ENDPOINT = "https://fcm.googleapis.com/fcm/send/test123"
test "pins connection to endpoint_ip" do
request = stub_request(:post, ENDPOINT)
.with(ipaddr: PUBLIC_TEST_IP)
.to_return(status: 201)
notification = WebPush::Notification.new(
title: "Test",
body: "Test notification",
path: "/test",
badge: 0,
endpoint: ENDPOINT,
endpoint_ip: PUBLIC_TEST_IP,
p256dh_key: "BNcRdreALRFXTkOOUHK1EtK2wtaz5Ry4YfYCA_0QTpQtUbVlUls0VJXg7A8u-Ts1XbjhazAkj7I99e8QcYP7DkM",
auth_key: "tBHItJI5svbpez7KI4CCXg"
)
notification.deliver
assert_requested request
end
end