|
14 | 14 | import ch.cyberduck.core.vault.VaultRegistryFactory; |
15 | 15 | import ch.cyberduck.test.VaultTest; |
16 | 16 |
|
17 | | -import org.jetbrains.annotations.NotNull; |
18 | 17 | import org.junit.jupiter.api.BeforeEach; |
19 | 18 | import org.junit.jupiter.api.Named; |
20 | 19 | import org.junit.jupiter.params.provider.Arguments; |
|
28 | 27 | import java.util.function.Function; |
29 | 28 |
|
30 | 29 | import cloud.katta.core.DeviceSetupCallback; |
31 | | -import cloud.katta.core.util.MockableDeviceSetupCallback; |
32 | 30 | import cloud.katta.model.AccountKeyAndDeviceName; |
33 | 31 | import cloud.katta.protocols.hub.HubProtocol; |
34 | 32 | import cloud.katta.protocols.hub.HubSession; |
@@ -152,7 +150,6 @@ protected void configureLogging(final String level) { |
152 | 150 | preferences.setProperty("factory.vault.class", HubUVFVault.class.getName()); |
153 | 151 | preferences.setProperty("factory.supportdirectoryfinder.class", ch.cyberduck.core.preferences.TemporarySupportDirectoryFinder.class.getName()); |
154 | 152 | preferences.setProperty("factory.passwordstore.class", UnsecureHostPasswordStore.class.getName()); |
155 | | - preferences.setProperty("factory.devicesetupcallback.class", MockableDeviceSetupCallback.class.getName()); |
156 | 153 | preferences.setProperty("factory.vaultregistry.class", HubVaultRegistry.class.getName()); |
157 | 154 |
|
158 | 155 | preferences.setProperty("oauth.handler.scheme", "katta"); |
@@ -191,19 +188,29 @@ protected static HubSession setupConnection(final HubTestConfig.Setup setup) thr |
191 | 188 | assertTrue(factory.forName("s3").isEnabled()); |
192 | 189 | assertTrue(factory.forType(Protocol.Type.s3).isEnabled()); |
193 | 190 |
|
194 | | - final DeviceSetupCallback proxy = deviceSetupCallback(setup); |
195 | | - MockableDeviceSetupCallback.setProxy(proxy); |
196 | | - |
197 | 191 | final Host hub = new HostParser(factory).get(setup.hubURL).withCredentials(new Credentials(setup.userConfig.username, setup.userConfig.password)); |
198 | 192 | final HubSession session = (HubSession) SessionFactory.create(hub, new DefaultX509TrustManager(), new DefaultX509KeyManager()) |
199 | 193 | .withRegistry(VaultRegistryFactory.get(new DisabledPasswordCallback())); |
200 | | - final LoginConnectionService login = new LoginConnectionService(new DisabledLoginCallback(), new DisabledHostKeyCallback(), |
| 194 | + final LoginConnectionService login = new LoginConnectionService(loginCallback(setup), new DisabledHostKeyCallback(), |
201 | 195 | PasswordStoreFactory.get(), new DisabledProgressListener()); |
202 | 196 | login.check(session, new DisabledCancelCallback()); |
203 | 197 | return session; |
204 | 198 | } |
205 | 199 |
|
206 | | - protected static @NotNull DeviceSetupCallback deviceSetupCallback(HubTestConfig.Setup setup) { |
| 200 | + protected static LoginCallback loginCallback(HubTestConfig.Setup setup) { |
| 201 | + return new DisabledLoginCallback() { |
| 202 | + @SuppressWarnings("unchecked") |
| 203 | + @Override |
| 204 | + public <T> T getFeature(final Class<T> type) { |
| 205 | + if(DeviceSetupCallback.class == type) { |
| 206 | + return (T) deviceSetupCallback(setup); |
| 207 | + } |
| 208 | + return null; |
| 209 | + } |
| 210 | + }; |
| 211 | + } |
| 212 | + |
| 213 | + protected static DeviceSetupCallback deviceSetupCallback(HubTestConfig.Setup setup) { |
207 | 214 | return new DeviceSetupCallback() { |
208 | 215 | @Override |
209 | 216 | public AccountKeyAndDeviceName displayAccountKeyAndAskDeviceName(final Host bookmark, final AccountKeyAndDeviceName accountKeyAndDeviceName) { |
|
0 commit comments