Skip to content

Commit d64b31e

Browse files
committed
test: add admin commands integration tests and fix RustFS compatibility
- Add integration test script (scripts/test-admin.sh) for admin commands - Add test IAM policy file (scripts/policies/readonly-policy.json) - Fix admin API URL path from /minio/admin/v3 to /rustfs/admin/v3 - Add status field to CreateUserRequest for RustFS compatibility - Update docker-compose.yml for RustFS 1.0.0-alpha.81: - Use specific image version - Fix healthcheck endpoint to /health - Add RUSTFS_ACCESS_KEY and RUSTFS_SECRET_KEY env vars
1 parent 3e9cebe commit d64b31e

4 files changed

Lines changed: 732 additions & 11 deletions

File tree

crates/s3/src/admin.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl AdminClient {
4949

5050
/// Build the base URL for admin API
5151
fn admin_url(&self, path: &str) -> String {
52-
format!("{}/minio/admin/v3{}", self.endpoint, path)
52+
format!("{}/rustfs/admin/v3{}", self.endpoint, path)
5353
}
5454

5555
/// Calculate SHA256 hash of the body
@@ -305,6 +305,7 @@ struct PolicyListResponse(HashMap<String, serde_json::Value>);
305305
#[serde(rename_all = "camelCase")]
306306
struct CreateUserRequest {
307307
secret_key: String,
308+
status: String,
308309
}
309310

310311
/// Request body for creating a group
@@ -389,6 +390,7 @@ impl AdminApi for AdminClient {
389390
let query = [("accessKey", access_key)];
390391
let body = serde_json::to_vec(&CreateUserRequest {
391392
secret_key: secret_key.to_string(),
393+
status: "enabled".to_string(),
392394
})
393395
.map_err(Error::Json)?;
394396

@@ -638,7 +640,7 @@ mod tests {
638640

639641
assert_eq!(
640642
client.admin_url("/list-users"),
641-
"http://localhost:9000/minio/admin/v3/list-users"
643+
"http://localhost:9000/rustfs/admin/v3/list-users"
642644
);
643645
}
644646

@@ -649,7 +651,7 @@ mod tests {
649651

650652
assert_eq!(
651653
client.admin_url("/list-users"),
652-
"http://localhost:9000/minio/admin/v3/list-users"
654+
"http://localhost:9000/rustfs/admin/v3/list-users"
653655
);
654656
}
655657

docker/docker-compose.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,24 @@
77
services:
88
# RustFS - S3-compatible object storage (Tier 1)
99
rustfs:
10-
image: rustfs/rustfs:1.0.0-alpha.80
11-
container_name: rustfs
10+
image: rustfs/rustfs:1.0.0-alpha.81
11+
container_name: rc-test-rustfs
1212
ports:
1313
- "9000:9000" # S3 API
1414
- "9001:9001" # Console
1515
environment:
16-
RUSTFS_ROOT_USER: rustfsadmin
17-
RUSTFS_ROOT_PASSWORD: rustfsadmin
16+
RUSTFS_ROOT_USER: accesskey
17+
RUSTFS_ROOT_PASSWORD: secretkey
18+
RUSTFS_ACCESS_KEY: accesskey
19+
RUSTFS_SECRET_KEY: secretkey
1820
RUSTFS_VOLUMES: /data
1921
RUSTFS_ADDRESS: ":9000"
2022
RUSTFS_CONSOLE_ENABLE: "true"
2123
RUSTFS_CONSOLE_ADDRESS: ":9001"
2224
volumes:
2325
- rustfs-data:/data
2426
healthcheck:
25-
test: ["CMD", "curl", "-sf", "http://127.0.0.1:9000/health"]
27+
test: ["CMD", "curl", "-sf", "http://localhost:9000/health"]
2628
interval: 10s
2729
timeout: 5s
2830
retries: 5
@@ -33,12 +35,13 @@ services:
3335
# Initialize RustFS - create test buckets using mc client
3436
rustfs-init:
3537
image: rustfs/rc:latest
36-
container_name: rc-init
38+
container_name: rc-test-rustfs-init
3739
depends_on:
38-
- rustfs
40+
rustfs:
41+
condition: service_healthy
3942
entrypoint: >
4043
/bin/sh -c "
41-
until (/usr/bin/rc alias set rustfs http://rustfs:9000 rustfsadmin rustfsadmin) do echo '...waiting...' && sleep 1; done;
44+
until (/usr/bin/rc alias set rustfs http://rustfs:9000 accesskey secretkey) do echo '...waiting...' && sleep 1; done;
4245
/usr/bin/rc mb rustfs/test-bucket;
4346
/usr/bin/rc mb rustfs/another-bucket;
4447
echo 'RustFS initialization complete';
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"Version": "2012-10-17",
3+
"Statement": [
4+
{
5+
"Effect": "Allow",
6+
"Action": ["s3:GetObject", "s3:ListBucket"],
7+
"Resource": ["arn:aws:s3:::*"]
8+
}
9+
]
10+
}

0 commit comments

Comments
 (0)