@@ -8165,7 +8165,6 @@ func TestProperty_broadcastBlobPayloads_MaxSizePayloadsWithinBlobLimit(t *testin
81658165 maxIDNamespaceSize := cresettings .Default .VaultIdentifierNamespaceSizeLimit .DefaultValue
81668166 maxSecretsPerReq := vaulttypes .MaxBatchSize
81678167 maxBlobPayloadBytes := cresettings .Default .VaultMaxBlobPayloadSizeLimit .DefaultValue
8168- numPayloads := 2 * maxRequestBatchSize
81698168
81708169 pubK , _ , err := box .GenerateKey (rand .Reader )
81718170 require .NoError (t , err )
@@ -8197,10 +8196,14 @@ func TestProperty_broadcastBlobPayloads_MaxSizePayloadsWithinBlobLimit(t *testin
81978196
81988197 buildMaxSecretRequests := func () []* vaultcommon.SecretRequest {
81998198 reqs := make ([]* vaultcommon.SecretRequest , maxSecretsPerReq )
8199+ encKeys := make ([]string , 10 )
8200+ for i := range encKeys {
8201+ encKeys [i ] = encKey
8202+ }
82008203 for i := range reqs {
82018204 reqs [i ] = & vaultcommon.SecretRequest {
82028205 Id : maxIdentifier (),
8203- EncryptionKeys : [] string { encKey } ,
8206+ EncryptionKeys : encKeys ,
82048207 }
82058208 }
82068209 return reqs
@@ -8218,78 +8221,66 @@ func TestProperty_broadcastBlobPayloads_MaxSizePayloadsWithinBlobLimit(t *testin
82188221 name string
82198222 payload proto.Message
82208223 }{
8221- {"GetSecretsRequest" , & vaultcommon.GetSecretsRequest {
8222- Requests : buildMaxSecretRequests (),
8223- OrgId : maxIDOwnerField ,
8224- WorkflowOwner : maxIDOwnerField ,
8225- }},
8226- {"CreateSecretsRequest" , & vaultcommon.CreateSecretsRequest {
8227- RequestId : "req" ,
8228- EncryptedSecrets : buildMaxEncryptedSecrets (),
8229- OrgId : maxIDOwnerField ,
8230- WorkflowOwner : maxIDOwnerField ,
8231- }},
8232- {"UpdateSecretsRequest" , & vaultcommon.UpdateSecretsRequest {
8233- RequestId : "req" ,
8234- EncryptedSecrets : buildMaxEncryptedSecrets (),
8235- OrgId : maxIDOwnerField ,
8236- WorkflowOwner : maxIDOwnerField ,
8237- }},
8238- {"DeleteSecretsRequest" , & vaultcommon.DeleteSecretsRequest {
8239- RequestId : "req" ,
8240- Ids : buildMaxIdentifiers (),
8241- OrgId : maxIDOwnerField ,
8242- WorkflowOwner : maxIDOwnerField ,
8243- }},
8244- {"ListSecretIdentifiersRequest" , & vaultcommon.ListSecretIdentifiersRequest {
8245- RequestId : "req" ,
8246- Owner : maxIDOwnerField ,
8247- Namespace : maxIDNamespaceField ,
8248- OrgId : maxIDOwnerField ,
8249- WorkflowOwner : maxIDOwnerField ,
8250- }},
8251- }
8252-
8253- runBroadcast := func (t * testing.T , payloads [][]byte , ids []string ) {
8254- t .Helper ()
8255- lggr := logger .TestLogger (t )
8256- r := & ReportingPlugin {
8257- lggr : lggr ,
8258- metrics : newTestMetrics (t ),
8259- marshalBlob : func (ocr3_1types.BlobHandle ) ([]byte , error ) {
8260- return []byte ("handle" ), nil
8224+ {
8225+ name : "GetSecretsRequest" ,
8226+ payload : & vaultcommon.GetSecretsRequest {
8227+ Requests : buildMaxSecretRequests (),
8228+ OrgId : maxIDOwnerField ,
8229+ WorkflowOwner : maxIDOwnerField ,
82618230 },
8262- }
8263- fetcher := & callbackBlobFetcher {fn : func ([]byte ) error { return nil }}
8264- result , err := r .broadcastBlobPayloads (t .Context (), fetcher , 1 , payloads , ids )
8265- require .NoError (t , err )
8266- assert .Len (t , result , numPayloads , "expected all %d payloads to broadcast successfully" , numPayloads )
8231+ },
8232+ {
8233+ name : "CreateSecretsRequest" ,
8234+ payload : & vaultcommon.CreateSecretsRequest {
8235+ RequestId : "req" ,
8236+ EncryptedSecrets : buildMaxEncryptedSecrets (),
8237+ OrgId : maxIDOwnerField ,
8238+ WorkflowOwner : maxIDOwnerField ,
8239+ }},
8240+ {
8241+ name : "UpdateSecretsRequest" ,
8242+ payload : & vaultcommon.UpdateSecretsRequest {
8243+ RequestId : "req" ,
8244+ EncryptedSecrets : buildMaxEncryptedSecrets (),
8245+ OrgId : maxIDOwnerField ,
8246+ WorkflowOwner : maxIDOwnerField ,
8247+ },
8248+ },
8249+ {
8250+ name : "DeleteSecretsRequest" ,
8251+ payload : & vaultcommon.DeleteSecretsRequest {
8252+ RequestId : "req" ,
8253+ Ids : buildMaxIdentifiers (),
8254+ OrgId : maxIDOwnerField ,
8255+ WorkflowOwner : maxIDOwnerField ,
8256+ },
8257+ },
8258+ {
8259+ name : "ListSecretIdentifiersRequest" ,
8260+ payload : & vaultcommon.ListSecretIdentifiersRequest {
8261+ RequestId : "req" ,
8262+ Owner : maxIDOwnerField ,
8263+ Namespace : maxIDNamespaceField ,
8264+ OrgId : maxIDOwnerField ,
8265+ WorkflowOwner : maxIDOwnerField ,
8266+ },
8267+ },
82678268 }
82688269
82698270 for _ , rt := range requestTypes {
82708271 t .Run (rt .name , func (t * testing.T ) {
82718272 anyMsg , err := anypb .New (rt .payload )
82728273 require .NoError (t , err )
82738274
8274- payloads := make ([][]byte , numPayloads )
8275- ids := make ([]string , numPayloads )
8276- for i := range numPayloads {
8277- item := & vaultcommon.StoredPendingQueueItem {
8278- Id : fmt .Sprintf ("req-%d" , i ),
8279- Item : anyMsg ,
8280- }
8281- itemBytes := protoMarshal (t , item )
8282-
8283- // Property 1: each max-size payload must fit within the blob size limit.
8284- assert .LessOrEqualf (t , len (itemBytes ), maxBlobPayloadBytes ,
8285- "marshaled %s StoredPendingQueueItem (%d bytes) exceeds VaultMaxBlobPayloadSizeLimit (%d bytes)" ,
8286- rt .name , len (itemBytes ), maxBlobPayloadBytes )
8287-
8288- payloads [i ] = itemBytes
8289- ids [i ] = item .Id
8275+ item := & vaultcommon.StoredPendingQueueItem {
8276+ Id : "req" ,
8277+ Item : anyMsg ,
82908278 }
8279+ itemBytes := protoMarshal (t , item )
82918280
8292- runBroadcast (t , payloads , ids )
8281+ assert .LessOrEqualf (t , len (itemBytes ), maxBlobPayloadBytes ,
8282+ "marshaled %s StoredPendingQueueItem (%d bytes) exceeds VaultMaxBlobPayloadSizeLimit (%d bytes)" ,
8283+ rt .name , len (itemBytes ), maxBlobPayloadBytes )
82938284 })
82948285 }
82958286}
0 commit comments