func doTokenLookup(args []string, client *api.Client) (*api.Secret, error) { if len(args) == 0 { return client.Auth().Token().LookupSelf() } token := args[0] return client.Auth().Token().Lookup(token) }
func makeToken(t *testing.T, c *vaultapi.Client, wrapTTL string, req *vaultapi.TokenCreateRequest) string { c.SetWrappingLookupFunc(func(string, string) string { return wrapTTL }) resp, err := c.Auth().Token().Create(req) if err != nil { t.Fatalf("Could not create a token: %s", err) } if wrapTTL != "" { if resp.WrapInfo == nil || resp.WrapInfo.Token == "" { t.Fatalf("Could not create a wrapped token") } return resp.WrapInfo.Token } if resp.WrapInfo != nil && resp.WrapInfo.Token != "" { t.Fatalf("Got a wrapped token but was not expecting one") } return resp.Auth.ClientToken }