@@ -2,7 +2,7 @@ import * as https from 'https';
2
2
import * as path from 'path' ;
3
3
import * as forge from 'node-forge' ;
4
4
5
- import { expect , fetch , nodeOnly } from "./test-utils" ;
5
+ import { expect , fetch , ignoreNetworkError , nodeOnly } from "./test-utils" ;
6
6
import * as fs from '../src/util/fs' ;
7
7
8
8
import { CA , generateCACertificate } from '../src/util/tls' ;
@@ -60,17 +60,18 @@ nodeOnly(() => {
60
60
} ) ;
61
61
62
62
it ( "should be able to generate a CA certificate that passes lintcert checks" , async function ( ) {
63
- this . retries ( 3 ) ; // Lintcert can have intermittent connectivity blips
64
-
65
63
const caCertificate = await caCertificatePromise ;
66
64
67
65
const { cert } = caCertificate ;
68
66
69
- const response = await fetch ( 'https://crt.sh/lintcert' , {
70
- method : 'POST' ,
71
- headers : { 'content-type' : 'application/x-www-form-urlencoded' } ,
72
- body : new URLSearchParams ( { 'b64cert' : cert } )
73
- } ) ;
67
+ const response = await ignoreNetworkError (
68
+ fetch ( 'https://crt.sh/lintcert' , {
69
+ method : 'POST' ,
70
+ headers : { 'content-type' : 'application/x-www-form-urlencoded' } ,
71
+ body : new URLSearchParams ( { 'b64cert' : cert } )
72
+ } ) ,
73
+ { context : this }
74
+ ) ;
74
75
75
76
const lintOutput = await response . text ( ) ;
76
77
@@ -88,7 +89,6 @@ nodeOnly(() => {
88
89
89
90
it ( "should generate CA certs that can be used to create domain certs that pass lintcert checks" , async function ( ) {
90
91
this . timeout ( 5000 ) ; // Large cert + remote request can make this slow
91
- this . retries ( 3 ) ; // Lintcert can have intermittent connectivity blips
92
92
93
93
const caCertificate = await caCertificatePromise ;
94
94
const ca = new CA ( caCertificate . key , caCertificate . cert , 2048 ) ;
@@ -99,11 +99,14 @@ nodeOnly(() => {
99
99
const certData = forge . pki . certificateFromPem ( cert ) ;
100
100
expect ( ( certData . getExtension ( 'subjectAltName' ) as any ) . altNames [ 0 ] . value ) . to . equal ( 'httptoolkit.tech' ) ;
101
101
102
- const response = await fetch ( 'https://crt.sh/lintcert' , {
103
- method : 'POST' ,
104
- headers : { 'content-type' : 'application/x-www-form-urlencoded' } ,
105
- body : new URLSearchParams ( { 'b64cert' : cert } )
106
- } ) ;
102
+ const response = await ignoreNetworkError (
103
+ fetch ( 'https://crt.sh/lintcert' , {
104
+ method : 'POST' ,
105
+ headers : { 'content-type' : 'application/x-www-form-urlencoded' } ,
106
+ body : new URLSearchParams ( { 'b64cert' : cert } )
107
+ } ) ,
108
+ { context : this }
109
+ ) ;
107
110
108
111
expect ( response . status ) . to . equal ( 200 ) ;
109
112
const lintOutput = await response . text ( ) ;
@@ -129,7 +132,6 @@ nodeOnly(() => {
129
132
130
133
it ( "should generate wildcard certs that pass lintcert checks for invalid subdomain names" , async function ( ) {
131
134
this . timeout ( 5000 ) ; // Large cert + remote request can make this slow
132
- this . retries ( 3 ) ; // Lintcert can have intermittent connectivity blips
133
135
134
136
const caCertificate = await caCertificatePromise ;
135
137
const ca = new CA ( caCertificate . key , caCertificate . cert , 2048 ) ;
@@ -139,11 +141,14 @@ nodeOnly(() => {
139
141
const certData = forge . pki . certificateFromPem ( cert ) ;
140
142
expect ( ( certData . getExtension ( 'subjectAltName' ) as any ) . altNames [ 0 ] . value ) . to . equal ( '*.httptoolkit.tech' ) ;
141
143
142
- const response = await fetch ( 'https://crt.sh/lintcert' , {
143
- method : 'POST' ,
144
- headers : { 'content-type' : 'application/x-www-form-urlencoded' } ,
145
- body : new URLSearchParams ( { 'b64cert' : cert } )
146
- } ) ;
144
+ const response = await ignoreNetworkError (
145
+ fetch ( 'https://crt.sh/lintcert' , {
146
+ method : 'POST' ,
147
+ headers : { 'content-type' : 'application/x-www-form-urlencoded' } ,
148
+ body : new URLSearchParams ( { 'b64cert' : cert } )
149
+ } ) ,
150
+ { context : this }
151
+ ) ;
147
152
148
153
expect ( response . status ) . to . equal ( 200 ) ;
149
154
const lintOutput = await response . text ( ) ;
0 commit comments