From ed10668eca20d1b7a09af89b261cecbecb6eec3c 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 ++++ admin/edi_accounts.pl | 2 ++ koha-tmpl/intranet-tmpl/prog/en/modules/admin/edi_accounts.tt | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/Koha/Edifact/Transport.pm b/Koha/Edifact/Transport.pm index c0ae452ef98..80f6cc9ecf9 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}->download_port ? $self->{account}->download_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}->upload_port ? $self->{account}->upload_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"); diff --git a/admin/edi_accounts.pl b/admin/edi_accounts.pl index 65e3b4e1a2a..c9f487cae90 100755 --- a/admin/edi_accounts.pl +++ b/admin/edi_accounts.pl @@ -79,6 +79,8 @@ else { host => scalar $input->param('host'), username => scalar $input->param('username'), password => $password, + upload_port => scalar $input->param('upload_port'), + download_port => scalar $input->param('download_port'), vendor_id => scalar $input->param('vendor_id'), upload_directory => scalar $input->param('upload_directory'), download_directory => scalar $input->param('download_directory'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/edi_accounts.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/edi_accounts.tt index 79a507d8d60..de2ee85be15 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/edi_accounts.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/edi_accounts.tt @@ -312,6 +312,8 @@ Remote host Username Password + Upload port + Download port Download directory Upload directory Qualifier @@ -333,6 +335,8 @@ [% account.host | html %] [% account.username | html %] [% IF account.password %]*****[% END %] + [% account.upload_port | html %] + [% account.download_port | html %] [% account.download_directory | html %] [% account.upload_directory | html %] -- 2.20.1