diff --git a/.travis.yml b/.travis.yml index 0e24e59f..00287d66 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,8 +16,6 @@ matrix: env: GO111MODULE=on - go: 1.12.x env: GO111MODULE=on - - go: 1.9.x - env: GAE=1 go_import_path: google.golang.org/grpc @@ -30,13 +28,11 @@ before_install: install: - try3() { eval "$*" || eval "$*" || eval "$*"; } - try3 'if [[ "${GO111MODULE}" = "on" ]]; then go mod download; else make testdeps; fi' - - if [[ -n "${GAE}" ]]; then source ./install_gae.sh; make testappenginedeps; fi - if [[ -n "${VET}" ]]; then ./vet.sh -install; fi script: - set -e - if [[ -n "${TESTEXTRAS}" ]]; then examples/examples_test.sh; interop/interop_test.sh; make testsubmodule; exit 0; fi - if [[ -n "${VET}" ]]; then ./vet.sh; fi - - if [[ -n "${GAE}" ]]; then make testappengine; exit 0; fi - if [[ -n "${RACE}" ]]; then make testrace; exit 0; fi - make test diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4f1567e2..cd03f8c7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -57,6 +57,5 @@ How to get your contributions merged smoothly and quickly. - `make vet` to catch vet errors - `make test` to run the tests - `make testrace` to run tests in race mode - - optional `make testappengine` to run tests with appengine - Exceptions to the rules can be made if there's a compelling reason for doing so. diff --git a/Makefile b/Makefile index 410f7d56..bd892e59 100644 --- a/Makefile +++ b/Makefile @@ -22,12 +22,6 @@ test: testdeps testsubmodule: testdeps cd security/advancedtls && go test -cpu 1,4 -timeout 7m google.golang.org/grpc/security/advancedtls/... -testappengine: testappenginedeps - goapp test -cpu 1,4 -timeout 7m google.golang.org/grpc/... - -testappenginedeps: - goapp get -d -v -t -tags 'appengine appenginevm' google.golang.org/grpc/... - testdeps: go get -d -v -t google.golang.org/grpc/... @@ -53,8 +47,6 @@ vetdeps: deps \ proto \ test \ - testappengine \ - testappenginedeps \ testdeps \ testrace \ updatedeps \ diff --git a/balancer/rls/internal/balancer.go b/balancer/rls/internal/balancer.go index aeb509aa..7af97b76 100644 --- a/balancer/rls/internal/balancer.go +++ b/balancer/rls/internal/balancer.go @@ -1,5 +1,3 @@ -// +build go1.10 - /* * * Copyright 2020 gRPC authors. diff --git a/balancer/rls/internal/balancer_test.go b/balancer/rls/internal/balancer_test.go index 9df769c2..973f5e0c 100644 --- a/balancer/rls/internal/balancer_test.go +++ b/balancer/rls/internal/balancer_test.go @@ -1,5 +1,3 @@ -// +build go1.10 - /* * * Copyright 2020 gRPC authors. diff --git a/balancer/rls/internal/builder.go b/balancer/rls/internal/builder.go index c38babff..7c29caef 100644 --- a/balancer/rls/internal/builder.go +++ b/balancer/rls/internal/builder.go @@ -1,5 +1,3 @@ -// +build go1.10 - /* * * Copyright 2020 gRPC authors. diff --git a/balancer/rls/internal/client_test.go b/balancer/rls/internal/client_test.go index 1a1a75d1..a45850dc 100644 --- a/balancer/rls/internal/client_test.go +++ b/balancer/rls/internal/client_test.go @@ -1,5 +1,3 @@ -// +build go1.10 - /* * * Copyright 2020 gRPC authors. diff --git a/balancer/rls/internal/config.go b/balancer/rls/internal/config.go index 0a8d2d91..94ed3c5e 100644 --- a/balancer/rls/internal/config.go +++ b/balancer/rls/internal/config.go @@ -1,5 +1,3 @@ -// +build go1.10 - /* * * Copyright 2020 gRPC authors. diff --git a/balancer/rls/internal/config_test.go b/balancer/rls/internal/config_test.go index 9200a29d..fa22e15a 100644 --- a/balancer/rls/internal/config_test.go +++ b/balancer/rls/internal/config_test.go @@ -1,5 +1,3 @@ -// +build go1.10 - /* * * Copyright 2020 gRPC authors. diff --git a/balancer/rls/internal/keys/builder.go b/balancer/rls/internal/keys/builder.go index abc076ab..5ce5a9da 100644 --- a/balancer/rls/internal/keys/builder.go +++ b/balancer/rls/internal/keys/builder.go @@ -1,5 +1,3 @@ -// +build go1.10 - /* * * Copyright 2020 gRPC authors. diff --git a/balancer/rls/internal/keys/builder_test.go b/balancer/rls/internal/keys/builder_test.go index f5e03ac5..a5cad29e 100644 --- a/balancer/rls/internal/keys/builder_test.go +++ b/balancer/rls/internal/keys/builder_test.go @@ -1,5 +1,3 @@ -// +build go1.10 - /* * * Copyright 2020 gRPC authors. diff --git a/balancer/rls/internal/picker.go b/balancer/rls/internal/picker.go index 698185b1..ce710053 100644 --- a/balancer/rls/internal/picker.go +++ b/balancer/rls/internal/picker.go @@ -1,5 +1,3 @@ -// +build go1.10 - /* * * Copyright 2020 gRPC authors. diff --git a/balancer/rls/internal/picker_test.go b/balancer/rls/internal/picker_test.go index b14a9fad..fc5f935d 100644 --- a/balancer/rls/internal/picker_test.go +++ b/balancer/rls/internal/picker_test.go @@ -1,5 +1,3 @@ -// +build go1.10 - /* * * Copyright 2020 gRPC authors. diff --git a/channelz/service/func_linux.go b/channelz/service/func_linux.go index cfa457a6..ce38a921 100644 --- a/channelz/service/func_linux.go +++ b/channelz/service/func_linux.go @@ -1,5 +1,3 @@ -// +build !appengine - /* * * Copyright 2018 gRPC authors. diff --git a/channelz/service/func_nonlinux.go b/channelz/service/func_nonlinux.go index eb53334e..64ecea94 100644 --- a/channelz/service/func_nonlinux.go +++ b/channelz/service/func_nonlinux.go @@ -1,4 +1,4 @@ -// +build !linux appengine +// +build !linux /* * diff --git a/channelz/service/service_sktopt_test.go b/channelz/service/service_sktopt_test.go index 1a12ed0e..e2d024f8 100644 --- a/channelz/service/service_sktopt_test.go +++ b/channelz/service/service_sktopt_test.go @@ -1,4 +1,4 @@ -// +build linux,!appengine +// +build linux // +build 386 amd64 /* diff --git a/channelz/service/service_test.go b/channelz/service/service_test.go index e6a7d8eb..41f4f31a 100644 --- a/channelz/service/service_test.go +++ b/channelz/service/service_test.go @@ -58,7 +58,7 @@ type protoToSocketOptFunc func([]*channelzpb.SocketOption) *channelz.SocketOptio // protoToSocketOpt is used in function socketProtoToStruct to extract socket option // data from unmarshaled proto message. -// It is only defined under linux, non-appengine environment on x86 architecture. +// It is only defined under linux environment on x86 architecture. var protoToSocketOpt protoToSocketOptFunc // emptyTime is used for detecting unset value of time.Time type. diff --git a/channelz/service/util_sktopt_386_test.go b/channelz/service/util_sktopt_386_test.go index cdc2fda4..d9c98127 100644 --- a/channelz/service/util_sktopt_386_test.go +++ b/channelz/service/util_sktopt_386_test.go @@ -1,4 +1,4 @@ -// +build 386,linux,!appengine +// +build 386,linux /* * diff --git a/channelz/service/util_sktopt_amd64_test.go b/channelz/service/util_sktopt_amd64_test.go index 7ebe9c70..0ff06d12 100644 --- a/channelz/service/util_sktopt_amd64_test.go +++ b/channelz/service/util_sktopt_amd64_test.go @@ -1,4 +1,4 @@ -// +build amd64,linux,!appengine +// +build amd64,linux /* * diff --git a/credentials/go12.go b/credentials/go12.go deleted file mode 100644 index ccbf35b3..00000000 --- a/credentials/go12.go +++ /dev/null @@ -1,30 +0,0 @@ -// +build go1.12 - -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package credentials - -import "crypto/tls" - -// This init function adds cipher suite constants only defined in Go 1.12. -func init() { - cipherSuiteLookup[tls.TLS_AES_128_GCM_SHA256] = "TLS_AES_128_GCM_SHA256" - cipherSuiteLookup[tls.TLS_AES_256_GCM_SHA384] = "TLS_AES_256_GCM_SHA384" - cipherSuiteLookup[tls.TLS_CHACHA20_POLY1305_SHA256] = "TLS_CHACHA20_POLY1305_SHA256" -} diff --git a/credentials/internal/syscallconn.go b/credentials/internal/syscallconn.go index 2f4472be..264c7298 100644 --- a/credentials/internal/syscallconn.go +++ b/credentials/internal/syscallconn.go @@ -1,5 +1,3 @@ -// +build !appengine - /* * * Copyright 2018 gRPC authors. diff --git a/credentials/internal/syscallconn_appengine.go b/credentials/internal/syscallconn_appengine.go deleted file mode 100644 index d4346e9e..00000000 --- a/credentials/internal/syscallconn_appengine.go +++ /dev/null @@ -1,30 +0,0 @@ -// +build appengine - -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package internal - -import ( - "net" -) - -// WrapSyscallConn returns newConn on appengine. -func WrapSyscallConn(rawConn, newConn net.Conn) net.Conn { - return newConn -} diff --git a/credentials/internal/syscallconn_test.go b/credentials/internal/syscallconn_test.go index a5a7d726..6700e754 100644 --- a/credentials/internal/syscallconn_test.go +++ b/credentials/internal/syscallconn_test.go @@ -1,5 +1,3 @@ -// +build !appengine - /* * * Copyright 2018 gRPC authors. diff --git a/credentials/tls.go b/credentials/tls.go index 1ba6f3a6..dfc4bfe0 100644 --- a/credentials/tls.go +++ b/credentials/tls.go @@ -241,6 +241,10 @@ var cipherSuiteLookup = map[uint16]string{ tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256: "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256", tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305: "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305", tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305: "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305", + // Go 1.12 + tls.TLS_AES_128_GCM_SHA256: "TLS_AES_128_GCM_SHA256", + tls.TLS_AES_256_GCM_SHA384: "TLS_AES_256_GCM_SHA384", + tls.TLS_CHACHA20_POLY1305_SHA256: "TLS_CHACHA20_POLY1305_SHA256", } // cloneTLSConfig returns a shallow clone of the exported diff --git a/examples/features/xds/client/main.go b/examples/features/xds/client/main.go index 9a67aabc..b1daa1ca 100644 --- a/examples/features/xds/client/main.go +++ b/examples/features/xds/client/main.go @@ -1,5 +1,3 @@ -// +build go1.11 - /* * * Copyright 2020 gRPC authors. diff --git a/examples/features/xds/server/main.go b/examples/features/xds/server/main.go index 512c4839..7e081564 100644 --- a/examples/features/xds/server/main.go +++ b/examples/features/xds/server/main.go @@ -1,5 +1,3 @@ -// +build go1.11 - /* * * Copyright 2020 gRPC authors. diff --git a/install_gae.sh b/install_gae.sh deleted file mode 100755 index 7c7bcada..00000000 --- a/install_gae.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -TMP=$(mktemp -d /tmp/sdk.XXX) \ -&& curl -o $TMP.zip "https://storage.googleapis.com/appengine-sdks/featured/go_appengine_sdk_linux_amd64-1.9.68.zip" \ -&& unzip -q $TMP.zip -d $TMP \ -&& export PATH="$PATH:$TMP/go_appengine" diff --git a/internal/channelz/types_linux.go b/internal/channelz/types_linux.go index 692dd618..1b1c4cce 100644 --- a/internal/channelz/types_linux.go +++ b/internal/channelz/types_linux.go @@ -1,5 +1,3 @@ -// +build !appengine - /* * * Copyright 2018 gRPC authors. diff --git a/internal/channelz/types_nonlinux.go b/internal/channelz/types_nonlinux.go index 19c2fc52..50177079 100644 --- a/internal/channelz/types_nonlinux.go +++ b/internal/channelz/types_nonlinux.go @@ -1,4 +1,4 @@ -// +build !linux appengine +// +build !linux /* * @@ -37,6 +37,6 @@ type SocketOptionData struct { // Windows OS doesn't support Socket Option func (s *SocketOptionData) Getsockopt(fd uintptr) { once.Do(func() { - logger.Warning("Channelz: socket options are not supported on non-linux os and appengine.") + logger.Warning("Channelz: socket options are not supported on non-linux os.") }) } diff --git a/internal/channelz/util_linux.go b/internal/channelz/util_linux.go index fdf409d5..49432beb 100644 --- a/internal/channelz/util_linux.go +++ b/internal/channelz/util_linux.go @@ -1,4 +1,4 @@ -// +build linux,!appengine +// +build linux /* * diff --git a/internal/channelz/util_nonlinux.go b/internal/channelz/util_nonlinux.go index 8864a081..d600417f 100644 --- a/internal/channelz/util_nonlinux.go +++ b/internal/channelz/util_nonlinux.go @@ -1,4 +1,4 @@ -// +build !linux appengine +// +build !linux /* * diff --git a/internal/channelz/util_test.go b/internal/channelz/util_test.go index 9efe3873..2621e741 100644 --- a/internal/channelz/util_test.go +++ b/internal/channelz/util_test.go @@ -1,4 +1,4 @@ -// +build linux,go1.10,!appengine +// +build linux /* * diff --git a/internal/credentials/gobefore110.go b/internal/credentials/gobefore110.go deleted file mode 100644 index 743713e1..00000000 --- a/internal/credentials/gobefore110.go +++ /dev/null @@ -1,31 +0,0 @@ -// +build !go1.10 - -/* - * - * Copyright 2020 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package credentials - -import ( - "crypto/tls" - "net/url" -) - -//TODO(ZhenLian): delete this file when we remove Go 1.9 tests. -func SPIFFEIDFromState(state tls.ConnectionState) *url.URL { - return nil -} diff --git a/internal/credentials/go110.go b/internal/credentials/spiffe.go similarity index 99% rename from internal/credentials/go110.go rename to internal/credentials/spiffe.go index d55b5203..c8681306 100644 --- a/internal/credentials/go110.go +++ b/internal/credentials/spiffe.go @@ -1,5 +1,3 @@ -// +build go1.10 - /* * * Copyright 2020 gRPC authors. diff --git a/internal/credentials/go110_test.go b/internal/credentials/spiffe_test.go similarity index 99% rename from internal/credentials/go110_test.go rename to internal/credentials/spiffe_test.go index 19266cce..324874e6 100644 --- a/internal/credentials/go110_test.go +++ b/internal/credentials/spiffe_test.go @@ -1,5 +1,3 @@ -// +build go1.10 - /* * * Copyright 2020 gRPC authors. diff --git a/internal/profiling/buffer/buffer.go b/internal/profiling/buffer/buffer.go index 45745cd0..f4cd4201 100644 --- a/internal/profiling/buffer/buffer.go +++ b/internal/profiling/buffer/buffer.go @@ -1,5 +1,3 @@ -// +build !appengine - /* * * Copyright 2019 gRPC authors. diff --git a/internal/profiling/buffer/buffer_appengine.go b/internal/profiling/buffer/buffer_appengine.go deleted file mode 100644 index c92599e5..00000000 --- a/internal/profiling/buffer/buffer_appengine.go +++ /dev/null @@ -1,43 +0,0 @@ -// +build appengine - -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package buffer - -// CircularBuffer is a no-op implementation for appengine builds. -// -// Appengine does not support stats because of lack of the support for unsafe -// pointers, which are necessary to efficiently store and retrieve things into -// and from a circular buffer. As a result, Push does not do anything and Drain -// returns an empty slice. -type CircularBuffer struct{} - -// NewCircularBuffer returns a no-op for appengine builds. -func NewCircularBuffer(size uint32) (*CircularBuffer, error) { - return nil, nil -} - -// Push returns a no-op for appengine builds. -func (cb *CircularBuffer) Push(x interface{}) { -} - -// Drain returns a no-op for appengine builds. -func (cb *CircularBuffer) Drain() []interface{} { - return nil -} diff --git a/internal/profiling/buffer/buffer_test.go b/internal/profiling/buffer/buffer_test.go index 86bd77d4..a7f3b61e 100644 --- a/internal/profiling/buffer/buffer_test.go +++ b/internal/profiling/buffer/buffer_test.go @@ -1,5 +1,3 @@ -// +build !appengine - /* * * Copyright 2019 gRPC authors. diff --git a/internal/profiling/profiling_test.go b/internal/profiling/profiling_test.go index f2065449..a6184a16 100644 --- a/internal/profiling/profiling_test.go +++ b/internal/profiling/profiling_test.go @@ -1,5 +1,3 @@ -// +build !appengine - /* * * Copyright 2019 gRPC authors. diff --git a/internal/syscall/syscall_linux.go b/internal/syscall/syscall_linux.go index c50468a0..3743bd45 100644 --- a/internal/syscall/syscall_linux.go +++ b/internal/syscall/syscall_linux.go @@ -1,5 +1,3 @@ -// +build !appengine - /* * * Copyright 2018 gRPC authors. @@ -43,7 +41,7 @@ func GetCPUTime() int64 { return ts.Nano() } -// Rusage is an alias for syscall.Rusage under linux non-appengine environment. +// Rusage is an alias for syscall.Rusage under linux environment. type Rusage syscall.Rusage // GetRusage returns the resource usage of current process. diff --git a/internal/syscall/syscall_nonlinux.go b/internal/syscall/syscall_nonlinux.go index adae60d6..95b71343 100644 --- a/internal/syscall/syscall_nonlinux.go +++ b/internal/syscall/syscall_nonlinux.go @@ -1,4 +1,4 @@ -// +build !linux appengine +// +build !linux /* * @@ -35,40 +35,40 @@ var logger = grpclog.Component("core") func log() { once.Do(func() { - logger.Info("CPU time info is unavailable on non-linux or appengine environment.") + logger.Info("CPU time info is unavailable on non-linux environment.") }) } // GetCPUTime returns the how much CPU time has passed since the start of this process. -// It always returns 0 under non-linux or appengine environment. +// It always returns 0 under non-linux environment. func GetCPUTime() int64 { log() return 0 } -// Rusage is an empty struct under non-linux or appengine environment. +// Rusage is an empty struct under non-linux environment. type Rusage struct{} -// GetRusage is a no-op function under non-linux or appengine environment. +// GetRusage is a no-op function under non-linux environment. func GetRusage() (rusage *Rusage) { log() return nil } // CPUTimeDiff returns the differences of user CPU time and system CPU time used -// between two Rusage structs. It a no-op function for non-linux or appengine environment. +// between two Rusage structs. It a no-op function for non-linux environment. func CPUTimeDiff(first *Rusage, latest *Rusage) (float64, float64) { log() return 0, 0 } -// SetTCPUserTimeout is a no-op function under non-linux or appengine environments +// SetTCPUserTimeout is a no-op function under non-linux environments func SetTCPUserTimeout(conn net.Conn, timeout time.Duration) error { log() return nil } -// GetTCPUserTimeout is a no-op function under non-linux or appengine environments +// GetTCPUserTimeout is a no-op function under non-linux environments // a negative return value indicates the operation is not supported func GetTCPUserTimeout(conn net.Conn) (int, error) { log() diff --git a/interop/grpclb_fallback/client.go b/interop/grpclb_fallback/client.go index ce7cc8e6..853c9a43 100644 --- a/interop/grpclb_fallback/client.go +++ b/interop/grpclb_fallback/client.go @@ -1,6 +1,4 @@ // +build linux -// +build !appengine -// +build go1.11 /* * diff --git a/security/advancedtls/sni_110.go b/security/advancedtls/sni.go similarity index 98% rename from security/advancedtls/sni_110.go rename to security/advancedtls/sni.go index 5c9a6ae1..00e551fa 100644 --- a/security/advancedtls/sni_110.go +++ b/security/advancedtls/sni.go @@ -1,5 +1,3 @@ -// +build go1.10 - /* * * Copyright 2020 gRPC authors. diff --git a/security/advancedtls/sni_before_110.go b/security/advancedtls/sni_before_110.go deleted file mode 100644 index 180e3a05..00000000 --- a/security/advancedtls/sni_before_110.go +++ /dev/null @@ -1,41 +0,0 @@ -// +build !go1.10 - -/* - * - * Copyright 2020 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package advancedtls - -import ( - "crypto/tls" - "fmt" -) - -// buildGetCertificates returns the first element of o.GetCertificates. -func buildGetCertificates(clientHello *tls.ClientHelloInfo, o *ServerOptions) (*tls.Certificate, error) { - if o.GetCertificates == nil { - return nil, fmt.Errorf("function GetCertificates must be specified") - } - certificates, err := o.GetCertificates(clientHello) - if err != nil { - return nil, err - } - if len(certificates) == 0 { - return nil, fmt.Errorf("no certificates configured") - } - return certificates[0], nil -} diff --git a/security/advancedtls/sni_test_before_110.go b/security/advancedtls/sni_test_before_110.go deleted file mode 100644 index e31e2e6e..00000000 --- a/security/advancedtls/sni_test_before_110.go +++ /dev/null @@ -1,108 +0,0 @@ -// +build !go1.10 - -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package advancedtls - -import ( - "crypto/tls" - "testing" - - "github.com/google/go-cmp/cmp" - "google.golang.org/grpc/security/advancedtls/testdata" -) - -// TestGetCertificatesSNI tests SNI logic for go1.9. -func TestGetCertificatesSNI(t *testing.T) { - // Load server certificates for setting the serverGetCert callback function. - serverCert1, err := tls.LoadX509KeyPair(testdata.Path("server_cert_1.pem"), testdata.Path("server_key_1.pem")) - if err != nil { - t.Fatalf("tls.LoadX509KeyPair(server_cert_1.pem, server_key_1.pem) failed: %v", err) - } - serverCert2, err := tls.LoadX509KeyPair(testdata.Path("server_cert_2.pem"), testdata.Path("server_key_2.pem")) - if err != nil { - t.Fatalf("tls.LoadX509KeyPair(server_cert_2.pem, server_key_2.pem) failed: %v", err) - } - serverCert3, err := tls.LoadX509KeyPair(testdata.Path("server_cert_3.pem"), testdata.Path("server_key_3.pem")) - if err != nil { - t.Fatalf("tls.LoadX509KeyPair(server_cert_3.pem, server_key_3.pem) failed: %v", err) - } - - tests := []struct { - desc string - serverGetCert func(*tls.ClientHelloInfo) ([]*tls.Certificate, error) - serverName string - wantCert tls.Certificate - }{ - { - desc: "Select serverCert1", - serverGetCert: func(info *tls.ClientHelloInfo) ([]*tls.Certificate, error) { - return []*tls.Certificate{&serverCert1, &serverCert2, &serverCert3}, nil - }, - // "foo.bar.com" is the common name on server certificate server_cert_1.pem. - serverName: "foo.bar.com", - wantCert: serverCert1, - }, - { - desc: "Select serverCert2", - serverGetCert: func(info *tls.ClientHelloInfo) ([]*tls.Certificate, error) { - return []*tls.Certificate{&serverCert1, &serverCert2, &serverCert3}, nil - }, - // "foo.bar.server2.com" is the common name on server certificate server_cert_2.pem. - serverName: "foo.bar.server2.com", - wantCert: serverCert1, - }, - { - desc: "Select serverCert3", - serverGetCert: func(info *tls.ClientHelloInfo) ([]*tls.Certificate, error) { - return []*tls.Certificate{&serverCert1, &serverCert2, &serverCert3}, nil - }, - // "google.com" is one of the DNS names on server certificate server_cert_3.pem. - serverName: "google.com", - wantCert: serverCert1, - }, - } - for _, test := range tests { - test := test - t.Run(test.desc, func(t *testing.T) { - serverOptions := &ServerOptions{ - GetCertificates: test.serverGetCert, - } - serverConfig, err := serverOptions.config() - if err != nil { - t.Fatalf("serverOptions.config() failed: %v", err) - } - pointFormatUncompressed := uint8(0) - clientHello := &tls.ClientHelloInfo{ - CipherSuites: []uint16{tls.TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA}, - ServerName: test.serverName, - SupportedCurves: []tls.CurveID{tls.CurveP256}, - SupportedPoints: []uint8{pointFormatUncompressed}, - SupportedVersions: []uint16{tls.VersionTLS10}, - } - gotCertificate, err := serverConfig.GetCertificate(clientHello) - if err != nil { - t.Fatalf("serverConfig.GetCertificate(clientHello) failed: %v", err) - } - if !cmp.Equal(gotCertificate, test.wantCert, cmp.AllowUnexported(tls.Certificate{})) { - t.Errorf("GetCertificates() = %v, want %v", gotCertificate, test.wantCert) - } - }) - } -} diff --git a/security/advancedtls/sni_test_110.go b/security/advancedtls/sni_test_disabled.go similarity index 99% rename from security/advancedtls/sni_test_110.go rename to security/advancedtls/sni_test_disabled.go index 130ccde5..3e9e19c1 100644 --- a/security/advancedtls/sni_test_110.go +++ b/security/advancedtls/sni_test_disabled.go @@ -1,5 +1,3 @@ -// +build go1.10 - /* * * Copyright 2019 gRPC authors. diff --git a/test/channelz_linux_go110_test.go b/test/channelz_linux_go110_test.go index ede329ad..dea374bf 100644 --- a/test/channelz_linux_go110_test.go +++ b/test/channelz_linux_go110_test.go @@ -1,4 +1,4 @@ -// +build go1.10,linux,!appengine +// +build linux /* * diff --git a/test/go_vet/vet.go b/test/go_vet/vet.go deleted file mode 100644 index 475e8d68..00000000 --- a/test/go_vet/vet.go +++ /dev/null @@ -1,53 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// vet checks whether files that are supposed to be built on appengine running -// Go 1.10 or earlier import an unsupported package (e.g. "unsafe", "syscall"). -package main - -import ( - "fmt" - "go/build" - "os" -) - -func main() { - fail := false - b := build.Default - b.BuildTags = []string{"appengine", "appenginevm"} - argsWithoutProg := os.Args[1:] - for _, dir := range argsWithoutProg { - p, err := b.Import(".", dir, 0) - if _, ok := err.(*build.NoGoError); ok { - continue - } else if err != nil { - fmt.Printf("build.Import failed due to %v\n", err) - fail = true - continue - } - for _, pkg := range p.Imports { - if pkg == "syscall" || pkg == "unsafe" { - fmt.Printf("Package %s/%s importing %s package without appengine build tag is NOT ALLOWED!\n", p.Dir, p.Name, pkg) - fail = true - } - } - } - if fail { - os.Exit(1) - } -} diff --git a/vet.sh b/vet.sh index 2116d198..8c14c7d3 100755 --- a/vet.sh +++ b/vet.sh @@ -89,10 +89,6 @@ not git grep "\(import \|^\s*\)\"github.com/golang/protobuf/ptypes/" -- "*.go" # - Ensure all xds proto imports are renamed to *pb or *grpc. git grep '"github.com/envoyproxy/go-control-plane/envoy' -- '*.go' | not grep -v 'pb "\|grpc "' -# - Check imports that are illegal in appengine (until Go 1.11). -# TODO: Remove when we drop Go 1.10 support -go list -f {{.Dir}} ./... | xargs go run test/go_vet/vet.go - # - gofmt, goimports, golint (with exceptions for generated code), go vet. gofmt -s -d -l . 2>&1 | fail_on_output goimports -l . 2>&1 | not grep -vE "\.pb\.go" diff --git a/xds/internal/client/bootstrap/bootstrap_test.go b/xds/internal/client/bootstrap/bootstrap_test.go index 4a825aa3..18c28db3 100644 --- a/xds/internal/client/bootstrap/bootstrap_test.go +++ b/xds/internal/client/bootstrap/bootstrap_test.go @@ -1,5 +1,3 @@ -// +build !appengine - /* * * Copyright 2019 gRPC authors.