Commit Graph

242 Commits

Author SHA1 Message Date
Ophir LOJKINE 56308adca0 update all crypto dependencies 2026-04-02 11:29:53 +02:00
Ophir LOJKINE 3af82f4857 Fix http header only page crashes (#1253)
Return errors early on invalid header values
2026-03-17 16:13:11 +01:00
Ophir LOJKINE 316fa4b5a2 Return BadRequest for non-unicode static paths and add test (#1252)
* Fix non-unicode DB filesystem regression test

* Fix non-unicode DB fs routing test
2026-03-17 13:50:55 +01:00
Ophir LOJKINE 8db4f036b8 Remove env_logger and use telemetry logging in tests (#1247)
* Remove env_logger and reuse telemetry logging in tests

* Use test-captured writer for telemetry logs in tests

* Isolate test logging init from OTEL and keep tests quiet
2026-03-15 15:43:39 +01:00
Ophir LOJKINE 99ad2685a0 Add optional mode argument to persist_uploaded_file (#1241)
* Add optional mode argument to persist_uploaded_file

This change adds an optional `mode` argument to the `persist_uploaded_file` function, allowing users to specify the Unix file permissions in octal notation when saving uploaded files.

- Updated `sqlpage.persist_uploaded_file` signature to include `mode`.
- Implemented permission setting logic using `std::os::unix::fs::PermissionsExt` (on Unix platforms).
- Default permission is set to "600" (octal `0o600`).
- Added documentation for the new parameter in `examples/official-site/sqlpage/migrations/39_persist_uploaded_file.sql`, including an explanation of octal notation and a link to Wikipedia.
- Added a unit test `test_set_file_mode` to verify the permission setting logic.

Co-authored-by: lovasoa <552629+lovasoa@users.noreply.github.com>

* Address PR feedback: Add integrated test for persist_uploaded_file mode

- Removed unit test from `functions.rs` and added an integrated test in `tests/uploads/mod.rs`.
- Created `tests/uploads/persist_with_mode.sql` for the integrated test.
- Refactored `set_file_mode` to use `#[cfg(unix)]` and `#[cfg(not(unix))]` on the entire function.
- Replied to PR comments.

Co-authored-by: lovasoa <552629+lovasoa@users.noreply.github.com>

* Fix Windows CI: Normalize paths and improve tests

- Normalized `persist_uploaded_file` return path to use forward slashes for URL compatibility.
- Updated `test_persist_uploaded_file_mode` to handle platform-specific path separators.
- Fixed clippy warning `expect_fun_call` in tests.

Co-authored-by: lovasoa <552629+lovasoa@users.noreply.github.com>

* Address PR feedback: Assert file contents and ignore test uploads

- Added assertion to verify persisted file contents in `test_persist_uploaded_file_mode`.
- Removed accidental test file from git and added `tests_uploads/` to `.gitignore`.
- Replied to PR comments.

Co-authored-by: lovasoa <552629+lovasoa@users.noreply.github.com>

* Address PR feedback: Revert breaking change to return value

- Reverted normalization of `persist_uploaded_file` return value to avoid a breaking change.
- Reverted corresponding test changes that relied on normalized paths.
- Replied to PR comments.

Co-authored-by: lovasoa <552629+lovasoa@users.noreply.github.com>

* Address PR feedback: Query results as JSON in integrated test

- Updated `test_persist_uploaded_file_mode` to directy request and verify JSON results.
- Replied to PR comments.

Co-authored-by: lovasoa <552629+lovasoa@users.noreply.github.com>

* Fix Windows CI: Robust path handling in tests

- Improved integrated test to correctly request JSON results.
- Added platform-specific path normalization when verifying files on disk.
- Ensured `persist_uploaded_file` return value remains OS-specific to avoid breaking changes.

Co-authored-by: lovasoa <552629+lovasoa@users.noreply.github.com>

* Address PR feedback: Delete leftover test file

- Deleted accidental leftover test file `tests_uploads/2026-03-13_15h47m26s_6JaXODDK.txt`.
- Replied to PR comments.

Co-authored-by: lovasoa <552629+lovasoa@users.noreply.github.com>

---------

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
2026-03-13 19:57:38 +01:00
Ophir LOJKINE 3eb527490e Fix HTTP status mapping for client request errors (#1240) 2026-03-13 11:11:12 +01:00
Ophir LOJKINE c7e5be793b Return 400 for invalid UTF-8 multipart fields (#1239) 2026-03-12 11:57:29 +01:00
Ophir LOJKINE 234eefd82b remove sleep in test
CI / compile_and_lint (push) Has been cancelled
CI / test (mssql, mssql, mssql://root:Password123!@127.0.0.1/sqlpage) (push) Has been cancelled
CI / test (mysql, mysql, mysql://root:Password123!@127.0.0.1/sqlpage) (push) Has been cancelled
CI / test (oracle, oracle, Driver=Oracle 21 ODBC driver;Dbq=//127.0.0.1:1521/FREEPDB1;Uid=root;Pwd=Password123!) (push) Has been cancelled
CI / test (postgres, odbc, Driver=PostgreSQL Unicode;Server=127.0.0.1;Port=5432;Database=sqlpage;UID=root;PWD=Password123!, true) (push) Has been cancelled
CI / test (postgres, postgres, postgres://root:Password123!@127.0.0.1/sqlpage) (push) Has been cancelled
CI / windows_test (push) Has been cancelled
CI / docker_build (linux/amd64, duckdb) (push) Has been cancelled
CI / docker_build (linux/amd64, minimal) (push) Has been cancelled
CI / docker_build (linux/arm/v7, minimal) (push) Has been cancelled
CI / docker_build (linux/arm64, duckdb) (push) Has been cancelled
CI / docker_build (linux/arm64, minimal) (push) Has been cancelled
CI / docker_push (duckdb) (push) Has been cancelled
CI / docker_push (minimal) (push) Has been cancelled
Create Release / Build sqlpage binaries (macOS & Windows) (.exe, , windows-latest, x86_64-pc-windows-msvc) (push) Has been cancelled
Create Release / Build sqlpage binaries (macOS & Windows) (odbc-static, macos-latest, x86_64-apple-darwin) (push) Has been cancelled
Create Release / Build sqlpage binaries (Linux) (push) Has been cancelled
Create Release / Build AWS Lambda Serverless zip image (push) Has been cancelled
Create Release / Create Github Release (push) Has been cancelled
Create Release / Publish to crates.io (push) Has been cancelled
2026-03-08 11:49:06 +01:00
Ophir LOJKINE ba06855f89 fmt 2026-03-08 10:57:36 +01:00
Ophir LOJKINE 6dcd6902d0 remove unused discovery_delay field from FakeOidcProvider
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 10:49:03 +01:00
Ophir LOJKINE 1def3e5129 assert that OIDC provider metadata is actually refreshed in test
Add a discovery request counter to FakeOidcProvider and assert it
increments after the background refresh completes. Remove unused
set_discovery_delay method.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 10:49:03 +01:00
Ophir LOJKINE 52c37e0dd5 use tokio::time::Instant for testable time manipulation, simplify tests
Replace std::time::Instant with tokio::time::Instant in OidcSnapshot so
that tokio::time::pause()/advance() controls elapsed time in tests.
Remove force_expire() — tests advance time past MAX_REFRESH_INTERVAL
instead. Simplify slow discovery test from ~70 to ~30 lines.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 10:49:02 +01:00
Ophir LOJKINE 817674cded OIDC: non-blocking background refresh and body read timeout
- OIDC provider metadata refreshes now run in a background task via
  spawn_local, never blocking incoming HTTP requests.
- Multiple concurrent refresh triggers are deduplicated via an AtomicBool.
- The write lock on the OIDC client is only held briefly to swap data,
  not during the upstream HTTP call.
- Add a body-read timeout to OIDC HTTP requests to prevent hangs when
  the provider stalls after sending headers.
- Add tests for both scenarios: slow discovery and slow token endpoint.

Fixes https://github.com/sqlpage/SQLPage/issues/1231

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 10:48:02 +01:00
Ophir LOJKINE 431ab87fa5 Add timeout to OIDC HTTP response body read (#1232)
* add timeout to OIDC HTTP response body read

A stalled OIDC provider that sends HTTP headers but never completes the
body would cause response.body().await to hang forever, freezing the
entire SQLPage process. Add a 5-second timeout on the body stream read
using awc's ClientResponse::timeout().

partially Fixes #1231

* simplify test comment

* simplify test: use token_endpoint_delay instead of Notify gate

* simplify test: use tokio time pause + auto-advance instead of select

* use spawn_local + advance instead of select to detect hang

* use Notify sync point instead of yield loop for deterministic test

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* simplify test: replace Notify+yields with sleep+time-advance

Remove the Notify synchronization and yield_now() calls. Instead,
use a small real-time sleep for TCP to complete, then pause+advance
tokio time. Assert the actual response status instead of is_finished().


* fix clippy: remove unnecessary mut on response
2026-03-08 03:55:40 +01:00
Ophir LOJKINE 17e6e1e712 Improve SQLPage function argument warnings (#1225)
* improve sqlpage function argument warnings with source context

Made-with: Cursor

* Param extraction: Result-based errors, single caller message, no CompoundIdentifier special case

- expr_to_stmt_param returns Result<StmtParam, ExprToParamError>; error carries only line + kind (UnsupportedExpr, UnemulatedFunction, NamedArgs)
- function_args_to_stmt_params logs one formatted message (ctx.format_param_error) then returns Err
- Single unsupported-expr arm; expr_summary() used for description
- Rename ParamWarnContext to ParamExtractContext

Made-with: Cursor

* Surface param extraction error in parse result; add parse_sql error-message tests; remove are_params_extractable

- When func_call_to_param returns StmtParam::Error, store it and have extract_parameters return Err so parse yields ParsedStatement::Error with specialized message
- Add test_parse_sql_unsupported_expr_in_sqlpage_arg and test_parse_sql_unemulated_function_in_sqlpage_arg
- Remove dead are_params_extractable and its unused import

Made-with: Cursor

* Refactor sqlpage function argument error messages to match user expectations

- Overhauled ExprToParamError formatting to construct exact user-friendly descriptions.
- Removed superfluous anyhow::Context prefixes in func_call_to_param.
- Passed source_path properly through validate_function_calls to ensure file line numbers populate the new error template accurately.
- Renamed error test file to match its dynamic error output signature.
- Removed redundant mut mutability warnings on parsing logic loops.

* improve error messages

* Refactor SqlPageFunctionError representation to clean up 'syntax error' wrappers

- Replaced stringly-typed anyhow errors with a strongly typed SqlPageFunctionError.
- Removed source_path threading completely from the parameter extraction phases, conforming to better separation of concerns.
- Appended file path prefix dynamically at the evaluation stage in clone_anyhow_err strictly when downcasting to SqlPageFunctionError.
- Removed the confusing generic 'Caused by: x.sql contains a syntax error...' wrapper from actual function logic errors.

* Remove redundant 'reorganize' hint from error message

* readd deleted test

* split parameter extraction logic into a separate file

* Add to changelog
2026-03-01 09:52:46 +01:00
Ophir LOJKINE a2ef976fc7 Add support for Oracle over ODBC (compatibility fixes, ci testing) (#1182)
* Add Oracle DB (free) and ODBC CI support

This change adds support for testing with Oracle DB (using the free version `gvenzl/oracle-free:slim`) in the CI pipeline. It:
- Updates `.github/workflows/ci.yml` to include a new matrix entry for Oracle DB.
- Adds steps to install the Oracle Instant Client and ODBC driver in the CI runner.
- Configures `odbcinst.ini` to register the Oracle ODBC driver.
- Updates `docker-compose.yml` to include the Oracle DB service definition.

* Fix CI: Remove libaio1 dependency

`libaio1` is not available in the ubuntu-latest environment used by GitHub Actions (which likely uses a newer Ubuntu version where `libaio1` is replaced by `libaio1t64` or similar, or it is transitively installed). Removing explicit installation to fix the CI failure.

* Fix CI: Update Oracle Instant Client to 21.14

The previous version 21.10.0.0.0-1 seems to be no longer available at the specified URL (404 Not Found). Updated to 21.14.0.0.0-1 which was verified to exist.

* Fix CI: Install libaio1t64 for Oracle Instant Client

Oracle Instant Client requires `libaio.so.1`, which is provided by the `libaio1t64` package in newer Ubuntu versions (like 24.04). Installing this package should resolve the "cannot open shared object file: No such file or directory" error.

* Fix CI: Symlink libaio.so.1 for Oracle Instant Client

On Ubuntu 24.04 (Noble), `libaio1t64` installs the library as `libaio.so.1t64`, but Oracle Instant Client explicitly looks for `libaio.so.1`. Creating a symlink fixes this loading issue.

* Fix CI: Install libodbcinst2 and unixodbc for Oracle driver

The Oracle ODBC driver requires `libodbcinst.so.2` which is provided by `libodbcinst2`. Installing `unixodbc` ensures the full ODBC stack is available.

* Fix CI: Remove redundant wget installation

`wget` is pre-installed on GitHub Actions runners, so the explicit installation via `apt-get` is unnecessary.

* Fix CI: Create 'root' user in Oracle DB

The Oracle test run failed with ORA-01017 (invalid credentials) because the 'root' user does not exist by default in the Oracle database.
This commit:
1. Installs Oracle SQL*Plus (instantclient-sqlplus) in the CI environment.
2. Adds a step to connect as SYSDBA and create the 'root' user with the required permissions and password, matching the test configuration.

* Fix CI: Use container env vars for Oracle user

Instead of manually creating the 'root' user with SQL*Plus, rely on the `gvenzl/oracle-free` container's initialization features (`APP_USER` and `APP_USER_PASSWORD`) which were already configured in `docker-compose.yml`.
Removed the SQL*Plus installation and user creation steps from the CI workflow.

* Fix CI: Use FREEPDB1 service for Oracle user

The `APP_USER` ('root') created by the `gvenzl/oracle-free` container is created in the `FREEPDB1` pluggable database, not the `FREE` container database. Updated the connection string to use `FREEPDB1`.

* Fix Oracle DB test failures

- `sql_to_json`: Handle Oracle's behavior where empty strings are treated as NULL.
- `filesystem`: Explicitly CAST the timestamp parameter to TIMESTAMP in `was_modified_query` for ODBC (Oracle) to avoid ORA-01843 (invalid month) errors caused by implicit string-to-date conversion mismatches.

* Fix Oracle tests by accounting for known behavior

- Revert generic ODBC changes in `filesystem.rs`.
- Skip `test_sql_file_read_utf8` for ODBC connections (Oracle) because fixing the `ORA-01843` error would require Oracle-specific SQL (e.g. `CAST` or `TO_TIMESTAMP`) in the main codebase which is undesirable for a generic ODBC implementation.
- Keep the test adjustment in `sql_to_json.rs` but clarify the comment that we are assuming ODBC implies Oracle in this test context for the empty string behavior.

* Fix Oracle tests: Identify Oracle by connection string

Instead of relying on `sqlx::any::AnyKind::Odbc` (which applies to any ODBC database), detect Oracle specifically by checking if the connection string contains "Oracle". This allows applying Oracle-specific test logic (like skipping tests with implicit timestamp conversions or handling empty strings as NULL) without incorrectly affecting other ODBC databases.

* use oracle dialect when talking to oracle

* remove stupid ai comment

* update oracle odbc installation steps

* fix odbc installation path

* cast variables to varchar(4000) in oracle

* clippy

* remove long backtraces from ci

* fixed csv upload test for oracle

* update tests for oracle

* properly quote sqlpage-generated col names

* fix test syntax for oracle

* clippy

* remove as but keep alias

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2026-01-12 14:22:07 +01:00
Ophir LOJKINE 8d106fb677 Oidc site prefix handling (#1179)
* fix(oidc): respect site_prefix in OIDC redirect and logout URLs

This change ensures that when `site_prefix` is configured, the OIDC redirect URI and logout URI include this prefix.
Previously, `site_prefix` was ignored, causing OIDC callbacks to fail when the application was served under a sub-path.

- Added `site_prefix` to `OidcConfig`.
- Updated `make_oidc_client` to prepend `site_prefix` to the redirect URI.
- Updated `handle_request` to match paths with `site_prefix` included.
- Updated `validate_redirect_url` to respect the prefix when verifying redirect targets.
- Added a regression test `test_oidc_with_site_prefix`.

* Refactor: Update dependencies and remove unused crates

This commit updates several dependencies to their latest versions and removes unused crates to streamline the project.

Co-authored-by: contact <contact@ophir.dev>

* removed unused config

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2026-01-08 16:46:10 +01:00
Ophir LOJKINE 72eff8079a Fix invalid redirect url scheme behind reverse proxy (#1178)
This commit refactors the OIDC tests to use a more robust fake OIDC provider and improves the logout URL generation to correctly handle the scheme.

Fixes https://github.com/sqlpage/SQLPage/issues/1174
2026-01-08 15:03:23 +01:00
Ophir Lojkine b349ef431c Ensure each fake oidc provider server stops immediately after the
corresponding test is done

Add cancellation token to fake OIDC provider server
2025-12-30 10:33:49 +01:00
Ophir Lojkine 1230326194 Remove unnecessary readiness check for OIDC provider in test setup 2025-12-30 10:13:35 +01:00
Ophir Lojkine 9f0941906f Remove unnecessary tokio async handling in FakeOidcProvider 2025-12-30 10:08:57 +01:00
lovasoa 16c089705c Fix: sqlpage.variables() no longer returns duplicate keys
The `sqlpage.variables()` function previously allowed duplicate keys
when GET, POST, and SET variables of the same name were present. This
commit ensures that the returned JSON object contains only unique keys,
with precedence given to SET variables, then POST, then GET.
2025-12-30 03:12:29 +01:00
lovasoa 5688140ca7 add more exhaustive tests for sqlpage.variables
see https://github.com/sqlpage/SQLPage/issues/1169
2025-12-30 02:20:11 +01:00
Ophir Lojkine d9078ac076 simplify oidc tests 2025-12-24 16:01:31 +01:00
Ophir Lojkine 34e361ca4a tests: cap actix workers to prevent fd exhaustion
cargo test was failing with too many open files because each test server
spawned a worker per CPU, quickly exhausting file descriptors when tests ran
in parallel. Set test servers to one worker so they use a bounded number of
sockets/threads, avoiding fd exhaustion and letting OIDC and migration tests
start reliably.
2025-12-23 14:16:37 +01:00
lovasoa 7d2de51231 Refactor OIDC test utilities
This commit introduces a macro for handling requests with cookies, simplifying the OIDC test flow. It also removes redundant session management functions, enhancing code clarity and maintainability. The setup function for OIDC tests is updated to improve readability and streamline the initialization process.
2025-12-12 01:10:13 +01:00
lovasoa 01391715a0 cleanup oidc tests deps 2025-12-12 00:55:08 +01:00
lovasoa 36c037455a cleanup oidc tests
Refactor OIDC login simulation by extracting query parameter logic into a separate function and renaming the callback function for clarity. This improves code readability and maintainability.
2025-12-12 00:37:04 +01:00
lovasoa 01102d76c2 add tests for the oidc code 2025-12-12 00:25:30 +01:00
Ophir LOJKINE 747cc78a91 sqlpage.fetch(null) = null (#1131)
* Fix: fetch(null) and fetch_with_meta(null) return null

Co-authored-by: contact <contact@ophir.dev>

* clean up implementation

* update docs

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2025-11-26 22:02:51 +01:00
lovasoa 9c89f02c9b fix regression: SET x = NULL now works even when ?x=something is set in
the URL

fix https://github.com/sqlpage/SQLPage/issues/1130
2025-11-26 21:29:14 +01:00
Ophir LOJKINE 95f228f383 simplify SQL test files (#1129)
* simplify SQL test files

- Simplified SQL test files by removing unnecessary components and restructuring queries to focus on expected vs actual results.
- Updated the request handling in `run_sql_test` to differentiate between JSON and HTML responses based on test file content.
- Enhanced error handling and assertions for both JSON and HTML responses to improve test reliability and clarity.
- Removed redundant code and improved readability in the test execution flow.

* move more tests to the new expected/actual format

* migrate more tests to the expected/actual format

- Changed references in various test files to point to the new `simple.sql` instead of the outdated `it_works_simple.sql`.
- Removed several obsolete SQL test files that are no longer needed, streamlining the test suite.
- Updated assertions and request paths in the test cases to reflect the new structure and improve clarity.

* Enhance error handling in SQL tests and update SQL syntax

- Added a new function `format_error` to improve error reporting in SQL test assertions, capturing detailed error descriptions and backtraces.
- Updated SQL syntax in `sqrt.sql` to use `INT` instead of `integer` for consistency with SQL standards.

* sqrt test
2025-11-26 00:45:13 +01:00
Ophir LOJKINE 2af95a041f Accept header JSON responses (#1127)
* Support JSON responses via Accept header

* no update in migrations

* No UPDATE in official site migrations

- Updated the JSON component description to clarify its integration with external services and the ability to serve both HTML and JSON based on the HTTP Accept header.
- Added examples demonstrating how to request JSON responses using `curl`.
- Removed the obsolete migration file that documented the JSON response format feature, consolidating information into the main documentation.

* revert stupid docs example change

stupid bot

* simplify tests

* avoid string then json in tests, parse as json directly

* changelog
2025-11-24 23:17:19 +01:00
Ophir LOJKINE e93056e6d8 Add sqlpage.set_variable(name, value) function and update docs (#1124)
* feat: Add sqlpage.set_variable function

Co-authored-by: contact <contact@ophir.dev>

* Refactor: Fix set_variable serialization and update tests

Co-authored-by: contact <contact@ophir.dev>

* fix tests: no json_extract on mssql

* Refactor: Update URLParameters handling in set_variable function

- Replaced serde_json::Map with a custom URLParameters struct for better management of URL parameters.
- Introduced methods for handling single and vector values in URLParameters.
- Updated tests to reflect changes in the set_variable function's behavior.

* cargo fmt

* clippy

* retsore set var test

* remove redundant test

* ensure set_variable only takes into account GET variables, not SET

* factor url parameter setting code

* v0.40

* sqlpage.set_variable links to "?" when no parameter is present

- Renamed URLParameters module for clarity and removed the deprecated url_parameter_deserializer.
- Updated the set_variable function to return parameters directly instead of appending to a URL.
- Adjusted related function calls to reflect changes in URL parameter management.

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2025-11-24 12:55:32 +01:00
Ophir LOJKINE b11e7bf0ff Make URL and POST parameters immutable (#1109)
* Make URL and POST parameters immutable, separate from SET variables

- URL and POST parameters are now immutable after request initialization
- SET command creates user-defined variables in separate namespace
- Variable lookup: SET variables shadow request parameters
- Added sqlpage.variables('set') to inspect user-defined variables
- Simplified API: most functions now use &RequestInfo instead of &mut
- All tests passing (151 total)

* Restore deprecation warning for SET on POST variable names

* Restore deprecation warnings for $var accessing POST variables

- Warn when both URL and POST have same variable name
- Warn when $var is used for POST-only variable (should use :var)

* Simplify run_sql: always use clone_without_variables

No need to branch on whether variables are provided since we clone in both cases anyway.

* Revert "Simplify run_sql: always use clone_without_variables"

This reverts commit 60f5a05446.

* Fix cross-database test compatibility for immutable variables

Renamed test to run only on SQLite since json_extract() is SQLite-specific.
Other databases (PostgreSQL, MySQL, MSSQL) have different JSON functions.

* Fix test to work across all databases without json_extract

PostgreSQL doesn't have json_extract, so compare the full JSON string instead.

* Document variable system improvements in CHANGELOG

* Make CHANGELOG more explicit about breaking changes with examples

* Fix CHANGELOG: SET overwrites GET parameters, not POST

* Add database-specific examples for accessing original URL parameters
2025-11-19 03:10:54 +01:00
lovasoa c803214766 Add server timing for parameter binding in query execution
- Recorded server timing for the parameter binding process in the query execution flow.
- Updated tests to verify the inclusion of the new timing event in the server timing header.
2025-10-28 16:18:05 +01:00
lovasoa 1e396ac095 Fix missing server timing in some cases
- Updated response handling to use a builder pattern for better clarity and consistency.
- Enhanced server timing format to include microseconds in the output.
- Added a new test for server timing in redirect responses to ensure proper header inclusion.
2025-10-28 16:08:40 +01:00
lovasoa 06df761eee Refactor: Update ServerTiming to use Arc and simplify header generation
This commit modifies the ServerTiming structure to utilize Arc for thread-safe reference counting, enhancing performance and memory management. The header generation logic is streamlined, and related code is updated to reflect these changes. Additionally, tests are adjusted to ensure proper functionality with the new implementation.

Co-authored-by: contact <contact@ophir.dev>
2025-10-23 12:42:09 +02:00
Cursor Agent 38e08d78d1 Refactor: Pass ServerTiming to extract_request_info
Co-authored-by: contact <contact@ophir.dev>
2025-10-22 22:08:10 +00:00
Cursor Agent 5c415984bf Refactor Server-Timing header generation and add tests
This commit refactors the Server-Timing header generation to be more efficient and adds comprehensive tests for its behavior in development and production environments. It also includes a new test SQL file for server timing verification.

Co-authored-by: contact <contact@ophir.dev>
2025-10-22 20:03:09 +00:00
lovasoa b485028e37 Add end-to-end tests for table action buttons
- Implemented tests for edit, delete, and custom action buttons in the table component.
- Verified visibility and correct href attributes for action buttons.
- Added checks for disabled action buttons in the table.

Updated package dependencies for Playwright and Node types in package.json and package-lock.json.
2025-10-21 14:07:41 +02:00
lovasoa 93ca430e14 add a test for simple static set that sets a variable to the value of another variable 2025-10-14 16:37:23 +02:00
lovasoa 9dfbf42f56 enable arbitrary precision in the internal representation of values
- Enabled arbitrary precision for `serde_json` to handle large numbers without rounding.
- Refactored decimal handling in `sql_to_json.rs` to utilize a new function for converting decimals to JSON format.

Fixes https://github.com/sqlpage/SQLPage/issues/1052
2025-10-14 16:33:10 +02:00
lovasoa 3c6dda30b5 test fixes 2025-10-02 10:51:11 +02:00
lovasoa 746c70c95b Refactor SQL column handling to ensure consistent JSON output
- Updated column name handling in `row_to_json` to use lowercase for ODBC databases.
- Added `canonical_col_name` function to standardize column names.
- Modified SQL queries in tests to use lowercase column names for consistency.
- Enhanced tests for edge cases and variations in column naming.
2025-10-01 23:39:34 +02:00
Ophir LOJKINE 625deb973b Add and document sqlpage.hmac function (#1033)
* feat: Add sqlpage.hmac function for cryptographic signing

Co-authored-by: contact <contact@ophir.dev>

* feat: Add sqlpage.hmac function for secure data signing

Co-authored-by: contact <contact@ophir.dev>

* Test HMAC function with RFC vectors and update tests

Co-authored-by: contact <contact@ophir.dev>

* feat: Add sqlpage.hmac() function for secure signatures

Co-authored-by: contact <contact@ophir.dev>

* feat: Add base64 output option to hmac function

Co-authored-by: contact <contact@ophir.dev>

* Refactor hmac function for cleaner output formatting

Co-authored-by: contact <contact@ophir.dev>

* Add webhook HMAC signature validation tests

Co-authored-by: contact <contact@ophir.dev>

* Refactor HMAC function and update SQL examples for clarity and consistency

- Changed function parameters to remove Option types for data and key in the HMAC function.
- Improved SQL documentation and examples for HMAC usage, including clearer descriptions and updated error handling.
- Enhanced test cases for webhook HMAC validation to ensure accurate signature checks and responses.
- Removed obsolete test file for HMAC with null values.

* Update HMAC validation logic to handle NULL values in SQL queries

- Modified conditions in SQL queries to check for NULL values alongside signature mismatches.
- Enhanced documentation on NULL handling for HMAC checks to improve clarity and portability.

* remove debug logging from ci

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2025-10-01 21:07:36 +02:00
lovasoa ebdac5b29b Update sqlx dependencies to new commit hash and modify SQL queries in CSV data tests for consistency 2025-09-30 17:39:36 +02:00
lovasoa 12daf3eb8f Refactor test files for improved clarity and consistency
- Updated SQL queries in CSV data tests to use uppercase column names.
- Simplified database table management in core tests by separating drop and create statements.
- Enhanced transaction tests to utilize an enum for database type handling.
2025-09-30 15:07:01 +02:00
lovasoa 112ef55b11 Refactor SQL test file to derive database type from app state instead of environment variable for improved consistency and clarity. 2025-09-26 16:21:42 +02:00
lovasoa e5fa8d56a1 Refactor database handling to consistently use DbInfo and AnyKind across filesystem and SQL modules for improved clarity and flexibility. 2025-09-26 16:21:42 +02:00