-
Notifications
You must be signed in to change notification settings - Fork 209
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added --pac-file flag to hoverctl start
- Loading branch information
Showing
7 changed files
with
161 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
function FindProxyForURL(url, host) { | ||
// our local URLs from the domains below example.com don't need a proxy: | ||
if (shExpMatch(host, "*.example.com")) | ||
{ | ||
return "DIRECT"; | ||
} | ||
|
||
// URLs within this network are accessed through | ||
// port 8080 on fastproxy.example.com: | ||
if (isInNet(host, "10.0.0.0", "255.255.248.0")) | ||
{ | ||
return "PROXY fastproxy.example.com:8080"; | ||
} | ||
|
||
// All other requests go through port 8080 of proxy.example.com. | ||
// should that fail to respond, go directly to the WWW: | ||
return "PROXY proxy.example.com:8080; DIRECT"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package wrapper | ||
|
||
import ( | ||
"github.com/SpectoLabs/hoverfly/hoverctl/configuration" | ||
) | ||
|
||
func SetPACFile(target configuration.Target) error { | ||
response, err := doRequest(target, "PUT", v2ApiPac, target.PACFile, nil) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
defer response.Body.Close() | ||
|
||
err = handleResponseError(response, "Could not set PAC file") | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package wrapper | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/SpectoLabs/hoverfly/core/handlers/v2" | ||
"github.com/SpectoLabs/hoverfly/core/matching/matchers" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
func Test_SetPACFile_CanSetPACFile(t *testing.T) { | ||
RegisterTestingT(t) | ||
|
||
hoverfly.DeleteSimulation() | ||
hoverfly.PutSimulation(v2.SimulationViewV5{ | ||
v2.DataViewV5{ | ||
RequestResponsePairs: []v2.RequestMatcherResponsePairViewV5{ | ||
v2.RequestMatcherResponsePairViewV5{ | ||
RequestMatcher: v2.RequestMatcherViewV5{ | ||
Method: []v2.MatcherViewV5{ | ||
{ | ||
Matcher: matchers.Exact, | ||
Value: "PUT", | ||
}, | ||
}, | ||
Path: []v2.MatcherViewV5{ | ||
{ | ||
Matcher: matchers.Exact, | ||
Value: "/api/v2/hoverfly/pac", | ||
}, | ||
}, | ||
}, | ||
Response: v2.ResponseDetailsViewV5{ | ||
Status: 200, | ||
Body: `PACFILE`, | ||
}, | ||
}, | ||
}, | ||
}, | ||
v2.MetaView{ | ||
SchemaVersion: "v2", | ||
}, | ||
}) | ||
|
||
err := SetPACFile(target) | ||
Expect(err).To(BeNil()) | ||
} | ||
|
||
func Test_SetPACFile_ServerError(t *testing.T) { | ||
RegisterTestingT(t) | ||
|
||
hoverfly.DeleteSimulation() | ||
hoverfly.PutSimulation(v2.SimulationViewV5{ | ||
v2.DataViewV5{ | ||
RequestResponsePairs: []v2.RequestMatcherResponsePairViewV5{ | ||
v2.RequestMatcherResponsePairViewV5{ | ||
RequestMatcher: v2.RequestMatcherViewV5{ | ||
Method: []v2.MatcherViewV5{ | ||
{ | ||
Matcher: matchers.Exact, | ||
Value: "PUT", | ||
}, | ||
}, | ||
Path: []v2.MatcherViewV5{ | ||
{ | ||
Matcher: matchers.Exact, | ||
Value: "/api/v2/hoverfly/pac", | ||
}, | ||
}, | ||
}, | ||
Response: v2.ResponseDetailsViewV5{ | ||
Status: 400, | ||
Body: `PACFILE`, | ||
}, | ||
}, | ||
}, | ||
}, | ||
v2.MetaView{ | ||
SchemaVersion: "v2", | ||
}, | ||
}) | ||
|
||
err := SetPACFile(target) | ||
Expect(err).To(Not(BeNil())) | ||
} |