mirror of
https://github.com/we-promise/sure.git
synced 2026-09-07 15:44:21 +00:00
* Add Swift-native Sure app * Fix push subscriptions schema for CI * Address native app review feedback * Address remaining native app review feedback * Use Flutter app logo for native icon * Honor insight notification preferences and locale --------- Co-authored-by: Juan Jose Mata <2v8shcb6pz@privaterelay.appleid.com> Co-authored-by: sure-admin <sure-admin@splashblot.com>
41 lines
1.3 KiB
Ruby
41 lines
1.3 KiB
Ruby
require "test_helper"
|
|
|
|
class Apns::ClientTest < ActiveSupport::TestCase
|
|
setup do
|
|
@environment = {
|
|
"APNS_KEY_ID" => "key-id",
|
|
"APNS_TEAM_ID" => "team-id",
|
|
"APNS_BUNDLE_ID" => "com.example.sure",
|
|
"APNS_PRIVATE_KEY_BASE64" => Base64.strict_encode64("private-key")
|
|
}
|
|
end
|
|
|
|
test "sends sandbox notifications with token authentication" do
|
|
connection = mock
|
|
response = stub(ok?: true)
|
|
Apnotic::Connection.expects(:development).with do |options|
|
|
options[:auth_method] == :token &&
|
|
options[:key_id] == "key-id" &&
|
|
options[:team_id] == "team-id" &&
|
|
options[:cert_path].read == "private-key"
|
|
end.returns(connection)
|
|
connection.expects(:push).with do |notification|
|
|
notification.topic == "com.example.sure" &&
|
|
notification.push_type == "alert" &&
|
|
notification.custom_payload == { insight_id: "insight-id", destination: "insights" }
|
|
end.returns(response)
|
|
connection.expects(:close)
|
|
|
|
ClimateControl.modify(@environment) do
|
|
result = Apns::Client.new(environment: "sandbox").deliver(
|
|
token: "ab" * 32,
|
|
title: "New financial insight",
|
|
body: "Open Sure to review your latest AI insight.",
|
|
insight_id: "insight-id"
|
|
)
|
|
|
|
assert result.ok?
|
|
end
|
|
end
|
|
end
|