11package scm_test
22
33import (
4+ "crypto/tls"
45 "github.com/analogj/capsulecd/pkg/config/mock"
56 "github.com/analogj/capsulecd/pkg/pipeline"
67 "github.com/analogj/capsulecd/pkg/scm"
78 "github.com/analogj/capsulecd/pkg/utils"
8- "crypto/tls"
99 "github.com/golang/mock/gomock"
1010 "github.com/seborama/govcr"
1111 "github.com/stretchr/testify/require"
@@ -14,7 +14,6 @@ import (
1414 "net/http"
1515 "os"
1616 "path"
17- "strings"
1817 "testing"
1918)
2019
@@ -34,22 +33,17 @@ func bitbucketVcrSetup(t *testing.T) *http.Client {
3433 Logging : true ,
3534 CassettePath : path .Join ("testdata" , "govcr-fixtures" ),
3635 Client : & insecureClient ,
37- ExcludeHeaderFunc : func (key string ) bool {
38- // HTTP headers are case-insensitive
39- //return strings.ToLower(key) == "user-agent" || strings.ToLower(key) == "accept"
40- return strings .ToLower (key ) == "user-agent" || strings .ToLower (key ) == "authorization"
41- },
42- RequestFilterFunc : func (reqHeader http.Header , reqBody []byte ) (* http.Header , * []byte ) {
43- reqHeader .Set ("Authorization" , "Basic UExBQ0VIT0xERVI6UExBQ0VIT0xERVI=" ) //placeholder:placeholder
44-
45- return & reqHeader , & reqBody
46- },
4736
4837 //this line ensures that we do not attempt to create new recordings.
4938 //Comment this out if you would like to make recordings.
5039 DisableRecording : DISABLE_RECORDINGS ,
5140 }
5241
42+ // HTTP headers are case-insensitive
43+ vcrConfig .RequestFilters .Add (govcr .RequestDeleteHeaderKeys ("User-Agent" , "user-agent" ))
44+ vcrConfig .RequestFilters .Add (govcr .RequestDeleteHeaderKeys ("Authorization" , "authorization" ))
45+ vcrConfig .RequestFilters .Add (govcr .RequestAddHeaderValue ("Authorization" , "Basic UExBQ0VIT0xERVI6UExBQ0VIT0xERVI=" )) //placeholder:placeholder
46+
5347 vcr := govcr .NewVCR (t .Name (), & vcrConfig )
5448 return vcr .Client
5549}
0 commit comments