mirror of
https://github.com/juanfont/headscale.git
synced 2024-12-30 00:09:42 +01:00
Linting fixes
This commit is contained in:
parent
7a171cf5ea
commit
083d2a871c
@ -12,6 +12,14 @@ import (
|
|||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
errMockOidcClientIDNotDefined = Error("MOCKOIDC_CLIENT_ID not defined")
|
||||||
|
errMockOidcClientSecretNotDefined = Error("MOCKOIDC_CLIENT_SECRET not defined")
|
||||||
|
errMockOidcPortNotDefined = Error("MOCKOIDC_PORT not defined")
|
||||||
|
accessTTL = 10 * time.Minute
|
||||||
|
refreshTTL = 60 * time.Minute
|
||||||
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.AddCommand(mockOidcCmd)
|
rootCmd.AddCommand(mockOidcCmd)
|
||||||
}
|
}
|
||||||
@ -32,15 +40,15 @@ var mockOidcCmd = &cobra.Command{
|
|||||||
func mockOIDC() error {
|
func mockOIDC() error {
|
||||||
clientID := os.Getenv("MOCKOIDC_CLIENT_ID")
|
clientID := os.Getenv("MOCKOIDC_CLIENT_ID")
|
||||||
if clientID == "" {
|
if clientID == "" {
|
||||||
return fmt.Errorf("MOCKOIDC_CLIENT_ID not set")
|
return errMockOidcClientIDNotDefined
|
||||||
}
|
}
|
||||||
clientSecret := os.Getenv("MOCKOIDC_CLIENT_SECRET")
|
clientSecret := os.Getenv("MOCKOIDC_CLIENT_SECRET")
|
||||||
if clientSecret == "" {
|
if clientSecret == "" {
|
||||||
return fmt.Errorf("MOCKOIDC_CLIENT_SECRET not set")
|
return errMockOidcClientSecretNotDefined
|
||||||
}
|
}
|
||||||
portStr := os.Getenv("MOCKOIDC_PORT")
|
portStr := os.Getenv("MOCKOIDC_PORT")
|
||||||
if portStr == "" {
|
if portStr == "" {
|
||||||
return fmt.Errorf("MOCKOIDC_PORT not set")
|
return errMockOidcPortNotDefined
|
||||||
}
|
}
|
||||||
|
|
||||||
port, err := strconv.Atoi(portStr)
|
port, err := strconv.Atoi(portStr)
|
||||||
@ -53,13 +61,16 @@ func mockOIDC() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
ln, err := net.Listen("tcp", fmt.Sprintf("mockoidc:%d", port))
|
listener, err := net.Listen("tcp", fmt.Sprintf("mockoidc:%d", port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
mock.Start(ln, nil)
|
err = mock.Start(listener, nil)
|
||||||
log.Info().Msgf("Mock OIDC server listening on %s", ln.Addr().String())
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
log.Info().Msgf("Mock OIDC server listening on %s", listener.Addr().String())
|
||||||
log.Info().Msgf("Issuer: %s", mock.Issuer())
|
log.Info().Msgf("Issuer: %s", mock.Issuer())
|
||||||
c := make(chan struct{})
|
c := make(chan struct{})
|
||||||
<-c
|
<-c
|
||||||
@ -76,8 +87,8 @@ func getMockOIDC(clientID string, clientSecret string) (*mockoidc.MockOIDC, erro
|
|||||||
mock := mockoidc.MockOIDC{
|
mock := mockoidc.MockOIDC{
|
||||||
ClientID: clientID,
|
ClientID: clientID,
|
||||||
ClientSecret: clientSecret,
|
ClientSecret: clientSecret,
|
||||||
AccessTTL: time.Duration(10) * time.Minute,
|
AccessTTL: accessTTL,
|
||||||
RefreshTTL: time.Duration(60) * time.Minute,
|
RefreshTTL: refreshTTL,
|
||||||
CodeChallengeMethodsSupported: []string{"plain", "S256"},
|
CodeChallengeMethodsSupported: []string{"plain", "S256"},
|
||||||
Keypair: keypair,
|
Keypair: keypair,
|
||||||
SessionStore: mockoidc.NewSessionStore(),
|
SessionStore: mockoidc.NewSessionStore(),
|
||||||
|
@ -225,7 +225,7 @@ oidc:
|
|||||||
client := &http.Client{Transport: insecureTransport}
|
client := &http.Client{Transport: insecureTransport}
|
||||||
resp, err := client.Get(url)
|
resp, err := client.Get(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("headscale for embedded OIDC tests is not ready: %s\n", err)
|
log.Printf("headscale for embedded OIDC tests is not ready: %s\n", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user