Skip to content

Commit b4cfe4d

Browse files
gnome/internal: Fully test password change
1 parent 39d52ab commit b4cfe4d

1 file changed

Lines changed: 34 additions & 2 deletions

File tree

server/src/gnome/internal.rs

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,8 @@ mod tests {
393393
#[tokio::test]
394394
async fn test_change_with_prompt() -> Result<(), Box<dyn std::error::Error>> {
395395
let setup = TestServiceSetup::encrypted_session(true).await?;
396+
setup.set_password_accept(true).await;
397+
396398
let internal_proxy = InternalInterfaceProxyProxy::builder(&setup.client_conn)
397399
.build()
398400
.await?;
@@ -412,8 +414,38 @@ mod tests {
412414
"Prompt path should not be empty"
413415
);
414416

415-
// Verify the prompt exists and is accessible via D-Bus
416-
let _prompt_proxy = dbus::api::Prompt::new(&setup.client_conn, prompt_path).await?;
417+
// Get the prompt and complete it
418+
let prompt_proxy = dbus::api::Prompt::new(&setup.client_conn, prompt_path)
419+
.await?
420+
.unwrap();
421+
let new_password = Secret::text("new-password-from-prompt");
422+
setup.set_password_queue(vec![new_password.clone()]).await;
423+
424+
prompt_proxy.prompt(None).await?;
425+
426+
// Wait for prompt to complete
427+
tokio::time::sleep(tokio::time::Duration::from_millis(100)).await;
428+
429+
// Verify the password was changed by locking and unlocking with new password
430+
setup
431+
.service_api
432+
.lock(&[collection_path.clone()], None)
433+
.await?;
434+
assert!(
435+
default_collection.is_locked().await?,
436+
"Collection should be locked"
437+
);
438+
439+
// Unlock with new password via D-Bus
440+
let unlock_dbus = setup.create_dbus_secret(new_password)?;
441+
internal_proxy
442+
.unlock_with_master_password(&collection_path.as_ref(), unlock_dbus.into())
443+
.await?;
444+
445+
assert!(
446+
!default_collection.is_locked().await?,
447+
"Collection should be unlocked with new password"
448+
);
417449

418450
Ok(())
419451
}

0 commit comments

Comments
 (0)