Skip to content

Commit

Permalink
Merge pull request #3 from hopleus/hotfix/use-tls-for-relogin-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hopleus authored Oct 13, 2024
2 parents 0602304 + 1ebb1f5 commit 320524c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
5 changes: 5 additions & 0 deletions integration/auth_oidc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func TestOIDCAuthenticationPingAll(t *testing.T) {
spec,
hsic.WithTestName("oidcauthping"),
hsic.WithConfigEnv(oidcMap),
hsic.WithTLS(),
hsic.WithHostnameAsServerURL(),
hsic.WithFileInContainer("/tmp/hs_client_oidc_secret", []byte(oidcConfig.ClientSecret)),
)
Expand Down Expand Up @@ -299,6 +300,10 @@ func (s *AuthOIDCScenario) runTailscaleUp(
loginURL.Host = fmt.Sprintf("%s:8080", headscale.GetIP())
loginURL.Scheme = "http"

if len(headscale.GetCert()) > 0 {
loginURL.Scheme = "https"
}

insecureTransport := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, // nolint
}
Expand Down
20 changes: 18 additions & 2 deletions integration/auth_web_flow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package integration

import (
"context"
"crypto/tls"
"errors"
"fmt"
"io"
Expand Down Expand Up @@ -41,7 +42,13 @@ func TestAuthWebFlowAuthenticationPingAll(t *testing.T) {
"user2": len(MustTestVersions),
}

err = scenario.CreateHeadscaleEnv(spec, hsic.WithTestName("webauthping"))
err = scenario.CreateHeadscaleEnv(
spec,
hsic.WithTestName("webauthping"),
hsic.WithEmbeddedDERPServerOnly(),
hsic.WithTLS(),
hsic.WithHostnameAsServerURL(),
)
assertNoErrHeadscaleEnv(t, err)

allClients, err := scenario.ListTailscaleClients()
Expand Down Expand Up @@ -275,7 +282,16 @@ func (s *AuthWebFlowScenario) runHeadscaleRegister(userStr string, loginURL *url
loginURL.Host = fmt.Sprintf("%s:8080", headscale.GetIP())
loginURL.Scheme = "http"

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

insecureTransport := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, // nolint
}
httpClient := &http.Client{
Transport: insecureTransport,
}
ctx := context.Background()
req, _ := http.NewRequestWithContext(ctx, http.MethodGet, loginURL.String(), nil)
resp, err := httpClient.Do(req)
Expand Down
9 changes: 8 additions & 1 deletion integration/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,14 @@ func TestPreAuthKeyCorrectUserLoggedInCommand(t *testing.T) {
user2: 0,
}

err = scenario.CreateHeadscaleEnv(spec, []tsic.Option{}, hsic.WithTestName("clipak"))
err = scenario.CreateHeadscaleEnv(
spec,
[]tsic.Option{},
hsic.WithTestName("clipak"),
hsic.WithEmbeddedDERPServerOnly(),
hsic.WithTLS(),
hsic.WithHostnameAsServerURL(),
)
assertNoErr(t, err)

headscale, err := scenario.Headscale()
Expand Down

0 comments on commit 320524c

Please sign in to comment.