github.com/grailbio/base@v0.0.11/cmdutil/access_test.go (about) 1 // Copyright 2018 GRAIL, Inc. All rights reserved. 2 // Use of this source code is governed by the Apache-2.0 3 // license that can be found in the LICENSE file. 4 5 //go:build !unit 6 // +build !unit 7 8 package cmdutil_test 9 10 import ( 11 "flag" 12 "path/filepath" 13 "strings" 14 "testing" 15 16 "github.com/grailbio/base/cmdutil" 17 "github.com/grailbio/testutil" 18 "v.io/x/ref/lib/security" 19 _ "v.io/x/ref/runtime/factories/library" 20 "v.io/x/ref/test" 21 ) 22 23 func TestCheckAccess(t *testing.T) { 24 _ = flag.Set("v23.credentials", "") 25 dir, cleanup := testutil.TempDir(t, "", "check-access") 26 defer cleanup() 27 cdir := filepath.Join(dir, "creds") 28 ctx, shutdown := test.V23Init() 29 defer shutdown() 30 _, err := security.CreatePersistentPrincipal(cdir, nil) 31 if err != nil { 32 t.Fatal(err) 33 } 34 _, err = cmdutil.CheckAccess(ctx) 35 if err == nil || !strings.Contains(err.Error(), "credentials are not set") { 36 t.Fatalf("missing or wrong error: %v", err) 37 } 38 // TODO: test for blessings being current. 39 }