Skip to content

Commit

Permalink
Try different Test structer
Browse files Browse the repository at this point in the history
  • Loading branch information
rexhoffman committed Sep 25, 2023
1 parent fcb06de commit e91dd6c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ public class FreedesktopKeyringBackend implements KeyringBackend {
public FreedesktopKeyringBackend() throws BackendNotSupportedException {
try {
collection = new SimpleCollection();
if (!collection.isConnected()) {
throw new BackendNotSupportedException("Error connecting to dbus");
}
} catch (IOException ex) {
throw new BackendNotSupportedException("Error connecting to dbus", ex);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ public SimpleCollection() throws IOException {
unlock();
}

public boolean isConnected() {
return this.session.getConnection().isConnected();
}

/*
* A user specified collection.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
package com.github.javakeyring.kde;

import com.github.javakeyring.BackendNotSupportedException;
import com.github.javakeyring.Keyring;
import com.github.javakeyring.KeyringStorageType;
import com.github.javakeyring.PasswordAccessException;
import com.github.javakeyring.internal.KeyringBackend;
import com.github.javakeyring.internal.freedesktop.FreedesktopKeyringBackend;
Expand Down Expand Up @@ -64,7 +62,12 @@ public void testSetup() throws Exception {
*/
@Test
public void testPasswordFlow() throws Exception {
assumeTrue(Platform.isLinux() && Keyring.create().getKeyringStorageType() == KeyringStorageType.KWALLET);
assumeTrue(Platform.isLinux());
//try (KeyringBackend be = new FreedesktopKeyringBackend()) {
// fail("Should throw a BackendNotSupportedException");
//} catch (BackendNotSupportedException ex) {
// assumeTrue(ex != null);
//}
KeyringBackend backend = new KWalletBackend();
catchThrowable(() -> backend.deletePassword(SERVICE, ACCOUNT));
checkExistenceOfPasswordEntry(backend);
Expand Down

0 comments on commit e91dd6c

Please sign in to comment.