rcourtman
|
ba03551dba
|
test: Add edge case for initializeBootstrapToken error path
Cover loadOrCreateBootstrapToken failure path.
Coverage: initializeBootstrapToken 92% -> 100%
|
2025-12-02 00:51:44 +00:00 |
|
rcourtman
|
41a7bdf7ff
|
test: Add edge case for clearBootstrapToken remove failure
Tests the warning log path when os.Remove fails with an error other
than ErrNotExist. Uses a directory with contents to trigger ENOTEMPTY.
|
2025-12-01 23:47:58 +00:00 |
|
rcourtman
|
a86aa5d6b7
|
test: Add edge cases for initializeBootstrapToken
- Nil router and nil config handling (no panic)
- OIDC enabled clears bootstrap token
Coverage: 80% to 92%.
|
2025-12-01 23:40:22 +00:00 |
|
rcourtman
|
d64e992b8e
|
test: Add edge case for handleValidateBootstrapToken invalid JSON
Tests invalid JSON body triggers json.Decode error and returns 400.
Coverage: 90.5% to 100%.
|
2025-12-01 23:35:40 +00:00 |
|
rcourtman
|
c6f14b2c6e
|
test: Add tests for webhook template generation and bootstrap token functions
- Add comprehensive tests for generatePayloadFromTemplateWithService covering:
- Valid JSON template rendering
- Invalid template syntax error handling
- Template execution errors
- ntfy service (plain text, skips JSON validation)
- Various services (discord, telegram, pagerduty) JSON validation
- Template function usage (upper, title)
- Numeric and boolean values in templates
- Special characters and empty template edge cases
- Add tests for bootstrapTokenValid covering:
- Nil router handling
- Empty hash and empty token cases
- Valid token validation
- Invalid token rejection
- Whitespace trimming
- Add tests for clearBootstrapToken covering:
- Nil router safety
- Token file deletion
- Missing file handling
- Empty path handling
|
2025-12-01 22:07:40 +00:00 |
|
rcourtman
|
200db2dc40
|
test: Add error path tests for loadOrCreateBootstrapToken
Cover all error branches in bootstrap token loading:
- Empty/whitespace dataPath validation
- os.MkdirAll failure (directory creation blocked by file)
- os.WriteFile failure (read-only directory)
- os.ReadFile failure (permission denied on existing file)
- Empty file contents after read
- Whitespace-only file contents
Also adds test for generateBootstrapToken helper function.
|
2025-12-01 13:00:27 +00:00 |
|
rcourtman
|
fb27ff7c75
|
Add unit tests for bootstrap token functions (internal/api)
20 test cases covering:
- generateBootstrapToken: uniqueness, format, hex encoding
- loadOrCreateBootstrapToken: new token creation, existing token loading,
empty/whitespace paths, empty token files, directory creation, file permissions
- bootstrapTokenValid: nil router safety, empty hash/token handling
- clearBootstrapToken: nil safety, file deletion, state clearing
First test file for bootstrap_token.go security utilities.
|
2025-11-30 22:54:28 +00:00 |
|