@@ -22,10 +22,8 @@ import (
22
22
"io"
23
23
"testing"
24
24
25
- casAPI "github.com/chainloop-dev/chainloop/app/artifact-cas/api/cas/v1"
26
25
"github.com/chainloop-dev/chainloop/app/controlplane/internal/biz"
27
26
"github.com/chainloop-dev/chainloop/app/controlplane/internal/biz/mocks"
28
- blobmock "github.com/chainloop-dev/chainloop/internal/blobmanager/mocks"
29
27
"github.com/google/uuid"
30
28
"github.com/secure-systems-lab/go-securesystemslib/dsse"
31
29
"github.com/stretchr/testify/assert"
@@ -39,52 +37,18 @@ var envelope = &dsse.Envelope{}
39
37
40
38
const expectedDigest = "f845058d865c3d4d491c9019f6afe9c543ad2cd11b31620cc512e341fb03d3d8"
41
39
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
-
56
40
func (s * attestationTestSuite ) TestUploadToCAS () {
57
41
ctx := context .Background ()
58
42
s .casClient .On (
59
43
"Upload" , ctx , "my-secret" , mock .Anything ,
60
44
fmt .Sprintf ("attestation-%s.json" , runID ), expectedDigest ,
61
45
).Return (nil )
62
46
63
- s .casClient .On ("Configured" ).Return (true )
64
-
65
47
gotDigest , err := s .uc .UploadToCAS (ctx , envelope , "my-secret" , runID )
66
48
assert .NoError (s .T (), err )
67
49
assert .Equal (s .T (), expectedDigest , gotDigest )
68
50
}
69
51
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
-
88
52
func (s * attestationTestSuite ) TestFetchFromStore () {
89
53
want := & biz.Attestation {Envelope : & dsse.Envelope {}}
90
54
@@ -96,8 +60,6 @@ func (s *attestationTestSuite) TestFetchFromStore() {
96
60
require .NoError (s .T (), err )
97
61
})
98
62
99
- s .casClient .On ("Configured" ).Return (true )
100
-
101
63
got , err := s .uc .FetchFromStore (ctx , "my-secret" , expectedDigest )
102
64
assert .NoError (s .T (), err )
103
65
assert .Equal (s .T (), want , got )
@@ -108,22 +70,13 @@ func TestAttestation(t *testing.T) {
108
70
}
109
71
110
72
func (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
-
115
73
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 )
119
75
}
120
76
121
77
// Utility struct to hold the test suite
122
78
type attestationTestSuite struct {
123
79
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
129
82
}
0 commit comments