Merge pull request #10200 from caesarxuchao/resthandler-validate-version
verify and default APIVersion in createHandler, verify APIVersion in UpdateResource
This commit is contained in:
@@ -51,12 +51,6 @@ import (
|
||||
"github.com/GoogleCloudPlatform/kubernetes/test/integration/framework"
|
||||
)
|
||||
|
||||
var nodeResourceName string
|
||||
|
||||
func init() {
|
||||
nodeResourceName = "nodes"
|
||||
}
|
||||
|
||||
const (
|
||||
AliceToken string = "abc123" // username: alice. Present in token file.
|
||||
BobToken string = "xyz987" // username: bob. Present in token file.
|
||||
@@ -86,7 +80,7 @@ func timeoutPath(resource, namespace, name string) string {
|
||||
var aPod string = `
|
||||
{
|
||||
"kind": "Pod",
|
||||
"apiVersion": "v1",
|
||||
"apiVersion": "` + testapi.Version() + `",
|
||||
"metadata": {
|
||||
"name": "a",
|
||||
"creationTimestamp": null%s
|
||||
@@ -104,7 +98,7 @@ var aPod string = `
|
||||
var aRC string = `
|
||||
{
|
||||
"kind": "ReplicationController",
|
||||
"apiVersion": "v1",
|
||||
"apiVersion": "` + testapi.Version() + `",
|
||||
"metadata": {
|
||||
"name": "a",
|
||||
"labels": {
|
||||
@@ -137,7 +131,7 @@ var aRC string = `
|
||||
var aService string = `
|
||||
{
|
||||
"kind": "Service",
|
||||
"apiVersion": "v1",
|
||||
"apiVersion": "` + testapi.Version() + `",
|
||||
"metadata": {
|
||||
"name": "a",
|
||||
"labels": {
|
||||
@@ -161,7 +155,7 @@ var aService string = `
|
||||
var aNode string = `
|
||||
{
|
||||
"kind": "Node",
|
||||
"apiVersion": "v1",
|
||||
"apiVersion": "` + testapi.Version() + `",
|
||||
"metadata": {
|
||||
"name": "a"%s
|
||||
},
|
||||
@@ -173,7 +167,7 @@ var aNode string = `
|
||||
var aEvent string = `
|
||||
{
|
||||
"kind": "Event",
|
||||
"apiVersion": "v1",
|
||||
"apiVersion": "` + testapi.Version() + `",
|
||||
"metadata": {
|
||||
"name": "a"%s
|
||||
},
|
||||
@@ -189,7 +183,7 @@ var aEvent string = `
|
||||
var aBinding string = `
|
||||
{
|
||||
"kind": "Binding",
|
||||
"apiVersion": "v1",
|
||||
"apiVersion": "` + testapi.Version() + `",
|
||||
"metadata": {
|
||||
"name": "a"%s
|
||||
},
|
||||
@@ -212,7 +206,7 @@ var emptyEndpoints string = `
|
||||
var aEndpoints string = `
|
||||
{
|
||||
"kind": "Endpoints",
|
||||
"apiVersion": "v1",
|
||||
"apiVersion": "` + testapi.Version() + `",
|
||||
"metadata": {
|
||||
"name": "a"%s
|
||||
},
|
||||
@@ -237,7 +231,7 @@ var aEndpoints string = `
|
||||
var deleteNow string = `
|
||||
{
|
||||
"kind": "DeleteOptions",
|
||||
"apiVersion": "v1",
|
||||
"apiVersion": "` + testapi.Version() + `",
|
||||
"gracePeriodSeconds": null%s
|
||||
}
|
||||
`
|
||||
@@ -337,11 +331,11 @@ func getTestRequests() []struct {
|
||||
{"DELETE", timeoutPath("endpoints", api.NamespaceDefault, "a"), "", code200},
|
||||
|
||||
// Normal methods on minions
|
||||
{"GET", path(nodeResourceName, "", ""), "", code200},
|
||||
{"POST", timeoutPath(nodeResourceName, "", ""), aNode, code201},
|
||||
{"PUT", timeoutPath(nodeResourceName, "", "a"), aNode, code200},
|
||||
{"GET", path(nodeResourceName, "", "a"), "", code200},
|
||||
{"DELETE", timeoutPath(nodeResourceName, "", "a"), "", code200},
|
||||
{"GET", path("nodes", "", ""), "", code200},
|
||||
{"POST", timeoutPath("nodes", "", ""), aNode, code201},
|
||||
{"PUT", timeoutPath("nodes", "", "a"), aNode, code200},
|
||||
{"GET", path("nodes", "", "a"), "", code200},
|
||||
{"DELETE", timeoutPath("nodes", "", "a"), "", code200},
|
||||
|
||||
// Normal methods on events
|
||||
{"GET", path("events", "", ""), "", code200},
|
||||
@@ -367,8 +361,8 @@ func getTestRequests() []struct {
|
||||
{"DELETE", timeoutPath("foo", api.NamespaceDefault, ""), "", code404},
|
||||
|
||||
// Special verbs on nodes
|
||||
{"GET", pathWithPrefix("proxy", nodeResourceName, api.NamespaceDefault, "a"), "", code404},
|
||||
{"GET", pathWithPrefix("redirect", nodeResourceName, api.NamespaceDefault, "a"), "", code404},
|
||||
{"GET", pathWithPrefix("proxy", "nodes", api.NamespaceDefault, "a"), "", code404},
|
||||
{"GET", pathWithPrefix("redirect", "nodes", api.NamespaceDefault, "a"), "", code404},
|
||||
// TODO: test .../watch/..., which doesn't end before the test timeout.
|
||||
// TODO: figure out how to create a minion so that it can successfully proxy/redirect.
|
||||
|
||||
|
Reference in New Issue
Block a user