File: is_in_cidr_spec.rb

package info (click to toggle)
puppet-module-extlib 7.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 420 kB
  • sloc: ruby: 1,035; sh: 15; makefile: 10
file content (29 lines) | stat: -rw-r--r-- 862 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
# frozen_string_literal: true

require 'spec_helper'

describe 'extlib::is_in_cidr' do
  it 'exists' do
    is_expected.not_to eq(nil)
  end

  describe 'IPv4' do
    context 'with an IPv4 address in a IPv4 CIDR' do
      it { is_expected.to run.with_params('192.0.2.1', '192.0.2.0/24').and_return(true) }
    end

    context 'with an IPv4 address outside of a IPv4 CIDR' do
      it { is_expected.to run.with_params('198.51.100.1', '192.0.2.0/24').and_return(false) }
    end
  end

  describe 'IPv6' do
    context 'with an IPv6 address in a IPv6 CIDR' do
      it { is_expected.to run.with_params('1080:0:0:0:8:800:200C:417A', '1080:0::0/64').and_return(true) }
    end

    context 'with an IPv6 address outside of a IPv6 CIDR' do
      it { is_expected.to run.with_params('1080:0:0:0:8:800:200C:417A', '1081:0::0/64').and_return(false) }
    end
  end
end