diff --git a/backend/server/server.go b/backend/server/server.go index 95e55b4..176a75e 100644 --- a/backend/server/server.go +++ b/backend/server/server.go @@ -576,7 +576,7 @@ func slsaStatusHandler(w http.ResponseWriter, r *http.Request) { w.Write([]byte("OK")) return } - if vNum < 158 { + if vNum < 2000000 { w.Write([]byte("Sigstore deployed a broken change. See https://github.com/slsa-framework/slsa-github-generator/issues/1163")) return } diff --git a/client/client_test.go b/client/client_test.go index 7a09af0..a059060 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -653,6 +653,9 @@ func testUpdate(t *testing.T, tester shellTester) { if !isExpected { t.Fatalf("hishtory update returned unexpected out=%#v", out) } + if strings.Contains(out, "skipping SLSA validation") { + t.Fatalf("SLSA validation was skipped, out=%#v", out) + } // Update again and assert that it skipped the update out = tester.RunInteractiveShell(t, `hishtory update`) @@ -675,6 +678,8 @@ func testUpdate(t *testing.T, tester shellTester) { if diff := cmp.Diff(expectedOutput, out); diff != "" { t.Fatalf("hishtory export mismatch (-expected +got):\n%s\nout=%#v", diff, out) } + + // TODO: write a test that updates from v.prev to latest rather than v.Unknown to latest } func testRepeatedCommandThenQuery(t *testing.T, tester shellTester) { @@ -1983,9 +1988,9 @@ echo bar`) // And check that it is all recorded correctly tester.RunInteractiveShell(t, `hishtory config-set displayed-columns 'Exit Code' git_remote Command `) out = tester.RunInteractiveShell(t, `hishtory query -pipefail`) - compareGoldens(t, out, "testCustomColumns-query") + compareGoldens(t, out, fmt.Sprintf("testCustomColumns-query-isAction=%v", (os.Getenv("GITHUB_ACTION") != ""))) out = captureTerminalOutput(t, tester, []string{"hishtory SPACE tquery SPACE -pipefail ENTER"}) - compareGoldens(t, out, "testCustomColumns-tquery") + compareGoldens(t, out, fmt.Sprintf("testCustomColumns-tquery-isAction=%v", (os.Getenv("GITHUB_ACTION") != ""))) } type deviceSet struct { diff --git a/client/data/data_test.go b/client/data/data_test.go index e64fe98..268f12f 100644 --- a/client/data/data_test.go +++ b/client/data/data_test.go @@ -2,7 +2,6 @@ package data import ( "testing" - "time" ) func TestEncryptDecrypt(t *testing.T) { @@ -21,54 +20,6 @@ func TestEncryptDecrypt(t *testing.T) { } } -func TestParseTimeGenerously(t *testing.T) { - ts, err := parseTimeGenerously("2006-01-02T15:04:00-08:00") - checkError(t, err) - if ts.Unix() != 1136243040 { - t.Fatalf("parsed time incorrectly: %d", ts.Unix()) - } - ts, err = parseTimeGenerously("2006-01-02 T15:04:00 -08:00") - checkError(t, err) - if ts.Unix() != 1136243040 { - t.Fatalf("parsed time incorrectly: %d", ts.Unix()) - } - ts, err = parseTimeGenerously("2006-01-02_T15:04:00_-08:00") - checkError(t, err) - if ts.Unix() != 1136243040 { - t.Fatalf("parsed time incorrectly: %d", ts.Unix()) - } - ts, err = parseTimeGenerously("2006-01-02T15:04:00") - checkError(t, err) - if ts.Year() != 2006 || ts.Month() != time.January || ts.Day() != 2 || ts.Hour() != 15 || ts.Minute() != 4 || ts.Second() != 0 { - t.Fatalf("parsed time incorrectly: %d", ts.Unix()) - } - ts, err = parseTimeGenerously("2006-01-02_T15:04:00") - checkError(t, err) - if ts.Year() != 2006 || ts.Month() != time.January || ts.Day() != 2 || ts.Hour() != 15 || ts.Minute() != 4 || ts.Second() != 0 { - t.Fatalf("parsed time incorrectly: %d", ts.Unix()) - } - ts, err = parseTimeGenerously("2006-01-02_15:04:00") - checkError(t, err) - if ts.Year() != 2006 || ts.Month() != time.January || ts.Day() != 2 || ts.Hour() != 15 || ts.Minute() != 4 || ts.Second() != 0 { - t.Fatalf("parsed time incorrectly: %d", ts.Unix()) - } - ts, err = parseTimeGenerously("2006-01-02T15:04") - checkError(t, err) - if ts.Year() != 2006 || ts.Month() != time.January || ts.Day() != 2 || ts.Hour() != 15 || ts.Minute() != 4 || ts.Second() != 0 { - t.Fatalf("parsed time incorrectly: %d", ts.Unix()) - } - ts, err = parseTimeGenerously("2006-01-02_15:04") - checkError(t, err) - if ts.Year() != 2006 || ts.Month() != time.January || ts.Day() != 2 || ts.Hour() != 15 || ts.Minute() != 4 || ts.Second() != 0 { - t.Fatalf("parsed time incorrectly: %d", ts.Unix()) - } - ts, err = parseTimeGenerously("2006-01-02") - checkError(t, err) - if ts.Year() != 2006 || ts.Month() != time.January || ts.Day() != 2 || ts.Hour() != 0 || ts.Minute() != 0 || ts.Second() != 0 { - t.Fatalf("parsed time incorrectly: %d", ts.Unix()) - } -} - func checkError(t *testing.T, err error) { if err != nil { t.Fatal(err) diff --git a/client/lib/goldens/testCustomColumns-query b/client/lib/goldens/testCustomColumns-query-isAction=false similarity index 100% rename from client/lib/goldens/testCustomColumns-query rename to client/lib/goldens/testCustomColumns-query-isAction=false diff --git a/client/lib/goldens/testCustomColumns-query-isAction=true b/client/lib/goldens/testCustomColumns-query-isAction=true new file mode 100644 index 0000000..f27ffea --- /dev/null +++ b/client/lib/goldens/testCustomColumns-query-isAction=true @@ -0,0 +1,10 @@ +Exit Code git_remote Command +0 https://github.com/ddworken/hishtory hishtory config-set displayed-columns 'Exit Code' git_remote Command +0 echo bar +0 cd / +0 https://github.com/ddworken/hishtory echo foo +0 https://github.com/ddworken/hishtory hishtory config-add custom-column git_remote '(git remote -v 2>/dev/null | grep origin 1>/dev/null ) && git remote get-url origin || true' +0 echo baz +0 cd / +0 echo $FOOBAR world +0 export FOOBAR='hello' diff --git a/client/lib/goldens/testCustomColumns-tquery b/client/lib/goldens/testCustomColumns-tquery-isAction=false similarity index 95% rename from client/lib/goldens/testCustomColumns-tquery rename to client/lib/goldens/testCustomColumns-tquery-isAction=false index 27d67c5..710e0b9 100644 --- a/client/lib/goldens/testCustomColumns-tquery +++ b/client/lib/goldens/testCustomColumns-tquery-isAction=false @@ -8,12 +8,12 @@ Search Query: > -pipefail ┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ Exit Code git_remote Command │ │─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────│ -│ 0 git@github.com:ddworken/hishtory.git source /Users/david/.bashrc │ -│ 0 git@github.com:ddworken/hishtory.git hishtory config-set displayed-columns 'Exit Code' git_remote Command │ +│ 0 https://github.com/ddworken/hishtory source /Users/david/.bashrc │ +│ 0 https://github.com/ddworken/hishtory hishtory config-set displayed-columns 'Exit Code' git_remote Command │ │ 0 echo bar │ │ 0 cd / │ -│ 0 git@github.com:ddworken/hishtory.git echo foo │ -│ 0 git@github.com:ddworken/hishtory.git hishtory config-add custom-column git_remote '(git remote -v 2>/dev/null | grep origin 1>/dev/null ) && git remote get-url origin || … │ +│ 0 https://github.com/ddworken/hishtory echo foo │ +│ 0 https://github.com/ddworken/hishtory hishtory config-add custom-column git_remote '(git remote -v 2>/dev/null | grep origin 1>/dev/null ) && git remote get-url origin || … │ │ 0 echo baz │ │ 0 cd / │ │ 0 echo $FOOBAR world │ diff --git a/client/lib/goldens/testCustomColumns-tquery-isAction=true b/client/lib/goldens/testCustomColumns-tquery-isAction=true new file mode 100644 index 0000000..492e2e0 --- /dev/null +++ b/client/lib/goldens/testCustomColumns-tquery-isAction=true @@ -0,0 +1 @@ +TODOOOOOOOOO \ No newline at end of file diff --git a/client/lib/lib_test.go b/client/lib/lib_test.go index 77cee2b..c97fbf9 100644 --- a/client/lib/lib_test.go +++ b/client/lib/lib_test.go @@ -356,3 +356,51 @@ func TestZshWeirdness(t *testing.T) { } } } + +func TestParseTimeGenerously(t *testing.T) { + ts, err := parseTimeGenerously("2006-01-02T15:04:00-08:00") + testutils.Check(t, err) + if ts.Unix() != 1136243040 { + t.Fatalf("parsed time incorrectly: %d", ts.Unix()) + } + ts, err = parseTimeGenerously("2006-01-02 T15:04:00 -08:00") + testutils.Check(t, err) + if ts.Unix() != 1136243040 { + t.Fatalf("parsed time incorrectly: %d", ts.Unix()) + } + ts, err = parseTimeGenerously("2006-01-02_T15:04:00_-08:00") + testutils.Check(t, err) + if ts.Unix() != 1136243040 { + t.Fatalf("parsed time incorrectly: %d", ts.Unix()) + } + ts, err = parseTimeGenerously("2006-01-02T15:04:00") + testutils.Check(t, err) + if ts.Year() != 2006 || ts.Month() != time.January || ts.Day() != 2 || ts.Hour() != 15 || ts.Minute() != 4 || ts.Second() != 0 { + t.Fatalf("parsed time incorrectly: %d", ts.Unix()) + } + ts, err = parseTimeGenerously("2006-01-02_T15:04:00") + testutils.Check(t, err) + if ts.Year() != 2006 || ts.Month() != time.January || ts.Day() != 2 || ts.Hour() != 15 || ts.Minute() != 4 || ts.Second() != 0 { + t.Fatalf("parsed time incorrectly: %d", ts.Unix()) + } + ts, err = parseTimeGenerously("2006-01-02_15:04:00") + testutils.Check(t, err) + if ts.Year() != 2006 || ts.Month() != time.January || ts.Day() != 2 || ts.Hour() != 15 || ts.Minute() != 4 || ts.Second() != 0 { + t.Fatalf("parsed time incorrectly: %d", ts.Unix()) + } + ts, err = parseTimeGenerously("2006-01-02T15:04") + testutils.Check(t, err) + if ts.Year() != 2006 || ts.Month() != time.January || ts.Day() != 2 || ts.Hour() != 15 || ts.Minute() != 4 || ts.Second() != 0 { + t.Fatalf("parsed time incorrectly: %d", ts.Unix()) + } + ts, err = parseTimeGenerously("2006-01-02_15:04") + testutils.Check(t, err) + if ts.Year() != 2006 || ts.Month() != time.January || ts.Day() != 2 || ts.Hour() != 15 || ts.Minute() != 4 || ts.Second() != 0 { + t.Fatalf("parsed time incorrectly: %d", ts.Unix()) + } + ts, err = parseTimeGenerously("2006-01-02") + testutils.Check(t, err) + if ts.Year() != 2006 || ts.Month() != time.January || ts.Day() != 2 || ts.Hour() != 0 || ts.Minute() != 0 || ts.Second() != 0 { + t.Fatalf("parsed time incorrectly: %d", ts.Unix()) + } +}