X-Git-Url: https://ruderich.org/simon/gitweb/?p=nsscash%2Fnsscash.git;a=blobdiff_plain;f=main_test.go;h=c4afa7929dbf980489cdde2fa487725d6f4917f1;hp=31c9e50064f21276776f5e344edc62da53f9aad0;hb=5f90bfd1ae2fb737d14532d74d93e3f1c1763f99;hpb=4403833dcfc3d296dd9664b1752f722e5f64a275 diff --git a/main_test.go b/main_test.go index 31c9e50..c4afa79 100644 --- a/main_test.go +++ b/main_test.go @@ -198,6 +198,7 @@ func TestMainFetch(t *testing.T) { // Perform most tests with passwd for simplicity fetchPasswdCacheFileDoesNotExist, fetchPasswd404, + fetchPasswdUnexpected304, fetchPasswdEmpty, fetchPasswdInvalid, fetchPasswdLimits, @@ -329,6 +330,24 @@ func fetchPasswd404(a args) { mustBeOld(a.t, passwdPath) } +func fetchPasswdUnexpected304(a args) { + t := a.t + mustWritePasswdConfig(t, a.url) + mustCreate(t, passwdPath) + + *a.handler = func(w http.ResponseWriter, r *http.Request) { + // 304 + w.WriteHeader(http.StatusNotModified) + } + + err := mainFetch(configPath) + mustBeErrorWithSubstring(t, err, + "status code 304 but did not send If-Modified-Since") + + mustNotExist(t, statePath, plainPath, groupPath) + mustBeOld(a.t, passwdPath) +} + func fetchPasswdEmpty(a args) { t := a.t mustWritePasswdConfig(t, a.url)