|
|
@@ -8,7 +8,7 @@ import { Role, UserEntity, UserService } from '@d8d/core-module/user-module';
|
|
|
import { File } from '@d8d/core-module/file-module';
|
|
|
import { Company } from '@d8d/allin-company-module/entities';
|
|
|
import { Platform } from '@d8d/allin-platform-module/entities';
|
|
|
-import authRoutes from '../../src/routes/index';
|
|
|
+import { enterpriseAuthRoutes } from '../../src/routes/index';
|
|
|
import { AuthService } from '../../src/services/index';
|
|
|
import { DisabledStatus } from '@d8d/shared-types';
|
|
|
import { TestDataFactory } from '../utils/test-data-factory';
|
|
|
@@ -17,7 +17,7 @@ import { TestDataFactory } from '../utils/test-data-factory';
|
|
|
setupIntegrationDatabaseHooksWithEntities([UserEntity, Role, File, Company, Platform])
|
|
|
|
|
|
describe('企业用户认证API集成测试', () => {
|
|
|
- let client: ReturnType<typeof testClient<typeof authRoutes>>;
|
|
|
+ let client: ReturnType<typeof testClient<typeof enterpriseAuthRoutes>>;
|
|
|
let authService: AuthService;
|
|
|
let userService: UserService;
|
|
|
let testToken: string;
|
|
|
@@ -26,7 +26,7 @@ describe('企业用户认证API集成测试', () => {
|
|
|
|
|
|
beforeEach(async () => {
|
|
|
// 创建测试客户端
|
|
|
- client = testClient(authRoutes);
|
|
|
+ client = testClient(enterpriseAuthRoutes);
|
|
|
|
|
|
// 获取数据源
|
|
|
const dataSource = await IntegrationTestDatabase.getDataSource();
|
|
|
@@ -91,7 +91,7 @@ describe('企业用户认证API集成测试', () => {
|
|
|
password: 'EnterprisePass123!'
|
|
|
};
|
|
|
|
|
|
- const response = await client.api.v1.yongren.auth.login.$post({
|
|
|
+ const response = await client.login.$post({
|
|
|
json: loginData
|
|
|
});
|
|
|
|
|
|
@@ -116,7 +116,7 @@ describe('企业用户认证API集成测试', () => {
|
|
|
password: 'WrongPassword123!'
|
|
|
};
|
|
|
|
|
|
- const response = await client.api.v1.yongren.auth.login.$post({
|
|
|
+ const response = await client.login.$post({
|
|
|
json: loginData
|
|
|
});
|
|
|
|
|
|
@@ -133,7 +133,7 @@ describe('企业用户认证API集成测试', () => {
|
|
|
password: 'EnterprisePass123!'
|
|
|
};
|
|
|
|
|
|
- const response = await client.api.v1.yongren.auth.login.$post({
|
|
|
+ const response = await client.login.$post({
|
|
|
json: loginData
|
|
|
});
|
|
|
|
|
|
@@ -160,7 +160,7 @@ describe('企业用户认证API集成测试', () => {
|
|
|
password: 'Password123!'
|
|
|
};
|
|
|
|
|
|
- const response = await client.api.v1.yongren.auth.login.$post({
|
|
|
+ const response = await client.login.$post({
|
|
|
json: loginData
|
|
|
});
|
|
|
|
|
|
@@ -182,7 +182,7 @@ describe('企业用户认证API集成测试', () => {
|
|
|
password: 'EnterprisePass123!'
|
|
|
};
|
|
|
|
|
|
- const response = await client.api.v1.yongren.auth.login.$post({
|
|
|
+ const response = await client.login.$post({
|
|
|
json: loginData
|
|
|
});
|
|
|
|
|
|
@@ -196,7 +196,7 @@ describe('企业用户认证API集成测试', () => {
|
|
|
|
|
|
describe('企业用户信息端点测试 (GET /api/v1/yongren/auth/me)', () => {
|
|
|
it('应该成功获取企业用户信息,包含企业详情', async () => {
|
|
|
- const response = await client.api.v1.yongren.auth.me.$get({
|
|
|
+ const response = await client.me.$get({
|
|
|
header: {
|
|
|
Authorization: `Bearer ${testToken}`
|
|
|
}
|
|
|
@@ -227,7 +227,7 @@ describe('企业用户认证API集成测试', () => {
|
|
|
});
|
|
|
const nonEnterpriseToken = authService.generateToken(nonEnterpriseUser);
|
|
|
|
|
|
- const response = await client.api.v1.yongren.auth.me.$get({
|
|
|
+ const response = await client.me.$get({
|
|
|
header: {
|
|
|
Authorization: `Bearer ${nonEnterpriseToken}`
|
|
|
}
|
|
|
@@ -241,7 +241,7 @@ describe('企业用户认证API集成测试', () => {
|
|
|
});
|
|
|
|
|
|
it('应该拒绝无效令牌的访问', async () => {
|
|
|
- const response = await client.api.v1.yongren.auth.me.$get({
|
|
|
+ const response = await client.me.$get({
|
|
|
header: {
|
|
|
Authorization: 'Bearer invalid_token'
|
|
|
}
|
|
|
@@ -251,7 +251,7 @@ describe('企业用户认证API集成测试', () => {
|
|
|
});
|
|
|
|
|
|
it('应该拒绝缺少令牌的访问', async () => {
|
|
|
- const response = await client.api.v1.yongren.auth.me.$get();
|
|
|
+ const response = await client.me.$get();
|
|
|
|
|
|
expect(response.status).toBe(401);
|
|
|
});
|
|
|
@@ -259,7 +259,7 @@ describe('企业用户认证API集成测试', () => {
|
|
|
|
|
|
describe('企业用户退出登录端点测试 (POST /api/v1/yongren/auth/logout)', () => {
|
|
|
it('应该成功退出登录', async () => {
|
|
|
- const response = await client.api.v1.yongren.auth.logout.$post({
|
|
|
+ const response = await client.logout.$post({
|
|
|
header: {
|
|
|
Authorization: `Bearer ${testToken}`
|
|
|
}
|
|
|
@@ -273,7 +273,7 @@ describe('企业用户认证API集成测试', () => {
|
|
|
});
|
|
|
|
|
|
it('应该拒绝无效令牌的退出登录', async () => {
|
|
|
- const response = await client.api.v1.yongren.auth.logout.$post({
|
|
|
+ const response = await client.logout.$post({
|
|
|
header: {
|
|
|
Authorization: 'Bearer invalid_token'
|
|
|
}
|