-
Notifications
You must be signed in to change notification settings - Fork 60
Open
Description
Following #768
For folks using slsa-verifier as a library, it could be useful to export the mocks we already have for the TUF client newMockSigstoreTUFClient, and it's implementation for GetTarget. We may also include some sample data for the mock.
slsa-verifier/verifiers/internal/gha/npm_sigstore_tuf_test.go
Lines 88 to 106 in 97ea5f8
| // mockSigstoreTUFClient a mock implementation of sigstoreTUFClient. | |
| type mockSigstoreTUFClient struct { | |
| fileContentMap map[string]string | |
| } | |
| // newMockSigstoreTUFClient returns an instance of the mock client, | |
| // with fileContentMap as input and outputs of the GetTarget() method. | |
| func newMockSigstoreTUFClient() *mockSigstoreTUFClient { | |
| return &mockSigstoreTUFClient{fileContentMap: mockFileContentMap} | |
| } | |
| // GetTarget mock implementation of GetTarget for the mockSigstoreTUFClient. | |
| func (c mockSigstoreTUFClient) GetTarget(targetPath string) ([]byte, error) { | |
| content, exists := c.fileContentMap[targetPath] | |
| if !exists { | |
| return nil, fmt.Errorf("content not definied in this mock, key: %s", targetPath) | |
| } | |
| return []byte(content), nil | |
| } |
Metadata
Metadata
Assignees
Labels
No labels