httpdtest

package
v2.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 4, 2022 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Overview

Package httpdtest provides utilities for testing the exposed REST API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddAPIKey

func AddAPIKey(apiKey dataprovider.APIKey, expectedStatusCode int) (dataprovider.APIKey, []byte, error)

AddAPIKey adds a new API key and checks the received HTTP Status code against expectedStatusCode.

func AddAdmin

func AddAdmin(admin dataprovider.Admin, expectedStatusCode int) (dataprovider.Admin, []byte, error)

AddAdmin adds a new admin and checks the received HTTP Status code against expectedStatusCode.

func AddFolder

func AddFolder(folder vfs.BaseVirtualFolder, expectedStatusCode int) (vfs.BaseVirtualFolder, []byte, error)

AddFolder adds a new folder and checks the received HTTP Status code against expectedStatusCode

func AddGroup added in v2.3.0

func AddGroup(group dataprovider.Group, expectedStatusCode int) (dataprovider.Group, []byte, error)

AddGroup adds a new group and checks the received HTTP Status code against expectedStatusCode.

func AddUser

func AddUser(user dataprovider.User, expectedStatusCode int) (dataprovider.User, []byte, error)

AddUser adds a new user and checks the received HTTP Status code against expectedStatusCode.

func ChangeAdminPassword

func ChangeAdminPassword(currentPassword, newPassword string, expectedStatusCode int) ([]byte, error)

ChangeAdminPassword changes the password for an existing admin

func CloseConnection

func CloseConnection(connectionID string, expectedStatusCode int) ([]byte, error)

CloseConnection closes an active connection identified by connectionID

func Dumpdata

func Dumpdata(outputFile, outputData, indent string, expectedStatusCode int) (map[string]any, []byte, error)

Dumpdata requests a backup to outputFile. outputFile is relative to the configured backups_path

func GetAPIKeyByID

func GetAPIKeyByID(keyID string, expectedStatusCode int) (dataprovider.APIKey, []byte, error)

GetAPIKeyByID gets a API key by ID and checks the received HTTP Status code against expectedStatusCode.

func GetAPIKeys

func GetAPIKeys(limit, offset int64, expectedStatusCode int) ([]dataprovider.APIKey, []byte, error)

GetAPIKeys returns a list of API keys and checks the received HTTP Status code against expectedStatusCode. The number of results can be limited specifying a limit. Some results can be skipped specifying an offset.

func GetAdminByUsername

func GetAdminByUsername(username string, expectedStatusCode int) (dataprovider.Admin, []byte, error)

GetAdminByUsername gets an admin by username and checks the received HTTP Status code against expectedStatusCode.

func GetAdmins

func GetAdmins(limit, offset int64, expectedStatusCode int) ([]dataprovider.Admin, []byte, error)

GetAdmins returns a list of admins and checks the received HTTP Status code against expectedStatusCode. The number of results can be limited specifying a limit. Some results can be skipped specifying an offset.

func GetBanTime

func GetBanTime(ip string, expectedStatusCode int) (map[string]any, []byte, error)

GetBanTime returns the ban time for the given IP address

func GetConnections

func GetConnections(expectedStatusCode int) ([]common.ConnectionStatus, []byte, error)

GetConnections returns status and stats for active SFTP/SCP connections

func GetDefenderHostByIP

func GetDefenderHostByIP(ip string, expectedStatusCode int) (dataprovider.DefenderEntry, []byte, error)

GetDefenderHostByIP returns the host with the given IP, if it exists

func GetDefenderHosts

func GetDefenderHosts(expectedStatusCode int) ([]dataprovider.DefenderEntry, []byte, error)

GetDefenderHosts returns hosts that are banned or for which some violations have been detected

func GetFolderByName

func GetFolderByName(name string, expectedStatusCode int) (vfs.BaseVirtualFolder, []byte, error)

GetFolderByName gets a folder by name and checks the received HTTP Status code against expectedStatusCode.

