/extensions/ssh/jsch/src/test/java/org/jclouds/ssh/jsch/config/JschSshClientModuleTest.java
Java | 54 lines | 24 code | 7 blank | 23 comment | 2 complexity | f4446a5be8b3a3a14af2dc12509947b7 MD5 | raw file
- /**
- *
- * Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
- *
- * ====================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ====================================================================
- */
- package org.jclouds.ssh.jsch.config;
- import static org.testng.Assert.assertEquals;
- import java.net.UnknownHostException;
- import java.util.Map;
- import org.jclouds.net.IPSocket;
- import org.jclouds.ssh.SshClient;
- import org.jclouds.ssh.jsch.JschSshClient;
- import org.testng.annotations.Test;
- import com.google.inject.Guice;
- import com.google.inject.Injector;
- /**
- * Tests the ability to configure a {@link JschSshClient}
- *
- * @author Adrian Cole
- */
- @Test
- public class JschSshClientModuleTest {
- public void testConfigureBindsClient() throws UnknownHostException {
- Injector i = Guice.createInjector(new JschSshClientModule());
- SshClient.Factory factory = i.getInstance(SshClient.Factory.class);
- SshClient connection = factory.create(new IPSocket("localhost", 22), "username", "password");
- assert connection instanceof JschSshClient;
- Map<String, String> keyPair = factory.generateRSAKeyPair("comment", "hola");
- assertEquals(keyPair.get("comment"), "comment");
- assertEquals(keyPair.get("passphrase"), "hola");
- assert keyPair.get("private").indexOf("-----BEGIN RSA PRIVATE KEY-----") == 0 : keyPair;
- assert keyPair.get("public").indexOf("ssh-rsa ") == 0 : keyPair;
- }
- }