Sha256: 49e223e35b52110a83e8e3cab20768bbab666b922d85b425ab5ab8c142b5f24c

Contents?: true

Size: 1.4 KB

Versions: 3

Compression:

Stored size: 1.4 KB

Contents

# frozen_string_literal: true
# encoding: utf-8

require 'mongo'
require 'lite_spec_helper'

describe Mongo::Crypt::KMS do
  context 'Validations' do
    context '.validate_tls_options' do
      it 'returns valid options for nil parameter' do
        expect(
          Mongo::Crypt::KMS::Validations.validate_tls_options(nil)
        ).to eq({})
      end

      it 'accepts empty hash' do
        expect(
          Mongo::Crypt::KMS::Validations.validate_tls_options({})
        ).to eq({})
      end

      it 'does not allow disabled ssl' do
        expect {
          Mongo::Crypt::KMS::Validations.validate_tls_options(
            {
              aws: {ssl: false}
            }
          )
        }.to raise_error(ArgumentError, /TLS is required/)
      end

      it 'does not allow insecure tls options' do
        %i(
          ssl_verify_certificate
          ssl_verify_hostname
          ssl_verify_ocsp_endpoint
        ).each do |insecure_opt|
          expect {
            Mongo::Crypt::KMS::Validations.validate_tls_options(
              {
                aws: {insecure_opt => false}
              }
            )
          }.to raise_error(ArgumentError, /Insecure TLS options prohibited/)
        end
      end

      it 'allows valid options' do
        options = {
          aws: {
            ssl: true,
            ssl_cert_string: 'Content is not validated',

          }
        }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mongo-2.18.1 spec/mongo/crypt/kms_spec.rb
mongo-2.18.0 spec/mongo/crypt/kms_spec.rb
mongo-2.18.0.beta1 spec/mongo/crypt/kms_spec.rb