From 30138c06db462c55a3d247decaaa70006c3d6c70 Mon Sep 17 00:00:00 2001 From: Jordan GAZEAU Date: Fri, 15 Mar 2019 10:13:56 +0100 Subject: [PATCH 1/4] Adding IgnoreSSLVerify option --- README.md | 1 + htmltest/htmltest.go | 1 + htmltest/options.go | 2 ++ 3 files changed, 4 insertions(+) diff --git a/README.md b/README.md index 203d7a8..c6df7be 100644 --- a/README.md +++ b/README.md @@ -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` | diff --git a/htmltest/htmltest.go b/htmltest/htmltest.go index f46a9fc..4d42b4d 100644 --- a/htmltest/htmltest.go +++ b/htmltest/htmltest.go @@ -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 diff --git a/htmltest/options.go b/htmltest/options.go index 57a25b4..b5619fb 100644 --- a/htmltest/options.go +++ b/htmltest/options.go @@ -44,6 +44,7 @@ type Options struct { IgnoreCanonicalBrokenLinks bool IgnoreAltMissing bool IgnoreDirectoryMissingTrailingSlash bool + IgnoreSSLVerify bool IgnoreTagAttribute string HTTPHeaders map[interface{}]interface{} @@ -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{ From fd0744b43eb709761482f96eec1422531731636f Mon Sep 17 00:00:00 2001 From: Jordan GAZEAU Date: Fri, 26 Apr 2019 10:47:05 +0200 Subject: [PATCH 2/4] Adding test case for IgnoreSSLVerify option --- htmltest/check-link_test.go | 12 ++++++++++++ htmltest/fixtures/links/selfSignedLink.html | 11 +++++++++++ 2 files changed, 23 insertions(+) create mode 100644 htmltest/fixtures/links/selfSignedLink.html diff --git a/htmltest/check-link_test.go b/htmltest/check-link_test.go index 61a3eac..e9c58a9 100644 --- a/htmltest/check-link_test.go +++ b/htmltest/check-link_test.go @@ -562,6 +562,18 @@ func TestAnchorBlankHTML4(t *testing.T) { tExpectIssueCount(t, hT2, 1) } +func TestSelfSignedLink(t *testing.T) { + hT := tTestFileOpts("fixtures/links/selfSignedLink.html", + "IgnoreSSLVerify": false}) + tExpectIssueCount(t, hT, 0) +} + +func TestSelfSignedLinkIgnoreSSLVerify(t *testing.T) { + hT := tTestFileOpts("fixtures/links/selfSignedLink.html", + "IgnoreSSLVerify": true}) + tExpectIssueCount(t, hT, 1) +} + // Favicon func TestFaviconDefaultMissing(t *testing.T) { diff --git a/htmltest/fixtures/links/selfSignedLink.html b/htmltest/fixtures/links/selfSignedLink.html new file mode 100644 index 0000000..3545709 --- /dev/null +++ b/htmltest/fixtures/links/selfSignedLink.html @@ -0,0 +1,11 @@ + + + + +

Blah blah blah. Working link!

+ + +self-signed link! + + + \ No newline at end of file From d1da91efe35aaa9259854deecf0d7f68cc530805 Mon Sep 17 00:00:00 2001 From: Jordan GAZEAU Date: Fri, 26 Apr 2019 10:53:19 +0200 Subject: [PATCH 3/4] Adding test case for IgnoreSSLVerify option --- htmltest/check-link_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htmltest/check-link_test.go b/htmltest/check-link_test.go index e9c58a9..89f3cf3 100644 --- a/htmltest/check-link_test.go +++ b/htmltest/check-link_test.go @@ -564,13 +564,13 @@ func TestAnchorBlankHTML4(t *testing.T) { func TestSelfSignedLink(t *testing.T) { hT := tTestFileOpts("fixtures/links/selfSignedLink.html", - "IgnoreSSLVerify": false}) + map[string]interface{}{"IgnoreSSLVerify": false}) tExpectIssueCount(t, hT, 0) } func TestSelfSignedLinkIgnoreSSLVerify(t *testing.T) { hT := tTestFileOpts("fixtures/links/selfSignedLink.html", - "IgnoreSSLVerify": true}) + map[string]interface{}{"IgnoreSSLVerify": true}) tExpectIssueCount(t, hT, 1) } From c580c112ac077deb4cbf05302364e0c7601547dc Mon Sep 17 00:00:00 2001 From: Jordan GAZEAU Date: Fri, 26 Apr 2019 11:00:39 +0200 Subject: [PATCH 4/4] Adding test case for IgnoreSSLVerify option --- htmltest/check-link_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htmltest/check-link_test.go b/htmltest/check-link_test.go index 89f3cf3..6a23535 100644 --- a/htmltest/check-link_test.go +++ b/htmltest/check-link_test.go @@ -565,13 +565,13 @@ func TestAnchorBlankHTML4(t *testing.T) { func TestSelfSignedLink(t *testing.T) { hT := tTestFileOpts("fixtures/links/selfSignedLink.html", map[string]interface{}{"IgnoreSSLVerify": false}) - tExpectIssueCount(t, hT, 0) + tExpectIssueCount(t, hT, 1) } func TestSelfSignedLinkIgnoreSSLVerify(t *testing.T) { hT := tTestFileOpts("fixtures/links/selfSignedLink.html", map[string]interface{}{"IgnoreSSLVerify": true}) - tExpectIssueCount(t, hT, 1) + tExpectIssueCount(t, hT, 0) } // Favicon