Sha256: 95eb809123b818d38575c726c6bf87f1cadb984852eff6246c149965fd20db32
Contents?: true
Size: 1.3 KB
Versions: 17
Compression:
Stored size: 1.3 KB
Contents
require 'spec_helper' require 'certmeister/policy/ip' require 'ipaddr' describe Certmeister::Policy::IP do subject { Certmeister::Policy::IP.new(['127.0.0.0/8', '192.168.0.0/23']) } it "demands a request" do expect { subject.authenticate }.to raise_error(ArgumentError) end it "explodes if initialized with things other than CIDR strings" do expect { Certmeister::Policy::IP.new(['localhost']) }.to raise_error(IPAddr::Error) end it "refuses to authenticate a request with a missing ip" do response = subject.authenticate(cn: 'localhost') expect(response).to_not be_authenticated expect(response.error).to eql "missing ip" end it "refuses to authenticate a request with a malformed ip" do response = subject.authenticate(cn: 'localhost', ip: '127.1') expect(response).to_not be_authenticated expect(response.error).to eql "invalid ip" end it "refuses to authenticate an IP outside the configured list of networks" do response = subject.authenticate(cn: 'localhost', ip: '172.16.0.1') expect(response).to_not be_authenticated expect(response.error).to eql "unauthorized ip" end it "allows an IP inside a configured network" do response = subject.authenticate(cn: 'localhost', ip: '192.168.0.1') expect(response).to be_authenticated end end
Version data entries
17 entries across 17 versions & 1 rubygems