Commit Graph

132 Commits

Author SHA1 Message Date
Copilot acae441a99 Improve test coverage for puzzle, portal, monitoring packages (#264)
* Initial plan

* Add tests for puzzle, monitoring, portal packages

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

* Add registration disabled tests

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

* Address PR review comments: fix tests and use constants

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

* Fix audit tests with non-empty arrays and use constants for error strings

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

* Update audit.go

* Update audit.go

---------

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-27 12:35:41 +02:00
Taras Kushnir 354967a96c Bump ClickHouse version to 25.6.2 2026-01-26 15:11:26 +02:00
Taras Kushnir 315248bba0 Fix CI 2026-01-26 14:40:41 +02:00
Taras Kushnir d355541170 Cosmetic improvement 2026-01-26 14:29:03 +02:00
Taras Kushnir 3c3f31a59d Fix heredoc in bash 2026-01-26 14:24:38 +02:00
Taras Kushnir c662aa30a1 Add option to have admin pwd for ClickHouse 2026-01-26 13:03:06 +02:00
Taras Kushnir e8999c9a16 Move to bash scripts for DB init in Docker 2026-01-26 11:31:36 +02:00
Taras Kushnir e72cf3c38a Record last used time for API keys. closes PrivateCaptcha/issues#166 2026-01-23 17:13:39 +02:00
Taras Kushnir 9048bcaa5a Add timeouts for channel selects 2026-01-23 16:59:37 +02:00
Taras Kushnir 7d42e32de6 Remove unused code 2026-01-23 14:10:22 +02:00
Copilot 9f101a13ff Split settings usage stats by organization (#256)
* Initial plan

* Split account stats by organization

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

* Fix usage chart layout and stats handler

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

* Address code review feedback

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

* Clarify account stats warning log

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

* Adjust stats logging and legend layout

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

* Move legend sizing constants

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

* Document legend sizing constants

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

* Refine legend text measurement

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

* Improve legend truncation and logging

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

* Cosmetic improvements

* Refactor legend layout logic

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

* Tweak legend row spacing

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

* Clarify legend layout fields

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>
Co-authored-by: Taras Kushnir <tk.dev@mailbox.org>
2026-01-17 09:56:46 +02:00
Taras Kushnir 64ceb48321 Remove unused code 2026-01-15 14:57:51 +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
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 3f3c0988bf Add more tests
With copilot. Merged maually due to bugs
2026-01-10 17:42:05 +02:00
Taras Kushnir 8442b9e7b2 Allow inviting users without accounts. closes PrivateCaptcha/issues#227 2026-01-10 09:51:54 +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 Kushnir bb82daa529 Make global variables in tests consistent 2026-01-08 08:44:33 +02:00
Taras Kushnir 2435770e2f Add tests for in-memory time series 2026-01-06 18:48:08 +02:00
Taras Kushnir f534ee7ec5 Add a mode to run tests without ClickHouse 2026-01-06 15:46:24 +02:00
Taras Kushnir 8112359ef9 Add more tests 2026-01-02 18:44:17 +02:00
github-actions[bot] 094dfdd67d Fix code style issues (#234) 2025-12-27 12:18:30 +00:00
Taras Kushnir a113c35188 Add new fields to audit event for API keys 2025-12-23 10:00:40 +01:00
Taras Kushnir cbdc994e0d Add Org scope to API keys. closes PrivateCaptcha/issues#237 2025-12-22 18:54:47 +01:00
Taras Kushnir 1478f7a376 Add read-only attribute to the scope of API key 2025-12-22 14:33:26 +01:00
Taras Kushnir 727fbfa93e Preallocate map size 2025-12-22 12:47:18 +01:00
Taras Kushnir 207d8a0f68 Fix api key scope migration 2025-12-19 14:44:24 +01:00
Taras Kushnir 77cb6e987d Cleanup user caches on logout 2025-12-19 10:09:31 +01:00
Taras Kushnir 3475c9c1e2 Add API to batch-update properties. related PrivateCaptcha/issues#45 2025-12-18 14:28:55 +01:00
Taras Kushnir 66d842413a Split portal and DB page size for properties 2025-12-17 19:01:35 +01:00
Taras Kushnir d1ac04d09d Cosmetic improvements
some found by CodeRabbit review
2025-12-17 19:00:37 +01:00
Taras Kushnir 05e653631e Add pagination support for org properties. related PrivateCaptcha/issues#45 2025-12-17 18:32:41 +01:00
Taras Kushnir b0c7b4c957 Cosmetic improvement 2025-12-17 18:16:02 +01:00
Taras Kushnir 653b91f86e Add API support to delete properties. related PrivateCaptcha/issues#45 2025-12-17 12:55:49 +01:00
Taras Kushnir b959c00af8 Add create properties bulk API. related PrivateCaptcha/issues#45 2025-12-15 15:43:05 +01:00
Taras Kushnir 85ca8c5a7a Add preliminary basic version of orgs API. related PrivateCaptcha/issues#45 2025-12-10 21:15:02 +01:00
Taras Kushnir 03910a870c Shuffle limits related code to DB 2025-12-08 18:49:34 +01:00
Taras Kushnir 96da407d92 Fix typo 2025-12-08 17:32:31 +01:00
Taras Kushnir f0db3be14d Add audit log source 2025-12-08 13:34:20 +01:00
Taras Kushnir 57636bbf48 Add API key scope 2025-12-08 12:44:42 +01:00
Taras Kushnir 81e5652860 Fix linter error 2025-12-08 09:05:39 +01:00
Taras Kushnir 9151c22370 Cache chart stats also on the server level 2025-12-07 20:13:18 +01:00
Taras Kushnir 567c7ddb00 Bump sqlc to 1.30.0 2025-12-06 14:04:04 +01:00
Taras Kushnir e03bf4f5ae Check if lock exists before trying to obtain it
Fixes infra warning about percent of rolled back transactions in PG
2025-12-06 14:03:30 +01:00
Taras Kushnir fbe500748a Refactor subscription limits. related PrivateCaptcha/issues#142 2025-12-05 10:38:34 +01:00
Taras Kushnir 54ddecb5b4 Record cancellation in subscription audit event 2025-12-01 20:14:20 +01:00