Skip to content

Commit 62f0dd5

Browse files
authored
refactor: fix auto-fixable staticcheck findings (#2834)
### Proposed Changes Fixes `staticcheck` findings that are fixable with the `--fix` flag. ### Checklist - [ ] I have added or updated unit tests - [ ] I have added or updated integration tests (if appropriate) - [ ] I have added or updated documentation ### Testing Instructions n/a
1 parent f8ea4ec commit 62f0dd5

32 files changed

+187
-187
lines changed

examples/cmd/attributes.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ func attruuid(ctx context.Context, s *sdk.SDK, nsu, fqn string) (string, error)
165165
return "", errors.Join(err, ErrInvalidArgument)
166166
}
167167
for _, a := range resp.GetAttributes() {
168-
if strings.ToLower(a.GetFqn()) == strings.ToLower(fqn) {
168+
if strings.EqualFold(a.GetFqn(), fqn) {
169169
return a.GetId(), nil
170170
}
171171
}
@@ -179,7 +179,7 @@ func avuuid(ctx context.Context, s *sdk.SDK, auuid, vs string) (string, error) {
179179
return "", errors.Join(err, ErrInvalidArgument)
180180
}
181181
for _, v := range resp.GetAttribute().GetValues() {
182-
if strings.ToLower(v.GetValue()) == strings.ToLower(vs) {
182+
if strings.EqualFold(v.GetValue(), vs) {
183183
return v.GetId(), nil
184184
}
185185
}

examples/cmd/kas.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func upsertKasRegistration(ctx context.Context, s *sdk.SDK, uri string, pk *poli
103103
return "", err
104104
}
105105
for _, ki := range r.GetKeyAccessServers() {
106-
if strings.ToLower(uri) == strings.ToLower(ki.GetUri()) {
106+
if strings.EqualFold(uri, ki.GetUri()) {
107107
oldpk := ki.GetPublicKey()
108108
recreate := false
109109
switch {
@@ -225,7 +225,7 @@ func removeKas(cmd *cobra.Command) error {
225225
}
226226
deletedSomething := false
227227
for _, ki := range r.GetKeyAccessServers() {
228-
if strings.ToLower(kas) == strings.ToLower(ki.GetUri()) {
228+
if strings.EqualFold(kas, ki.GetUri()) {
229229
_, err := s.KeyAccessServerRegistry.DeleteKeyAccessServer(cmd.Context(), &kasregistry.DeleteKeyAccessServerRequest{Id: ki.GetId()})
230230
if err != nil {
231231
slog.Error("failed to DeleteKeyAccessServer", slog.Any("error", err))

lib/fixtures/keycloak.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -454,13 +454,13 @@ func SetupCustomKeycloak(ctx context.Context, kcParams KeycloakConnectParams, ke
454454
if customUser.Copies < 1 {
455455
continue
456456
}
457-
baseUserName := *customUser.User.Username
458-
baseEmail := *customUser.User.Email
457+
baseUserName := *customUser.Username
458+
baseEmail := *customUser.Email
459459
numDigits := int(math.Log10(float64(customUser.Copies-1))) + 1
460460
padFormat := fmt.Sprintf("%%s-%%%dd", numDigits)
461461
for i := 0; i < customUser.Copies; i++ {
462-
customUser.User.Username = gocloak.StringP(fmt.Sprintf(padFormat, baseUserName, i))
463-
customUser.User.Email = gocloak.StringP(fmt.Sprintf("%d-%s", i, baseEmail))
462+
customUser.Username = gocloak.StringP(fmt.Sprintf(padFormat, baseUserName, i))
463+
customUser.Email = gocloak.StringP(fmt.Sprintf("%d-%s", i, baseEmail))
464464
_, err = createUser(ctx, client, token, &kcConnectParams, customUser.User)
465465
if err != nil {
466466
return err
@@ -899,7 +899,7 @@ func createTokenExchange(ctx context.Context, connectParams *KeycloakConnectPara
899899
Type: &policyType,
900900
}
901901
policyClients := []string{startClientID}
902-
realmMgmtExchangePolicyRepresentation.ClientPolicyRepresentation.Clients = &policyClients
902+
realmMgmtExchangePolicyRepresentation.Clients = &policyClients
903903

904904
realmMgmtPolicy, err := client.CreatePolicy(ctx, token.AccessToken, connectParams.Realm,
905905
*realmManagementClientID, realmMgmtExchangePolicyRepresentation)

sdk/experimental/tdf/example_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func ExampleWriter() {
5050
return
5151
}
5252

53-
fmt.Printf("TDF finalized with %d key access object(s).\n", len(finalizeResult.Manifest.EncryptionInformation.KeyAccessObjs))
53+
fmt.Printf("TDF finalized with %d key access object(s).\n", len(finalizeResult.Manifest.KeyAccessObjs))
5454
// Output:
5555
// TDF writer created and 2 segments written.
5656
// TDF finalized with 1 key access object(s).
@@ -115,7 +115,7 @@ func ExampleWriter_withAttributes() {
115115
log.Println(err)
116116
}
117117

118-
fmt.Printf("TDF finalized with %d key access object(s) for %d attribute(s).\n", len(finalizeResult.Manifest.EncryptionInformation.KeyAccessObjs), len(attributes))
118+
fmt.Printf("TDF finalized with %d key access object(s) for %d attribute(s).\n", len(finalizeResult.Manifest.KeyAccessObjs), len(attributes))
119119
// Output:
120120
// TDF with 2 attributes configured.
121121
// TDF finalized with 1 key access object(s) for 2 attribute(s).
@@ -226,7 +226,7 @@ func ExampleWriter_outOfOrder() {
226226
log.Println(err)
227227
}
228228

229-
fmt.Printf("Finalized TDF with %d segment(s).\n", len(finalizeResult.Manifest.EncryptionInformation.IntegrityInformation.Segments))
229+
fmt.Printf("Finalized TDF with %d segment(s).\n", len(finalizeResult.Manifest.Segments))
230230
// Output:
231231
// Wrote segment 2
232232
// Wrote segment 0
@@ -277,7 +277,7 @@ func ExampleWriter_largeFile() {
277277
log.Println(err)
278278
}
279279

280-
fmt.Printf("Finalized large file with %d segment(s).\n", len(finalizeResult.Manifest.EncryptionInformation.IntegrityInformation.Segments))
280+
fmt.Printf("Finalized large file with %d segment(s).\n", len(finalizeResult.Manifest.Segments))
281281
// Output:
282282
// Processed segment 0: 1048576 bytes
283283
// Processed segment 1: 1048576 bytes

sdk/experimental/tdf/writer.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ func (w *Writer) Finalize(ctx context.Context, opts ...Option[*WriterFinalizeCon
384384
return &FinalizeResult{
385385
Data: finalBytes,
386386
Manifest: manifest,
387-
TotalSegments: len(manifest.EncryptionInformation.IntegrityInformation.Segments),
387+
TotalSegments: len(manifest.Segments),
388388
TotalSize: totalPlaintextSize,
389389
EncryptedSize: totalEncryptedSize,
390390
}, nil
@@ -505,19 +505,19 @@ func (w *Writer) getManifest(ctx context.Context, cfg *WriterFinalizeConfig) (*M
505505
// Copy segments to manifest in finalize order (pack densely)
506506
for i, idx := range order {
507507
if segment, exists := w.segments[idx]; exists {
508-
encryptInfo.IntegrityInformation.Segments[i] = segment
508+
encryptInfo.Segments[i] = segment
509509
}
510510
}
511511

512512
// Set default segment sizes for reader compatibility
513513
// Use the first segment as the default (streaming TDFs have variable segment sizes)
514514
if firstSegment, exists := w.segments[0]; exists {
515-
encryptInfo.IntegrityInformation.DefaultSegmentSize = firstSegment.Size
516-
encryptInfo.IntegrityInformation.DefaultEncryptedSegSize = firstSegment.EncryptedSize
515+
encryptInfo.DefaultSegmentSize = firstSegment.Size
516+
encryptInfo.DefaultEncryptedSegSize = firstSegment.EncryptedSize
517517
}
518518

519519
// Set segment hash algorithm
520-
encryptInfo.IntegrityInformation.SegmentHashAlgorithm = w.segmentIntegrityAlgorithm.String()
520+
encryptInfo.SegmentHashAlgorithm = w.segmentIntegrityAlgorithm.String()
521521

522522
var aggregateHash bytes.Buffer
523523
// Calculate totals and iterate through segments in finalize order
@@ -578,11 +578,11 @@ func cloneManifest(in *Manifest) *Manifest {
578578
out := *in // copy by value
579579

580580
// Copy slices to new backing arrays
581-
if in.EncryptionInformation.KeyAccessObjs != nil {
582-
out.EncryptionInformation.KeyAccessObjs = append([]KeyAccess(nil), in.EncryptionInformation.KeyAccessObjs...)
581+
if in.KeyAccessObjs != nil {
582+
out.KeyAccessObjs = append([]KeyAccess(nil), in.KeyAccessObjs...)
583583
}
584-
if in.EncryptionInformation.Segments != nil {
585-
out.EncryptionInformation.Segments = append([]Segment(nil), in.EncryptionInformation.Segments...)
584+
if in.Segments != nil {
585+
out.Segments = append([]Segment(nil), in.Segments...)
586586
}
587587
if in.Assertions != nil {
588588
out.Assertions = append([]Assertion(nil), in.Assertions...)

sdk/experimental/tdf/writer_test.go

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ func testGetManifestIncludesInitialPolicy(t *testing.T) {
8787
m, err := writer.GetManifest(t.Context())
8888
require.NoError(t, err)
8989
require.NotNil(t, m)
90-
require.NotEmpty(t, m.EncryptionInformation.Policy, "expected provisional policy in stub manifest")
90+
require.NotEmpty(t, m.Policy, "expected provisional policy in stub manifest")
9191

92-
policyBytes, err := ocrypto.Base64Decode([]byte(m.EncryptionInformation.Policy))
92+
policyBytes, err := ocrypto.Base64Decode([]byte(m.Policy))
9393
require.NoError(t, err)
9494

9595
var pol Policy
@@ -105,8 +105,8 @@ func testGetManifestIncludesInitialPolicy(t *testing.T) {
105105
assert.True(t, found, "provisional policy should include initial attribute FQN")
106106

107107
// Pre-finalize manifest should include kaos based on initial attributes, and estimated root signature
108-
assert.Len(t, m.EncryptionInformation.KeyAccessObjs, 1)
109-
assert.NotEmpty(t, m.EncryptionInformation.RootSignature.Signature)
108+
assert.Len(t, m.KeyAccessObjs, 1)
109+
assert.NotEmpty(t, m.Signature)
110110
}
111111

112112
// Sparse indices end-to-end: write 0,1,2,5000,5001,5002 and verify manifest and totals.
@@ -138,7 +138,7 @@ func testSparseIndicesInOrder(t *testing.T) {
138138
require.NotNil(t, fin.Manifest)
139139
assert.Equal(t, len(order), fin.TotalSegments)
140140

141-
segs := fin.Manifest.EncryptionInformation.IntegrityInformation.Segments
141+
segs := fin.Manifest.Segments
142142
require.Len(t, segs, len(order))
143143
// Ensure manifest segments are densely packed and sizes match our inputs in order
144144
expectedPlain := 0
@@ -178,7 +178,7 @@ func testSparseIndicesOutOfOrder(t *testing.T) {
178178
require.NotNil(t, fin.Manifest)
179179
assert.Equal(t, len(finalOrder), fin.TotalSegments)
180180

181-
segs := fin.Manifest.EncryptionInformation.IntegrityInformation.Segments
181+
segs := fin.Manifest.Segments
182182
require.Len(t, segs, len(finalOrder))
183183
expectedPlain := 0
184184
for i, idx := range finalOrder {
@@ -211,9 +211,9 @@ func testInitialAttributesOnWriter(t *testing.T) {
211211
fin1, err := writer.Finalize(ctx)
212212
require.NoError(t, err)
213213
require.NotNil(t, fin1.Manifest)
214-
assert.GreaterOrEqual(t, len(fin1.Manifest.EncryptionInformation.KeyAccessObjs), 1)
214+
assert.GreaterOrEqual(t, len(fin1.Manifest.KeyAccessObjs), 1)
215215

216-
policyBytes, err := ocrypto.Base64Decode([]byte(fin1.Manifest.EncryptionInformation.Policy))
216+
policyBytes, err := ocrypto.Base64Decode([]byte(fin1.Manifest.Policy))
217217
require.NoError(t, err)
218218
var pol1 Policy
219219
require.NoError(t, json.Unmarshal(policyBytes, &pol1))
@@ -241,7 +241,7 @@ func testInitialAttributesOnWriter(t *testing.T) {
241241
fin2, err := writer2.Finalize(ctx, WithAttributeValues(overrideAttrs))
242242
require.NoError(t, err)
243243

244-
policyBytes2, err := ocrypto.Base64Decode([]byte(fin2.Manifest.EncryptionInformation.Policy))
244+
policyBytes2, err := ocrypto.Base64Decode([]byte(fin2.Manifest.Policy))
245245
require.NoError(t, err)
246246
var pol2 Policy
247247
require.NoError(t, json.Unmarshal(policyBytes2, &pol2))
@@ -298,22 +298,22 @@ func testBasicTDFCreationFlow(t *testing.T) {
298298

299299
// Verify manifest structure
300300
assert.Equal(t, TDFSpecVersion, finalizeResult.Manifest.TDFVersion, "TDF version should match expected")
301-
assert.Equal(t, "application/octet-stream", finalizeResult.Manifest.Payload.MimeType, "Default MIME type should be set")
302-
assert.True(t, finalizeResult.Manifest.Payload.IsEncrypted, "Payload should be marked as encrypted")
303-
assert.Equal(t, "zip", finalizeResult.Manifest.Payload.Protocol, "Protocol should be zip")
304-
assert.Equal(t, "reference", finalizeResult.Manifest.Payload.Type, "Type should be reference")
301+
assert.Equal(t, "application/octet-stream", finalizeResult.Manifest.MimeType, "Default MIME type should be set")
302+
assert.True(t, finalizeResult.Manifest.IsEncrypted, "Payload should be marked as encrypted")
303+
assert.Equal(t, "zip", finalizeResult.Manifest.Protocol, "Protocol should be zip")
304+
assert.Equal(t, "reference", finalizeResult.Manifest.Type, "Type should be reference")
305305

306306
// Verify key access objects
307-
assert.Len(t, finalizeResult.Manifest.EncryptionInformation.KeyAccessObjs, 1, "Should have one key access object for default KAS")
308-
keyAccess := finalizeResult.Manifest.EncryptionInformation.KeyAccessObjs[0]
307+
assert.Len(t, finalizeResult.Manifest.KeyAccessObjs, 1, "Should have one key access object for default KAS")
308+
keyAccess := finalizeResult.Manifest.KeyAccessObjs[0]
309309
assert.Equal(t, testKAS1, keyAccess.KasURL, "KAS URL should match")
310310
assert.Equal(t, "kas", keyAccess.Protocol, "Protocol should be kas")
311311
assert.NotEmpty(t, keyAccess.WrappedKey, "Wrapped key should not be empty")
312312

313313
// Verify encryption information
314-
assert.Equal(t, kGCMCipherAlgorithm, finalizeResult.Manifest.EncryptionInformation.Method.Algorithm, "Algorithm should be AES-256-GCM")
315-
assert.True(t, finalizeResult.Manifest.EncryptionInformation.Method.IsStreamable, "Should be marked as streamable")
316-
assert.NotEmpty(t, finalizeResult.Manifest.EncryptionInformation.Policy, "Policy should not be empty")
314+
assert.Equal(t, kGCMCipherAlgorithm, finalizeResult.Manifest.Method.Algorithm, "Algorithm should be AES-256-GCM")
315+
assert.True(t, finalizeResult.Manifest.Method.IsStreamable, "Should be marked as streamable")
316+
assert.NotEmpty(t, finalizeResult.Manifest.Policy, "Policy should not be empty")
317317
}
318318

319319
// testSingleSegmentWithAttributes tests TDF creation with attribute-based key splitting
@@ -343,10 +343,10 @@ func testSingleSegmentWithAttributes(t *testing.T) {
343343
validateManifestSchema(t, finalizeResult.Manifest)
344344

345345
// Verify key access objects were created for each attribute's KAS
346-
assert.GreaterOrEqual(t, len(finalizeResult.Manifest.EncryptionInformation.KeyAccessObjs), 1, "Should have at least one key access object")
346+
assert.GreaterOrEqual(t, len(finalizeResult.Manifest.KeyAccessObjs), 1, "Should have at least one key access object")
347347

348348
// Verify policy contains attributes
349-
policyBytes, err := ocrypto.Base64Decode([]byte(finalizeResult.Manifest.EncryptionInformation.Policy))
349+
policyBytes, err := ocrypto.Base64Decode([]byte(finalizeResult.Manifest.Policy))
350350
require.NoError(t, err)
351351
assert.NotEmpty(t, policyBytes, "Policy should not be empty")
352352

@@ -406,8 +406,8 @@ func testMultiSegmentFlow(t *testing.T) {
406406
validateManifestSchema(t, finalizeResult.Manifest)
407407

408408
// Verify root signature was calculated from all segments
409-
assert.NotEmpty(t, finalizeResult.Manifest.EncryptionInformation.RootSignature.Signature, "Root signature should be set")
410-
assert.Equal(t, "HS256", finalizeResult.Manifest.EncryptionInformation.RootSignature.Algorithm, "Root signature algorithm should be HS256")
409+
assert.NotEmpty(t, finalizeResult.Manifest.Signature, "Root signature should be set")
410+
assert.Equal(t, "HS256", finalizeResult.Manifest.Algorithm, "Root signature algorithm should be HS256")
411411
}
412412

413413
// testKeySplittingWithMultipleAttributes tests XOR key splitting with complex attribute scenarios
@@ -440,7 +440,7 @@ func testKeySplittingWithMultipleAttributes(t *testing.T) {
440440
validateManifestSchema(t, finalizeResult.Manifest)
441441

442442
// Verify multiple key access objects were created
443-
keyAccessObjs := finalizeResult.Manifest.EncryptionInformation.KeyAccessObjs
443+
keyAccessObjs := finalizeResult.Manifest.KeyAccessObjs
444444
assert.GreaterOrEqual(t, len(keyAccessObjs), 1, "Should have at least one key access object")
445445

446446
// Verify each key access object has proper structure
@@ -498,10 +498,10 @@ func testManifestGeneration(t *testing.T) {
498498
assert.Equal(t, TDFSpecVersion, finalizeResult.Manifest.TDFVersion, "TDF version should match")
499499

500500
// Verify payload information
501-
assert.Equal(t, customMimeType, finalizeResult.Manifest.Payload.MimeType, "MIME type should match custom value")
502-
assert.Equal(t, "zip", finalizeResult.Manifest.Payload.Protocol, "Protocol should be zip")
503-
assert.Equal(t, "reference", finalizeResult.Manifest.Payload.Type, "Type should be reference")
504-
assert.True(t, finalizeResult.Manifest.Payload.IsEncrypted, "Payload should be encrypted")
501+
assert.Equal(t, customMimeType, finalizeResult.Manifest.MimeType, "MIME type should match custom value")
502+
assert.Equal(t, "zip", finalizeResult.Manifest.Protocol, "Protocol should be zip")
503+
assert.Equal(t, "reference", finalizeResult.Manifest.Type, "Type should be reference")
504+
assert.True(t, finalizeResult.Manifest.IsEncrypted, "Payload should be encrypted")
505505

506506
// Verify encryption information
507507
encInfo := finalizeResult.Manifest.EncryptionInformation
@@ -511,8 +511,8 @@ func testManifestGeneration(t *testing.T) {
511511

512512
// Verify integrity information
513513
intInfo := encInfo.IntegrityInformation
514-
assert.Equal(t, "HS256", intInfo.RootSignature.Algorithm, "Root signature algorithm should be HS256")
515-
assert.NotEmpty(t, intInfo.RootSignature.Signature, "Root signature should not be empty")
514+
assert.Equal(t, "HS256", intInfo.Algorithm, "Root signature algorithm should be HS256")
515+
assert.NotEmpty(t, intInfo.Signature, "Root signature should not be empty")
516516

517517
// Verify key access objects
518518
assert.GreaterOrEqual(t, len(encInfo.KeyAccessObjs), 1, "Should have at least one key access object")
@@ -598,7 +598,7 @@ func testAssertionsAndMetadata(t *testing.T) {
598598
assert.NotEmpty(t, metadata["timestamp"], "Timestamp should be set")
599599

600600
// Verify encrypted metadata in key access object
601-
keyAccess := finalizeResult.Manifest.EncryptionInformation.KeyAccessObjs[0]
601+
keyAccess := finalizeResult.Manifest.KeyAccessObjs[0]
602602
assert.NotEmpty(t, keyAccess.EncryptedMetadata, "Encrypted metadata should be present")
603603
}
604604

@@ -711,10 +711,10 @@ func testXORReconstruction(t *testing.T) {
711711

712712
// The actual verification of XOR reconstruction is done internally by the splitter,
713713
// but we can verify the structure is correct and key access objects were generated
714-
assert.GreaterOrEqual(t, len(finalizeResult.Manifest.EncryptionInformation.KeyAccessObjs), 1, "Should have key access objects")
714+
assert.GreaterOrEqual(t, len(finalizeResult.Manifest.KeyAccessObjs), 1, "Should have key access objects")
715715

716716
// Verify that each key access object has the required fields
717-
for i, keyAccess := range finalizeResult.Manifest.EncryptionInformation.KeyAccessObjs {
717+
for i, keyAccess := range finalizeResult.Manifest.KeyAccessObjs {
718718
assert.NotEmpty(t, keyAccess.WrappedKey, "Key access %d should have wrapped key", i)
719719
assert.NotEmpty(t, keyAccess.KasURL, "Key access %d should have KAS URL", i)
720720
assert.NotEmpty(t, keyAccess.SplitID, "Key access %d should have split ID", i)
@@ -764,7 +764,7 @@ func testDifferentAttributeRules(t *testing.T) {
764764

765765
// Verify manifest was created successfully
766766
assert.NotNil(t, finalizeResult.Manifest, "Manifest should not be nil for %s", tc.name)
767-
assert.NotEmpty(t, finalizeResult.Manifest.EncryptionInformation.KeyAccessObjs, "Should have key access objects for %s", tc.name)
767+
assert.NotEmpty(t, finalizeResult.Manifest.KeyAccessObjs, "Should have key access objects for %s", tc.name)
768768
})
769769
}
770770
}
@@ -1010,11 +1010,11 @@ func testGetManifestBeforeAndAfterFinalize(t *testing.T) {
10101010
require.NoError(t, err)
10111011
require.NotNil(t, m0)
10121012
assert.Equal(t, TDFSpecVersion, m0.TDFVersion)
1013-
assert.Equal(t, tdfAsZip, m0.Payload.Protocol)
1014-
assert.Equal(t, tdfZipReference, m0.Payload.Type)
1015-
assert.True(t, m0.Payload.IsEncrypted)
1013+
assert.Equal(t, tdfAsZip, m0.Protocol)
1014+
assert.Equal(t, tdfZipReference, m0.Type)
1015+
assert.True(t, m0.IsEncrypted)
10161016
// No segments yet
1017-
assert.Empty(t, m0.EncryptionInformation.Segments)
1017+
assert.Empty(t, m0.Segments)
10181018

10191019
// Write a segment and check stub updates
10201020
data := []byte("abc123")
@@ -1025,10 +1025,10 @@ func testGetManifestBeforeAndAfterFinalize(t *testing.T) {
10251025
require.NoError(t, err)
10261026
require.NotNil(t, m1)
10271027
// Should reflect first segment defaults and sizes
1028-
assert.Len(t, m1.EncryptionInformation.Segments, 1)
1029-
assert.Equal(t, int64(len(data)), m1.EncryptionInformation.DefaultSegmentSize)
1030-
assert.Greater(t, m1.EncryptionInformation.DefaultEncryptedSegSize, int64(len(data)))
1031-
assert.Equal(t, writer.segmentIntegrityAlgorithm.String(), m1.EncryptionInformation.SegmentHashAlgorithm)
1028+
assert.Len(t, m1.Segments, 1)
1029+
assert.Equal(t, int64(len(data)), m1.DefaultSegmentSize)
1030+
assert.Greater(t, m1.DefaultEncryptedSegSize, int64(len(data)))
1031+
assert.Equal(t, writer.segmentIntegrityAlgorithm.String(), m1.SegmentHashAlgorithm)
10321032

10331033
// Finalize and GetManifest should return the final one (with key access, root signature)
10341034
attrs := []*policy.Value{createTestAttribute("https://example.com/attr/Test/value/Basic", testKAS1, "kid1")}
@@ -1039,8 +1039,8 @@ func testGetManifestBeforeAndAfterFinalize(t *testing.T) {
10391039
m2, err := writer.GetManifest(t.Context())
10401040
require.NoError(t, err)
10411041
// Expect at least one key access and a root signature after finalize
1042-
assert.Len(t, m2.EncryptionInformation.KeyAccessObjs, 1)
1043-
assert.NotEmpty(t, m2.EncryptionInformation.RootSignature.Signature)
1042+
assert.Len(t, m2.KeyAccessObjs, 1)
1043+
assert.NotEmpty(t, m2.Signature)
10441044

10451045
// Ensure GetManifest returns a clone, not the same pointer
10461046
assert.NotSame(t, fin.Manifest, m2)

sdk/fuzz_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ func FuzzLoadTDF(f *testing.F) {
200200
_, _ = rand.Read(r.payloadKey)
201201
gcm, err := ocrypto.NewAESGcm(r.payloadKey)
202202
require.NoError(t, err)
203-
for _, seg := range r.manifest.EncryptionInformation.IntegrityInformation.Segments {
203+
for _, seg := range r.manifest.Segments {
204204
r.payloadSize += seg.Size
205205
}
206206
r.unencryptedMetadata = []byte{}

0 commit comments

Comments
 (0)