This repository has been archived by the owner on Oct 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
145 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package notarize | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/davecgh/go-spew/spew" | ||
"github.com/sebdah/goldie" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func init() { | ||
goldie.FixtureDir = "testdata" | ||
spew.Config.DisablePointerAddresses = true | ||
} | ||
|
||
func TestParseFile(t *testing.T) { | ||
f, err := os.Open("testdata") | ||
require.NoError(t, err) | ||
defer f.Close() | ||
|
||
fis, err := f.Readdir(-1) | ||
require.NoError(t, err) | ||
for _, fi := range fis { | ||
if fi.IsDir() { | ||
continue | ||
} | ||
|
||
if filepath.Ext(fi.Name()) == ".golden" { | ||
continue | ||
} | ||
|
||
t.Run(fi.Name(), func(t *testing.T) { | ||
f, err := os.Open(filepath.Join("testdata", fi.Name())) | ||
require.NoError(t, err) | ||
defer f.Close() | ||
|
||
log, err := ParseLog(f) | ||
require.NoError(t, err) | ||
goldie.Assert(t, fi.Name(), []byte(spew.Sdump(log))) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"logFormatVersion": 1, | ||
"jobId": "4ba7c420-7444-44bc-a190-1bd4bad97b13", | ||
"status": "Invalid", | ||
"statusSummary": "Archive contains critical validation errors", | ||
"statusCode": 4000, | ||
"archiveFilename": "gon.zip", | ||
"uploadDate": "2019-11-06T00:54:22Z", | ||
"sha256": "c109f26d378fbf1efadc8987fdab79d2ce63155e8941823d4d11a907152e11a5", | ||
"ticketContents": null, | ||
"issues": [ | ||
{ | ||
"severity": "error", | ||
"code": null, | ||
"path": "gon.zip/foo", | ||
"message": "The binary is not signed.", | ||
"docUrl": null, | ||
"architecture": "x86_64" | ||
}, | ||
{ | ||
"severity": "error", | ||
"code": null, | ||
"path": "gon.zip/foo", | ||
"message": "The signature does not include a secure timestamp.", | ||
"docUrl": null, | ||
"architecture": "x86_64" | ||
}, | ||
{ | ||
"severity": "error", | ||
"code": null, | ||
"path": "gon.zip/foo", | ||
"message": "The executable does not have the hardened runtime enabled.", | ||
"docUrl": null, | ||
"architecture": "x86_64" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
(*notarize.Log)({ | ||
JobId: (string) (len=36) "4ba7c420-7444-44bc-a190-1bd4bad97b13", | ||
Status: (string) (len=7) "Invalid", | ||
StatusSummary: (string) (len=43) "Archive contains critical validation errors", | ||
StatusCode: (int) 4000, | ||
ArchiveFilename: (string) (len=7) "gon.zip", | ||
UploadDate: (string) (len=20) "2019-11-06T00:54:22Z", | ||
SHA256: (string) (len=64) "c109f26d378fbf1efadc8987fdab79d2ce63155e8941823d4d11a907152e11a5", | ||
Issues: ([]notarize.LogIssue) (len=3 cap=4) { | ||
(notarize.LogIssue) { | ||
Severity: (string) (len=5) "error", | ||
Path: (string) (len=11) "gon.zip/foo", | ||
Message: (string) (len=25) "The binary is not signed." | ||
}, | ||
(notarize.LogIssue) { | ||
Severity: (string) (len=5) "error", | ||
Path: (string) (len=11) "gon.zip/foo", | ||
Message: (string) (len=50) "The signature does not include a secure timestamp." | ||
}, | ||
(notarize.LogIssue) { | ||
Severity: (string) (len=5) "error", | ||
Path: (string) (len=11) "gon.zip/foo", | ||
Message: (string) (len=58) "The executable does not have the hardened runtime enabled." | ||
} | ||
}, | ||
TicketContents: ([]notarize.LogTicketContent) <nil> | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"logFormatVersion": 1, | ||
"jobId": "3382aa04-e417-46a0-b1b4-42eebf85906c", | ||
"status": "Accepted", | ||
"statusSummary": "Ready for distribution", | ||
"statusCode": 0, | ||
"archiveFilename": "gon.zip", | ||
"uploadDate": "2019-11-06T00:51:10Z", | ||
"sha256": "1070be725b5b0c89b8dad699a9080a3bf5809fe68bfe8f84d6ff4a282d661fd1", | ||
"ticketContents": [ | ||
{ | ||
"path": "gon.zip/foo", | ||
"digestAlgorithm": "SHA-256", | ||
"cdhash": "b7049085e21423f102d6119bca93d57ebd903289", | ||
"arch": "x86_64" | ||
} | ||
], | ||
"issues": null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
(*notarize.Log)({ | ||
JobId: (string) (len=36) "3382aa04-e417-46a0-b1b4-42eebf85906c", | ||
Status: (string) (len=8) "Accepted", | ||
StatusSummary: (string) (len=22) "Ready for distribution", | ||
StatusCode: (int) 0, | ||
ArchiveFilename: (string) (len=7) "gon.zip", | ||
UploadDate: (string) (len=20) "2019-11-06T00:51:10Z", | ||
SHA256: (string) (len=64) "1070be725b5b0c89b8dad699a9080a3bf5809fe68bfe8f84d6ff4a282d661fd1", | ||
Issues: ([]notarize.LogIssue) <nil>, | ||
TicketContents: ([]notarize.LogTicketContent) (len=1 cap=4) { | ||
(notarize.LogTicketContent) { | ||
Path: (string) (len=11) "gon.zip/foo", | ||
DigestAlgorithm: (string) (len=7) "SHA-256", | ||
CDHash: (string) (len=40) "b7049085e21423f102d6119bca93d57ebd903289", | ||
Arch: (string) (len=6) "x86_64" | ||
} | ||
} | ||
}) |