Skip to content

Commit

Permalink
Fixed CDI dep and updated rest endpoint test
Browse files Browse the repository at this point in the history
See emicklei/go-restful#396 for the changes test

Signed-off-by: Marc Sluiter <[email protected]>
  • Loading branch information
slintes committed Oct 1, 2019
1 parent ce73897 commit 5107bb7
Show file tree
Hide file tree
Showing 314 changed files with 33,622 additions and 13,274 deletions.
43 changes: 19 additions & 24 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module kubevirt.io/kubevirt
require (
github.com/Azure/go-autorest/autorest v0.9.1 // indirect
github.com/Azure/go-autorest/autorest/adal v0.6.0 // indirect
github.com/NYTimes/gziphandler v1.0.1 // indirect
github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf
github.com/blang/semver v3.5.1+incompatible
github.com/coreos/go-iptables v0.4.1
Expand All @@ -11,7 +12,7 @@ require (
github.com/docker/spdystream v0.0.0-20181023171402-6480d4af844c // indirect
github.com/elazarl/goproxy v0.0.0-20190421051319-9d40249d3c2f // indirect
github.com/elazarl/goproxy/ext v0.0.0-20190421051319-9d40249d3c2f // indirect
github.com/emicklei/go-restful v2.8.1+incompatible
github.com/emicklei/go-restful v2.9.5+incompatible
github.com/emicklei/go-restful-openapi v0.10.0
github.com/evanphx/json-patch v4.2.0+incompatible
github.com/fatih/color v1.7.0 // indirect
Expand All @@ -23,7 +24,7 @@ require (
github.com/go-openapi/errors v0.17.2
github.com/go-openapi/loads v0.17.2 // indirect
github.com/go-openapi/runtime v0.17.2 // indirect
github.com/go-openapi/spec v0.17.2
github.com/go-openapi/spec v0.19.2
github.com/go-openapi/strfmt v0.18.0
github.com/go-openapi/validate v0.18.0
github.com/gogo/protobuf v1.2.1
Expand Down Expand Up @@ -57,17 +58,17 @@ require (
github.com/subgraph/libmacouflage v0.0.1
github.com/vishvananda/netlink v0.0.0-20180206203732-d35d6b58e1cb
github.com/vishvananda/netns v0.0.0-20180720170159-13995c7128cc // indirect
golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f
golang.org/x/net v0.0.0-20190522155817-f3200d17e092
golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980
golang.org/x/oauth2 v0.0.0-20181105165119-ca4130e427c7 // indirect
golang.org/x/sys v0.0.0-20190425145619-16072639606e
golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f
google.golang.org/grpc v1.19.1
gopkg.in/cheggaaa/pb.v1 v1.0.28
gopkg.in/ini.v1 v1.42.0
gopkg.in/yaml.v2 v2.2.2
k8s.io/api v0.0.0-20190313235455-40a48860b5ab
k8s.io/api v0.0.0-20190725062911-6607c48751ae
k8s.io/apiextensions-apiserver v0.0.0-20190315093550-53c4693659ed
k8s.io/apimachinery v0.0.0-20190313205120-d7deff9243b1
k8s.io/apimachinery v0.0.0-20190719140911-bfcf53abc9f8
k8s.io/client-go v11.0.0+incompatible
k8s.io/kube-aggregator v0.0.0-20190228175259-3e0149950b0e
k8s.io/utils v0.0.0-20190607212802-c55fbcfc754a
Expand All @@ -78,20 +79,14 @@ require (
sigs.k8s.io/yaml v1.1.0 // indirect
)

replace k8s.io/client-go => k8s.io/client-go v0.0.0-20190228174230-b40b2a5939e4

replace k8s.io/api => k8s.io/api v0.0.0-20190222213804-5cb15d344471

replace k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.0.0-20190228180357-d002e88f6236

replace k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20190221213512-86fb29eff628

replace github.com/go-kit/kit => github.com/go-kit/kit v0.3.0

replace github.com/Azure/go-autorest => github.com/Azure/go-autorest v11.0.0+incompatible

replace github.com/openshift/client-go => github.com/openshift/client-go v0.0.0-20190401163519-84c2b942258a

replace kubevirt.io/client-go => ./staging/src/kubevirt.io/client-go

replace github.com/coreos/prometheus-operator => github.com/coreos/prometheus-operator v0.0.0-20181206002233-dd6f23e7207c
replace (
github.com/Azure/go-autorest => github.com/Azure/go-autorest v11.0.0+incompatible
github.com/coreos/prometheus-operator => github.com/coreos/prometheus-operator v0.0.0-20181206002233-dd6f23e7207c
github.com/go-kit/kit => github.com/go-kit/kit v0.3.0
github.com/openshift/client-go => github.com/openshift/client-go v0.0.0-20190401163519-84c2b942258a
k8s.io/api => k8s.io/api v0.0.0-20190222213804-5cb15d344471
k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.0.0-20190228180357-d002e88f6236
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20190221213512-86fb29eff628
k8s.io/client-go => k8s.io/client-go v0.0.0-20190228174230-b40b2a5939e4
kubevirt.io/client-go => ./staging/src/kubevirt.io/client-go
)
100 changes: 90 additions & 10 deletions go.sum

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions pkg/rest/endpoints/patch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ import (

func newValidPatchRequest() *http.Request {
request, _ := http.NewRequest("PATCH", "/apis/kubevirt.io/v1alpha3/namespaces/default/virtualmachineinstances/test", nil)
request.Body = toReader("[{\"op\": \"replace\", \"path\": \"/email\", \"value\":\"newmail\"}]")
length := 0
request.Body, length = toReader("[{\"op\": \"replace\", \"path\": \"/email\", \"value\":\"newmail\"}]")
request.ContentLength = int64(length)
request.Header.Set("Content-Type", rest.MIME_JSON_PATCH)
return request
}
Expand Down Expand Up @@ -99,14 +101,14 @@ var _ = Describe("Patch", func() {
})
Context("with invalid patch operation", func() {
It("should return 422", func() {
request.Body = toReader("[{\"op\": \"nonexistent\", \"path\": \"/unknown\", \"value\":\"newmail\"}]")
request.Body, _ = toReader("[{\"op\": \"nonexistent\", \"path\": \"/unknown\", \"value\":\"newmail\"}]")
handler.ServeHTTP(recorder, request)
Expect(recorder.Code).To(Equal(422))
})
})
Context("with invalid field", func() {
It("should return 200 and not update the object", func() {
request.Body = toReader("[{\"op\": \"add\", \"path\": \"/unknown\", \"value\":\"newmail\"}]")
request.Body, _ = toReader("[{\"op\": \"add\", \"path\": \"/unknown\", \"value\":\"newmail\"}]")
handler.ServeHTTP(recorder, request)
Expect(recorder.Code).To(Equal(http.StatusOK))
responseBody := payload{}
Expand Down
8 changes: 5 additions & 3 deletions pkg/rest/endpoints/post_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ import (

func newValidJSONPostRequest() *http.Request {
request, _ := http.NewRequest("POST", "/apis/kubevirt.io/v1alpha3/namespaces/default/virtualmachineinstances", nil)
request.Body = marshalToJSON(payload{Name: "test", Email: "[email protected]"})
length := 0
request.Body, length = marshalToJSON(payload{Name: "test", Email: "[email protected]"})
request.ContentLength = int64(length)
request.Header.Set("Content-Type", rest.MIME_JSON)
return request
}
Expand Down Expand Up @@ -90,14 +92,14 @@ var _ = Describe("Post", func() {
})
Context("with missing name field", func() {
It("should return 400", func() {
request.Body = marshalToJSON(payload{Email: "[email protected]"})
request.Body, _ = marshalToJSON(payload{Email: "[email protected]"})
handler.ServeHTTP(recorder, request)
Expect(recorder.Code).To(Equal(http.StatusBadRequest))
})
})
Context("with invalid email", func() {
It("should return 400", func() {
request.Body = marshalToJSON(payload{Name: "test", Email: "wrong"})
request.Body, _ = marshalToJSON(payload{Name: "test", Email: "wrong"})
handler.ServeHTTP(recorder, request)
Expect(recorder.Code).To(Equal(http.StatusBadRequest))
})
Expand Down
16 changes: 9 additions & 7 deletions pkg/rest/endpoints/put_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@ import (
"kubevirt.io/kubevirt/pkg/rest"
)

func marshalToJSON(payload interface{}) io.ReadCloser {
func marshalToJSON(payload interface{}) (io.ReadCloser, int) {
var b []byte
buffer := bytes.NewBuffer(b)
Expect(json.NewEncoder(buffer).Encode(payload)).To(Succeed())
return ioutil.NopCloser(buffer)
return ioutil.NopCloser(buffer), buffer.Len()
}

func toReader(json string) io.ReadCloser {
func toReader(json string) (io.ReadCloser, int) {
var b []byte
buffer := bytes.NewBuffer(b)
buffer.WriteString(json)
return ioutil.NopCloser(buffer)
return ioutil.NopCloser(buffer), buffer.Len()
}

func marshalToYAML(payload interface{}) io.ReadCloser {
Expand All @@ -69,7 +69,9 @@ type payload struct {

func newValidPutRequest() *http.Request {
request, _ := http.NewRequest("PUT", "/apis/kubevirt.io/v1alpha3/namespaces/default/virtualmachineinstances/test", nil)
request.Body = marshalToJSON(payload{Name: "test", Email: "[email protected]"})
length := 0
request.Body, length = marshalToJSON(payload{Name: "test", Email: "[email protected]"})
request.ContentLength = int64(length)
request.Header.Set("Content-Type", rest.MIME_JSON)
return request
}
Expand Down Expand Up @@ -122,14 +124,14 @@ var _ = Describe("Put", func() {
})
Context("with missing name field", func() {
It("should return 400", func() {
request.Body = marshalToJSON(payload{Email: "[email protected]"})
request.Body, _ = marshalToJSON(payload{Email: "[email protected]"})
handler.ServeHTTP(recorder, request)
Expect(recorder.Code).To(Equal(http.StatusBadRequest))
})
})
Context("with invalid email", func() {
It("should return 400", func() {
request.Body = marshalToJSON(payload{Name: "test", Email: "wrong"})
request.Body, _ = marshalToJSON(payload{Name: "test", Email: "wrong"})
handler.ServeHTTP(recorder, request)
Expect(recorder.Code).To(Equal(http.StatusBadRequest))
})
Expand Down
42 changes: 17 additions & 25 deletions staging/src/kubevirt.io/client-go/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,47 +5,39 @@ go 1.12
require (
github.com/coreos/prometheus-operator v0.31.1
github.com/go-kit/kit v0.8.0
github.com/go-openapi/spec v0.17.2
github.com/go-openapi/swag v0.19.0 // indirect
github.com/go-openapi/spec v0.19.2
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef // indirect
github.com/golang/mock v1.1.1
github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf
github.com/googleapis/gnostic v0.2.0 // indirect
github.com/gorilla/websocket v0.0.0-20180228210902-0647012449a1
github.com/json-iterator/go v1.1.6 // indirect
github.com/k8snetworkplumbingwg/network-attachment-definition-client v0.0.0-20181121151021-386d141f4c94
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/onsi/ginkgo v1.8.0
github.com/onsi/gomega v1.5.1-0.20190515112211-6a48b4839f85
github.com/openshift/api v3.9.1-0.20190401220125-3a6077f1f910+incompatible // indirect
github.com/openshift/client-go v0.0.0-20190401163519-84c2b942258a
github.com/openshift/custom-resource-status v0.0.0-20190822192428-e62f2f3b79f3 // indirect
github.com/pborman/uuid v1.2.0
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/spf13/pflag v1.0.3
google.golang.org/appengine v1.5.0 // indirect
k8s.io/api v0.0.0-20190313235455-40a48860b5ab
k8s.io/api v0.0.0-20190725062911-6607c48751ae
k8s.io/apiextensions-apiserver v0.0.0-20190315093550-53c4693659ed
k8s.io/apimachinery v0.0.0-20190313205120-d7deff9243b1
k8s.io/apimachinery v0.0.0-20190719140911-bfcf53abc9f8
k8s.io/client-go v11.0.0+incompatible
k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30
kubevirt.io/containerized-data-importer v1.8.1-0.20190516083534-83c12eaae2ed
k8s.io/kube-openapi v0.0.0-20190709113604-33be087ad058
kubevirt.io/containerized-data-importer v1.10.6
)

replace github.com/k8snetworkplumbingwg/network-attachment-definition-client => github.com/booxter/network-attachment-definition-client v0.0.0-20181121221720-d76adb95b0b7

replace k8s.io/client-go => k8s.io/client-go v0.0.0-20190228174230-b40b2a5939e4

replace k8s.io/api => k8s.io/api v0.0.0-20190222213804-5cb15d344471

replace k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.0.0-20190228180357-d002e88f6236

replace k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20190221213512-86fb29eff628

replace github.com/go-kit/kit => github.com/go-kit/kit v0.3.0

replace github.com/Azure/go-autorest => github.com/Azure/go-autorest v11.0.0+incompatible

replace kubevirt.io/containerized-data-importer => kubevirt.io/containerized-data-importer v1.8.1-0.20190530153240-6734c225525a

replace github.com/openshift/client-go => github.com/openshift/client-go v0.0.0-20190401163519-84c2b942258a
replace (
github.com/Azure/go-autorest => github.com/Azure/go-autorest v11.0.0+incompatible
github.com/go-kit/kit => github.com/go-kit/kit v0.3.0
github.com/k8snetworkplumbingwg/network-attachment-definition-client => github.com/booxter/network-attachment-definition-client v0.0.0-20181121221720-d76adb95b0b7
github.com/openshift/client-go => github.com/openshift/client-go v0.0.0-20190401163519-84c2b942258a
k8s.io/api => k8s.io/api v0.0.0-20190222213804-5cb15d344471
k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.0.0-20190228180357-d002e88f6236
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20190221213512-86fb29eff628
k8s.io/client-go => k8s.io/client-go v0.0.0-20190228174230-b40b2a5939e4
kubevirt.io/containerized-data-importer => kubevirt.io/containerized-data-importer v1.10.6
)
Loading

0 comments on commit 5107bb7

Please sign in to comment.