[jbosstools-commits] JBoss Tools SVN: r41605 - trunk/openshift/tests/org.jboss.tools.openshift.express.test/src/org/jboss/tools/openshift/express/test.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Thu May 31 19:26:49 EDT 2012


Author: adietish
Date: 2012-05-31 19:26:48 -0400 (Thu, 31 May 2012)
New Revision: 41605

Added:
   trunk/openshift/tests/org.jboss.tools.openshift.express.test/src/org/jboss/tools/openshift/express/test/SSHUserConfigTest.java
Modified:
   trunk/openshift/tests/org.jboss.tools.openshift.express.test/src/org/jboss/tools/openshift/express/test/OpenShiftTestSuite.java
Log:
[JBIDE-12031] now allowing keys id_rsa or libra_id_rsa (depending on the user to have a <home>/.ssh/config with libra-keys or not)

Modified: trunk/openshift/tests/org.jboss.tools.openshift.express.test/src/org/jboss/tools/openshift/express/test/OpenShiftTestSuite.java
===================================================================
--- trunk/openshift/tests/org.jboss.tools.openshift.express.test/src/org/jboss/tools/openshift/express/test/OpenShiftTestSuite.java	2012-05-31 23:24:34 UTC (rev 41604)
+++ trunk/openshift/tests/org.jboss.tools.openshift.express.test/src/org/jboss/tools/openshift/express/test/OpenShiftTestSuite.java	2012-05-31 23:26:48 UTC (rev 41605)
@@ -17,7 +17,8 @@
 @RunWith(Suite.class)
 @SuiteClasses({
 		OpenShiftMavenProfileTests.class,
-		EmbedCartridgeStrategyTest.class
+		EmbedCartridgeStrategyTest.class,
+		SSHUserConfigTest.class
 		
 })
 /**

Added: trunk/openshift/tests/org.jboss.tools.openshift.express.test/src/org/jboss/tools/openshift/express/test/SSHUserConfigTest.java
===================================================================
--- trunk/openshift/tests/org.jboss.tools.openshift.express.test/src/org/jboss/tools/openshift/express/test/SSHUserConfigTest.java	                        (rev 0)
+++ trunk/openshift/tests/org.jboss.tools.openshift.express.test/src/org/jboss/tools/openshift/express/test/SSHUserConfigTest.java	2012-05-31 23:26:48 UTC (rev 41605)
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.openshift.express.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+import org.jboss.tools.openshift.express.internal.ui.utils.FileUtils;
+import org.jboss.tools.openshift.express.internal.ui.utils.SSHUserConfig;
+import org.junit.Test;
+
+import com.openshift.client.OpenShiftException;
+
+/**
+ * @author Andre Dietisheim
+ */
+public class SSHUserConfigTest {
+
+	@Test
+	public void shouldDetectIdentityFile() throws OpenShiftException, IOException {
+		String config = 
+				"# comment\n" +
+				"Host *.redhat.com\n" +
+				"    IdentityFile ~/.ssh/id_rsa_redhat\n" +
+				"    VerifyHostKeyDNS yes\n" +
+				"    StrictHostKeyChecking no\n" +
+				"\n" +
+				"# comment\n" +
+				"Host *.dev.rhcloud.com\n" +
+				"    IdentityFile ~/.ssh/libra_id_rsa_dev\n" +
+				"    VerifyHostKeyDNS yes\n" +
+				"    StrictHostKeyChecking no\n" +
+				"    UserKnownHostsFile ~/.ssh/libra_known_hosts\n";
+		SSHUserConfig sshUserConfig = getSSHUserConfig(config, createConfigFile(config));
+		assertEquals("~/.ssh/libra_id_rsa_dev", sshUserConfig.getLibraIdentityFile());
+	}
+
+	@Test
+	public void shouldNotDetectIdentityFile() throws OpenShiftException, IOException {
+		String config = 
+				"# comment\n" +
+				"Host *.redhat.com\n" +
+				"    IdentityFile ~/.ssh/id_rsa_redhat\n" +
+				"    VerifyHostKeyDNS yes\n" +
+				"    StrictHostKeyChecking no\n" +
+				"\n" +
+				"# comment\n" +
+				"Host *.jboss.org\n" +
+				"    IdentityFile ~/.ssh/libra_id_rsa_dev\n" +
+				"    VerifyHostKeyDNS yes\n" +
+				"    StrictHostKeyChecking no\n" +
+				"    UserKnownHostsFile ~/.ssh/libra_known_hosts\n";
+		SSHUserConfig sshUserConfig = getSSHUserConfig(config, createConfigFile(config));
+		assertNull(sshUserConfig.getLibraIdentityFile());
+	}
+
+	private SSHUserConfig getSSHUserConfig(String configFileContent, File sshConfigFile) throws FileNotFoundException {
+		return new SSHUserConfig(sshConfigFile);
+	}
+
+	private File createConfigFile(String configFileContent) throws FileNotFoundException {
+		final File configFile = 
+				new File(FileUtils.getSystemTmpFolder(), String.valueOf(System.currentTimeMillis()));
+		FileUtils.writeTo(configFileContent, configFile);
+		return configFile;
+	}
+}


Property changes on: trunk/openshift/tests/org.jboss.tools.openshift.express.test/src/org/jboss/tools/openshift/express/test/SSHUserConfigTest.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain



More information about the jbosstools-commits mailing list