-
Notifications
You must be signed in to change notification settings - Fork 380
Expand file tree
/
Copy pathtcloud_utils.ts
More file actions
34 lines (32 loc) · 985 Bytes
/
tcloud_utils.ts
File metadata and controls
34 lines (32 loc) · 985 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import path from 'path'
import fs from 'fs-extra'
/**
* Helper function to set up a pre-authenticated tcloud state
*/
export async function setupAuthenticatedState(tempDir: string): Promise<void> {
const authStateFile = path.join(tempDir, '.tcloud_auth_state.json')
const authState = {
is_logged_in: true,
id_token: {
iss: 'https://mock.tobikodata.com',
aud: 'mock-audience',
sub: 'user-123',
scope: 'openid email profile',
iat: Math.floor(Date.now() / 1000),
exp: Math.floor(Date.now() / 1000) + 3600, // Valid for 1 hour
email: 'test@example.com',
name: 'Test User',
},
}
await fs.writeJson(authStateFile, authState)
}
/**
* Helper function to set the tcloud version for testing
*/
export async function setTcloudVersion(
tempDir: string,
version: string,
): Promise<void> {
const versionStateFile = path.join(tempDir, '.tcloud_version_state.json')
await fs.writeJson(versionStateFile, { version })
}