@@ -949,6 +949,13 @@ func TestCloudflareProvider(t *testing.T) {
949949 Value string
950950 }
951951
952+ // unset environment variables to avoid interference with tests
953+ testutils .TestHelperEnvSetter (t , map [string ]string {
954+ cfAPIEmailEnvKey : "" ,
955+ cfAPIKeyEnvKey : "" ,
956+ cfAPITokenEnvKey : "" ,
957+ })
958+
952959 tokenFile := "/tmp/cf_api_token"
953960 if err := os .WriteFile (tokenFile , []byte ("abc123def" ), 0o644 ); err != nil {
954961 t .Errorf ("failed to write token file, %s" , err )
@@ -962,22 +969,22 @@ func TestCloudflareProvider(t *testing.T) {
962969 {
963970 Name : "use_api_token" ,
964971 Environment : []EnvVar {
965- {Key : "CF_API_TOKEN" , Value : "abc123def" },
972+ {Key : cfAPITokenEnvKey , Value : "abc123def" },
966973 },
967974 ShouldFail : false ,
968975 },
969976 {
970977 Name : "use_api_token_file_contents" ,
971978 Environment : []EnvVar {
972- {Key : "CF_API_TOKEN" , Value : tokenFile },
979+ {Key : cfAPITokenEnvKey , Value : tokenFile },
973980 },
974981 ShouldFail : false ,
975982 },
976983 {
977984 Name : "use_email_and_key" ,
978985 Environment : []EnvVar {
979- {Key : "CF_API_KEY" , Value : "xxxxxxxxxxxxxxxxx" },
980- {
Key :
"CF_API_EMAIL" ,
Value :
"[email protected] " },
986+ {Key : cfAPIKeyEnvKey , Value : "xxxxxxxxxxxxxxxxx" },
987+ {
Key :
cfAPIEmailEnvKey ,
Value :
"[email protected] " },
981988 },
982989 ShouldFail : false ,
983990 },
@@ -989,14 +996,14 @@ func TestCloudflareProvider(t *testing.T) {
989996 {
990997 Name : "use_credentials_in_missing_file" ,
991998 Environment : []EnvVar {
992- {Key : "CF_API_TOKEN" , Value : "file://abc" },
999+ {Key : cfAPITokenEnvKey , Value : "file://abc" },
9931000 },
9941001 ShouldFail : true ,
9951002 },
9961003 {
9971004 Name : "use_credentials_in_missing_file" ,
9981005 Environment : []EnvVar {
999- {Key : "CF_API_TOKEN" , Value : "file:/tmp/cf_api_token" },
1006+ {Key : cfAPITokenEnvKey , Value : "file:/tmp/cf_api_token" },
10001007 },
10011008 ShouldFail : false ,
10021009 },
@@ -1809,8 +1816,10 @@ func TestCustomTTLWithEnabledProxyNotChanged(t *testing.T) {
18091816}
18101817
18111818func TestCloudFlareProvider_Region (t * testing.T ) {
1812- t .Setenv ("CF_API_TOKEN" , "abc123def" )
1813- t .
Setenv (
"CF_API_EMAIL" ,
"[email protected] " )
1819+ testutils .TestHelperEnvSetter (t , map [string ]string {
1820+ cfAPITokenEnvKey : "abc123def" ,
1821+ cfAPIEmailEnvKey :
"[email protected] " ,
1822+ })
18141823 provider , err := NewCloudFlareProvider (
18151824 endpoint .NewDomainFilter ([]string {"example.com" }),
18161825 provider.ZoneIDFilter {},
0 commit comments