Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Commit

Permalink
Rename "repo/image" to "repo/repo"
Browse files Browse the repository at this point in the history
Sad but it matches backend's naming.

Signed-off-by: Laurent Bonnans <laurent.bonnans@here.com>
  • Loading branch information
lbonn committed Aug 23, 2019
1 parent 74f2cdb commit babda9e
Show file tree
Hide file tree
Showing 12 changed files with 10 additions and 31 deletions.
4 changes: 0 additions & 4 deletions scripts/selfupdate_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ class Handler(BaseHTTPRequestHandler):
def do_GET(self):
local_path = self.path
print("GET: " + local_path)
# Fix annoying issue where uptane-generator generates metadata for the
# images repository in /image but aktualizr expects /repo.
if local_path.startswith("/repo/"):
local_path = local_path.replace('/repo/', '/image/', 1)
self.send_response(200)
self.end_headers()
with open(self.server.base_dir + "/fake_root/repo/" + local_path, "rb") as fl:
Expand Down
2 changes: 0 additions & 2 deletions src/libaktualizr/primary/aktualizr_fullostree_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,6 @@ int main(int argc, char **argv) {
"--serial", "CA:FE:A6:D2:84:9D"});
uptane_gen.run({"signtargets", "--path", meta_dir.PathString(), "--correlationid", "abc123"});
LOG_INFO << uptane_gen.lastStdOut();
// Work around inconsistent directory naming.
Utils::copyDir(meta_dir.Path() / "repo/image", meta_dir.Path() / "repo/repo");

