From d9a73521203738d2d9b8b69d58efb1e4eb580b0e Mon Sep 17 00:00:00 2001 From: Alex Buckley Date: Mon, 8 Jan 2024 14:47:37 +0000 Subject: [PATCH] Bug 35724: Define non-standard ports for EDI SFTP in EDI accounts Not all EDI vendors accept Koha servers connecting on port 22, sometimes they require a different port to be used, so it would be helpful for librarians to be able to configure non-standard EDI SFTP ports themselves. Test plan: 1. Set EDIFACT syspref = 'Enable' and define a EDI account: Administration > Acquisition parameters > EDI accounts. 2. Create an EDI order: https://koha-community.org/manual/latest/en/html/acquisitions.html#ordering-via-edi 3. Confirm you can upload the EDI order and download the vendor invoice. 4. Apply patches, update database, and restart services. 5. Go to the EDI account you made in #1. 6. Confirm there are two new fields: Upload port and Download port, both have the value of 22. 7. Create a new EDI order. 8. Confirm you can upload the EDI order and download the vendor invoice. 9. Change the EDI account. Set the Download port = 10022. 10. Create a third EDI order. 11. Confirm you can upload the EDI order and download the vendor invoice. Sponsored-by: Waikato Institute of Technology, New Zealand --- Koha/Edifact/Transport.pm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Koha/Edifact/Transport.pm b/Koha/Edifact/Transport.pm index c0ae452ef98..d266dd7499c 100644 --- a/Koha/Edifact/Transport.pm +++ b/Koha/Edifact/Transport.pm @@ -136,10 +136,12 @@ sub sftp_download { # C = ready to retrieve E = Edifact my $msg_hash = $self->message_hash(); my @downloaded_files; + my $port = $self->{account}->{port} ? $self->{account}->{port} : '22'; my $sftp = Net::SFTP::Foreign->new( host => $self->{account}->host, user => $self->{account}->username, password => Koha::Encryption->new->decrypt_hex($self->{account}->password), + port => $port, timeout => 10, ); if ( $sftp->error ) { @@ -293,10 +295,12 @@ sub ftp_upload { sub sftp_upload { my ( $self, @messages ) = @_; + my $port = $self->{account}->{port} ? $self->{account}->{port} : '22'; my $sftp = Net::SFTP::Foreign->new( host => $self->{account}->host, user => $self->{account}->username, password => Koha::Encryption->new->decrypt_hex($self->{account}->password), + port => $port, timeout => 10, ); $sftp->die_on_error("Cannot ssh to $self->{account}->host"); -- 2.20.1