Sha256: 7a21974aa16faeb9daf101629a1ebeef283fb6f5d1c10285aa22a8a26ce365bb

Contents?: true

Size: 1.79 KB

Versions: 1

Compression:

Stored size: 1.79 KB

Contents

'use strict';

const { expect } = require('chai');
const mongodbClientEncryption = require('../lib/index');
const { fetchAzureKMSToken } = require('../lib/providers');

// Update this as you add exports, helps double check we don't accidentally remove something
// since not all tests import from the root public export
const EXPECTED_EXPORTS = [
  'extension',
  'MongoCryptError',
  'MongoCryptCreateEncryptedCollectionError',
  'MongoCryptCreateDataKeyError',
  'MongoCryptAzureKMSRequestError',
  'MongoCryptKMSRequestNetworkTimeoutError',
  'AutoEncrypter',
  'ClientEncryption'
];

describe('mongodb-client-encryption entrypoint', () => {
  it('should export all and only the expected keys in expected_exports', () => {
    expect(mongodbClientEncryption).to.have.all.keys(EXPECTED_EXPORTS);
  });

  it('extension returns an object equal in shape to the default except for extension', () => {
    const extensionResult = mongodbClientEncryption.extension(require('mongodb'));
    const expectedExports = EXPECTED_EXPORTS.filter(exp => exp !== 'extension');
    const exportsDefault = Object.keys(mongodbClientEncryption).filter(exp => exp !== 'extension');
    expect(extensionResult).to.have.all.keys(expectedExports);
    expect(extensionResult).to.have.all.keys(exportsDefault);
  });

  context('exports for driver testing', () => {
    it('exports `fetchAzureKMSToken` in a symbol property', () => {
      expect(mongodbClientEncryption).to.have.property(
        '___azureKMSProseTestExports',
        fetchAzureKMSToken
      );
    });
    it('extension exports `fetchAzureKMSToken` in a symbol property', () => {
      const extensionResult = mongodbClientEncryption.extension(require('mongodb'));
      expect(extensionResult).to.have.property('___azureKMSProseTestExports', fetchAzureKMSToken);
    });
  });
});

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
libmongocrypt-helper-1.8.0.0.1001 ext/libmongocrypt/libmongocrypt/bindings/node/test/index.test.js