Beispiel #1
0
 def test_missing_credential_file(self):
     with self.assertRaises(FileNotFoundError):
         Credentials("nonexistant.yaml")
Beispiel #2
0
 def test_bad_yaml_file(self):
     with self.assertRaises(yaml.YAMLError):
         Credentials("bad_yaml_file.yaml")
Beispiel #3
0
 def test_bad_permissions_file(self):
     with self.assertRaises(PermissionError):
         Credentials("bad_permissions.yaml")
Beispiel #4
0
 def test_bad_dir(self):
     os.environ["IIP_CREDENTIAL_DIR"] = os.path.join(self.package, "tests", "files", "nothing")
     with self.assertRaises(PermissionError):
         Credentials("iip_cred.yaml")
Beispiel #5
0
 def test_missing_credentials(self):
     del os.environ["IIP_CREDENTIAL_DIR"]
     os.environ["HOME"] = "/tmp"
     with self.assertRaises(PermissionError):
         Credentials("iip_cred.yaml")
     del os.environ["HOME"]
Beispiel #6
0
 def test_credentials(self):
     cred = Credentials("iip_cred.yaml")
     self.assertEqual(cred.getUser("service_user"), "fakeuser")
     self.assertEqual(cred.getPasswd("service_passwd"), "fakepass")
Beispiel #7
0
 def __init__(self, name, config_filename, log_filename):
     self._name = name
     self._config = self.loadConfigFile(config_filename)
     self.setupLogging(log_filename)
     self._cred = Credentials('iip_cred.yaml')