@@ -10,10 +10,12 @@ import (
1010 "bytes"
1111 "os"
1212 "path/filepath"
13+ "strings"
1314 "testing"
1415 "time"
1516
1617 "github.com/hyperledger/fabric/core/deliverservice"
18+ "github.com/hyperledger/fabric/internal/peer/common"
1719 "github.com/hyperledger/fabric/internal/pkg/comm"
1820 "github.com/spf13/viper"
1921 "github.com/stretchr/testify/require"
@@ -168,6 +170,37 @@ func TestLoadOverridesMap(t *testing.T) {
168170 require .Equal (t , "addressTo2" , ep2 .Address )
169171 })
170172
173+ t .Run ("GreenPath With Env" , func (t * testing.T ) {
174+ t .Setenv ("CORE_PEER_DELIVERYCLIENT_ADDRESSOVERRIDES" , "[{from: addressFrom1, to: addressTo1, caCertsFile: testdata/cert.pem}" +
175+ ", {from: addressFrom2, to: addressTo2, caCertsFile: testdata/cert.pem}]" )
176+ config := `
177+ peer:
178+ deliveryclient:
179+ addressOverrides:
180+ `
181+
182+ viper .Reset ()
183+
184+ viper .SetEnvPrefix (common .CmdRoot )
185+ viper .AllowEmptyEnv (true )
186+ viper .AutomaticEnv ()
187+ replacer := strings .NewReplacer ("." , "_" )
188+ viper .SetEnvKeyReplacer (replacer )
189+
190+ viper .SetConfigType ("yaml" )
191+ err := viper .ReadConfig (bytes .NewBuffer ([]byte (config )))
192+ require .NoError (t , err )
193+ res , err := deliverservice .LoadOverridesMap ()
194+ require .NoError (t , err )
195+ require .Len (t , res , 2 )
196+ ep1 , ok := res ["addressFrom1" ]
197+ require .True (t , ok )
198+ require .Equal (t , "addressTo1" , ep1 .Address )
199+ ep2 , ok := res ["addressFrom2" ]
200+ require .True (t , ok )
201+ require .Equal (t , "addressTo2" , ep2 .Address )
202+ })
203+
171204 t .Run ("MissingCAFiles" , func (t * testing.T ) {
172205 config := `
173206 peer:
0 commit comments