1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
17 func TestTLS(t *testing.T) {
19 theConfig.TLSKeyFile = ""
20 theConfig.TLSCertificateFile = ""
22 theConfig.TLSKeyFile = "../api/tmp/self-signed.key"
23 theConfig.TLSCertificateFile = "../api/tmp/self-signed.pem"
25 srv.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
28 l, err := net.Listen("tcp", ":")
34 defer srv.Shutdown(context.Background())
35 c := &http.Client{Transport: &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}}}
36 resp, err := c.Get("https://" + l.Addr().String() + "/")
40 body, err := ioutil.ReadAll(resp.Body)
44 if !bytes.Equal(body, []byte("OK")) {
45 t.Errorf("expected OK, got %q", body)