Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumemichel committed Jan 15, 2025
1 parent 5fbe088 commit 52aa448
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,21 +484,32 @@ func TestIPv6Lookup(t *testing.T) {
}

func TestLibp2pACMEE2E(t *testing.T) {
isValidResolvedForgeAddr := func(addr string) bool {
return strings.Contains(addr, "libp2p.direct/ws")
}
isValidShortForgeAddr := func(addr string) bool {
return strings.Contains(addr, "libp2p.direct/tcp/") && strings.Contains(addr, "/tls/ws")
}

tests := []struct {
name string
clientOpts []client.P2PForgeCertMgrOptions
name string
clientOpts []client.P2PForgeCertMgrOptions
isValidForgeAddr func(addr string) bool
}{
{
name: "default opts",
clientOpts: []client.P2PForgeCertMgrOptions{},
name: "default opts",
clientOpts: []client.P2PForgeCertMgrOptions{},
isValidForgeAddr: isValidResolvedForgeAddr,
},
{
name: "explicit WithShortForgeAddrs(true)",
clientOpts: []client.P2PForgeCertMgrOptions{client.WithShortForgeAddrs(true)},
name: "explicit WithShortForgeAddrs(true)",
clientOpts: []client.P2PForgeCertMgrOptions{client.WithShortForgeAddrs(true)},
isValidForgeAddr: isValidShortForgeAddr,
},
{
name: "explicit WithShortForgeAddrs(false)",
clientOpts: []client.P2PForgeCertMgrOptions{client.WithShortForgeAddrs(false)},
name: "explicit WithShortForgeAddrs(false)",
clientOpts: []client.P2PForgeCertMgrOptions{client.WithShortForgeAddrs(false)},
isValidForgeAddr: isValidResolvedForgeAddr,
},
}

Expand Down Expand Up @@ -630,7 +641,7 @@ func TestLibp2pACMEE2E(t *testing.T) {
if strings.Contains(as, "p2p-circuit") {
continue
}
if strings.Contains(as, "libp2p.direct/ws") {
if tt.isValidForgeAddr(as) {
dialAddr = addr
break
}
Expand Down

0 comments on commit 52aa448

Please sign in to comment.