Skip to content

Commit 5f43417

Browse files
committed
Correct wire version range checks
1 parent 57d7294 commit 5f43417

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

lib/mongo/server/description/features.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ def initialize(server_wire_versions)
7575
private
7676

7777
def check_driver_support!
78-
if DRIVER_WIRE_VERSIONS.max < server_wire_versions.max
78+
if DRIVER_WIRE_VERSIONS.max < server_wire_versions.min ||
79+
DRIVER_WIRE_VERSIONS.min > server_wire_versions.max
7980
raise Error::UnsupportedFeatures.new(server_wire_versions)
8081
end
8182
end

spec/mongo/server/description/features_spec.rb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,20 @@
1515
end
1616
end
1717

18-
context 'when the server wire version range is higher' do
18+
context 'when the server wire version range min is higher' do
1919

2020
it 'raises an exception' do
2121
expect {
22-
described_class.new(0..4)
22+
described_class.new(described_class::DRIVER_WIRE_VERSIONS.max+1..described_class::DRIVER_WIRE_VERSIONS.max+2)
23+
}.to raise_error(Mongo::Error::UnsupportedFeatures)
24+
end
25+
end
26+
27+
context 'when the server wire version range max is lower' do
28+
29+
it 'raises an exception' do
30+
expect {
31+
described_class.new(described_class::DRIVER_WIRE_VERSIONS.min-2..described_class::DRIVER_WIRE_VERSIONS.min-1)
2332
}.to raise_error(Mongo::Error::UnsupportedFeatures)
2433
end
2534
end

0 commit comments

Comments
 (0)