Skip to content

Commit

Permalink
Merge pull request #113 from jgazeau/fix/112
Browse files Browse the repository at this point in the history
Adding IgnoreSSLVerify option
  • Loading branch information
wjdp authored Jun 20, 2019
2 parents c04b7d3 + c580c11 commit f8a0ead
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 0 deletions.
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

0 comments on commit f8a0ead

Please sign in to comment.