@ln-maf/sftp
v4.1.7
Published
SFTP step definitions for MAF
Readme
MAF - SFTP Module
This module provides SFTP step definitions for testing file servers, enabling automated testing of file transfers and server operations.
[![Dependencies][dep-image]][dep-url]
Dependencies
This module is dependent on the following npm modules:
- ssh2-sftp-client
Setup
Install by running
npm i @ln-maf/sftpAdd a new step file in the features folder with the following code:
require('@ln-maf/sftp')Configuration
The SFTP module uses connection configuration that can be provided through:
- Environment variables (SSH_AUTH_SOCK for agent authentication)
- Global MAF variables stored in
this.results:hostorhostname: The SFTP server hostnameport: The SFTP server portusername: The username for authenticationpassword: The password for authentication
Note: Username and host are required for SFTP operations.
Step Definitions
When list of files from remote server directory {string} is received
Retrieves a list of files from the specified remote server directory.
Parameters:
serverDirectory(string): The path to the remote directory
Returns: Array of filenames found in the directory
Example:
When list of files from remote server directory "/uploads" is receivedWhen file {string} is downloaded from server as file {string}
Downloads a specific file from the remote server to a local location.
Parameters:
serverFile(string): The full path to the file on the remote serverfile(string): The local filename where the file will be saved
Returns: The local file path where the file was downloaded
Example:
When file "/uploads/data.txt" is downloaded from server as file "downloaded_data.txt"When latest file from server directory {string} is downloaded as file {string}
Downloads the most recently modified file from the specified remote directory.
Parameters:
remoteDirectory(string): The path to the remote directoryfile(string): The local filename where the file will be saved
Returns: The name of the file that was downloaded
Example:
When latest file from server directory "/uploads" is downloaded as file "latest_upload.txt"When file {string} is put in server folder {string}
Uploads a local file to the specified remote server directory.
Parameters:
file(string): The local filename to uploadserverDirectory(string): The remote directory path where the file will be placed
Returns: The remote file path where the file was uploaded
Example:
When file "test_data.txt" is put in server folder "/uploads/"Global MAF Variables
The SFTP module integrates with MAF's global variable system and supports template literals:
- host/hostname: SFTP server address
- port: SFTP server port (optional)
- username: Authentication username (required)
- password: Authentication password (required)
