Skip to content

Commit 0a193cf

Browse files
committed
Merge pull request influxdata#301 from canardleteer/master
Make InfluxDBClient to force an integer as the HTTP(s) port.
2 parents 682a892 + aeb4966 commit 0a193cf

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

influxdb/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def __init__(self,
7676
):
7777
"""Construct a new InfluxDBClient object."""
7878
self.__host = host
79-
self.__port = port
79+
self.__port = int(port)
8080
self._username = username
8181
self._password = password
8282
self._database = database

influxdb/tests/client_test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,10 @@ def test_revoke_privilege_invalid(self):
794794
with _mocked_session(cli, 'get', 400):
795795
self.cli.revoke_privilege('', 'testdb', 'test')
796796

797+
def test_invalid_port_fails(self):
798+
with self.assertRaises(ValueError):
799+
InfluxDBClient('host', '80/redir', 'username', 'password')
800+
797801

798802
class FakeClient(InfluxDBClient):
799803

influxdb/tests/server_tests/client_test_with_server.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,10 @@ def test_revoke_privilege_invalid(self):
295295
self.assertIn('{"error":"error parsing query: ',
296296
ctx.exception.content)
297297

298+
def test_invalid_port_fails(self):
299+
with self.assertRaises(ValueError):
300+
InfluxDBClient('host', '80/redir', 'username', 'password')
301+
298302

299303
@skipServerTests
300304
class CommonTests(ManyTestCasesWithServerMixin,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy