Esempio n. 1
0
  it('should always use declared security definition', async () => {
    const API = await initAPI({
      log,
      CONFIG,
      HOST,
      PORT,
      NODE_ENV,
      DEBUG_NODE_ENVS,
      API_VERSION: '1.1.0',
    });
    const securitySchemes = API.components.securitySchemes;
    const operations = await getOpenAPIOperations(API);

    expect(
      operations
        .filter(operation => operation.security && operation.security.length)
        .filter(operation =>
          operation.security.some(operationSecurity =>
            Object.keys(operationSecurity).some(
              operationSecurityName => !securitySchemes[operationSecurityName],
            ),
          ),
        )
        .map(({ method, path }) => `${method} ${path}`)
        .sort(),
    ).toEqual([]);
  });
Esempio n. 2
0
    beforeAll(async () => {
      const API = await initAPI({
        log,
        CONFIG,
        HOST,
        PORT,
        NODE_ENV,
        DEBUG_NODE_ENVS,
        API_VERSION: '1.1.0',
      });

      operations = await getOpenAPIOperations(await flattenOpenAPI(API));
    });