Skip to content

Commit

Permalink
Add tests for new CLI arguments
Browse files Browse the repository at this point in the history
This commit extends CLI test suite to validate new CLI arguments.

Signed-off-by: Mark Kirichenko <[email protected]>
  • Loading branch information
atanzu committed Jan 22, 2025
1 parent 6224df1 commit 0d405e8
Showing 1 changed file with 128 additions and 0 deletions.
128 changes: 128 additions & 0 deletions tests/test_nitro_cli_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,134 @@ mod test_nitro_cli_args {
assert!(app.try_get_matches_from(args).is_ok())
}

#[test]
fn build_signed_enclave_correct_command_kms_key() {
let app = create_app!();
let args = vec![
"nitro cli",
"build-enclave",
"--docker-uri",
"dkr.ecr.us-east-1.amazonaws.com/stronghold-develss",
"--docker-dir",
"dir/",
"--output-file",
"image.eif",
"--signing-certificate",
"cert.pem",
"--kms-key-id",
"key_id",
];

assert!(app.try_get_matches_from(args).is_ok())
}

#[test]
fn build_signed_enclave_correct_command_kms_key_and_region() {
let app = create_app!();
let args = vec![
"nitro cli",
"build-enclave",
"--docker-uri",
"dkr.ecr.us-east-1.amazonaws.com/stronghold-develss",
"--docker-dir",
"dir/",
"--output-file",
"image.eif",
"--signing-certificate",
"cert.pem",
"--kms-key-id",
"key_id",
"--kms-key-region",
"us-east-1",
];

assert!(app.try_get_matches_from(args).is_ok())
}

#[test]
fn build_signed_enclave_no_key_and_kms_region() {
let app = create_app!();
let args = vec![
"nitro cli",
"build-enclave",
"--docker-uri",
"dkr.ecr.us-east-1.amazonaws.com/stronghold-develss",
"--docker-dir",
"dir/",
"--output-file",
"image.eif",
"--signing-certificate",
"cert.pem",
"--kms-key-region",
"us-east-1",
];

assert!(app.try_get_matches_from(args).is_err())
}

#[test]
fn build_signed_enclave_missing_certificate() {
let app = create_app!();
let args = vec![
"nitro cli",
"build-enclave",
"--docker-uri",
"dkr.ecr.us-east-1.amazonaws.com/stronghold-develss",
"--docker-dir",
"dir/",
"--output-file",
"image.eif",
"--private-key",
"key.pem",
];

assert!(app.try_get_matches_from(args).is_err())
}

#[test]
fn build_signed_enclave_both_local_and_kms_key() {
let app = create_app!();
let args = vec![
"nitro cli",
"build-enclave",
"--docker-uri",
"dkr.ecr.us-east-1.amazonaws.com/stronghold-develss",
"--docker-dir",
"dir/",
"--output-file",
"image.eif",
"--signing-certificate",
"cert.pem",
"--private-key",
"key.pem",
"--kms-key-id",
"key_id",
];

assert!(app.try_get_matches_from(args).is_err())
}

#[test]
fn build_signed_enclave_both_local_and_kms_key_missing_certificate() {
let app = create_app!();
let args = vec![
"nitro cli",
"build-enclave",
"--docker-uri",
"dkr.ecr.us-east-1.amazonaws.com/stronghold-develss",
"--docker-dir",
"dir/",
"--output-file",
"image.eif",
"--private-key",
"key.pem",
"--kms-key-id",
"key_id",
];

assert!(app.try_get_matches_from(args).is_err())
}

#[test]
fn build_enclave_with_metadata_correct_command() {
let app = create_app!();
Expand Down

0 comments on commit 0d405e8

Please sign in to comment.