@@ -65,18 +65,18 @@ func TestCertFromPEM(t *testing.T) {
6565
6666const (
6767 authorityFmt = "https://%s/%s"
68- fakeAuthority = "https://fake_authority/fake "
68+ fakeAuthority = "https://fake_authority/fake_tenant "
6969 fakeClientID = "fake_client_id"
7070 fakeSecret = "fake_secret"
71- fakeTokenEndpoint = "https://fake_authority/fake /token"
71+ fakeTokenEndpoint = "https://fake_authority/fake_tenant /token"
7272 localhost = "http://localhost"
7373 refresh = "fake_refresh"
7474 token = "fake_token"
7575)
7676
7777var tokenScope = []string {"the_scope" }
7878
79- func fakeClient (tk accesstokens.TokenResponse , credential Credential , options ... Option ) (Client , error ) {
79+ func fakeClient (tk accesstokens.TokenResponse , credential Credential , fakeAuthority string , options ... Option ) (Client , error ) {
8080 client , err := New (fakeAuthority , fakeClientID , credential , options ... )
8181 if err != nil {
8282 return Client {}, err
@@ -86,7 +86,7 @@ func fakeClient(tk accesstokens.TokenResponse, credential Credential, options ..
8686 }
8787 client .base .Token .Authority = & fake.Authority {
8888 InstanceResp : authority.InstanceDiscoveryResponse {
89- TenantDiscoveryEndpoint : "https://fake_authority/fake /discovery/endpoint" ,
89+ TenantDiscoveryEndpoint : fakeAuthority + " /discovery/endpoint" ,
9090 Metadata : []authority.InstanceDiscoveryMetadata {
9191 {
9292 PreferredNetwork : "fake_authority" ,
@@ -104,8 +104,12 @@ func fakeClient(tk accesstokens.TokenResponse, credential Credential, options ..
104104 },
105105 }
106106 client .base .Token .Resolver = & fake.ResolveEndpoints {
107- Endpoints : authority .NewEndpoints ("https://fake_authority/fake/auth" ,
108- fakeTokenEndpoint , "https://fake_authority/fake/jwt" , "fake_authority" ),
107+ Endpoints : authority .NewEndpoints (
108+ fakeAuthority + "/auth" ,
109+ fakeAuthority + "/token" ,
110+ fakeAuthority + "/jwt" ,
111+ fakeAuthority ,
112+ ),
109113 }
110114 client .base .Token .WSTrust = & fake.WSTrust {}
111115 return client , nil
@@ -137,7 +141,7 @@ func TestAcquireTokenByCredential(t *testing.T) {
137141 ExtExpiresOn : internalTime.DurationTime {T : time .Now ().Add (1 * time .Hour )},
138142 GrantedScopes : accesstokens.Scopes {Slice : tokenScope },
139143 TokenType : "Bearer" ,
140- }, cred )
144+ }, cred , fakeAuthority )
141145 if err != nil {
142146 t .Fatal (err )
143147 }
@@ -304,7 +308,7 @@ func TestAcquireTokenByAssertionCallback(t *testing.T) {
304308 return "" , errors .New ("expected error" )
305309 }
306310 cred := NewCredFromAssertionCallback (getAssertion )
307- client , err := fakeClient (accesstokens.TokenResponse {}, cred )
311+ client , err := fakeClient (accesstokens.TokenResponse {}, cred , fakeAuthority )
308312 if err != nil {
309313 t .Fatal (err )
310314 }
@@ -348,7 +352,7 @@ func TestAcquireTokenByAuthCode(t *testing.T) {
348352 Oid : "123-456" ,
349353 TenantID : "fake" ,
350354 Subject : "nothing" ,
351- Issuer : "https://fake_authority/fake" ,
355+ Issuer : fakeAuthority ,
352356 Audience : "abc-123" ,
353357 ExpirationTime : time .Now ().Add (time .Hour ).Unix (),
354358 IssuedAt : time .Now ().Add (- 5 * time .Minute ).Unix (),
@@ -363,7 +367,7 @@ func TestAcquireTokenByAuthCode(t *testing.T) {
363367 },
364368 }
365369
366- client , err := fakeClient (tr , cred )
370+ client , err := fakeClient (tr , cred , fakeAuthority )
367371 if err != nil {
368372 t .Fatal (err )
369373 }
@@ -590,7 +594,7 @@ func TestNewCredFromCert(t *testing.T) {
590594 AccessToken : token ,
591595 ExpiresOn : internalTime.DurationTime {T : time .Now ().Add (time .Hour )},
592596 GrantedScopes : accesstokens.Scopes {Slice : tokenScope },
593- }, cred , opts ... )
597+ }, cred , fakeAuthority , opts ... )
594598 if err != nil {
595599 t .Fatal (err )
596600 }
@@ -1382,7 +1386,7 @@ func TestWithAuthenticationScheme(t *testing.T) {
13821386 ExtExpiresOn : internalTime.DurationTime {T : time .Now ().Add (1 * time .Hour )},
13831387 GrantedScopes : accesstokens.Scopes {Slice : tokenScope },
13841388 TokenType : "TokenType" ,
1385- }, cred )
1389+ }, cred , fakeAuthority )
13861390 if err != nil {
13871391 t .Fatal (err )
13881392 }
0 commit comments