mirror of
https://github.com/we-promise/sure.git
synced 2026-09-05 06:41:08 +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>
71 lines
2.1 KiB
Ruby
71 lines
2.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require "swagger_helper"
|
|
|
|
RSpec.describe "API V1 Push Subscriptions", type: :request do
|
|
let(:family) { Family.create!(name: "API Family") }
|
|
let(:user) do
|
|
family.users.create!(email: "push-api@example.com", password: "password123", ai_enabled: true)
|
|
end
|
|
let(:api_key) do
|
|
key = ApiKey.generate_secure_key
|
|
ApiKey.create!(user: user, name: "API Docs Key", key: key, scopes: %w[read_write], source: "web")
|
|
end
|
|
let(:"X-Api-Key") { api_key.plain_key }
|
|
|
|
path "/api/v1/push_subscriptions" do
|
|
post "Register an APNs device token" do
|
|
tags "Push Subscriptions"
|
|
security [ { apiKeyAuth: [] } ]
|
|
consumes "application/json"
|
|
produces "application/json"
|
|
parameter name: :subscription, in: :body, required: true, schema: {
|
|
type: :object,
|
|
required: %w[token environment platform],
|
|
properties: {
|
|
token: { type: :string },
|
|
environment: { type: :string, enum: %w[sandbox production] },
|
|
platform: { type: :string, enum: %w[ios] }
|
|
}
|
|
}
|
|
let(:subscription) { { token: "ab" * 32, environment: "sandbox", platform: "ios" } }
|
|
|
|
response "201", "token registered" do
|
|
schema "$ref" => "#/components/schemas/PushSubscription"
|
|
run_test!
|
|
end
|
|
|
|
|
|
response "422", "invalid or conflicting subscription" do
|
|
schema "$ref" => "#/components/schemas/ErrorResponse"
|
|
let(:subscription) { { token: "ab" * 32, environment: "staging", platform: "ios" } }
|
|
|
|
run_test!
|
|
end
|
|
end
|
|
end
|
|
|
|
|
|
path "/api/v1/push_subscriptions/{id}" do
|
|
parameter name: :id, in: :path, type: :string, required: true
|
|
let(:subscription) do
|
|
user.push_subscriptions.create!(
|
|
token: "cd" * 32,
|
|
environment: "sandbox",
|
|
platform: "ios",
|
|
last_registered_at: Time.current
|
|
)
|
|
end
|
|
let(:id) { subscription.id }
|
|
|
|
delete "Unregister an APNs device token" do
|
|
tags "Push Subscriptions"
|
|
security [ { apiKeyAuth: [] } ]
|
|
|
|
response "204", "token unregistered" do
|
|
run_test!
|
|
end
|
|
end
|
|
end
|
|
end
|