Skip to content
Snippets Groups Projects
vault.rs 31.2 KiB
Newer Older
			"bottom drive obey lake curtain smoke basket hold race lonely fit walk//Alice"
		),
		String::from("bottom drive obey lake curtain smoke basket hold race lonely fit walk"),
		Some(String::from("//Alice"))
	)]
	#[case(
		String::from("bottom drive obey lake curtain smoke basket hold race lonely fit walk"),
		String::from("bottom drive obey lake curtain smoke basket hold race lonely fit walk"),
		None
	)]
	#[case(
		String::from("0xfac7959dbfe72f052e5a0c3c8d6530f202b02fd8f9f5ca3580ec8deb7797479e"),
		String::from("0xfac7959dbfe72f052e5a0c3c8d6530f202b02fd8f9f5ca3580ec8deb7797479e"),
		None
	)]
	#[case(
		String::from("fac7959dbfe72f052e5a0c3c8d6530f202b02fd8f9f5ca3580ec8deb7797479e"),
		String::from("fac7959dbfe72f052e5a0c3c8d6530f202b02fd8f9f5ca3580ec8deb7797479e"),
		None
	)]
	#[case(
		String::from("someVaultName//Alice"),
		String::from("someVaultName"),
		Some(String::from("//Alice"))
	)]
	#[case(String::from("someVaultName"), String::from("someVaultName"), None)]
	fn test_parse_prefix_and_derivation_path_from_string(
		#[case] raw_string: String,
		#[case] expected_prefix: String,
		#[case] expected_derivation_path: Option<String>,
	) {
		let (root_secret, derivation_path) =
			parse_prefix_and_derivation_path_from_string(raw_string).unwrap();
		assert_eq!(expected_prefix, root_secret);
		assert_eq!(expected_derivation_path, derivation_path);
	}