Commit Graph

662 Commits

Author SHA1 Message Date
Taras Kushnir 5e8eac34b5 Bump widget lib version to 19 2026-01-15 15:10:04 +02:00
Taras Kushnir 64ceb48321 Remove unused code 2026-01-15 14:57:51 +02:00
Taras Kushnir 809a667bf9 Allow localhost subdomains 2026-01-15 14:52:54 +02:00
Taras Kushnir 0f70c38529 Add more tests
80% done by Claude Opus 4.5 w/ copilot, but not quite
2026-01-15 14:35:13 +02:00
Copilot e09db1dbb8 Allow org members without subscription to create properties via API (#251)
* Initial plan

* Allow org members without subscription to create properties via API

- Add requestUserEx() to allow skipping subscription check
- Update postNewProperties() to not require user subscription (org owner subscription is checked instead)
- Update getAsyncTask() to not require user subscription
- Add integration tests for Portal and API to verify org members can create properties

Co-authored-by: ribtoks <505555+ribtoks@users.noreply.github.com>

* Fix TestApiPostPropertiesNoSubscription to check API error code

Update test to use requestResponseAPISuite and check for StatusSubscriptionPropertyLimitError instead of HTTP 402

Co-authored-by: ribtoks <505555+ribtoks@users.noreply.github.com>

* Refactor tests and fix task handler subscription check

- Fix getAsyncTask to require subscription (nil subscriptions blocked, expired trials allowed)
- Refactor API tests with helper functions createPropertyInputs, waitForAsyncTaskCompletion
- Refactor API and Portal tests as test suites for nil and expired trial subscriptions
- Add step to test non-member rejection before join in API tests
- Simplify Portal tests to focus on member property creation

Co-authored-by: ribtoks <505555+ribtoks@users.noreply.github.com>

* Fix redundant imports in property_test.go

Use consistent db_test alias instead of multiple aliases for the same package

Co-authored-by: ribtoks <505555+ribtoks@users.noreply.github.com>

* Add non-member rejection test and refactor async task wait helpers

- Add non-member rejection step in API tests (verifies 403 Forbidden before invite)
- Simplify Portal tests (just verify member can create properties after joining)
- Refactor multiple async task wait loops to use waitForAsyncTaskCompletion helper
- Add waitForAsyncTaskCompletionWithResult helper for tests that need results

Co-authored-by: ribtoks <505555+ribtoks@users.noreply.github.com>

* Ensure invited-but-not-joined members cannot create properties

- Add RetrieveUserOrganizationMember() that excludes invited users
- Add requestOrgMember() API helper that uses the new function
- Add OrgMember() Portal helper that uses the new function
- Update postNewProperties() to use requestOrgMember()
- Update postNewOrgProperty() to use OrgMember()
- Add test steps for invited-but-not-joined rejection in API and Portal tests

Co-authored-by: ribtoks <505555+ribtoks@users.noreply.github.com>

* Refactor: return access level from requestOrg/Org instead of new functions

- Modify RetrieveUserOrganization to return access level as third value
- Delete RetrieveUserOrganizationMember function
- Modify requestOrg to return access level as third value
- Delete requestOrgMember function
- Modify Org to return access level as third value
- Delete OrgMember function
- Update all callers to ignore unused access level return values
- Check access level in postNewProperties and postNewOrgProperty to block invited users

Co-authored-by: ribtoks <505555+ribtoks@users.noreply.github.com>

* Fix code review: use 403 Forbidden and check level.Valid

- Use HTTP 403 Forbidden instead of 500 in Portal for invited users
- Add level.Valid check before accessing level.AccessLevel

Co-authored-by: ribtoks <505555+ribtoks@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: ribtoks <505555+ribtoks@users.noreply.github.com>
2026-01-15 12:06:34 +02:00
Copilot 7d1ef63389 Add t.Helper annotations to Go test helpers (#253)
* Initial plan

* test: mark helper functions with t.Helper

Co-authored-by: ribtoks <505555+ribtoks@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: ribtoks <505555+ribtoks@users.noreply.github.com>
2026-01-14 19:20:53 +02:00
Taras Kushnir 0ceb759fee Refactor html string concatenation to JS in widget html
credit to Claude Opus 4.5 w/ GH copilot
2026-01-14 18:56:47 +02:00
Taras Kushnir ec0aca8b7f Cosmetic improvement 2026-01-14 10:15:25 +02:00
Taras Kushnir 28ba7ed860 Create html element explicitly 2026-01-14 10:12:59 +02:00
Taras Kushnir ba1dcb1492 Cosmetic improvements 2026-01-13 21:29:17 +02:00
Taras Kushnir 411a289e32 Protect against private-captcha redeclaration 2026-01-13 21:23:11 +02:00
Luke Watts 2a1e074b17 fix: guard against custom element 'progress-ring' already existing (#250)
When the widget script is loaded multiple times (possible in SPA environments with framework component lifecycles), the application crashes with:

```
Uncaught DOMException: CustomElementRegistry.define: 'progress-ring' has already been defined as a custom element
```

This occurs because `customElements.define()` throws an error if called twice with the same element name, and the Custom Elements API provides no way to undefine or replace registered elements.

### Solution
Added a guard to check if the custom element is already registered before attempting to define it:
```javascript
if (typeof window !== "undefined" && 
    window.customElements && 
    !window.customElements.get('progress-ring')) {
    window.customElements.define('progress-ring', ProgressRing);
}
```

### Why This Matters
- **Prevents crashes** in SPA environments where components mount/unmount repeatedly
- **Idempotent behavior** - script can safely be included multiple times

This is a defensive programming practice recommended for any third-party script that registers custom elements, as you cannot control how integrators will load your code.
2026-01-13 21:19:49 +02:00
Taras Kushnir 76b9b81d37 Add ErrorLog for http server 2026-01-13 16:40:44 +02:00
Taras Kushnir 5cffff09d8 Use status recorder also for recovered middleware 2026-01-12 19:11:09 +02:00
Taras Kushnir 8b160436fe Use http request with context 2026-01-12 12:15:57 +02:00
Taras Kushnir d1c0a1afcb Split timeout handler into soft and hard
- fix potential superfluous writes like the stdlib http.TimeoutHandler
- we don't want to run extra goroutines on public unauthenticated methods
2026-01-12 12:13:02 +02:00
Taras Kushnir 00c287f274 Bump readiness drain delay 2026-01-12 10:01:20 +02:00
Taras Kushnir c9da66dc33 Use backoff and multiple attempts to ping DBs 2026-01-12 09:58:33 +02:00
Taras Kushnir 688ace5196 Cosmetic improvement 2026-01-11 20:05:45 +02:00
Taras Kushnir 9f1c81af51 Fix typo 2026-01-11 19:42:32 +02:00
Taras Kushnir ebdeb3ea05 Cosmetic improvement 2026-01-11 19:30:02 +02:00
Taras Kushnir e1f0e612f3 Use standard timeout handler 2026-01-11 15:51:04 +02:00
Taras Kushnir f3dd1fafcb Use portal mailer in tests instead of stub mailer 2026-01-11 15:44:15 +02:00
Taras Kushnir 17f577a4f7 Generate coverage report as an artifact 2026-01-11 14:47:01 +02:00
Taras Kushnir 3f3c0988bf Add more tests
With copilot. Merged maually due to bugs
2026-01-10 17:42:05 +02:00
Taras Kushnir b13d351363 Cosmetic improvement [ci skip] 2026-01-10 14:38:32 +02:00
Taras Kushnir 5926536d2c Revert redirect 'fix' 2026-01-10 12:13:47 +02:00
Taras Kushnir 27495ae7ee Cosmetic improvements 2026-01-10 12:04:42 +02:00
Taras 3cbcb9bab5 Update module github.com/jackc/pgx/v5 to v5.8.0 (#245)
Co-authored-by: Renovate Bot <renovate@whitesourcesoftware.com>
2026-01-10 12:01:53 +02:00
Taras Kushnir 79965c7e72 Fix tests 2026-01-10 12:01:07 +02:00
Taras Kushnir 341d071c65 Add cosmetic validation for email domains 2026-01-10 11:52:02 +02:00
Taras Kushnir 2c98081185 Improve org invitation functionality. related PrivateCaptcha/issues#227
- Prefill email address for the invite link
- show masked email in members list
- improve usual register flow too
2026-01-10 11:50:09 +02:00
Taras Kushnir 8442b9e7b2 Allow inviting users without accounts. closes PrivateCaptcha/issues#227 2026-01-10 09:51:54 +02:00
Taras Kushnir f02b7fca9e Remove unused code 2026-01-09 15:54:12 +02:00
Taras Kushnir 336353e551 Add negative test coverage for portal endpoint
Done by copilot, merged manually due to conflicts
2026-01-09 09:59:26 +02:00
Taras Kushnir 3e453bdee8 Cosmetic improvement 2026-01-09 09:50:38 +02:00
Taras Kushnir 7dc8891e4b Fix duplicate html element ID 2026-01-08 21:25:24 +02:00
Taras Kushnir 19991f1fb7 Cosmetic improvements 2026-01-08 20:31:08 +02:00
Copilot 7d1247848b Add organization transfer feature (#240)
* Initial plan

* Initial plan for organization transfer feature

Co-authored-by: ribtoks <505555+ribtoks@users.noreply.github.com>

* Add organization transfer feature with UI, DB layer, and integration test

Co-authored-by: ribtoks <505555+ribtoks@users.noreply.github.com>

* Address PR feedback: verify old owner in property transfer, swap org membership, show masked email in audit, add negative tests

Co-authored-by: ribtoks <505555+ribtoks@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: ribtoks <505555+ribtoks@users.noreply.github.com>
2026-01-08 20:25:09 +02:00
Copilot bc5f8a9d6e Add test coverage for maintenance jobs, rate limiter, cache, and portal handlers (#241)
* Initial plan

* Add unit tests for improved test coverage

Co-authored-by: ribtoks <505555+ribtoks@users.noreply.github.com>

* Address code review feedback

Co-authored-by: ribtoks <505555+ribtoks@users.noreply.github.com>

* Move integration tests to pkg/api and pkg/portal, fix TestResend2FA logic

Co-authored-by: ribtoks <505555+ribtoks@users.noreply.github.com>

* Fix code review issues: remove unused import and fix job name generation

Co-authored-by: ribtoks <505555+ribtoks@users.noreply.github.com>

* Fix TestResend2FA tests: add CSRF token and verify codes are different

Co-authored-by: ribtoks <505555+ribtoks@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: ribtoks <505555+ribtoks@users.noreply.github.com>
2026-01-08 19:56:39 +02:00
Taras 0e2323ca10 Add copilot 2026-01-08 09:08:55 +02:00
Taras Kushnir ae0972b1d1 Fix build 2026-01-08 08:46:13 +02:00
Taras Kushnir a519cf0ea0 Cosmetic improvements 2026-01-08 08:44:33 +02:00
Taras Kushnir bb82daa529 Make global variables in tests consistent 2026-01-08 08:44:33 +02:00
Copilot b9a3945ff0 Add negative codepath tests for API endpoints (#242)
* Initial plan

* Add negative codepath tests for API endpoints

Co-authored-by: ribtoks <505555+ribtoks@users.noreply.github.com>

* Fix task test for invalid UUID format

Co-authored-by: ribtoks <505555+ribtoks@users.noreply.github.com>

* Fix code review feedback - use t.Fatalf for consistency

Co-authored-by: ribtoks <505555+ribtoks@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: ribtoks <505555+ribtoks@users.noreply.github.com>
2026-01-07 20:25:08 +02:00
Taras Kushnir 18ec9715a0 Cosmetic improvements 2026-01-07 18:37:13 +02:00
Copilot d00d9ce9cb Add unit and integration tests for code coverage improvements (#238)
* Initial plan

* Initial planning for code coverage improvements

Co-authored-by: ribtoks <505555+ribtoks@users.noreply.github.com>

* Add unit tests for code coverage improvements

Co-authored-by: ribtoks <505555+ribtoks@users.noreply.github.com>

* Fix integration test failures and add more tests for code coverage

Co-authored-by: ribtoks <505555+ribtoks@users.noreply.github.com>

* Address code review feedback - simplify status code conversion

Co-authored-by: ribtoks <505555+ribtoks@users.noreply.github.com>

* Address PR review feedback: use config.NewStaticValue() and improve test assertions

Co-authored-by: ribtoks <505555+ribtoks@users.noreply.github.com>

* Add remaining tests: ChunkedCleanup, audit_enterprise, echoPuzzle

Co-authored-by: ribtoks <505555+ribtoks@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: ribtoks <505555+ribtoks@users.noreply.github.com>
2026-01-07 18:29:04 +02:00
Taras 23a4e115b3 Update Node.js to v24 (#239)
Co-authored-by: Renovate Bot <renovate@whitesourcesoftware.com>
2026-01-07 16:28:14 +02:00
Taras Kushnir d7089d7c39 Remove cache option for node setup 2026-01-07 10:53:40 +02:00
Taras Kushnir f0958d2b72 Add copilot setup steps 2026-01-07 10:48:28 +02:00