mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 09:49:50 +00:00
Add CBOR decoder unit test that accepts tag 55799.
Tag 55799 (self-described CBOR) imparts no special semantics on the item it encloses. The CBOR encoder always encloses its output in this tag so that the prefix 0xd9d9f7 can be used to mechanically distinguish encoded CBOR from encoded JSON, and the decoder must be able to accept any sequence of bytes that the encoder can produce.
This commit is contained in:
parent
f75d8e97f1
commit
19921cbf0d
@ -181,6 +181,24 @@ func TestDecode(t *testing.T) {
|
||||
expectedGVK *schema.GroupVersionKind
|
||||
assertOnError func(*testing.T, error)
|
||||
}{
|
||||
{
|
||||
name: "self-described cbor tag accepted",
|
||||
data: []byte("\xd9\xd9\xf7\xa3\x4aapiVersion\x41v\x44kind\x41k\x48metadata\xa1\x44name\x43foo"), // 55799({'apiVersion': 'v', 'kind': 'k', 'metadata': {'name': 'foo'}})
|
||||
gvk: &schema.GroupVersionKind{},
|
||||
metaFactory: &defaultMetaFactory{},
|
||||
typer: stubTyper{gvks: []schema.GroupVersionKind{{Version: "v", Kind: "k"}}},
|
||||
into: &metav1.PartialObjectMetadata{},
|
||||
expectedObj: &metav1.PartialObjectMetadata{
|
||||
TypeMeta: metav1.TypeMeta{APIVersion: "v", Kind: "k"},
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "foo"},
|
||||
},
|
||||
expectedGVK: &schema.GroupVersionKind{Version: "v", Kind: "k"},
|
||||
assertOnError: func(t *testing.T, err error) {
|
||||
if err != nil {
|
||||
t.Errorf("expected nil error, got: %v", err)
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "error determining gvk",
|
||||
metaFactory: stubMetaFactory{err: errors.New("test")},
|
||||
|
Loading…
Reference in New Issue
Block a user