2015-03-19 02:36:17 +00:00
|
|
|
package vault
|
|
|
|
|
|
|
|
import (
|
2018-01-19 06:44:44 +00:00
|
|
|
"context"
|
2015-03-19 02:36:17 +00:00
|
|
|
"reflect"
|
2017-02-17 04:09:39 +00:00
|
|
|
"strings"
|
2015-03-19 02:36:17 +00:00
|
|
|
"testing"
|
2015-03-19 17:39:47 +00:00
|
|
|
|
2017-02-17 04:09:39 +00:00
|
|
|
"github.com/hashicorp/vault/helper/jsonutil"
|
2018-09-18 03:03:00 +00:00
|
|
|
"github.com/hashicorp/vault/helper/namespace"
|
2015-03-19 17:39:47 +00:00
|
|
|
"github.com/hashicorp/vault/logical"
|
2015-03-19 02:36:17 +00:00
|
|
|
)
|
|
|
|
|
2018-02-09 19:04:25 +00:00
|
|
|
func TestAuth_ReadOnlyViewDuringMount(t *testing.T) {
|
|
|
|
c, _, _ := TestCoreUnsealed(t)
|
|
|
|
c.credentialBackends["noop"] = func(ctx context.Context, config *logical.BackendConfig) (logical.Backend, error) {
|
|
|
|
err := config.StorageView.Put(ctx, &logical.StorageEntry{
|
|
|
|
Key: "bar",
|
|
|
|
Value: []byte("baz"),
|
|
|
|
})
|
|
|
|
if err == nil || !strings.Contains(err.Error(), logical.ErrSetupReadOnly.Error()) {
|
|
|
|
t.Fatalf("expected a read-only error")
|
|
|
|
}
|
2018-11-07 01:21:24 +00:00
|
|
|
return &NoopBackend{
|
|
|
|
BackendType: logical.TypeCredential,
|
|
|
|
}, nil
|
2018-02-09 19:04:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
me := &MountEntry{
|
|
|
|
Table: credentialTableType,
|
|
|
|
Path: "foo",
|
|
|
|
Type: "noop",
|
|
|
|
}
|
2018-11-05 16:11:32 +00:00
|
|
|
err := c.enableCredential(namespace.RootContext(nil), me)
|
2018-02-09 19:04:25 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("err: %v", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-19 02:36:17 +00:00
|
|
|
func TestCore_DefaultAuthTable(t *testing.T) {
|
2017-01-17 20:43:10 +00:00
|
|
|
c, keys, _ := TestCoreUnsealed(t)
|
2015-03-19 02:36:17 +00:00
|
|
|
verifyDefaultAuthTable(t, c.auth)
|
|
|
|
|
|
|
|
// Start a second core with same physical
|
2015-04-29 01:12:57 +00:00
|
|
|
conf := &CoreConfig{
|
|
|
|
Physical: c.physical,
|
|
|
|
DisableMlock: true,
|
|
|
|
}
|
2015-03-19 02:36:17 +00:00
|
|
|
c2, err := NewCore(conf)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("err: %v", err)
|
|
|
|
}
|
2017-01-17 20:43:10 +00:00
|
|
|
for i, key := range keys {
|
|
|
|
unseal, err := TestCoreUnseal(c2, key)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("err: %v", err)
|
|
|
|
}
|
|
|
|
if i+1 == len(keys) && !unseal {
|
|
|
|
t.Fatalf("should be unsealed")
|
|
|
|
}
|
2015-03-19 02:36:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Verify matching mount tables
|
|
|
|
if !reflect.DeepEqual(c.auth, c2.auth) {
|
|
|
|
t.Fatalf("mismatch: %v %v", c.auth, c2.auth)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-19 17:39:47 +00:00
|
|
|
func TestCore_EnableCredential(t *testing.T) {
|
2017-01-17 20:43:10 +00:00
|
|
|
c, keys, _ := TestCoreUnsealed(t)
|
2018-01-19 06:44:44 +00:00
|
|
|
c.credentialBackends["noop"] = func(context.Context, *logical.BackendConfig) (logical.Backend, error) {
|
2018-11-07 01:21:24 +00:00
|
|
|
return &NoopBackend{
|
|
|
|
BackendType: logical.TypeCredential,
|
|
|
|
}, nil
|
2015-03-19 17:39:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
me := &MountEntry{
|
2016-05-26 17:38:51 +00:00
|
|
|
Table: credentialTableType,
|
|
|
|
Path: "foo",
|
|
|
|
Type: "noop",
|
2015-03-19 17:39:47 +00:00
|
|
|
}
|
2018-11-05 16:11:32 +00:00
|
|
|
err := c.enableCredential(namespace.RootContext(nil), me)
|
2015-03-19 17:39:47 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("err: %v", err)
|
|
|
|
}
|
|
|
|
|
2018-11-05 16:11:32 +00:00
|
|
|
match := c.router.MatchingMount(namespace.RootContext(nil), "auth/foo/bar")
|
2015-03-19 17:39:47 +00:00
|
|
|
if match != "auth/foo/" {
|
2018-09-18 03:03:00 +00:00
|
|
|
t.Fatalf("missing mount, match: %q", match)
|
2015-03-19 17:39:47 +00:00
|
|
|
}
|
|
|
|
|
2015-04-29 01:12:57 +00:00
|
|
|
conf := &CoreConfig{
|
|
|
|
Physical: c.physical,
|
|
|
|
DisableMlock: true,
|
|
|
|
}
|
2015-03-19 17:39:47 +00:00
|
|
|
c2, err := NewCore(conf)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("err: %v", err)
|
|
|
|
}
|
2018-01-19 06:44:44 +00:00
|
|
|
c2.credentialBackends["noop"] = func(context.Context, *logical.BackendConfig) (logical.Backend, error) {
|
2018-11-07 01:21:24 +00:00
|
|
|
return &NoopBackend{
|
|
|
|
BackendType: logical.TypeCredential,
|
|
|
|
}, nil
|
2015-11-02 16:01:00 +00:00
|
|
|
}
|
2017-01-17 20:43:10 +00:00
|
|
|
for i, key := range keys {
|
|
|
|
unseal, err := TestCoreUnseal(c2, key)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("err: %v", err)
|
|
|
|
}
|
|
|
|
if i+1 == len(keys) && !unseal {
|
|
|
|
t.Fatalf("should be unsealed")
|
|
|
|
}
|
2015-03-19 17:39:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Verify matching auth tables
|
|
|
|
if !reflect.DeepEqual(c.auth, c2.auth) {
|
|
|
|
t.Fatalf("mismatch: %v %v", c.auth, c2.auth)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-17 04:09:39 +00:00
|
|
|
// Test that the local table actually gets populated as expected with local
|
|
|
|
// entries, and that upon reading the entries from both are recombined
|
|
|
|
// correctly
|
|
|
|
func TestCore_EnableCredential_Local(t *testing.T) {
|
|
|
|
c, _, _ := TestCoreUnsealed(t)
|
2018-01-19 06:44:44 +00:00
|
|
|
c.credentialBackends["noop"] = func(context.Context, *logical.BackendConfig) (logical.Backend, error) {
|
2018-11-07 01:21:24 +00:00
|
|
|
return &NoopBackend{
|
|
|
|
BackendType: logical.TypeCredential,
|
|
|
|
}, nil
|
2017-02-17 04:09:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
c.auth = &MountTable{
|
|
|
|
Type: credentialTableType,
|
|
|
|
Entries: []*MountEntry{
|
|
|
|
&MountEntry{
|
2018-03-21 19:04:27 +00:00
|
|
|
Table: credentialTableType,
|
|
|
|
Path: "noop/",
|
|
|
|
Type: "noop",
|
|
|
|
UUID: "abcd",
|
|
|
|
Accessor: "noop-abcd",
|
|
|
|
BackendAwareUUID: "abcde",
|
2018-09-18 03:03:00 +00:00
|
|
|
NamespaceID: namespace.RootNamespaceID,
|
2018-11-05 16:11:32 +00:00
|
|
|
namespace: namespace.RootNamespace,
|
2017-02-17 04:09:39 +00:00
|
|
|
},
|
|
|
|
&MountEntry{
|
2018-03-21 19:04:27 +00:00
|
|
|
Table: credentialTableType,
|
|
|
|
Path: "noop2/",
|
|
|
|
Type: "noop",
|
|
|
|
UUID: "bcde",
|
|
|
|
Accessor: "noop-bcde",
|
|
|
|
BackendAwareUUID: "bcdea",
|
2018-09-18 03:03:00 +00:00
|
|
|
NamespaceID: namespace.RootNamespaceID,
|
2018-11-05 16:11:32 +00:00
|
|
|
namespace: namespace.RootNamespace,
|
2017-02-17 04:09:39 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
// Both should set up successfully
|
2018-01-19 06:44:44 +00:00
|
|
|
err := c.setupCredentials(context.Background())
|
2017-02-17 04:09:39 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2018-01-19 06:44:44 +00:00
|
|
|
rawLocal, err := c.barrier.Get(context.Background(), coreLocalAuthConfigPath)
|
2017-02-17 04:09:39 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if rawLocal == nil {
|
|
|
|
t.Fatal("expected non-nil local credential")
|
|
|
|
}
|
|
|
|
localCredentialTable := &MountTable{}
|
|
|
|
if err := jsonutil.DecodeJSON(rawLocal.Value, localCredentialTable); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if len(localCredentialTable.Entries) > 0 {
|
|
|
|
t.Fatalf("expected no entries in local credential table, got %#v", localCredentialTable)
|
|
|
|
}
|
|
|
|
|
|
|
|
c.auth.Entries[1].Local = true
|
2018-04-11 18:32:55 +00:00
|
|
|
if err := c.persistAuth(context.Background(), c.auth, nil); err != nil {
|
2017-02-17 04:09:39 +00:00
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2018-01-19 06:44:44 +00:00
|
|
|
rawLocal, err = c.barrier.Get(context.Background(), coreLocalAuthConfigPath)
|
2017-02-17 04:09:39 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if rawLocal == nil {
|
|
|
|
t.Fatal("expected non-nil local credential")
|
|
|
|
}
|
|
|
|
localCredentialTable = &MountTable{}
|
|
|
|
if err := jsonutil.DecodeJSON(rawLocal.Value, localCredentialTable); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if len(localCredentialTable.Entries) != 1 {
|
|
|
|
t.Fatalf("expected one entry in local credential table, got %#v", localCredentialTable)
|
|
|
|
}
|
|
|
|
|
|
|
|
oldCredential := c.auth
|
2018-01-19 06:44:44 +00:00
|
|
|
if err := c.loadCredentials(context.Background()); err != nil {
|
2017-02-17 04:09:39 +00:00
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if !reflect.DeepEqual(oldCredential, c.auth) {
|
|
|
|
t.Fatalf("expected\n%#v\ngot\n%#v\n", oldCredential, c.auth)
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(c.auth.Entries) != 2 {
|
|
|
|
t.Fatalf("expected two credential entries, got %#v", localCredentialTable)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-12 00:18:52 +00:00
|
|
|
func TestCore_EnableCredential_twice_409(t *testing.T) {
|
|
|
|
c, _, _ := TestCoreUnsealed(t)
|
2018-01-19 06:44:44 +00:00
|
|
|
c.credentialBackends["noop"] = func(context.Context, *logical.BackendConfig) (logical.Backend, error) {
|
2018-11-07 01:21:24 +00:00
|
|
|
return &NoopBackend{
|
|
|
|
BackendType: logical.TypeCredential,
|
|
|
|
}, nil
|
2015-08-12 00:18:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
me := &MountEntry{
|
2016-05-26 17:38:51 +00:00
|
|
|
Table: credentialTableType,
|
|
|
|
Path: "foo",
|
|
|
|
Type: "noop",
|
2015-08-12 00:18:52 +00:00
|
|
|
}
|
2018-11-05 16:11:32 +00:00
|
|
|
err := c.enableCredential(namespace.RootContext(nil), me)
|
2015-08-12 00:18:52 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("err: %v", err)
|
|
|
|
}
|
|
|
|
|
2015-09-15 16:27:22 +00:00
|
|
|
// 2nd should be a 409 error
|
2018-11-05 16:11:32 +00:00
|
|
|
err2 := c.enableCredential(namespace.RootContext(nil), me)
|
2015-09-15 16:27:22 +00:00
|
|
|
switch err2.(type) {
|
|
|
|
case logical.HTTPCodedError:
|
|
|
|
if err2.(logical.HTTPCodedError).Code() != 409 {
|
|
|
|
t.Fatalf("invalid code given")
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
t.Fatalf("expected a different error type")
|
|
|
|
}
|
2015-08-12 00:18:52 +00:00
|
|
|
}
|
|
|
|
|
2015-03-19 17:39:47 +00:00
|
|
|
func TestCore_EnableCredential_Token(t *testing.T) {
|
2015-03-29 23:18:08 +00:00
|
|
|
c, _, _ := TestCoreUnsealed(t)
|
2015-03-19 17:39:47 +00:00
|
|
|
me := &MountEntry{
|
2016-05-26 17:38:51 +00:00
|
|
|
Table: credentialTableType,
|
|
|
|
Path: "foo",
|
|
|
|
Type: "token",
|
2015-03-19 17:39:47 +00:00
|
|
|
}
|
2018-11-05 16:11:32 +00:00
|
|
|
err := c.enableCredential(namespace.RootContext(nil), me)
|
2015-03-19 17:39:47 +00:00
|
|
|
if err.Error() != "token credential backend cannot be instantiated" {
|
|
|
|
t.Fatalf("err: %v", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestCore_DisableCredential(t *testing.T) {
|
2017-01-17 20:43:10 +00:00
|
|
|
c, keys, _ := TestCoreUnsealed(t)
|
2018-01-19 06:44:44 +00:00
|
|
|
c.credentialBackends["noop"] = func(context.Context, *logical.BackendConfig) (logical.Backend, error) {
|
2018-11-07 01:21:24 +00:00
|
|
|
return &NoopBackend{
|
|
|
|
BackendType: logical.TypeCredential,
|
|
|
|
}, nil
|
2015-03-19 17:39:47 +00:00
|
|
|
}
|
|
|
|
|
2018-11-05 16:11:32 +00:00
|
|
|
err := c.disableCredential(namespace.RootContext(nil), "foo")
|
2018-09-18 03:03:00 +00:00
|
|
|
if err != nil && !strings.HasPrefix(err.Error(), "no matching mount") {
|
|
|
|
t.Fatal(err)
|
2015-03-19 17:39:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
me := &MountEntry{
|
2016-05-26 17:38:51 +00:00
|
|
|
Table: credentialTableType,
|
|
|
|
Path: "foo",
|
|
|
|
Type: "noop",
|
2015-03-19 17:39:47 +00:00
|
|
|
}
|
2018-11-05 16:11:32 +00:00
|
|
|
err = c.enableCredential(namespace.RootContext(nil), me)
|
2015-03-19 17:39:47 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("err: %v", err)
|
|
|
|
}
|
|
|
|
|
2018-11-05 16:11:32 +00:00
|
|
|
err = c.disableCredential(namespace.RootContext(nil), "foo")
|
2017-07-13 17:57:14 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("err: %v", err)
|
2015-03-19 17:39:47 +00:00
|
|
|
}
|
|
|
|
|
2018-11-05 16:11:32 +00:00
|
|
|
match := c.router.MatchingMount(namespace.RootContext(nil), "auth/foo/bar")
|
2015-03-19 17:39:47 +00:00
|
|
|
if match != "" {
|
|
|
|
t.Fatalf("backend present")
|
|
|
|
}
|
|
|
|
|
2015-04-29 01:12:57 +00:00
|
|
|
conf := &CoreConfig{
|
|
|
|
Physical: c.physical,
|
|
|
|
DisableMlock: true,
|
|
|
|
}
|
2015-03-19 17:39:47 +00:00
|
|
|
c2, err := NewCore(conf)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("err: %v", err)
|
|
|
|
}
|
2017-01-17 20:43:10 +00:00
|
|
|
for i, key := range keys {
|
|
|
|
unseal, err := TestCoreUnseal(c2, key)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("err: %v", err)
|
|
|
|
}
|
|
|
|
if i+1 == len(keys) && !unseal {
|
|
|
|
t.Fatalf("should be unsealed")
|
|
|
|
}
|
2015-03-19 17:39:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Verify matching mount tables
|
|
|
|
if !reflect.DeepEqual(c.auth, c2.auth) {
|
|
|
|
t.Fatalf("mismatch: %v %v", c.auth, c2.auth)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestCore_DisableCredential_Protected(t *testing.T) {
|
2015-03-29 23:18:08 +00:00
|
|
|
c, _, _ := TestCoreUnsealed(t)
|
2018-11-05 16:11:32 +00:00
|
|
|
err := c.disableCredential(namespace.RootContext(nil), "token")
|
2017-07-13 17:57:14 +00:00
|
|
|
if err.Error() != "token credential backend cannot be disabled" {
|
|
|
|
t.Fatalf("err: %v", err)
|
2015-03-19 17:39:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-03 23:15:34 +00:00
|
|
|
func TestCore_DisableCredential_Cleanup(t *testing.T) {
|
|
|
|
noop := &NoopBackend{
|
2018-11-07 01:21:24 +00:00
|
|
|
Login: []string{"login"},
|
|
|
|
BackendType: logical.TypeCredential,
|
2015-04-03 23:15:34 +00:00
|
|
|
}
|
|
|
|
c, _, _ := TestCoreUnsealed(t)
|
2018-01-19 06:44:44 +00:00
|
|
|
c.credentialBackends["noop"] = func(context.Context, *logical.BackendConfig) (logical.Backend, error) {
|
2015-04-03 23:15:34 +00:00
|
|
|
return noop, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
me := &MountEntry{
|
2016-05-26 17:38:51 +00:00
|
|
|
Table: credentialTableType,
|
|
|
|
Path: "foo",
|
|
|
|
Type: "noop",
|
2015-04-03 23:15:34 +00:00
|
|
|
}
|
2018-11-05 16:11:32 +00:00
|
|
|
err := c.enableCredential(namespace.RootContext(nil), me)
|
2015-04-03 23:15:34 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("err: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Store the view
|
2018-11-05 16:11:32 +00:00
|
|
|
view := c.router.MatchingStorageByAPIPath(namespace.RootContext(nil), "auth/foo/")
|
2015-04-03 23:15:34 +00:00
|
|
|
|
|
|
|
// Inject data
|
|
|
|
se := &logical.StorageEntry{
|
|
|
|
Key: "plstodelete",
|
|
|
|
Value: []byte("test"),
|
|
|
|
}
|
2018-01-19 06:44:44 +00:00
|
|
|
if err := view.Put(context.Background(), se); err != nil {
|
2015-04-03 23:15:34 +00:00
|
|
|
t.Fatalf("err: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Generate a new token auth
|
|
|
|
noop.Response = &logical.Response{
|
|
|
|
Auth: &logical.Auth{
|
|
|
|
Policies: []string{"foo"},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
r := &logical.Request{
|
|
|
|
Operation: logical.ReadOperation,
|
|
|
|
Path: "auth/foo/login",
|
|
|
|
}
|
2018-11-05 16:11:32 +00:00
|
|
|
resp, err := c.HandleRequest(namespace.RootContext(nil), r)
|
2015-04-03 23:15:34 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("err: %v", err)
|
|
|
|
}
|
|
|
|
if resp.Auth.ClientToken == "" {
|
|
|
|
t.Fatalf("bad: %#v", resp)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Disable should cleanup
|
2018-11-05 16:11:32 +00:00
|
|
|
err = c.disableCredential(namespace.RootContext(nil), "foo")
|
2017-07-13 17:57:14 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("err: %v", err)
|
2015-04-03 23:15:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Token should be revoked
|
2018-11-05 16:11:32 +00:00
|
|
|
te, err := c.tokenStore.Lookup(namespace.RootContext(nil), resp.Auth.ClientToken)
|
2015-04-03 23:15:34 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("err: %v", err)
|
|
|
|
}
|
|
|
|
if te != nil {
|
|
|
|
t.Fatalf("bad: %#v", te)
|
|
|
|
}
|
|
|
|
|
|
|
|
// View should be empty
|
2018-01-19 06:44:44 +00:00
|
|
|
out, err := logical.CollectKeys(context.Background(), view)
|
2015-04-03 23:15:34 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("err: %v", err)
|
|
|
|
}
|
|
|
|
if len(out) != 0 {
|
|
|
|
t.Fatalf("bad: %#v", out)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-19 02:36:17 +00:00
|
|
|
func TestDefaultAuthTable(t *testing.T) {
|
2017-06-26 17:14:36 +00:00
|
|
|
c, _, _ := TestCoreUnsealed(t)
|
|
|
|
table := c.defaultAuthTable()
|
2015-03-19 02:36:17 +00:00
|
|
|
verifyDefaultAuthTable(t, table)
|
|
|
|
}
|
|
|
|
|
2015-03-19 16:54:57 +00:00
|
|
|
func verifyDefaultAuthTable(t *testing.T, table *MountTable) {
|
2015-03-19 02:36:17 +00:00
|
|
|
if len(table.Entries) != 1 {
|
|
|
|
t.Fatalf("bad: %v", table.Entries)
|
|
|
|
}
|
2016-05-26 17:38:51 +00:00
|
|
|
if table.Type != credentialTableType {
|
|
|
|
t.Fatalf("bad: %v", *table)
|
|
|
|
}
|
2015-03-19 02:36:17 +00:00
|
|
|
for idx, entry := range table.Entries {
|
|
|
|
switch idx {
|
|
|
|
case 0:
|
2015-04-03 21:24:00 +00:00
|
|
|
if entry.Path != "token/" {
|
2015-03-19 02:36:17 +00:00
|
|
|
t.Fatalf("bad: %v", entry)
|
|
|
|
}
|
|
|
|
if entry.Type != "token" {
|
|
|
|
t.Fatalf("bad: %v", entry)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if entry.Description == "" {
|
|
|
|
t.Fatalf("bad: %v", entry)
|
|
|
|
}
|
|
|
|
if entry.UUID == "" {
|
|
|
|
t.Fatalf("bad: %v", entry)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|