Esempio n. 1
0
    def bindPico(UserID, group, IsTrader, accountType):
        # 连接account测试服务器
        consulAccountHost = FMCommon.consul_operater(
            host=userData['consulHost'],
            port=userData['consulPort'],
            server='followme.srv.account',
            key='ServiceAddress')
        consulAccountPort = FMCommon.consul_operater(
            host=userData['consulHost'],
            port=userData['consulPort'],
            server='followme.srv.account',
            key='ServicePort')
        accountChannel = grpc.insecure_channel(consulAccountHost + ':' +
                                               str(consulAccountPort))
        accountStub = account_pb2_grpc.AccountSrvStub(accountChannel)

        # 连接dealer测试服务器  http://10.1.0.4:8500
        consulDealerHost = FMCommon.consul_operater(
            host=userData['consulHost'],
            port=userData['consulPort'],
            server='followme.srv.copytrade.dealer.pico',
            key='ServiceAddress')
        consulDealerPort = FMCommon.consul_operater(
            host=userData['consulHost'],
            port=userData['consulPort'],
            server='followme.srv.copytrade.dealer.pico',
            key='ServicePort')
        dealerChannel = grpc.insecure_channel(consulDealerHost + ':' +
                                              str(consulDealerPort))
        dealerStub = mt4dealer_pb2_grpc.MT4DealerSrvStub(dealerChannel)

        bindPico = dealerStub.CreateAccount(
            mt4dealer_pb2.Account(Name='MAM_ACCOUNT_' + str(UserID),
                                  Password='******',
                                  BrokerID=1,
                                  Group=group,
                                  City='sz'))
        login = bindPico.Login

        # 将注册的用户提取到t_useraccount表
        accountStub.SaveUserAccount(
            account_pb2.SaveUserAccountRequest(
                User=account_pb2.User(Id=UserID),
                BrokerID=1,
                MT4Account=str(login),
                IsTrader=IsTrader,
                AccountCreateType=0,
                IsBind=2,
                AccountType=accountType))

        # pico入金
        dealerStub.DepositWithdraw(
            mt4dealer_pb2.DepositWithdrawMessage(
                Login=login, Price=10000000, Comment='Deposit With script.'))
        return bindPico
 def test_registerAndLogin(self):
     #注册账号
     #开户
     #验证是否升级为2星
     self.mobile = '18766666668'
     self.password = '******'
     self.invite = '220432'  # vcode 信息。
     # 注册一个测试账号
     # 获取图形验证码
     captchaUrl = webApiData['hostName'] + userDataAuthUrl['getCaptcha_url']
     self.user_token = Account.getTokenForCaptcha(captchaUrl)
     self.header = {
         'content-type': 'application/json',
         'Authorization': 'Bearer ' + str(self.user_token)
     }
     # 读取图形验证码
     self.ccap = Account.getCaptchaForRedis(self.user_token)
     # 根据图形验证码获取短信验证码
     smsUrl = webApiData['hostName'] + userDataAuthUrl[
         'getSMSScode_url'] + self.mobile + '&captcha=' + self.ccap
     # print(smsUrl)
     '''获取短信验证码成功'''
     self.smsCode = Account.getSMSCodeForRedis(smsUrl,
                                               headers=self.header,
                                               userToken=str(
                                                   self.user_token),
                                               registerAccount=self.mobile)
     '''注册场景验证'''
     # 注册
     url = webApiData['hostName'] + userDataAuthUrl['register_url']
     res = Auth.register(url,
                         headers=self.header,
                         account=self.mobile,
                         password=self.password,
                         platform=webApiData['platform'],
                         captcha=str(self.ccap),
                         smscode=self.smsCode,
                         invite=self.invite,
                         oauth2=webApiData['oauth2'])
     # 请求成功,返回200 ok
     '''注册成功'''
     self.assertEqual(res.status_code, webApiData['status_code_200'])
     self.userID = json.loads(res.text)["data"]["id"]
     print("userID ", self.userID)
     print("mobile ", self.mobile)
     # 设置用户昵称
     setNickName = self.accountStub.SetNickName(
         account_pb2.User(Id=self.userID, NickName=str(self.userID)))
     # 检查设置成功后,返回值为:0
     self.assertEqual(setNickName.Success, 0)
