/* * Copyright 2014 VMware, Inc. All rights reserved. Licensed under the Apache v2 License. */ package govcd import ( "github.com/hmrc/vmware-govcd/testutil" . "gopkg.in/check.v1" ) func (s *S) Test_Refresh(c *C) { // Get the Org populated testServer.ResponseMap(2, testutil.ResponseMap{ "/api/vdc/00000000-0000-0000-0000-000000000000/edgeGateways": testutil.Response{200, nil, edgegatewayqueryresultsExample}, "/api/admin/edgeGateway/00000000-0000-0000-0000-000000000000": testutil.Response{200, nil, edgegatewayExample}, }) edge, err := s.vdc.FindEdgeGateway("M916272752-5793") _ = testServer.WaitRequests(2) testServer.Flush() c.Assert(err, IsNil) c.Assert(edge.EdgeGateway.Name, Equals, "M916272752-5793") testServer.Response(200, nil, edgegatewayExample) err = edge.Refresh() _ = testServer.WaitRequest() testServer.Flush() c.Assert(err, IsNil) c.Assert(edge.EdgeGateway.Name, Equals, "M916272752-5793") } func (s *S) Test_NATMapping(c *C) { testServer.ResponseMap(2, testutil.ResponseMap{ "/api/vdc/00000000-0000-0000-0000-000000000000/edgeGateways": testutil.Response{200, nil, edgegatewayqueryresultsExample}, "/api/admin/edgeGateway/00000000-0000-0000-0000-000000000000": testutil.Response{200, nil, edgegatewayExample}, }) edge, err := s.vdc.FindEdgeGateway("M916272752-5793") _ = testServer.WaitRequests(2) testServer.Flush() c.Assert(err, IsNil) c.Assert(edge.EdgeGateway.Name, Equals, "M916272752-5793") testServer.ResponseMap(2, testutil.ResponseMap{ "/api/admin/edgeGateway/00000000-0000-0000-0000-000000000000": testutil.Response{200, nil, edgegatewayExample}, "/api/admin/edgeGateway/00000000-0000-0000-0000-000000000000/action/configureServices": testutil.Response{200, nil, taskExample}, }) _, err = edge.AddNATMapping("DNAT", "10.0.0.1", "20.0.0.2", "77") _ = testServer.WaitRequest() c.Assert(err, IsNil) testServer.ResponseMap(2, testutil.ResponseMap{ "/api/admin/edgeGateway/00000000-0000-0000-0000-000000000000": testutil.Response{200, nil, edgegatewayExample}, "/api/admin/edgeGateway/00000000-0000-0000-0000-000000000000/action/configureServices": testutil.Response{200, nil, taskExample}, }) _, err = edge.RemoveNATMapping("DNAT", "10.0.0.1", "20.0.0.2", "77") _ = testServer.WaitRequest() c.Assert(err, IsNil) } func (s *S) Test_1to1Mappings(c *C) { testServer.ResponseMap(2, testutil.ResponseMap{ "/api/vdc/00000000-0000-0000-0000-000000000000/edgeGateways": testutil.Response{200, nil, edgegatewayqueryresultsExample}, "/api/admin/edgeGateway/00000000-0000-0000-0000-000000000000": testutil.Response{200, nil, edgegatewayExample}, }) edge, err := s.vdc.FindEdgeGateway("M916272752-5793") _ = testServer.WaitRequests(2) testServer.Flush() c.Assert(err, IsNil) c.Assert(edge.EdgeGateway.Name, Equals, "M916272752-5793") testServer.ResponseMap(2, testutil.ResponseMap{ "/api/admin/edgeGateway/00000000-0000-0000-0000-000000000000": testutil.Response{200, nil, edgegatewayExample}, "/api/admin/edgeGateway/00000000-0000-0000-0000-000000000000/action/configureServices": testutil.Response{200, nil, taskExample}, }) _, err = edge.Create1to1Mapping("10.0.0.1", "20.0.0.2", "description") _ = testServer.WaitRequests(2) c.Assert(err, IsNil) testServer.ResponseMap(2, testutil.ResponseMap{ "/api/admin/edgeGateway/00000000-0000-0000-0000-000000000000": testutil.Response{200, nil, edgegatewayExample}, "/api/admin/edgeGateway/00000000-0000-0000-0000-000000000000/action/configureServices": testutil.Response{200, nil, taskExample}, }) _, err = edge.Remove1to1Mapping("10.0.0.1", "20.0.0.2") _ = testServer.WaitRequests(2) c.Assert(err, IsNil) } var edgegatewayqueryresultsExample = ` ` var edgegatewayExample = ` compact JGray Network JGray Network internal 192.168.108.1 255.255.255.0 192.168.108.1 false false M916272752-5793-default-routed M916272752-5793-default-routed internal 192.168.109.1 255.255.255.0 192.168.109.1 false false d2p3-ext d2p3-ext uplink 23.92.224.1 255.255.254.0 23.92.225.51 23.92.225.73 23.92.225.75 23.92.225.27 23.92.225.27 23.92.225.11 23.92.225.11 23.92.225.54 23.92.225.54 23.92.224.34 23.92.224.34 23.92.225.5 23.92.225.5 23.92.225.34 23.92.225.34 23.92.224.255 23.92.224.255 23.92.225.49 23.92.225.51 23.92.225.62 23.92.225.62 23.92.225.43 23.92.225.43 23.92.225.30 23.92.225.30 true 1024.0 1024.0 true true drop false 1 true false ssh prd-001 allow true 999 999 23.92.225.51 -1 Any 60.241.110.111 false 2 true false inet prd-001 allow true -1 Any Any -1 Any 192.168.109.8 false 3 true false suppah megah rulez creati0nz allow true -1 Any 23.92.224.255 -1 Any Any false 4 true false suppah megah rulez creati0nz allow true -1 Any Any -1 Any 192.168.109.3 false false DNAT true 65537 23.92.225.51 999 192.168.109.8 22 Tcp SNAT true 65538 192.168.109.8 23.92.225.51 SNAT true 65539 192.168.109.3 23.92.224.255 DNAT true 65540 23.92.224.255 any 192.168.109.3 any any true Test VPN Alpha For OC Pod Testing 192.168.110.99 64.184.133.62 192.168.110.99 23.92.225.51 23.92.225.51 M916272752-5793-default-routed 192.168.109.1 255.255.255.0 192.168.120.0/24 192.168.120.0 255.255.255.0 Blah1Blah2Blah3Blah1Blah2Blah3Blah1Blah2Blah3 false AES256 1500 true false JGray VPN 67.172.148.74 67.172.148.74 67.172.148.74 23.92.225.51 23.92.225.51 JGray Network 192.168.108.1 255.255.255.0 192.168.1.0/24 192.168.1.0 255.255.255.0 fM7puHkGbg6tqpd4jKNhBo45mbs8fw3yapgt3H7f97a2jrkLyYjP9eSH4oGwps7u false AES256 1500 false false false false true true `