(t *testing.T)
| 34 | const PubKeyStorePath = "./acl.keystore" |
| 35 | |
| 36 | func 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 | } |
nothing calls this directly
no test coverage detected