@@ -123,7 +123,7 @@ func (suite *basicSuite) TestTenantsAPI() {
123123 Path : "/" + tenantID + "/destinations" ,
124124 Body : map [string ]interface {}{
125125 "id" : sampleDestinationID ,
126- "type" : "webhooks " ,
126+ "type" : "webhook " ,
127127 "topics" : "*" ,
128128 "config" : map [string ]interface {}{
129129 "url" : "http://host.docker.internal:4444" ,
@@ -250,7 +250,7 @@ func (suite *basicSuite) TestDestinationsAPI() {
250250 Method : httpclient .MethodPOST ,
251251 Path : "/" + tenantID + "/destinations" ,
252252 Body : map [string ]interface {}{
253- "type" : "webhooks " ,
253+ "type" : "webhook " ,
254254 "topics" : "*" ,
255255 "config" : map [string ]interface {}{
256256 "url" : "http://host.docker.internal:4444" ,
@@ -305,7 +305,7 @@ func (suite *basicSuite) TestDestinationsAPI() {
305305 Method : httpclient .MethodPOST ,
306306 Path : "/" + tenantID + "/destinations" ,
307307 Body : map [string ]interface {}{
308- "type" : "webhooks " ,
308+ "type" : "webhook " ,
309309 "topics" : "invalid" ,
310310 "config" : map [string ]interface {}{
311311 "url" : "http://host.docker.internal:4444" ,
@@ -327,7 +327,7 @@ func (suite *basicSuite) TestDestinationsAPI() {
327327 Method : httpclient .MethodPOST ,
328328 Path : "/" + tenantID + "/destinations" ,
329329 Body : map [string ]interface {}{
330- "type" : "webhooks " ,
330+ "type" : "webhook " ,
331331 "topics" : []string {"invalid" },
332332 "config" : map [string ]interface {}{
333333 "url" : "http://host.docker.internal:4444" ,
@@ -349,7 +349,7 @@ func (suite *basicSuite) TestDestinationsAPI() {
349349 Method : httpclient .MethodPOST ,
350350 Path : "/" + tenantID + "/destinations" ,
351351 Body : map [string ]interface {}{
352- "type" : "webhooks " ,
352+ "type" : "webhook " ,
353353 "topics" : []string {"user.created" },
354354 "config" : map [string ]interface {}{},
355355 },
@@ -370,7 +370,7 @@ func (suite *basicSuite) TestDestinationsAPI() {
370370 Path : "/" + tenantID + "/destinations" ,
371371 Body : map [string ]interface {}{
372372 "id" : sampleDestinationID ,
373- "type" : "webhooks " ,
373+ "type" : "webhook " ,
374374 "topics" : "*" ,
375375 "config" : map [string ]interface {}{
376376 "url" : "http://host.docker.internal:4444" ,
@@ -390,7 +390,7 @@ func (suite *basicSuite) TestDestinationsAPI() {
390390 Path : "/" + tenantID + "/destinations" ,
391391 Body : map [string ]interface {}{
392392 "id" : sampleDestinationID ,
393- "type" : "webhooks " ,
393+ "type" : "webhook " ,
394394 "topics" : "*" ,
395395 "config" : map [string ]interface {}{
396396 "url" : "http://host.docker.internal:4444" ,
@@ -427,7 +427,7 @@ func (suite *basicSuite) TestDestinationsAPI() {
427427 StatusCode : http .StatusOK ,
428428 Body : map [string ]interface {}{
429429 "id" : sampleDestinationID ,
430- "type" : "webhooks " ,
430+ "type" : "webhook " ,
431431 "topics" : []string {"*" },
432432 "config" : map [string ]interface {}{
433433 "url" : "http://host.docker.internal:4444" ,
@@ -451,7 +451,7 @@ func (suite *basicSuite) TestDestinationsAPI() {
451451 StatusCode : http .StatusOK ,
452452 Body : map [string ]interface {}{
453453 "id" : sampleDestinationID ,
454- "type" : "webhooks " ,
454+ "type" : "webhook " ,
455455 "topics" : []string {"user.created" },
456456 "config" : map [string ]interface {}{
457457 "url" : "http://host.docker.internal:4444" ,
@@ -472,7 +472,7 @@ func (suite *basicSuite) TestDestinationsAPI() {
472472 StatusCode : http .StatusOK ,
473473 Body : map [string ]interface {}{
474474 "id" : sampleDestinationID ,
475- "type" : "webhooks " ,
475+ "type" : "webhook " ,
476476 "topics" : []string {"user.created" },
477477 "config" : map [string ]interface {}{
478478 "url" : "http://host.docker.internal:4444" ,
@@ -568,6 +568,172 @@ func (suite *basicSuite) TestDestinationsAPI() {
568568 suite .RunAPITests (suite .T (), tests )
569569}
570570
571+ func (suite * basicSuite ) TestDestinationsListAPI () {
572+ tenantID := uuid .New ().String ()
573+ tests := []APITest {
574+ {
575+ Name : "PUT /:tenantID" ,
576+ Request : suite .AuthRequest (httpclient.Request {
577+ Method : httpclient .MethodPUT ,
578+ Path : "/" + tenantID ,
579+ }),
580+ Expected : APITestExpectation {
581+ Match : & httpclient.Response {
582+ StatusCode : http .StatusCreated ,
583+ },
584+ },
585+ },
586+ {
587+ Name : "POST /:tenantID/destinations type=webhook topics=*" ,
588+ Request : suite .AuthRequest (httpclient.Request {
589+ Method : httpclient .MethodPOST ,
590+ Path : "/" + tenantID + "/destinations" ,
591+ Body : map [string ]interface {}{
592+ "type" : "webhook" ,
593+ "topics" : "*" ,
594+ "config" : map [string ]interface {}{
595+ "url" : "http://host.docker.internal:4444" ,
596+ },
597+ },
598+ }),
599+ Expected : APITestExpectation {
600+ Match : & httpclient.Response {
601+ StatusCode : http .StatusCreated ,
602+ },
603+ },
604+ },
605+ {
606+ Name : "POST /:tenantID/destinations type=webhook topics=user.created" ,
607+ Request : suite .AuthRequest (httpclient.Request {
608+ Method : httpclient .MethodPOST ,
609+ Path : "/" + tenantID + "/destinations" ,
610+ Body : map [string ]interface {}{
611+ "type" : "webhook" ,
612+ "topics" : []string {"user.created" },
613+ "config" : map [string ]interface {}{
614+ "url" : "http://host.docker.internal:4444" ,
615+ },
616+ },
617+ }),
618+ Expected : APITestExpectation {
619+ Match : & httpclient.Response {
620+ StatusCode : http .StatusCreated ,
621+ },
622+ },
623+ },
624+ {
625+ Name : "POST /:tenantID/destinations type=webhook topics=user.created user.updated" ,
626+ Request : suite .AuthRequest (httpclient.Request {
627+ Method : httpclient .MethodPOST ,
628+ Path : "/" + tenantID + "/destinations" ,
629+ Body : map [string ]interface {}{
630+ "type" : "webhook" ,
631+ "topics" : []string {"user.created" , "user.updated" },
632+ "config" : map [string ]interface {}{
633+ "url" : "http://host.docker.internal:4444" ,
634+ },
635+ },
636+ }),
637+ Expected : APITestExpectation {
638+ Match : & httpclient.Response {
639+ StatusCode : http .StatusCreated ,
640+ },
641+ },
642+ },
643+ {
644+ Name : "GET /:tenantID/destinations" ,
645+ Request : suite .AuthRequest (httpclient.Request {
646+ Method : httpclient .MethodGET ,
647+ Path : "/" + tenantID + "/destinations" ,
648+ }),
649+ Expected : APITestExpectation {
650+ Validate : makeDestinationListValidator (3 ),
651+ },
652+ },
653+ {
654+ Name : "GET /:tenantID/destinations?type=webhook" ,
655+ Request : suite .AuthRequest (httpclient.Request {
656+ Method : httpclient .MethodGET ,
657+ Path : "/" + tenantID + "/destinations?type=webhook" ,
658+ }),
659+ Expected : APITestExpectation {
660+ Validate : makeDestinationListValidator (3 ),
661+ },
662+ },
663+ {
664+ Name : "GET /:tenantID/destinations?type=rabbitmq" ,
665+ Request : suite .AuthRequest (httpclient.Request {
666+ Method : httpclient .MethodGET ,
667+ Path : "/" + tenantID + "/destinations?type=rabbitmq" ,
668+ }),
669+ Expected : APITestExpectation {
670+ Validate : makeDestinationListValidator (0 ),
671+ },
672+ },
673+ {
674+ Name : "GET /:tenantID/destinations?topics=*" ,
675+ Request : suite .AuthRequest (httpclient.Request {
676+ Method : httpclient .MethodGET ,
677+ Path : "/" + tenantID + "/destinations?topics=*" ,
678+ }),
679+ Expected : APITestExpectation {
680+ Validate : makeDestinationListValidator (1 ),
681+ },
682+ },
683+ {
684+ Name : "GET /:tenantID/destinations?topics=user.created" ,
685+ Request : suite .AuthRequest (httpclient.Request {
686+ Method : httpclient .MethodGET ,
687+ Path : "/" + tenantID + "/destinations?topics=user.created" ,
688+ }),
689+ Expected : APITestExpectation {
690+ Validate : makeDestinationListValidator (3 ),
691+ },
692+ },
693+ {
694+ Name : "GET /:tenantID/destinations?topics=user.updated" ,
695+ Request : suite .AuthRequest (httpclient.Request {
696+ Method : httpclient .MethodGET ,
697+ Path : "/" + tenantID + "/destinations?topics=user.updated" ,
698+ }),
699+ Expected : APITestExpectation {
700+ Validate : makeDestinationListValidator (2 ),
701+ },
702+ },
703+ {
704+ Name : "GET /:tenantID/destinations?topics=user.created&topics=user.updated" ,
705+ Request : suite .AuthRequest (httpclient.Request {
706+ Method : httpclient .MethodGET ,
707+ Path : "/" + tenantID + "/destinations?topics=user.created&topics=user.updated" ,
708+ }),
709+ Expected : APITestExpectation {
710+ Validate : makeDestinationListValidator (2 ),
711+ },
712+ },
713+ {
714+ Name : "GET /:tenantID/destinations?type=webhook&topics=user.created&topics=user.updated" ,
715+ Request : suite .AuthRequest (httpclient.Request {
716+ Method : httpclient .MethodGET ,
717+ Path : "/" + tenantID + "/destinations?type=webhook&topics=user.created&topics=user.updated" ,
718+ }),
719+ Expected : APITestExpectation {
720+ Validate : makeDestinationListValidator (2 ),
721+ },
722+ },
723+ {
724+ Name : "GET /:tenantID/destinations?type=rabbitmq&topics=user.created&topics=user.updated" ,
725+ Request : suite .AuthRequest (httpclient.Request {
726+ Method : httpclient .MethodGET ,
727+ Path : "/" + tenantID + "/destinations?type=rabbitmq&topics=user.created&topics=user.updated" ,
728+ }),
729+ Expected : APITestExpectation {
730+ Validate : makeDestinationListValidator (0 ),
731+ },
732+ },
733+ }
734+ suite .RunAPITests (suite .T (), tests )
735+ }
736+
571737func makeDestinationListValidator (length int ) map [string ]any {
572738 return map [string ]any {
573739 "type" : "object" ,
0 commit comments