2929 standardRespBody = `{"access_token":"fake_token","expires_in":42,"token_type":"Bearer"}`
3030)
3131
32+ func staticCredentials (tok string ) * auth.Credentials {
33+ return auth .NewCredentials (& auth.CredentialsOptions {
34+ TokenProvider : staticTokenProvider (tok ),
35+ })
36+ }
37+
3238type staticTokenProvider string
3339
3440func (s staticTokenProvider ) Token (context.Context ) (* auth.Token , error ) {
@@ -58,8 +64,8 @@ func TestNewTokenProvider(t *testing.T) {
5864 oldEndpoint := identityBindingEndpoint
5965 identityBindingEndpoint = ts .URL
6066 t .Cleanup (func () { identityBindingEndpoint = oldEndpoint })
61- tp , err := NewTokenProvider (& Options {
62- BaseProvider : staticTokenProvider ("token_base" ),
67+ creds , err := NewCredentials (& Options {
68+ Credentials : staticCredentials ("token_base" ),
6369 Rules : []AccessBoundaryRule {
6470 {
6571 AvailableResource : "test1" ,
@@ -70,16 +76,16 @@ func TestNewTokenProvider(t *testing.T) {
7076 if err != nil {
7177 t .Fatalf ("NewTokenProvider() = %v" , err )
7278 }
73- tok , err := tp .Token (context .Background ())
79+ tok , err := creds .Token (context .Background ())
7480 if err != nil {
75- t .Fatalf ("NewDownscopedTokenSource failed with error: %v" , err )
81+ t .Fatalf ("Token failed with error: %v" , err )
7682 }
7783 if want := "fake_token" ; tok .Value != want {
7884 t .Fatalf ("got %v, want %v" , tok .Value , want )
7985 }
8086}
8187
82- func TestTestNewTokenProvider_Validations (t * testing.T ) {
88+ func TestTestNewCredentials_Validations (t * testing.T ) {
8389 tests := []struct {
8490 name string
8591 opts * Options
@@ -95,27 +101,27 @@ func TestTestNewTokenProvider_Validations(t *testing.T) {
95101 {
96102 name : "no rules" ,
97103 opts : & Options {
98- BaseProvider : staticTokenProvider ("token_base" ),
104+ Credentials : staticCredentials ("token_base" ),
99105 },
100106 },
101107 {
102108 name : "too many rules" ,
103109 opts : & Options {
104- BaseProvider : staticTokenProvider ("token_base" ),
105- Rules : []AccessBoundaryRule {{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}},
110+ Credentials : staticCredentials ("token_base" ),
111+ Rules : []AccessBoundaryRule {{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}},
106112 },
107113 },
108114 {
109115 name : "no resource" ,
110116 opts : & Options {
111- BaseProvider : staticTokenProvider ("token_base" ),
112- Rules : []AccessBoundaryRule {{}},
117+ Credentials : staticCredentials ("token_base" ),
118+ Rules : []AccessBoundaryRule {{}},
113119 },
114120 },
115121 {
116122 name : "no perm" ,
117123 opts : & Options {
118- BaseProvider : staticTokenProvider ("token_base" ),
124+ Credentials : staticCredentials ("token_base" ),
119125 Rules : []AccessBoundaryRule {{
120126 AvailableResource : "resource" ,
121127 }},
@@ -124,7 +130,7 @@ func TestTestNewTokenProvider_Validations(t *testing.T) {
124130 }
125131 for _ , test := range tests {
126132 t .Run (test .name , func (t * testing.T ) {
127- if _ , err := NewTokenProvider (test .opts ); err == nil {
133+ if _ , err := NewCredentials (test .opts ); err == nil {
128134 t .Fatal ("want non-nil err" )
129135 }
130136 })
0 commit comments