+----------------------------------------------------+----------+--------------------------------------------------------------+----------+-----------+----------+
| ``Request.Tags`` | table | object tags map | yes | no | no |
+----------------------------------------------------+----------+--------------------------------------------------------------+----------+-----------+----------+
+| ``Request.User`` | table | user that triggered the request | no | no | no |
++----------------------------------------------------+----------+--------------------------------------------------------------+----------+-----------+----------+
+| ``Request.User.Tenant`` | string | triggering user tenant | no | no | no |
++----------------------------------------------------+----------+--------------------------------------------------------------+----------+-----------+----------+
+| ``Request.User.Id`` | string | triggering user id | no | no | no |
++----------------------------------------------------+----------+--------------------------------------------------------------+----------+-----------+----------+
Request Functions
--------------------
pushstring(L, s->trans_id);
} else if (strcasecmp(index, "Tags") == 0) {
create_metatable<StringMapMetaTable<RGWObjTags::tag_map_t>>(L, false, &(s->tagset.get_tags()));
+ } else if (strcasecmp(index, "User") == 0) {
+ if (!s->user) {
+ lua_pushnil(L);
+ } else {
+ create_metatable<UserMetaTable>(L, false, const_cast<rgw_user*>(&(s->user->get_id())));
+ }
} else {
return error_unknown_field(L, index, TableName());
}
ASSERT_EQ(rc, 0);
}
+TEST(TestRGWLua, User)
+{
+ const std::string script = R"(
+ assert(Request.User)
+ assert(Request.User.Id == "myid")
+ assert(Request.User.Tenant == "mytenant")
+ )";
+
+ DEFINE_REQ_STATE;
+
+ rgw_user u;
+ u.tenant = "mytenant";
+ u.id = "myid";
+ s.user.reset(new sal::RadosUser(nullptr, u));
+
+ const auto rc = lua::request::execute(nullptr, nullptr, nullptr, &s, "put_obj", script);
+ ASSERT_EQ(rc, 0);
+}
+
+
TEST(TestRGWLua, UseFunction)
{
const std::string script = R"(