mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-08 12:41:58 +00:00
Fix reflect panic in runtime/conversion
Fixes `panic: reflect: call of reflect.Value.Type on zero Value` when calling conversion.EnforcePtr() or runtime.Scheme.ObjectVersionAndKind() from default type switch. Signed-off-by: Vojtech Vitek (V-Teq) <vvitek@redhat.com>
This commit is contained in:
@@ -123,6 +123,20 @@ func TestScheme(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestInvalidObjectValueKind(t *testing.T) {
|
||||
scheme := runtime.NewScheme()
|
||||
scheme.AddKnownTypeWithName("", "Simple", &InternalSimple{})
|
||||
|
||||
embedded := &runtime.EmbeddedObject{}
|
||||
switch obj := embedded.Object.(type) {
|
||||
default:
|
||||
_, _, err := scheme.ObjectVersionAndKind(obj)
|
||||
if err == nil {
|
||||
t.Errorf("Expected error on invalid kind")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestBadJSONRejection(t *testing.T) {
|
||||
scheme := runtime.NewScheme()
|
||||
badJSONMissingKind := []byte(`{ }`)
|
||||
|
Reference in New Issue
Block a user