diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0a3dc5a..847794f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,10 +33,16 @@ jobs: - name: Install and start SFTP run: | sudo apt install openssh-server + sudo sh -c 'echo "UsePAM yes" >> /etc/ssh/sshd_config' + sudo sh -c 'echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config' sudo sh -c 'echo "ChallengeResponseAuthentication no" >> /etc/ssh/sshd_config' - sudo sh -c 'echo "PasswordAuthentication no" >> /etc/ssh/sshd_config' + sudo sh -c 'echo "Match User usr4ssh" >> /etc/ssh/sshd_config' + sudo sh -c 'echo -e "\tPasswordAuthentication no" >> /etc/ssh/sshd_config' + sudo sh -c 'echo -e "\tPermitEmptyPasswords yes" >> /etc/ssh/sshd_config' + sudo sh -c 'echo -e "\tChallengeResponseAuthentication no" >> /etc/ssh/sshd_config' sudo systemctl enable ssh sudo systemctl start ssh + sudo cat /etc/ssh/sshd_config - name: Create a test user account run: | @@ -45,15 +51,17 @@ jobs: echo "adding user to group ${sshGroup}" sudo useradd -s /bin/bash -d /home/usr -m -g ${sshGroup} -p $(echo pwd | openssl passwd -1 -stdin) usr + echo "adding user for test ssh keypair to group ${sshGroup}" + sudo useradd -s /bin/bash -d /home/usr4ssh -m -g ${sshGroup} -p $(echo pwd | openssl passwd -1 -stdin) usr4ssh ssh-keygen -t rsa -b 4096 -N "123456" -f ~/.ssh/sftptest chmod -R 700 ~/.ssh/sftptest chmod 600 ~/.ssh/sftptest.pub - sudo -u usr mkdir /home/usr/.ssh/ - sudo cat ~/.ssh/sftptest.pub >> /home/usr/.ssh/authorized_keys - sudo chown -R usr:${sshGroup} /home/usr/.ssh - sudo chmod -R 700 /home/usr/.ssh - sudo chmod 664 /home/usr/.ssh/authorized_keys + sudo -u usr4ssh mkdir /home/usr4ssh/.ssh/ + sudo cat ~/.ssh/sftptest.pub >> /home/usr4ssh/.ssh/authorized_keys + sudo chown -R usr4ssh:${sshGroup} /home/usr4ssh/.ssh + sudo chmod -R 700 /home/usr4ssh/.ssh + sudo chmod 664 /home/usr4ssh/.ssh/authorized_keys cp ~/.ssh/sftptest ${GITHUB_WORKSPACE}/sftp-connector-test/src_test/com/axonivy/connector/sftp/test/sftptest - name: Setup Maven diff --git a/sftp-connector-test/src_test/com/axonivy/connector/sftp/test/SftpProcessSSHTest.java b/sftp-connector-test/src_test/com/axonivy/connector/sftp/test/SftpProcessSSHTest.java index 698bda2..e94a60e 100644 --- a/sftp-connector-test/src_test/com/axonivy/connector/sftp/test/SftpProcessSSHTest.java +++ b/sftp-connector-test/src_test/com/axonivy/connector/sftp/test/SftpProcessSSHTest.java @@ -52,6 +52,8 @@ public class SftpProcessSSHTest { @BeforeAll public static void init() throws Exception { String prefix = "com_axonivy_connector_sftp_server_"; + // set-up var for ssh + Ivy.var().set(prefix+"username", "usr4ssh"); Ivy.var().set(prefix+"auth", "ssh"); Ivy.var().set(prefix+"password", ""); diff --git a/sftp-connector-test/src_test/com/axonivy/connector/sftp/test/SftpProcessTest.java b/sftp-connector-test/src_test/com/axonivy/connector/sftp/test/SftpProcessTest.java index fc93b9b..04a5161 100644 --- a/sftp-connector-test/src_test/com/axonivy/connector/sftp/test/SftpProcessTest.java +++ b/sftp-connector-test/src_test/com/axonivy/connector/sftp/test/SftpProcessTest.java @@ -4,10 +4,12 @@ import java.io.IOException; import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.List; import org.apache.commons.io.FileUtils; -import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; @@ -19,6 +21,7 @@ import ch.ivyteam.ivy.bpm.engine.client.element.BpmProcess; import ch.ivyteam.ivy.bpm.engine.client.sub.SubProcessCallResult; import ch.ivyteam.ivy.bpm.exec.client.IvyProcessTest; +import ch.ivyteam.ivy.environment.Ivy; import ch.ivyteam.ivy.scripting.objects.File; @@ -36,7 +39,6 @@ *

*/ @IvyProcessTest(enableWebServer = true) -@Disabled public class SftpProcessTest { private static final BpmProcess TEST_HELPER_PROCESS = BpmProcess.path("Sftp/SftpHelper"); @@ -46,7 +48,18 @@ public class SftpProcessTest { private static final String TEST_FILE_NAME = "market_market_connector_sftp.pdf"; private static final long TEST_FILE_SIZE = 207569L; - + @BeforeAll + public static void init() throws Exception { + String prefix = "com_axonivy_connector_sftp_server_"; + // set-up var for ssh + Ivy.var().set(prefix+"username", "usr"); + Ivy.var().set(prefix+"auth", "password"); + Ivy.var().set(prefix+"password", "pwd"); + + Ivy.var().set(prefix+"secret_sshkey", ""); + Ivy.var().set(prefix+"secret_sshpassphrase", ""); + } + @Test @Order(1) public void callOpenConnection(BpmClient bpmClient) {