Merge "Exit sucessfully when manipulating project keys"

This commit is contained in:
Zuul
2021-09-22 10:47:56 +00:00
committed by Gerrit Code Review
2 changed files with 9 additions and 0 deletions
+4
View File
@@ -193,6 +193,7 @@ class TestKeyOperations(ZuulTestCase):
stdout=subprocess.PIPE)
out, _ = p.communicate()
self.log.debug(out.decode('utf8'))
self.assertEqual(p.returncode, 0)
# Delete keys from ZK
self.zk_client.client.delete('/keystorage', recursive=True)
@@ -209,6 +210,7 @@ class TestKeyOperations(ZuulTestCase):
stdout=subprocess.PIPE)
out, _ = p.communicate()
self.log.debug(out.decode('utf8'))
self.assertEqual(p.returncode, 0)
# Make sure the new data matches the original
new_data = self.getZKTree('/keystorage')
@@ -229,6 +231,7 @@ class TestKeyOperations(ZuulTestCase):
stdout=subprocess.PIPE)
out, _ = p.communicate()
self.log.debug(out.decode('utf8'))
self.assertEqual(p.returncode, 0)
data = self.getZKTree('/keystorage')
self.assertEqual(
@@ -247,6 +250,7 @@ class TestKeyOperations(ZuulTestCase):
stdout=subprocess.PIPE)
out, _ = p.communicate()
self.log.debug(out.decode('utf8'))
self.assertEqual(p.returncode, 0)
data = self.getZKTree('/keystorage')
self.assertIsNone(
+5
View File
@@ -861,6 +861,7 @@ class Client(zuul.cmd.ZuulApp):
with open(os.open(self.args.path,
os.O_CREAT | os.O_WRONLY, 0o600), 'w') as f:
json.dump(export, f)
sys.exit(0)
def import_keys(self):
logging.basicConfig(level=logging.INFO)
@@ -875,6 +876,7 @@ class Client(zuul.cmd.ZuulApp):
with open(self.args.path, 'r') as f:
import_data = json.load(f)
keystore.importKeys(import_data, self.args.force)
sys.exit(0)
def copy_keys(self):
logging.basicConfig(level=logging.INFO)
@@ -900,6 +902,7 @@ class Client(zuul.cmd.ZuulApp):
self.log.info("Copied keys from %s %s to %s %s",
args.src_connection, args.src_project,
args.dest_connection, args.dest_project)
sys.exit(0)
def delete_keys(self):
logging.basicConfig(level=logging.INFO)
@@ -916,6 +919,7 @@ class Client(zuul.cmd.ZuulApp):
keystore.deleteProjectsSecretsKeys(args.connection, args.project)
self.log.info("Delete keys from %s %s",
args.connection, args.project)
sys.exit(0)
def delete_state(self):
logging.basicConfig(level=logging.INFO)
@@ -926,6 +930,7 @@ class Client(zuul.cmd.ZuulApp):
"all ephemeral data from ZooKeeper? (yes/no) ")
if confirm.strip().lower() == 'yes':
zk_client.client.delete('/zuul', recursive=True)
sys.exit(0)
def main():