@@ -25,12 +25,12 @@ func TestAuthAddM365UsesOAuthAndStoresToken(t *testing.T) {
2525 openSecretsStore = func () (secrets.Store , error ) { return store , nil }
2626 ensureKeychainAccess = func () error { return nil }
2727 authorizeM365 = func (context.Context , msauth.AuthorizeOptions ) (msauth.AuthorizeResult , error ) {
28- return msauth.AuthorizeResult {Email : "bernardo@hapvida .com.br " , RefreshToken : "m365-refresh-token" }, nil
28+ return msauth.AuthorizeResult {Email : "pilot@example .com" , RefreshToken : "m365-refresh-token" }, nil
2929 }
3030
3131 out := captureStdout (t , func () {
3232 _ = captureStderr (t , func () {
33- if err := Execute ([]string {"--json" , "auth" , "add" , "bernardo@hapvida .com.br " , "--services" , "m365" , "--readonly" }); err != nil {
33+ if err := Execute ([]string {"--json" , "auth" , "add" , "pilot@example .com" , "--services" , "m365" , "--readonly" }); err != nil {
3434 t .Fatalf ("auth add m365: %v" , err )
3535 }
3636 })
@@ -43,7 +43,7 @@ func TestAuthAddM365UsesOAuthAndStoresToken(t *testing.T) {
4343 if payload ["provider" ] != "microsoft_graph" || payload ["stored" ] != true {
4444 t .Fatalf ("unexpected output: %#v" , payload )
4545 }
46- tok , err := store .GetToken (msauth .ClientName , "bernardo@hapvida .com.br " )
46+ tok , err := store .GetToken (msauth .ClientName , "pilot@example .com" )
4747 if err != nil {
4848 t .Fatalf ("stored m365 token: %v" , err )
4949 }
@@ -57,7 +57,7 @@ func TestAuthAddM365UsesOAuthAndStoresToken(t *testing.T) {
5757
5858func TestAuthAddM365RequiresReadonly (t * testing.T ) {
5959 _ = captureStderr (t , func () {
60- err := Execute ([]string {"--json" , "auth" , "add" , "bernardo@hapvida .com.br " , "--services" , "m365" })
60+ err := Execute ([]string {"--json" , "auth" , "add" , "pilot@example .com" , "--services" , "m365" })
6161 if err == nil {
6262 t .Fatal ("expected missing --readonly to fail closed" )
6363 }
@@ -67,23 +67,16 @@ func TestAuthAddM365RequiresReadonly(t *testing.T) {
6767 })
6868}
6969
70- func TestAuthAddM365RemoteStepOnePrintsMicrosoftURL (t * testing.T ) {
71- origURL := m365ManualAuthURL
72- t .Cleanup (func () { m365ManualAuthURL = origURL })
73- m365ManualAuthURL = func (context.Context , msauth.ManualAuthURLOptions ) (msauth.ManualAuthURLResult , error ) {
74- return msauth.ManualAuthURLResult {URL : "https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize?client_id=test" , State : "state" }, nil
75- }
76-
77- out := captureStdout (t , func () {
78- _ = captureStderr (t , func () {
79- if err := Execute ([]string {"--json" , "auth" , "add" , "bernardo@hapvida.com.br" , "--services" , "m365" , "--readonly" , "--remote" , "--step" , "1" }); err != nil {
80- t .Fatalf ("remote step 1: %v" , err )
81- }
82- })
70+ func TestAuthAddM365RemoteModeFailsClosed (t * testing.T ) {
71+ _ = captureStderr (t , func () {
72+ err := Execute ([]string {"--json" , "auth" , "add" , "pilot@example.com" , "--services" , "m365" , "--readonly" , "--remote" , "--step" , "1" })
73+ if err == nil {
74+ t .Fatal ("expected remote m365 auth to fail closed" )
75+ }
76+ if ! strings .Contains (err .Error (), "remote auth is not supported yet" ) {
77+ t .Fatalf ("unexpected error: %v" , err )
78+ }
8379 })
84- if ! strings .Contains (out , "login.microsoftonline.com" ) || ! strings .Contains (out , "auth_url" ) {
85- t .Fatalf ("unexpected output: %s" , out )
86- }
8780}
8881
8982func TestAuthManageM365PrintURLIsNonTechnicalOAuthHandoff (t * testing.T ) {
0 commit comments