def test_Login_nullAccount(self): #新注册的账号需要先激活才能登录 #发送验证码邮件到邮箱 sendActivationEmail = self.stub.SendActivationEmail( account_pb2.SendActivationEmailRequest( UserId=self.accountID, ActivationCode=userData['ActivationCode'], Email=userData['SendActivationEmail'], Subject=userData['Subject'])) #断言验证码邮件发送成功,返回0 self.assertEqual(sendActivationEmail.Success, 0) #获取验证码 getActivationByObj = self.stub.GetActivationByObj( account_pb2.ActivationRequest(ObjectId=self.accountID)) vercode = getActivationByObj.VerCode activationCode = getActivationByObj.ActivationCode #激活账号。 #AccountStatus: 0 新申请, 1 审核中, 2 正常, 3 锁定(此时交易员才可提取服务费), 4 注销, 5 未激活,6 注销 validateEmailLink = self.stub.ValidateEmailLink( account_pb2.ValidateEmailLinkRequest(UserId=self.accountID, VerCode=vercode, ActivationCode=activationCode, Token=str(uuid.uuid1()))) self.assertEqual(validateEmailLink.Success, 0) #账号为空,返回无效的用户 self.assertRaisesRegex( grpc._channel._Rendezvous, userData['UserInvalid_returnCode'], self.stub.Login, account_pb2.LoginRequest( User=account_pb2.User(UserPassword='******'), Token=str(uuid.uuid1())))
def test_SendActivationEmail(self): #发送验证码邮件到邮箱 sendActivationEmail = self.stub.SendActivationEmail( account_pb2.SendActivationEmailRequest( UserId=self.accountID, ActivationCode=userData['ActivationCode'], Email=userData['SendActivationEmail'], Subject=userData['Subject'])) #断言验证码邮件发送成功,返回0 self.assertEqual(sendActivationEmail.Success, 0) #获取验证码 getActivationByObj = self.stub.GetActivationByObj( account_pb2.ActivationRequest(ObjectId=self.accountID)) vercode = getActivationByObj.VerCode activationCode = getActivationByObj.ActivationCode self.assertEqual(getActivationByObj.ActivationCode, userData['ActivationCode']) #激活账号。 #AccountStatus: 0 新申请, 1 审核中, 2 正常, 3 锁定(此时交易员才可提取服务费), 4 注销, 5 未激活,6 注销 validateEmailLink = self.stub.ValidateEmailLink( account_pb2.ValidateEmailLinkRequest(UserId=self.accountID, VerCode=vercode, ActivationCode=activationCode, Token=str(uuid.uuid1()))) self.assertEqual(validateEmailLink.Success, 0)
def test_Login(self): #新注册的账号需要先激活才能登录 #发送验证码邮件到邮箱 sendActivationEmail = self.stub.SendActivationEmail( account_pb2.SendActivationEmailRequest( UserId=self.accountID, ActivationCode=userData['ActivationCode'], Email=userData['SendActivationEmail'], Subject=userData['Subject'])) #断言验证码邮件发送成功,返回0 self.assertEqual(sendActivationEmail.Success, 0) #获取验证码 getActivationByObj = self.stub.GetActivationByObj( account_pb2.ActivationRequest(ObjectId=self.accountID)) vercode = getActivationByObj.VerCode activationCode = getActivationByObj.ActivationCode #激活账号。 #AccountStatus: 0 新申请, 1 审核中, 2 正常, 3 锁定(此时交易员才可提取服务费), 4 注销, 5 未激活,6 注销 validateEmailLink = self.stub.ValidateEmailLink( account_pb2.ValidateEmailLinkRequest(UserId=self.accountID, VerCode=vercode, ActivationCode=activationCode, Token=str(uuid.uuid1()))) self.assertEqual(validateEmailLink.Success, 0) #登录成功 Login = self.stub.Login( account_pb2.LoginRequest(User=account_pb2.User( AccountEmail=userData['AccountEmail'], UserPassword=userData['UserPasswd']), Token=str(uuid.uuid1()))) self.assertEqual(Login.Id, self.accountID) self.assertEqual(Login.AccountEmail, userData['AccountEmail'])