blob: 7ee21ed4ebbb4aee1e870a3b28c83f032c83769a [file] [log] [blame]
// Copyright 2015 The Vanadium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package principal
import (
"fmt"
"strings"
"v.io/v23/security"
"v.io/v23/verror"
)
func blessSelf(p security.Principal, name string) security.Blessings {
b, err := p.BlessSelf(name)
if err != nil {
panic(err)
}
return b
}
func matchesError(got error, want string) error {
if (got == nil) && len(want) == 0 {
return nil
}
if got == nil {
return fmt.Errorf("Got nil error, wanted to match %q", want)
}
if !strings.Contains(got.Error(), want) {
return fmt.Errorf("Got error %q, wanted to match %q", got, want)
}
return nil
}
func matchesErrorID(got error, want verror.ID) error {
if (got == nil) && len(want) == 0 {
return nil
}
if got == nil {
return fmt.Errorf("Got nil error, wanted to match %q", want)
}
if verror.ErrorID(got) != want {
return fmt.Errorf("Got error %q, wanted to match %q", got, want)
}
return nil
}