Update
This commit is contained in:
@@ -148,6 +148,67 @@ func TestContaboStorageConfigAllowsDisplayNamesWithSpaces(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSFTPStorageConfigValidation(t *testing.T) {
|
||||
service := newTestUploadService(t)
|
||||
cfg, err := service.Storage().CreateS3Backend(StorageBackendConfig{
|
||||
Provider: StorageProviderSFTP,
|
||||
Name: "NAS storage",
|
||||
Host: "files.example.test",
|
||||
Username: "warpbox",
|
||||
Password: "secret",
|
||||
RemotePath: "/srv/warpbox//",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("CreateS3Backend returned error: %v", err)
|
||||
}
|
||||
if cfg.Type != StorageBackendSFTP || cfg.Provider != StorageProviderSFTP {
|
||||
t.Fatalf("sftp config type/provider = %+v", cfg)
|
||||
}
|
||||
if cfg.Port != 22 {
|
||||
t.Fatalf("port = %d, want 22", cfg.Port)
|
||||
}
|
||||
if cfg.RemotePath != "/srv/warpbox" {
|
||||
t.Fatalf("remote path = %q", cfg.RemotePath)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSMBAndWebDAVStorageConfigValidation(t *testing.T) {
|
||||
service := newTestUploadService(t)
|
||||
smb, err := service.Storage().CreateS3Backend(StorageBackendConfig{
|
||||
Provider: StorageProviderSMB,
|
||||
Name: "Office NAS",
|
||||
Host: "nas.example.test",
|
||||
Username: "warpbox",
|
||||
Password: "secret",
|
||||
Share: "uploads",
|
||||
RemotePath: "/warpbox//",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("CreateS3Backend smb returned error: %v", err)
|
||||
}
|
||||
if smb.Type != StorageBackendSMB || smb.Provider != StorageProviderSMB || smb.Port != 445 {
|
||||
t.Fatalf("smb config was not normalized: %+v", smb)
|
||||
}
|
||||
if smb.RemotePath != "/warpbox" {
|
||||
t.Fatalf("smb remote path = %q", smb.RemotePath)
|
||||
}
|
||||
|
||||
webdav, err := service.Storage().CreateS3Backend(StorageBackendConfig{
|
||||
Provider: StorageProviderWebDAV,
|
||||
Name: "Nextcloud",
|
||||
Endpoint: "https://files.example.test/webdav",
|
||||
Username: "warpbox",
|
||||
Password: "secret",
|
||||
RemotePath: "/warpbox",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("CreateS3Backend webdav returned error: %v", err)
|
||||
}
|
||||
if webdav.Type != StorageBackendWebDAV || webdav.Provider != StorageProviderWebDAV {
|
||||
t.Fatalf("webdav config was not normalized: %+v", webdav)
|
||||
}
|
||||
}
|
||||
|
||||
func testContext() context.Context {
|
||||
return context.Background()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user