From 11b683a156dfbb918dd74b53650efdcc5e2ab969 Mon Sep 17 00:00:00 2001 From: Kevin Fronczak Date: Mon, 6 Mar 2017 23:20:46 -0500 Subject: [PATCH] Fixed issue with host name in header, added test to catch this --- .gitignore | 1 + blinkpy.py | 2 +- setup.py | 2 +- tests/test_blink_requests.py | 1 + tests/test_const.py | 5 ++++- 5 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 561086d..2155ed6 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ dist/* MANIFEST README .sh +build/* diff --git a/blinkpy.py b/blinkpy.py index 178d2df..4c33422 100644 --- a/blinkpy.py +++ b/blinkpy.py @@ -376,7 +376,7 @@ class Blink(object): response = _request(LOGIN_URL, headers=headers, data=data, type='post') self._TOKEN = response['authtoken']['authtoken'] (self._REGION_ID, self._REGION), = response['region'].items() - self._HOST = self._REGION + '.' + BLINK_URL + self._HOST = self._REGION_ID + '.' + BLINK_URL self._AUTH_HEADER = {'Host': self._HOST, 'TOKEN_AUTH': self._TOKEN } diff --git a/setup.py b/setup.py index c99a7df..e05ff80 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ from setuptools import setup setup( name = 'blinkpy', - version = '0.4.', + version = '0.4.4', description = 'A Blink camera Python library', long_description='A library that communicates with Blink cameras', author = 'Kevin Fronczak', diff --git a/tests/test_blink_requests.py b/tests/test_blink_requests.py index 28776bf..f88c103 100644 --- a/tests/test_blink_requests.py +++ b/tests/test_blink_requests.py @@ -66,6 +66,7 @@ class TestBlinkRequests(unittest.TestCase): self.assertEqual(name, const.CAMERA_NAME) self.assertEqual(camera.armed, const.ARMED) self.assertEqual(camera.motion['video'], BASE_URL + const.THUMB + '.mp4') + self.assertEqual(camera.header, const.auth_header) elif camera.id == str(const.DEVICE_ID2): self.assertEqual(name, const.CAMERA_NAME2) self.assertEqual(camera.armed, const.ARMED2) diff --git a/tests/test_const.py b/tests/test_const.py index f0dd330..415b86b 100644 --- a/tests/test_const.py +++ b/tests/test_const.py @@ -24,7 +24,10 @@ if ISONLINE: ONLINE = 'online' else: ONLINE = 'offline' - + +auth_header = {'Host': REGION_ID+'.immedia-semi.com', + 'TOKEN_AUTH': TOKEN + } response = {'account': {'notifications': 1}, 'devices': [{'device_type': 'camera',