File tree Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -1151,6 +1151,9 @@ def __init__(self,
1151
1151
raise ValueError ("Only numeric values are supported for port (%s)" % port )
1152
1152
port = int (port )
1153
1153
1154
+ if port < 1 or port > 65535 :
1155
+ raise ValueError ("Invalid port number (%s) (1-65535)" % port )
1156
+
1154
1157
if connection_class is not None :
1155
1158
self .connection_class = connection_class
1156
1159
Original file line number Diff line number Diff line change @@ -132,6 +132,12 @@ def test_port_str(self):
132
132
cluster = Cluster (contact_points = ['127.0.0.1' ], port = 'string' )
133
133
134
134
135
+ def test_port_range (self ):
136
+ for invalid_port in [0 , 65536 , - 1 ]:
137
+ with self .assertRaises (ValueError ):
138
+ cluster = Cluster (contact_points = ['127.0.0.1' ], port = invalid_port )
139
+
140
+
135
141
class SchedulerTest (unittest .TestCase ):
136
142
# TODO: this suite could be expanded; for now just adding a test covering a ticket
137
143
You can’t perform that action at this time.
0 commit comments