Clear final M0 bugs on master (T-5 verified, T-12, T-15, T-17)
This commit is contained in:
parent
ade0a3ef1d
commit
2ea7316af6
7 changed files with 148 additions and 17 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import { hostname as osHostname, networkInterfaces } from 'node:os';
|
||||
import { describe, expect, test } from 'bun:test';
|
||||
import { ConfigManager } from '@stock-bot/config';
|
||||
import { ServiceContainerBuilder } from '@stock-bot/di';
|
||||
|
|
@ -299,6 +300,44 @@ describe('Environment safety & multi-env isolation', () => {
|
|||
);
|
||||
});
|
||||
|
||||
test('blocks QA MongoDB and PostgreSQL when targeted via machine hostname or local LAN IP (T-15)', () => {
|
||||
const localHost = osHostname().trim();
|
||||
if (localHost) {
|
||||
const mongoByHostname = makeConfig({
|
||||
environment: 'development',
|
||||
mongoUri: `mongodb://trading_admin:pass@${localHost}:27017/stock`,
|
||||
mongoDatabase: 'stock',
|
||||
});
|
||||
expect(() => assertEnvironmentSafety(mongoByHostname, 'dataIngestion', {})).toThrow(
|
||||
/cannot open a writable MongoDB connection to QA MongoDB/
|
||||
);
|
||||
|
||||
const pgByHostname = makeConfig({
|
||||
environment: 'development',
|
||||
pgHost: localHost,
|
||||
pgPort: 5432,
|
||||
pgDatabase: 'trading_bot',
|
||||
});
|
||||
expect(() => assertEnvironmentSafety(pgByHostname, 'dataPipeline', {})).toThrow(
|
||||
/cannot target QA PostgreSQL/
|
||||
);
|
||||
}
|
||||
|
||||
const lanIpv4 = Object.values(networkInterfaces())
|
||||
.flatMap(list => list ?? [])
|
||||
.find(iface => iface.family === 'IPv4' && !iface.internal)?.address;
|
||||
if (lanIpv4) {
|
||||
const mongoByLanIp = makeConfig({
|
||||
environment: 'development',
|
||||
mongoUri: `mongodb://trading_admin:pass@${lanIpv4}:27017/stock`,
|
||||
mongoDatabase: 'stock',
|
||||
});
|
||||
expect(() => assertEnvironmentSafety(mongoByLanIp, 'dataIngestion', {})).toThrow(
|
||||
/cannot open a writable MongoDB connection to QA MongoDB/
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test('blocks multi-host MongoDB seed lists targeting QA loopback :27017 for dataIngestion and dataPipeline', () => {
|
||||
const qaFirstIngestion = makeConfig({
|
||||
environment: 'development',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue