Files
smom-dbis-138/orchestration/portal/tests/admin-panel.test.ts
defiQUG 1fb7266469 Add Oracle Aggregator and CCIP Integration
- Introduced Aggregator.sol for Chainlink-compatible oracle functionality, including round-based updates and access control.
- Added OracleWithCCIP.sol to extend Aggregator with CCIP cross-chain messaging capabilities.
- Created .gitmodules to include OpenZeppelin contracts as a submodule.
- Developed a comprehensive deployment guide in NEXT_STEPS_COMPLETE_GUIDE.md for Phase 2 and smart contract deployment.
- Implemented Vite configuration for the orchestration portal, supporting both Vue and React frameworks.
- Added server-side logic for the Multi-Cloud Orchestration Portal, including API endpoints for environment management and monitoring.
- Created scripts for resource import and usage validation across non-US regions.
- Added tests for CCIP error handling and integration to ensure robust functionality.
- Included various new files and directories for the orchestration portal and deployment scripts.
2025-12-12 14:57:48 -08:00

123 lines
3.7 KiB
TypeScript

/**
* End-to-end tests for Admin Panel
* Run with: pnpm test
*/
import request from 'supertest';
import { describe, it, expect, beforeAll, afterAll } from '@jest/globals';
// Note: This requires the server to be running
// For full E2E tests, use Playwright or Cypress
describe('Admin Panel API', () => {
const baseUrl = process.env.TEST_URL || 'http://localhost:5000';
let adminToken: string;
beforeAll(async () => {
// Login to get admin token
const loginResponse = await request(baseUrl)
.post('/api/admin/login')
.send({ username: 'admin', password: 'admin' });
if (loginResponse.status === 200) {
adminToken = loginResponse.body.token;
}
});
describe('Authentication', () => {
it('should login with valid credentials', async () => {
const response = await request(baseUrl)
.post('/api/admin/login')
.send({ username: 'admin', password: 'admin' });
expect(response.status).toBe(200);
expect(response.body).toHaveProperty('token');
expect(response.body).toHaveProperty('username');
});
it('should reject invalid credentials', async () => {
const response = await request(baseUrl)
.post('/api/admin/login')
.send({ username: 'admin', password: 'wrong' });
expect(response.status).toBe(401);
});
it('should require authentication for admin routes', async () => {
const response = await request(baseUrl)
.get('/api/admin/services');
expect(response.status).toBe(401);
});
});
describe('Service Management', () => {
it('should get all services', async () => {
const response = await request(baseUrl)
.get('/api/admin/services')
.set('X-Admin-Token', adminToken);
expect(response.status).toBe(200);
expect(Array.isArray(response.body)).toBe(true);
});
it('should update service configuration', async () => {
const serviceName = 'test-service';
const response = await request(baseUrl)
.put(`/api/admin/services/${serviceName}`)
.set('X-Admin-Token', adminToken)
.send({ enabled: true });
expect(response.status).toBe(200);
expect(response.body).toHaveProperty('success', true);
});
});
describe('Provider Management', () => {
it('should get all providers', async () => {
const response = await request(baseUrl)
.get('/api/admin/providers')
.set('X-Admin-Token', adminToken);
expect(response.status).toBe(200);
expect(Array.isArray(response.body)).toBe(true);
});
it('should update provider configuration', async () => {
const providerName = 'azure';
const response = await request(baseUrl)
.put(`/api/admin/providers/${providerName}`)
.set('X-Admin-Token', adminToken)
.send({ enabled: true });
expect(response.status).toBe(200);
expect(response.body).toHaveProperty('success', true);
});
});
describe('Environment Management', () => {
it('should toggle environment', async () => {
const envName = 'workload-azure-eastus';
const response = await request(baseUrl)
.put(`/api/admin/environments/${envName}/toggle`)
.set('X-Admin-Token', adminToken)
.send({ enabled: true });
// May return 404 if environment doesn't exist, or 200 if it does
expect([200, 404]).toContain(response.status);
});
});
describe('Audit Logs', () => {
it('should get audit logs', async () => {
const response = await request(baseUrl)
.get('/api/admin/audit-logs?limit=10')
.set('X-Admin-Token', adminToken);
expect(response.status).toBe(200);
expect(Array.isArray(response.body)).toBe(true);
});
});
});