(t *testing.T)
| 172 | } |
| 173 | |
| 174 | func TestNewClientFromConfig(t *testing.T) { |
| 175 | newClientValidConfig := []struct { |
| 176 | clientConfig HTTPClientConfig |
| 177 | handler func(w http.ResponseWriter, r *http.Request) |
| 178 | }{ |
| 179 | { |
| 180 | clientConfig: HTTPClientConfig{ |
| 181 | TLSConfig: TLSConfig{ |
| 182 | CAFile: "", |
| 183 | CertFile: ClientCertificatePath, |
| 184 | KeyFile: ClientKeyNoPassPath, |
| 185 | ServerName: "", |
| 186 | InsecureSkipVerify: true, |
| 187 | }, |
| 188 | }, |
| 189 | handler: func(w http.ResponseWriter, _ *http.Request) { |
| 190 | fmt.Fprint(w, ExpectedMessage) |
| 191 | }, |
| 192 | }, |
| 193 | { |
| 194 | clientConfig: HTTPClientConfig{ |
| 195 | TLSConfig: TLSConfig{ |
| 196 | CAFile: TLSCAChainPath, |
| 197 | CertFile: ClientCertificatePath, |
| 198 | KeyFile: ClientKeyNoPassPath, |
| 199 | ServerName: "", |
| 200 | InsecureSkipVerify: false, |
| 201 | }, |
| 202 | }, |
| 203 | handler: func(w http.ResponseWriter, _ *http.Request) { |
| 204 | fmt.Fprint(w, ExpectedMessage) |
| 205 | }, |
| 206 | }, |
| 207 | { |
| 208 | clientConfig: HTTPClientConfig{ |
| 209 | BearerToken: BearerToken, |
| 210 | TLSConfig: TLSConfig{ |
| 211 | CAFile: TLSCAChainPath, |
| 212 | CertFile: ClientCertificatePath, |
| 213 | KeyFile: ClientKeyNoPassPath, |
| 214 | ServerName: "", |
| 215 | InsecureSkipVerify: false, |
| 216 | }, |
| 217 | }, |
| 218 | handler: func(w http.ResponseWriter, r *http.Request) { |
| 219 | bearer := r.Header.Get("Authorization") |
| 220 | if bearer != ExpectedBearer { |
| 221 | fmt.Fprintf(w, "The expected Bearer Authorization (%s) differs from the obtained Bearer Authorization (%s)", |
| 222 | ExpectedBearer, bearer) |
| 223 | } else { |
| 224 | fmt.Fprint(w, ExpectedMessage) |
| 225 | } |
| 226 | }, |
| 227 | }, |
| 228 | { |
| 229 | clientConfig: HTTPClientConfig{ |
| 230 | BearerTokenFile: BearerTokenFile, |
| 231 | TLSConfig: TLSConfig{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…