michael-o commented on code in PR #155:
URL: https://github.com/apache/maven-scm/pull/155#discussion_r925618018


##########
maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/checkout/GitExeSshCheckOutCommandTckTest.java:
##########
@@ -0,0 +1,72 @@
+package org.apache.maven.scm.provider.git.gitexe.command.checkout;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.security.GeneralSecurityException;
+
+import org.apache.commons.io.FilenameUtils;
+import 
org.apache.maven.scm.provider.git.command.checkout.GitSshCheckOutCommandTckTest;
+import org.apache.maven.scm.provider.git.gitexe.GitExeScmProvider;
+import org.apache.maven.scm.provider.git.repository.GitScmProviderRepository;
+import org.apache.maven.scm.repository.ScmRepository;
+import org.bouncycastle.operator.OperatorCreationException;
+
+/**
+ *
+ */
+public class GitExeSshCheckOutCommandTckTest
+    extends GitSshCheckOutCommandTckTest
+{
+    private Path knownHostsFile;
+
+    public static final String VARIABLE_GIT_SSH_COMMAND = "GIT_SSH_COMMAND"; 
// https://git-scm.com/docs/git#Documentation/git.txt-codeGITSSHCOMMANDcode, 
requires git 2.3.0 or newer
+
+    public GitExeSshCheckOutCommandTckTest() throws GeneralSecurityException
+    {
+        super();
+    }
+
+    @Override
+    protected String getScmProvider()
+    {
+        return "git";
+    }
+
+    @Override
+    public void configureCredentials(ScmRepository repository, String 
passphrase) throws Exception {

Review Comment:
   Wrap please



##########
maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/checkout/GitExeSshCheckOutCommandTckTest.java:
##########
@@ -0,0 +1,72 @@
+package org.apache.maven.scm.provider.git.gitexe.command.checkout;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.security.GeneralSecurityException;
+
+import org.apache.commons.io.FilenameUtils;
+import 
org.apache.maven.scm.provider.git.command.checkout.GitSshCheckOutCommandTckTest;
+import org.apache.maven.scm.provider.git.gitexe.GitExeScmProvider;
+import org.apache.maven.scm.provider.git.repository.GitScmProviderRepository;
+import org.apache.maven.scm.repository.ScmRepository;
+import org.bouncycastle.operator.OperatorCreationException;
+
+/**
+ *
+ */
+public class GitExeSshCheckOutCommandTckTest
+    extends GitSshCheckOutCommandTckTest
+{
+    private Path knownHostsFile;
+
+    public static final String VARIABLE_GIT_SSH_COMMAND = "GIT_SSH_COMMAND"; 
// https://git-scm.com/docs/git#Documentation/git.txt-codeGITSSHCOMMANDcode, 
requires git 2.3.0 or newer
+
+    public GitExeSshCheckOutCommandTckTest() throws GeneralSecurityException
+    {
+        super();
+    }
+
+    @Override
+    protected String getScmProvider()
+    {
+        return "git";
+    }
+
+    @Override
+    public void configureCredentials(ScmRepository repository, String 
passphrase) throws Exception {
+        super.configureCredentials(repository, passphrase);
+        GitScmProviderRepository providerRepository = 
(GitScmProviderRepository) repository.getProviderRepository();
+        GitExeScmProvider provider = (GitExeScmProvider) 
getScmManager().getProviderByRepository( getScmRepository() );
+        knownHostsFile = Files.createTempFile( "known-hosts", null );
+        provider.setEnvironmentVariable( VARIABLE_GIT_SSH_COMMAND, "ssh -o 
UserKnownHostsFile=" + knownHostsFile.toString() +
+                " -o StrictHostKeyChecking=no -o IdentitiesOnly=yes -i " + 
FilenameUtils.separatorsToUnix( providerRepository.getPrivateKey() ) );

Review Comment:
   Even on Windows the path tranformation is necessary? What if this is an 
absolute path?



##########
maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/checkout/GitExeSshCheckOutCommandTckTest.java:
##########
@@ -0,0 +1,72 @@
+package org.apache.maven.scm.provider.git.gitexe.command.checkout;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.security.GeneralSecurityException;
+
+import org.apache.commons.io.FilenameUtils;
+import 
org.apache.maven.scm.provider.git.command.checkout.GitSshCheckOutCommandTckTest;
+import org.apache.maven.scm.provider.git.gitexe.GitExeScmProvider;
+import org.apache.maven.scm.provider.git.repository.GitScmProviderRepository;
+import org.apache.maven.scm.repository.ScmRepository;
+import org.bouncycastle.operator.OperatorCreationException;
+
+/**
+ *
+ */
+public class GitExeSshCheckOutCommandTckTest
+    extends GitSshCheckOutCommandTckTest
+{
+    private Path knownHostsFile;
+
+    public static final String VARIABLE_GIT_SSH_COMMAND = "GIT_SSH_COMMAND"; 
// https://git-scm.com/docs/git#Documentation/git.txt-codeGITSSHCOMMANDcode, 
requires git 2.3.0 or newer
+
+    public GitExeSshCheckOutCommandTckTest() throws GeneralSecurityException
+    {
+        super();
+    }
+
+    @Override
+    protected String getScmProvider()
+    {
+        return "git";
+    }
+
+    @Override
+    public void configureCredentials(ScmRepository repository, String 
passphrase) throws Exception {
+        super.configureCredentials(repository, passphrase);

Review Comment:
   spaces



##########
maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/pom.xml:
##########
@@ -33,6 +33,10 @@
   <name>Maven SCM Git Provider TCK Tests</name>
   <description>Tests library for SCM Git Provider.</description>
 
+  <properties>
+    <sshdVersion>2.8.0</sshdVersion>

Review Comment:
   This should be `minaSsshdVersion` or similar, not to confuse with OpenSSH's 
`sshd`.



##########
maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/checkout/GitExeSshCheckOutCommandTckTest.java:
##########
@@ -0,0 +1,72 @@
+package org.apache.maven.scm.provider.git.gitexe.command.checkout;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.security.GeneralSecurityException;
+
+import org.apache.commons.io.FilenameUtils;
+import 
org.apache.maven.scm.provider.git.command.checkout.GitSshCheckOutCommandTckTest;
+import org.apache.maven.scm.provider.git.gitexe.GitExeScmProvider;
+import org.apache.maven.scm.provider.git.repository.GitScmProviderRepository;
+import org.apache.maven.scm.repository.ScmRepository;
+import org.bouncycastle.operator.OperatorCreationException;
+
+/**
+ *
+ */
+public class GitExeSshCheckOutCommandTckTest
+    extends GitSshCheckOutCommandTckTest
+{
+    private Path knownHostsFile;
+
+    public static final String VARIABLE_GIT_SSH_COMMAND = "GIT_SSH_COMMAND"; 
// https://git-scm.com/docs/git#Documentation/git.txt-codeGITSSHCOMMANDcode, 
requires git 2.3.0 or newer
+
+    public GitExeSshCheckOutCommandTckTest() throws GeneralSecurityException
+    {
+        super();
+    }
+
+    @Override
+    protected String getScmProvider()
+    {
+        return "git";
+    }
+
+    @Override
+    public void configureCredentials(ScmRepository repository, String 
passphrase) throws Exception {

Review Comment:
   spaces



##########
maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/checkout/GitExeSshCheckOutCommandTckTest.java:
##########
@@ -0,0 +1,72 @@
+package org.apache.maven.scm.provider.git.gitexe.command.checkout;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.security.GeneralSecurityException;
+
+import org.apache.commons.io.FilenameUtils;
+import 
org.apache.maven.scm.provider.git.command.checkout.GitSshCheckOutCommandTckTest;
+import org.apache.maven.scm.provider.git.gitexe.GitExeScmProvider;
+import org.apache.maven.scm.provider.git.repository.GitScmProviderRepository;
+import org.apache.maven.scm.repository.ScmRepository;
+import org.bouncycastle.operator.OperatorCreationException;
+
+/**
+ *
+ */
+public class GitExeSshCheckOutCommandTckTest
+    extends GitSshCheckOutCommandTckTest
+{
+    private Path knownHostsFile;
+
+    public static final String VARIABLE_GIT_SSH_COMMAND = "GIT_SSH_COMMAND"; 
// https://git-scm.com/docs/git#Documentation/git.txt-codeGITSSHCOMMANDcode, 
requires git 2.3.0 or newer
+
+    public GitExeSshCheckOutCommandTckTest() throws GeneralSecurityException
+    {
+        super();
+    }
+
+    @Override
+    protected String getScmProvider()
+    {
+        return "git";
+    }
+
+    @Override
+    public void configureCredentials(ScmRepository repository, String 
passphrase) throws Exception {
+        super.configureCredentials(repository, passphrase);
+        GitScmProviderRepository providerRepository = 
(GitScmProviderRepository) repository.getProviderRepository();
+        GitExeScmProvider provider = (GitExeScmProvider) 
getScmManager().getProviderByRepository( getScmRepository() );
+        knownHostsFile = Files.createTempFile( "known-hosts", null );
+        provider.setEnvironmentVariable( VARIABLE_GIT_SSH_COMMAND, "ssh -o 
UserKnownHostsFile=" + knownHostsFile.toString() +

Review Comment:
   `toString()` is redudant



##########
maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/checkout/GitSshCheckOutCommandTckTest.java:
##########
@@ -0,0 +1,185 @@
+package org.apache.maven.scm.provider.git.command.checkout;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+import java.io.IOException;
+import java.io.Writer;
+import java.nio.file.FileSystem;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.attribute.PosixFilePermissions;
+import java.security.GeneralSecurityException;
+import java.security.KeyPair;
+import java.security.PrivateKey;
+import java.security.SecureRandom;
+import java.util.Collections;
+
+import org.apache.maven.scm.provider.ScmProviderRepositoryWithHost;
+import org.apache.maven.scm.provider.git.GitScmTestUtils;
+import org.apache.maven.scm.repository.ScmRepository;
+import org.apache.maven.scm.tck.command.checkout.CheckOutCommandTckTest;
+import org.apache.sshd.common.config.keys.KeyUtils;
+import org.apache.sshd.git.GitLocationResolver;
+import org.apache.sshd.git.pack.GitPackCommandFactory;
+import org.apache.sshd.server.SshServer;
+import org.apache.sshd.server.auth.pubkey.KeySetPublickeyAuthenticator;
+import org.apache.sshd.server.auth.pubkey.PublickeyAuthenticator;
+import org.apache.sshd.server.session.ServerSession;
+import org.apache.sshd.util.test.CommonTestSupportUtils;
+import org.apache.sshd.util.test.CoreTestSupportUtils;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.bouncycastle.openssl.PKCS8Generator;
+import org.bouncycastle.openssl.jcajce.JcaPEMWriter;
+import org.bouncycastle.openssl.jcajce.JcaPKCS8Generator;
+import org.bouncycastle.openssl.jcajce.JceOpenSSLPKCS8EncryptorBuilder;
+import org.bouncycastle.operator.OperatorCreationException;
+import org.bouncycastle.operator.OutputEncryptor;
+import org.bouncycastle.util.io.pem.PemObject;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+
+/**
+ *
+ */
+public abstract class GitSshCheckOutCommandTckTest
+    extends CheckOutCommandTckTest
+{
+    protected final SshServer sshServer;
+    protected final KeyPair keyPair;
+
+    @Rule
+    public TemporaryFolder tmpDirectory = new TemporaryFolder();
+
+    protected GitSshCheckOutCommandTckTest() throws GeneralSecurityException
+    {
+         sshServer = CoreTestSupportUtils.setupTestServer( getClass() );
+         keyPair = CommonTestSupportUtils.generateKeyPair( 
KeyUtils.RSA_ALGORITHM, 2048 );
+         PublickeyAuthenticator authenticator = new 
KeySetPublickeyAuthenticator( "onlykey",
+                 Collections.singletonList( keyPair.getPublic() ) );
+         sshServer.setPublickeyAuthenticator( authenticator );
+    }
+
+    static void writePrivateKeyAsPkcs8( Path file, PrivateKey privateKey, 
String passphrase )
+            throws IOException, OperatorCreationException
+    {
+        final OutputEncryptor encryptor;
+        // encryption only optional
+        if ( passphrase != null )
+        {
+            //encrypted form of PKCS#8 file  
+            JceOpenSSLPKCS8EncryptorBuilder encryptorBuilder = 
+                    new JceOpenSSLPKCS8EncryptorBuilder( 
PKCS8Generator.PBE_SHA1_3DES );
+            encryptorBuilder.setRandom( new SecureRandom() );
+            encryptorBuilder.setProvider( BouncyCastleProvider.PROVIDER_NAME );
+            encryptorBuilder.setPassword( passphrase.toCharArray() );
+            encryptor = encryptorBuilder.build();
+        }
+        else 
+        {
+            encryptor = null;
+        }
+
+        PKCS8Generator pkcs8Generator = new JcaPKCS8Generator( privateKey, 
encryptor );
+        PemObject pemObject = pkcs8Generator.generate();
+        
+        try ( Writer writer = Files.newBufferedWriter( file );
+              JcaPEMWriter pw = new JcaPEMWriter( writer ) )
+        {
+            pw.writeObject( pemObject );
+        }
+        if ( file.getFileSystem().supportedFileAttributeViews().contains( 
"posix" ) )
+        {
+            // must only be readable/writeable by me
+            Files.setPosixFilePermissions( file, 
PosixFilePermissions.fromString( "rwx------" ) );
+        }
+    }
+
+    protected abstract String getScmProvider();
+
+    /** {@inheritDoc} */
+    public String getScmUrl()
+        throws Exception
+    {
+        return "scm:" + getScmProvider() + ":ssh://127.0.0.1:" + 
sshServer.getPort() + "/repository";

Review Comment:
   repository.git is the convention, isn't it?



##########
maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/checkout/JGitSshCheckOutCommandTckTest.java:
##########
@@ -0,0 +1,105 @@
+package org.apache.maven.scm.provider.git.jgit.command.checkout;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.security.GeneralSecurityException;
+import java.security.PublicKey;
+import java.util.function.Consumer;
+
+import 
org.apache.maven.scm.provider.git.command.checkout.GitSshCheckOutCommandTckTest;
+import org.apache.maven.scm.provider.git.jgit.JGitTestScmProvider;
+import 
org.apache.maven.scm.provider.git.jgit.command.ScmProviderAwareSshdSessionFactory;
+import org.apache.maven.scm.provider.git.repository.GitScmProviderRepository;
+import org.eclipse.jgit.annotations.NonNull;
+import org.eclipse.jgit.internal.transport.sshd.OpenSshServerKeyDatabase;
+import org.eclipse.jgit.transport.CredentialsProvider;
+import org.eclipse.jgit.transport.sshd.ServerKeyDatabase;
+import org.eclipse.jgit.util.FileUtils;
+import org.slf4j.Logger;
+
+/**
+ * @author <a href="mailto:[email protected]";>Mark Struberg</a>
+ */
+public class JGitSshCheckOutCommandTckTest
+    extends GitSshCheckOutCommandTckTest
+{
+
+    public JGitSshCheckOutCommandTckTest() throws GeneralSecurityException, 
IOException {
+        super();
+    }
+
+    @Override
+    protected String getScmProvider() {
+        return "jgit";
+    }
+
+    

Review Comment:
   one empty line



##########
maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/checkout/GitSshCheckOutCommandTckTest.java:
##########
@@ -0,0 +1,185 @@
+package org.apache.maven.scm.provider.git.command.checkout;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+import java.io.IOException;
+import java.io.Writer;
+import java.nio.file.FileSystem;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.attribute.PosixFilePermissions;
+import java.security.GeneralSecurityException;
+import java.security.KeyPair;
+import java.security.PrivateKey;
+import java.security.SecureRandom;
+import java.util.Collections;
+
+import org.apache.maven.scm.provider.ScmProviderRepositoryWithHost;
+import org.apache.maven.scm.provider.git.GitScmTestUtils;
+import org.apache.maven.scm.repository.ScmRepository;
+import org.apache.maven.scm.tck.command.checkout.CheckOutCommandTckTest;
+import org.apache.sshd.common.config.keys.KeyUtils;
+import org.apache.sshd.git.GitLocationResolver;
+import org.apache.sshd.git.pack.GitPackCommandFactory;
+import org.apache.sshd.server.SshServer;
+import org.apache.sshd.server.auth.pubkey.KeySetPublickeyAuthenticator;
+import org.apache.sshd.server.auth.pubkey.PublickeyAuthenticator;
+import org.apache.sshd.server.session.ServerSession;
+import org.apache.sshd.util.test.CommonTestSupportUtils;
+import org.apache.sshd.util.test.CoreTestSupportUtils;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.bouncycastle.openssl.PKCS8Generator;
+import org.bouncycastle.openssl.jcajce.JcaPEMWriter;
+import org.bouncycastle.openssl.jcajce.JcaPKCS8Generator;
+import org.bouncycastle.openssl.jcajce.JceOpenSSLPKCS8EncryptorBuilder;
+import org.bouncycastle.operator.OperatorCreationException;
+import org.bouncycastle.operator.OutputEncryptor;
+import org.bouncycastle.util.io.pem.PemObject;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+
+/**
+ *
+ */
+public abstract class GitSshCheckOutCommandTckTest
+    extends CheckOutCommandTckTest
+{
+    protected final SshServer sshServer;
+    protected final KeyPair keyPair;
+
+    @Rule
+    public TemporaryFolder tmpDirectory = new TemporaryFolder();
+
+    protected GitSshCheckOutCommandTckTest() throws GeneralSecurityException
+    {
+         sshServer = CoreTestSupportUtils.setupTestServer( getClass() );
+         keyPair = CommonTestSupportUtils.generateKeyPair( 
KeyUtils.RSA_ALGORITHM, 2048 );
+         PublickeyAuthenticator authenticator = new 
KeySetPublickeyAuthenticator( "onlykey",
+                 Collections.singletonList( keyPair.getPublic() ) );
+         sshServer.setPublickeyAuthenticator( authenticator );
+    }
+
+    static void writePrivateKeyAsPkcs8( Path file, PrivateKey privateKey, 
String passphrase )
+            throws IOException, OperatorCreationException
+    {
+        final OutputEncryptor encryptor;
+        // encryption only optional
+        if ( passphrase != null )
+        {
+            //encrypted form of PKCS#8 file  
+            JceOpenSSLPKCS8EncryptorBuilder encryptorBuilder = 
+                    new JceOpenSSLPKCS8EncryptorBuilder( 
PKCS8Generator.PBE_SHA1_3DES );
+            encryptorBuilder.setRandom( new SecureRandom() );
+            encryptorBuilder.setProvider( BouncyCastleProvider.PROVIDER_NAME );
+            encryptorBuilder.setPassword( passphrase.toCharArray() );
+            encryptor = encryptorBuilder.build();
+        }
+        else 
+        {
+            encryptor = null;
+        }
+
+        PKCS8Generator pkcs8Generator = new JcaPKCS8Generator( privateKey, 
encryptor );
+        PemObject pemObject = pkcs8Generator.generate();
+        
+        try ( Writer writer = Files.newBufferedWriter( file );
+              JcaPEMWriter pw = new JcaPEMWriter( writer ) )
+        {
+            pw.writeObject( pemObject );
+        }
+        if ( file.getFileSystem().supportedFileAttributeViews().contains( 
"posix" ) )
+        {
+            // must only be readable/writeable by me
+            Files.setPosixFilePermissions( file, 
PosixFilePermissions.fromString( "rwx------" ) );
+        }
+    }
+
+    protected abstract String getScmProvider();
+
+    /** {@inheritDoc} */
+    public String getScmUrl()
+        throws Exception
+    {
+        return "scm:" + getScmProvider() + ":ssh://127.0.0.1:" + 
sshServer.getPort() + "/repository";

Review Comment:
   localhost



##########
maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/checkout/JGitSshCheckOutCommandTckTest.java:
##########
@@ -0,0 +1,105 @@
+package org.apache.maven.scm.provider.git.jgit.command.checkout;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.security.GeneralSecurityException;
+import java.security.PublicKey;
+import java.util.function.Consumer;
+
+import 
org.apache.maven.scm.provider.git.command.checkout.GitSshCheckOutCommandTckTest;
+import org.apache.maven.scm.provider.git.jgit.JGitTestScmProvider;
+import 
org.apache.maven.scm.provider.git.jgit.command.ScmProviderAwareSshdSessionFactory;
+import org.apache.maven.scm.provider.git.repository.GitScmProviderRepository;
+import org.eclipse.jgit.annotations.NonNull;
+import org.eclipse.jgit.internal.transport.sshd.OpenSshServerKeyDatabase;
+import org.eclipse.jgit.transport.CredentialsProvider;
+import org.eclipse.jgit.transport.sshd.ServerKeyDatabase;
+import org.eclipse.jgit.util.FileUtils;
+import org.slf4j.Logger;
+
+/**
+ * @author <a href="mailto:[email protected]";>Mark Struberg</a>
+ */
+public class JGitSshCheckOutCommandTckTest
+    extends GitSshCheckOutCommandTckTest
+{
+
+    public JGitSshCheckOutCommandTckTest() throws GeneralSecurityException, 
IOException {
+        super();
+    }
+
+    @Override
+    protected String getScmProvider() {
+        return "jgit";
+    }
+
+    
+    @Override
+    public void initRepo() throws Exception {

Review Comment:
   wrap



##########
maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/checkout/JGitSshCheckOutCommandTckTest.java:
##########
@@ -0,0 +1,105 @@
+package org.apache.maven.scm.provider.git.jgit.command.checkout;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.security.GeneralSecurityException;
+import java.security.PublicKey;
+import java.util.function.Consumer;
+
+import 
org.apache.maven.scm.provider.git.command.checkout.GitSshCheckOutCommandTckTest;
+import org.apache.maven.scm.provider.git.jgit.JGitTestScmProvider;
+import 
org.apache.maven.scm.provider.git.jgit.command.ScmProviderAwareSshdSessionFactory;
+import org.apache.maven.scm.provider.git.repository.GitScmProviderRepository;
+import org.eclipse.jgit.annotations.NonNull;
+import org.eclipse.jgit.internal.transport.sshd.OpenSshServerKeyDatabase;
+import org.eclipse.jgit.transport.CredentialsProvider;
+import org.eclipse.jgit.transport.sshd.ServerKeyDatabase;
+import org.eclipse.jgit.util.FileUtils;
+import org.slf4j.Logger;
+
+/**
+ * @author <a href="mailto:[email protected]";>Mark Struberg</a>
+ */
+public class JGitSshCheckOutCommandTckTest
+    extends GitSshCheckOutCommandTckTest
+{
+
+    public JGitSshCheckOutCommandTckTest() throws GeneralSecurityException, 
IOException {
+        super();
+    }
+
+    @Override
+    protected String getScmProvider() {
+        return "jgit";
+    }
+
+    
+    @Override
+    public void initRepo() throws Exception {
+        super.initRepo();
+        JGitTestScmProvider provider = (JGitTestScmProvider) 
getScmManager().getProviderByRepository( getScmRepository() );
+        // accept all hosts
+        provider.registerCheckOutCommandCallback( new 
Consumer<JGitCheckOutCommand>() 
+        {
+            @Override
+            public void accept(JGitCheckOutCommand command) {

Review Comment:
   spaces



##########
maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/checkout/JGitSshCheckOutCommandTckTest.java:
##########
@@ -0,0 +1,105 @@
+package org.apache.maven.scm.provider.git.jgit.command.checkout;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.security.GeneralSecurityException;
+import java.security.PublicKey;
+import java.util.function.Consumer;
+
+import 
org.apache.maven.scm.provider.git.command.checkout.GitSshCheckOutCommandTckTest;
+import org.apache.maven.scm.provider.git.jgit.JGitTestScmProvider;
+import 
org.apache.maven.scm.provider.git.jgit.command.ScmProviderAwareSshdSessionFactory;
+import org.apache.maven.scm.provider.git.repository.GitScmProviderRepository;
+import org.eclipse.jgit.annotations.NonNull;
+import org.eclipse.jgit.internal.transport.sshd.OpenSshServerKeyDatabase;
+import org.eclipse.jgit.transport.CredentialsProvider;
+import org.eclipse.jgit.transport.sshd.ServerKeyDatabase;
+import org.eclipse.jgit.util.FileUtils;
+import org.slf4j.Logger;
+
+/**
+ * @author <a href="mailto:[email protected]";>Mark Struberg</a>
+ */
+public class JGitSshCheckOutCommandTckTest
+    extends GitSshCheckOutCommandTckTest
+{
+
+    public JGitSshCheckOutCommandTckTest() throws GeneralSecurityException, 
IOException {
+        super();
+    }
+
+    @Override
+    protected String getScmProvider() {

Review Comment:
   wrap



##########
maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/checkout/JGitSshCheckOutCommandTckTest.java:
##########
@@ -0,0 +1,105 @@
+package org.apache.maven.scm.provider.git.jgit.command.checkout;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.security.GeneralSecurityException;
+import java.security.PublicKey;
+import java.util.function.Consumer;
+
+import 
org.apache.maven.scm.provider.git.command.checkout.GitSshCheckOutCommandTckTest;
+import org.apache.maven.scm.provider.git.jgit.JGitTestScmProvider;
+import 
org.apache.maven.scm.provider.git.jgit.command.ScmProviderAwareSshdSessionFactory;
+import org.apache.maven.scm.provider.git.repository.GitScmProviderRepository;
+import org.eclipse.jgit.annotations.NonNull;
+import org.eclipse.jgit.internal.transport.sshd.OpenSshServerKeyDatabase;
+import org.eclipse.jgit.transport.CredentialsProvider;
+import org.eclipse.jgit.transport.sshd.ServerKeyDatabase;
+import org.eclipse.jgit.util.FileUtils;
+import org.slf4j.Logger;
+
+/**
+ * @author <a href="mailto:[email protected]";>Mark Struberg</a>
+ */
+public class JGitSshCheckOutCommandTckTest
+    extends GitSshCheckOutCommandTckTest
+{
+
+    public JGitSshCheckOutCommandTckTest() throws GeneralSecurityException, 
IOException {

Review Comment:
   wrap



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to