Working with remote files

You can use a File transport with a File Access resource to publish or consume remote file contents using File Transport Protocol (FTP) or SSH File Transport Protocol (SFTP) in HCL OneTest™ API.

About this task

To work with remote files, you must bind a File transport to a File Access resource and configure the file transfer by using either SFTP or FTP protocols.

Procedure

  1. Create an identity resource with the sign-in credentials. From the Physical view, click General > Identity. See Figure 1.
    Figure 1. The Identity window
    Image of the Identity screen.
    Note: An FTP connection uses the value anonymous for the Username or for the Password when these fields are left blank.
  2. Create a File Access resource and specify the host and the protocol as either FTP or SFTP. See Figure 2.
    Figure 2. The File Access window
    File Access screen
    1. If required, specify the port override.
    2. You can specify the sign-in credentials by selecting Specify username and password or select Use Identity to use the created identity.
    3. To verify that the configured connection works, click Test Connection.
  3. Create a named logical resource. From the Logical view, click Files > File and enter a name for the new resource.
  4. Bind the logical File to the physical File Access. From the Logical View, right-click the file to bind, navigate in the menu displayed to Set Binding in > Environment > to File Access<credentials-host>, as shown in Figure 3.
    Figure 3. Binding the File
    Image showing the file binding options screen.
  5. Configure the logical File.
    Note:
    • The directory specified on the logical File for an FTP is always relative to the home directory of the user. See Figure 4.
    • For an SFTP, the pathname can either be relative to the home directory of the user or explicitly described through an absolute path, as shown in Figure 5.
  6. Click Test Transport to test the connect to the remote file system and verify the existence of the specified directory.
    Figure 4. Transport test result for an FTP with a relative path
    Image of the result screen for an FTP when Test Transport is clicked.
    Figure 5. Transport test result for an SFTP with an absolute path
    Image of the result screen for an SFTP when Test Transport is clicked.
  7. Set the Last Modification Delay, which is specified in seconds to defer consumption of a file until it is completely uploaded. See Figure 6.
    Figure 6. The Consuming tab in the File window
    Image of the screen to set the delay of last modification.
    You can use a File transport in a test or stub like a file on the local machine. However, appending to a remote file is not allowed as shown in Figure 7.
    Figure 7. The Config tab in the Publish window
    Image of the Publish screen.
Feedback