Skip to content

Commit

Permalink
Merge pull request #36 from spiegel-im-spiegel/support-rfc4880bis
Browse files Browse the repository at this point in the history
Fix bug of tag11
  • Loading branch information
spiegel-im-spiegel authored Jan 31, 2020
2 parents 5256dbf + 56dd782 commit 3872673
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cli/gpgpdump/facade/facade.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var (
var (
usage = []string{ //output message of version
Name + " " + Version,
"Copyright 2016-2019 Spiegel (based on pgpdump by kazu-yamamoto)",
"Copyright 2016-2020 Spiegel (based on pgpdump by kazu-yamamoto)",
"Licensed under Apache License, Version 2.0",
}
versionFlag bool //version flag
Expand Down
2 changes: 1 addition & 1 deletion cli/gpgpdump/facade/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

func TestVersionMin(t *testing.T) {
result := "gpgpdump dev-version\nCopyright 2016-2019 Spiegel (based on pgpdump by kazu-yamamoto)\nLicensed under Apache License, Version 2.0\n"
result := "gpgpdump dev-version\nCopyright 2016-2020 Spiegel (based on pgpdump by kazu-yamamoto)\nLicensed under Apache License, Version 2.0\n"

outBuf := new(bytes.Buffer)
outErrBuf := new(bytes.Buffer)
Expand Down
10 changes: 9 additions & 1 deletion packet/values/datetime.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,15 @@ func unixtime2RFC3339(ut uint32, utcFlag bool) string {

//FileTimeItem returns UNIXTime instance for Modification time of a file
func FileTimeItem(dt *DateTime, dumpFlag bool) *info.Item {
return dt.ToItem("Creation time", dumpFlag)
name := "Creation time"
if dt.IsZero() {
return info.NewItem(
info.Name(name),
info.Value("null"),
info.DumpStr(DumpBytes(dt.tm, dumpFlag).String()),
)
}
return dt.ToItem(name, dumpFlag)
}

//PubKeyTimeItem returns UNIXTime instance for Public key creation time
Expand Down
16 changes: 16 additions & 0 deletions packet/values/datetime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

var (
ut = []byte{0x36, 0x5e, 0x72, 0x6e}
ut0 = []byte{0, 0, 0, 0}
rfc3339 = "1998-11-27T09:35:42Z"
)

Expand Down Expand Up @@ -69,6 +70,21 @@ func TestFileTimeItem(t *testing.T) {
}
}

func TestFileTimeItemZero(t *testing.T) {
name := "Creation time"
dt, err := NewDateTime(reader.New(ut0), true) //UTC
if err != nil {
t.Errorf("NewDateTime() = \"%+v\", want nil error.", err)
}
itm := FileTimeItem(dt, true)
if itm.Name != name {
t.Errorf("FileTimeItem() = \"%v\", want \"%v\".", itm.Name, name)
}
if itm.Value != "null" {
t.Errorf("FileTimeItem() = \"%v\", want \"%v\".", itm.Value, "null")
}
}

func TestPubKeyTimeItem(t *testing.T) {
name := "Public key creation time"
dt, err := NewDateTime(reader.New(ut), true) //UTC
Expand Down

0 comments on commit 3872673

Please sign in to comment.