From d71bfc62c2a337523114389bba86b58049961d19 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Fri, 2 Aug 2019 20:53:43 +0200 Subject: [PATCH] nsscash: main_test: fix Last-Modified/If-Modified-Since headers http.TimeFormat requires a time in UTC for a proper Last-Modified header. Previously, the time was in CEST (my local timezone) which caused all Last-Modified headers to have an offset of two hours. This also hid a bug in the If-Modified-Since header handling: The last change time must be truncated to seconds as the If-Modified-Since header has only a second precision. These bugs did not affect the current test cases. However, it affects the test case which will be added in the next commit. --- main_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main_test.go b/main_test.go index 2015817..0279bb7 100644 --- a/main_test.go +++ b/main_test.go @@ -438,14 +438,14 @@ func fetchPasswd(a args) { t.Fatalf("invalid If-Modified-Since %v", modified) } - if !x.Before(lastChange) { + if !x.Before(lastChange.Truncate(time.Second)) { w.WriteHeader(http.StatusNotModified) return } } w.Header().Add("Last-Modified", - lastChange.Format(http.TimeFormat)) + lastChange.UTC().Format(http.TimeFormat)) fmt.Fprintln(w, "root:x:0:0:root:/root:/bin/bash") fmt.Fprintln(w, "daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin") } -- 2.45.2