Skip to content

Commit

Permalink
pleasing linters
Browse files Browse the repository at this point in the history
Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
  • Loading branch information
eckelj committed Feb 16, 2024
1 parent 70507f3 commit 6fa955a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
12 changes: 11 additions & 1 deletion service/firmware_test.go
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
4 changes: 2 additions & 2 deletions service/router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ import (
)

func TestTestnetModeTrue(t *testing.T) {
t.Parallel()
cfg := config.DefaultConfig()
cfg.TestnetMode = true
s := service.NewTrustAnchorAttestationService(cfg)

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))

}
1 change: 0 additions & 1 deletion service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 6fa955a

Please sign in to comment.