@@ -18,25 +18,28 @@ func TestProxyCreate_Datacenter_Success(t *testing.T) {
1818 // Verify the request
1919 assert .Equal (t , kernel .ProxyNewParamsTypeDatacenter , body .Type )
2020 assert .Equal (t , "My DC Proxy" , body .Name .Value )
21+ assert .Equal (t , []string {"localhost" , "internal.service.local" }, body .BypassHosts )
2122
2223 // Check config
2324 dcConfig := body .Config .OfProxyNewsConfigDatacenterProxyConfig
2425 assert .NotNil (t , dcConfig )
2526 assert .Equal (t , "US" , dcConfig .Country .Value )
2627
2728 return & kernel.ProxyNewResponse {
28- ID : "dc-new" ,
29- Name : "My DC Proxy" ,
30- Type : kernel .ProxyNewResponseTypeDatacenter ,
29+ ID : "dc-new" ,
30+ Name : "My DC Proxy" ,
31+ Type : kernel .ProxyNewResponseTypeDatacenter ,
32+ BypassHosts : []string {"localhost" , "internal.service.local" },
3133 }, nil
3234 },
3335 }
3436
3537 p := ProxyCmd {proxies : fake }
3638 err := p .Create (context .Background (), ProxyCreateInput {
37- Name : "My DC Proxy" ,
38- Type : "datacenter" ,
39- Country : "US" ,
39+ Name : "My DC Proxy" ,
40+ Type : "datacenter" ,
41+ Country : "US" ,
42+ BypassHosts : []string {"localhost" , "internal.service.local" },
4043 })
4144
4245 assert .NoError (t , err )
@@ -46,6 +49,9 @@ func TestProxyCreate_Datacenter_Success(t *testing.T) {
4649 assert .Contains (t , output , "Successfully created proxy" )
4750 assert .Contains (t , output , "dc-new" )
4851 assert .Contains (t , output , "My DC Proxy" )
52+ assert .Contains (t , output , "Bypass Hosts" )
53+ assert .Contains (t , output , "localhost" )
54+ assert .Contains (t , output , "internal.service.local" )
4955}
5056
5157func TestProxyCreate_Datacenter_WithoutCountry (t * testing.T ) {
@@ -306,6 +312,27 @@ func TestProxyCreate_Protocol_Invalid(t *testing.T) {
306312 assert .Contains (t , err .Error (), "invalid protocol: ftp" )
307313}
308314
315+ func TestProxyCreate_BypassHosts_Normalized (t * testing.T ) {
316+ fake := & FakeProxyService {
317+ NewFunc : func (ctx context.Context , body kernel.ProxyNewParams , opts ... option.RequestOption ) (* kernel.ProxyNewResponse , error ) {
318+ assert .Equal (t , []string {"localhost" , "internal.service.local" }, body .BypassHosts )
319+ return & kernel.ProxyNewResponse {
320+ ID : "test-proxy" ,
321+ Type : kernel .ProxyNewResponseTypeDatacenter ,
322+ }, nil
323+ },
324+ }
325+
326+ p := ProxyCmd {proxies : fake }
327+ err := p .Create (context .Background (), ProxyCreateInput {
328+ Type : "datacenter" ,
329+ Country : "US" ,
330+ BypassHosts : []string {" localhost " , "" , "internal.service.local" },
331+ })
332+
333+ assert .NoError (t , err )
334+ }
335+
309336func TestProxyCreate_APIError (t * testing.T ) {
310337 _ = captureOutput (t )
311338
0 commit comments