mirror of https://github.com/buster-so/buster.git
Merge pull request #460 from buster-so/dal/slack-url-cleanup
change server url
This commit is contained in:
commit
a1f0c9e078
|
@ -11,5 +11,5 @@ TRIGGER_SECRET_KEY=
|
||||||
SLACK_INTEGRATION_ENABLED=false
|
SLACK_INTEGRATION_ENABLED=false
|
||||||
SLACK_CLIENT_ID=""
|
SLACK_CLIENT_ID=""
|
||||||
SLACK_CLIENT_SECRET=""
|
SLACK_CLIENT_SECRET=""
|
||||||
SLACK_REDIRECT_URI="http://localhost:3000/api/v2/slack/auth/callback"
|
SERVER_URL="http://localhost:3002"
|
||||||
SLACK_APP_SUPPORT_URL=
|
SLACK_APP_SUPPORT_URL=
|
|
@ -12,8 +12,8 @@ declare global {
|
||||||
SLACK_INTEGRATION_ENABLED: string;
|
SLACK_INTEGRATION_ENABLED: string;
|
||||||
SLACK_CLIENT_ID: string;
|
SLACK_CLIENT_ID: string;
|
||||||
SLACK_CLIENT_SECRET: string;
|
SLACK_CLIENT_SECRET: string;
|
||||||
SLACK_REDIRECT_URI: string;
|
|
||||||
SLACK_APP_SUPPORT_URL: string;
|
SLACK_APP_SUPPORT_URL: string;
|
||||||
|
SERVER_URL: string;
|
||||||
NODE_ENV?: 'development' | 'production' | 'test';
|
NODE_ENV?: 'development' | 'production' | 'test';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,9 +26,9 @@ const env = {
|
||||||
const slackEnv = {
|
const slackEnv = {
|
||||||
SLACK_CLIENT_ID: process.env.SLACK_CLIENT_ID,
|
SLACK_CLIENT_ID: process.env.SLACK_CLIENT_ID,
|
||||||
SLACK_CLIENT_SECRET: process.env.SLACK_CLIENT_SECRET,
|
SLACK_CLIENT_SECRET: process.env.SLACK_CLIENT_SECRET,
|
||||||
SLACK_REDIRECT_URI: process.env.SLACK_REDIRECT_URI,
|
|
||||||
SLACK_INTEGRATION_ENABLED: process.env.SLACK_INTEGRATION_ENABLED || 'false',
|
SLACK_INTEGRATION_ENABLED: process.env.SLACK_INTEGRATION_ENABLED || 'false',
|
||||||
SLACK_APP_SUPPORT_URL: process.env.SLACK_APP_SUPPORT_URL,
|
SLACK_APP_SUPPORT_URL: process.env.SLACK_APP_SUPPORT_URL,
|
||||||
|
SERVER_URL: process.env.SERVER_URL,
|
||||||
};
|
};
|
||||||
|
|
||||||
let hasErrors = false;
|
let hasErrors = false;
|
||||||
|
@ -50,8 +50,8 @@ if (slackEnv.SLACK_INTEGRATION_ENABLED === 'true') {
|
||||||
const requiredSlackVars = [
|
const requiredSlackVars = [
|
||||||
'SLACK_CLIENT_ID',
|
'SLACK_CLIENT_ID',
|
||||||
'SLACK_CLIENT_SECRET',
|
'SLACK_CLIENT_SECRET',
|
||||||
'SLACK_REDIRECT_URI',
|
|
||||||
'SLACK_APP_SUPPORT_URL',
|
'SLACK_APP_SUPPORT_URL',
|
||||||
|
'SERVER_URL',
|
||||||
];
|
];
|
||||||
|
|
||||||
for (const envKey of requiredSlackVars) {
|
for (const envKey of requiredSlackVars) {
|
||||||
|
|
|
@ -11,7 +11,6 @@ const skipIfNoEnv =
|
||||||
!process.env.DATABASE_URL ||
|
!process.env.DATABASE_URL ||
|
||||||
!process.env.SLACK_CLIENT_ID ||
|
!process.env.SLACK_CLIENT_ID ||
|
||||||
!process.env.SLACK_CLIENT_SECRET ||
|
!process.env.SLACK_CLIENT_SECRET ||
|
||||||
!process.env.SLACK_REDIRECT_URI ||
|
|
||||||
!process.env.SUPABASE_URL ||
|
!process.env.SUPABASE_URL ||
|
||||||
!process.env.SUPABASE_SERVICE_ROLE_KEY ||
|
!process.env.SUPABASE_SERVICE_ROLE_KEY ||
|
||||||
!process.env.SLACK_TEST_ACCESS_TOKEN; // Additional env var for testing channels
|
!process.env.SLACK_TEST_ACCESS_TOKEN; // Additional env var for testing channels
|
||||||
|
|
|
@ -12,7 +12,6 @@ const skipIfNoEnv =
|
||||||
!process.env.DATABASE_URL ||
|
!process.env.DATABASE_URL ||
|
||||||
!process.env.SLACK_CLIENT_ID ||
|
!process.env.SLACK_CLIENT_ID ||
|
||||||
!process.env.SLACK_CLIENT_SECRET ||
|
!process.env.SLACK_CLIENT_SECRET ||
|
||||||
!process.env.SLACK_REDIRECT_URI ||
|
|
||||||
!process.env.SUPABASE_URL ||
|
!process.env.SUPABASE_URL ||
|
||||||
!process.env.SUPABASE_SERVICE_ROLE_KEY;
|
!process.env.SUPABASE_SERVICE_ROLE_KEY;
|
||||||
|
|
||||||
|
@ -80,7 +79,6 @@ describe.skipIf(skipIfNoEnv)('SlackHandler Integration Tests', () => {
|
||||||
// Ensure all required env vars are set for the service
|
// Ensure all required env vars are set for the service
|
||||||
process.env.SLACK_CLIENT_ID = process.env.SLACK_CLIENT_ID || 'test-client-id';
|
process.env.SLACK_CLIENT_ID = process.env.SLACK_CLIENT_ID || 'test-client-id';
|
||||||
process.env.SLACK_CLIENT_SECRET = process.env.SLACK_CLIENT_SECRET || 'test-client-secret';
|
process.env.SLACK_CLIENT_SECRET = process.env.SLACK_CLIENT_SECRET || 'test-client-secret';
|
||||||
process.env.SLACK_REDIRECT_URI = process.env.SLACK_REDIRECT_URI || 'https://test.com/callback';
|
|
||||||
|
|
||||||
// Create unique test organization and user
|
// Create unique test organization and user
|
||||||
const { organizationId, userId } = await createTestOrgAndUser();
|
const { organizationId, userId } = await createTestOrgAndUser();
|
||||||
|
|
|
@ -9,7 +9,6 @@ const skipIfNoEnv =
|
||||||
!process.env.DATABASE_URL ||
|
!process.env.DATABASE_URL ||
|
||||||
!process.env.SLACK_CLIENT_ID ||
|
!process.env.SLACK_CLIENT_ID ||
|
||||||
!process.env.SLACK_CLIENT_SECRET ||
|
!process.env.SLACK_CLIENT_SECRET ||
|
||||||
!process.env.SLACK_REDIRECT_URI ||
|
|
||||||
!process.env.SUPABASE_URL ||
|
!process.env.SUPABASE_URL ||
|
||||||
!process.env.SUPABASE_SERVICE_ROLE_KEY;
|
!process.env.SUPABASE_SERVICE_ROLE_KEY;
|
||||||
|
|
||||||
|
@ -99,8 +98,7 @@ describe.skipIf(skipIfNoEnv)('SlackOAuthService Integration Tests', () => {
|
||||||
// Set test environment variables
|
// Set test environment variables
|
||||||
process.env.SLACK_CLIENT_ID = process.env.SLACK_CLIENT_ID || 'test-client-id';
|
process.env.SLACK_CLIENT_ID = process.env.SLACK_CLIENT_ID || 'test-client-id';
|
||||||
process.env.SLACK_CLIENT_SECRET = process.env.SLACK_CLIENT_SECRET || 'test-client-secret';
|
process.env.SLACK_CLIENT_SECRET = process.env.SLACK_CLIENT_SECRET || 'test-client-secret';
|
||||||
process.env.SLACK_REDIRECT_URI =
|
process.env.SERVER_URL = process.env.SERVER_URL || 'https://test.com';
|
||||||
process.env.SLACK_REDIRECT_URI || 'https://test.com/callback';
|
|
||||||
const { SlackOAuthService } = await import('./slack-oauth-service');
|
const { SlackOAuthService } = await import('./slack-oauth-service');
|
||||||
service = new SlackOAuthService();
|
service = new SlackOAuthService();
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ vi.mock('@buster/slack', () => ({
|
||||||
// Mock environment variables before importing
|
// Mock environment variables before importing
|
||||||
vi.stubEnv('SLACK_CLIENT_ID', 'test-client-id');
|
vi.stubEnv('SLACK_CLIENT_ID', 'test-client-id');
|
||||||
vi.stubEnv('SLACK_CLIENT_SECRET', 'test-client-secret');
|
vi.stubEnv('SLACK_CLIENT_SECRET', 'test-client-secret');
|
||||||
vi.stubEnv('SLACK_REDIRECT_URI', 'https://test.com/callback');
|
vi.stubEnv('SERVER_URL', 'https://test.com');
|
||||||
vi.stubEnv('SLACK_INTEGRATION_ENABLED', 'true');
|
vi.stubEnv('SLACK_INTEGRATION_ENABLED', 'true');
|
||||||
|
|
||||||
// Import after mocking env vars
|
// Import after mocking env vars
|
||||||
|
@ -27,7 +27,7 @@ describe('SlackOAuthService', () => {
|
||||||
// Reset env vars to defaults
|
// Reset env vars to defaults
|
||||||
vi.stubEnv('SLACK_CLIENT_ID', 'test-client-id');
|
vi.stubEnv('SLACK_CLIENT_ID', 'test-client-id');
|
||||||
vi.stubEnv('SLACK_CLIENT_SECRET', 'test-client-secret');
|
vi.stubEnv('SLACK_CLIENT_SECRET', 'test-client-secret');
|
||||||
vi.stubEnv('SLACK_REDIRECT_URI', 'https://test.com/callback');
|
vi.stubEnv('SERVER_URL', 'https://test.com');
|
||||||
vi.stubEnv('SLACK_INTEGRATION_ENABLED', 'true');
|
vi.stubEnv('SLACK_INTEGRATION_ENABLED', 'true');
|
||||||
service = new SlackOAuthService();
|
service = new SlackOAuthService();
|
||||||
});
|
});
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { oauthStateStorage, tokenStorage } from './token-storage';
|
||||||
const SlackEnvSchema = z.object({
|
const SlackEnvSchema = z.object({
|
||||||
SLACK_CLIENT_ID: z.string().min(1),
|
SLACK_CLIENT_ID: z.string().min(1),
|
||||||
SLACK_CLIENT_SECRET: z.string().min(1),
|
SLACK_CLIENT_SECRET: z.string().min(1),
|
||||||
SLACK_REDIRECT_URI: z.string().url(),
|
SERVER_URL: z.string().url(),
|
||||||
SLACK_INTEGRATION_ENABLED: z
|
SLACK_INTEGRATION_ENABLED: z
|
||||||
.string()
|
.string()
|
||||||
.transform((val) => val === 'true')
|
.transform((val) => val === 'true')
|
||||||
|
@ -39,7 +39,7 @@ export class SlackOAuthService {
|
||||||
{
|
{
|
||||||
clientId: this.env.SLACK_CLIENT_ID,
|
clientId: this.env.SLACK_CLIENT_ID,
|
||||||
clientSecret: this.env.SLACK_CLIENT_SECRET,
|
clientSecret: this.env.SLACK_CLIENT_SECRET,
|
||||||
redirectUri: this.env.SLACK_REDIRECT_URI,
|
redirectUri: `${this.env.SERVER_URL}/api/v2/slack/auth/callback`,
|
||||||
scopes: [
|
scopes: [
|
||||||
'channels:history',
|
'channels:history',
|
||||||
'channels:read',
|
'channels:read',
|
||||||
|
@ -60,7 +60,7 @@ export class SlackOAuthService {
|
||||||
environment: {
|
environment: {
|
||||||
hasClientId: !!process.env.SLACK_CLIENT_ID,
|
hasClientId: !!process.env.SLACK_CLIENT_ID,
|
||||||
hasClientSecret: !!process.env.SLACK_CLIENT_SECRET,
|
hasClientSecret: !!process.env.SLACK_CLIENT_SECRET,
|
||||||
hasRedirectUri: !!process.env.SLACK_REDIRECT_URI,
|
hasServerUrl: !!process.env.SERVER_URL,
|
||||||
integrationEnabled: process.env.SLACK_INTEGRATION_ENABLED,
|
integrationEnabled: process.env.SLACK_INTEGRATION_ENABLED,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue