test: comprehensive test suites and quality gates pass across backend, storefront and admin
- Backend (NestJS): 82 suites, 641 tests passing; 0 ESLint errors; 0 tsc errors. Hardened SSL cert/key matching, SSRF IP pinning, and eBank validation. - Admin Panel (Vite/React): 48 suites, 300 tests passing; 0 ESLint errors; 0 tsc errors. Full coverage across all pages and settings. - Storefront (Next.js): 62 suites, 368 tests passing; 0 ESLint errors; 0 tsc errors. - Fixed unmount lifecycle guards, promise error handling, and component edge cases.
This commit is contained in:
1 parent
1e73715169
commit
ddbf1ca026
439 files changed
+32911
-6107
No files matched your search
@@ -8,74 +8,74 @@ import {
|
||||
UploadedFiles,
|
||||
Query,
|
||||
BadRequestException,
|
||||
} from '@nestjs/common';
|
||||
import { AnyFilesInterceptor } from '@nestjs/platform-express';
|
||||
import { SslService } from './ssl.service';
|
||||
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
|
||||
import { RolesGuard } from '../common/guards/roles.guard';
|
||||
import { Roles } from '../common/decorators/roles.decorator';
|
||||
import { ApiTags, ApiBearerAuth, ApiOperation } from '@nestjs/swagger';
|
||||
} from "@nestjs/common";
|
||||
import { AnyFilesInterceptor } from "@nestjs/platform-express";
|
||||
import { SslService } from "./ssl.service";
|
||||
import { JwtAuthGuard } from "../auth/jwt-auth.guard";
|
||||
import { RolesGuard } from "../common/guards/roles.guard";
|
||||
import { Roles } from "../common/decorators/roles.decorator";
|
||||
import { ApiTags, ApiBearerAuth, ApiOperation } from "@nestjs/swagger";
|
||||
|
||||
@ApiTags('Admin SSL - مدیریت گواهیهای امنیتی SSL')
|
||||
@ApiTags("Admin SSL - مدیریت گواهیهای امنیتی SSL")
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles('Admin')
|
||||
@Controller('admin/ssl')
|
||||
@Roles("Admin")
|
||||
@Controller("admin/ssl")
|
||||
export class SslController {
|
||||
constructor(private readonly sslService: SslService) {}
|
||||
|
||||
@Get('status')
|
||||
@ApiOperation({ summary: 'دریافت وضعیت و جزئیات گواهی SSL فعلی سرور' })
|
||||
@Get("status")
|
||||
@ApiOperation({ summary: "دریافت وضعیت و جزئیات گواهی SSL فعلی سرور" })
|
||||
getStatus() {
|
||||
const status = this.sslService.getStatus();
|
||||
return { success: true, data: status };
|
||||
}
|
||||
|
||||
@Post('update-text')
|
||||
@ApiOperation({ summary: 'بهروزرسانی گواهی SSL از طریق متن و کلید' })
|
||||
@Post("update-text")
|
||||
@ApiOperation({ summary: "بهروزرسانی گواهی SSL از طریق متن و کلید" })
|
||||
updateByText(
|
||||
@Body('certificate') certificate: string,
|
||||
@Body('privateKey') privateKey: string,
|
||||
@Body("certificate") certificate: string,
|
||||
@Body("privateKey") privateKey: string,
|
||||
) {
|
||||
return this.sslService.updateCertificates(certificate, privateKey);
|
||||
}
|
||||
|
||||
@Post('upload')
|
||||
@Post("upload")
|
||||
@UseInterceptors(AnyFilesInterceptor())
|
||||
@ApiOperation({
|
||||
summary: 'آپلود فایلهای گواهی SSL (FullChain/CRT و PrivateKey)',
|
||||
summary: "آپلود فایلهای گواهی SSL (FullChain/CRT و PrivateKey)",
|
||||
})
|
||||
uploadFiles(
|
||||
@UploadedFiles() files: Array<Express.Multer.File>,
|
||||
@Body('certificateText') certText?: string,
|
||||
@Body('privateKeyText') keyText?: string,
|
||||
@Body("certificateText") certText?: string,
|
||||
@Body("privateKeyText") keyText?: string,
|
||||
) {
|
||||
let certContent = certText || '';
|
||||
let keyContent = keyText || '';
|
||||
let certContent = certText || "";
|
||||
let keyContent = keyText || "";
|
||||
|
||||
if (files && files.length > 0) {
|
||||
for (const file of files) {
|
||||
const content = file.buffer.toString('utf8');
|
||||
const content = file.buffer.toString("utf8");
|
||||
const fieldName = file.fieldname.toLowerCase();
|
||||
const originalName = file.originalname.toLowerCase();
|
||||
|
||||
if (
|
||||
fieldName.includes('cert') ||
|
||||
fieldName.includes('fullchain') ||
|
||||
fieldName.includes('crt') ||
|
||||
originalName.endsWith('.crt') ||
|
||||
originalName.includes('fullchain') ||
|
||||
originalName.includes('cert') ||
|
||||
content.includes('BEGIN CERTIFICATE')
|
||||
fieldName.includes("cert") ||
|
||||
fieldName.includes("fullchain") ||
|
||||
fieldName.includes("crt") ||
|
||||
originalName.endsWith(".crt") ||
|
||||
originalName.includes("fullchain") ||
|
||||
originalName.includes("cert") ||
|
||||
content.includes("BEGIN CERTIFICATE")
|
||||
) {
|
||||
certContent = content;
|
||||
} else if (
|
||||
fieldName.includes('key') ||
|
||||
originalName.endsWith('.key') ||
|
||||
originalName.includes('priv') ||
|
||||
content.includes('BEGIN PRIVATE KEY') ||
|
||||
content.includes('BEGIN RSA PRIVATE KEY') ||
|
||||
content.includes('BEGIN EC PRIVATE KEY')
|
||||
fieldName.includes("key") ||
|
||||
originalName.endsWith(".key") ||
|
||||
originalName.includes("priv") ||
|
||||
content.includes("BEGIN PRIVATE KEY") ||
|
||||
content.includes("BEGIN RSA PRIVATE KEY") ||
|
||||
content.includes("BEGIN EC PRIVATE KEY")
|
||||
) {
|
||||
keyContent = content;
|
||||
}
|
||||
@@ -84,20 +84,20 @@ export class SslController {
|
||||
|
||||
if (!certContent || !keyContent) {
|
||||
throw new BadRequestException(
|
||||
'ارسال هر دو فایل گواهی (Fullchain/CRT) و کلید خصوصی (Private Key) الزامی است.',
|
||||
"ارسال هر دو فایل گواهی (Fullchain/CRT) و کلید خصوصی (Private Key) الزامی است.",
|
||||
);
|
||||
}
|
||||
|
||||
return this.sslService.updateCertificates(certContent, keyContent);
|
||||
}
|
||||
|
||||
@Get('test-domain')
|
||||
@Get("test-domain")
|
||||
@ApiOperation({
|
||||
summary: 'بررسی آنلاین گواهی SSL یک دامنه مشخص روی پورت ۴۴۳',
|
||||
summary: "بررسی آنلاین گواهی SSL یک دامنه مشخص روی پورت ۴۴۳",
|
||||
})
|
||||
testDomain(@Query('domain') domain: string) {
|
||||
testDomain(@Query("domain") domain: string) {
|
||||
if (!domain) {
|
||||
throw new BadRequestException('نام دامنه الزامی است');
|
||||
throw new BadRequestException("نام دامنه الزامی است");
|
||||
}
|
||||
return this.sslService.testOnlineDomainSsl(domain);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user