package cli

import (
	"testing"
)

// TestAuthStatusNotAuthenticated verifies auth status reports
// "not authenticated" when no credentials exist.
func TestAuthStatusNotAuthenticated(t *testing.T) {
	dir := t.TempDir()
	t.Setenv("ORCA_HOME", dir)
	resetRootFlags(t)
	rootCmd.SetArgs([]string{"auth", "status"})
	// auth status should not error on missing credentials.
	if err := rootCmd.Execute(); err != nil {
		t.Errorf("auth status on missing creds: %v", err)
	}
}

// TestAuthLogoutNoCreds verifies logout succeeds even with no creds.
func TestAuthLogoutNoCreds(t *testing.T) {
	dir := t.TempDir()
	t.Setenv("ORCA_HOME", dir)
	resetRootFlags(t)
	rootCmd.SetArgs([]string{"auth", "logout"})
	if err := rootCmd.Execute(); err != nil {
		t.Errorf("auth logout with no creds: %v", err)
	}
}

// TestAuthInitIDPRequiresRPID verifies --rp-id is required.
func TestAuthInitIDPRequiresRPID(t *testing.T) {
	dir := t.TempDir()
	t.Setenv("ORCA_HOME", dir)
	resetRootFlags(t)
	rootCmd.SetArgs([]string{"auth", "init-idp"})
	err := rootCmd.Execute()
	if err == nil {
		t.Error("auth init-idp without --rp-id should error")
	}
}

// TestAuthLoginRequiresIssuer verifies --issuer is required.
func TestAuthLoginRequiresIssuer(t *testing.T) {
	dir := t.TempDir()
	t.Setenv("ORCA_HOME", dir)
	resetRootFlags(t)
	rootCmd.SetArgs([]string{"auth", "login"})
	err := rootCmd.Execute()
	if err == nil {
		t.Error("auth login without --issuer should error")
	}
}
