Documentation
¶
Overview ¶
Package pushtest provides a scripted push.Pusher and an in-process APNs server.
Design ¶
Fake records targets and returns configured results for service and notifier tests. Server exposes a TLS HTTP/2 endpoint with per-token scripts and a default successful response. Tests can exercise invalid tokens, rate limits, request rejections and transport behavior without contacting APNs. These helpers do not establish live-device delivery.
References ¶
- Decision record 0007: https://github.com/deploymenttheory/go-apple-dm/blob/main/docs/research/decisions/0007-apns-push.md
- Decision record 0015: https://github.com/deploymenttheory/go-apple-dm/blob/main/docs/research/decisions/0015-push-cert-store.md
- End-to-end scenarios: https://github.com/deploymenttheory/go-apple-dm/blob/main/docs/testing/e2e-scenarios.md (E2E-007)
- Apple: https://developer.apple.com/documentation/usernotifications/sending-notification-requests-to-apns
- Apple: https://developer.apple.com/documentation/devicemanagement/dealing-with-inactive-managed-devices-and-invalid-push-tokens
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrScripted = errors.New("pushtest: scripted failure")
ErrScripted is a convenience error for Fake results.
Functions ¶
func ClientCertStore ¶
func ClientCertStore(topic string, cert tls.Certificate) push.StaticCertStore
ClientCertStore returns a push.CertStore whose certificate the Server trusts for mutual TLS, plus an option-compatible HTTP client factory.
Types ¶
type Fake ¶
type Fake struct {
// Results by enrollment id; targets not listed are reported as Sent.
Results map[mdm.EnrollmentID]push.Result
// Err, when set, fails the whole batch.
Err error
Calls [][]push.Target
// contains filtered or unexported fields
}
Fake records pushes and returns scripted results.
type Request ¶
type Request struct {
Token string
Topic string
PushType string
Priority string
Magic string
Headers http.Header
}
Request is one notification the Server received.
type Server ¶
Server is an in-process APNs endpoint. Tokens without a script get 200.
func NewServer ¶
func NewServer() *Server
NewServer starts a TLS server. Use ClientCertificate to require mutual TLS.
func NewServerWithClientCAs ¶ added in v0.3.0
NewServerWithClientCAs optionally verifies provider certificates during TLS.
func (*Server) ScriptToken ¶
ScriptToken sets the response for a device token (hex).