func (*KeysSuite) TestMarshalText(c *gc.C) { data, err := testKey.MarshalText() c.Assert(err, gc.IsNil) c.Assert(string(data), gc.Equals, base64.StdEncoding.EncodeToString([]byte(testKey[:]))) var key1 bakery.Key err = key1.UnmarshalText(data) c.Assert(err, gc.IsNil) c.Assert(key1, gc.Equals, testKey) }
// PublicKeyForLocation implements bakery.PublicKeyLocator by providing the key // that was specified on the command line. // TODO: PKIWTFBBQ. // TODO: request keys on-demand if location is HTTPS. func (ctx condContext) PublicKeyForLocation(loc string) (*bakery.PublicKey, error) { var key bakery.Key keyText := ctx.String("key") if keyText == "" { return nil, fmt.Errorf("--key is required for third-party caveat") } err := key.UnmarshalText([]byte(keyText)) if err != nil { return nil, fmt.Errorf("failed to unmarshal key %q: %v", keyText, err) } return &bakery.PublicKey{key}, nil }