T-28: tests
This commit is contained in:
parent
01e2c930a5
commit
8413c03110
1 changed files with 28 additions and 0 deletions
|
|
@ -294,6 +294,34 @@ describe('T-28: guard and driver agree on where the Mongo URI authority splits',
|
|||
}
|
||||
});
|
||||
|
||||
test('non-ASCII whitespace that the driver keeps inside the host list fails closed in schema and guard', () => {
|
||||
// The driver accepts these verbatim as part of the host (local<NBSP>host:27017); neither the
|
||||
// ASCII control-char check nor a '#'/'@' rule catches them, so the /\s/ check must.
|
||||
const uris = [
|
||||
'mongodb://u:p@local host:27017/stock',
|
||||
'mongodb://u:p@local
host:27017/stock',
|
||||
'mongodb://u:p@localhost:27018, localhost/stock',
|
||||
];
|
||||
|
||||
for (const uri of uris) {
|
||||
expect(driverDialHosts(uri)).not.toBeNull();
|
||||
expect(
|
||||
stockAppSchema.shape.database.shape.mongodb.safeParse({
|
||||
enabled: true,
|
||||
uri,
|
||||
database: 'stock_dev',
|
||||
}).success
|
||||
).toBe(false);
|
||||
|
||||
expect(() => assertEnvironmentSafety(makeDevConfig({ uri }), 'dataIngestion', {})).toThrow(
|
||||
/forbidden whitespace/
|
||||
);
|
||||
expect(() =>
|
||||
assertEnvironmentSafety(makeDevConfig({ readUri: uri, readOnly: true }), 'dataPipeline', {})
|
||||
).toThrow(/forbidden whitespace/);
|
||||
}
|
||||
});
|
||||
|
||||
test('disabled MongoDB in development is not parsed, so a placeholder URI never blocks startup', () => {
|
||||
const config = makeDevConfig({ uri: 'mongodb://disabled' });
|
||||
config.database.mongodb.enabled = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue