diff --git a/tests/karate/features/apartments/get_one_rest.feature b/tests/karate/features/apartments/get_one_rest.feature index b95facf..53418bd 100644 --- a/tests/karate/features/apartments/get_one_rest.feature +++ b/tests/karate/features/apartments/get_one_rest.feature @@ -11,7 +11,7 @@ Scenario: returns 401 without token Given url apiBase + '/api/apartments/00000000-0000-0000-0000-000000000000' When method get Then status 401 -And match response == { error: 'Unauthorized: No token provided' } +And match response == { error: 'Unauthorized', message: 'Missing or malformed Authorization header' } Scenario: returns 404 when apartment does not exist Given url apiBase + '/api/apartments/00000000-0000-0000-0000-000000000000' diff --git a/tests/karate/features/auth/sync-wallet.feature b/tests/karate/features/auth/sync-wallet.feature index b664021..8298ce9 100644 --- a/tests/karate/features/auth/sync-wallet.feature +++ b/tests/karate/features/auth/sync-wallet.feature @@ -21,7 +21,7 @@ Feature: POST /api/auth/sync-wallet * def rows = db.query("SELECT * FROM public.user_wallets WHERE wallet_address = '" + stellarAddress + "'") And match rows[0].user_id == testUid And match rows[0].chain_type == 'STELLAR' - And match rows[0].is_primary == 'true' + And match rows[0].is_primary == '#? _ == "true" || _ == "t" || _ == true' Scenario: Upsert same address updates user_id and is_primary # Pre-seed the address under tenant-456, then reassign it to testUid via the endpoint diff --git a/webhook/src/routes/auth/sync-wallet.handler.js b/webhook/src/routes/auth/sync-wallet.handler.js index 059fb48..85b7ce2 100644 --- a/webhook/src/routes/auth/sync-wallet.handler.js +++ b/webhook/src/routes/auth/sync-wallet.handler.js @@ -11,7 +11,11 @@ const UPSERT_WALLET = ` INSERT INTO public.user_wallets (user_id, wallet_address, chain_type, is_primary) VALUES ($1, $2, $3, $4) ON CONFLICT (wallet_address) - DO UPDATE SET user_id = $1, is_primary = $4, updated_at = NOW() + DO UPDATE SET + user_id = EXCLUDED.user_id, + chain_type = EXCLUDED.chain_type, + is_primary = EXCLUDED.is_primary, + updated_at = NOW() RETURNING id, wallet_address, chain_type, is_primary `;