Commit 5f135a27 authored by Matthew Holt's avatar Matthew Holt

Eliminate ineffectual assignments

Most of these were fixed by handling errors that were previously
unhandled (oops).
parent 45a3d0b5
......@@ -290,18 +290,19 @@ func TestBrowseJson(t *testing.T) {
for i, test := range tests {
var marsh []byte
req, err := http.NewRequest("GET", "/photos"+test.QueryURL, nil)
if err == nil && test.shouldErr {
t.Errorf("Test %d didn't error, but it should have", i)
} else if err != nil && !test.shouldErr {
t.Errorf("Test %d errored, but it shouldn't have; got '%v'", i, err)
if err != nil && !test.shouldErr {
t.Errorf("Test %d errored when making request, but it shouldn't have; got '%v'", i, err)
}
req.Header.Set("Accept", "application/json")
rec := httptest.NewRecorder()
code, err := b.ServeHTTP(rec, req)
if err == nil && test.shouldErr {
t.Errorf("Test %d didn't error, but it should have", i)
} else if err != nil && !test.shouldErr {
t.Errorf("Test %d errored, but it shouldn't have; got '%v'", i, err)
}
if code != http.StatusOK {
t.Fatalf("In test %d: Wrong status, expected %d, got %d", i, http.StatusOK, code)
}
......
......@@ -546,6 +546,9 @@ func (c *FCGIClient) PostFile(p map[string]string, data url.Values, file map[str
return nil, e
}
_, err = io.Copy(part, fd)
if err != nil {
return
}
}
err = writer.Close()
......
......@@ -103,7 +103,6 @@ func (fs FileServer) serveFile(w http.ResponseWriter, r *http.Request, name stri
defer ff.Close()
dd, err := ff.Stat()
if err == nil {
name = index
d = dd
f = ff
break
......
......@@ -163,6 +163,9 @@ func TestServeHTTP(t *testing.T) {
for i, test := range tests {
responseRecorder := httptest.NewRecorder()
request, err := http.NewRequest("GET", test.url, nil)
if err != nil {
t.Errorf("Test %d: Error making request: %v", i, err)
}
// prevent any URL sanitization within Go: we need unmodified paths here
if u, _ := url.Parse(test.url); u.RawPath != "" {
request.URL.Path = u.RawPath
......
......@@ -56,6 +56,9 @@ var newACMEClient = func(config *Config, allowPrompts bool) (*ACMEClient, error)
caURL = "https://" + caURL
}
u, err := url.Parse(caURL)
if err != nil {
return nil, err
}
if u.Scheme != "https" && !caddy.IsLoopback(u.Host) && !strings.HasPrefix(u.Host, "10.") {
return nil, fmt.Errorf("%s: insecure CA URL (HTTPS required)", caURL)
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment