mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-09-20 06:54:16 +00:00
dealing with deprecation
This commit is contained in:
@@ -13,6 +13,7 @@ import org.junit.jupiter.api.Test;
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.property.ReadOnlyBooleanProperty;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
import java.time.Duration;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
@@ -23,7 +24,7 @@ public class KeychainManagerTest {
|
||||
@Test
|
||||
public void testStoreAndLoad() throws KeychainAccessException {
|
||||
KeychainManager keychainManager = new KeychainManager(new SimpleObjectProperty<>(new MapKeychainAccess()));
|
||||
keychainManager.storePassphrase("test", "asd");
|
||||
keychainManager.storePassphrase("test", "Test", "asd");
|
||||
Assertions.assertArrayEquals("asd".toCharArray(), keychainManager.loadPassphrase("test"));
|
||||
}
|
||||
|
||||
@@ -42,7 +43,7 @@ public class KeychainManagerTest {
|
||||
public void testPropertyChangesWhenStoringPassword() throws KeychainAccessException, InterruptedException {
|
||||
KeychainManager keychainManager = new KeychainManager(new SimpleObjectProperty<>(new MapKeychainAccess()));
|
||||
ReadOnlyBooleanProperty property = keychainManager.getPassphraseStoredProperty("test");
|
||||
Assertions.assertEquals(false, property.get());
|
||||
Assertions.assertFalse(property.get());
|
||||
|
||||
keychainManager.storePassphrase("test", "bar");
|
||||
|
||||
@@ -52,8 +53,8 @@ public class KeychainManagerTest {
|
||||
result.set(property.get());
|
||||
latch.countDown();
|
||||
});
|
||||
latch.await(1, TimeUnit.SECONDS);
|
||||
Assertions.assertEquals(true, result.get());
|
||||
Assertions.assertTimeoutPreemptively(Duration.ofSeconds(1), () -> latch.await());
|
||||
Assertions.assertTrue(result.get());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
*******************************************************************************/
|
||||
package org.cryptomator.common.keychain;
|
||||
|
||||
import org.cryptomator.integrations.keychain.KeychainAccessException;
|
||||
import org.cryptomator.integrations.keychain.KeychainAccessProvider;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -20,7 +21,13 @@ class MapKeychainAccess implements KeychainAccessProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void storePassphrase(String key, CharSequence passphrase) {
|
||||
throw new NoSuchMethodError("not implemented");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void storePassphrase(String key, String displayName,CharSequence passphrase) {
|
||||
char[] pw = new char[passphrase.length()];
|
||||
for (int i = 0; i < passphrase.length(); i++) {
|
||||
pw[i] = passphrase.charAt(i);
|
||||
@@ -39,7 +46,13 @@ class MapKeychainAccess implements KeychainAccessProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changePassphrase(String key, CharSequence passphrase) {
|
||||
@Deprecated
|
||||
public void changePassphrase(String key, CharSequence passphrase) throws KeychainAccessException {
|
||||
throw new NoSuchMethodError("not implemented");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changePassphrase(String key, String displayName, CharSequence passphrase) {
|
||||
map.get(key);
|
||||
storePassphrase(key, passphrase);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user