MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / TestIsPermitted

Function TestIsPermitted

route/acl_test.go:36–68  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

34const PubKeyStorePath = "./acl.keystore"
35
36func TestIsPermitted(t *testing.T) {
37 log.SetLevel(log.DebugLevel)
38 utils.RemoveAll(PubKeyStorePath + "*")
39 defer utils.RemoveAll(PubKeyStorePath + "*")
40
41 _, testFile, _, _ := runtime.Caller(0)
42 confFile := filepath.Join(filepath.Dir(testFile), "../test/node_0/config.yaml")
43
44 conf.GConf, _ = conf.LoadConfig(confFile)
45 log.Debugf("GConf: %#v", conf.GConf)
46 // reset the once
47 Once.Reset()
48 InitKMS(PubKeyStorePath)
49
50 Convey("test IsPermitted", t, func() {
51 nodeID := proto.NodeID("0000")
52 testEnv := &proto.Envelope{NodeID: nodeID.ToRawNodeID()}
53 testAnonymous := &proto.Envelope{NodeID: kms.AnonymousRawNodeID}
54 So(IsPermitted(&proto.Envelope{NodeID: &conf.GConf.BP.RawNodeID}, DHTGSetNode), ShouldBeTrue)
55 So(IsPermitted(testEnv, DHTGSetNode), ShouldBeFalse)
56 So(IsPermitted(testEnv, DHTFindNode), ShouldBeTrue)
57 So(IsPermitted(testEnv, RemoteFunc(9999)), ShouldBeFalse)
58 So(IsPermitted(testAnonymous, DHTFindNode), ShouldBeFalse)
59 })
60
61 Convey("string RemoteFunc", t, func() {
62 for i := DHTPing; i < MaxRPCOffset; i++ {
63 So(fmt.Sprintf("%s", RemoteFunc(i)), ShouldContainSubstring, ".")
64 }
65 So(fmt.Sprintf("%s", RemoteFunc(9999)), ShouldContainSubstring, "Unknown")
66 })
67
68}

Callers

nothing calls this directly

Calls 10

SetLevelFunction · 0.92
RemoveAllFunction · 0.92
LoadConfigFunction · 0.92
DebugfFunction · 0.92
NodeIDTypeAlias · 0.92
InitKMSFunction · 0.85
IsPermittedFunction · 0.85
RemoteFuncTypeAlias · 0.85
ToRawNodeIDMethod · 0.80
ResetMethod · 0.65

Tested by

no test coverage detected