MCPcopy
hub / github.com/perkeep/perkeep / TestNewFromConfig

Function TestNewFromConfig

pkg/blobserver/encrypt/encrypt_test.go:227–264  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

225}
226
227func TestNewFromConfig(t *testing.T) {
228 ld := test.NewLoader()
229
230 // Using key file
231 tmpKeyFile, _ := os.CreateTemp(t.TempDir(), "camlitest")
232 defer os.Remove((tmpKeyFile.Name()))
233 defer tmpKeyFile.Close()
234 tmpKeyFile.WriteString(testIdentity.String())
235
236 if _, err := newFromConfig(ld, jsonconfig.Obj{
237 "I_AGREE": "that encryption support hasn't been peer-reviewed, isn't finished, and its format might change.",
238 "keyFile": tmpKeyFile.Name(),
239 "blobs": "/good-blobs/",
240 "meta": "/good-meta/",
241 "metaIndex": map[string]interface{}{
242 "type": "memory",
243 },
244 }); err != nil {
245 t.Fatal(err)
246 }
247
248 // Using public key file
249 if runtime.GOOS != "windows" {
250 os.Chmod(tmpKeyFile.Name(), 0644)
251 if _, err := newFromConfig(ld, jsonconfig.Obj{
252 "I_AGREE": "that encryption support hasn't been peer-reviewed, isn't finished, and its format might change.",
253 "keyFile": tmpKeyFile.Name(),
254 "blobs": "/good-blobs/",
255 "meta": "/good-meta/",
256 "metaIndex": map[string]interface{}{
257 "type": "memory",
258 },
259 }); err == nil || !strings.Contains(err.Error(), "Key file permissions are too permissive") {
260 t.Fatal(err)
261 }
262 }
263
264}

Callers

nothing calls this directly

Calls 9

NewLoaderFunction · 0.92
FatalMethod · 0.80
ContainsMethod · 0.80
newFromConfigFunction · 0.70
RemoveMethod · 0.65
NameMethod · 0.65
CloseMethod · 0.65
StringMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected