Merge pull request #14 from github/ipv6

Test ipv6 functionality for source-address extension
This commit is contained in:
Ben Toews 2019-08-27 09:10:46 -06:00 коммит произвёл GitHub
Родитель aa6d619079 1c6eb996fb
Коммит fa503f2194
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 30 добавлений и 7 удалений

Просмотреть файл

@ -1,7 +1,7 @@
PATH
remote: .
specs:
ssh_data (1.0.0)
ssh_data (1.1.0)
GEM
remote: https://rubygems.org/

Просмотреть файл

@ -122,20 +122,34 @@ describe SSHData::Certificate do
described_class.new(public_key: public_key, key_id: key_id)
}
it "checks single address" do
it "checks single IPv4 address" do
subject.critical_options["source-address"] = "1.1.1.1"
expect(subject.allowed_source_address?("1.1.1.1")).to be(true)
expect(subject.allowed_source_address?("2.2.2.2")).to be(false)
end
it "checks multiple addresses" do
it "checks single IPv6 address" do
subject.critical_options["source-address"] = "3ffe:505:2::1"
expect(subject.allowed_source_address?("3ffe:505:2::1")).to be(true)
expect(subject.allowed_source_address?("3ffe:505:2:0::1")).to be(true)
expect(subject.allowed_source_address?("3ffe:505:2::2")).to be(false)
end
it "checks multiple IPv4 addresses" do
subject.critical_options["source-address"] = "1.1.1.1,2.2.2.2"
expect(subject.allowed_source_address?("1.1.1.1")).to be(true)
expect(subject.allowed_source_address?("2.2.2.2")).to be(true)
expect(subject.allowed_source_address?("3.3.3.3")).to be(false)
end
it "checks single CIDR range" do
it "checks multiple IPv6 addresses" do
subject.critical_options["source-address"] = "3ffe:505:2::1,3ffe:505:2::2"
expect(subject.allowed_source_address?("3ffe:505:2::1")).to be(true)
expect(subject.allowed_source_address?("3ffe:505:2::2")).to be(true)
expect(subject.allowed_source_address?("3ffe:505:2::3")).to be(false)
end
it "checks single IPv4 CIDR range" do
subject.critical_options["source-address"] = "1.1.1.0/24"
expect(subject.allowed_source_address?("1.1.1.1")).to be(true)
expect(subject.allowed_source_address?("1.1.1.2")).to be(true)
@ -143,11 +157,19 @@ describe SSHData::Certificate do
expect(subject.allowed_source_address?("1.1.2.1")).to be(false)
end
it "checks single IPv6 CIDR range" do
subject.critical_options["source-address"] = "3ffe:505:2::/112"
expect(subject.allowed_source_address?("3ffe:505:2::1")).to be(true)
expect(subject.allowed_source_address?("3ffe:505:2::2")).to be(true)
expect(subject.allowed_source_address?("3ffe:505:2::1:1")).to be(false)
end
it "checks multiple CIDR ranges" do
subject.critical_options["source-address"] = "1.1.1.0/24,2.2.2.0/24"
subject.critical_options["source-address"] = "1.1.1.0/24,3ffe:505:2::/112"
expect(subject.allowed_source_address?("1.1.1.1")).to be(true)
expect(subject.allowed_source_address?("2.2.2.2")).to be(true)
expect(subject.allowed_source_address?("3.3.3.3")).to be(false)
expect(subject.allowed_source_address?("3ffe:505:2::1")).to be(true)
expect(subject.allowed_source_address?("2.2.2.2")).to be(false)
expect(subject.allowed_source_address?("3ffe:505:2::1:1")).to be(false)
end
it "returns false for bad addresses" do
@ -157,6 +179,7 @@ describe SSHData::Certificate do
it "allows any address if option is missing" do
expect(subject.allowed_source_address?("1.1.1.1")).to be(true)
expect(subject.allowed_source_address?("3ffe:505:2::1")).to be(true)
end
end