{"id":13714393,"url":"https://github.com/baobabus/go-apnsmock","last_synced_at":"2026-01-18T09:24:01.147Z","repository":{"id":57529736,"uuid":"112776888","full_name":"baobabus/go-apnsmock","owner":"baobabus","description":"A highly-configurable emulator of Apple Push Notification HTTP/2 service written in Go – embeddable server and command line utility.","archived":false,"fork":false,"pushed_at":"2017-12-14T00:53:48.000Z","size":28,"stargazers_count":6,"open_issues_count":1,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-07T01:41:13.526Z","etag":null,"topics":["apns","apns-http2","apns2","go","go-testing","golang","http2"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/baobabus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-01T19:09:36.000Z","updated_at":"2025-03-17T21:46:04.000Z","dependencies_parsed_at":"2022-08-30T14:50:21.851Z","dependency_job_id":null,"html_url":"https://github.com/baobabus/go-apnsmock","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/baobabus/go-apnsmock","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baobabus%2Fgo-apnsmock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baobabus%2Fgo-apnsmock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baobabus%2Fgo-apnsmock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baobabus%2Fgo-apnsmock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/baobabus","download_url":"https://codeload.github.com/baobabus/go-apnsmock/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baobabus%2Fgo-apnsmock/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28534159,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-18T00:39:45.795Z","status":"online","status_checked_at":"2026-01-18T02:00:07.578Z","response_time":98,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apns","apns-http2","apns2","go","go-testing","golang","http2"],"created_at":"2024-08-02T23:01:58.604Z","updated_at":"2026-01-18T09:24:01.123Z","avatar_url":"https://github.com/baobabus.png","language":"Go","funding_links":[],"categories":["Repositories"],"sub_categories":[],"readme":"# Go APNS Mock\n\nAPNS Mock is a configurable emulator of Apple Push Notification HTTP/2 service written in Go.\nAn embeddable server as well as a standalone command line utility are provided.\n\n[![Build Status](https://travis-ci.org/baobabus/go-apnsmock.svg?branch=master)](https://travis-ci.org/baobabus/go-apnsmock)\n[![GoDoc](https://godoc.org/github.com/baobabus/go-apnsmock/apns2mock?status.svg)](https://godoc.org/github.com/baobabus/go-apnsmock/apns2mock)\n\n## Features\n\n- Emulation of new Apple Push Notification service over HTTP/2 protocol\n- Configurable connection handling options (stream concurrency, latency, etc.)\n- Emulation of token-based authentication (JWT)\n- Emulation of TLS client certificate-based authentication (coming)\n- Preconfigured set of request handling scenarios including many deterministic failure cases\n- Support for custom request handling scenarios\n- Supports Go 1.7 and later\n\n## Handling of mock communications\n\nThe ability to mock various communication scenarios is the primary goal of APNS Mock package.\nThe following comms-related parameters can be customized to help with testing of your APNS clients.\n\n- Connection delay - simulate long connection delays or set it to 0\n- Response time - configure how long the server takes to respond to a request\n- Maximum number of open connections - test how well your client handles refused connections\n- Maximum number of concurrent HTTP/2 streams - test how your client handles low and high numbers\n\nIn addition to the above, you can programmaticaly instruct the mock server to become unavailable\nor to resume normal processing at any point so that you can test your client's handling of such scenarios.\n\n\n## Request validation\n\nThe following validation is performed by the default request handler:\n\n- Request methods other than POST return 405, \"MethodNotAllowed\"\n- Non-hexadecimal device tokens return 400, \"BadDeviceToken\"\n- Missing or incorrect authorization header returns 403, \"MissingProviderToken\"\n- Malformed JWT headres/claims return 403, \"InvalidProviderToken\"\n- Tokens with incorrct signing algorithm return 403, \"InvalidProviderToken\"\n- Missing request body returns 400, \"PayloadEmpty\"\n- Invalid UUID format in APNS Id returns 400, \"BadMessageId\"\n- Priority that is not empty, 5 or 10 returns 400, \"BadPriority\"\n- Empty topic returns 400, \"MissingTopic\"\n- Collapse Ids longer than 64 return 400, \"BadCollapseId\"\n- Expiration date that cannot be parsed returns 400, \"BadExpirationDate\"\n- Expired tokens return 403, \"ExpiredProviderToken\"\n\nOr use AllOkayHandler if request validation is not desired. \n\n## Precofigured failure scenarios\n\nThe following scenarios produce mock rejection responses:\n\n- Device tokens starting with '1' return 400, \"BadDeviceToken\"\n- Device tokens starting with '2' return 410, \"Unregistered\"\n- Device tokens starting with the same letter/digit as APNS topic return 400, \"DeviceTokenNotForTopic\"\n- Topics starting with 'd' return 400, \"TopicDisallowed\"\n- Team IDs (JWT \"iss\" claims) starting with '1' return 403, \"InvalidProviderToken\"\n\nSetting you request handler to AllOkayHandler will turn off mock push rejections. \n\n\n## Command line\n\n`go-apnsmock` is a command line tool that can be used to run a standalone APNS emulator.\n\nUsage:\n\n```\ngo-apnsmock \u003cflags\u003e\n\nFlags:\n\n  -addr address\n    \tnetwork address to serve on (default \"127.0.0.1:8443\")\n  -allok\n    \tif allok is true, server will respond with 200 status to all requests\n  -cert path\n    \tpath to server TLS certificate (default \"certs/server.crt\")\n  -conn-delay time\n    \tamount of time by which client connect attempts should be delayed (default 100ms)\n  -conns number\n    \tmaximum number of concurrent HTTP/2 connections (default 5)\n  -key path\n    \tpath to TLS certificate key (default \"certs/server.key\")\n  -resp-delay time\n    \tamount of time by which responses should be delayed (default 5ms)\n  -streams number\n    \tnumber of concurrent HTTP/2 streams (default 500)\n  -verbose\n    \tif true, verbose enables http2 verbose logging\n```\n\n## Embedding in automated tests\n\nInstances of `apns2mock.Server` can be easily embedded in automated tests.\nAny number of server instances can be concurrently instantiated while providing complete isolation from each other.\n\nUnit test example\n\n```go\npackage apns2\n\nimport (\n\t\"strings\"\n\t\"testing\"\n\n\t\"github.com/baobabus/go-apnsmock/apns2mock\"\n)\n\nfunc TestRoundtrip(t *testing.T) {\n\ts, err := apns2mock.NewServer(apns2mock.NoDelayCommsCfg, apns2mock.AllOkayHandler, apns2mock.AutoCert, apns2mock.AutoKey)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tdefer s.Close()\n\n\t// client is preconfigured for communication with the server\n\tclient := s.Client()\n\turl := s.URL + apns2mock.RequestRoot\n\tcont := \"application/json; charset=utf-8\"\n\n\t// Expecting to get 200 back\n\tresp, err := client.Post(url, cont, strings.NewReader(\"{}\"))\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif resp == nil {\n\t\tt.Fatal(\"Should have gotten a response\")\n\t}\n\tif resp.StatusCode != 200 {\n\t\tt.Fatal(\"Should have gotten status 200\")\n\t}\n\n\ts.BecomeUnavailable(503, \"Shutdown\")\n\n\t// Now expecting 503\n\tresp, err = client.Post(url, cont, strings.NewReader(\"{}\"))\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif resp == nil {\n\t\tt.Fatal(\"Should have gotten a response\")\n\t}\n\tif resp.StatusCode != 503 {\n\t\tt.Fatal(\"Should have gotten status 503\")\n\t}\n}\n```\n\n## License\n\nThe MIT License (MIT)\n\nCopyright (c) 2017 Aleksey Blinov\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaobabus%2Fgo-apnsmock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbaobabus%2Fgo-apnsmock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaobabus%2Fgo-apnsmock/lists"}