]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
test: Add test for fscrypt dummy encryption
authorChristopher Hoffman <choffman@redhat.com>
Wed, 17 Sep 2025 15:47:44 +0000 (15:47 +0000)
committerChristopher Hoffman <choffman@redhat.com>
Fri, 19 Sep 2025 21:20:15 +0000 (21:20 +0000)
Signed-off-by: Christopher Hoffman <choffman@redhat.com>
src/client/Client.cc
src/test/libcephfs/fscrypt.cc

index 0b89fcc2e6bf62b50e24ba49bcc57b543718425e..da8aeefd1c4e5d08dfa338e65610137aea1333fa 100644 (file)
@@ -18328,11 +18328,11 @@ int Client::ll_get_fscrypt_policy_v2(Inode *in, struct fscrypt_policy_v2* policy
   if (in->is_fscrypt_enabled()) {
     in->fscrypt_ctx->convert_to(policy);
     if (policy->version != 2) {
-      return EINVAL;
+      return -EINVAL;
     }
     return 0;
   }
-  return ENODATA;
+  return -ENODATA;
 }
 
 int Client::is_encrypted(int fd, UserPerm& perms, char* enctag)
index ac70b91dfcec6fca8ac97c6bae1083fd820a729e..aa80749668e730fbf06265dc4b9a3fb2584f2937 100644 (file)
@@ -1148,6 +1148,31 @@ TEST(FSCrypt, SetPolicyAlreadyExistDifferentPolicyNotEmpty) {
   ceph_shutdown(cmount);
 }
 
+TEST(FSCrypt, FSCryptDummyEncryptionNoExistingRegularPolicy) {
+  struct ceph_mount_info* cmount;
+  ASSERT_EQ(0, ceph_create(&cmount, NULL));
+  ASSERT_EQ(0, ceph_conf_read_file(cmount, NULL));
+  ASSERT_EQ(0, ceph_conf_parse_env(cmount, NULL));
+
+  string name = get_unique_dir_name();
+  name = string("/") + name;
+
+  int r = ceph_mount(cmount, NULL);
+  ASSERT_EQ(0, ceph_mkdir(cmount, name.c_str(), 0777));
+  ceph_unmount(cmount);
+
+  ASSERT_EQ(0, ceph_conf_set(cmount, "client_fscrypt_dummy_encryption", "true"));
+  r = ceph_mount(cmount, name.c_str());
+  ASSERT_EQ(0, r);
+
+  int fd = ceph_open(cmount, ".", O_DIRECTORY, 0);
+
+  fscrypt_policy_v2 policy;
+  ASSERT_EQ(0, ceph_get_fscrypt_policy_v2(cmount, fd, &policy));
+
+  ceph_shutdown(cmount);
+}
+
 int main(int argc, char **argv)
 {
   int r = update_root_mode();