Skip to content

Commit

Permalink
Fix JWT tests
Browse files Browse the repository at this point in the history
  • Loading branch information
slvrtrn committed Dec 16, 2024
1 parent d06f0da commit c07fdd0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
11 changes: 6 additions & 5 deletions packages/client-node/__tests__/integration/node_jwt_auth.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import type { ClickHouseClient } from '@clickhouse/client-common'
import { createTestClient, TestEnv, whenOnEnv } from '@test/utils'
import { TestEnv, whenOnEnv } from '@test/utils'
import { EnvKeys, getFromEnv } from '@test/utils/env'
import { createClient } from '../../src'
import type { NodeClickHouseClient } from '../../src/client'
import { makeJWT } from '../utils/jwt'

whenOnEnv(TestEnv.CloudSMT).describe('[Node.js] JWT auth', () => {
let jwtClient: ClickHouseClient
let jwtClient: NodeClickHouseClient
let url: string
let jwt: string

Expand All @@ -17,7 +18,7 @@ whenOnEnv(TestEnv.CloudSMT).describe('[Node.js] JWT auth', () => {
})

it('should work with client configuration', async () => {
jwtClient = createTestClient({
jwtClient = createClient({
url,
access_token: jwt,
})
Expand All @@ -29,7 +30,7 @@ whenOnEnv(TestEnv.CloudSMT).describe('[Node.js] JWT auth', () => {
})

it('should override the client instance auth', async () => {
jwtClient = createTestClient({
jwtClient = createClient({
url,
username: 'gibberish',
password: 'gibberish',
Expand Down
10 changes: 5 additions & 5 deletions packages/client-web/__tests__/jwt/web_jwt_auth.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { ClickHouseClient } from '@clickhouse/client-common'
import { createTestClient } from '@test/utils'
import { EnvKeys, getFromEnv } from '@test/utils/env'
import { createClient } from '../../src'
import type { WebClickHouseClient } from '../../src/client'

/** Cannot use the jsonwebtoken library to generate the token: it is Node.js only.
* The access token should be generated externally before running the test,
* and set as the CLICKHOUSE_JWT_ACCESS_TOKEN environment variable */
describe('[Web] JWT auth', () => {
let client: ClickHouseClient
let client: WebClickHouseClient
let url: string
let jwt: string

Expand All @@ -19,7 +19,7 @@ describe('[Web] JWT auth', () => {
})

it('should work with client configuration', async () => {
client = createTestClient({
client = createClient({
url,
access_token: jwt,
})
Expand All @@ -31,7 +31,7 @@ describe('[Web] JWT auth', () => {
})

it('should override the client instance auth', async () => {
client = createTestClient({
client = createClient({
url,
username: 'gibberish',
password: 'gibberish',
Expand Down

0 comments on commit c07fdd0

Please sign in to comment.