cicd: fix tests
This commit is contained in:
parent
2cd739c3b4
commit
fbbf168e88
|
|
@ -119,7 +119,7 @@ func buildChoices(choices []config.ActionArgumentChoice) []*pb.ActionArgumentCho
|
|||
|
||||
func createPublicID(action *config.Action, entityPrefix string) string {
|
||||
h := sha256.New()
|
||||
h.Write([]byte(action.ID+"."+entityPrefix))
|
||||
h.Write([]byte(action.ID + "." + entityPrefix))
|
||||
|
||||
return fmt.Sprintf("%x", h.Sum(nil))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,28 +86,7 @@ func testBase(t *testing.T, expire int64, expectCode int) {
|
|||
})
|
||||
|
||||
// make server and attach handler
|
||||
srv := &http.Server{Handler: cors.AllowCors(mux)}
|
||||
lis, _ := net.Listen("tcp", ":1337")
|
||||
|
||||
/*
|
||||
if err != nil {
|
||||
t.Errorf("Could not listen %v", err)
|
||||
}
|
||||
|
||||
if srv == nil {
|
||||
y.Errorf("srv is nil. Could not listen %v", err)
|
||||
}
|
||||
*/
|
||||
|
||||
go func() {
|
||||
if lis == nil {
|
||||
t.Errorf("couldn't start server: listener is null")
|
||||
} else {
|
||||
if err := srv.Serve(lis); err != nil {
|
||||
t.Errorf("couldn't start server: %v", err)
|
||||
}
|
||||
}
|
||||
}()
|
||||
setupTestingServer(mux, t)
|
||||
|
||||
// make http client and send request to myself
|
||||
client := &http.Client{}
|
||||
|
|
@ -130,6 +109,32 @@ func testBase(t *testing.T, expire int64, expectCode int) {
|
|||
}
|
||||
}
|
||||
|
||||
func setupTestingServer(mux *runtime.ServeMux, t *testing.T) {
|
||||
lis, err := net.Listen("tcp", ":1337")
|
||||
|
||||
if err != nil || lis == nil {
|
||||
t.Errorf("Could not listen %v %v", err, lis)
|
||||
return
|
||||
}
|
||||
|
||||
srv := &http.Server{Handler: cors.AllowCors(mux)}
|
||||
|
||||
go startTestingServer(lis, srv, t)
|
||||
}
|
||||
|
||||
func startTestingServer(lis net.Listener, srv *http.Server, t *testing.T) {
|
||||
if srv == nil {
|
||||
t.Errorf("srv is nil. Could not listen")
|
||||
return
|
||||
}
|
||||
|
||||
go func() {
|
||||
if err := srv.Serve(lis); err != nil {
|
||||
t.Errorf("couldn't start server: %v", err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
func TestJWTSignatureVerificationSucceeds(t *testing.T) {
|
||||
// testBase(t, 1000, 200)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue