mirror of
https://github.com/openobserve/openobserve.git
synced 2026-11-04 08:09:27 +00:00
## Summary - **apiUtils.js**: `getHeaders()` now reads `cloud-config.json` for `email:passcode` auth when `IS_CLOUD=true`, with caching - **streamsPage.js**: `deleteStreamViaAPI`, `createStream`, `verifyStreamExists` use `page.evaluate(fetch())` on cloud for OIDC cookie auth on management APIs (node-fetch can't send session cookies) - All 5 Streams spec files (30 tests) passing on alpha1 cloud ## Test plan - [x] All 5 Streams specs pass locally against alpha1 (headless) - [x] CI run passed: https://github.com/openobserve/o2-enterprise/actions/runs/22906826643 - [ ] Full regression with all shards uncommented after merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
54 lines
1.7 KiB
JavaScript
54 lines
1.7 KiB
JavaScript
import fs from 'fs';
|
|
import path from 'path';
|
|
|
|
// Cache cloud config to avoid re-reading on every call
|
|
let _cachedCloudConfig = null;
|
|
|
|
export const getHeaders = () => {
|
|
// On cloud, use email:passcode from cloud-config.json (written by global-setup-alpha1.js)
|
|
if (process.env.IS_CLOUD === 'true') {
|
|
try {
|
|
if (!_cachedCloudConfig) {
|
|
const configPath = path.join(process.cwd(), 'playwright-tests', 'utils', 'auth', 'cloud-config.json');
|
|
_cachedCloudConfig = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
|
|
}
|
|
if (_cachedCloudConfig.passcode) {
|
|
const basicAuth = Buffer.from(
|
|
`${_cachedCloudConfig.userEmail}:${_cachedCloudConfig.passcode}`
|
|
).toString('base64');
|
|
return {
|
|
Authorization: `Basic ${basicAuth}`,
|
|
"Content-Type": "application/json",
|
|
};
|
|
}
|
|
} catch (e) {
|
|
console.warn('[apiUtils] Failed to read cloud-config.json, falling back to password auth:', e.message);
|
|
}
|
|
}
|
|
|
|
const basicAuthCredentials = Buffer.from(
|
|
`${process.env["ZO_ROOT_USER_EMAIL"]}:${process.env["ZO_ROOT_USER_PASSWORD"]}`
|
|
).toString("base64");
|
|
|
|
return {
|
|
Authorization: `Basic ${basicAuthCredentials}`,
|
|
"Content-Type": "application/json",
|
|
};
|
|
};
|
|
|
|
export const getIngestionUrl = (orgId, streamName) => {
|
|
return `${process.env.INGESTION_URL}/api/${orgId}/${streamName}/_json`;
|
|
};
|
|
|
|
export const sendRequest = async (page, url, payload, headers) => {
|
|
// Use Node.js fetch instead of browser fetch to avoid CORS issues with deployed environments
|
|
const fetch = (await import('node-fetch')).default;
|
|
|
|
const response = await fetch(url, {
|
|
method: "POST",
|
|
headers: headers,
|
|
body: JSON.stringify(payload),
|
|
});
|
|
|
|
return await response.json();
|
|
};
|