Commit graph

13 commits

Author SHA1 Message Date
Felipe M.
ca949c5dab
fix: resolve linting errors and e2e test failures
- Fix ST1005 linting errors by lowercasing error message strings
- Fix QF1008 linting errors by removing embedded field selectors in containers.go
- Update Alpine version from 3.22 to 3.21 in Makefile to fix Docker image resolution
- Update corresponding test expectations for error message changes
2025-07-30 17:48:13 +02:00
Federico Scodelaro
9f6a4c39d4
feat: support proxy forward headers authentication (#1105)
* feat: Add SSO forward header

* fix: Use domain layer

* test: Some test

* chore: Print new values when debugging

* chore: Rename enabled envvar

* fix: Wrongly parsing remote ip

* fix: Always validate token. NPE on validateSession

* fix: Dont overwrite token when sso

* fix: Best effort to get ip. Parse as ip:port and then as ip

* fix: Forgot to update handler version

* fix: Forgot to commit changes

* test: GetAccountByUsername

* chore: Rename some variables

* chore: return error from ssoAccount

* refactor: Extract sso proxy auth to own middleware

* fix: Dont panic if not sso account on legacy validate session

* ci: gofmt

---------

Co-authored-by: Felipe Martin <812088+fmartingr@users.noreply.github.com>
2025-07-12 12:11:42 +02:00
Felipe Martin
d41981861c
feat: add apis to handle bookmark tags (#1081)
* feat: add tag search api

* feat: add apis to add/remove bookmark tags

* chore: removed debug logger

* docs: updated swagger

* test: added tests

* test: invalid ids

* feat: webapp v2

* chore: updated swagger

* fix: route params missing

* feat: added cors middleware

* feat: built api implementation

* feat: implemented login in webapp

* feat; dark mode in web app

* feat: labels + i18n

* refactor: remove custom message output in json apis

* docs: updated swagger

* chore: make lint

* chore: make styles

* fix: include new webapp dist files (for now)
2025-03-15 21:28:26 +01:00
Felipe Martin
21165aa2e7
feat: allow tag filtering and count retrieval via api v1 (#1079)
* fix: frontend url to retrieve bookmark count

* chore: unneeded type in generic

* feat: allow tag filtering and count retrieval

* fix: make styles

* fix: make swagger

* fix: make swag

* tests: refactored gettags tests

* fix: initialise tags empty slice
2025-03-12 23:10:50 +01:00
Felipe Martin
cdc13edb77
feat(apiv1): refactor tags api (#1075)
* refactor: tags api into v1 api

* feat: tags api huge refactor

* fix: pg & sqlite tests

* tests: added more tests

* fix: bug on mysql bookmark and tag creation

* test: re-enabled test

* tests: slices test

* tests: model bookmarks

* test: use filepath.Join for path construction in bookmark tests
2025-03-11 17:37:08 +01:00
Felipe Martin
876d27f337
refactor: remove gin and use stdlib http server (#1064)
* refactor: base http server stdlib

* refactor: swagger and frontend routes

* fix: use global middlewares

* refactor: removed gin from testutils

* fix: object references in legacy webserver

* refactor: legacy, swagger and system handlers

* fix: added verbs to handlers

* fix: server handlers ordering

* refactor: bookmarks handlers

* refactor: system api routes

* tests: bookmark handlers

* refactor: migrated api auth routes

* chore: remove unused middlewares

* docs: add swagger docs to refactored system api

* chore: remove old auth routes

* refactor: account apis

* chore: removed old handlers

* fix: api v1 handlers missing middlewares

* refactor: migrated tag list route

* refactor: bookmark routes

* refactor: remove gin

* chore: make styles

* test: fixed tests

* test: generate binary file without text

* fix: global middleware missing from system api handler

* fix: incorrect api handler

* chore: avoid logging screenshot contents

* tests: bookmarks domain

* tests: shortcuts

* test: missing tests

* tests: server tests

* test: remove test using syscall to avoid windows errors

* chore: added middlewares
2025-02-26 20:50:48 +01:00
Felipe Martin
73a5239753
refactor(apiv1): accounts api (#825)
* list account and create account

* deleteaccount (wip)

* remove old accounts code

* fix from merge

* remove serve method from makefile

* ListAccounts, password hash on domain

* make lint

* more permissive assertion

* rename test

* update account

* Authorization

* updated api calls

* apis, pointers, auth

* swagger

* stylecheck

* domain validation

* tests

* swagger

* error handling

* fix system account changes

* Cleanup database interface

* test cleanup

* fixed nil references

* feat: Add logout endpoint to auth routes

* feat: Add logoutHandler for stateless JWT token logout

* fixed some bug catched in tests

* auth/account patch

* prettier

* remove test logs

* fixed incorrect number of parameters

* fixed swagger docs

* enable swagger in dev environment

* errors.Wrap -> fmt.Errorf

* test: Add comprehensive test cases for accounts API handlers

* fix: Resolve test failures in accounts_test.go

* test: Add tests for duplicate username handling in account creation and update

* feat: Add username uniqueness checks for account creation and update

refactor: Improve username existence checks in SQLite account methods

* linted

* test: Add comprehensive tests for auth domain token and credential validation

* test: Add comprehensive test cases for auth domain token creation and validation

* test: Add comprehensive error handling test cases for accounts domain

* refactor: Remove `SaveAccountSettings` method from database implementations

* test: Add test cases for password update functionality

* test(e2e): auth login

* lint

* send regular context to domain

* fixed e2e auth tests

* test: Add auth_test.go for end-to-end authentication testing

* feat: Add comprehensive authentication tests using Playwright and testcontainers

* fix: Handle multiple return values in Playwright test methods

* error message

* e2e playwrigth tests

* ci: setup playwrigth

* refactor: Update Playwright tests to use locator-based API

* refactor: Remove unnecessary alias for playwright-go expect import

* refactor: Replace deprecated expect package with WaitFor() method in Playwright tests

* fix: Resolve linting issues in e2e Playwright tests

* remove npm ci from e2e ci

* make playwright available in path

* typo

* re enabled ci

* base e2e accounts test

* more account e2e

* feat: Add HTML test reporter with screenshots and detailed results

* feat: Embed screenshots as base64 in HTML test report

* refactor: Remove GitHub step summary functionality from test helper

* refactor: Make reporter global to share test results across test helpers

* refactor: Add HandleSuccess method to TestHelper for consistent test result reporting

* feat: Add descriptive messages to all test assertions in TestHelper

* test: Add descriptive messages to assertions in accounts_test.go

* test: Add descriptive error messages to assertions in accounts_test.go

* feat: Add descriptive messages to assertions in accounts_test.go

* refactor: Update assertion functions to receive *testing.T as first argument

* refactor: Update accounts_test.go assertions to pass *testing.T argument

* refactor: Update accounts_test.go assertions to use *testing.T argument

* refactor: Update `accounts_test.go` to use `*testing.T` argument in `Require()` calls

* refactor: Update `th.Require()` calls with `t *testing.T` argument in accounts_test.go

* assert helper

* refactor: Refactor `False` test helper to use `Assert` function consistently

* refactor: Refactor `Equal` test helper to use `Assert` function

* refactor: Simplify Error test helper to use Assert function

* refactor: Refactor `NoError` to use `Assert` function for consistent error handling

* typo

* refactor: Differentiate between test cases and assertions in reporter

* refactor: Simplify AddResult method signature and use error message for assertion

* refactor: Simplify test report with focused failure details and screenshots

* refactor: Ensure assertions are always called in PlaywrightRequire helper methods

* refactor: Update test error messages to be action-oriented

* refactor: Update error messages to be more action-oriented in accounts_test.go

* refactor: Update error messages to be action-oriented in accounts_test.go

* refactor: Improve error messages in auth_test.go for better test readability

* refactor: Improve screenshot handling and test result reporting in Playwright test helper

* fix: Improve test reporting with detailed error messages and logging

* refactor: Remove unused runningInCI field from TestHelper struct

* fix: Improve message formatting in Assert method for better reporting

* assertions

* test: Add `Require()` calls to 007 test for improved error handling

* refactor: Update test reporter to include error details and improve HTML rendering

* fix: Properly escape and render base64 screenshot in HTML report

* fix: Correct base64 screenshot rendering in test reporter

* fixed tests + html report

* feat: Add artifact upload for e2e test report

* make lint

* chore: use correct version in user agent

* ci: run e2e after other checks

* chore: remove pre-commit
2025-02-22 20:38:36 +01:00
Felipe Martin
c58c35509b
feat: improve SQLite performance (#1024)
* refactor: Improve SQLite performance with connection pooling and retry logic

* feat: Add withTx and withTxRetry methods to SQLiteDatabase for handling database locks

* refactor: add Init command to all databases

* refactor: Improve transaction handling with retry and error management

* refactor: Remove panic/recover pattern in transaction handling

* refactor: Replace `errors.WithStack` with `fmt.Errorf` in transaction methods

* docs: Add docstrings to `withTx` and `withTxRetry` methods in SQLite database implementation

* feat: use new withTxRetry in SaveBookmarks

* feat: sqlite inmmediate transactions by default

* refactor: Split SQLiteDatabase into separate writer and reader dbbase instances

* refactor: Update Init method to configure both reader and writer database connections

* feat: use writer/reader sqlite databases

* refactor: Replace all read calls to use the `reader` database instance

* refactor: Replace errors.WithStack with fmt.Errorf and add nil checks

refactor: Replace errors.WithStack with fmt.Errorf and add proper error handling

fix: Handle potential database connection errors with improved error wrapping

refactor: Replace errors.WithStack with fmt.Errorf and improve error handling

refactor: Replace error handling with fmt.Errorf and proper nil checks

refactor: Replace errors.WithStack with fmt.Errorf and add nil error checks

refactor: Replace errors.WithStack with fmt.Errorf and add nil checks in sqlite.go

refactor: Replace errors.WithStack with fmt.Errorf and add nil checks

refactor: Replace errors.WithStack with fmt.Errorf and improve error handling

refactor: Replace remaining errors.WithStack with fmt.Errorf in sqlite.go

* refactor: Use withTxRetry for SetDatabaseSchemaVersion method

* fix: Simplify error handling in GetBookmark and GetAccount methods

* refactor: Remove duplicated non-nil error checks in sqlite.go

fix: duplicated non-nil checks

* tests: use testutil instead of a manual in memory sqlite db

* fix: openbsd sqlite connection
2025-01-02 09:46:39 +01:00
Felipe Martin
4a58ef0ff2
tests: added tests to the account domain (#993)
* tests: added tests to account domain

* refactor: ensure expiration comes from same value

* refactor: jwtclaims to model package

* refactor: add testutil.GetValidAccount
2024-11-01 10:07:11 +01:00
Felipe Martin
31767f75e6
feat: new migrations system (#876)
* feat: new migration system

* use newFuncMigration

* database version -> database schema version

* column name

* use path instead of filepath for goembed

* simplified migrations, added backwards compatible migrations
2024-04-27 07:46:36 +02:00
Felipe Martin
cc7c75116d
refactor: migrate bookmark static pages to new http server (#775)
* migrate bookmark content route to new http server

* new archive page

* remove unused go generate comment

* database mock

* utils cleanup

* unused var

* domains refactor and tests

* fixed secret key type

* redirect to login on ui errors

* fixed archive folder with storage domain

* webroot documentation

* some bookmark route tests

* fixed error in bookmark domain for non existant bookmarks

* centralice errors

* add coverage data to unittests

* added tests, refactor storage to use afero

* removed mock to avoid increasing complexity

* using deps to copy files around

* remove config usage (to deps)

* remove handler-ui file
2023-12-28 18:18:32 +01:00
Felipe Martin
a60dbf3dc5
Run legacy API and new API at the same time. (#648)
* config: backwards comptabile dir

* remove duplicated frontend

* frontend: move assets to assets folder

* legacy routes handler in gin

* templates and asset in different embed

* new routes

* frontend routes serve old views

* added DTO for account object

* api auth calls legacy handler

* frontend: handle new error messages

* frontend: update urls

* frontend: login using new api

* updated frontend tests

* chore: remove debug route

* create shiori/gopher user if no owner is present

* server as default command

* serve -> server

* refactored database logic, allow database url

* removed unused configuration

* storage docs

* refactor cli to use cfg and deps

* check errors only in server

* log fatal instead of os exit

* dont default data directory to current dir

* fixed sqlite path

* trigger build on prs

* avoid releasing if lint/test fails

* pull request condition

* event -> event_name

* Get correct pull request number

* added workflow to delete dangling tags

* fix: nil error checking

* set gin mode first

* set gin mode before initialization

* fix logger

* allow version bump from custom ref

* Updated matrix link to workspace
2023-07-19 18:25:41 +02:00
Felipe Martin
6f19c12c95
Start working on new REST API. Refactor logic in domains. (#497)
* added 404 template

* added auth domain

* added embed file for frontend

* added base config and dependencies

* added basic new http server

* added separated server command

* updated go modules

* removed modd file

* Added shortcut to send internal server error response

* Added JWT support to Auth Domain

* Added JWT support to API

* docs: added comments to response struct

* naming

* inline returns

* updated dependencies

* production logger

* bookmarks endpoint

* reverted old views api path

* frontend for api v1

* proper 404 error (not working atm)

* use response

* removed 404 html

* server error handler

* login and basic auth

* adjusted session duration

* properly retrieve tags

* properly delete bookmark

* cleanup

* archiver domain

* debug routes

* bookmark routes

* expiration by parameter

* move to logrus

* logout

* frontend cache

* updated dependencies

* http: migrated to gin

* linted

* Added version command

* unit tests, docs

* response test utils and tests

* remove logout handler

* auth

* createtag

* improved http test utilities

* assert message equals

* Remove 1.19 from test matrix

* moved api to v1 folder

* docs: contribute docs

* updated makefile

* updated usage docs

* warn in server command

* updaed docs with shiori version command

* Updated documentation

* deps: update
2023-07-17 14:30:18 +01:00