From 3a00db02a3d2b7b2ae290ff7523415e19a9125a9 Mon Sep 17 00:00:00 2001 From: Martin Vrachev Date: Wed, 1 Dec 2021 20:03:55 +0200 Subject: [PATCH] Sanitize repo simulator role names when writing Sanitize the delegated rolenames in the repo simulator when dumping in a directory the same way the ngclient does. That's necessary because when testing fishy role names leads to an error: "PermissionError: [Errno 13] Permission denied: '/.json'" Signed-off-by: Martin Vrachev --- tests/repository_simulator.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/repository_simulator.py b/tests/repository_simulator.py index 6377fe0a2b..dc3f0e5721 100644 --- a/tests/repository_simulator.py +++ b/tests/repository_simulator.py @@ -397,5 +397,6 @@ def write(self) -> None: f.write(self.fetch_metadata(role)) for role in self.md_delegates: - with open(os.path.join(dest_dir, f"{role}.json"), "wb") as f: + quoted_role = parse.quote(role, "") + with open(os.path.join(dest_dir, f"{quoted_role}.json"), "wb") as f: f.write(self.fetch_metadata(role))