Esempio n. 3
0
    def test_test1(self):
        # self.userID = 169204
        # self.isTrader = False      #交易员:1, 跟随者:0
        # self.accountType = 3

        for userInfo in load_dict["items"]:
            print("isTrader:", userInfo["isTrader"])
            if userInfo["accountType"] == 3:
                self.group = 'a_balance'
            elif userInfo["accountType"] == 1:
                self.group = 'ct_pico'

            bindPico = self.dealerStub.CreateAccount(
                mt4dealer_pb2.Account(Name='MAM_ACCOUNT_' +
                                      str(userInfo["UserID"]),
                                      Password='******',
                                      BrokerID=1,
                                      Group=self.group,
                                      City='sz'))
            print(bindPico)
            self.login = bindPico.Login
            self.assertEqual(bindPico.Name,
                             "MAM_ACCOUNT_" + str(userInfo["UserID"]))
            # 断言绑定的经济商为:1. 晋峰
            self.assertEqual(bindPico.BrokerID, 1)

            # 将注册的用户提取到t_useraccount表
            # accounttype:Demo = 0,Real = 1,Sam  = 2,Mam  = 3
            saveUserAccount = self.accountStub.SaveUserAccount(
                account_pb2.SaveUserAccountRequest(
                    User=account_pb2.User(Id=userInfo["UserID"]),
                    BrokerID=1,
                    MT4Account=str(self.login),
                    IsTrader=userInfo["isTrader"],
                    AccountCreateType=0,
                    IsBind=2,
                    AccountType=userInfo["accountType"]))
            self.assertEqual(saveUserAccount.Success, 0)

            # pico入金
            self.dealerStub.DepositWithdraw(
                mt4dealer_pb2.DepositWithdrawMessage(
                    Login=self.login,
                    Price=userInfo["price"],
                    Comment='Deposit With script.'))
