persona-community-5/.pnpm-store/v3/files/1e/2b45e54573c2ae6256f4b55eeb518b5c34f53fc36ee0ec09624d6b55eb047b86ae3439e638d0d95c452893d62a72b2f4e463905eddfaf8c24f73b94d6455d1
rdev-worker a1d0d1bf1c
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
build: /implement-feature community-ui --requirements 'Build the React commu...
2026-02-24 08:22:30 +00:00

96 lines
2.7 KiB
Plaintext

import { outdent } from 'outdent';
import { lintDocument } from '../../../lint';
import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils';
import { BaseResolver } from '../../../resolve';
describe('Oas3 oas3-no-server-example.com', () => {
it('oas3-no-server-example.com: should report on server object with "example.com" url', async () => {
const document = parseYamlToDocument(
outdent`
openapi: 3.0.0
servers:
- url: example.com
`,
'foobar.yaml'
);
const results = await lintDocument({
externalRefResolver: new BaseResolver(),
document,
config: await makeConfig({ rules: { 'no-server-example.com': 'error' } }),
});
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
[
{
"location": [
{
"pointer": "#/servers/0/url",
"reportOnKey": false,
"source": "foobar.yaml",
},
],
"message": "Server \`url\` should not point to example.com or localhost.",
"ruleId": "no-server-example.com",
"severity": "error",
"suggest": [],
},
]
`);
});
it('oas3-no-server-example.com: should not report on server object with not "example.com" url', async () => {
const document = parseYamlToDocument(
outdent`
openapi: 3.0.0
servers:
- url: not-example.com
`,
'foobar.yaml'
);
const results = await lintDocument({
externalRefResolver: new BaseResolver(),
document,
config: await makeConfig({ rules: { 'no-server-example.com': 'error' } }),
});
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
});
it('oas3-no-server-example.com: should report on server object with "foo.example.com" url', async () => {
const document = parseYamlToDocument(
outdent`
openapi: 3.0.0
servers:
- url: foo.example.com
`,
'foobar.yaml'
);
const results = await lintDocument({
externalRefResolver: new BaseResolver(),
document,
config: await makeConfig({ rules: { 'no-server-example.com': 'error' } }),
});
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
[
{
"location": [
{
"pointer": "#/servers/0/url",
"reportOnKey": false,
"source": "foobar.yaml",
},
],
"message": "Server \`url\` should not point to example.com or localhost.",
"ruleId": "no-server-example.com",
"severity": "error",
"suggest": [],
},
]
`);
});
});