aboutsummaryrefslogtreecommitdiff
path: root/vendor/google.golang.org/appengine
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/google.golang.org/appengine')
-rw-r--r--vendor/google.golang.org/appengine/appengine.go3
-rw-r--r--vendor/google.golang.org/appengine/internal/api.go22
-rw-r--r--vendor/google.golang.org/appengine/internal/api_common.go30
3 files changed, 49 insertions, 6 deletions
diff --git a/vendor/google.golang.org/appengine/appengine.go b/vendor/google.golang.org/appengine/appengine.go
index 475cf2e..d4f8084 100644
--- a/vendor/google.golang.org/appengine/appengine.go
+++ b/vendor/google.golang.org/appengine/appengine.go
@@ -28,7 +28,8 @@ import (
// See https://cloud.google.com/appengine/docs/flexible/custom-runtimes#health_check_requests
// for details on how to do your own health checking.
//
-// Main is not yet supported on App Engine Standard.
+// On App Engine Standard it ensures the server has started and is prepared to
+// receive requests.
//
// Main never returns.
//
diff --git a/vendor/google.golang.org/appengine/internal/api.go b/vendor/google.golang.org/appengine/internal/api.go
index e9c56d4..09562c4 100644
--- a/vendor/google.golang.org/appengine/internal/api.go
+++ b/vendor/google.golang.org/appengine/internal/api.go
@@ -32,7 +32,8 @@ import (
)
const (
- apiPath = "/rpc_http"
+ apiPath = "/rpc_http"
+ defaultTicketSuffix = "/default.20150612t184001.0"
)
var (
@@ -269,8 +270,13 @@ func WithContext(parent netcontext.Context, req *http.Request) netcontext.Contex
return withContext(parent, c)
}
-func getDefaultTicket() string {
+// DefaultTicket returns a ticket used for background context or dev_appserver.
+func DefaultTicket() string {
defaultTicketOnce.Do(func() {
+ if IsDevAppServer() {
+ defaultTicket = "testapp" + defaultTicketSuffix
+ return
+ }
appID := partitionlessAppID()
escAppID := strings.Replace(strings.Replace(appID, ":", "_", -1), ".", "_", -1)
majVersion := VersionID(nil)
@@ -291,7 +297,7 @@ func BackgroundContext() netcontext.Context {
}
// Compute background security ticket.
- ticket := getDefaultTicket()
+ ticket := DefaultTicket()
ctxs.bg = &context{
req: &http.Request{
@@ -485,9 +491,15 @@ func Call(ctx netcontext.Context, service, method string, in, out proto.Message)
}
ticket := c.req.Header.Get(ticketHeader)
- // Fall back to use background ticket when the request ticket is not available in Flex.
+ // Use a test ticket under test environment.
+ if ticket == "" {
+ if appid := ctx.Value(&appIDOverrideKey); appid != nil {
+ ticket = appid.(string) + defaultTicketSuffix
+ }
+ }
+ // Fall back to use background ticket when the request ticket is not available in Flex or dev_appserver.
if ticket == "" {
- ticket = getDefaultTicket()
+ ticket = DefaultTicket()
}
req := &remotepb.Request{
ServiceName: &service,
diff --git a/vendor/google.golang.org/appengine/internal/api_common.go b/vendor/google.golang.org/appengine/internal/api_common.go
index 2db33a7..8c3eece 100644
--- a/vendor/google.golang.org/appengine/internal/api_common.go
+++ b/vendor/google.golang.org/appengine/internal/api_common.go
@@ -5,6 +5,8 @@
package internal
import (
+ "os"
+
"github.com/golang/protobuf/proto"
netcontext "golang.org/x/net/context"
)
@@ -84,3 +86,31 @@ func Logf(ctx netcontext.Context, level int64, format string, args ...interface{
func NamespacedContext(ctx netcontext.Context, namespace string) netcontext.Context {
return withNamespace(ctx, namespace)
}
+
+// SetTestEnv sets the env variables for testing background ticket in Flex.
+func SetTestEnv() func() {
+ var environ = []struct {
+ key, value string
+ }{
+ {"GAE_LONG_APP_ID", "my-app-id"},
+ {"GAE_MINOR_VERSION", "067924799508853122"},
+ {"GAE_MODULE_INSTANCE", "0"},
+ {"GAE_MODULE_NAME", "default"},
+ {"GAE_MODULE_VERSION", "20150612t184001"},
+ }
+
+ for _, v := range environ {
+ old := os.Getenv(v.key)
+ os.Setenv(v.key, v.value)
+ v.value = old
+ }
+ return func() { // Restore old environment after the test completes.
+ for _, v := range environ {
+ if v.value == "" {
+ os.Unsetenv(v.key)
+ continue
+ }
+ os.Setenv(v.key, v.value)
+ }
+ }
+}