Fixes: http://tracker.ceph.com/issues/20395
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
return true;
}
-void RGWAccessControlPolicy_SWIFTAcct::to_str(std::string& acl_str) const
+boost::optional<std::string> RGWAccessControlPolicy_SWIFTAcct::to_str() const
{
std::vector<std::string> admin;
std::vector<std::string> readwrite;
}
}
+ /* If there is no grant to serialize, let's exit earlier to not return
+ * an empty JSON object which brakes the functional tests of Swift. */
+ if (admin.empty() && readwrite.empty() && readonly.empty()) {
+ return boost::none;
+ }
+
/* Serialize the groups. */
JSONFormatter formatter;
std::ostringstream oss;
formatter.flush(oss);
- acl_str = oss.str();
+ return oss.str();
}
#include <string>
#include <include/types.h>
+#include <boost/optional.hpp>
+
#include "rgw_acl.h"
class RGWAccessControlPolicy_SWIFT : public RGWAccessControlPolicy
const rgw_user& id,
const std::string& name,
const std::string& acl_str);
- void to_str(std::string& acl) const;
+ boost::optional<std::string> to_str() const;
};
#endif
}
/* Dump account ACLs */
- string acct_acl;
- policy.to_str(acct_acl);
- if (acct_acl.size()) {
- dump_header(s, "X-Account-Access-Control", std::move(acct_acl));
+ auto account_acls = policy.to_str();
+ if (account_acls) {
+ dump_header(s, "X-Account-Access-Control", std::move(*account_acls));
}
}