This is an automated email from the ASF dual-hosted git repository.
Xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/opendal.git
The following commit(s) were added to refs/heads/main by this push:
new bb907a1873 fix(integrations/unftp-sbe): honor put start_pos and
validate cwd directories (#8720)
bb907a1873 is described below
commit bb907a18738cee10540717a587e28b136e3d835d
Author: Xuanwo <[email protected]>
AuthorDate: Mon Nov 23 05:19:40 2026 +0800
fix(integrations/unftp-sbe): honor put start_pos and validate cwd
directories (#8720)
* fix(integrations/unftp-sbe): honor put start_pos and validate cwd
directories
put() ignored its start_pos argument, so an APPE (or any offset write)
silently truncated the file. Offset writes now append at end of file on
write_can_append backends, return CommandNotImplemented where the
backend cannot append, and reject offsets that do not match the current
file size instead of overwriting data.
cwd() stat'ed the bare path, which rejects real directories on object
stores that address them as "dir/", and never checked the entry mode,
so CWD could switch to a regular file. cwd() now stats the normalized
trailing-slash form, requires a directory, and accepts implicit prefix
directories that have children but no directory entry of their own.
* fix(integrations/unftp-sbe): report cwd failures on list-less backends
correctly
Backends without the list capability cannot probe implicit prefix
directories; skipping the probe keeps cwd() reporting
PermanentDirectoryNotAvailable instead of leaking LocalError. cwd() also
short-circuits the FTP root, which some backends cannot stat, and a
probe that still reports unsupported/not-found maps to
PermanentDirectoryNotAvailable.
CI now runs the full cargo test suite for the integration instead of
only the ftp_loopback target.
* fix(integrations/unftp-sbe): propagate real stat errors from cwd
The stat fallback ran for every error, so PermissionDenied and
transient failures were reported as PermanentDirectoryNotAvailable on
list-less backends and hidden by the implicit-directory probe on
list-capable ones. The fallback now only covers NotFound,
NotADirectory, and Unsupported; other stat errors propagate through
convert_err. The probe reads a single lister entry instead of buffering
a full prefix listing.
Adds a stat-error-injection layer test covering permission and
unexpected errors on list-capable and list-less operators.
---
.github/workflows/ci_integration_unftp_sbe.yml | 4 +-
integrations/unftp-sbe/Cargo.toml | 2 +
integrations/unftp-sbe/src/lib.rs | 96 +++++-
integrations/unftp-sbe/tests/ftp_loopback.rs | 32 ++
integrations/unftp-sbe/tests/storage_backend.rs | 428 ++++++++++++++++++++++++
5 files changed, 548 insertions(+), 14 deletions(-)
diff --git a/.github/workflows/ci_integration_unftp_sbe.yml
b/.github/workflows/ci_integration_unftp_sbe.yml
index 51cfc5bb85..4b1b6ac8cb 100644
--- a/.github/workflows/ci_integration_unftp_sbe.yml
+++ b/.github/workflows/ci_integration_unftp_sbe.yml
@@ -52,6 +52,6 @@ jobs:
working-directory: integrations/unftp-sbe
run: cargo clippy --all-targets --all-features -- -D warnings
- - name: FTP loopback tests
+ - name: Cargo test
working-directory: integrations/unftp-sbe
- run: cargo test --test ftp_loopback
+ run: cargo test
diff --git a/integrations/unftp-sbe/Cargo.toml
b/integrations/unftp-sbe/Cargo.toml
index cf3695ba30..88824a9eef 100644
--- a/integrations/unftp-sbe/Cargo.toml
+++ b/integrations/unftp-sbe/Cargo.toml
@@ -28,6 +28,7 @@ version = "0.4.11"
[dependencies]
async-trait = "0.1.88"
+futures = "0.3"
opendal = { version = "0.59.5", path = "../../core" }
tokio = { version = "1.38.0", default-features = false, features = ["io-util"]
}
tokio-util = { version = "0.7.11", features = ["compat"] }
@@ -39,6 +40,7 @@ libunftp = "0.23.0"
opendal = { version = "0.59.5", path = "../../core", features = [
"services-fs",
"services-s3",
+ "services-cacache",
] }
suppaftp = { version = "10.0.2", default-features = false, features = [
"tokio",
diff --git a/integrations/unftp-sbe/src/lib.rs
b/integrations/unftp-sbe/src/lib.rs
index 297a01e13a..af9cacc15e 100644
--- a/integrations/unftp-sbe/src/lib.rs
+++ b/integrations/unftp-sbe/src/lib.rs
@@ -62,6 +62,7 @@ use opendal::Operator;
use unftp_core::auth::UserDetail;
use unftp_core::storage::{self, Error, StorageBackend};
+use futures::StreamExt;
use tokio::io::AsyncReadExt;
use tokio::io::AsyncWriteExt;
use tokio_util::compat::{FuturesAsyncReadCompatExt,
FuturesAsyncWriteCompatExt};
@@ -230,15 +231,42 @@ impl<User: UserDetail> StorageBackend<User> for
OpendalStorage {
_: &User,
mut input: R,
path: P,
- _: u64,
+ start_pos: u64,
) -> storage::Result<u64> {
- let mut w = self
- .op
- .writer(convert_path(path.as_ref())?)
- .await
- .map_err(convert_err)?
- .into_futures_async_write()
- .compat_write();
+ let path = convert_path(path.as_ref())?;
+
+ // libunftp sends nonzero `start_pos` for APPE, where it equals the
+ // current file size. Silently overwriting there would corrupt data,
+ // so writes at an offset require an append-capable backend and must
+ // land exactly at the end of the existing file.
+ let append = start_pos > 0;
+ if append {
+ if !self.op.info().capability().write_can_append {
+ return Err(Error::new(
+ storage::ErrorKind::CommandNotImplemented,
+ "the storage service does not support appending to an
existing file",
+ ));
+ }
+ match self.op.stat(path).await {
+ Ok(meta) if meta.content_length() == start_pos => {}
+ Ok(_) => {
+ return Err(Error::new(
+ storage::ErrorKind::PermanentFileNotAvailable,
+ format!("start position {start_pos} does not match the
size of {path}"),
+ ));
+ }
+ Err(err) => return Err(convert_err(err)),
+ }
+ }
+
+ let writer = if append {
+ self.op.writer_with(path).append(true).await
+ } else {
+ self.op.writer(path).await
+ }
+ .map_err(convert_err)?;
+
+ let mut w = writer.into_futures_async_write().compat_write();
// Avoid `tokio::io::copy`'s pending-read flush path and keep
buffering policy explicit.
let copy_result = copy_read_write_loop(&mut input, &mut w).await;
let shutdown_result = w.shutdown().await;
@@ -298,12 +326,56 @@ impl<User: UserDetail> StorageBackend<User> for
OpendalStorage {
async fn cwd<P: AsRef<Path> + Send + Debug>(&self, _: &User, path: P) ->
storage::Result<()> {
use opendal::ErrorKind::*;
- match self.op.stat(convert_path(path.as_ref())?).await {
- Ok(_) => Ok(()),
- Err(e) if matches!(e.kind(), NotFound | NotADirectory) =>
Err(Error::new(
+ // Object stores only address directories with a trailing `/`.
+ // Normalizing to root yields "/", which `trim_end_matches('/')`
+ // preserves.
+ let path = opendal::raw::normalize_path(convert_path(path.as_ref())?);
+ let directory = format!("{}/", path.trim_end_matches('/'));
+
+ // The FTP root always exists; some backends cannot stat it.
+ if directory == "/" {
+ return Ok(());
+ }
+
+ match self.op.stat(&directory).await {
+ Ok(meta) if meta.is_dir() => Ok(()),
+ Ok(_) => Err(Error::new(
storage::ErrorKind::PermanentDirectoryNotAvailable,
- e,
+ format!("{directory} is not a directory"),
)),
+ Err(e) if matches!(e.kind(), NotFound | NotADirectory |
Unsupported) => {
+ // Object stores can serve implicit prefix directories that
+ // have no directory entry of their own; probing needs the
+ // list capability. The probe only reads the first entry.
+ if !self.op.info().capability().list {
+ return Err(Error::new(
+ storage::ErrorKind::PermanentDirectoryNotAvailable,
+ e,
+ ));
+ }
+ match self.op.lister(&directory).await {
+ Ok(mut entries) => match entries.next().await {
+ Some(Ok(_)) => Ok(()),
+ Some(Err(e))
+ if matches!(e.kind(), NotFound | NotADirectory |
Unsupported) =>
+ {
+ Err(Error::new(
+
storage::ErrorKind::PermanentDirectoryNotAvailable,
+ e,
+ ))
+ }
+ Some(Err(e)) => Err(convert_err(e)),
+ None => Err(Error::new(
+ storage::ErrorKind::PermanentDirectoryNotAvailable,
+ e,
+ )),
+ },
+ Err(e) if matches!(e.kind(), NotFound | NotADirectory |
Unsupported) => Err(
+
Error::new(storage::ErrorKind::PermanentDirectoryNotAvailable, e),
+ ),
+ Err(e) => Err(convert_err(e)),
+ }
+ }
Err(e) => Err(convert_err(e)),
}
}
diff --git a/integrations/unftp-sbe/tests/ftp_loopback.rs
b/integrations/unftp-sbe/tests/ftp_loopback.rs
index c142d7abad..13b32d05fc 100644
--- a/integrations/unftp-sbe/tests/ftp_loopback.rs
+++ b/integrations/unftp-sbe/tests/ftp_loopback.rs
@@ -187,6 +187,38 @@ async fn utf8_directory_lifecycle() -> Result<()> {
.await
}
+#[tokio::test]
+async fn append_extends_existing_file() -> Result<()> {
+ with_ftp_client(async |ftp| {
+ let file = "append.bin";
+
+ ftp.put_file(file, &mut "abc".as_bytes())
+ .await
+ .context("STOR append.bin")?;
+ ftp.append_file(file, &mut "def".as_bytes())
+ .await
+ .context("APPE append.bin")?;
+ assert_eq!(retrieve(ftp, file).await?, b"abcdef");
+ Ok(())
+ })
+ .await
+}
+
+#[tokio::test]
+async fn cwd_rejects_regular_file() -> Result<()> {
+ with_ftp_client(async |ftp| {
+ let file = "file.bin";
+
+ ftp.put_file(file, &mut "abc".as_bytes())
+ .await
+ .context("STOR file.bin")?;
+ assert_reply(ftp.cwd(file).await, Status::FileUnavailable, "CWD
file.bin");
+ assert_eq!(ftp.pwd().await.context("PWD")?, "/");
+ Ok(())
+ })
+ .await
+}
+
#[tokio::test]
async fn restart_is_unsupported() -> Result<()> {
with_ftp_client(async |ftp| {
diff --git a/integrations/unftp-sbe/tests/storage_backend.rs
b/integrations/unftp-sbe/tests/storage_backend.rs
new file mode 100644
index 0000000000..5b4a324b04
--- /dev/null
+++ b/integrations/unftp-sbe/tests/storage_backend.rs
@@ -0,0 +1,428 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use std::sync::Arc;
+
+use anyhow::{Context, Result};
+use opendal::raw::{self, oio};
+use opendal::{OperationContext, Operator, services};
+use tempfile::TempDir;
+use unftp_core::auth::DefaultUser;
+use unftp_core::storage::{ErrorKind, StorageBackend};
+use unftp_sbe_opendal::OpendalStorage;
+
+/// Test layer that injects a fixed [`opendal::ErrorKind`] for `stat` calls on
+/// one path and can hide the `list` capability, emulating backends whose
+/// `stat` fails for reasons other than a missing path.
+#[derive(Debug)]
+struct StatErrorLayer {
+ injected_path: &'static str,
+ injected_kind: opendal::ErrorKind,
+ hide_list: bool,
+}
+
+impl raw::Layer for StatErrorLayer {
+ fn apply_service(&self, srv: raw::Servicer) -> raw::Servicer {
+ Arc::new(StatErrorService {
+ inner: srv,
+ injected_path: self.injected_path,
+ injected_kind: self.injected_kind,
+ hide_list: self.hide_list,
+ })
+ }
+}
+
+#[derive(Debug)]
+struct StatErrorService {
+ inner: raw::Servicer,
+ injected_path: &'static str,
+ injected_kind: opendal::ErrorKind,
+ hide_list: bool,
+}
+
+impl raw::Service for StatErrorService {
+ type Reader = oio::Reader;
+ type Writer = oio::Writer;
+ type Lister = oio::Lister;
+ type Deleter = oio::Deleter;
+ type Copier = oio::Copier;
+ type Composer = oio::Composer;
+
+ fn info(&self) -> raw::ServiceInfo {
+ self.inner.info()
+ }
+
+ fn capability(&self) -> opendal::Capability {
+ let mut capability = self.inner.capability();
+ capability.list &= !self.hide_list;
+ capability
+ }
+
+ async fn create_dir(
+ &self,
+ ctx: &OperationContext,
+ path: &str,
+ args: raw::OpCreateDir,
+ ) -> opendal::Result<raw::RpCreateDir> {
+ self.inner.create_dir(ctx, path, args).await
+ }
+
+ async fn stat(
+ &self,
+ ctx: &OperationContext,
+ path: &str,
+ args: raw::OpStat,
+ ) -> opendal::Result<raw::RpStat> {
+ if path == self.injected_path {
+ return Err(opendal::Error::new(
+ self.injected_kind,
+ "stat error injected by the test",
+ ));
+ }
+ self.inner.stat(ctx, path, args).await
+ }
+
+ fn read(
+ &self,
+ ctx: &OperationContext,
+ path: &str,
+ args: raw::OpRead,
+ ) -> opendal::Result<Self::Reader> {
+ self.inner.read(ctx, path, args)
+ }
+
+ fn write(
+ &self,
+ ctx: &OperationContext,
+ path: &str,
+ args: raw::OpWrite,
+ ) -> opendal::Result<Self::Writer> {
+ self.inner.write(ctx, path, args)
+ }
+
+ fn delete(&self, ctx: &OperationContext) -> opendal::Result<Self::Deleter>
{
+ self.inner.delete(ctx)
+ }
+
+ fn list(
+ &self,
+ ctx: &OperationContext,
+ path: &str,
+ args: raw::OpList,
+ ) -> opendal::Result<Self::Lister> {
+ self.inner.list(ctx, path, args)
+ }
+
+ fn copy(
+ &self,
+ ctx: &OperationContext,
+ from: &str,
+ to: &str,
+ args: raw::OpCopy,
+ ) -> opendal::Result<Self::Copier> {
+ self.inner.copy(ctx, from, to, args)
+ }
+
+ fn compose(
+ &self,
+ ctx: &OperationContext,
+ to: &str,
+ args: raw::OpCompose,
+ ) -> opendal::Result<Self::Composer> {
+ self.inner.compose(ctx, to, args)
+ }
+
+ async fn rename(
+ &self,
+ ctx: &OperationContext,
+ from: &str,
+ to: &str,
+ args: raw::OpRename,
+ ) -> opendal::Result<raw::RpRename> {
+ self.inner.rename(ctx, from, to, args).await
+ }
+
+ async fn restore(
+ &self,
+ ctx: &OperationContext,
+ path: &str,
+ args: raw::OpRestore,
+ ) -> opendal::Result<raw::RpRestore> {
+ self.inner.restore(ctx, path, args).await
+ }
+
+ async fn presign(
+ &self,
+ ctx: &OperationContext,
+ path: &str,
+ args: raw::OpPresign,
+ ) -> opendal::Result<raw::RpPresign> {
+ self.inner.presign(ctx, path, args).await
+ }
+}
+
+fn fs_storage() -> Result<(TempDir, OpendalStorage)> {
+ let root = tempfile::tempdir()?;
+ let fs =
services::Fs::default().root(root.path().to_str().context("non-UTF-8 test
root")?);
+ Ok((root, OpendalStorage::new(Operator::new(fs)?)))
+}
+
+async fn read_file(storage: &OpendalStorage, path: &str) -> Result<String> {
+ let mut reader = storage.get(&DefaultUser, path, 0).await.context("get")?;
+ let mut content = String::new();
+ tokio::io::AsyncReadExt::read_to_string(&mut reader, &mut content).await?;
+ Ok(content)
+}
+
+/// `start_pos == 0` stores the input verbatim, whether the file exists or not.
+#[tokio::test]
+async fn put_overwrites_at_start_position_zero() -> Result<()> {
+ let (_root, storage) = fs_storage()?;
+ let user = DefaultUser;
+
+ storage
+ .put(&user, "abc".as_bytes(), "file", 0)
+ .await
+ .context("put abc")?;
+ storage
+ .put(&user, "def".as_bytes(), "file", 0)
+ .await
+ .context("put def")?;
+
+ assert_eq!(read_file(&storage, "file").await?, "def");
+ Ok(())
+}
+
+/// `start_pos` equal to the current file size appends on an append-capable
+/// backend, which is how libunftp implements `APPE`.
+#[tokio::test]
+async fn put_appends_at_end_of_file() -> Result<()> {
+ let root = tempfile::tempdir()?;
+ let fs =
services::Fs::default().root(root.path().to_str().context("non-UTF-8 test
root")?);
+ let op = Operator::new(fs)?;
+ assert!(op.info().capability().write_can_append);
+ let storage = OpendalStorage::new(op);
+ let user = DefaultUser;
+
+ storage
+ .put(&user, "abc".as_bytes(), "file", 0)
+ .await
+ .context("put abc")?;
+ storage
+ .put(&user, "def".as_bytes(), "file", 3)
+ .await
+ .context("put def at start_pos 3")?;
+
+ assert_eq!(read_file(&storage, "file").await?, "abcdef");
+ Ok(())
+}
+
+/// A nonzero `start_pos` that does not match the file size must fail instead
+/// of overwriting the file.
+#[tokio::test]
+async fn put_rejects_offset_past_end_of_file() -> Result<()> {
+ let (_root, storage) = fs_storage()?;
+ let user = DefaultUser;
+
+ storage
+ .put(&user, "abc".as_bytes(), "file", 0)
+ .await
+ .context("put abc")?;
+
+ for start_pos in [1, 100] {
+ let err = storage
+ .put(&user, "def".as_bytes(), "file", start_pos)
+ .await
+ .expect_err("put with mismatched start_pos must fail");
+ assert_eq!(err.kind(), ErrorKind::PermanentFileNotAvailable);
+ assert_eq!(
+ read_file(&storage, "file").await?,
+ "abc",
+ "file must be preserved after rejected put at start_pos
{start_pos}"
+ );
+ }
+ Ok(())
+}
+
+/// Without `write_can_append` a nonzero `start_pos` is reported as
+/// unimplemented and leaves the file untouched.
+#[tokio::test]
+async fn put_rejects_offset_on_non_append_backend() -> Result<()> {
+ let op = Operator::new(services::Memory::default())?;
+ assert!(!op.info().capability().write_can_append);
+ let storage = OpendalStorage::new(op);
+ let user = DefaultUser;
+
+ storage
+ .put(&user, "abc".as_bytes(), "file", 0)
+ .await
+ .context("put abc")?;
+
+ let err = storage
+ .put(&user, "def".as_bytes(), "file", 3)
+ .await
+ .expect_err("put at start_pos 3 must fail on a non-append backend");
+ assert_eq!(err.kind(), ErrorKind::CommandNotImplemented);
+ assert_eq!(read_file(&storage, "file").await?, "abc");
+ Ok(())
+}
+
+#[tokio::test]
+async fn cwd_on_filesystem_backend() -> Result<()> {
+ let (_root, storage) = fs_storage()?;
+ let user = DefaultUser;
+
+ storage.cwd(&user, "/").await.context("cwd /")?;
+ storage.cwd(&user, "").await.context("cwd empty path")?;
+
+ storage.mkd(&user, "dir").await.context("mkd dir")?;
+ storage.cwd(&user, "dir").await.context("cwd dir")?;
+ storage.cwd(&user, "dir/").await.context("cwd dir/")?;
+
+ storage
+ .put(&user, "abc".as_bytes(), "file", 0)
+ .await
+ .context("put file")?;
+ let err = storage
+ .cwd(&user, "file")
+ .await
+ .expect_err("cwd file must fail");
+ assert_eq!(err.kind(), ErrorKind::PermanentDirectoryNotAvailable);
+
+ let err = storage
+ .cwd(&user, "nonexistent")
+ .await
+ .expect_err("cwd nonexistent must fail");
+ assert_eq!(err.kind(), ErrorKind::PermanentDirectoryNotAvailable);
+ Ok(())
+}
+
+/// Memory keeps no directory entries of its own, so a directory only exists
+/// implicitly through its children. `cwd` must still accept it while
+/// rejecting files and absent paths, like on object stores.
+#[tokio::test]
+async fn cwd_on_memory_backend() -> Result<()> {
+ let storage =
OpendalStorage::new(Operator::new(services::Memory::default())?);
+ let user = DefaultUser;
+
+ storage.cwd(&user, "/").await.context("cwd /")?;
+ storage.cwd(&user, "").await.context("cwd empty path")?;
+
+ storage
+ .put(&user, "abc".as_bytes(), "dir/file", 0)
+ .await
+ .context("put dir/file")?;
+ storage
+ .cwd(&user, "dir")
+ .await
+ .context("cwd into implicit dir")?;
+ storage
+ .cwd(&user, "dir/")
+ .await
+ .context("cwd into implicit dir/")?;
+
+ storage
+ .put(&user, "abc".as_bytes(), "file", 0)
+ .await
+ .context("put file")?;
+ let err = storage
+ .cwd(&user, "file")
+ .await
+ .expect_err("cwd file must fail");
+ assert_eq!(err.kind(), ErrorKind::PermanentDirectoryNotAvailable);
+
+ let err = storage
+ .cwd(&user, "nonexistent")
+ .await
+ .expect_err("cwd nonexistent must fail");
+ assert_eq!(err.kind(), ErrorKind::PermanentDirectoryNotAvailable);
+ Ok(())
+}
+
+/// `stat` failures that do not mean "missing path" must propagate their
+/// real error instead of being swallowed into
+/// `PermanentDirectoryNotAvailable`, on list-capable and list-less
+/// backends alike.
+#[tokio::test]
+async fn cwd_propagates_stat_errors() -> Result<()> {
+ let user = DefaultUser;
+
+ for hide_list in [false, true] {
+ for (injected_kind, expected_kind) in [
+ (
+ opendal::ErrorKind::PermissionDenied,
+ ErrorKind::PermissionDenied,
+ ),
+ (opendal::ErrorKind::Unexpected, ErrorKind::LocalError),
+ (
+ opendal::ErrorKind::NotFound,
+ ErrorKind::PermanentDirectoryNotAvailable,
+ ),
+ ] {
+ let op =
Operator::new(services::Memory::default())?.layer(StatErrorLayer {
+ injected_path: "forbidden/",
+ injected_kind,
+ hide_list,
+ });
+ let storage = OpendalStorage::new(op);
+
+ let err = storage
+ .cwd(&user, "forbidden")
+ .await
+ .expect_err("cwd forbidden must fail");
+ assert_eq!(
+ err.kind(),
+ expected_kind,
+ "hide_list={hide_list}, injected stat error: {injected_kind}"
+ );
+ }
+ }
+ Ok(())
+}
+
+/// Backends without the list capability cannot probe implicit prefix
+/// directories; `cwd` must still report `PermanentDirectoryNotAvailable`
+/// instead of leaking an internal `LocalError`.
+#[tokio::test]
+async fn cwd_on_backend_without_list_capability() -> Result<()> {
+ let root = tempfile::tempdir()?;
+ let cacache =
+
services::Cacache::default().datadir(root.path().to_str().context("non-UTF-8
test root")?);
+ let op = Operator::new(cacache)?;
+ assert!(!op.info().capability().list);
+ let storage = OpendalStorage::new(op);
+ let user = DefaultUser;
+
+ storage.cwd(&user, "/").await.context("cwd /")?;
+
+ storage
+ .put(&user, "abc".as_bytes(), "file", 0)
+ .await
+ .context("put file")?;
+ let err = storage
+ .cwd(&user, "file")
+ .await
+ .expect_err("cwd file must fail");
+ assert_eq!(err.kind(), ErrorKind::PermanentDirectoryNotAvailable);
+
+ let err = storage
+ .cwd(&user, "nonexistent")
+ .await
+ .expect_err("cwd nonexistent must fail");
+ assert_eq!(err.kind(), ErrorKind::PermanentDirectoryNotAvailable);
+ Ok(())
+}