From 40a737d05cff2f5d021b3dd63fbf82a7a147da6b Mon Sep 17 00:00:00 2001
From: Chandrasekhar Ramakrishnan <chandrasekhar.ramakrishnan@id.ethz.ch>
Date: Tue, 10 May 2016 15:28:40 +0200
Subject: [PATCH] SSDM-3554: Implemented storage and reading of credentials
 from file.

---
 src/python/pybis/pybis.py      | 4 +++-
 src/python/pybis/pybis_test.py | 3 ++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/python/pybis/pybis.py b/src/python/pybis/pybis.py
index 8b0d081e3d9..c968523d073 100644
--- a/src/python/pybis/pybis.py
+++ b/src/python/pybis/pybis.py
@@ -59,7 +59,9 @@ class OpenbisCredentialStore:
         """
         if not os.path.exists(self.store_path):
             return OpenbisCredentials()
-        # TODO Implement reading a credentials file
+        with open(self.store_path, "r") as f:
+            token = f.read()
+        return OpenbisCredentials(token)
 
     def write(self, credentials):
         """Write a credentials object to the store, overwriting any previous information.
diff --git a/src/python/pybis/pybis_test.py b/src/python/pybis/pybis_test.py
index 5c9dcf3c652..8f22386a658 100644
--- a/src/python/pybis/pybis_test.py
+++ b/src/python/pybis/pybis_test.py
@@ -18,4 +18,5 @@ def test_credentials_store(tmpdir):
     store = OpenbisCredentialStore(str(tmpdir))
     store.write(credentials)
     disk_credentials = store.read()
-    assert credentials.token == disk_credentials.token
\ No newline at end of file
+    assert credentials.token == disk_credentials.token
+    assert not disk_credentials.has_username_and_password()
-- 
GitLab