mirror of
https://github.com/kopia/kopia.git
synced 2026-01-17 19:07:51 -05:00
* test(general): refactored parsing of server output * test(ui): added experimental end-to-end test using chromedp
43 lines
1.2 KiB
Go
43 lines
1.2 KiB
Go
package testutil
|
|
|
|
import "strings"
|
|
|
|
// Pattern in stderr that `kopia server` uses to pass ephemeral data.
|
|
const (
|
|
serverOutputAddress = "SERVER ADDRESS: "
|
|
serverOutputCertSHA256 = "SERVER CERT SHA256: "
|
|
serverOutputPassword = "SERVER PASSWORD: "
|
|
serverOutputControlPassword = "SERVER CONTROL PASSWORD: "
|
|
)
|
|
|
|
// ServerParameters encapsulates parameters captured by processing stderr of
|
|
// 'kopia server start'.
|
|
type ServerParameters struct {
|
|
BaseURL string
|
|
SHA256Fingerprint string
|
|
Password string
|
|
ServerControlPassword string
|
|
}
|
|
|
|
// ProcessOutput processes output lines from a server that's starting up.
|
|
func (s *ServerParameters) ProcessOutput(l string) bool {
|
|
if strings.HasPrefix(l, serverOutputAddress) {
|
|
s.BaseURL = strings.TrimPrefix(l, serverOutputAddress)
|
|
return false
|
|
}
|
|
|
|
if strings.HasPrefix(l, serverOutputCertSHA256) {
|
|
s.SHA256Fingerprint = strings.TrimPrefix(l, serverOutputCertSHA256)
|
|
}
|
|
|
|
if strings.HasPrefix(l, serverOutputPassword) {
|
|
s.Password = strings.TrimPrefix(l, serverOutputPassword)
|
|
}
|
|
|
|
if strings.HasPrefix(l, serverOutputControlPassword) {
|
|
s.ServerControlPassword = strings.TrimPrefix(l, serverOutputControlPassword)
|
|
}
|
|
|
|
return true
|
|
}
|