Browse Source
fix: correct SFTP HomeDir path translation and add CI
fix: correct SFTP HomeDir path translation and add CI
Fix path.Join issue where paths starting with '/' weren't joined correctly.
path.Join('/sftp/user', '/file') returns '/file' instead of '/sftp/user/file'.
Now we strip the leading '/' before joining.
Test improvements:
- Update go.mod to Go 1.24
- Fix weed binary discovery to prefer local build over PATH
- Add stabilization delay after service startup
- All 8 SFTP integration tests pass locally
Add GitHub Actions workflow for SFTP tests:
- Runs on push/PR affecting sftpd code or tests
- Tests HomeDir path translation, file ops, directory ops
- Covers issue #7470 fix verification
pull/7611/head
5 changed files with 189 additions and 50 deletions
-
92.github/workflows/sftp-tests.yml
-
89test/sftp/framework.go
-
10test/sftp/go.mod
-
34test/sftp/go.sum
-
14weed/sftpd/sftp_server.go
@ -0,0 +1,92 @@ |
|||
name: "SFTP Integration Tests" |
|||
|
|||
on: |
|||
push: |
|||
branches: [ master, main ] |
|||
paths: |
|||
- 'weed/sftpd/**' |
|||
- 'weed/command/sftp.go' |
|||
- 'test/sftp/**' |
|||
- '.github/workflows/sftp-tests.yml' |
|||
pull_request: |
|||
branches: [ master, main ] |
|||
paths: |
|||
- 'weed/sftpd/**' |
|||
- 'weed/command/sftp.go' |
|||
- 'test/sftp/**' |
|||
- '.github/workflows/sftp-tests.yml' |
|||
|
|||
concurrency: |
|||
group: ${{ github.head_ref }}/sftp-tests |
|||
cancel-in-progress: true |
|||
|
|||
permissions: |
|||
contents: read |
|||
|
|||
env: |
|||
GO_VERSION: '1.24' |
|||
TEST_TIMEOUT: '15m' |
|||
|
|||
jobs: |
|||
sftp-integration: |
|||
name: SFTP Integration Testing |
|||
runs-on: ubuntu-22.04 |
|||
timeout-minutes: 20 |
|||
|
|||
steps: |
|||
- name: Checkout code |
|||
uses: actions/checkout@v4 |
|||
|
|||
- name: Set up Go ${{ env.GO_VERSION }} |
|||
uses: actions/setup-go@v5 |
|||
with: |
|||
go-version: ${{ env.GO_VERSION }} |
|||
|
|||
- name: Install dependencies |
|||
run: | |
|||
sudo apt-get update |
|||
sudo apt-get install -y openssh-client |
|||
|
|||
- name: Build SeaweedFS |
|||
run: | |
|||
cd weed |
|||
go build -o weed . |
|||
chmod +x weed |
|||
./weed version |
|||
|
|||
- name: Run SFTP Integration Tests |
|||
run: | |
|||
cd test/sftp |
|||
|
|||
echo "🧪 Running SFTP integration tests..." |
|||
echo "============================================" |
|||
|
|||
# Install test dependencies |
|||
go mod download |
|||
|
|||
# Run all SFTP tests |
|||
go test -v -timeout=${{ env.TEST_TIMEOUT }} ./... |
|||
|
|||
echo "============================================" |
|||
echo "✅ SFTP integration tests completed" |
|||
|
|||
- name: Test Summary |
|||
if: always() |
|||
run: | |
|||
echo "## 🔐 SFTP Integration Test Summary" >> $GITHUB_STEP_SUMMARY |
|||
echo "" >> $GITHUB_STEP_SUMMARY |
|||
echo "### Test Coverage" >> $GITHUB_STEP_SUMMARY |
|||
echo "- ✅ **HomeDir Path Translation**: User home directory mapping (fixes #7470)" >> $GITHUB_STEP_SUMMARY |
|||
echo "- ✅ **File Operations**: Upload, download, delete" >> $GITHUB_STEP_SUMMARY |
|||
echo "- ✅ **Directory Operations**: Create, list, remove" >> $GITHUB_STEP_SUMMARY |
|||
echo "- ✅ **Large File Handling**: 1MB+ file support" >> $GITHUB_STEP_SUMMARY |
|||
echo "- ✅ **Path Edge Cases**: Unicode, trailing slashes, .. paths" >> $GITHUB_STEP_SUMMARY |
|||
echo "- ✅ **Admin Access**: Root user verification" >> $GITHUB_STEP_SUMMARY |
|||
echo "" >> $GITHUB_STEP_SUMMARY |
|||
echo "### Test Configuration" >> $GITHUB_STEP_SUMMARY |
|||
echo "| User | HomeDir | Permissions |" >> $GITHUB_STEP_SUMMARY |
|||
echo "|------|---------|-------------|" >> $GITHUB_STEP_SUMMARY |
|||
echo "| admin | / | Full access |" >> $GITHUB_STEP_SUMMARY |
|||
echo "| testuser | /sftp/testuser | Home directory only |" >> $GITHUB_STEP_SUMMARY |
|||
echo "| readonly | /public | Read-only |" >> $GITHUB_STEP_SUMMARY |
|||
|
|||
@ -1,17 +1,17 @@ |
|||
module seaweedfs-sftp-tests |
|||
|
|||
go 1.21 |
|||
go 1.24 |
|||
|
|||
require ( |
|||
github.com/pkg/sftp v1.13.6 |
|||
github.com/stretchr/testify v1.8.4 |
|||
golang.org/x/crypto v0.17.0 |
|||
github.com/pkg/sftp v1.13.7 |
|||
github.com/stretchr/testify v1.10.0 |
|||
golang.org/x/crypto v0.31.0 |
|||
) |
|||
|
|||
require ( |
|||
github.com/davecgh/go-spew v1.1.1 // indirect |
|||
github.com/kr/fs v0.1.0 // indirect |
|||
github.com/pmezard/go-difflib v1.0.0 // indirect |
|||
golang.org/x/sys v0.15.0 // indirect |
|||
golang.org/x/sys v0.28.0 // indirect |
|||
gopkg.in/yaml.v3 v3.0.1 // indirect |
|||
) |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue