From db0c32a1771e96afa5bd935cbeecc9351fa8dc37 Mon Sep 17 00:00:00 2001 From: Bin Tang Date: Mon, 24 Jul 2023 17:40:18 +0800 Subject: [PATCH] fs: add test for filling auth Signed-off-by: Bin Tang --- api/src/config.rs | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/api/src/config.rs b/api/src/config.rs index 2dff3d0b602..e606770ddc9 100644 --- a/api/src/config.rs +++ b/api/src/config.rs @@ -2134,4 +2134,48 @@ mod tests { assert_eq!(&config.id, "id1"); assert_eq!(config.backend.as_ref().unwrap().backend_type, "localfs"); } + + #[test] + fn test_update_registry_auth_info() { + let config = r#" + { + "device": { + "id": "test", + "backend": { + "type": "registry", + "config": { + "readahead": false, + "host": "docker.io", + "repo": "library/nginx", + "scheme": "https", + "proxy": { + "fallback": false + }, + "timeout": 5, + "connect_timeout": 5, + "retry_limit": 8 + } + } + }, + "mode": "direct", + "digest_validate": false, + "enable_xattr": true, + "fs_prefetch": { + "enable": true, + "threads_count": 10, + "merging_size": 131072, + "bandwidth_rate": 10485760 + } + }"#; + + let mut rafs_config = ConfigV2::from_str(&config).unwrap(); + let test_auth = "test_auth".to_string(); + + rafs_config.update_registry_auth_info(&Some(test_auth.clone())); + + let backend = rafs_config.backend.unwrap(); + let registry = backend.registry.unwrap(); + let auth = registry.auth.unwrap(); + assert_eq!(auth, test_auth); + } }