@@ -26,6 +26,8 @@ import (
2626 "net/url"
2727 "testing"
2828
29+ "github.com/hyperledger/firefly/mocks/metricsmocks"
30+
2931 "github.com/hyperledger/firefly-common/pkg/config"
3032 "github.com/hyperledger/firefly-common/pkg/ffresty"
3133 "github.com/hyperledger/firefly-common/pkg/fftls"
@@ -45,6 +47,55 @@ import (
4547
4648var utConfig = config .RootSection ("ffdx_unit_tests" )
4749
50+ const (
51+ testCertBundle = `
52+ -----BEGIN CERTIFICATE-----
53+ MIIDqTCCApGgAwIBAgIUbZT+Ds4f2oDmGpgVi+SaQq9gxvcwDQYJKoZIhvcNAQEL
54+ BQAwZDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcM
55+ DVNhbiBGcmFuY2lzY28xEzARBgNVBAoMCkV4YW1wbGUgQ0ExEzARBgNVBAMMCmV4
56+ YW1wbGUtY2EwHhcNMjUwMjI4MTkzMDM4WhcNMzUwMjI2MTkzMDM4WjBkMQswCQYD
57+ VQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNU2FuIEZyYW5j
58+ aXNjbzETMBEGA1UECgwKRXhhbXBsZSBDQTETMBEGA1UEAwwKZXhhbXBsZS1jYTCC
59+ ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAOWBryFqk0YqQ6pzGJvBDjbV
60+ 4BnkMzsv+Fq869Xks09OP4eW44oqfFUmpCFyS3fEmRCz+389t4mKvxcCRIJMW0f5
61+ K9jffG1QKUKL4UuNfEPFpM0MXTwhI+dCdvofdelzc+KBGA6CDYlnWYcCKFSuWeSu
62+ xrb/qCEvhcCaSYt3e2WcRHRuK+OLzM3REeJctC4G/pq858OUV5CZU2B6aGV/9uFL
63+ ZW3TCrOaj+Khzzt5FNvjVdLiUw0FS8VESxFA4kH8p+XUshs9S0e7LfIBSID2NU8+
64+ +5D6HliqNqikbsny1Ps6GhLa+nI37LOVj7nFcG7uk+gb6HUN1+0Y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cWWS0+QPp03PrdxsnAAtG2tWOk2CEG7HS3AlBU82YImhCidKOw+jQPS68
83+ 2f2d0tYBhugqB2Ki6HsfYMGTjHDLbUQ5y+cLk6PFbvhjm39Ayd+WGmhWht5qFtRN
84+ gllTa/SbG8+iGaSPIVFCyvg1IzxsFnBGn+05Gu+KjpL4i0l1RqDmy5ItxKGP77in
85+ RPEUkejiUozg/X3v2TWAGagIVF5+EQ2Cswot9W1faAvyu/QmSGLLfSH22GdEDHXa
86+ U4DV5ArJ2U2eNkOuasSWGKBopa/Wh1SZjKrNsy5Gw84ihAI4k7ARoP+vu1dIPdaX
87+ ElipmGMtUWu0Azn2l9QJZpMCAwEAAaNCMEAwHQYDVR0OBBYEFL798jEmX2+hw70t
88+ SmfJA78PZnnHMB8GA1UdIwQYMBaAFJfNoXmIn5S6W7Lcj5G/huW5q1YQMA0GCSqG
89+ SIb3DQEBCwUAA4IBAQBY1NXTuQJZvjip33dRXyWP6GsSDKbXTSCcSF38P4/m+pcH
90+ r/q/upo+K+8eTtPqUwBsIywH5bypWqoIPtM+rkd3FVBe7uti2FExufpcOruzEGsY
91+ rNTfiFZbc7eHmFRTkKXWW4j6b6ElygrBvV999BhCRNf6NS0/syjqsbALHkFGeIcl
92+ 78wdaR+m2XVJBV7SmPmZ/EQzxvhCZONNVyU5zvW2sehI7sRbZt9/FG5U1Ng0LarW
93+ R0gnXX/IZFnLhLh6UpLOBB0KIGENh75EEU7755jMKDKFj16D0uA1Lzrh5YxicTMy
94+ ydFYQLpLycsWl2oV3JB4pO5TIzjY9awkRE0MeMMc
95+ -----END CERTIFICATE-----
96+ `
97+ )
98+
4899func newTestFFDX (t * testing.T , manifestEnabled bool ) (h * FFDX , toServer , fromServer chan string , httpURL string , done func ()) {
49100 mockedClient := & http.Client {}
50101 httpmock .ActivateNonDefault (mockedClient )
@@ -64,8 +115,9 @@ func newTestFFDX(t *testing.T, manifestEnabled bool) (h *FFDX, toServer, fromSer
64115 h = & FFDX {initialized : true }
65116 h .InitConfig (utConfig )
66117
118+ mmm := metricsmocks .NewManager (t )
67119 dxCtx , dxCancel := context .WithCancel (context .Background ())
68- err := h .Init (dxCtx , dxCancel , utConfig )
120+ err := h .Init (dxCtx , dxCancel , utConfig , mmm )
69121 assert .NoError (t , err )
70122 assert .Equal (t , "ffdx" , h .Name ())
71123 assert .NotNil (t , h .Capabilities ())
@@ -114,7 +166,7 @@ func TestInitBadURL(t *testing.T) {
114166 h .InitConfig (utConfig )
115167 utConfig .Set (ffresty .HTTPConfigURL , "::::////" )
116168 ctx , cancel := context .WithCancel (context .Background ())
117- err := h .Init (ctx , cancel , utConfig )
169+ err := h .Init (ctx , cancel , utConfig , nil )
118170 assert .Regexp (t , "FF00149" , err )
119171}
120172
@@ -127,7 +179,7 @@ func TestInitBadTLS(t *testing.T) {
127179 tlsConfig .Set (fftls .HTTPConfTLSEnabled , true )
128180 tlsConfig .Set (fftls .HTTPConfTLSCAFile , "badCA" )
129181 ctx , cancel := context .WithCancel (context .Background ())
130- err := h .Init (ctx , cancel , utConfig )
182+ err := h .Init (ctx , cancel , utConfig , nil )
131183 assert .Regexp (t , "FF00153" , err )
132184}
133185
@@ -136,7 +188,7 @@ func TestInitMissingURL(t *testing.T) {
136188 h := & FFDX {}
137189 h .InitConfig (utConfig )
138190 ctx , cancel := context .WithCancel (context .Background ())
139- err := h .Init (ctx , cancel , utConfig )
191+ err := h .Init (ctx , cancel , utConfig , nil )
140192 assert .Regexp (t , "FF10138" , err )
141193}
142194
@@ -159,7 +211,7 @@ func TestInitWithBackgroundStart(t *testing.T) {
159211
160212 h .InitConfig (utConfig )
161213 ctx , cancel := context .WithCancel (context .Background ())
162- err := h .Init (ctx , cancel , utConfig )
214+ err := h .Init (ctx , cancel , utConfig , nil )
163215 assert .NoError (t , err )
164216
165217 assert .NotNil (t , h .backgroundRetry )
@@ -453,7 +505,7 @@ func TestBackgroundStartWSFail(t *testing.T) {
453505
454506 dxCtx , dxCancel := context .WithCancel (context .Background ())
455507 defer dxCancel ()
456- err := h .Init (dxCtx , dxCancel , utConfig )
508+ err := h .Init (dxCtx , dxCancel , utConfig , nil )
457509 assert .NoError (t , err )
458510 assert .Equal (t , "ffdx" , h .Name ())
459511 assert .NotNil (t , h .Capabilities ())
@@ -480,7 +532,7 @@ func TestMessageEventsBackgroundStart(t *testing.T) {
480532 // Starting in background mode and making sure the event loop are started as well
481533 // to listen to messages
482534 utConfig .Set (DataExchangeBackgroundStart , true )
483- h .Init (h .ctx , h .cancelCtx , utConfig )
535+ h .Init (h .ctx , h .cancelCtx , utConfig , nil )
484536
485537 mcb := & dataexchangemocks.Callbacks {}
486538 h .SetHandler ("ns1" , "node1" , mcb )
@@ -811,7 +863,7 @@ func TestWebsocketWithReinit(t *testing.T) {
811863
812864 h .InitConfig (utConfig )
813865 ctx , cancel := context .WithCancel (context .Background ())
814- err := h .Init (ctx , cancel , utConfig )
866+ err := h .Init (ctx , cancel , utConfig , nil )
815867 assert .NoError (t , err )
816868 h .AddNode (context .Background (), "ns1" , "node1" , fftypes.JSONObject {})
817869
@@ -859,7 +911,7 @@ func TestWebsocketWithEmptyNodesInit(t *testing.T) {
859911
860912 h .InitConfig (utConfig )
861913 ctx , cancel := context .WithCancel (context .Background ())
862- err := h .Init (ctx , cancel , utConfig )
914+ err := h .Init (ctx , cancel , utConfig , nil )
863915 assert .NoError (t , err )
864916
865917 err = h .Start ()
@@ -909,3 +961,14 @@ func TestDeleteBlobFail(t *testing.T) {
909961 err := h .DeleteBlob (context .Background (), fmt .Sprintf ("ns1/%s" , u ))
910962 assert .Regexp (t , "FF10229" , err )
911963}
964+
965+ //
966+ //matchingProfile := fftypes.JSONAnyPtr(fmt.Sprintf(`{"cert": "%s" }`, strings.ReplaceAll(testCertBundle, "\n", `\n`))).JSONObject()
967+ //
968+ //nm.identity.(*identitymanagermocks.Manager).On("GetLocalNode", ctx).Return(&core.Identity{
969+ //IdentityProfile: core.IdentityProfile{
970+ //Profile: matchingProfile,
971+ //},
972+ //}, nil)
973+ //
974+ //expiry := time.Unix(1835379057, 0).UTC()
0 commit comments