func GetFolders

func GetFolders(limit int64, offset int64, expectedStatusCode int) ([]vfs.BaseVirtualFolder, []byte, error)

GetFolders returns a list of folders and checks the received HTTP Status code against expectedStatusCode. The number of results can be limited specifying a limit. Some results can be skipped specifying an offset. The results can be filtered specifying a folder path, the folder path filter is an exact match

func GetFoldersQuotaScans

func GetFoldersQuotaScans(expectedStatusCode int) ([]common.ActiveVirtualFolderQuotaScan, []byte, error)

GetFoldersQuotaScans gets active quota scans for folders and checks the received HTTP Status code against expectedStatusCode.

func GetGroupByName added in v2.3.0

func GetGroupByName(name string, expectedStatusCode int) (dataprovider.Group, []byte, error)

GetGroupByName gets a group by name and checks the received HTTP Status code against expectedStatusCode.

func GetGroups added in v2.3.0

func GetGroups(limit, offset int64, expectedStatusCode int) ([]dataprovider.Group, []byte, error)

GetGroups returns a list of groups and checks the received HTTP Status code against expectedStatusCode. The number of results can be limited specifying a limit. Some results can be skipped specifying an offset.

func GetQuotaScans

func GetQuotaScans(expectedStatusCode int) ([]common.ActiveQuotaScan, []byte, error)

GetQuotaScans gets active quota scans for users and checks the received HTTP Status code against expectedStatusCode.

func GetRetentionChecks

func GetRetentionChecks(expectedStatusCode int) ([]common.ActiveRetentionChecks, []byte, error)

GetRetentionChecks returns the active retention checks

func GetScore

func GetScore(ip string, expectedStatusCode int) (map[string]any, []byte, error)

GetScore returns the score for the given IP address

func GetStatus

func GetStatus(expectedStatusCode int) (httpd.ServicesStatus, []byte, error)

GetStatus returns the server status

func GetToken

func GetToken(username, password string) (string, map[string]any, error)

GetToken tries to return a JWT token

func GetUserByUsername

func GetUserByUsername(username string, expectedStatusCode int) (dataprovider.User, []byte, error)

GetUserByUsername gets a user by username and checks the received HTTP Status code against expectedStatusCode.

func GetUsers

func GetUsers(limit, offset int64, expectedStatusCode int) ([]dataprovider.User, []byte, error)

GetUsers returns a list of users and checks the received HTTP Status code against expectedStatusCode. The number of results can be limited specifying a limit. Some results can be skipped specifying an offset.

func GetVersion

func GetVersion(expectedStatusCode int) (version.Info, []byte, error)

GetVersion returns version details

func Loaddata

func Loaddata(inputFile, scanQuota, mode string, expectedStatusCode int) (map[string]any, []byte, error)

Loaddata restores a backup.

func LoaddataFromPostBody

func LoaddataFromPostBody(data []byte, scanQuota, mode string, expectedStatusCode int) (map[string]any, []byte, error)

LoaddataFromPostBody restores a backup

func RemoveAPIKey

func RemoveAPIKey(apiKey dataprovider.APIKey, expectedStatusCode int) ([]byte, error)

RemoveAPIKey removes an existing API key and checks the received HTTP Status code against expectedStatusCode.

func RemoveAdmin

func RemoveAdmin(admin dataprovider.Admin, expectedStatusCode int) ([]byte, error)

RemoveAdmin removes an existing admin and checks the received HTTP Status code against expectedStatusCode.

func RemoveDefenderHostByIP

func RemoveDefenderHostByIP(ip string, expectedStatusCode int) ([]byte, error)

RemoveDefenderHostByIP removes the host with the given IP from the defender list

func RemoveFolder

func RemoveFolder(folder vfs.BaseVirtualFolder, expectedStatusCode int) ([]byte, error)

RemoveFolder removes an existing user and checks the received HTTP Status code against expectedStatusCode.

