@@ -31,15 +31,15 @@ import (
31
31
)
32
32
33
33
const (
34
- apiKey = "mykey"
35
- apiSecret = "mysecret"
34
+ testAPIKey = "mykey"
35
+ testAPISecret = "mysecret"
36
36
testAddr = ":8765"
37
37
testUrl = "http://localhost:8765"
38
38
webhookCheckInterval = 100 * time .Millisecond
39
39
)
40
40
41
41
var authProvider = auth .NewSimpleKeyProvider (
42
- apiKey , apiSecret ,
42
+ testAPIKey , testAPISecret ,
43
43
)
44
44
45
45
func TestWebHook (t * testing.T ) {
@@ -146,15 +146,17 @@ func TestURLNotifierLifecycle(t *testing.T) {
146
146
147
147
t .Run ("times out after accepting connection" , func (t * testing.T ) {
148
148
urlNotifier := NewURLNotifier (URLNotifierParams {
149
- QueueSize : 20 ,
150
149
URL : testUrl ,
151
- APIKey : apiKey ,
152
- APISecret : apiSecret ,
150
+ APIKey : testAPIKey ,
151
+ APISecret : testAPISecret ,
153
152
HTTPClientParams : HTTPClientParams {
154
153
RetryWaitMax : time .Millisecond ,
155
154
MaxRetries : 1 ,
156
155
ClientTimeout : 100 * time .Millisecond ,
157
156
},
157
+ Config : URLNotifierConfig {
158
+ QueueSize : 20 ,
159
+ },
158
160
})
159
161
160
162
numCalled := atomic.Int32 {}
@@ -181,8 +183,8 @@ func TestURLNotifierLifecycle(t *testing.T) {
181
183
defer ln .Close ()
182
184
urlNotifier := NewURLNotifier (URLNotifierParams {
183
185
URL : "http://localhost:9987" ,
184
- APIKey : apiKey ,
185
- APISecret : apiSecret ,
186
+ APIKey : testAPIKey ,
187
+ APISecret : testAPISecret ,
186
188
HTTPClientParams : HTTPClientParams {
187
189
RetryWaitMax : time .Millisecond ,
188
190
MaxRetries : 1 ,
@@ -205,10 +207,12 @@ func TestURLNotifierFilter(t *testing.T) {
205
207
206
208
t .Run ("none" , func (t * testing.T ) {
207
209
urlNotifier := NewURLNotifier (URLNotifierParams {
208
- QueueSize : 20 ,
209
210
URL : testUrl ,
210
- APIKey : apiKey ,
211
- APISecret : apiSecret ,
211
+ APIKey : testAPIKey ,
212
+ APISecret : testAPISecret ,
213
+ Config : URLNotifierConfig {
214
+ QueueSize : 20 ,
215
+ },
212
216
})
213
217
defer urlNotifier .Stop (false )
214
218
@@ -231,13 +235,15 @@ func TestURLNotifierFilter(t *testing.T) {
231
235
232
236
t .Run ("includes" , func (t * testing.T ) {
233
237
urlNotifier := NewURLNotifier (URLNotifierParams {
234
- QueueSize : 20 ,
235
238
URL : testUrl ,
236
- APIKey : apiKey ,
237
- APISecret : apiSecret ,
239
+ APIKey : testAPIKey ,
240
+ APISecret : testAPISecret ,
238
241
FilterParams : FilterParams {
239
242
IncludeEvents : []string {EventRoomStarted },
240
243
},
244
+ Config : URLNotifierConfig {
245
+ QueueSize : 20 ,
246
+ },
241
247
})
242
248
defer urlNotifier .Stop (false )
243
249
@@ -260,13 +266,15 @@ func TestURLNotifierFilter(t *testing.T) {
260
266
261
267
t .Run ("excludes" , func (t * testing.T ) {
262
268
urlNotifier := NewURLNotifier (URLNotifierParams {
263
- QueueSize : 20 ,
264
269
URL : testUrl ,
265
- APIKey : apiKey ,
266
- APISecret : apiSecret ,
270
+ APIKey : testAPIKey ,
271
+ APISecret : testAPISecret ,
267
272
FilterParams : FilterParams {
268
273
ExcludeEvents : []string {EventRoomStarted },
269
274
},
275
+ Config : URLNotifierConfig {
276
+ QueueSize : 20 ,
277
+ },
270
278
})
271
279
defer urlNotifier .Stop (false )
272
280
@@ -289,14 +297,16 @@ func TestURLNotifierFilter(t *testing.T) {
289
297
290
298
t .Run ("includes + excludes" , func (t * testing.T ) {
291
299
urlNotifier := NewURLNotifier (URLNotifierParams {
292
- QueueSize : 20 ,
293
300
URL : testUrl ,
294
- APIKey : apiKey ,
295
- APISecret : apiSecret ,
301
+ APIKey : testAPIKey ,
302
+ APISecret : testAPISecret ,
296
303
FilterParams : FilterParams {
297
304
IncludeEvents : []string {EventRoomStarted },
298
305
ExcludeEvents : []string {EventRoomStarted , EventRoomFinished },
299
306
},
307
+ Config : URLNotifierConfig {
308
+ QueueSize : 20 ,
309
+ },
300
310
})
301
311
defer urlNotifier .Stop (false )
302
312
@@ -321,10 +331,12 @@ func TestURLNotifierFilter(t *testing.T) {
321
331
322
332
func newTestNotifier () * URLNotifier {
323
333
return NewURLNotifier (URLNotifierParams {
324
- QueueSize : 20 ,
325
334
URL : testUrl ,
326
- APIKey : apiKey ,
327
- APISecret : apiSecret ,
335
+ APIKey : testAPIKey ,
336
+ APISecret : testAPISecret ,
337
+ Config : URLNotifierConfig {
338
+ QueueSize : 20 ,
339
+ },
328
340
})
329
341
}
330
342
@@ -336,7 +348,13 @@ func TestResourceWebHook(t *testing.T) {
336
348
defer s .Stop ()
337
349
338
350
t .Run ("test event payload" , func (t * testing.T ) {
339
- resourceURLNotifier := NewDefaultNotifier (apiKey , apiSecret , []string {testUrl })
351
+ resourceURLNotifier := NewDefaultNotifier (
352
+ WebHookConfig {
353
+ URLs : []string {testUrl },
354
+ APIKey : testAPIKey ,
355
+ },
356
+ testAPISecret ,
357
+ )
340
358
defer resourceURLNotifier .Stop (false )
341
359
342
360
event := & livekit.WebhookEvent {
@@ -599,8 +617,8 @@ func TestResourceURLNotifierLifecycle(t *testing.T) {
599
617
t .Run ("times out after accepting connection" , func (t * testing.T ) {
600
618
resourceURLNotifier := NewResourceURLNotifier (ResourceURLNotifierParams {
601
619
URL : testUrl ,
602
- APIKey : apiKey ,
603
- APISecret : apiSecret ,
620
+ APIKey : testAPIKey ,
621
+ APISecret : testAPISecret ,
604
622
Config : ResourceURLNotifierConfig {
605
623
MaxAge : 200 * time .Millisecond ,
606
624
MaxDepth : 50 ,
@@ -636,8 +654,8 @@ func TestResourceURLNotifierLifecycle(t *testing.T) {
636
654
defer ln .Close ()
637
655
resourceURLNotifier := NewResourceURLNotifier (ResourceURLNotifierParams {
638
656
URL : "http://localhost:9987" ,
639
- APIKey : apiKey ,
640
- APISecret : apiSecret ,
657
+ APIKey : testAPIKey ,
658
+ APISecret : testAPISecret ,
641
659
Config : ResourceURLNotifierConfig {
642
660
MaxAge : 200 * time .Millisecond ,
643
661
MaxDepth : 50 ,
@@ -665,8 +683,8 @@ func TestResourceURLNotifierFilter(t *testing.T) {
665
683
t .Run ("none" , func (t * testing.T ) {
666
684
resourceURLNotifier := NewResourceURLNotifier (ResourceURLNotifierParams {
667
685
URL : testUrl ,
668
- APIKey : apiKey ,
669
- APISecret : apiSecret ,
686
+ APIKey : testAPIKey ,
687
+ APISecret : testAPISecret ,
670
688
Config : ResourceURLNotifierConfig {
671
689
MaxAge : 200 * time .Millisecond ,
672
690
MaxDepth : 50 ,
@@ -695,8 +713,8 @@ func TestResourceURLNotifierFilter(t *testing.T) {
695
713
t .Run ("includes" , func (t * testing.T ) {
696
714
resourceURLNotifier := NewResourceURLNotifier (ResourceURLNotifierParams {
697
715
URL : testUrl ,
698
- APIKey : apiKey ,
699
- APISecret : apiSecret ,
716
+ APIKey : testAPIKey ,
717
+ APISecret : testAPISecret ,
700
718
Config : ResourceURLNotifierConfig {
701
719
MaxAge : 200 * time .Millisecond ,
702
720
MaxDepth : 50 ,
@@ -727,8 +745,8 @@ func TestResourceURLNotifierFilter(t *testing.T) {
727
745
t .Run ("excludes" , func (t * testing.T ) {
728
746
resourceURLNotifier := NewResourceURLNotifier (ResourceURLNotifierParams {
729
747
URL : testUrl ,
730
- APIKey : apiKey ,
731
- APISecret : apiSecret ,
748
+ APIKey : testAPIKey ,
749
+ APISecret : testAPISecret ,
732
750
Config : ResourceURLNotifierConfig {
733
751
MaxAge : 200 * time .Millisecond ,
734
752
MaxDepth : 50 ,
@@ -759,8 +777,8 @@ func TestResourceURLNotifierFilter(t *testing.T) {
759
777
t .Run ("includes + excludes" , func (t * testing.T ) {
760
778
resourceURLNotifier := NewResourceURLNotifier (ResourceURLNotifierParams {
761
779
URL : testUrl ,
762
- APIKey : apiKey ,
763
- APISecret : apiSecret ,
780
+ APIKey : testAPIKey ,
781
+ APISecret : testAPISecret ,
764
782
Config : ResourceURLNotifierConfig {
765
783
MaxAge : 200 * time .Millisecond ,
766
784
MaxDepth : 50 ,
@@ -794,8 +812,8 @@ func TestResourceURLNotifierFilter(t *testing.T) {
794
812
func newTestResourceNotifier (timeout time.Duration , maxAge time.Duration , maxDepth int ) * ResourceURLNotifier {
795
813
return NewResourceURLNotifier (ResourceURLNotifierParams {
796
814
URL : testUrl ,
797
- APIKey : apiKey ,
798
- APISecret : apiSecret ,
815
+ APIKey : testAPIKey ,
816
+ APISecret : testAPISecret ,
799
817
Timeout : timeout ,
800
818
Config : ResourceURLNotifierConfig {
801
819
MaxAge : maxAge ,
0 commit comments