def test_get_rpc_secret_returns_None_when_empty_file(self): maas_dir = os.path.join(self.environ['SNAP_DATA'], 'var', 'lib', 'maas') os.makedirs(maas_dir) secret_path = os.path.join(maas_dir, 'secret') open(secret_path, 'w').close() self.assertIsNone(snappy.get_rpc_secret())
def test_set_rpc_secret_sets_secret(self): maas_dir = os.path.join(self.environ['SNAP_DATA'], 'var', 'lib', 'maas') os.makedirs(maas_dir) secret = factory.make_string() snappy.set_rpc_secret(secret) self.assertEquals(secret, snappy.get_rpc_secret())
def test_set_rpc_secret_sets_secret(self): maas_dir = os.path.join(self.environ["SNAP_DATA"], "var", "lib", "maas") os.makedirs(maas_dir) secret = factory.make_string() snappy.set_rpc_secret(secret) self.assertEquals(secret, snappy.get_rpc_secret())
def test_get_rpc_secret_returns_None_when_empty_file(self): maas_dir = os.path.join(self.environ["SNAP_DATA"], "var", "lib", "maas") os.makedirs(maas_dir) secret_path = os.path.join(maas_dir, "secret") open(secret_path, "w").close() self.assertIsNone(snappy.get_rpc_secret())
def test_get_rpc_secret_returns_secret(self): maas_dir = os.path.join(self.environ['SNAP_DATA'], 'var', 'lib', 'maas') os.makedirs(maas_dir) secret_path = os.path.join(maas_dir, 'secret') secret = factory.make_string() with open(secret_path, 'w') as stream: stream.write(secret) self.assertEqual(secret, snappy.get_rpc_secret())
def test_get_rpc_secret_returns_secret(self): maas_dir = os.path.join(self.environ["SNAP_DATA"], "var", "lib", "maas") os.makedirs(maas_dir) secret_path = os.path.join(maas_dir, "secret") secret = factory.make_string() with open(secret_path, "w") as stream: stream.write(secret) self.assertEqual(secret, snappy.get_rpc_secret())
def test_get_rpc_secret_returns_None_when_no_file(self): maas_dir = os.path.join(self.environ['SNAP_DATA'], 'var', 'lib', 'maas') os.makedirs(maas_dir) self.assertIsNone(snappy.get_rpc_secret())
def test_set_rpc_secret_clears_secret(self): secret = factory.make_string() snappy.set_rpc_secret(secret) snappy.set_rpc_secret(None) self.assertIsNone(snappy.get_rpc_secret()) self.assertFalse(self.secret_file.exists())
def test_set_rpc_secret_sets_secret(self): secret = factory.make_string() snappy.set_rpc_secret(secret) self.assertEqual(secret, snappy.get_rpc_secret())
def test_get_rpc_secret_returns_None_when_empty_file(self): self.secret_file.write_text("") self.assertIsNone(snappy.get_rpc_secret())
def test_get_rpc_secret_returns_None_when_no_file(self): self.assertIsNone(snappy.get_rpc_secret())
def test_get_rpc_secret_returns_secret(self): secret = factory.make_string() self.secret_file.write_text(secret) self.assertEqual(snappy.get_rpc_secret(), secret)
def test_get_rpc_secret_returns_None_when_no_file(self): maas_dir = os.path.join(self.environ["SNAP_DATA"], "var", "lib", "maas") os.makedirs(maas_dir) self.assertIsNone(snappy.get_rpc_secret())