MCPcopy Create free account
hub / github.com/openclaw/gogcli / TestAuthAddCmd_DriveScopeFile

Function TestAuthAddCmd_DriveScopeFile

internal/cmd/auth_add_test.go:593–640  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

591}
592
593func TestAuthAddCmd_DriveScopeFile(t *testing.T) {
594 openSecretsStore, authorizeGoogle, ensureKeychainAccess, fetchAuthorizedIdentity := defaultAuthTestOperations()
595 execute := func(args []string) error {
596 return executeWithRuntime(args, runtimeWithAuthTestOperations(
597 openSecretsStore, authorizeGoogle, ensureKeychainAccess, fetchAuthorizedIdentity,
598 ))
599 }
600
601 ensureKeychainAccess = func(context.Context) error { return nil }
602
603 store := newMemSecretsStore()
604 openSecretsStore = func() (secrets.Store, error) { return store, nil }
605
606 var gotOpts googleauth.AuthorizeOptions
607 authorizeGoogle = func(ctx context.Context, opts googleauth.AuthorizeOptions) (string, error) {
608 gotOpts = opts
609 gotOpts.Services = append([]googleauth.Service(nil), opts.Services...)
610 gotOpts.Scopes = append([]string(nil), opts.Scopes...)
611 return "rt", nil
612 }
613 fetchAuthorizedIdentity = func(context.Context, string, string, []string, time.Duration) (googleauth.Identity, error) {
614 return googleauth.Identity{Email: "user@example.com"}, nil
615 }
616
617 _ = captureStdout(t, func() {
618 _ = captureStderr(t, func() {
619 if err := execute([]string{
620 "--json",
621 "auth",
622 "add",
623 "user@example.com",
624 "--services",
625 "drive",
626 "--drive-scope",
627 "file",
628 }); err != nil {
629 t.Fatalf("Execute: %v", err)
630 }
631 })
632 })
633
634 if !containsStringInSlice(gotOpts.Scopes, "https://www.googleapis.com/auth/drive.file") {
635 t.Fatalf("missing drive.file in %v", gotOpts.Scopes)
636 }
637 if containsStringInSlice(gotOpts.Scopes, "https://www.googleapis.com/auth/drive") {
638 t.Fatalf("unexpected drive in %v", gotOpts.Scopes)
639 }
640}
641
642func TestAuthAddCmd_ReadonlyWithDriveScopeFileRejected(t *testing.T) {
643 err := Execute([]string{"auth", "add", "user@example.com", "--services", "drive", "--readonly", "--drive-scope", "file"})

Callers

nothing calls this directly

Calls 7

executeWithRuntimeFunction · 0.85
newMemSecretsStoreFunction · 0.85
captureStdoutFunction · 0.85
captureStderrFunction · 0.85
containsStringInSliceFunction · 0.85

Tested by

no test coverage detected