Skip to content

Commit

Permalink
juanfont#2176 Added TLS for AuthApproval test
Browse files Browse the repository at this point in the history
  • Loading branch information
hopleus committed Oct 9, 2024
1 parent 82a13db commit 0da4e2d
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions integration/auth_approval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ package integration

import (
"context"
"crypto/tls"
"fmt"
v1 "github.com/juanfont/headscale/gen/go/headscale/v1"
"github.com/juanfont/headscale/integration/hsic"
"github.com/samber/lo"
"github.com/stretchr/testify/assert"
"io"
"log"
"net/http"
"net/netip"
"net/url"
"strings"
"testing"

v1 "github.com/juanfont/headscale/gen/go/headscale/v1"
"github.com/juanfont/headscale/integration/hsic"
"github.com/samber/lo"
"github.com/stretchr/testify/assert"
)

type AuthApprovalScenario struct {
Expand All @@ -40,6 +40,9 @@ func TestAuthNodeApproval(t *testing.T) {
err = scenario.CreateHeadscaleEnv(
spec,
hsic.WithTestName("approval"),
hsic.WithEmbeddedDERPServerOnly(),
hsic.WithTLS(),
hsic.WithHostnameAsServerURL(),
hsic.WithManualApproveNewNode(),
)
assertNoErrHeadscaleEnv(t, err)
Expand Down Expand Up @@ -237,7 +240,16 @@ func (s *AuthApprovalScenario) runHeadscaleRegister(userStr string, loginURL *ur
loginURL.Host = fmt.Sprintf("%s:8080", headscale.GetIP())
loginURL.Scheme = "http"

httpClient := &http.Client{}
if len(headscale.GetCert()) > 0 {
loginURL.Scheme = "https"
}

tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
httpClient := &http.Client{
Transport: tr,
}
ctx := context.Background()
req, _ := http.NewRequestWithContext(ctx, http.MethodGet, loginURL.String(), nil)
resp, err := httpClient.Do(req)
Expand Down

0 comments on commit 0da4e2d

Please sign in to comment.