refactor:项目架构重构和命名规范化
- 统一文件命名为snake_case格式(kebab-case snake_case) - 重构zulip模块为zulip_core,明确Core层职责 - 重构user-mgmt模块为user_mgmt,统一命名规范 - 调整模块依赖关系,优化架构分层 - 删除过时的文件和目录结构 - 更新相关文档和配置文件 本次重构涉及大量文件重命名和模块重组, 旨在建立更清晰的项目架构和统一的命名规范。
This commit is contained in:
@@ -39,8 +39,9 @@ import {
|
||||
IZulipConfigService,
|
||||
ZulipClientInstance,
|
||||
SendMessageResult,
|
||||
} from '../../core/zulip/interfaces/zulip-core.interfaces';
|
||||
import { ApiKeySecurityService } from '../../core/zulip/services/api_key_security.service';
|
||||
} from '../../core/zulip_core/interfaces/zulip_core.interfaces';
|
||||
import { ApiKeySecurityService } from '../../core/zulip_core/services/api_key_security.service';
|
||||
import { LoginCoreService } from '../../core/login_core/login_core.service';
|
||||
|
||||
describe('ZulipService', () => {
|
||||
let service: ZulipService;
|
||||
@@ -49,6 +50,7 @@ describe('ZulipService', () => {
|
||||
let mockMessageFilter: jest.Mocked<MessageFilterService>;
|
||||
let mockEventProcessor: jest.Mocked<ZulipEventProcessorService>;
|
||||
let mockConfigManager: jest.Mocked<IZulipConfigService>;
|
||||
let mockLoginCoreService: jest.Mocked<LoginCoreService>;
|
||||
|
||||
// 创建模拟的Zulip客户端实例
|
||||
const createMockClientInstance = (overrides: Partial<ZulipClientInstance> = {}): ZulipClientInstance => ({
|
||||
@@ -136,6 +138,14 @@ describe('ZulipService', () => {
|
||||
validateConfig: jest.fn(),
|
||||
} as any;
|
||||
|
||||
mockLoginCoreService = {
|
||||
verifyToken: jest.fn(),
|
||||
generateTokens: jest.fn(),
|
||||
refreshTokens: jest.fn(),
|
||||
revokeToken: jest.fn(),
|
||||
validateTokenPayload: jest.fn(),
|
||||
} as any;
|
||||
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
providers: [
|
||||
ZulipService,
|
||||
@@ -160,7 +170,7 @@ describe('ZulipService', () => {
|
||||
useValue: mockConfigManager,
|
||||
},
|
||||
{
|
||||
provide: ApiKeySecurityService,
|
||||
provide: 'API_KEY_SECURITY_SERVICE',
|
||||
useValue: {
|
||||
extractApiKey: jest.fn(),
|
||||
validateApiKey: jest.fn(),
|
||||
@@ -172,10 +182,39 @@ describe('ZulipService', () => {
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
provide: LoginCoreService,
|
||||
useValue: mockLoginCoreService,
|
||||
},
|
||||
],
|
||||
}).compile();
|
||||
|
||||
service = module.get<ZulipService>(ZulipService);
|
||||
|
||||
// 配置LoginCoreService的默认mock行为
|
||||
mockLoginCoreService.verifyToken.mockImplementation(async (token: string) => {
|
||||
// 模拟token验证逻辑
|
||||
if (token.startsWith('invalid')) {
|
||||
throw new Error('Invalid token');
|
||||
}
|
||||
|
||||
// 从token中提取用户信息(模拟JWT解析)
|
||||
const userId = `user_${token.substring(0, 8)}`;
|
||||
const username = `Player_${userId.substring(5, 10)}`;
|
||||
const email = `${userId}@example.com`;
|
||||
|
||||
return {
|
||||
sub: userId,
|
||||
username,
|
||||
email,
|
||||
role: 1, // 数字类型的角色
|
||||
type: 'access' as const,
|
||||
iat: Math.floor(Date.now() / 1000),
|
||||
exp: Math.floor(Date.now() / 1000) + 3600,
|
||||
iss: 'whale-town',
|
||||
aud: 'whale-town-users',
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
|
||||
Reference in New Issue
Block a user