Skip to content

Commit 570f596

Browse files
Merge branch 'develop' into release/1.1.0
2 parents 96cfe06 + 1ee3e20 commit 570f596

File tree

2 files changed

+36
-8
lines changed

2 files changed

+36
-8
lines changed

src/main/java/org/cryptomator/integrations/keychain/KeychainAccessProvider.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ static Stream<KeychainAccessProvider> get() {
4040
*/
4141
@Deprecated
4242
@ApiStatus.ScheduledForRemoval(inVersion = "1.2.0")
43-
void storePassphrase(String key, CharSequence passphrase) throws KeychainAccessException;
43+
default void storePassphrase(String key, CharSequence passphrase) throws KeychainAccessException {
44+
storePassphrase(key, null, passphrase);
45+
}
4446

4547
/**
4648
* Associates a passphrase with a given key and a name for that key.
@@ -53,9 +55,7 @@ static Stream<KeychainAccessProvider> get() {
5355
* @throws KeychainAccessException If storing the password failed
5456
*/
5557
@Blocking
56-
default void storePassphrase(String key, String displayName, CharSequence passphrase) throws KeychainAccessException {
57-
storePassphrase(key, passphrase);
58-
}
58+
void storePassphrase(String key, String displayName, CharSequence passphrase) throws KeychainAccessException;
5959

6060
/**
6161
* @param key Unique key previously used while {@link #storePassphrase(String, String, CharSequence)} storing a passphrase}.
@@ -83,7 +83,9 @@ default void storePassphrase(String key, String displayName, CharSequence passph
8383
*/
8484
@Deprecated
8585
@ApiStatus.ScheduledForRemoval(inVersion = "1.2.0")
86-
void changePassphrase(String key, CharSequence passphrase) throws KeychainAccessException;
86+
default void changePassphrase(String key, CharSequence passphrase) throws KeychainAccessException {
87+
changePassphrase(key, null, passphrase);
88+
}
8789

8890
/**
8991
* Updates a passphrase with a given key and stores a name for that key. Noop, if there is no item for the given key.
@@ -96,9 +98,7 @@ default void storePassphrase(String key, String displayName, CharSequence passph
9698
* @throws KeychainAccessException If changing the password failed
9799
*/
98100
@Blocking
99-
default void changePassphrase(String key, String displayName, CharSequence passphrase) throws KeychainAccessException {
100-
changePassphrase(key, passphrase);
101-
}
101+
void changePassphrase(String key, String displayName, CharSequence passphrase) throws KeychainAccessException;
102102

103103
/**
104104
* @return <code>true</code> if this KeychainAccessIntegration works on the current machine.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package org.cryptomator.integrations.keychain;
2+
3+
import org.junit.jupiter.api.Test;
4+
import org.mockito.Mockito;
5+
6+
public class KeychainAccessProviderTest {
7+
8+
@Test
9+
public void testStorePassphrase() throws KeychainAccessException {
10+
var provider = Mockito.mock(KeychainAccessProvider.class);
11+
Mockito.doCallRealMethod().when(provider).storePassphrase(Mockito.anyString(), Mockito.anyString());
12+
13+
provider.storePassphrase("key", "pass");
14+
15+
Mockito.verify(provider).storePassphrase("key", null, "pass");
16+
}
17+
18+
@Test
19+
public void testChangePassphrase() throws KeychainAccessException {
20+
var provider = Mockito.mock(KeychainAccessProvider.class);
21+
Mockito.doCallRealMethod().when(provider).changePassphrase(Mockito.anyString(), Mockito.anyString());
22+
23+
provider.changePassphrase("key", "pass");
24+
25+
Mockito.verify(provider).changePassphrase("key", null, "pass");
26+
}
27+
28+
}

0 commit comments

Comments
 (0)