diff options
author | Peter Wagner <pwagner@pebble.com> | 2015-09-11 08:51:34 -0400 |
---|---|---|
committer | Giuseppe Lavagetto <lavagetto@gmail.com> | 2015-11-16 08:45:18 +0100 |
commit | 817adc5348a798d2981e6cc5b988373a0985cf54 (patch) | |
tree | 6f6d66cb7b0836e9da94f6da588f4bfe2325cd65 /src/etcd/tests/unit/test_client.py | |
parent | 8e1e1ce3021031dd3487d94b7b4165908787b9f1 (diff) |
User authentication initial
* Initial BASIC auth implementation + unit tests
Checkpoint before integration tests.
Diffstat (limited to 'src/etcd/tests/unit/test_client.py')
-rw-r--r-- | src/etcd/tests/unit/test_client.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/etcd/tests/unit/test_client.py b/src/etcd/tests/unit/test_client.py index 4301732..bb05a66 100644 --- a/src/etcd/tests/unit/test_client.py +++ b/src/etcd/tests/unit/test_client.py @@ -45,6 +45,16 @@ class TestClient(unittest.TestCase): client = etcd.Client() assert client.allow_redirect + def test_default_username(self): + """ default username is None""" + client = etcd.Client() + assert client.username is None + + def test_default_password(self): + """ default username is None""" + client = etcd.Client() + assert client.password is None + def test_set_host(self): """ can change host """ client = etcd.Client(host='192.168.1.1') @@ -92,6 +102,29 @@ class TestClient(unittest.TestCase): client = etcd.Client(use_proxies = True) assert client._use_proxies + def test_set_username_only(self): + client = etcd.Client(username='username') + assert client.username is None + + def test_set_password_only(self): + client = etcd.Client(password='password') + assert client.password is None + + def test_set_username_password(self): + client = etcd.Client(username='username', password='password') + assert client.username == 'username' + assert client.password == 'password' + + def test_get_headers_with_auth(self): + client = etcd.Client(username='username', password='password') + assert client._get_headers() == { + 'authorization': 'Basic dXNlcm5hbWU6cGFzc3dvcmQ=' + } + + def test_get_headers_without_auth(self): + client = etcd.Client() + assert client._get_headers() == {} + def test_allow_reconnect(self): """ Fails if allow_reconnect is false and a list of hosts is given""" with self.assertRaises(etcd.EtcdException): |