return RUN_ALL_TESTS();
}
Expand Down
4 changes: 0 additions & 4 deletions src/libaktualizr/primary/custom_url_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ TEST(Aktualizr, ImagesCustomUrl) {
uptane_gen.run({"addtarget", "--path", meta_dir.PathString(), "--targetname", "firmware.txt", "--hwid", "primary_hw",
"--serial", "CA:FE:A6:D2:84:9D"});
uptane_gen.run({"signtargets", "--path", meta_dir.PathString(), "--correlationid", "abc123"});
// Work around inconsistent directory naming.
Utils::copyDir(meta_dir.Path() / "repo/image", meta_dir.Path() / "repo/repo");

auto storage = INvStorage::newStorage(conf.storage);
UptaneTestCommon::TestAktualizr aktualizr(conf, storage, http);
Expand Down Expand Up @@ -78,8 +76,6 @@ TEST(Aktualizr, BothCustomUrl) {
uptane_gen.run({"addtarget", "--path", meta_dir.PathString(), "--targetname", "firmware.txt", "--hwid", "primary_hw",
"--serial", "CA:FE:A6:D2:84:9D", "--url", "test-url3"});
uptane_gen.run({"signtargets", "--path", meta_dir.PathString(), "--correlationid", "abc123"});
// Work around inconsistent directory naming.
Utils::copyDir(meta_dir.Path() / "repo/image", meta_dir.Path() / "repo/repo");

auto storage = INvStorage::newStorage(conf.storage);
UptaneTestCommon::TestAktualizr aktualizr(conf, storage, http);
Expand Down
2 changes: 0 additions & 2 deletions src/libaktualizr/primary/download_nonostree_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ int main(int argc, char **argv) {
uptane_gen.run({"addtarget", "--path", meta_dir.PathString(), "--targetname", "update_1.0", "--hwid", "primary_hw",
"--serial", "CA:FE:A6:D2:84:9D"});
uptane_gen.run({"signtargets", "--path", meta_dir.PathString(), "--correlationid", "abc123"});
// Work around inconsistent directory naming.
Utils::copyDir(meta_dir.Path() / "repo/image", meta_dir.Path() / "repo/repo");

return RUN_ALL_TESTS();
}
Expand Down
6 changes: 0 additions & 6 deletions src/libaktualizr/primary/empty_targets_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ TEST(Aktualizr, EmptyTargets) {
uptane_gen.run({"addtarget", "--path", meta_dir.PathString(), "--targetname", "firmware.txt", "--hwid", "primary_hw",
"--serial", "CA:FE:A6:D2:84:9D"});
uptane_gen.run({"signtargets", "--path", meta_dir.PathString(), "--correlationid", "abc123"});
// Work around inconsistent directory naming.
Utils::copyDir(meta_dir.Path() / "repo/image", meta_dir.Path() / "repo/repo");

auto storage = INvStorage::newStorage(conf.storage);
{
Expand Down Expand Up @@ -112,8 +110,6 @@ TEST(Aktualizr, EmptyTargetsAfterDownload) {
uptane_gen.run({"addtarget", "--path", meta_dir.PathString(), "--targetname", "firmware.txt", "--hwid", "primary_hw",
"--serial", "CA:FE:A6:D2:84:9D"});
uptane_gen.run({"signtargets", "--path", meta_dir.PathString(), "--correlationid", "abc123"});
// Work around inconsistent directory naming.
Utils::copyDir(meta_dir.Path() / "repo/image", meta_dir.Path() / "repo/repo");

// failing download
fault_injection_init();
Expand Down Expand Up @@ -161,8 +157,6 @@ TEST(Aktualizr, EmptyTargetsAfterInstall) {
uptane_gen.run({"addtarget", "--path", meta_dir.PathString(), "--targetname", "firmware.txt", "--hwid", "primary_hw",
"--serial", "CA:FE:A6:D2:84:9D"});
uptane_gen.run({"signtargets", "--path", meta_dir.PathString(), "--correlationid", "abc123"});
// Work around inconsistent directory naming.
Utils::copyDir(meta_dir.Path() / "repo/image", meta_dir.Path() / "repo/repo");

// failing install
fault_injection_init();
Expand Down
2 changes: 0 additions & 2 deletions src/libaktualizr/primary/target_mismatch_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ TEST(Aktualizr, HardwareMismatch) {
uptane_gen.run({"addtarget", "--path", meta_dir.PathString(), "--targetname", "firmware.txt", "--hwid", "primary_hw",
"--serial", "CA:FE:A6:D2:84:9D"});
uptane_gen.run({"signtargets", "--path", meta_dir.PathString()});
// Work around inconsistent directory naming.
Utils::copyDir(meta_dir.Path() / "repo/image", meta_dir.Path() / "repo/repo");

auto storage = INvStorage::newStorage(conf.storage);
UptaneTestCommon::TestAktualizr aktualizr(conf, storage, http);
Expand Down
5 changes: 1 addition & 4 deletions src/libaktualizr/uptane/uptane_delegation_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ void delegation_nested(const boost::filesystem::path& delegation_path, bool revo
class HttpFakeDelegation : public HttpFake {
public:
HttpFakeDelegation(const boost::filesystem::path& test_dir_in)
: HttpFake(test_dir_in, "", test_dir_in / "delegation_test/repo") {
// Work around inconsistent directory naming.
Utils::copyDir(test_dir_in / "delegation_test/repo/image", test_dir_in / "delegation_test/repo/repo");
}
: HttpFake(test_dir_in, "", test_dir_in / "delegation_test/repo") {}

HttpResponse handle_event(const std::string& url, const Json::Value& data) override {
(void)url;
Expand Down
4 changes: 3 additions & 1 deletion src/uptane_generator/image_repo.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ class ImageRepo : public Repo {
void revokeDelegation(const Uptane::Role &name);
std::vector<std::string> getDelegationTargets(const Uptane::Role &name);

static constexpr const char *dir{"repo/image"};
// note: it used to be "repo/image" which is way less confusing but we've just
// given up and adopted what the backend does
static constexpr const char *dir{"repo/repo"};

private:
void addImage(const std::string &name, Json::Value &target, const std::string &hardware_id,
Expand Down
2 changes: 1 addition & 1 deletion src/uptane_generator/run/serve_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def do_GET(self):
if self.path.startswith('/director/'):
self.do_get_static(top_path + "/uptane/repo/director/", self.path[10:])
elif self.path.startswith('/repo/'):
self.do_get_static(top_path + "/uptane/repo/image/", self.path[6:])
self.do_get_static(top_path + "/uptane/repo/repo/", self.path[6:])
elif self.path.startswith('/treehub/'):
self.do_get_static(top_path + "/uptane/repo/ostree/", self.path[9:])
else:
Expand Down
2 changes: 1 addition & 1 deletion tests/fake_http_server/fake_api_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def do_GET(self):
self.send_response(200)
self.end_headers()
if self.path == "/api/v1/user_repo/targets.json":
with open(os.path.join(sys.argv[2], "repo/image/targets.json")) as f:
with open(os.path.join(sys.argv[2], "repo/repo/targets.json")) as f:
self.wfile.write(bytes(f.read(), "utf8"))

def do_POST(self):
Expand Down
4 changes: 2 additions & 2 deletions tests/fake_http_server/fake_test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def do_GET(self):
self.send_response(200)
self.end_headers()
role = self.path[len("/repo/"):]
self.serve_meta('/repo/image/' + role)
self.serve_meta('/repo/repo/' + role)
elif self.path.startswith("/repo/targets"):
self.send_response(200)
self.end_headers()
Expand Down Expand Up @@ -181,7 +181,7 @@ def __init__(self, addr, meta_path, target_path, srcdir=None, fail_injector=None
if target_path is not None:
self.target_path = target_path
elif meta_path is not None:
self.target_path = path.join(meta_path, 'repo/image/targets')
self.target_path = path.join(meta_path, 'repo/repo/targets')
else:
self.target_path = None
self.fail_injector = fail_injector
Expand Down
4 changes: 2 additions & 2 deletions tests/ipsecondary_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
class UptaneTestRepo:

def __init__(self, repo_manager_exe):
self.image_rel_dir = 'repo/image'
self.target_rel_dir = 'repo/image/targets'
self.image_rel_dir = 'repo/repo'
self.target_rel_dir = 'repo/repo/targets'

self._repo_manager_exe = repo_manager_exe
self._repo_root_dir = tempfile.TemporaryDirectory()
Expand Down

0 comments on commit babda9e

Please sign in to comment.