Documentation ¶
Overview ¶
Package logintest provide a command for testing the login.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Command = &cli.Command{ Name: "login-test", Usage: "Test the login.", Action: func(cCtx *cli.Context) error { ctx, cancel := context.WithCancel(cCtx.Context) cleanChan := make(chan os.Signal, 1) signal.Notify(cleanChan, os.Interrupt, syscall.SIGINT, syscall.SIGTERM) go func() { <-cleanChan cancel() }() jar, err := cookiejar.New(&cookiejar.Options{}) if err != nil { log.Panic().Err(err).Msg("failed to create cookie jar") } hclient := &http.Client{Jar: jar, Timeout: time.Minute} usernameInput := textinput.New("Username/Email:") username, err := usernameInput.RunPrompt() if err != nil { return err } passwordInput := textinput.New("Password:") passwordInput.Hidden = true password, err := passwordInput.RunPrompt() if err != nil { return err } client := api.NewClient(hclient, &secret.Static{ SavedCredentials: api.SavedCredentials{ Username: username, Password: password, }, }) if err := client.Login(ctx); err != nil { log.Err(err). Msg("failed to login to withny") return err } log.Info().Msg("Login successful") return nil }, }
Command is the command for logging in and testing the login.
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.