mirror of https://github.com/hashicorp/boundary
parent
80c5c08fe1
commit
9ebbcf901a
@ -1,7 +1,5 @@
|
||||
FROM golang:1.14
|
||||
|
||||
RUN "git config --global url.ssh://git@github.com/.insteadOf https://github.com/"
|
||||
|
||||
WORKDIR /watchtower
|
||||
|
||||
COPY . .
|
||||
|
||||
@ -0,0 +1,21 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
const cmdPath = "/tmp/watchtower"
|
||||
|
||||
func Run(args ...string) ([]byte, error) {
|
||||
return exec.Command(cmdPath, args...).Output()
|
||||
}
|
||||
|
||||
func Start(args ...string) (*exec.Cmd, error) {
|
||||
cmd := exec.Command(cmdPath, args...)
|
||||
err := cmd.Start()
|
||||
if err != nil {
|
||||
return cmd, err
|
||||
}
|
||||
|
||||
return cmd, nil
|
||||
}
|
||||
Binary file not shown.
@ -0,0 +1,44 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/watchtower/e2e/cli"
|
||||
)
|
||||
|
||||
func TestDevServerStart(t *testing.T) {
|
||||
cmd, err := cli.Start("dev")
|
||||
if err != nil {
|
||||
t.Errorf("err starting in dev mode: '%s'", err.Error())
|
||||
}
|
||||
|
||||
go func() {
|
||||
if err := cmd.Wait(); err != nil {
|
||||
t.Error(err.Error())
|
||||
}
|
||||
}()
|
||||
|
||||
time.Sleep(3 * time.Second)
|
||||
if err := cmd.Process.Kill(); err != nil {
|
||||
t.Errorf("error sending kill to dev server: %s", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func TestAuthenticate(t *testing.T) {
|
||||
serverCmd, err := cli.Start("dev")
|
||||
if err != nil {
|
||||
t.Errorf("err starting in dev mode: %s", err.Error())
|
||||
}
|
||||
defer serverCmd.Process.Kill()
|
||||
time.Sleep(3 * time.Second)
|
||||
|
||||
authCmdOut, err := cli.Run("authenticate", "password", "-name", "test", "-method-id", "am_1234567890")
|
||||
if err != nil {
|
||||
t.Errorf("err authenticating: %s", err.Error())
|
||||
}
|
||||
|
||||
fmt.Printf("%s\n", authCmdOut)
|
||||
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
pushd ../
|
||||
make dev
|
||||
cp bin/watchtower /tmp/
|
||||
popd
|
||||
|
||||
go test -v
|
||||
Loading…
Reference in new issue