diff --git a/internal/cli/app_test.go b/internal/cli/app_test.go index 73cd943..fb75aa7 100644 --- a/internal/cli/app_test.go +++ b/internal/cli/app_test.go @@ -964,9 +964,8 @@ base_url = "https://gitea.lclr.dev" for _, needle := range []string{ "[OK] config: config file is readable", "[OK] profile: required profile values are resolved", - "[OK] password: stored password is present", "[OK] connectivity: IMAP server is reachable", - "Summary: 5 ok, 0 warning(s), 0 failure(s), 5 total", + "Summary: 4 ok, 0 warning(s), 0 failure(s), 4 total", } { if !strings.Contains(text, needle) { t.Fatalf("output = %q, want substring %q", text, needle) @@ -1018,7 +1017,7 @@ func TestAppRunDoctorReturnsErrorWhenChecksFail(t *testing.T) { if !strings.Contains(err.Error(), "doctor checks failed") { t.Fatalf("unexpected error: %v", err) } - if !strings.Contains(output.String(), "[FAIL] password: stored password is missing") { + if !strings.Contains(output.String(), "[FAIL] connectivity: cannot load IMAP credentials") { t.Fatalf("unexpected output: %q", output.String()) } } @@ -1065,7 +1064,7 @@ func TestAppRunDoctorAcceptsPasswordFromEnvironment(t *testing.T) { if err := app.Run([]string{"doctor"}); err != nil { t.Fatalf("doctor returned error: %v", err) } - if !strings.Contains(output.String(), "[OK] password: password is provided via environment") { + if !strings.Contains(output.String(), "[OK] connectivity: IMAP server is reachable") { t.Fatalf("unexpected output: %q", output.String()) } } diff --git a/internal/cli/doctor.go b/internal/cli/doctor.go index 2e8b794..5d9f08b 100644 --- a/internal/cli/doctor.go +++ b/internal/cli/doctor.go @@ -2,7 +2,6 @@ package cli import ( "context" - "errors" "fmt" "os" "time" @@ -33,7 +32,6 @@ func (a *App) runDoctor(ctx context.Context, args []string) error { ConnectivityCheck: a.doctorConnectivityCheck(profileFlag), ExtraChecks: []frameworkcli.DoctorCheck{ a.doctorRequiredProfileFieldsCheck(profileFlag), - a.doctorPasswordCheck(profileFlag), }, }) if err := frameworkcli.RenderDoctorReport(a.stdout, report); err != nil { @@ -86,66 +84,6 @@ func (a *App) doctorRequiredProfileFieldsCheck(profileFlag string) frameworkcli. } } -func (a *App) doctorPasswordCheck(profileFlag string) frameworkcli.DoctorCheck { - return func(context.Context) frameworkcli.DoctorResult { - profileName := a.resolveDoctorProfileName(profileFlag) - store, err := a.openSecretStore() - if err != nil { - return frameworkcli.DoctorResult{ - Name: "password", - Status: frameworkcli.DoctorStatusFail, - Summary: "cannot inspect stored password", - Detail: err.Error(), - } - } - - resolution, err := resolveCredentialFields( - ProfileConfig{}, - store, - passwordOnlyFieldSpecs(profileName), - ) - if err != nil { - var missingErr *frameworkcli.MissingRequiredValuesError - if errors.As(err, &missingErr) { - return frameworkcli.DoctorResult{ - Name: "password", - Status: frameworkcli.DoctorStatusFail, - Summary: "stored password is missing", - Detail: fmt.Sprintf( - "set %q or secret %q", - passwordEnv, - passwordSecretName(profileName), - ), - } - } - - return frameworkcli.DoctorResult{ - Name: "password", - Status: frameworkcli.DoctorStatusFail, - Summary: "cannot read stored password", - Detail: err.Error(), - } - } - - password, _ := resolution.Get("password") - if password.Source == frameworkcli.SourceEnv { - return frameworkcli.DoctorResult{ - Name: "password", - Status: frameworkcli.DoctorStatusOK, - Summary: "password is provided via environment", - Detail: fmt.Sprintf("variable %q", passwordEnv), - } - } - - return frameworkcli.DoctorResult{ - Name: "password", - Status: frameworkcli.DoctorStatusOK, - Summary: "stored password is present", - Detail: fmt.Sprintf("secret %q", passwordSecretName(profileName)), - } - } -} - func (a *App) doctorConnectivityCheck(profileFlag string) frameworkcli.DoctorCheck { return func(parent context.Context) frameworkcli.DoctorResult { ctx, cancel := context.WithTimeout(parent, 35*time.Second)