Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

credentials/alts: Simplify "New" APIs #1895

Merged
merged 1 commit into from Mar 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions credentials/alts/alts.go
Expand Up @@ -100,13 +100,13 @@ type altsTC struct {
accounts []string
}

// NewClientALTS constructs a client-side ALTS TransportCredentials object.
func NewClientALTS(targetServiceAccounts []string) credentials.TransportCredentials {
// NewClient constructs a client-side ALTS TransportCredentials object.
func NewClient(targetServiceAccounts []string) credentials.TransportCredentials {
return newALTS(core.ClientSide, targetServiceAccounts)
}

// NewServerALTS constructs a server-side ALTS TransportCredentials object.
func NewServerALTS() credentials.TransportCredentials {
// NewServer constructs a server-side ALTS TransportCredentials object.
func NewServer() credentials.TransportCredentials {
return newALTS(core.ServerSide, nil)
}

Expand Down
16 changes: 8 additions & 8 deletions credentials/alts/alts_test.go
Expand Up @@ -27,8 +27,8 @@ import (

func TestInfoServerName(t *testing.T) {
// This is not testing any handshaker functionality, so it's fine to only
// use NewServerALTS and not NewClientALTS.
alts := NewServerALTS()
// use NewServer and not NewClient.
alts := NewServer()
if got, want := alts.Info().ServerName, ""; got != want {
t.Fatalf("%v.Info().ServerName = %v, want %v", alts, got, want)
}
Expand All @@ -37,8 +37,8 @@ func TestInfoServerName(t *testing.T) {
func TestOverrideServerName(t *testing.T) {
wantServerName := "server.name"
// This is not testing any handshaker functionality, so it's fine to only
// use NewServerALTS and not NewClientALTS.
c := NewServerALTS()
// use NewServer and not NewClient.
c := NewServer()
c.OverrideServerName(wantServerName)
if got, want := c.Info().ServerName, wantServerName; got != want {
t.Fatalf("c.Info().ServerName = %v, want %v", got, want)
Expand All @@ -48,8 +48,8 @@ func TestOverrideServerName(t *testing.T) {
func TestClone(t *testing.T) {
wantServerName := "server.name"
// This is not testing any handshaker functionality, so it's fine to only
// use NewServerALTS and not NewClientALTS.
c := NewServerALTS()
// use NewServer and not NewClient.
c := NewServer()
c.OverrideServerName(wantServerName)
cc := c.Clone()
if got, want := cc.Info().ServerName, wantServerName; got != want {
Expand All @@ -66,8 +66,8 @@ func TestClone(t *testing.T) {

func TestInfo(t *testing.T) {
// This is not testing any handshaker functionality, so it's fine to only
// use NewServerALTS and not NewClientALTS.
c := NewServerALTS()
// use NewServer and not NewClient.
c := NewServer()
info := c.Info()
if got, want := info.ProtocolVersion, ""; got != want {
t.Errorf("info.ProtocolVersion=%v, want %v", got, want)
Expand Down
2 changes: 1 addition & 1 deletion interop/alts/client/client.go
Expand Up @@ -41,7 +41,7 @@ var (
func main() {
flag.Parse()

altsTC := alts.NewClientALTS(nil)
altsTC := alts.NewClient(nil)
// Block until the server is ready.
conn, err := grpc.Dial(*serverAddr, grpc.WithTransportCredentials(altsTC), grpc.WithBlock())
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion interop/alts/server/server.go
Expand Up @@ -41,7 +41,7 @@ func main() {
if err != nil {
grpclog.Fatalf("gRPC Server: failed to start the server at %v: %v", *serverAddr, err)
}
altsTC := alts.NewServerALTS()
altsTC := alts.NewServer()
grpcServer := grpc.NewServer(grpc.Creds(altsTC))
testpb.RegisterTestServiceServer(grpcServer, interop.NewTestServer())
grpcServer.Serve(lis)
Expand Down