@@ -22,10 +22,8 @@ import (
2222 "io"
2323 "testing"
2424
25- casAPI "github.com/chainloop-dev/chainloop/app/artifact-cas/api/cas/v1"
2625 "github.com/chainloop-dev/chainloop/app/controlplane/internal/biz"
2726 "github.com/chainloop-dev/chainloop/app/controlplane/internal/biz/mocks"
28- blobmock "github.com/chainloop-dev/chainloop/internal/blobmanager/mocks"
2927 "github.com/google/uuid"
3028 "github.com/secure-systems-lab/go-securesystemslib/dsse"
3129 "github.com/stretchr/testify/assert"
@@ -39,52 +37,18 @@ var envelope = &dsse.Envelope{}
3937
4038const expectedDigest = "f845058d865c3d4d491c9019f6afe9c543ad2cd11b31620cc512e341fb03d3d8"
4139
42- // Deprecated method
43- func (s * attestationTestSuite ) TestUploadToCASFallbackOCI () {
44- ctx := context .Background ()
45- s .uploader .On ("Upload" , ctx , mock .Anything , & casAPI.CASResource {
46- FileName : fmt .Sprintf ("attestation-%s.json" , runID ), Digest : expectedDigest ,
47- }).Return (nil )
48-
49- s .casClient .On ("Configured" ).Return (false )
50-
51- gotDigest , err := s .uc .UploadToCAS (ctx , envelope , "my-secret" , runID )
52- assert .NoError (s .T (), err )
53- assert .Equal (s .T (), expectedDigest , gotDigest )
54- }
55-
5640func (s * attestationTestSuite ) TestUploadToCAS () {
5741 ctx := context .Background ()
5842 s .casClient .On (
5943 "Upload" , ctx , "my-secret" , mock .Anything ,
6044 fmt .Sprintf ("attestation-%s.json" , runID ), expectedDigest ,
6145 ).Return (nil )
6246
63- s .casClient .On ("Configured" ).Return (true )
64-
6547 gotDigest , err := s .uc .UploadToCAS (ctx , envelope , "my-secret" , runID )
6648 assert .NoError (s .T (), err )
6749 assert .Equal (s .T (), expectedDigest , gotDigest )
6850}
6951
70- func (s * attestationTestSuite ) TestFetchFromStoreFallbackOCI () {
71- want := & biz.Attestation {Envelope : & dsse.Envelope {}}
72-
73- ctx := context .Background ()
74- s .downloader .On ("Download" , ctx , mock .Anything , expectedDigest ).Return (nil ).Run (
75- func (args mock.Arguments ) {
76- buf := args .Get (1 ).(io.Writer )
77- err := json .NewEncoder (buf ).Encode (want )
78- require .NoError (s .T (), err )
79- })
80-
81- s .casClient .On ("Configured" ).Return (false )
82-
83- got , err := s .uc .FetchFromStore (ctx , "my-secret" , expectedDigest )
84- assert .NoError (s .T (), err )
85- assert .Equal (s .T (), want , got )
86- }
87-
8852func (s * attestationTestSuite ) TestFetchFromStore () {
8953 want := & biz.Attestation {Envelope : & dsse.Envelope {}}
9054
@@ -96,8 +60,6 @@ func (s *attestationTestSuite) TestFetchFromStore() {
9660 require .NoError (s .T (), err )
9761 })
9862
99- s .casClient .On ("Configured" ).Return (true )
100-
10163 got , err := s .uc .FetchFromStore (ctx , "my-secret" , expectedDigest )
10264 assert .NoError (s .T (), err )
10365 assert .Equal (s .T (), want , got )
@@ -108,22 +70,13 @@ func TestAttestation(t *testing.T) {
10870}
10971
11072func (s * attestationTestSuite ) SetupTest () {
111- backendProvider := blobmock .NewProvider (s .T ())
112- ociBackend := blobmock .NewUploaderDownloader (s .T ())
113- backendProvider .On ("FromCredentials" , mock .Anything , "my-secret" ).Maybe ().Return (ociBackend , nil )
114-
11573 s .casClient = mocks .NewCASClient (s .T ())
116- s .uc = biz .NewAttestationUseCase (s .casClient , backendProvider , nil )
117- s .uploader = (* blobmock .Uploader )(ociBackend )
118- s .downloader = (* blobmock .Downloader )(ociBackend )
74+ s .uc = biz .NewAttestationUseCase (s .casClient , nil )
11975}
12076
12177// Utility struct to hold the test suite
12278type attestationTestSuite struct {
12379 suite.Suite
124- uc * biz.AttestationUseCase
125- // Deprecated: attestation should use the casclient instead of the blobmanager
126- uploader * blobmock.Uploader
127- downloader * blobmock.Downloader
128- casClient * mocks.CASClient
80+ uc * biz.AttestationUseCase
81+ casClient * mocks.CASClient
12982}
0 commit comments