Skip to content

feat: expose SigstoreTUFClient mocks #773

@ramonpetgrave64

Description

@ramonpetgrave64

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.

// 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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions