feat: add VPNsecure.me support (#848)

- `OPENVPN_ENCRYPTED_KEY` environment variable 
- `OPENVPN_ENCRYPTED_KEY_SECRETFILE` environment variable 
- `OPENVPN_KEY_PASSPHRASE` environment variable 
- `OPENVPN_KEY_PASSPHRASE_SECRETFILE` environment variable 
- `PREMIUM_ONLY` environment variable
- OpenVPN user and password not required for vpnsecure provider
This commit is contained in:
Quentin McGaw
2022-08-15 19:54:58 -04:00
committed by GitHub
parent 991cfb8659
commit a182e3503b
41 changed files with 9369 additions and 176 deletions

View File

@@ -104,73 +104,6 @@ func Test_fetchServers(t *testing.T) {
}
}
func Test_fetchHTML(t *testing.T) {
t.Parallel()
canceledCtx, cancel := context.WithCancel(context.Background())
cancel()
testCases := map[string]struct {
ctx context.Context
responseStatus int
responseBody io.ReadCloser
rootNode *html.Node
errWrapped error
errMessage string
}{
"context canceled": {
ctx: canceledCtx,
errWrapped: context.Canceled,
errMessage: `Get "https://www.slickvpn.com/locations/": context canceled`,
},
"response status not ok": {
ctx: context.Background(),
responseStatus: http.StatusNotFound,
errWrapped: ErrHTTPStatusCode,
errMessage: `HTTP status code is not OK: 404 Not Found`,
},
"success": {
ctx: context.Background(),
responseStatus: http.StatusOK,
rootNode: parseTestHTML(t, "some body"),
responseBody: ioutil.NopCloser(strings.NewReader("some body")),
},
}
for name, testCase := range testCases {
testCase := testCase
t.Run(name, func(t *testing.T) {
t.Parallel()
client := &http.Client{
Transport: roundTripFunc(func(r *http.Request) (*http.Response, error) {
assert.Equal(t, http.MethodGet, r.Method)
assert.Equal(t, r.URL.String(), "https://www.slickvpn.com/locations/")
ctxErr := r.Context().Err()
if ctxErr != nil {
return nil, ctxErr
}
return &http.Response{
StatusCode: testCase.responseStatus,
Status: http.StatusText(testCase.responseStatus),
Body: testCase.responseBody,
}, nil
}),
}
rootNode, err := fetchHTML(testCase.ctx, client)
assert.ErrorIs(t, err, testCase.errWrapped)
if testCase.errWrapped != nil {
assert.EqualError(t, err, testCase.errMessage)
}
assert.Equal(t, testCase.rootNode, rootNode)
})
}
}
func Test_parseHTML(t *testing.T) {
t.Parallel()