Esempio n. 4
0
    def registerByMobile(mobile,password,invite):
        # 连接account测试服务器
        consulAccountHost = FMCommon.consul_operater(host=userData['consulHost'], port=userData['consulPort'],
                                                     server='followme.srv.account', key='ServiceAddress')
        consulAccountPort = FMCommon.consul_operater(host=userData['consulHost'], port=userData['consulPort'],
                                                     server='followme.srv.account', key='ServicePort')
        # print(consulAccountHost + ':' + str(consulAccountPort))
        accountChannel = grpc.insecure_channel(consulAccountHost + ':' + str(consulAccountPort))
        accountStub = account_pb2_grpc.AccountSrvStub(accountChannel)

        # 连接dealer测试服务器  http://10.1.0.4:8500
        consulDealerHost = FMCommon.consul_operater(host=userData['consulHost'], port=userData['consulPort'],
                                                    server='followme.srv.copytrade.dealer.pico', key='ServiceAddress')
        consulDealerPort = FMCommon.consul_operater(host=userData['consulHost'], port=userData['consulPort'],
                                                    server='followme.srv.copytrade.dealer.pico', key='ServicePort')
        # print(consulDealerHost + ':' + str(consulDealerPort))
        dealerChannel = grpc.insecure_channel(consulDealerHost + ':' + str(consulDealerPort))
        dealerStub = mt4dealer_pb2_grpc.MT4DealerSrvStub(dealerChannel)

        # 获取图形验证码
        captchaUrl = webApiData['hostName'] + userDataAuthUrl['getCaptcha_url']
        user_token = Account.getTokenForCaptcha(captchaUrl)
        header = {'content-type': 'application/json', 'Authorization': 'Bearer ' + str(user_token)}
        # 读取图形验证码
        ccap = Account.getCaptchaForRedis(user_token)
        # 根据图形验证码获取短信验证码
        smsUrl = webApiData['hostName'] + userDataAuthUrl['getSMSScode_url'] + mobile + '&captcha=' + ccap
        # print(smsUrl)
        '''获取短信验证码成功'''
        smsCode = Account.getSMSCodeForRedis(smsUrl, headers=header, userToken=str(user_token),registerAccount=mobile)

        # 注册
        url = webApiData['hostName'] + userDataAuthUrl['register_url']
        res = Auth.register(url, headers=header, account=mobile,
                            password=password, platform=webApiData['platform'], captcha=str(ccap),
                            smscode=smsCode, invite=invite, oauth2=webApiData['oauth2'])
        # 请求成功,返回200 ok
        userID = json.loads(res.text)["data"]["id"]
        # 设置用户昵称
        setNickName = accountStub.SetNickName(account_pb2.User(Id=userID, NickName="ciStar"+str(userID)))
        # 检查设置成功后,返回值为:0
        return userID
    def test_RegisterByEmail(self):
        for userInfo in load_dict["items"]:
            # print(userInfo["Mobile"])
            # 注册一个测试账号
            print("bind.")

            #获取图形验证码
            captchaUrl = webApiData['hostName'] + userDataAuthUrl[
                'getCaptcha_url']
            self.user_token = Account.getTokenForCaptcha(captchaUrl)
            self.header = {
                'content-type': 'application/json',
                'Authorization': 'Bearer ' + str(self.user_token)
            }
            #读取图形验证码
            self.ccap = Account.getCaptchaForRedis(self.user_token)
            #根据图形验证码获取短信验证码
            smsUrl = webApiData['hostName'] + userDataAuthUrl[
                'getSMSScode_url'] + userInfo[
                    "Mobile"] + '&captcha=' + self.ccap
            # print(smsUrl)
            '''获取短信验证码成功'''
            self.smsCode = Account.getSMSCodeForRedis(
                smsUrl,
                headers=self.header,
                userToken=str(self.user_token),
                registerAccount=userInfo["Mobile"])
            '''注册场景验证'''
            #注册
            url = webApiData['hostName'] + userDataAuthUrl['register_url']
            res = Auth.register(url,
                                headers=self.header,
                                account=userInfo["Mobile"],
                                password=webApiData['registerPwd'],
                                platform=webApiData['platform'],
                                captcha=str(self.ccap),
                                smscode=self.smsCode,
                                invite=webApiData['invite'],
                                oauth2=webApiData['oauth2'])
            #请求成功,返回200 ok
            '''注册成功'''
            self.assertEqual(res.status_code, webApiData['status_code_200'])
            self.userID = json.loads(res.text)["data"]["id"]

            #设置用户昵称
            setNickName = self.accountStub.SetNickName(
                account_pb2.User(Id=self.userID,
                                 NickName=userInfo["NickName"]))
            #检查设置成功后,返回值为:0
            self.assertEqual(setNickName.Success, 0)

            for key in userInfo["AccountList"]:

                if key["bind"] == "true":
                    time.sleep(2)
                    #将注册的用户提取到t_useraccount表
                    #accounttype:Demo = 0,Real = 1,Sam  = 2,Mam  = 3
                    print("select * from ", self.userID, key["BrokerID"],
                          key["Mt4Account"], key["UserType"],
                          key["AccountType"])
                    saveUserAccount = self.accountStub.SaveUserAccount(
                        account_pb2.SaveUserAccountRequest(
                            User=account_pb2.User(Id=self.userID),
                            BrokerID=key["BrokerID"],
                            MT4Account=str(key["Mt4Account"]),
                            IsTrader=key["UserType"],
                            AccountCreateType=0,
                            IsBind=2,
                            AccountType=key["AccountType"]))
                    self.assertEqual(saveUserAccount.Success, 0)

                if key["BrokerID"] == 1:
                    #pico入金
                    print("Deposit")
                    self.dealerStub.DepositWithdraw(
                        mt4dealer_pb2.DepositWithdrawMessage(
                            Login=int(key["Mt4Account"]),
                            Price=999999,
                            Comment='Deposit With script.'))

                if key["BrokerID"] == 5 or key["BrokerID"] == 4:
                    #T_MT4Users表插入数与账号审核
                    sql1 = """INSERT INTO [dbo].[T_MT4Users]
           ([LOGIN],[BrokerID],[ENABLE],[GROUP],[REGDATE],[LASTDATE],[BALANCE],[PREVMONTHBALANCE]
           ,[PREVBALANCE],[CREDIT],[INTERESTRATE],[EQUITY],[MARGIN],[MARGIN_LEVEL],[MARGIN_FREE],[MODIFY_TIME]
           ,[gidt],[ManagerAccount])
     VALUES ('%s',%d,0,NULL,getdate(),getdate(),0,0,0,0,0,0,0,0,0,getdate(),NULL,'')""" % (
                        key["Mt4Account"], key["BrokerID"])
                    #账号升级审核
                    sql2 = """INSERT INTO [FM_OS_V3].[dbo].[U_UserAccountAudit]
           ([UserId],[BrokerId],[IsBind],[UserType],[AuditStatus],[MT4Account],[ManageerAccount],
           [CreateTime],[AuditTime],[BALANCE],[JoinStatus],[Remark],[GetedAccountTime],[BindTime])
     VALUES (%d,%d,0,%d,3,'%s','d16994402',getdate(),getdate(),0,1,NULL,getdate(),getdate())""" % (
                        self.userID, key["BrokerID"], key["UserType"],
                        key["Mt4Account"])
                    time.sleep(1)
                    FMCommon.mssql_operaters(
                        host=webApiData['dataHost'],
                        port=webApiData['dataPost'],
                        database=webApiData['database_V3'],
                        uid=webApiData['dataID'],
                        pwd=webApiData['dataPWD'],
                        sql=sql1)
                    time.sleep(1)
                    FMCommon.mssql_operaters(
                        host=webApiData['dataHost'],
                        port=webApiData['dataPost'],
                        database=webApiData['database_V3'],
                        uid=webApiData['dataID'],
                        pwd=webApiData['dataPWD'],
                        sql=sql2)
    def test_RegisterByEmail(self):
        self.accountEmail = '*****@*****.**'
        self.userPassword = '******'
        self.nickName = 'fsa005555'
        print(self.nickName)
        # 注册一个测试账号
        register = self.accountStub.RegisterByEmail(
            account_pb2.RegisterUserRequest(
                User=account_pb2.User(AccountEmail=self.accountEmail,
                                      UserPassword=self.userPassword)))
        # print(register)
        # #断言帐号状态为5,未激活
        # #AccountStatus: 0 新申请, 1 审核中, 2 正常, 3 锁定(此时交易员才可提取服务费), 4 注销, 5 未激活,6 注销
        self.assertEqual(register.AccountStatus, 5)
        self.assertEqual(register.AccountEmail, self.accountEmail)
        self.userID = register.Id

        #新注册的账号需要先激活才能登录
        #发送验证码邮件到邮箱
        sendActivationEmail = self.accountStub.SendActivationEmail(
            account_pb2.SendActivationEmailRequest(
                UserId=self.userID,
                ActivationCode='thisisactivationcode',
                Email='*****@*****.**',
                Subject='注册followme验证码'))
        #断言验证码邮件发送成功,返回0
        self.assertEqual(sendActivationEmail.Success, 0)
        #获取验证码
        getActivationByObj = self.accountStub.GetActivationByObj(
            account_pb2.ActivationRequest(ObjectId=self.userID))
        vercode = getActivationByObj.VerCode
        activationCode = getActivationByObj.ActivationCode
        #激活账号。
        #AccountStatus: 0 新申请, 1 审核中, 2 正常, 3 锁定(此时交易员才可提取服务费), 4 注销, 5 未激活,6 注销
        validateEmailLink = self.accountStub.ValidateEmailLink(
            account_pb2.ValidateEmailLinkRequest(UserId=self.userID,
                                                 VerCode=vercode,
                                                 ActivationCode=activationCode,
                                                 Token=str(uuid.uuid1())))
        self.assertEqual(validateEmailLink.Success, 0)

        #设置用户昵称
        setNickName = self.accountStub.SetNickName(
            account_pb2.User(Id=self.userID, NickName=self.nickName))
        #检查设置成功后,返回值为:0
        self.assertEqual(setNickName.Success, 0)

        #绑定pico帐号
        bindPico = self.dealerStub.CreateAccount(
            mt4dealer_pb2.Account(Name='DEMO_ACCOUNT_' + str(self.userID),
                                  Password='******',
                                  BrokerID=1,
                                  Group='ct_pico',
                                  City='sz'))
        print(bindPico)
        self.login = bindPico.Login
        self.assertEqual(bindPico.Name, "DEMO_ACCOUNT_" + str(self.userID))
        #断言绑定的经济商为:1. 晋峰
        self.assertEqual(bindPico.BrokerID, 1)

        #将注册的用户提取到t_useraccount表
        #accounttype:Demo = 0,Real = 1,Sam  = 2,Mam  = 3
        saveUserAccount = self.accountStub.SaveUserAccount(
            account_pb2.SaveUserAccountRequest(
                User=account_pb2.User(Id=self.userID),
                BrokerID=1,
                MT4Account=str(self.login),
                IsTrader=0,
                AccountCreateType=0,
                IsBind=2,
                AccountType=1))
        self.assertEqual(saveUserAccount.Success, 0)

        #pico入金
        self.dealerStub.DepositWithdraw(
            mt4dealer_pb2.DepositWithdrawMessage(
                Login=self.login,
                Price=9999999,
                Comment='Deposit With script.'))

        #登录
        self.signinToken = str(uuid.uuid1())
        signin = self.accountStub.Login(
            account_pb2.LoginRequest(
                User=account_pb2.User(AccountEmail=self.accountEmail,
                                      UserPassword=self.userPassword),
                Token=self.signinToken))
        self.assertEqual(signin.Id, self.userID)
        print("signin:>>>>>>>", signin)
