diff --git a/scripts/pp_client.py b/scripts/pp_client.py index 5755ab3..ad2869a 100644 --- a/scripts/pp_client.py +++ b/scripts/pp_client.py @@ -60,7 +60,10 @@ def load_config(path=None): if not isinstance(config, dict): raise PPError("incomplete") else: - legacy = pathlib.Path(os.environ.get("PP_LEGACY_CREDENTIALS_FILE") or "/run/source-secrets/pp_credentials.json") + legacy_path = os.environ.get("PP_LEGACY_CREDENTIALS_FILE") + if not legacy_path: + raise PPError("incomplete") + legacy = pathlib.Path(legacy_path) try: config = json.loads(legacy.read_text(encoding="utf-8")) except (OSError, ValueError): diff --git a/scripts/test_pp_client.py b/scripts/test_pp_client.py index 9ac97f9..35cb606 100644 --- a/scripts/test_pp_client.py +++ b/scripts/test_pp_client.py @@ -53,4 +53,8 @@ class PPClientTests(unittest.TestCase): self.assertFalse(local);self.assertGreater(size,0);self.assertEqual(hashlib.sha256(pathlib.Path(path).read_bytes()).hexdigest(),digest) self.assertEqual([x[0] for x in self.calls],['POST','GET','GET']) finally:os.unlink(path) + def test_missing_state_never_implicitly_reuses_legacy_credentials(self): + fake=json.dumps({'username':'example','password':'synthetic-'+'fixture'}) + with patch.dict(os.environ,{'PP_LEGACY_CREDENTIALS_FILE':''}),patch('pathlib.Path.exists',return_value=False),patch('pathlib.Path.read_text',return_value=fake): + with self.assertRaises(pp_client.PPError):pp_client.load_config('/example-missing/settings.json') if __name__=='__main__':unittest.main()