Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions pages/api/control/error/client-fail.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { checkSutAuth } from '../../../../src/services/sut-utils';

/**
* @swagger
* /api/control/error/client-fail:
Expand All @@ -10,9 +8,6 @@ import { checkSutAuth } from '../../../../src/services/sut-utils';
* description: Unauthorized error
*/
export default function handler(req, res) {
if (!checkSutAuth(req)) {
return res.status(401).json({ error: 'Authentication required' });
}

res.status(401).json({ error: 'Unauthorized (401)' });
}
5 changes: 0 additions & 5 deletions pages/api/control/error/redirect-temp.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { checkSutAuth } from '../../../../src/services/sut-utils';

/**
* @swagger
* /api/control/error/redirect-temp:
Expand All @@ -12,9 +10,6 @@ import { checkSutAuth } from '../../../../src/services/sut-utils';
* description: Unauthorized
*/
export default function handler(req, res) {
if (!checkSutAuth(req)) {
return res.status(401).json({ error: 'Authentication required' });
}

res.redirect(307, '/api/control/error/success');
}
5 changes: 0 additions & 5 deletions pages/api/control/error/server-fail.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { checkSutAuth } from '../../../../src/services/sut-utils';

/**
* @swagger
* /api/control/error/server-fail:
Expand All @@ -12,9 +10,6 @@ import { checkSutAuth } from '../../../../src/services/sut-utils';
* description: Unauthorized
*/
export default function handler(req, res) {
if (!checkSutAuth(req)) {
return res.status(401).json({ error: 'Authentication required' });
}

res.status(503).json({ error: 'Service Unavailable (503)' });
}
5 changes: 0 additions & 5 deletions pages/api/control/error/success.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { checkSutAuth } from '../../../../src/services/sut-utils';

/**
* @swagger
* /api/control/error/success:
Expand All @@ -12,9 +10,6 @@ import { checkSutAuth } from '../../../../src/services/sut-utils';
* description: Unauthorized
*/
export default function handler(req, res) {
if (!checkSutAuth(req)) {
return res.status(401).json({ error: 'Authentication required' });
}

res.status(200).json({ message: 'Success (200 OK)' });
}
6 changes: 1 addition & 5 deletions pages/api/control/latency/avg.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { delay, checkSutAuth } from '../../../../src/services/sut-utils';
import { delay } from '../../../../src/services/sut-utils';

/**
* @swagger
Expand All @@ -12,10 +12,6 @@ import { delay, checkSutAuth } from '../../../../src/services/sut-utils';
* description: Unauthorized
*/
export default async function handler(req, res) {
// Check authentication
if (!checkSutAuth(req)) {
return res.status(401).json({ error: 'Authentication required' });
}

await delay(500);
res.status(200).json({ status: 'OK', latency: '500ms' });
Expand Down
5 changes: 1 addition & 4 deletions pages/api/control/latency/p99-outlier.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { delay, checkSutAuth } from '../../../../src/services/sut-utils';
import { delay } from '../../../../src/services/sut-utils';

/**
* @swagger
Expand All @@ -12,9 +12,6 @@ import { delay, checkSutAuth } from '../../../../src/services/sut-utils';
* description: Unauthorized
*/
export default async function handler(req, res) {
if (!checkSutAuth(req)) {
return res.status(401).json({ error: 'Authentication required' });
}

const randomValue = Math.random();
const delayTime = randomValue < 0.01 ? 5000 : 200; // 1% slow, 99% fast
Expand Down
5 changes: 1 addition & 4 deletions pages/api/control/latency/threshold.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { delay, checkSutAuth } from '../../../../src/services/sut-utils';
import { delay } from '../../../../src/services/sut-utils';

/**
* @swagger
Expand All @@ -12,9 +12,6 @@ import { delay, checkSutAuth } from '../../../../src/services/sut-utils';
* description: Unauthorized
*/
export default async function handler(req, res) {
if (!checkSutAuth(req)) {
return res.status(401).json({ error: 'Authentication required' });
}

await delay(3500);
res.status(200).json({ status: 'OK', flag: 'slow' });
Expand Down
5 changes: 0 additions & 5 deletions pages/api/zero/errors.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { checkSutAuth } from '../../../src/services/sut-utils';

/**
* @swagger
* /api/zero/errors:
Expand All @@ -12,9 +10,6 @@ import { checkSutAuth } from '../../../src/services/sut-utils';
* description: Unauthorized
*/
export default function handler(req, res) {
if (!checkSutAuth(req)) {
return res.status(401).json({ error: 'Authentication required' });
}

res.status(200).json({ message: 'Perfect run, zero errors targeted.' });
}
1 change: 0 additions & 1 deletion pages/sut/dashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import Head from 'next/head';
import { useEffect, useState } from 'react';
import { useRouter } from 'next/router';
import Link from 'next/link';
import { checkSutAuth } from '../../src/services/sut-utils';

export default function SutDashboard() {
const router = useRouter();
Expand Down
2 changes: 1 addition & 1 deletion pages/sut/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default function SutIndex() {
const router = useRouter();

useEffect(() => {
router.replace('/sut/login');
router.replace('/sut/dashboard');
}, [router]);

return <div>Redirecting to SUT Login...</div>;
Expand Down
137 changes: 0 additions & 137 deletions pages/sut/login.jsx

This file was deleted.

24 changes: 1 addition & 23 deletions src/services/sut-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,33 +51,11 @@ const getBaseHtml = (title, bodyContent) => `
</html>
`;

const generateSessionId = () => Math.random().toString(36).substring(2, 15);

// Simple auth check - returns session info or null
const checkSutAuth = (req) => {
const cookieHeader = req.headers.cookie;
let sessionId = null;

if (cookieHeader) {
const sessionCookie = cookieHeader.split('; ').find(row => row.startsWith('sutSessionId='));
if (sessionCookie) {
sessionId = sessionCookie.split('=')[1];
}
}

if (sessionId && sessions[sessionId]) {
return { sessionId, session: sessions[sessionId] };
}

return null;
};

module.exports = {
DUMMY_USERNAME,
DUMMY_PASSWORD,
sessions,
delay,
getBaseHtml,
generateSessionId,
checkSutAuth
generateSessionId
};