MCPcopy Create free account
hub / github.com/blobcache/blobcache / TestOwn

Function TestOwn

src/blobcachecmd/cmd_test.go:19–48  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

17)
18
19func TestOwn(t *testing.T) {
20 d, apiUrl := blobcached.BGTestDaemon(t)
21 env := map[string]string{
22 bcclient.EnvBlobcacheAPI: apiUrl,
23 }
24
25 // Get the node's peer ID to verify the output
26 nodePeerID, err := d.GetPeerID()
27 require.NoError(t, err)
28
29 // Use a made-up peer ID for the owner
30 ownerPeerID := nodePeerID // reuse node's own ID as the owner for simplicity
31
32 // Run the own command
33 out := runCmdGetOut(t, env, []string{"--state", d.StateDir.Name(), "own", ownerPeerID.String()})
34 outStr := string(out)
35 t.Log(outStr)
36
37 // Verify the output contains expected strings
38 require.Contains(t, outStr, "OWN")
39 require.Contains(t, outStr, "full access")
40 require.Contains(t, outStr, "ns create")
41 require.Contains(t, outStr, nodePeerID.String()[:8])
42
43 // Verify the peer was added to the admin group
44 pol, err := d.GetPolicy()
45 require.NoError(t, err)
46 rights := pol.OpenFiat(ownerPeerID, blobcache.OID{})
47 require.NotZero(t, rights, "owner should have rights on the root volume")
48}
49
50func TestGLFS(t *testing.T) {
51 stateDir := t.TempDir()

Callers

nothing calls this directly

Calls 6

BGTestDaemonFunction · 0.92
runCmdGetOutFunction · 0.85
GetPeerIDMethod · 0.80
GetPolicyMethod · 0.80
StringMethod · 0.65
OpenFiatMethod · 0.65

Tested by

no test coverage detected