From f13c862ff121c99e2450a7915b8b7068357a10cb Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Thu, 26 Sep 2024 16:37:04 +0200 Subject: [PATCH] test: add real world test case --- routing/http/server/filters_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/routing/http/server/filters_test.go b/routing/http/server/filters_test.go index c3f2e5a9a..078e4aa96 100644 --- a/routing/http/server/filters_test.go +++ b/routing/http/server/filters_test.go @@ -169,6 +169,24 @@ func TestProtocolsAllowed(t *testing.T) { filterProtocols: []string{"unknown"}, expected: false, }, + { + name: "Unknown or specific protocol for matching non-empty peer protocols", + peerProtocols: []string{"transport-bitswap"}, + filterProtocols: []string{"unknown", "transport-bitswap", "transport-ipfs-gateway-http"}, + expected: true, + }, + { + name: "Unknown or specific protocol for matching empty peer protocols", + peerProtocols: []string{}, + filterProtocols: []string{"unknown", "transport-bitswap", "transport-ipfs-gateway-http"}, + expected: true, + }, + { + name: "Unknown or specific protocol for not matching non-empty peer protocols", + peerProtocols: []string{"transport-graphsync-filecoinv1"}, + filterProtocols: []string{"unknown", "transport-bitswap", "transport-ipfs-gateway-http"}, + expected: false, + }, { name: "Case insensitive match", peerProtocols: []string{"TRANSPORT-BITSWAP", "Transport-IPFS-Gateway-HTTP"},