File: constraints.rb

package info (click to toggle)
ruby-mongo 2.23.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,020 kB
  • sloc: ruby: 110,810; makefile: 5
file content (49 lines) | stat: -rw-r--r-- 1,199 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# frozen_string_literal: true
# rubocop:todo all

module Constraints

  # Some tests hardcode the TLS certificates shipped with the driver's
  # test suite, and will fail when using TLS connections that use other
  # certificates.
  def require_local_tls
    require_tls

    before(:all) do
      # TODO This isn't actually the foolproof check
      if ENV['OCSP_ALGORITHM']
        skip 'Driver TLS certificate required, OCSP certificates are not acceptable'
      end
    end
  end

  def minimum_mri_version(version)
    require_mri

    before(:all) do
      if RUBY_VERSION < version
        skip "Ruby #{version} or greater is required"
      end
    end
  end

  def forbid_x509_auth
    before(:all) do
      skip 'X.509 auth not allowed' if SpecConfig.instance.x509_auth?
    end
  end

  def max_bson_version(version)
    required_version = version.split('.').map(&:to_i)
    actual_version = bson_version(required_version.length)
    before(:all) do
      if (actual_version <=> required_version) > 0
        skip "bson-ruby version #{version} or lower is required"
      end
    end
  end

  def bson_version(precision)
    BSON::VERSION.split('.')[0...precision].map(&:to_i)
  end
end