aboutsummaryrefslogtreecommitdiff
path: root/http_server_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'http_server_test.go')
-rw-r--r--http_server_test.go48
1 files changed, 27 insertions, 21 deletions
diff --git a/http_server_test.go b/http_server_test.go
index d5cb270..3ad9bd8 100644
--- a/http_server_test.go
+++ b/http_server_test.go
@@ -1,5 +1,5 @@
-// SPDX-FileCopyrightText: 2023 M. Shulhan <ms@kilabit.info>
// SPDX-License-Identifier: GPL-3.0-or-later
+// SPDX-FileCopyrightText: 2023 M. Shulhan <ms@kilabit.info>
package awwan
@@ -48,8 +48,9 @@ func TestHttpServer_Decrypt(t *testing.T) {
}
var httpd *httpServer
+ var serveOpts = ServeOptions{}
- httpd, err = newHTTPServer(aww, nil, ``)
+ httpd, err = newHTTPServer(aww, serveOpts)
if err != nil {
t.Fatal(err)
}
@@ -132,8 +133,9 @@ func TestHttpServer_Encrypt(t *testing.T) {
}
var httpd *httpServer
+ var serveOpts = ServeOptions{}
- httpd, err = newHTTPServer(aww, nil, ``)
+ httpd, err = newHTTPServer(aww, serveOpts)
if err != nil {
t.Fatal(err)
}
@@ -211,13 +213,14 @@ func TestHttpServer_Execute(t *testing.T) {
t.Fatal(err)
}
- var (
- address = testGenerateServerAddress()
- isDev = false
- )
+ var serveOpts = ServeOptions{
+ ServerOptions: libhttp.ServerOptions{
+ Address: testGenerateServerAddress(),
+ },
+ }
go func() {
- err = aww.Serve(nil, address, isDev)
+ err = aww.Serve(serveOpts)
if err != nil {
log.Fatal(err)
}
@@ -226,14 +229,14 @@ func TestHttpServer_Execute(t *testing.T) {
aww.Stop()
})
- err = libnet.WaitAlive(`tcp`, address, 10*time.Second)
+ err = libnet.WaitAlive(`tcp`, serveOpts.Address, 10*time.Second)
if err != nil {
t.Fatal(err)
}
var (
clientOpts = libhttp.ClientOptions{
- ServerURL: `http://` + address,
+ ServerURL: `http://` + serveOpts.Address,
}
reqJSON = tdata.Input[`local:/local.aww:1-`]
@@ -284,7 +287,8 @@ func TestHttpServer_Execute(t *testing.T) {
// Tail the execution output.
var ssec = sseclient.Client{
- Endpoint: fmt.Sprintf(`http://%s%s?id=%s`, address, pathAwwanAPIExecuteTail, execResp.ID),
+ Endpoint: fmt.Sprintf(`http://%s%s?id=%s`, serveOpts.Address,
+ pathAwwanAPIExecuteTail, execResp.ID),
}
err = ssec.Connect(nil)
@@ -339,13 +343,13 @@ func TestHttpServer_ExecuteCancel(t *testing.T) {
t.Fatal(err)
}
- var (
- address = testGenerateServerAddress()
- isDev = false
- )
-
+ var serveOpts = ServeOptions{
+ ServerOptions: libhttp.ServerOptions{
+ Address: testGenerateServerAddress(),
+ },
+ }
go func() {
- err = aww.Serve(nil, address, isDev)
+ err = aww.Serve(serveOpts)
if err != nil {
log.Fatal(err)
}
@@ -354,14 +358,14 @@ func TestHttpServer_ExecuteCancel(t *testing.T) {
aww.Stop()
})
- err = libnet.WaitAlive(`tcp`, address, 10*time.Second)
+ err = libnet.WaitAlive(`tcp`, serveOpts.Address, 10*time.Second)
if err != nil {
t.Fatal(err)
}
var (
clientOpts = libhttp.ClientOptions{
- ServerURL: `http://` + address,
+ ServerURL: `http://` + serveOpts.Address,
}
reqJSON = tdata.Input[`local:/cancel.aww:1-`]
@@ -412,7 +416,8 @@ func TestHttpServer_ExecuteCancel(t *testing.T) {
// Tail the execution output.
var ssec = sseclient.Client{
- Endpoint: fmt.Sprintf(`http://%s%s?id=%s`, address, pathAwwanAPIExecuteTail, execResp.ID),
+ Endpoint: fmt.Sprintf(`http://%s%s?id=%s`, serveOpts.Address,
+ pathAwwanAPIExecuteTail, execResp.ID),
}
err = ssec.Connect(nil)
@@ -490,8 +495,9 @@ func TestHttpServer_FSGet(t *testing.T) {
}
var httpd *httpServer
+ var serveOpts = ServeOptions{}
- httpd, err = newHTTPServer(aww, nil, ``)
+ httpd, err = newHTTPServer(aww, serveOpts)
if err != nil {
t.Fatal(err)
}