use android_tools::java_tools::{android_dir, Key, KeyAlgorithm, Keytool};
#[test]
fn test_create_keystore_with_keytool() {
let tempdir = tempfile::tempdir().unwrap();
let aab_build_dir = tempdir.path();
let user_dirs = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
let aab_path = user_dirs
.join("tests")
.join("resources")
.join("android_app_bundle")
.join("minimal_unsigned.aab");
let cloned_aab = aab_build_dir.join("minimal_unsigned.aab");
if aab_path.exists() {
std::fs::copy(&aab_path, &cloned_aab).unwrap();
}
let android_dir = android_dir().unwrap();
let target = vec![android_dir.join("aab.keystore")];
target.iter().for_each(|content| {
if content.is_file() {
std::fs::remove_file(&content).unwrap();
}
});
let key = Key::new_default().unwrap();
Keytool::new()
.genkeypair(true)
.v(true)
.keystore(&key.key_path)
.alias(&key.key_alias)
.keypass(&key.key_pass)
.storepass(&key.key_pass)
.dname(&["CN=Android Debug,O=Android,C=US".to_owned()])
.keyalg(KeyAlgorithm::RSA)
.keysize(2048)
.validity(10000)
.run()
.unwrap();
}