- Create SECURITY.md with vulnerability reporting policy - Add environment variables & secrets best practices - Document input validation and rate limiting strategies - Create docs/API_KEYS.md with step-by-step API credential guides - IGDB OAuth 2.0 via Twitch setup - RAWG API key simple registration - TheGamesDB API key registration - Update README.md with security and API configuration sections - Add tests/documentation.spec.ts with 12 validation tests
71 lines
2.6 KiB
TypeScript
71 lines
2.6 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { readFileSync } from 'fs';
|
|
import { existsSync } from 'fs';
|
|
|
|
describe('Documentation - Security and API Keys', () => {
|
|
// SECURITY.md tests
|
|
it('SECURITY.md exists and contains "Reporting Security Vulnerabilities"', () => {
|
|
expect(existsSync('./SECURITY.md')).toBe(true);
|
|
const content = readFileSync('./SECURITY.md', 'utf-8');
|
|
expect(content).toContain('Reporting Security Vulnerabilities');
|
|
});
|
|
|
|
it('SECURITY.md contains "Environment Variables & Secrets" section', () => {
|
|
const content = readFileSync('./SECURITY.md', 'utf-8');
|
|
expect(content).toContain('Environment Variables & Secrets');
|
|
});
|
|
|
|
it('SECURITY.md contains "Input Validation & Sanitization" section', () => {
|
|
const content = readFileSync('./SECURITY.md', 'utf-8');
|
|
expect(content).toContain('Input Validation & Sanitization');
|
|
});
|
|
|
|
it('SECURITY.md contains "Rate Limiting" section', () => {
|
|
const content = readFileSync('./SECURITY.md', 'utf-8');
|
|
expect(content).toContain('Rate Limiting');
|
|
});
|
|
|
|
it('SECURITY.md contains "Database Security" section', () => {
|
|
const content = readFileSync('./SECURITY.md', 'utf-8');
|
|
expect(content).toContain('Database Security');
|
|
});
|
|
|
|
// docs/API_KEYS.md tests
|
|
it('docs/API_KEYS.md exists and contains "IGDB" section', () => {
|
|
expect(existsSync('./docs/API_KEYS.md')).toBe(true);
|
|
const content = readFileSync('./docs/API_KEYS.md', 'utf-8');
|
|
expect(content).toContain('IGDB');
|
|
});
|
|
|
|
it('docs/API_KEYS.md contains "RAWG" section', () => {
|
|
const content = readFileSync('./docs/API_KEYS.md', 'utf-8');
|
|
expect(content).toContain('RAWG');
|
|
});
|
|
|
|
it('docs/API_KEYS.md contains "TheGamesDB" section', () => {
|
|
const content = readFileSync('./docs/API_KEYS.md', 'utf-8');
|
|
expect(content).toContain('TheGamesDB');
|
|
});
|
|
|
|
it('docs/API_KEYS.md contains step-by-step instructions', () => {
|
|
const content = readFileSync('./docs/API_KEYS.md', 'utf-8');
|
|
expect(content).toMatch(/steps?|step-by-step|guide/i);
|
|
});
|
|
|
|
// README.md tests
|
|
it('README.md contains link to SECURITY.md', () => {
|
|
const content = readFileSync('./README.md', 'utf-8');
|
|
expect(content).toMatch(/SECURITY\.md|security/i);
|
|
});
|
|
|
|
it('README.md contains link to docs/API_KEYS.md', () => {
|
|
const content = readFileSync('./README.md', 'utf-8');
|
|
expect(content).toMatch(/API_KEYS\.md|api.*key|obtaining.*key/i);
|
|
});
|
|
|
|
it('README.md mentions .env.example template', () => {
|
|
const content = readFileSync('./README.md', 'utf-8');
|
|
expect(content).toMatch(/\.env|environment.*variable/i);
|
|
});
|
|
});
|