Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding IgnoreSSLVerify option #113

Merged
merged 4 commits into from
Jun 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ htmltest uses a YAML configuration file. Put `.htmltest.yml` in the same directo
| `IgnoreCanonicalBrokenLinks` | When true produces a warning, rather than an error, for broken canonical links. When testing a site which isn't live yet or before publishing a new page canonical links will fail. | `true` |
| `IgnoreAltMissing` | Turns off image alt attribute checking. | `false` |
| `IgnoreDirectoryMissingTrailingSlash` | Turns off errors for links to directories without a trailing slash. | `false` |
| `IgnoreSSLVerify` | Turns off x509 errors for self-signed certificates. | `false` |
| `IgnoreTagAttribute` | Specify the ignore attribute. All tags with this attribute will be excluded from every check. | `"data-proofer-ignore"` |
| `HTTPHeaders` | Dictionary of headers to include in external requests | `{"Range": "bytes=0-0", "Accept": "*/*"}` |
| `TestFilesConcurrently` | :warning: :construction: *EXPERIMENTAL* Turns on [concurrent](https://github.com/wjdp/htmltest/wiki/Concurrency) checking of files. | `false` |
Expand Down
12 changes: 12 additions & 0 deletions htmltest/check-link_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,18 @@ func TestAnchorBlankHTML4(t *testing.T) {
tExpectIssueCount(t, hT2, 1)
}

func TestSelfSignedLink(t *testing.T) {
hT := tTestFileOpts("fixtures/links/selfSignedLink.html",
map[string]interface{}{"IgnoreSSLVerify": false})
tExpectIssueCount(t, hT, 1)
}

func TestSelfSignedLinkIgnoreSSLVerify(t *testing.T) {
hT := tTestFileOpts("fixtures/links/selfSignedLink.html",
map[string]interface{}{"IgnoreSSLVerify": true})
tExpectIssueCount(t, hT, 0)
}

// Favicon

func TestFaviconDefaultMissing(t *testing.T) {
Expand Down
11 changes: 11 additions & 0 deletions htmltest/fixtures/links/selfSignedLink.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<html>

<body>

<p>Blah blah blah. <a href="http://www.google.com">Working link!</a></p>


<a href="https://self-signed.badssl.com">self-signed link!</a>
</body>

</html>
1 change: 1 addition & 0 deletions htmltest/htmltest.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func Test(optsUser map[string]interface{}) (*HTMLTest, error) {
// > Programs that must disable HTTP/2 can do so by setting Transport.TLSNextProto ... to a non-nil, empty map.
// See issue #49
TLSNextProto: make(map[string]func(authority string, c *tls.Conn) http.RoundTripper),
TLSClientConfig: &tls.Config{InsecureSkipVerify : hT.opts.IgnoreSSLVerify},
}
hT.httpClient = &http.Client{
// Durations are in nanoseconds
Expand Down
2 changes: 2 additions & 0 deletions htmltest/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type Options struct {
IgnoreCanonicalBrokenLinks bool
IgnoreAltMissing bool
IgnoreDirectoryMissingTrailingSlash bool
IgnoreSSLVerify bool
IgnoreTagAttribute string

HTTPHeaders map[interface{}]interface{}
Expand Down Expand Up @@ -105,6 +106,7 @@ func DefaultOptions() map[string]interface{} {
"IgnoreCanonicalBrokenLinks": true,
"IgnoreAltMissing": false,
"IgnoreDirectoryMissingTrailingSlash": false,
"IgnoreSSLVerify": false,
"IgnoreTagAttribute": "data-proofer-ignore",

"HTTPHeaders": map[string]string{
Expand Down