@@ -14,6 +14,7 @@ import (
1414 "sync"
1515 "time"
1616
17+ "github.com/aws/aws-sdk-go-v2/service/s3"
1718 "github.com/letsencrypt/borp"
1819
1920 corepb "github.com/letsencrypt/boulder/core/proto"
@@ -30,7 +31,13 @@ var ErrCheckpointNotReady = errors.New("not ready - no mirror signature")
3031var _ mtcapb.MTCAServer = & mtca {}
3132
3233// New creates a new MTCA service.
33- func New (issuer * issuance.Issuer , sequencingPeriod time.Duration , dbMap * borp.DbMap , logger blog.Logger ) (* mtca , error ) {
34+ func New (
35+ issuer * issuance.Issuer ,
36+ sequencingPeriod time.Duration ,
37+ dbMap * borp.DbMap ,
38+ s3c simpleS3 ,
39+ logger blog.Logger ,
40+ ) (* mtca , error ) {
3441 mtcaID , err := getMTCAID (issuer .Cert .Certificate )
3542 if err != nil {
3643 return nil , err
@@ -50,6 +57,7 @@ func New(issuer *issuance.Issuer, sequencingPeriod time.Duration, dbMap *borp.Db
5057 sequencingPeriod : sequencingPeriod ,
5158
5259 db : initDB (dbMap ),
60+ s3c : s3c ,
5361 log : logger ,
5462 }, nil
5563}
@@ -67,11 +75,20 @@ type mtca struct {
6775 // TODO: decide whether we want to route this through the SA or an SA-like object,
6876 // or keep a direct DB connection from the MTCA.
6977 db * db.WrappedMap
78+ s3c simpleS3
7079 log blog.Logger
7180
7281 pool * pool
7382}
7483
84+ // simpleS3 matches the subset of the s3.Client interface which we use, to allow
85+ // simpler mocking in tests.
86+ type simpleS3 interface {
87+ PutObject (ctx context.Context , params * s3.PutObjectInput , optFns ... func (* s3.Options )) (* s3.PutObjectOutput , error )
88+ GetObject (ctx context.Context , params * s3.GetObjectInput , optFns ... func (* s3.Options )) (* s3.GetObjectOutput , error )
89+ Bucket () string
90+ }
91+
7592func getMTCAID (issuerCert * x509.Certificate ) (string , error ) {
7693 testingTrustAnchorIDOID := asn1.ObjectIdentifier {1 , 3 , 6 , 1 , 4 , 1 , 44363 , 47 , 1 }
7794 for _ , attribute := range issuerCert .Subject .Names {
0 commit comments