webdav: relax test to check for any redirect status, not just 301

CL 720820 changed net/http to use a 307 Temporary Redirect instead of
a 301 Moved Permanently when performing an automatic redirect under
some circumstances. Update tests in the webdav package to be agnostic
on the exact redirect status code.

Change-Id: I71784a738d18928a98387ddbd5475d50b19d15bf
Reviewed-on: https://go-review.googlesource.com/c/net/+/723120
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Nicholas Husin <husin@google.com>
Reviewed-by: Sean Liao <sean@liao.dev>
Reviewed-by: Nicholas Husin <nsh@golang.org>
Auto-Submit: Nicholas Husin <nsh@golang.org>
diff --git a/webdav/webdav_test.go b/webdav/webdav_test.go
index deb60fb..54380e3 100644
--- a/webdav/webdav_test.go
+++ b/webdav/webdav_test.go
@@ -53,7 +53,19 @@
 			return nil, err
 		}
 		defer res.Body.Close()
-		if res.StatusCode != wantStatusCode {
+		isRedirect := func(code int) bool {
+			switch code {
+			case http.StatusMovedPermanently,
+				http.StatusTemporaryRedirect,
+				http.StatusPermanentRedirect:
+				return true
+			default:
+				return false
+			}
+		}
+		if isRedirect(res.StatusCode) && isRedirect(wantStatusCode) {
+			// Allow any redirect.
+		} else if res.StatusCode != wantStatusCode {
 			return nil, fmt.Errorf("got status code %d, want %d", res.StatusCode, wantStatusCode)
 		}
 		return res.Header, nil