Skip to content

Commit

Permalink
fix(transport): set UniverseDomain in http.NewClient for new auth (#2773
Browse files Browse the repository at this point in the history
)

* Set value when GOOGLE_API_GO_EXPERIMENTAL_ENABLE_NEW_AUTH_LIB=true
  • Loading branch information
quartzmo authored Sep 5, 2024
1 parent 0c7c227 commit 140d0a5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions transport/grpc/dial.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ func dialPoolNewAuth(ctx context.Context, secure bool, poolSize int, ds *interna
DefaultScopes: ds.DefaultScopes,
SkipValidation: skipValidation,
},
UniverseDomain: ds.UniverseDomain,
})
return pool, err
}
Expand Down
12 changes: 12 additions & 0 deletions transport/grpc/dial_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,15 @@ func TestDial(t *testing.T) {
func TestDialPoolNewAuthDialOptions(t *testing.T) {
oldDialContextNewAuth := dialContextNewAuth
var wantNumOpts int
var universeDomain string
// Replace package var in order to assert DialContext args.
dialContextNewAuth = func(ctx context.Context, secure bool, opts *grpctransport.Options) (grpctransport.GRPCClientConnPool, error) {
if len(opts.GRPCDialOpts) != wantNumOpts {
t.Fatalf("got: %d, want: %d", len(opts.GRPCDialOpts), wantNumOpts)
}
if opts.UniverseDomain != universeDomain {
t.Fatalf("got: %q, want: %q", opts.UniverseDomain, universeDomain)
}
return nil, nil
}
defer func() {
Expand All @@ -67,9 +71,17 @@ func TestDialPoolNewAuthDialOptions(t *testing.T) {
},
wantNumOpts: 1,
},
{
name: "universe domain",
ds: &internal.DialSettings{
UniverseDomain: "example.com",
},
wantNumOpts: 0,
},
} {
t.Run(testcase.name, func(t *testing.T) {
wantNumOpts = testcase.wantNumOpts
universeDomain = testcase.ds.UniverseDomain
dialPoolNewAuth(context.Background(), false, 1, testcase.ds)
})
}
Expand Down
1 change: 1 addition & 0 deletions transport/http/dial.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ func newClientNewAuth(ctx context.Context, base http.RoundTripper, ds *internal.
DefaultScopes: ds.DefaultScopes,
SkipValidation: skipValidation,
},
UniverseDomain: ds.UniverseDomain,
})
if err != nil {
return nil, err
Expand Down

0 comments on commit 140d0a5

Please sign in to comment.