use crate::integration::utils::{assert_output_contains, assert_success, CliTest};
use tempfile::NamedTempFile;
#[test]
fn test_fs_endpoints_list() {
let cli = CliTest::new();
let output = cli.run(&["fs", "endpoints", "list", "--network", "mainnet"]);
assert_success(&output);
assert_output_contains(&output, "NeoFS endpoints for mainnet network:");
let output = cli.run(&["fs", "endpoints", "list", "--network", "testnet"]);
assert_success(&output);
assert_output_contains(&output, "NeoFS endpoints for testnet network:");
}
#[test]
fn test_fs_status_no_wallet() {
let cli = CliTest::new();
let output = cli.run(&["fs", "status"]);
assert!(output.status.code().unwrap_or(127) != 127, "Command not found");
}
#[test]
fn test_fs_endpoints_test() {
let cli = CliTest::new();
let output = cli.run(&[
"fs",
"endpoints",
"test",
"--endpoint",
"https://http.mainnet.fs.neo.org",
"--type",
"http",
]);
assert!(output.status.code().unwrap_or(127) != 127, "Command not found");
let output = cli.run(&["fs", "endpoints", "test", "--network", "mainnet"]);
assert!(output.status.code().unwrap_or(127) != 127, "Command not found");
}
#[test]
fn test_fs_container_operations() {
let cli = CliTest::new();
let wallet_path = cli.create_temp_file(
r#"{
"name": "test_wallet",
"version": "1.0",
"scrypt": {"n": 16384, "r": 8, "p": 8},
"accounts": [
{
"address": "NZKvXidwBhnV8rNXh2eXtpm5bH1rkofaDz",
"label": "test_account",
"isDefault": true,
"lock": false,
"key": "6PYXHjPaNvW8YknSXaKzL1Xoxw4RjmQwCryMGEZ2GaLhGH8AdazLJPBBXw",
"contract": {
"script": "DCECIgZYieFCd+WHwCJK/I8btx1lYRIzOz8I8ZB6Ll6G3IIRLUFAQQ==",
"parameters": [{"name": "signature", "type": "Signature"}]
}
}
]
}"#,
);
let container_config = cli.create_temp_file(
r#"{
"name": "test-container",
"basic_acl": 644,
"placement_policy": "REP 3",
"attributes": [
{"key": "CreatedBy", "value": "NeoRust CLI"},
{"key": "Description", "value": "Test container"}
]
}"#,
);
let output = cli.run(&[
"fs",
"container",
"create",
"--config",
container_config.to_str().unwrap(),
"--wallet",
wallet_path.to_str().unwrap(),
"--password",
"test123",
]);
assert!(output.status.code().unwrap_or(127) != 127, "Command not found");
}
#[test]
fn test_fs_object_operations() {
let cli = CliTest::new();
let wallet_path = cli.create_temp_file(
r#"{
"name": "test_wallet",
"version": "1.0",
"scrypt": {"n": 16384, "r": 8, "p": 8},
"accounts": [
{
"address": "NZKvXidwBhnV8rNXh2eXtpm5bH1rkofaDz",
"label": "test_account",
"isDefault": true,
"lock": false,
"key": "6PYXHjPaNvW8YknSXaKzL1Xoxw4RjmQwCryMGEZ2GaLhGH8AdazLJPBBXw",
"contract": {
"script": "DCECIgZYieFCd+WHwCJK/I8btx1lYRIzOz8I8ZB6Ll6G3IIRLUFAQQ==",
"parameters": [{"name": "signature", "type": "Signature"}]
}
}
]
}"#,
);
let mut temp_file = NamedTempFile::new().unwrap();
std::io::Write::write_all(&mut temp_file, b"This is test content for NeoFS").unwrap();
let file_path = temp_file.path();
let output = cli.run(&[
"fs",
"object",
"put",
"--container",
"testhash",
"--file",
file_path.to_str().unwrap(),
"--wallet",
wallet_path.to_str().unwrap(),
"--password",
"test123",
]);
assert!(output.status.code().unwrap_or(127) != 127, "Command not found");
}
#[test]
fn test_fs_acl_operations() {
let cli = CliTest::new();
let wallet_path = cli.create_temp_file(
r#"{
"name": "test_wallet",
"version": "1.0",
"scrypt": {"n": 16384, "r": 8, "p": 8},
"accounts": [
{
"address": "NZKvXidwBhnV8rNXh2eXtpm5bH1rkofaDz",
"label": "test_account",
"isDefault": true,
"lock": false,
"key": "6PYXHjPaNvW8YknSXaKzL1Xoxw4RjmQwCryMGEZ2GaLhGH8AdazLJPBBXw",
"contract": {
"script": "DCECIgZYieFCd+WHwCJK/I8btx1lYRIzOz8I8ZB6Ll6G3IIRLUFAQQ==",
"parameters": [{"name": "signature", "type": "Signature"}]
}
}
]
}"#,
);
let output = cli.run(&[
"fs",
"acl",
"set",
"--container",
"testhash",
"--basic",
"644",
"--wallet",
wallet_path.to_str().unwrap(),
"--password",
"test123",
]);
assert!(output.status.code().unwrap_or(127) != 127, "Command not found");
}