func RemoveGroup added in v2.3.0

func RemoveGroup(group dataprovider.Group, expectedStatusCode int) ([]byte, error)

RemoveGroup removes an existing group and checks the received HTTP Status code against expectedStatusCode.

func RemoveUser

func RemoveUser(user dataprovider.User, expectedStatusCode int) ([]byte, error)

RemoveUser removes an existing user and checks the received HTTP Status code against expectedStatusCode.

func SetBaseURL

func SetBaseURL(url string)

SetBaseURL sets the base url to use for HTTP requests. Default URL is "http://127.0.0.1:8080"

func SetJWTToken

func SetJWTToken(token string)

SetJWTToken sets the JWT token to use

func StartFolderQuotaScan

func StartFolderQuotaScan(folder vfs.BaseVirtualFolder, expectedStatusCode int) ([]byte, error)

StartFolderQuotaScan start a new quota scan for the given folder and checks the received HTTP Status code against expectedStatusCode.

func StartQuotaScan

func StartQuotaScan(user dataprovider.User, expectedStatusCode int) ([]byte, error)

StartQuotaScan starts a new quota scan for the given user and checks the received HTTP Status code against expectedStatusCode.

func StartRetentionCheck

func StartRetentionCheck(username string, retention []common.FolderRetention, expectedStatusCode int) ([]byte, error)

StartRetentionCheck starts a new retention check

func UnbanIP

func UnbanIP(ip string, expectedStatusCode int) error

UnbanIP unbans the given IP address

func UpdateAPIKey

func UpdateAPIKey(apiKey dataprovider.APIKey, expectedStatusCode int) (dataprovider.APIKey, []byte, error)

UpdateAPIKey updates an existing API key and checks the received HTTP Status code against expectedStatusCode

func UpdateAdmin

func UpdateAdmin(admin dataprovider.Admin, expectedStatusCode int) (dataprovider.Admin, []byte, error)

UpdateAdmin updates an existing admin and checks the received HTTP Status code against expectedStatusCode

func UpdateFolder

func UpdateFolder(folder vfs.BaseVirtualFolder, expectedStatusCode int) (vfs.BaseVirtualFolder, []byte, error)

UpdateFolder updates an existing folder and checks the received HTTP Status code against expectedStatusCode.

func UpdateFolderQuotaUsage

func UpdateFolderQuotaUsage(folder vfs.BaseVirtualFolder, mode string, expectedStatusCode int) ([]byte, error)

UpdateFolderQuotaUsage updates the folder used quota limits and checks the received HTTP Status code against expectedStatusCode.

func UpdateGroup added in v2.3.0

func UpdateGroup(group dataprovider.Group, expectedStatusCode int) (dataprovider.Group, []byte, error)

UpdateGroup updates an existing group and checks the received HTTP Status code against expectedStatusCode

func UpdateQuotaUsage

func UpdateQuotaUsage(user dataprovider.User, mode string, expectedStatusCode int) ([]byte, error)

UpdateQuotaUsage updates the user used quota limits and checks the received HTTP Status code against expectedStatusCode.

func UpdateTransferQuotaUsage added in v2.3.0

func UpdateTransferQuotaUsage(user dataprovider.User, mode string, expectedStatusCode int) ([]byte, error)

UpdateTransferQuotaUsage updates the user used transfer quota limits and checks the received HTTP Status code against expectedStatusCode.

func UpdateUser

func UpdateUser(user dataprovider.User, expectedStatusCode int, disconnect string) (dataprovider.User, []byte, error)

UpdateUser updates an existing user and checks the received HTTP Status code against expectedStatusCode.

func UpdateUserWithJSON

func UpdateUserWithJSON(user dataprovider.User, expectedStatusCode int, disconnect string, userAsJSON []byte) (dataprovider.User, []byte, error)

UpdateUserWithJSON update a user using the provided JSON as POST body

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL