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