This repository has been archived by the owner on Jun 25, 2024. It is now read-only.
generated from JupiterOne-Archives/integration-template
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathconfig.ts
87 lines (77 loc) · 3.09 KB
/
config.ts
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import { IntegrationConfig, SerializedIntegrationConfig } from '../src/types';
import * as dotenv from 'dotenv';
import * as path from 'path';
import * as fs from 'fs';
import { ParsedServiceAccountKeyFile } from '../src/utils/parseServiceAccountKeyFile';
import { deserializeIntegrationConfig } from '../src/utils/integrationConfig';
import { omitNewRegionsFromTests } from './regions';
omitNewRegionsFromTests();
if (process.env.LOAD_ENV) {
dotenv.config({
path: path.join(__dirname, '../.env'),
});
}
export const DEFAULT_INTEGRATION_CONFIG_PROJECT_ID = 'j1-gc-integration-dev-v2';
// NOTE: This is a bogus certificate for tests. The Google Cloud SDK asserts
// that a certificate is valid.
export const DEFAULT_INTEGRATION_PRIVATE_KEY = fs.readFileSync(
path.join(__dirname, '../fake-private-test-key.key'),
{
encoding: 'utf-8',
},
);
export const DEFAULT_INTEGRATION_CLIENT_EMAIL =
'j1-gc-integration-dev-sa@j1-gc-integration-dev.iam.gserviceaccount.com';
export const DEFAULT_INTEGRATION_CONFIG_SERVICE_ACCOUNT_KEY_FILE: ParsedServiceAccountKeyFile =
{
type: 'service_account',
project_id: DEFAULT_INTEGRATION_CONFIG_PROJECT_ID,
private_key_id: 'abcdef123456abcdef123456abcdef123456abc',
private_key: DEFAULT_INTEGRATION_PRIVATE_KEY,
client_email: DEFAULT_INTEGRATION_CLIENT_EMAIL,
client_id: '12345678901234567890',
auth_uri: 'https://accounts.google.com/o/oauth2/auth',
token_uri: 'https://oauth2.googleapis.com/token',
auth_provider_x509_cert_url: 'https://www.googleapis.com/oauth2/v1/certs',
client_x509_cert_url: 'https://www.googleapis.com/abc',
};
export const serializedIntegrationConfig: SerializedIntegrationConfig = {
serviceAccountKeyFile:
process.env.SERVICE_ACCOUNT_KEY_FILE ||
JSON.stringify(DEFAULT_INTEGRATION_CONFIG_SERVICE_ACCOUNT_KEY_FILE),
organizationId: '958457776463',
configureOrganizationProjects: true,
};
export const integrationConfig: IntegrationConfig =
deserializeIntegrationConfig(serializedIntegrationConfig);
export const setupErrorIntegrationConfig: IntegrationConfig = {
...serializedIntegrationConfig,
serviceAccountKeyConfig: {
type: 'service_account',
project_id: 'mknoedel-project-1',
private_key_id: 'abcdef123456abcdef123456abcdef123456abc',
private_key: DEFAULT_INTEGRATION_PRIVATE_KEY,
client_email:
'j1-gc-integration-dev-sa@mknoedel-project-1.iam.gserviceaccount.com',
client_id: '106311430307184243261',
auth_uri: 'https://accounts.google.com/o/oauth2/auth',
token_uri: 'https://oauth2.googleapis.com/token',
auth_provider_x509_cert_url: 'https://www.googleapis.com/oauth2/v1/certs',
client_x509_cert_url: 'https://www.googleapis.com/abc',
},
};
export function getMockSerializedIntegrationConfig(): SerializedIntegrationConfig {
return {
serviceAccountKeyFile: JSON.stringify(
DEFAULT_INTEGRATION_CONFIG_SERVICE_ACCOUNT_KEY_FILE,
),
};
}
export function getMockIntegrationConfig(
partial?: Partial<IntegrationConfig>,
): IntegrationConfig {
return {
...deserializeIntegrationConfig(getMockSerializedIntegrationConfig()),
...partial,
};
}