@@ -125,7 +125,6 @@ func TestHTTPSync_Fetch(t *testing.T) {
125125 tests := map [string ]struct {
126126 setup func (t * testing.T , client * syncmock.MockClient )
127127 uri string
128- bearerToken string
129128 authHeader string
130129 eTagHeader string
131130 lastBodySHA string
@@ -181,37 +180,6 @@ func TestHTTPSync_Fetch(t *testing.T) {
181180 }
182181 },
183182 },
184- "authorization with bearerToken" : {
185- setup : func (t * testing.T , client * syncmock.MockClient ) {
186- expectedToken := "bearer-1234"
187- client .EXPECT ().Do (gomock .Any ()).DoAndReturn (func (req * http.Request ) (* http.Response , error ) {
188- actualAuthHeader := req .Header .Get ("Authorization" )
189- if actualAuthHeader != "Bearer " + expectedToken {
190- t .Fatalf ("expected Authorization header to be 'Bearer %s', got %s" , expectedToken , actualAuthHeader )
191- }
192- return & http.Response {
193- Header : buildHeaders (map [string ][]string {"Content-Type" : {"application/json" }}),
194- Body : io .NopCloser (strings .NewReader ("test response" )),
195- StatusCode : http .StatusOK ,
196- }, nil
197- })
198- },
199- uri : "http://localhost" ,
200- bearerToken : "bearer-1234" ,
201- lastBodySHA : "" ,
202- handleResponse : func (t * testing.T , httpSync Sync , _ string , err error ) {
203- if err != nil {
204- t .Fatalf ("fetch: %v" , err )
205- }
206-
207- expectedLastBodySHA := "UjeJHtCU_wb7OHK-tbPoHycw0TqlHzkWJmH4y6cqg50="
208- if httpSync .lastBodySHA != expectedLastBodySHA {
209- t .Errorf (
210- "expected last body sha to be: '%s', got: '%s'" , expectedLastBodySHA , httpSync .lastBodySHA ,
211- )
212- }
213- },
214- },
215183 "authorization with authHeader" : {
216184 setup : func (t * testing.T , client * syncmock.MockClient ) {
217185 expectedHeader := "Basic dXNlcjpwYXNz"
@@ -348,7 +316,6 @@ func TestHTTPSync_Fetch(t *testing.T) {
348316 httpSync := Sync {
349317 uri : tt .uri ,
350318 client : mockClient ,
351- bearerToken : tt .bearerToken ,
352319 authHeader : tt .authHeader ,
353320 lastBodySHA : tt .lastBodySHA ,
354321 logger : logger .NewLogger (nil , false ),
@@ -361,30 +328,6 @@ func TestHTTPSync_Fetch(t *testing.T) {
361328 }
362329}
363330
364- func TestSync_Init (t * testing.T ) {
365- tests := []struct {
366- name string
367- bearerToken string
368- }{
369- {"with bearerToken" , "bearer-1234" },
370- {"without bearerToken" , "" },
371- }
372-
373- for _ , tt := range tests {
374- t .Run (tt .name , func (t * testing.T ) {
375- httpSync := Sync {
376- bearerToken : tt .bearerToken ,
377- logger : logger .NewLogger (nil , false ),
378- }
379-
380- if err := httpSync .Init (context .Background ()); err != nil {
381- t .Errorf ("Init() error = %v" , err )
382- }
383- })
384- }
385-
386- }
387-
388331func TestHTTPSync_Resync (t * testing.T ) {
389332 ctrl := gomock .NewController (t )
390333 source := "http://localhost"
@@ -393,7 +336,6 @@ func TestHTTPSync_Resync(t *testing.T) {
393336 tests := map [string ]struct {
394337 setup func (t * testing.T , client * syncmock.MockClient )
395338 uri string
396- bearerToken string
397339 lastBodySHA string
398340 handleResponse func (* testing.T , Sync , string , error )
399341 wantErr bool
@@ -448,7 +390,6 @@ func TestHTTPSync_Resync(t *testing.T) {
448390 httpSync := Sync {
449391 uri : tt .uri ,
450392 client : mockClient ,
451- bearerToken : tt .bearerToken ,
452393 lastBodySHA : tt .lastBodySHA ,
453394 logger : logger .NewLogger (nil , false ),
454395 }
@@ -617,7 +558,7 @@ func TestHTTPSync_OAuth(t *testing.T) {
617558 l := logger .NewLogger (nil , false )
618559 s := NewHTTP (sync.SourceConfig {
619560 URI : ts .URL ,
620- BearerToken : "it_should_be_replaced_by_oauth" ,
561+ AuthHeader : "Bearer it_should_be_replaced_by_oauth" ,
621562 OAuth : & sync.OAuthCredentialHandler {
622563 ClientID : clientID ,
623564 ClientSecret : clientSecret ,
@@ -710,7 +651,7 @@ func TestHTTPSync_OAuthFolderSecrets(t *testing.T) {
710651 l := logger .NewLogger (nil , false )
711652 s := NewHTTP (sync.SourceConfig {
712653 URI : ts .URL + flagsPath ,
713- BearerToken : "it_should_be_replaced_by_oauth" ,
654+ AuthHeader : "Bearer it_should_be_replaced_by_oauth" ,
714655 OAuth : & sync.OAuthCredentialHandler {
715656 ClientID : clientID ,
716657 ClientSecret : clientSecret ,
0 commit comments