From 56415888490792ddd3b04d9af19e82f86c0b08f0 Mon Sep 17 00:00:00 2001 From: Justin Hiemstra Date: Fri, 23 Feb 2024 18:46:27 +0000 Subject: [PATCH 1/2] When `get_lot_as_json` without recursive, return "owner" To distinguish between a lot's personal owner and those who own the lot through inheritance, the `get_lot_as_json` function will return something like ``` "owners": ["owner1", "owner2"] ``` when called with recursion, and something like ``` "owner": "owner1" ``` when called without. The distinction here is that "owner" MUST map to the lot's personal owner, whereas "owners" is a list of all owners, including the personal owner. --- src/lotman.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lotman.cpp b/src/lotman.cpp index d8f4611..059199e 100644 --- a/src/lotman.cpp +++ b/src/lotman.cpp @@ -1522,7 +1522,7 @@ int lotman_get_lot_as_json(const char *lot_name, const bool recursive, char **ou output_obj["owners"] = rp_vec_str.first; } else { - output_obj["owners"] = rp_vec_str.first[0]; // Only one owner, this is where it will be. + output_obj["owner"] = rp_vec_str.first[0]; // Only one owner, this is where it will be. } // Add parents according to recursive flag From c28040081364405bbef910ea4a52c8b78e0087a7 Mon Sep 17 00:00:00 2001 From: Justin Hiemstra Date: Fri, 23 Feb 2024 18:56:01 +0000 Subject: [PATCH 2/2] Update test to reflect 'owner' --- test/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/main.cpp b/test/main.cpp index 07a0230..e3334bb 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -619,7 +619,7 @@ namespace { ASSERT_TRUE(rv == 0) << err_msg; json output_JSON = json::parse(output); free(output); - json expected_output = R"({"children":["lot5"],"lot_name":"lot3","management_policy_attrs":{"creation_time":123.0,"dedicated_GB":10.111,"deletion_time":333.0,"expiration_time":222.0,"max_num_objects":50.0,"opportunistic_GB":6.6},"owners":"not owner1","parents":["lot2","sep_node"],"paths":[{"lot_name":"lot3","path":"/another/path","recursive":true},{"lot_name":"lot3","path":"/updated/path","recursive":false},{"lot_name":"lot3","path":"/foo/barr","recursive":true}],"usage":{"GB_being_written":{"self_contrib":0.0},"dedicated_GB":{"self_contrib":0.0},"num_objects":{"self_contrib":0.0},"objects_being_written":{"self_contrib":0.0},"opportunistic_GB":{"self_contrib":0.0},"total_GB":{"self_contrib":0.0}}})"_json; + json expected_output = R"({"children":["lot5"],"lot_name":"lot3","management_policy_attrs":{"creation_time":123.0,"dedicated_GB":10.111,"deletion_time":333.0,"expiration_time":222.0,"max_num_objects":50.0,"opportunistic_GB":6.6},"owner":"not owner1","parents":["lot2","sep_node"],"paths":[{"lot_name":"lot3","path":"/another/path","recursive":true},{"lot_name":"lot3","path":"/updated/path","recursive":false},{"lot_name":"lot3","path":"/foo/barr","recursive":true}],"usage":{"GB_being_written":{"self_contrib":0.0},"dedicated_GB":{"self_contrib":0.0},"num_objects":{"self_contrib":0.0},"objects_being_written":{"self_contrib":0.0},"opportunistic_GB":{"self_contrib":0.0},"total_GB":{"self_contrib":0.0}}})"_json; ASSERT_TRUE(output_JSON == expected_output) << output_JSON; char *output2;