diff --git a/src/libaktualizr/primary/sotauptaneclient.cc b/src/libaktualizr/primary/sotauptaneclient.cc index f9d192b893..0c3ab21975 100644 --- a/src/libaktualizr/primary/sotauptaneclient.cc +++ b/src/libaktualizr/primary/sotauptaneclient.cc @@ -555,7 +555,7 @@ bool SotaUptaneClient::updateImagesMeta() { // Update Images delegated Targets Metadata for (const std::string &delegation : images_repo.delegations("targets")) { std::string images_delegated; - Uptane::Role delegated_role = Uptane::Role::Delegated(delegation); + Uptane::Role delegated_role = Uptane::Role::Delegation(delegation); if (!uptane_fetcher->fetchLatestRole(&images_delegated, Uptane::kMaxImagesTargetsSize, Uptane::RepositoryType::Image(), delegated_role)) { @@ -712,7 +712,7 @@ bool SotaUptaneClient::checkImagesMetaOffline() { // Update Images delegated Targets Metadata for (const std::string &delegation : images_repo.delegations("targets")) { std::string images_delegated; - Uptane::Role delegated_role = Uptane::Role::Delegated(delegation); + Uptane::Role delegated_role = Uptane::Role::Delegation(delegation); if (!storage->loadDelegation(&images_delegated, delegated_role)) { return false; } diff --git a/src/libaktualizr/uptane/imagesrepository.cc b/src/libaktualizr/uptane/imagesrepository.cc index 6b45cde9f3..5e308229c7 100644 --- a/src/libaktualizr/uptane/imagesrepository.cc +++ b/src/libaktualizr/uptane/imagesrepository.cc @@ -130,7 +130,7 @@ std::unique_ptr ImagesRepository::getTarget(const Uptane::Target if (it == toplevel.targets.cend()) { // Check if the target matches any of the delegation paths. for (const auto& delegate_name : toplevel.delegated_role_names_) { - Role delegate_role = Role::Delegated(delegate_name); + Role delegate_role = Role::Delegation(delegate_name); std::vector patterns = toplevel.paths_for_role_[delegate_role]; for (const auto& pattern : patterns) { if (fnmatch(pattern.c_str(), director_target.filename().c_str(), 0) == 0) { diff --git a/src/libaktualizr/uptane/role.cc b/src/libaktualizr/uptane/role.cc index 0f7bdd6815..928c951e1a 100644 --- a/src/libaktualizr/uptane/role.cc +++ b/src/libaktualizr/uptane/role.cc @@ -18,7 +18,7 @@ Role::Role(const std::string &role_name, const bool delegation) { if (IsReserved(name_)) { throw Uptane::Exception("", "Delegated role name " + role_name + " is reserved."); } - role_ = RoleEnum::kDelegated; + role_ = RoleEnum::kDelegation; name_ = role_name; } else if (role_name_lower == ROOT) { role_ = RoleEnum::kRoot; diff --git a/src/libaktualizr/uptane/tuf.cc b/src/libaktualizr/uptane/tuf.cc index ef7625fc88..a2b1bead31 100644 --- a/src/libaktualizr/uptane/tuf.cc +++ b/src/libaktualizr/uptane/tuf.cc @@ -279,7 +279,7 @@ void Uptane::Targets::init(const Json::Value &json) { const Json::Value role_list = json["signed"]["delegations"]["roles"]; for (Json::ValueIterator it = role_list.begin(); it != role_list.end(); it++) { const std::string role_name = (*it)["name"].asString(); - const Role role = Role::Delegated(role_name); + const Role role = Role::Delegation(role_name); delegated_role_names_.insert(role_name); ParseRole(Uptane::RepositoryType::Image(), it, role, name_); diff --git a/src/libaktualizr/uptane/tuf.h b/src/libaktualizr/uptane/tuf.h index 191caf325c..0d13dd9679 100644 --- a/src/libaktualizr/uptane/tuf.h +++ b/src/libaktualizr/uptane/tuf.h @@ -64,9 +64,9 @@ class Role { static Role Snapshot() { return Role{RoleEnum::kSnapshot}; } static Role Targets() { return Role{RoleEnum::kTargets}; } static Role Timestamp() { return Role{RoleEnum::kTimestamp}; } - static Role Delegated(const std::string &name) { return Role(name, true); } + static Role Delegation(const std::string &name) { return Role(name, true); } static Role InvalidRole() { return Role{RoleEnum::kInvalidRole}; } - // Delegated is not included because this is only used for a metadata table + // Delegation is not included because this is only used for a metadata table // that doesn't include delegations. static std::vector Roles() { return {Root(), Snapshot(), Targets(), Timestamp()}; } static bool IsReserved(const std::string &name) { @@ -76,7 +76,7 @@ class Role { explicit Role(const std::string &role_name, bool delegation = false); std::string ToString() const; int ToInt() const { return static_cast(role_); } - bool IsDelegation() const { return role_ == RoleEnum::kDelegated; } + bool IsDelegation() const { return role_ == RoleEnum::kDelegation; } bool operator==(const Role &other) const { return name_ == other.name_; } bool operator!=(const Role &other) const { return !(*this == other); } bool operator<(const Role &other) const { return name_ < other.name_; } @@ -86,7 +86,7 @@ class Role { private: /** The four standard roles must match the meta_types table in sqlstorage. * Delegations are special and handled differently. */ - enum class RoleEnum { kRoot = 0, kSnapshot = 1, kTargets = 2, kTimestamp = 3, kDelegated = 4, kInvalidRole = -1 }; + enum class RoleEnum { kRoot = 0, kSnapshot = 1, kTargets = 2, kTimestamp = 3, kDelegation = 4, kInvalidRole = -1 }; explicit Role(RoleEnum role) : role_(role) { if (role_ == RoleEnum::kRoot) { diff --git a/src/libaktualizr/uptane/tuf_test.cc b/src/libaktualizr/uptane/tuf_test.cc index 248d232f78..2080d0848e 100644 --- a/src/libaktualizr/uptane/tuf_test.cc +++ b/src/libaktualizr/uptane/tuf_test.cc @@ -72,17 +72,17 @@ TEST(Role, ValidateRoles) { /* Delegated roles have custom names. */ TEST(Role, ValidateDelegation) { - Uptane::Role delegated = Uptane::Role::Delegated("whatever"); + Uptane::Role delegated = Uptane::Role::Delegation("whatever"); EXPECT_EQ(delegated.ToString(), "whatever"); EXPECT_EQ(delegated.IsDelegation(), true); } /* Reject delegated role names that are identical to reserved role names. */ TEST(Role, InvalidDelegationName) { - EXPECT_THROW(Uptane::Role::Delegated("root"), Uptane::Exception); - EXPECT_THROW(Uptane::Role::Delegated("snapshot"), Uptane::Exception); - EXPECT_THROW(Uptane::Role::Delegated("targets"), Uptane::Exception); - EXPECT_THROW(Uptane::Role::Delegated("timestamp"), Uptane::Exception); + EXPECT_THROW(Uptane::Role::Delegation("root"), Uptane::Exception); + EXPECT_THROW(Uptane::Role::Delegation("snapshot"), Uptane::Exception); + EXPECT_THROW(Uptane::Role::Delegation("targets"), Uptane::Exception); + EXPECT_THROW(Uptane::Role::Delegation("timestamp"), Uptane::Exception); } #ifndef __NO_MAIN__