Remove decorative icons and update CORS configuration
This commit is contained in:
62
__tests__/auth-security.test.ts
Normal file
62
__tests__/auth-security.test.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
import { readFileSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
|
||||
describe('Authentication Security Tests', () => {
|
||||
it('should use /upadaj route instead of /admin', () => {
|
||||
const adminDashboardPath = join(process.cwd(), 'app', 'upadaj', 'dashboard', 'page.tsx');
|
||||
const adminLoginPath = join(process.cwd(), 'app', 'upadaj', 'page.tsx');
|
||||
|
||||
const dashboardContent = readFileSync(adminDashboardPath, 'utf-8');
|
||||
const loginContent = readFileSync(adminLoginPath, 'utf-8');
|
||||
|
||||
// Check that /admin is not used
|
||||
expect(dashboardContent).not.toContain("'/admin'");
|
||||
expect(loginContent).not.toContain("'/admin/dashboard'");
|
||||
|
||||
// Check that /upadaj is used
|
||||
expect(dashboardContent).toContain("'/upadaj'");
|
||||
expect(loginContent).toContain("'/upadaj/dashboard'");
|
||||
});
|
||||
|
||||
it('should have proper password hash in terraform vars', () => {
|
||||
const tfvarsPath = join(process.cwd(), 'terraform', 'terraform.tfvars');
|
||||
const tfvarsContent = readFileSync(tfvarsPath, 'utf-8');
|
||||
|
||||
// Check that password hash is present and looks like bcrypt
|
||||
expect(tfvarsContent).toMatch(/admin_password_hash\s*=\s*"\$2[aby]\$\d{2}\$[./A-Za-z0-9]{53}"/);
|
||||
|
||||
// Ensure the new password hash is set (this is the hash for Filamenteka2025!)
|
||||
expect(tfvarsContent).toContain('$2b$10$5G9fgrNGEKMMDunJkjtzy.vWCmLNIftf6HTby25TylgQHqsePI3CG');
|
||||
});
|
||||
|
||||
it('should include proper CORS headers in Lambda functions', () => {
|
||||
const filamentsLambda = join(process.cwd(), 'lambda', 'filaments', 'index.js');
|
||||
const authLambda = join(process.cwd(), 'lambda', 'auth', 'index.js');
|
||||
const colorsLambda = join(process.cwd(), 'lambda', 'colors', 'index.js');
|
||||
|
||||
const filamentsContent = readFileSync(filamentsLambda, 'utf-8');
|
||||
const authContent = readFileSync(authLambda, 'utf-8');
|
||||
const colorsContent = readFileSync(colorsLambda, 'utf-8');
|
||||
|
||||
// Check that all Lambda functions include X-Accept-Format in CORS headers
|
||||
expect(filamentsContent).toContain('X-Accept-Format');
|
||||
expect(authContent).toContain('X-Accept-Format');
|
||||
expect(colorsContent).toContain('X-Accept-Format');
|
||||
});
|
||||
|
||||
it('should have JWT authentication in protected endpoints', () => {
|
||||
const authLambda = join(process.cwd(), 'lambda', 'auth', 'index.js');
|
||||
const colorsLambda = join(process.cwd(), 'lambda', 'colors', 'index.js');
|
||||
|
||||
const authContent = readFileSync(authLambda, 'utf-8');
|
||||
const colorsContent = readFileSync(colorsLambda, 'utf-8');
|
||||
|
||||
// Check for JWT in auth Lambda
|
||||
expect(authContent).toContain('jwt.sign');
|
||||
expect(authContent).toContain('jwt.verify');
|
||||
|
||||
// Check for auth verification in colors Lambda
|
||||
expect(colorsContent).toContain('verifyAuth');
|
||||
expect(colorsContent).toContain('Authorization');
|
||||
});
|
||||
});
|
||||
42
__tests__/data-structure.test.ts
Normal file
42
__tests__/data-structure.test.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { readFileSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
|
||||
describe('Data Structure Tests', () => {
|
||||
it('should have bojaHex field in Filament interface', () => {
|
||||
const filamentTypePath = join(process.cwd(), 'src', 'types', 'filament.ts');
|
||||
const typeContent = readFileSync(filamentTypePath, 'utf-8');
|
||||
|
||||
expect(typeContent).toContain('bojaHex?: string;');
|
||||
});
|
||||
|
||||
it('should handle V2 data format in Lambda', () => {
|
||||
const filamentsLambdaPath = join(process.cwd(), 'lambda', 'filaments', 'index.js');
|
||||
const lambdaContent = readFileSync(filamentsLambdaPath, 'utf-8');
|
||||
|
||||
// Check for V2 format handling
|
||||
expect(lambdaContent).toContain('X-Accept-Format');
|
||||
expect(lambdaContent).toContain('transformToLegacy');
|
||||
expect(lambdaContent).toContain('acceptsNewFormat');
|
||||
});
|
||||
|
||||
it('should have colors table structure', () => {
|
||||
const colorsLambdaPath = join(process.cwd(), 'lambda', 'colors', 'index.js');
|
||||
const colorsContent = readFileSync(colorsLambdaPath, 'utf-8');
|
||||
|
||||
// Check for colors table handling
|
||||
expect(colorsContent).toContain('COLORS_TABLE_NAME');
|
||||
expect(colorsContent).toContain('name: data.name');
|
||||
expect(colorsContent).toContain('hex: data.hex');
|
||||
});
|
||||
|
||||
it('should have proper DynamoDB table configuration', () => {
|
||||
const dynamodbTfPath = join(process.cwd(), 'terraform', 'dynamodb.tf');
|
||||
const tfContent = readFileSync(dynamodbTfPath, 'utf-8');
|
||||
|
||||
// Check for DynamoDB configuration
|
||||
expect(tfContent).toContain('aws_dynamodb_table');
|
||||
expect(tfContent).toContain('${var.app_name}-filaments');
|
||||
expect(tfContent).toContain('hash_key');
|
||||
expect(tfContent).toContain('billing_mode = "PAY_PER_REQUEST"');
|
||||
});
|
||||
});
|
||||
@@ -18,7 +18,7 @@ describe('No Mock Data Tests', () => {
|
||||
|
||||
it('should use NEXT_PUBLIC_API_URL in all components', () => {
|
||||
const pagePath = join(process.cwd(), 'app', 'page.tsx');
|
||||
const adminPath = join(process.cwd(), 'app', 'admin', 'dashboard', 'page.tsx');
|
||||
const adminPath = join(process.cwd(), 'app', 'upadaj', 'dashboard', 'page.tsx');
|
||||
|
||||
const pageContent = readFileSync(pagePath, 'utf-8');
|
||||
const adminContent = readFileSync(adminPath, 'utf-8');
|
||||
|
||||
77
__tests__/ui-features.test.ts
Normal file
77
__tests__/ui-features.test.ts
Normal file
@@ -0,0 +1,77 @@
|
||||
import { readFileSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
|
||||
describe('UI Features Tests', () => {
|
||||
it('should have color hex input in admin form', () => {
|
||||
const adminDashboardPath = join(process.cwd(), 'app', 'upadaj', 'dashboard', 'page.tsx');
|
||||
const adminContent = readFileSync(adminDashboardPath, 'utf-8');
|
||||
|
||||
// Check for color input
|
||||
expect(adminContent).toContain('type="color"');
|
||||
expect(adminContent).toContain('bojaHex');
|
||||
expect(adminContent).toContain('Hex kod boje');
|
||||
});
|
||||
|
||||
it('should display color hex in frontend table', () => {
|
||||
const filamentTablePath = join(process.cwd(), 'src', 'components', 'FilamentTable.tsx');
|
||||
const tableContent = readFileSync(filamentTablePath, 'utf-8');
|
||||
|
||||
// Check for color hex display
|
||||
expect(tableContent).toContain('filament.bojaHex');
|
||||
expect(tableContent).toContain('backgroundColor: filament.bojaHex');
|
||||
});
|
||||
|
||||
it('should have checkboxes for boolean fields', () => {
|
||||
const adminDashboardPath = join(process.cwd(), 'app', 'upadaj', 'dashboard', 'page.tsx');
|
||||
const adminContent = readFileSync(adminDashboardPath, 'utf-8');
|
||||
|
||||
// Check for checkbox inputs
|
||||
expect(adminContent).toMatch(/type="checkbox"[\s\S]*?name="refill"/);
|
||||
expect(adminContent).toMatch(/type="checkbox"[\s\S]*?name="vakum"/);
|
||||
expect(adminContent).toMatch(/type="checkbox"[\s\S]*?name="otvoreno"/);
|
||||
});
|
||||
|
||||
it('should have number input for quantity', () => {
|
||||
const adminDashboardPath = join(process.cwd(), 'app', 'upadaj', 'dashboard', 'page.tsx');
|
||||
const adminContent = readFileSync(adminDashboardPath, 'utf-8');
|
||||
|
||||
// Check for number input
|
||||
expect(adminContent).toMatch(/type="number"[\s\S]*?name="kolicina"/);
|
||||
expect(adminContent).toContain('min="0"');
|
||||
expect(adminContent).toContain('step="1"');
|
||||
});
|
||||
|
||||
it('should have predefined brand options', () => {
|
||||
const adminDashboardPath = join(process.cwd(), 'app', 'upadaj', 'dashboard', 'page.tsx');
|
||||
const adminContent = readFileSync(adminDashboardPath, 'utf-8');
|
||||
|
||||
// Check for brand select dropdown
|
||||
expect(adminContent).toContain('<option value="Bambu Lab">Bambu Lab</option>');
|
||||
expect(adminContent).toContain('<option value="PolyMaker">PolyMaker</option>');
|
||||
expect(adminContent).toContain('<option value="Prusament">Prusament</option>');
|
||||
});
|
||||
|
||||
it('should have sidebar navigation in admin', () => {
|
||||
const adminDashboardPath = join(process.cwd(), 'app', 'upadaj', 'dashboard', 'page.tsx');
|
||||
const colorsPagePath = join(process.cwd(), 'app', 'upadaj', 'colors', 'page.tsx');
|
||||
|
||||
const dashboardContent = readFileSync(adminDashboardPath, 'utf-8');
|
||||
const colorsContent = readFileSync(colorsPagePath, 'utf-8');
|
||||
|
||||
// Check for sidebar
|
||||
expect(dashboardContent).toContain('href="/upadaj/dashboard"');
|
||||
expect(dashboardContent).toContain('href="/upadaj/colors"');
|
||||
expect(colorsContent).toContain('href="/upadaj/dashboard"');
|
||||
expect(colorsContent).toContain('href="/upadaj/colors"');
|
||||
});
|
||||
|
||||
it('should have Safari-specific select styling', () => {
|
||||
const selectCssPath = join(process.cwd(), 'src', 'styles', 'select.css');
|
||||
const selectContent = readFileSync(selectCssPath, 'utf-8');
|
||||
|
||||
// Check for Safari fixes
|
||||
expect(selectContent).toContain('-webkit-appearance: none !important');
|
||||
expect(selectContent).toContain('@supports (-webkit-appearance: none)');
|
||||
expect(selectContent).toContain('-webkit-min-device-pixel-ratio');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user