| 1 |
# ntfy End-to-End Tests |
| 2 |
|
| 3 |
This directory contains end-to-end (e2e) tests for the ntfy service in Shoutrrr. |
| 4 |
|
| 5 |
## Overview |
| 6 |
|
| 7 |
The end-to-end tests validate the complete ntfy notification functionality by sending messages to a real ntfy server and verifying they are received. |
| 8 |
|
| 9 |
## Test Coverage |
| 10 |
|
| 11 |
### Basic Message Functionality |
| 12 |
|
| 13 |
- Plain text messages |
| 14 |
- Empty messages |
| 15 |
- Message delivery verification via ntfy API |
| 16 |
|
| 17 |
### Message Features |
| 18 |
|
| 19 |
- Title |
| 20 |
- Priority levels |
| 21 |
- Tags/emojis |
| 22 |
- Markdown formatting |
| 23 |
- Click actions |
| 24 |
- Attachments |
| 25 |
- Action buttons |
| 26 |
- Delayed delivery |
| 27 |
- Email notifications |
| 28 |
- Icon |
| 29 |
- Filename |
| 30 |
- Multiple tags |
| 31 |
- Combined parameters |
| 32 |
|
| 33 |
### Configuration |
| 34 |
|
| 35 |
- Default configuration |
| 36 |
- URL-based configuration |
| 37 |
- Priority from URL |
| 38 |
- Markdown from URL |
| 39 |
- Tags from URL |
| 40 |
- Title from URL |
| 41 |
- DisableTLS from URL |
| 42 |
|
| 43 |
### Authentication |
| 44 |
|
| 45 |
- Basic authentication with username and password |
| 46 |
- Username-only authentication |
| 47 |
|
| 48 |
### TLS |
| 49 |
|
| 50 |
- HTTPS connections (default) |
| 51 |
- HTTP connections with DisableTLS |
| 52 |
|
| 53 |
## Setup Requirements |
| 54 |
|
| 55 |
### ntfy Server |
| 56 |
|
| 57 |
A local ntfy server is required for e2e testing. The provided `docker-compose.yaml` sets up a local ntfy server. |
| 58 |
|
| 59 |
### Prerequisites |
| 60 |
|
| 61 |
- Go 1.25+ |
| 62 |
- Docker and Docker Compose |
| 63 |
- Linux OS |
| 64 |
|
| 65 |
### Quick Start |
| 66 |
|
| 67 |
1. Start the ntfy server and wait for it to be ready using the setup script: |
| 68 |
|
| 69 |
```bash |
| 70 |
cd testing/e2e/ntfy |
| 71 |
./setup.sh setup-all |
| 72 |
``` |
| 73 |
|
| 74 |
2. Run the e2e tests: |
| 75 |
|
| 76 |
```bash |
| 77 |
go test -v ./testing/e2e/ntfy/... |
| 78 |
``` |
| 79 |
|
| 80 |
### ntfy Server Details |
| 81 |
|
| 82 |
| Field | Value | |
| 83 |
|---------|-----------------------------------| |
| 84 |
| Host | localhost | |
| 85 |
| Port | 8080 | |
| 86 |
| API URL | <http://localhost:8080> | |
| 87 |
| Health | <http://localhost:8080/v1/health> | |
| 88 |
|
| 89 |
### Stopping the Server |
| 90 |
|
| 91 |
To stop the ntfy server: |
| 92 |
|
| 93 |
```bash |
| 94 |
cd testing/e2e/ntfy |
| 95 |
docker compose down |
| 96 |
``` |
| 97 |
|
| 98 |
## Environment Variables |
| 99 |
|
| 100 |
A `.env` file is provided with preconfigured defaults. |
| 101 |
|
| 102 |
**Default values:** |
| 103 |
**Security Note**: Never commit real credentials to version control. The `.env` file is in `.gitignore`. |
| 104 |
|
| 105 |
```bash |
| 106 |
# Required: ntfy server URL |
| 107 |
SHOUTRRR_NTFY_URL=ntfy://localhost:8080/shoutrrr-e2e-test |
| 108 |
|
| 109 |
# Optional: ntfy server authentication |
| 110 |
# SHOUTRRR_NTFY_USERNAME= |
| 111 |
# SHOUTRRR_NTFY_PASSWORD= |
| 112 |
|
| 113 |
# Optional: TLS configuration |
| 114 |
# SHOUTRRR_NTFY_DISABLE_TLS=false |
| 115 |
``` |
| 116 |
|
| 117 |
## Running the Tests |
| 118 |
|
| 119 |
### Test Execution Prerequisites |
| 120 |
|
| 121 |
- Go 1.25+ |
| 122 |
- Running ntfy server |
| 123 |
- `.env` file with required environment variables |
| 124 |
|
| 125 |
### Execute E2E Tests |
| 126 |
|
| 127 |
Run all e2e tests: |
| 128 |
|
| 129 |
```bash |
| 130 |
go test ./testing/e2e/ntfy/ -v |
| 131 |
``` |
| 132 |
|
| 133 |
Run specific test files: |
| 134 |
|
| 135 |
```bash |
| 136 |
# Test basic functionality |
| 137 |
go test ./testing/e2e/ntfy/ -v -args -ginkgo.focus="basic" |
| 138 |
|
| 139 |
# Test configuration |
| 140 |
go test ./testing/e2e/ntfy/ -v -args -ginkgo.focus="config" |
| 141 |
|
| 142 |
# Test message features |
| 143 |
go test ./testing/e2e/ntfy/ -v -args -ginkgo.focus="message" |
| 144 |
|
| 145 |
# Test authentication |
| 146 |
go test ./testing/e2e/ntfy/ -v -args -ginkgo.focus="auth" |
| 147 |
|
| 148 |
# Test TLS |
| 149 |
go test ./testing/e2e/ntfy/ -v -args -ginkgo.focus="TLS" |
| 150 |
``` |
| 151 |
|
| 152 |
### Test Behavior |
| 153 |
|
| 154 |
- Tests will skip if the ntfy server is not available |
| 155 |
- Tests include delays between executions to respect ntfy rate limits |
| 156 |
- All tests send actual messages to the ntfy server |
| 157 |
- Messages are verified via the ntfy API polling endpoint |
| 158 |
- Each test includes an "E2E Test:" prefix to identify test messages |
| 159 |
|
| 160 |
### Message Verification |
| 161 |
|
| 162 |
The e2e tests verify message delivery by polling the ntfy API: |
| 163 |
|
| 164 |
1. A message is sent to a unique topic |
| 165 |
2. The test polls `GET /<topic>/json?poll=1&message=<message>` to retrieve the message |
| 166 |
3. The response is parsed as JSON and verified against expected values |
| 167 |
|
| 168 |
## Test Structure |
| 169 |
|
| 170 |
```bash |
| 171 |
testing/e2e/ntfy/ |
| 172 |
├── .env # Environment variables (not committed) |
| 173 |
├── .gitignore # Git ignore rules |
| 174 |
├── docker-compose.yaml # ntfy server setup (Docker Compose) |
| 175 |
├── setup.sh # Setup script for starting/stopping the server |
| 176 |
├── suite_test.go # Test suite setup and configuration |
| 177 |
├── basic_test.go # Basic message sending functionality |
| 178 |
├── config_test.go # Configuration tests |
| 179 |
├── message_features_test.go # Message features (title, priority, tags, etc.) |
| 180 |
├── authentication_test.go # Authentication tests |
| 181 |
├── tls_test.go # TLS connection tests |
| 182 |
└── README.md # This file |
| 183 |
``` |
| 184 |
|
| 185 |
### Test Organization |
| 186 |
|
| 187 |
Each test file focuses on a specific feature category: |
| 188 |
|
| 189 |
- **Basic Tests** (`basic_test.go`): Core message sending functionality |
| 190 |
- **Config Tests** (`config_test.go`): Configuration options and URL parsing |
| 191 |
- **Message Features Tests** (`message_features_test.go`): Rich message features |
| 192 |
- **Authentication Tests** (`authentication_test.go`): Basic auth handling |
| 193 |
- **TLS Tests** (`tls_test.go`): TLS/HTTP connection handling |
| 194 |
|
| 195 |
## ntfy URL Examples |
| 196 |
|
| 197 |
### Basic Connection |
| 198 |
|
| 199 |
```bash |
| 200 |
SHOUTRRR_NTFY_URL=ntfy://localhost:8080/shoutrrr-e2e-test |
| 201 |
``` |
| 202 |
|
| 203 |
### With Authentication |
| 204 |
|
| 205 |
```bash |
| 206 |
SHOUTRRR_NTFY_URL=ntfy://username:password@localhost:8080/shoutrrr-e2e-test |
| 207 |
``` |
| 208 |
|
| 209 |
### With Priority |
| 210 |
|
| 211 |
```bash |
| 212 |
SHOUTRRR_NTFY_URL=ntfy://localhost:8080/shoutrrr-e2e-test?priority=5 |
| 213 |
``` |
| 214 |
|
| 215 |
### With Tags |
| 216 |
|
| 217 |
```bash |
| 218 |
SHOUTRRR_NTFY_URL=ntfy://localhost:8080/shoutrrr-e2e-test?tags=warning,skull |
| 219 |
``` |
| 220 |
|
| 221 |
### With HTTP (DisableTLS) |
| 222 |
|
| 223 |
```bash |
| 224 |
SHOUTRRR_NTFY_URL=ntfy://localhost:8080/shoutrrr-e2e-test |
| 225 |
SHOUTRRR_NTFY_DISABLE_TLS=true |
| 226 |
``` |
| 227 |
|
| 228 |
## Resources |
| 229 |
|
| 230 |
- ntfy Documentation: <https://docs.ntfy.sh> |
| 231 |
- ntfy Docker Image: <https://hub.docker.com/r/binwiederhier/ntfy> |
| 232 |
- ntfy GitHub: <https://github.com/binwiederhier/ntfy> |