Skip to content

Commit

Permalink
Fix Test_NsxtL2VpnTunnel for VCD 10.5.1.1+ (#659)
Browse files Browse the repository at this point in the history
  • Loading branch information
Didainius authored Apr 26, 2024
1 parent 781f591 commit 1b16c6f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .changes/v2.25.0/659-notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Patched `Test_NsxtL2VpnTunnel` to match PresharedKey of VCD 10.5.1.1+ as it started returning
`******` instead of PSK itself when performing GET [GH-659]
21 changes: 18 additions & 3 deletions govcd/nsxt_l2_vpn_tunnel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,12 @@ func (vcd *TestVCD) Test_NsxtL2VpnTunnel(check *C) {
check.Assert(serverTunnel.NsxtL2VpnTunnel.LocalEndpointIp, Equals, localEndpointIp[0].IPAddress)
check.Assert(serverTunnel.NsxtL2VpnTunnel.RemoteEndpointIp, Equals, "1.1.1.1")
check.Assert(serverTunnel.NsxtL2VpnTunnel.ConnectorInitiationMode, Equals, "ON_DEMAND")
check.Assert(serverTunnel.NsxtL2VpnTunnel.PreSharedKey, Equals, check.TestName())
if is10511plus, err := vcd.client.Client.VersionEqualOrGreater("10.5.1.23400185", 4); err == nil && is10511plus {
// VCD 10.5.1.1+ return 6 asterisks instead of PreSharedKey
check.Assert(serverTunnel.NsxtL2VpnTunnel.PreSharedKey, Equals, "******")
} else {
check.Assert(serverTunnel.NsxtL2VpnTunnel.PreSharedKey, Equals, check.TestName())
}

fetchedServerTunnel, err := edge.GetL2VpnTunnelById(serverTunnel.NsxtL2VpnTunnel.ID)
check.Assert(err, IsNil)
Expand All @@ -97,7 +102,12 @@ func (vcd *TestVCD) Test_NsxtL2VpnTunnel(check *C) {
check.Assert(updatedServerTunnel.NsxtL2VpnTunnel.RemoteEndpointIp, Equals, "2.2.2.2")
check.Assert(updatedServerTunnel.NsxtL2VpnTunnel.TunnelInterface, Equals, "192.168.0.1/24")
check.Assert(updatedServerTunnel.NsxtL2VpnTunnel.ConnectorInitiationMode, Equals, "INITIATOR")
check.Assert(updatedServerTunnel.NsxtL2VpnTunnel.PreSharedKey, Equals, check.TestName())
if is10511plus, err := vcd.client.Client.VersionEqualOrGreater("10.5.1.23400185", 4); err == nil && is10511plus {
// VCD 10.5.1.1+ return 6 asterisks instead of PreSharedKey
check.Assert(serverTunnel.NsxtL2VpnTunnel.PreSharedKey, Equals, "******")
} else {
check.Assert(serverTunnel.NsxtL2VpnTunnel.PreSharedKey, Equals, check.TestName())
}

tunnelByName, err := edge.GetL2VpnTunnelByName(serverTunnel.NsxtL2VpnTunnel.Name)
check.Assert(err, IsNil)
Expand Down Expand Up @@ -150,7 +160,12 @@ func (vcd *TestVCD) Test_NsxtL2VpnTunnel(check *C) {
check.Assert(clientTunnel.NsxtL2VpnTunnel.Enabled, Equals, true)
check.Assert(clientTunnel.NsxtL2VpnTunnel.LocalEndpointIp, Equals, localEndpointIp[0].IPAddress)
check.Assert(clientTunnel.NsxtL2VpnTunnel.RemoteEndpointIp, Equals, "1.1.1.1")
check.Assert(clientTunnel.NsxtL2VpnTunnel.PreSharedKey, Equals, check.TestName())
if is10511plus, err := vcd.client.Client.VersionEqualOrGreater("10.5.1.23400185", 4); err == nil && is10511plus {
// VCD 10.5.1.1+ return 6 asterisks instead of PreSharedKey
check.Assert(serverTunnel.NsxtL2VpnTunnel.PreSharedKey, Equals, "******")
} else {
check.Assert(serverTunnel.NsxtL2VpnTunnel.PreSharedKey, Equals, check.TestName())
}

fetchedClientTunnel, err := edge.GetL2VpnTunnelById(clientTunnel.NsxtL2VpnTunnel.ID)
check.Assert(err, IsNil)
Expand Down

0 comments on commit 1b16c6f

Please sign in to comment.