httpdtest

package
v2.0.0-...-83f77b2 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2022 License: AGPL-3.0 Imports: 30 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 AddEventAction

func AddEventAction(action dataprovider.BaseEventAction, expectedStatusCode int) (dataprovider.BaseEventAction, []byte, error)

AddEventAction adds a new event action

func AddEventRule

func AddEventRule(rule dataprovider.EventRule, expectedStatusCode int) (dataprovider.EventRule, []byte, error)

AddEventRule adds a new event rule

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

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 AddRole

func AddRole(role dataprovider.Role, expectedStatusCode int) (dataprovider.Role, []byte, error)

AddRole adds a new role 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 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 GetEventActionByName

func GetEventActionByName(name string, expectedStatusCode int) (dataprovider.BaseEventAction, []byte, error)

GetEventActionByName gets an event action by name and checks the received HTTP Status code against expectedStatusCode.

func GetEventActions

func GetEventActions(limit, offset int64, expectedStatusCode int) ([]dataprovider.BaseEventAction, []byte, error)

GetEventActions returns a list of event actions 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 GetEventRuleByName

func GetEventRuleByName(name string, expectedStatusCode int) (dataprovider.EventRule, []byte, error)

GetEventRuleByName gets an event rule by name and checks the received HTTP Status code against expectedStatusCode.

func GetEventRules

func GetEventRules(limit, offset int64, expectedStatusCode int) ([]dataprovider.EventRule, []byte, error)

GetEventRules returns a list of event rules 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 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

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

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 GetRoleByName

func GetRoleByName(name string, expectedStatusCode int) (dataprovider.Role, []byte, error)

GetRoleByName gets a role by name and checks the received HTTP Status code against expectedStatusCode.

func GetRoles

func GetRoles(limit, offset int64, expectedStatusCode int) ([]dataprovider.Role, []byte, error)

GetRoles returns a list of roles 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 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 RemoveEventAction

func RemoveEventAction(action dataprovider.BaseEventAction, expectedStatusCode int) ([]byte, error)

RemoveEventAction removes an existing action and checks the received HTTP Status code against expectedStatusCode.

func RemoveEventRule

func RemoveEventRule(rule dataprovider.EventRule, expectedStatusCode int) ([]byte, error)

RemoveEventRule removes an existing rule and checks the received HTTP Status code against expectedStatusCode.

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

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

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

func RemoveRole

func RemoveRole(role dataprovider.Role, expectedStatusCode int) ([]byte, error)

RemoveRole removes an existing role 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 []dataprovider.FolderRetention, expectedStatusCode int) ([]byte, error)

StartRetentionCheck starts a new retention check

func StartTestHTTPFs

func StartTestHTTPFs(port int) error

StartTestHTTPFs starts a test HTTP service that implements httpfs and listens on the specified port

func StartTestHTTPFsOverUnixSocket

func StartTestHTTPFsOverUnixSocket(socketPath string) error

StartTestHTTPFsOverUnixSocket starts a test HTTP service that implements httpfs and listens on the specified UNIX domain socket path

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 UpdateEventAction

func UpdateEventAction(action dataprovider.BaseEventAction, expectedStatusCode int) (dataprovider.BaseEventAction, []byte, error)

UpdateEventAction updates an existing event action

func UpdateEventRule

func UpdateEventRule(rule dataprovider.EventRule, expectedStatusCode int) (dataprovider.EventRule, []byte, error)

UpdateEventRule updates an existing event rule

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

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 UpdateRole

func UpdateRole(role dataprovider.Role, expectedStatusCode int) (dataprovider.Role, []byte, error)

UpdateRole updates an existing role and checks the received HTTP Status code against expectedStatusCode

func UpdateTransferQuotaUsage

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