Esempio n. 7
0
def getCachedUserById(channel):
    stub = account_pb2_grpc.AccountSrvStub(channel)
    response = stub.GetCachedUserById(account_pb2.User(Id=2))
    print("============Greeter client received: " + response.User.AccountEmail)
Esempio n. 8
0
    def RegisterByEmail():
        ##alibeta 环境连接信息 ++++++++++++++++++++++++++++++++
        #连接account测试服务器
        consulAccountHost = FMCommon.consul_operater(
            host=userData['consulHost'],
            port=userData['consulPort'],
            server='followme.srv.account',
            key='ServiceAddress')
        consulAccountPort = FMCommon.consul_operater(
            host=userData['consulHost'],
            port=userData['consulPort'],
            server='followme.srv.account',
            key='ServicePort')
        accountChannel = grpc.insecure_channel(consulAccountHost + ':' +
                                               str(consulAccountPort))
        accountStub = account_pb2_grpc.AccountSrvStub(accountChannel)
        #连接dealer测试服务器  http://10.1.0.4:8500
        consulDealerHost = FMCommon.consul_operater(
            host=userData['consulHost'],
            port=userData['consulPort'],
            server='followme.srv.copytrade.dealer.pico',
            key='ServiceAddress')
        consulDealerPort = FMCommon.consul_operater(
            host=userData['consulHost'],
            port=userData['consulPort'],
            server='followme.srv.copytrade.dealer.pico',
            key='ServicePort')
        # print(consulDealerHost + ':' + str(consulDealerPort))
        dealerChannel = grpc.insecure_channel(consulDealerHost + ':' +
                                              str(consulDealerPort))
        mt4dealer_pb2_grpc.MT4DealerSrvStub(dealerChannel)

        accountEmail = 'test' + str(int(time.time())) + '@followme-inc.com'
        userPassword = '******'
        nickName = 'Demo' + str(int(time.time()))
        print(nickName)
        # 注册一个测试账号
        register = accountStub.RegisterByEmail(
            account_pb2.RegisterUserRequest(User=account_pb2.User(
                AccountEmail=accountEmail, UserPassword=userPassword)))
        # #断言帐号状态为5,未激活
        # #AccountStatus: 0 新申请, 1 审核中, 2 正常, 3 锁定(此时交易员才可提取服务费), 4 注销, 5 未激活,6 注销
        userID = register.Id

        #新注册的账号需要先激活才能登录
        #发送验证码邮件到邮箱
        accountStub.SendActivationEmail(
            account_pb2.SendActivationEmailRequest(
                UserId=userID,
                ActivationCode='thisisactivationcode',
                Email='*****@*****.**',
                Subject='注册followme验证码'))
        #获取验证码
        getActivationByObj = accountStub.GetActivationByObj(
            account_pb2.ActivationRequest(ObjectId=userID))
        vercode = getActivationByObj.VerCode
        activationCode = getActivationByObj.ActivationCode
        #激活账号。
        #AccountStatus: 0 新申请, 1 审核中, 2 正常, 3 锁定(此时交易员才可提取服务费), 4 注销, 5 未激活,6 注销
        accountStub.ValidateEmailLink(
            account_pb2.ValidateEmailLinkRequest(UserId=userID,
                                                 VerCode=vercode,
                                                 ActivationCode=activationCode,
                                                 Token=str(uuid.uuid1())))

        #设置用户昵称
        accountStub.SetNickName(account_pb2.User(Id=userID, NickName=nickName))
        return accountEmail