@@ -11,14 +11,15 @@ import (
1111 "io/ioutil"
1212 "os"
1313 "path/filepath"
14+ "strings"
1415 "testing"
1516 "time"
1617
17- "github.com/stretchr/testify/require"
18-
1918 "github.com/hyperledger/fabric/core/deliverservice"
19+ "github.com/hyperledger/fabric/internal/peer/common"
2020 "github.com/hyperledger/fabric/internal/pkg/comm"
2121 "github.com/spf13/viper"
22+ "github.com/stretchr/testify/require"
2223)
2324
2425func TestSecureOptsConfig (t * testing.T ) {
@@ -161,6 +162,37 @@ func TestLoadOverridesMap(t *testing.T) {
161162 require .Equal (t , "addressTo2" , ep2 .Address )
162163 })
163164
165+ t .Run ("GreenPath With Env" , func (t * testing.T ) {
166+ t .Setenv ("CORE_PEER_DELIVERYCLIENT_ADDRESSOVERRIDES" , "[{from: addressFrom1, to: addressTo1, caCertsFile: testdata/cert.pem}" +
167+ ", {from: addressFrom2, to: addressTo2, caCertsFile: testdata/cert.pem}]" )
168+ config := `
169+ peer:
170+ deliveryclient:
171+ addressOverrides:
172+ `
173+
174+ viper .Reset ()
175+
176+ viper .SetEnvPrefix (common .CmdRoot )
177+ viper .AllowEmptyEnv (true )
178+ viper .AutomaticEnv ()
179+ replacer := strings .NewReplacer ("." , "_" )
180+ viper .SetEnvKeyReplacer (replacer )
181+
182+ viper .SetConfigType ("yaml" )
183+ err := viper .ReadConfig (bytes .NewBuffer ([]byte (config )))
184+ require .NoError (t , err )
185+ res , err := deliverservice .LoadOverridesMap ()
186+ require .NoError (t , err )
187+ require .Len (t , res , 2 )
188+ ep1 , ok := res ["addressFrom1" ]
189+ require .True (t , ok )
190+ require .Equal (t , "addressTo1" , ep1 .Address )
191+ ep2 , ok := res ["addressFrom2" ]
192+ require .True (t , ok )
193+ require .Equal (t , "addressTo2" , ep2 .Address )
194+ })
195+
164196 t .Run ("MissingCAFiles" , func (t * testing.T ) {
165197 config := `
166198 peer:
0 commit comments