From 6fa955aefc29d976ee6f6d15bd52238fa6bbd2f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Eckel?= Date: Fri, 16 Feb 2024 12:06:13 +0100 Subject: [PATCH] pleasing linters MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jürgen Eckel --- service/firmware_test.go | 12 +++++++++++- service/router_test.go | 4 ++-- service/service.go | 1 - 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/service/firmware_test.go b/service/firmware_test.go index 814d7d6..943f910 100644 --- a/service/firmware_test.go +++ b/service/firmware_test.go @@ -1,19 +1,29 @@ package service_test import ( + "context" "io" "net/http" "testing" + "time" "github.com/rddl-network/ta_attest/service" "github.com/stretchr/testify/assert" ) func TestFirmwareHandling(t *testing.T) { + t.Parallel() privKey, _ := service.GenerateNewKeyPair() firmwareURL := "https://github.com/rddl-network/Tasmota/releases/download/rddl-v0.40.1/tasmota32-rddl.bin" - resp, err := http.Get(firmwareURL) + ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) // 30 seconds timeout + defer cancel() + + req, err := http.NewRequestWithContext(ctx, http.MethodGet, firmwareURL, nil) + assert.NoError(t, err) + + client := &http.Client{} + resp, err := client.Do(req) assert.NoError(t, err) assert.Equal(t, http.StatusOK, resp.StatusCode) diff --git a/service/router_test.go b/service/router_test.go index eb6e476..f3ff081 100644 --- a/service/router_test.go +++ b/service/router_test.go @@ -9,6 +9,7 @@ import ( ) func TestTestnetModeTrue(t *testing.T) { + t.Parallel() cfg := config.DefaultConfig() cfg.TestnetMode = true s := service.NewTrustAnchorAttestationService(cfg) @@ -16,14 +17,13 @@ func TestTestnetModeTrue(t *testing.T) { routes := s.GetRoutes() assert.Equal(t, 2, len(routes)) assert.Equal(t, "/register/:pubkey", routes[1].Path) - } func TestTestnetModeFalse(t *testing.T) { + t.Parallel() cfg := config.DefaultConfig() s := service.NewTrustAnchorAttestationService(cfg) routes := s.GetRoutes() assert.Equal(t, 1, len(routes)) - } diff --git a/service/service.go b/service/service.go index 44eba43..60980e0 100644 --- a/service/service.go +++ b/service/service.go @@ -44,7 +44,6 @@ func (s *TAAService) loadFirmwares() { } func (s *TAAService) startWebService() error { - addr := fmt.Sprintf("%s:%d", s.cfg.ServiceBind, s.cfg.ServicePort) err := s.router.Run(addr)