Making all operations synchronous
This commit is contained in:
@@ -153,9 +153,8 @@ var aEndpoints string = `
|
||||
}
|
||||
`
|
||||
|
||||
// To ensure that a POST completes before a dependent GET, make operations
|
||||
// effectively synchronous with the following parameters.
|
||||
var syncFlags = "?sync=true&timeout=60s"
|
||||
// To ensure that a POST completes before a dependent GET, set a timeout.
|
||||
var timeoutFlag = "?timeout=60s"
|
||||
|
||||
// Requests to try. Each one should be forbidden or not forbidden
|
||||
// depending on the authentication and authorization setup of the master.
|
||||
@@ -182,11 +181,11 @@ func getTestRequests() []struct {
|
||||
}{
|
||||
// Normal methods on pods
|
||||
{"GET", "/api/v1beta1/pods", "", code200},
|
||||
{"POST", "/api/v1beta1/pods" + syncFlags, aPod, code200},
|
||||
{"PUT", "/api/v1beta1/pods/a" + syncFlags, aPod, code500}, // See #2114 about why 500
|
||||
{"POST", "/api/v1beta1/pods" + timeoutFlag, aPod, code200},
|
||||
{"PUT", "/api/v1beta1/pods/a" + timeoutFlag, aPod, code500}, // See #2114 about why 500
|
||||
{"GET", "/api/v1beta1/pods", "", code200},
|
||||
{"GET", "/api/v1beta1/pods/a", "", code200},
|
||||
{"DELETE", "/api/v1beta1/pods/a" + syncFlags, "", code200},
|
||||
{"DELETE", "/api/v1beta1/pods/a" + timeoutFlag, "", code200},
|
||||
|
||||
// Non-standard methods (not expected to work,
|
||||
// but expected to pass/fail authorization prior to
|
||||
@@ -202,53 +201,53 @@ func getTestRequests() []struct {
|
||||
|
||||
// Normal methods on services
|
||||
{"GET", "/api/v1beta1/services", "", code200},
|
||||
{"POST", "/api/v1beta1/services" + syncFlags, aService, code200},
|
||||
{"PUT", "/api/v1beta1/services/a" + syncFlags, aService, code409}, // TODO: GET and put back server-provided fields to avoid a 422
|
||||
{"POST", "/api/v1beta1/services" + timeoutFlag, aService, code200},
|
||||
{"PUT", "/api/v1beta1/services/a" + timeoutFlag, aService, code409}, // TODO: GET and put back server-provided fields to avoid a 422
|
||||
{"GET", "/api/v1beta1/services", "", code200},
|
||||
{"GET", "/api/v1beta1/services/a", "", code200},
|
||||
{"DELETE", "/api/v1beta1/services/a" + syncFlags, "", code200},
|
||||
{"DELETE", "/api/v1beta1/services/a" + timeoutFlag, "", code200},
|
||||
|
||||
// Normal methods on replicationControllers
|
||||
{"GET", "/api/v1beta1/replicationControllers", "", code200},
|
||||
{"POST", "/api/v1beta1/replicationControllers" + syncFlags, aRC, code200},
|
||||
{"PUT", "/api/v1beta1/replicationControllers/a" + syncFlags, aRC, code409}, // See #2115 about why 409
|
||||
{"POST", "/api/v1beta1/replicationControllers" + timeoutFlag, aRC, code200},
|
||||
{"PUT", "/api/v1beta1/replicationControllers/a" + timeoutFlag, aRC, code409}, // See #2115 about why 409
|
||||
{"GET", "/api/v1beta1/replicationControllers", "", code200},
|
||||
{"GET", "/api/v1beta1/replicationControllers/a", "", code200},
|
||||
{"DELETE", "/api/v1beta1/replicationControllers/a" + syncFlags, "", code200},
|
||||
{"DELETE", "/api/v1beta1/replicationControllers/a" + timeoutFlag, "", code200},
|
||||
|
||||
// Normal methods on endpoints
|
||||
{"GET", "/api/v1beta1/endpoints", "", code200},
|
||||
{"POST", "/api/v1beta1/endpoints" + syncFlags, aEndpoints, code200},
|
||||
{"PUT", "/api/v1beta1/endpoints/a" + syncFlags, aEndpoints, code200},
|
||||
{"POST", "/api/v1beta1/endpoints" + timeoutFlag, aEndpoints, code200},
|
||||
{"PUT", "/api/v1beta1/endpoints/a" + timeoutFlag, aEndpoints, code200},
|
||||
{"GET", "/api/v1beta1/endpoints", "", code200},
|
||||
{"GET", "/api/v1beta1/endpoints/a", "", code200},
|
||||
{"DELETE", "/api/v1beta1/endpoints/a" + syncFlags, "", code405},
|
||||
{"DELETE", "/api/v1beta1/endpoints/a" + timeoutFlag, "", code405},
|
||||
|
||||
// Normal methods on minions
|
||||
{"GET", "/api/v1beta1/minions", "", code200},
|
||||
{"POST", "/api/v1beta1/minions" + syncFlags, aMinion, code200},
|
||||
{"PUT", "/api/v1beta1/minions/a" + syncFlags, aMinion, code422}, // TODO: GET and put back server-provided fields to avoid a 422
|
||||
{"POST", "/api/v1beta1/minions" + timeoutFlag, aMinion, code200},
|
||||
{"PUT", "/api/v1beta1/minions/a" + timeoutFlag, aMinion, code422}, // TODO: GET and put back server-provided fields to avoid a 422
|
||||
{"GET", "/api/v1beta1/minions", "", code200},
|
||||
{"GET", "/api/v1beta1/minions/a", "", code200},
|
||||
{"DELETE", "/api/v1beta1/minions/a" + syncFlags, "", code200},
|
||||
{"DELETE", "/api/v1beta1/minions/a" + timeoutFlag, "", code200},
|
||||
|
||||
// Normal methods on events
|
||||
{"GET", "/api/v1beta1/events", "", code200},
|
||||
{"POST", "/api/v1beta1/events" + syncFlags, aEvent, code200},
|
||||
{"PUT", "/api/v1beta1/events/a" + syncFlags, aEvent, code405},
|
||||
{"POST", "/api/v1beta1/events" + timeoutFlag, aEvent, code200},
|
||||
{"PUT", "/api/v1beta1/events/a" + timeoutFlag, aEvent, code405},
|
||||
{"GET", "/api/v1beta1/events", "", code200},
|
||||
{"GET", "/api/v1beta1/events", "", code200},
|
||||
{"GET", "/api/v1beta1/events/a", "", code200},
|
||||
{"DELETE", "/api/v1beta1/events/a" + syncFlags, "", code200},
|
||||
{"DELETE", "/api/v1beta1/events/a" + timeoutFlag, "", code200},
|
||||
|
||||
// Normal methods on bindings
|
||||
{"GET", "/api/v1beta1/bindings", "", code405}, // Bindings are write-only
|
||||
{"POST", "/api/v1beta1/pods" + syncFlags, aPod, code200}, // Need a pod to bind or you get a 404
|
||||
{"POST", "/api/v1beta1/bindings" + syncFlags, aBinding, code200},
|
||||
{"PUT", "/api/v1beta1/bindings/a" + syncFlags, aBinding, code405},
|
||||
{"GET", "/api/v1beta1/bindings", "", code405}, // Bindings are write-only
|
||||
{"POST", "/api/v1beta1/pods" + timeoutFlag, aPod, code200}, // Need a pod to bind or you get a 404
|
||||
{"POST", "/api/v1beta1/bindings" + timeoutFlag, aBinding, code200},
|
||||
{"PUT", "/api/v1beta1/bindings/a" + timeoutFlag, aBinding, code405},
|
||||
{"GET", "/api/v1beta1/bindings", "", code405},
|
||||
{"GET", "/api/v1beta1/bindings/a", "", code405}, // No bindings instances
|
||||
{"DELETE", "/api/v1beta1/bindings/a" + syncFlags, "", code405},
|
||||
{"DELETE", "/api/v1beta1/bindings/a" + timeoutFlag, "", code405},
|
||||
|
||||
// Non-existent object type.
|
||||
{"GET", "/api/v1beta1/foo", "", code404},
|
||||
@@ -256,7 +255,7 @@ func getTestRequests() []struct {
|
||||
{"PUT", "/api/v1beta1/foo/a", `{"foo": "foo"}`, code404},
|
||||
{"GET", "/api/v1beta1/foo", "", code404},
|
||||
{"GET", "/api/v1beta1/foo/a", "", code404},
|
||||
{"DELETE", "/api/v1beta1/foo" + syncFlags, "", code404},
|
||||
{"DELETE", "/api/v1beta1/foo" + timeoutFlag, "", code404},
|
||||
|
||||
// Operations
|
||||
{"GET", "/api/v1beta1/operations", "", code200},
|
||||
@@ -271,6 +270,7 @@ func getTestRequests() []struct {
|
||||
|
||||
// Non-object endpoints
|
||||
{"GET", "/", "", code200},
|
||||
{"GET", "/api", "", code200},
|
||||
{"GET", "/healthz", "", code200},
|
||||
{"GET", "/version", "", code200},
|
||||
}
|
||||
@@ -635,20 +635,20 @@ func TestNamespaceAuthorization(t *testing.T) {
|
||||
statusCodes map[int]bool // allowed status codes.
|
||||
}{
|
||||
|
||||
{"POST", "/api/v1beta1/pods" + syncFlags + "&namespace=foo", aPod, code200},
|
||||
{"POST", "/api/v1beta1/pods" + timeoutFlag + "&namespace=foo", aPod, code200},
|
||||
{"GET", "/api/v1beta1/pods?namespace=foo", "", code200},
|
||||
{"GET", "/api/v1beta1/pods/a?namespace=foo", "", code200},
|
||||
{"DELETE", "/api/v1beta1/pods/a" + syncFlags + "&namespace=foo", "", code200},
|
||||
{"DELETE", "/api/v1beta1/pods/a" + timeoutFlag + "&namespace=foo", "", code200},
|
||||
|
||||
{"POST", "/api/v1beta1/pods" + syncFlags + "&namespace=bar", aPod, code403},
|
||||
{"POST", "/api/v1beta1/pods" + timeoutFlag + "&namespace=bar", aPod, code403},
|
||||
{"GET", "/api/v1beta1/pods?namespace=bar", "", code403},
|
||||
{"GET", "/api/v1beta1/pods/a?namespace=bar", "", code403},
|
||||
{"DELETE", "/api/v1beta1/pods/a" + syncFlags + "&namespace=bar", "", code403},
|
||||
{"DELETE", "/api/v1beta1/pods/a" + timeoutFlag + "&namespace=bar", "", code403},
|
||||
|
||||
{"POST", "/api/v1beta1/pods" + syncFlags, aPod, code403},
|
||||
{"POST", "/api/v1beta1/pods" + timeoutFlag, aPod, code403},
|
||||
{"GET", "/api/v1beta1/pods", "", code403},
|
||||
{"GET", "/api/v1beta1/pods/a", "", code403},
|
||||
{"DELETE", "/api/v1beta1/pods/a" + syncFlags, "", code403},
|
||||
{"DELETE", "/api/v1beta1/pods/a" + timeoutFlag, "", code403},
|
||||
}
|
||||
|
||||
for _, r := range requests {
|
||||
@@ -718,15 +718,15 @@ func TestKindAuthorization(t *testing.T) {
|
||||
body string
|
||||
statusCodes map[int]bool // allowed status codes.
|
||||
}{
|
||||
{"POST", "/api/v1beta1/services" + syncFlags, aService, code200},
|
||||
{"POST", "/api/v1beta1/services" + timeoutFlag, aService, code200},
|
||||
{"GET", "/api/v1beta1/services", "", code200},
|
||||
{"GET", "/api/v1beta1/services/a", "", code200},
|
||||
{"DELETE", "/api/v1beta1/services/a" + syncFlags, "", code200},
|
||||
{"DELETE", "/api/v1beta1/services/a" + timeoutFlag, "", code200},
|
||||
|
||||
{"POST", "/api/v1beta1/pods" + syncFlags, aPod, code403},
|
||||
{"POST", "/api/v1beta1/pods" + timeoutFlag, aPod, code403},
|
||||
{"GET", "/api/v1beta1/pods", "", code403},
|
||||
{"GET", "/api/v1beta1/pods/a", "", code403},
|
||||
{"DELETE", "/api/v1beta1/pods/a" + syncFlags, "", code403},
|
||||
{"DELETE", "/api/v1beta1/pods/a" + timeoutFlag, "", code403},
|
||||
}
|
||||
|
||||
for _, r := range requests {
|
||||
|
Reference in New Issue
Block a user