示例#1
0
func TestAuthorityWithZk(t *testing.T) {
	coor := c.NewCenterAgent("192.168.13.157:50001", "192.168.13.157:60000")

	if nil == coor {
		t.Errorf("Failed to init coordinator with ttmv_uuid_zk:2181 and ttmv_uuid_redis:6379")
	}

	err := a.InitAuthority(coor)
	if err != nil {
		t.Errorf("Failed to get data from %s or %s", global.VERIFY_INFO_PATH, global.PERMISSION_INFO_PATH)
	}

	if !a.Verify("CID64", "123456") {
		t.Errorf("Failed to verify \"bizCode\" ")
		for key, value := range global.LegalUser {
			t.Errorf(key + ":" + value)
		}
	}

	if !a.Permission("0101", "CID64") {
		t.Errorf("Failed to give \"bizCode\" permission \"0101\" ")
		for key, value := range global.Permission {
			t.Errorf(key + ":" + value)
		}
	}
}
示例#2
0
文件: ids.go 项目: zbs4ms/ids
func InitProgram() {
	global.CoordinateCenter = coordinate.NewCenterPoolAgent(global.Get("center", "zookeeperAddr"), global.Get("center", "redisAddr"))
	if nil == global.CoordinateCenter {
		fmt.Println("Can not access to coordintor")
		os.Exit(1)
	}
	global.ServeAddr = global.Get("uuidCluster", "serveAddr")

	machineCode := global.Get("uuidCluster", "machineCode")
	global.MachineCode = machineCode

	global.QueCounter = count.NewQueCounter(1, 8191, 1)

	services.InitAuthority(global.CoordinateCenter)
}