MCPcopy
hub / github.com/kopia/kopia / mustPutDummySessionBlob

Function mustPutDummySessionBlob

repo/maintenance/pack_gc_test.go:173–201  ·  view source on GitHub ↗
(t *testing.T, st blob.Storage, sessionIDSuffix blob.ID, si *content.SessionInfo)

Source from the content-addressed store, hash-verified

171}
172
173func mustPutDummySessionBlob(t *testing.T, st blob.Storage, sessionIDSuffix blob.ID, si *content.SessionInfo) blob.ID {
174 t.Helper()
175
176 j, err := json.Marshal(si)
177 require.NoError(t, err)
178
179 h := hmac.New(sha256.New, testHMACSecret)
180 h.Write(j)
181
182 iv := h.Sum(nil)[16:32]
183
184 blobID := blob.ID(fmt.Sprintf("s%x-%v", iv, sessionIDSuffix))
185
186 e, err := encryption.CreateEncryptor(&format.ContentFormat{
187 Encryption: encryption.DefaultAlgorithm,
188 MasterKey: testMasterKey,
189 HMACSecret: testHMACSecret,
190 })
191
192 require.NoError(t, err)
193
194 var enc gather.WriteBuffer
195 defer enc.Close()
196
197 require.NoError(t, e.Encrypt(gather.FromSlice(j), iv, &enc))
198 require.NoError(t, st.PutBlob(testlogging.Context(t), blobID, enc.Bytes(), blob.PutOptions{}))
199
200 return blobID
201}

Callers 1

Calls 10

CloseMethod · 0.95
BytesMethod · 0.95
IDTypeAlias · 0.92
CreateEncryptorFunction · 0.92
FromSliceFunction · 0.92
ContextFunction · 0.92
HelperMethod · 0.80
EncryptMethod · 0.65
PutBlobMethod · 0.65
WriteMethod · 0.45

Tested by

no test coverage detected