Skip to content

Commit 8979433

Browse files
committed
auth() no async
1 parent 7b10006 commit 8979433

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

packages/pgsql-test/__tests__/postgres-test.auth-methods.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ describe('auth() method', () => {
4040

4141
it('sets role and userId', async () => {
4242
const authRole = getRoleName('authenticated');
43-
await db.auth({ role: authRole, userId: '12345' });
43+
db.auth({ role: authRole, userId: '12345' });
4444

4545
const role = await db.query('SELECT current_setting(\'role\', true) AS role');
4646
expect(role.rows[0].role).toBe(authRole);
@@ -51,7 +51,7 @@ describe('auth() method', () => {
5151

5252
it('sets role with custom userIdKey', async () => {
5353
const authRole = getRoleName('authenticated');
54-
await db.auth({
54+
db.auth({
5555
role: authRole,
5656
userId: 'custom-123',
5757
userIdKey: 'app.user.id'
@@ -66,15 +66,15 @@ describe('auth() method', () => {
6666

6767
it('handles numeric userId', async () => {
6868
const authRole = getRoleName('authenticated');
69-
await db.auth({ role: authRole, userId: 99999 });
69+
db.auth({ role: authRole, userId: 99999 });
7070

7171
const userId = await db.query('SELECT current_setting(\'jwt.claims.user_id\', true) AS user_id');
7272
expect(userId.rows[0].user_id).toBe('99999');
7373
});
7474

7575
it('sets role without userId', async () => {
7676
const authRole = getRoleName('authenticated');
77-
await db.auth({ role: authRole });
77+
db.auth({ role: authRole });
7878

7979
const role = await db.query('SELECT current_setting(\'role\', true) AS role');
8080
expect(role.rows[0].role).toBe(authRole);
@@ -91,7 +91,7 @@ describe('auth() with default role', () => {
9191
});
9292

9393
it('uses default authenticated role when role not provided', async () => {
94-
await db.auth({ userId: 'test-user-456' });
94+
db.auth({ userId: 'test-user-456' });
9595

9696
const role = await db.query('SELECT current_setting(\'role\', true) AS role');
9797
const expectedRole = getRoleName('authenticated');
@@ -103,7 +103,7 @@ describe('auth() with default role', () => {
103103

104104
it('allows explicit role override', async () => {
105105
const anonRole = getRoleName('anonymous');
106-
await db.auth({ userId: 'admin-user-789', role: anonRole });
106+
db.auth({ userId: 'admin-user-789', role: anonRole });
107107

108108
const role = await db.query('SELECT current_setting(\'role\', true) AS role');
109109
expect(role.rows[0].role).toBe(anonRole);
@@ -113,7 +113,7 @@ describe('auth() with default role', () => {
113113
});
114114

115115
it('handles numeric userId with default role', async () => {
116-
await db.auth({ userId: 42 });
116+
db.auth({ userId: 42 });
117117

118118
const userId = await db.query('SELECT current_setting(\'jwt.claims.user_id\', true) AS user_id');
119119
expect(userId.rows[0].user_id).toBe('42');
@@ -166,7 +166,7 @@ describe('clearContext() method', () => {
166166
expect(userIdBefore.rows[0].user_id).toBe('old-user');
167167

168168
db.clearContext();
169-
await db.auth({ userId: 'new-user' });
169+
db.auth({ userId: 'new-user' });
170170

171171
const userId = await db.query('SELECT current_setting(\'jwt.claims.user_id\', true) AS user_id');
172172
expect(userId.rows[0].user_id).toBe('new-user');
@@ -200,7 +200,7 @@ describe('publish() method', () => {
200200

201201
it('preserves context after publish', async () => {
202202
const authRole = getRoleName('authenticated');
203-
await db.auth({ role: authRole, userId: 'test-999' });
203+
db.auth({ role: authRole, userId: 'test-999' });
204204

205205
await db.publish();
206206

packages/pgsql-test/src/test-client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export class PgTestClient {
9191
* Set authentication context for the current session.
9292
* Configures role and user ID using cascading defaults from options → opts.auth → RoleMapping.
9393
*/
94-
async auth(options: AuthOptions = {}): Promise<void> {
94+
auth(options: AuthOptions = {}): void {
9595
const role =
9696
options.role ?? this.opts.auth?.role ?? getRoleName('authenticated', this.opts);
9797
const userIdKey =

0 commit comments

Comments
 (0)