Exemple #1
0
    def test_sendMessage_EMAIL_HardSoftBounce_AfterWhitelisting(
            self, priority, gateway):
        self.nsadminHelper.configureGateway(priority, gateway)
        emailH = "*****@*****.**"
        emailS = "*****@*****.**"
        self.nsObj.whitelistEmailIds([emailH, emailS])
        msgDict = {
            "messageClass": "EMAIL",
            "priority": priority,
            "receiver": emailH,
            "message": "test body",
            "body": "test message body",
            "tags": ["hb"]
        }
        msgObj = NSAdminObject.message(msgDict)
        msgId = self.nsObj.sendMessage(msgObj)
        self.nsadminHelper.assertWithWaitUntil(msgId,
                                               ['RECEIVED_IN_QUEUE', 'SENT'],
                                               'Messages status ACK', 10)

        msgDict = {
            "messageClass": "EMAIL",
            "priority": priority,
            "receiver": emailS,
            "message": "test body",
            "body": "test message body",
            "tags": ["sb"]
        }
        msgObj = NSAdminObject.message(msgDict)
        msgId = self.nsObj.sendMessage(msgObj)
        self.nsadminHelper.assertWithWaitUntil(msgId,
                                               ['RECEIVED_IN_QUEUE', 'SENT'],
                                               'Messages status ACK', 10)
 def test_addCreditsEmail(self):
     creditDetails1 = {
         "orgId": self.orgId,
         "bulkCredits": 200,
         'messageClass': 1
     }
     creditDetails1 = NSAdminObject.OrgCreditDetails(creditDetails1)
     currVal = self.masterNsObj.getCreditDetailsByOrgAndChannel(
         self.orgId, 1, 'test')
     resp1 = self.masterNsObj.addCredits(creditDetails1)
     afterAdd = self.masterNsObj.getCreditDetailsByOrgAndChannel(
         self.orgId, 1, 'test')
     Assertion.constructAssertion(resp1 == True, 'addCredits response')
     Assertion.constructAssertion(
         afterAdd.bulkCredits == currVal.bulkCredits + 200,
         'increase in bulkCredits')
     creditDetails2 = {
         "orgId": self.orgId,
         "bulkCredits": -100,
         'messageClass': 1
     }
     creditDetails2 = NSAdminObject.OrgCreditDetails(creditDetails2)
     resp2 = self.masterNsObj.addCredits(creditDetails2)
     afterDeduc = self.masterNsObj.getCreditDetailsByOrgAndChannel(
         self.orgId, 1, 'test')
     Assertion.constructAssertion(resp2 == True, 'addCredits response')
     Assertion.constructAssertion(
         afterDeduc.bulkCredits == currVal.bulkCredits + 100,
         'decrease in bulkCredits')
Exemple #3
0
 def test_sendMessage_SMS_Eu_Prod_Sanity(self, priority, gateway, tags):
     domainPropertiesId = self.nsadminHelper.addDefaultDomain()
     orgName = constant.config['orgName']
     shortName = orgName + gateway
     connectionProperties = json.dumps(
         {"dlrUrl": constant.config['dlrUrl'] + 'solutionsinfini'})
     properties = json.dumps({"scopes": tags, "countries": ["44"]})
     gatewayOrgConfigs = {
         "orgId": self.orgId,
         "hostName": "solutionsinfini",
         "shortName": shortName,
         "fullName": shortName,
         "username": "******",
         "password": "******",
         "connectionProperties": connectionProperties,
         "serviceIp": "",
         "serviceUrl": "http://global.sinfini.com/api/v0/xmlapi.php",
         "statusCheckUrl": "http://global.sinfini.com/api/v0/xmlapi.php",
         "messageClass": "SMS",
         "messagePriority": priority,
         "properties": properties
     }
     gatewayOrgConfigs = NSAdminObject.gatewayOrgConfigs(gatewayOrgConfigs)
     domainProperties = self.nsObj.getDomainPropertiesByID(
         domainPropertiesId)
     domainPropertiesGatewayMap = {
         "orgId": self.orgId,
         "subDomain": shortName,
         "gatewayOrgConfigs": gatewayOrgConfigs,
         "domainProperties": domainProperties,
         "domainPropertiesId": domainPropertiesId,
     }
     domainPropertiesGatewayMap = NSAdminObject.domainPropertiesGatewayMap(
         domainPropertiesGatewayMap)
     self.nsObj.saveDomainPropertiesGatewayMap(domainPropertiesGatewayMap)
     self.nsadminHelper.domainGatewayValidate()
     msgDict = {
         "messageClass":
         "SMS",
         "receiver":
         constant.config['prodMobile4'],
         "priority":
         priority,
         "message":
         "test message priority " + priority + " cluster:" + self.cluster
     }
     msgObj = NSAdminObject.message(msgDict)
     msgId = self.nsObj.sendMessage(msgObj)
     resp = self.nsadminHelper.assertWithWaitUntil(
         msgId, ['RECEIVED_IN_QUEUE', 'SENT', 'DELIVERED'],
         'Messages status', 10)
     Assertion.constructAssertion(resp.gateway == shortName,
                                  'gateway used for sending')
     Assertion.constructAssertion(resp.priority == priority, 'priority')
Exemple #4
0
    def test_sendMessasge_SMS_InvalidReceiver(self):
        self.nsadminHelper.configureGateway("BULK", "valuefirstmock")
        msgDict = {
            "receiver": "invalid",
            "messageClass": "SMS",
            "priority": "BULK",
            "message": "test message with receiver invalid"
        }
        msgId = self.nsadminHelper.createAndSendMessage(msgDict)
        self.nsadminHelper.assertWithWaitUntil(msgId, ['GTW_NOT_FOUND'],
                                               'Messages status', 10)
        resp = self.nsObj.getMessageSendError(msgId)
        Assertion.constructAssertion("no gw found after checking" in resp,
                                     'Error message without gateway')

        msgDict = {
            "receiver": "",
            "messageClass": "SMS",
            "priority": "BULK",
            "message": "test message with empty receiver"
        }
        resp = self.nsadminHelper.createAndSendMessage(msgDict)
        Assertion.constructAssertion(resp == -1, 'sendMessage output')

        msgDict = {
            "messageClass": "SMS",
            "priority": "BULK",
            "message": "test message with empty receiver"
        }
        msgObj = NSAdminObject.message(msgDict)
        resp = self.nsObj.sendMessage(msgObj)
        Assertion.constructAssertion(resp == -1, 'sendMessage output')
Exemple #5
0
 def test_sendMultipleMessageWithBulkGateway(self):
     self.nsadminHelper.configureGateway('BULK', 'valuefirstmock')
     params = [
         [
             0, "BULK", "test message 1",
             randValues.getRandomMobileNumber(),
             ['RECEIVED_IN_QUEUE', 'SENT']
         ],
         #[1, "BULK",  "test message 2", randValues.getRandomMobileNumber(), ['RECEIVED_IN_QUEUE', 'SENT']],
         #[2, "HIGH",  "test message 3", randValues.getRandomMobileNumber(), ['GTW_NOT_FOUND']]
     ]
     msgObjList = []
     for p in params:
         msgObj = NSAdminObject.message({
             "messageClass": "SMS",
             "inboxId": p[0],
             "priority": p[1],
             "message": p[2],
             "receiver": p[3]
         })
         msgObjList.append(msgObj)
     resp = self.nsObj.sendMultipleMessages(msgObjList)
     for i in range(0, 3):
         msgId = resp[i]
         msgResp = self.nsObj.getMessagesById([msgId])[0]
         #inboxId = msgResp.inboxId
         msgParams = params[i]
         Assertion.constructAssertion(msgResp.status in msgParams[4],
                                      'Messages status')
         Assertion.constructAssertion(msgResp.priority == msgParams[1],
                                      'Messages priority')
         Assertion.constructAssertion(msgResp.message == msgParams[2],
                                      'Message')
         Assertion.constructAssertion(msgResp.receiver == msgParams[3],
                                      'Messages receiver')
 def test_Create_And_Disable_Domain(self):
     contactInfoList = self.nsadminHelper.getDefaultContactInfo('SMS')
     domainName = str(randValues.getRandomMobileNumber())+'_SMS_'+str(self.orgId)
     DomainProperties = {
         'orgId' : self.orgId,
         'domainName' : domainName,
         'description' : domainName,
         'contactInfo' : contactInfoList
     }      
     DomainProperties = NSAdminObject.domainProperties(DomainProperties)
     self.nsObj.insertDomainProperties(DomainProperties)
     domainPropertiesList = self.nsObj.getDomainPropertiesByOrg(self.orgId)
     for k in domainPropertiesList:
         if domainName == k.domainName and len(k.contactInfo) != 0:
             domainID = k.id
             contactInfoId0 = k.contactInfo[0].id
             contactInfoId1 = k.contactInfo[1].id
             break
     DomainProperties.contactInfo[0].value = '919845012346'
     DomainProperties.contactInfo[0].id = contactInfoId0
     DomainProperties.contactInfo[0].domainPropId = domainID
     DomainProperties.contactInfo[1].id = contactInfoId1  
     DomainProperties.contactInfo[1].domainPropId = domainID
     DomainProperties.id = domainID
     self.nsObj.updateDomainProperties(DomainProperties)          
     updatedDP = self.nsObj.getDomainPropertiesByID(domainID)
     Assertion.constructAssertion(updatedDP.contactInfo[0].value == '919845012346', 'updated value')
     self.nsObj.disableDomainProperties(domainID, self.orgId)
     deletedDP = self.nsObj.getDomainPropertiesByID(domainID)          
     Assertion.constructAssertion(deletedDP.domainName == None, 'Diasbled domain')            
Exemple #7
0
    def test_sendMessasge_EMAIL_InvalidReceiver(self):
        self.nsadminHelper.configureGateway("BULK", "localmail_BULK")
        msgDict = {
            "receiver": "invalid",
            "messageClass": "EMAIL",
            "priority": "BULK",
            "message": "test message with receiver invalid"
        }
        msgId = self.nsadminHelper.createAndSendMessage(msgDict)
        self.nsadminHelper.assertWithWaitUntil(msgId, ['BLOCKED'],
                                               'Messages status ACK', 10)

        msgDict = {
            "receiver": "",
            "messageClass": "EMAIL",
            "priority": "BULK",
            "message": "test message with empty receiver"
        }
        resp = self.nsadminHelper.createAndSendMessage(msgDict)
        Assertion.constructAssertion(resp == -1, 'sendMessage output')

        msgDict = {
            "messageClass": "EMAIL",
            "priority": "BULK",
            "message": "test message with empty receiver"
        }
        msgObj = NSAdminObject.message(msgDict)
        resp = self.nsObj.sendMessage(msgObj)
        Assertion.constructAssertion(resp == -1, 'sendMessage output')
Exemple #8
0
 def est_ratelimit(
     self, mobileNumber
 ):  # Same number if used will timeout within 24hrs # to be fixed
     self.nsadminHelper.configureGateway('BULK', 'valuefirstmock')
     msgObjList = []
     for i in range(1, 10):
         msgObj = NSAdminObject.message({
             "messageClass": "SMS",
             "inboxId": i,
             "clientId": 113,
             "priority": "BULK",
             "message": "test message " + str(i),
             "receiver": mobileNumber
         })
         msgObjList.append(msgObj)
     self.nsObj.sendMultipleMessages(msgObjList)
     msgObj = NSAdminObject.message({
         "messageClass": "SMS",
         "inboxId": 10,
         "clientId": 113,
         "priority": "BULK",
         "message": "test message 10",
         "receiver": mobileNumber
     })
     nsadminId = self.nsObj.sendMessage(msgObj)
     resp = self.nsadminHelper.waitUntil(nsadminId, ['SENT'])
     if resp:
         Assertion.constructAssertion(resp.requestId != '',
                                      'msg_ref_id is not generated')
     else:
         Assertion.constructAssertion(False, 'Failed to get status SENT')
     msgObj = NSAdminObject.message({
         "messageClass": "SMS",
         "inboxId": 11,
         "clientId": 113,
         "priority": "BULK",
         "message": "test message 11",
         "receiver": mobileNumber
     })
     nsadminId = self.nsObj.sendMessage(msgObj)
     resp = self.nsadminHelper.waitUntil(nsadminId, ['RATE_LIMIT_EXCEEDED'])
     if resp:
         Assertion.constructAssertion(resp.requestId == '',
                                      'msg_ref_id is generated')
     else:
         Assertion.constructAssertion(
             False, 'Failed to get status RATE_LIMIT_EXCEEDED')
Exemple #9
0
 def test_sendMessage_EMAIL_OrgGateway(self, priority, gateway, tags):
     domainPropertiesId = self.nsadminHelper.addDefaultDomain()
     orgName = constant.config['orgName']
     shortName = orgName + gateway
     connectionProperties = json.dumps({})
     properties = json.dumps({"scopes": tags})
     gatewayOrgConfigs = {
         "orgId": self.orgId,
         "hostName": "localmail",
         "shortName": shortName,
         "fullName": shortName,
         "username": "",
         "password": "",
         "connectionProperties": connectionProperties,
         "serviceIp": "",
         "serviceUrl": "",
         "statusCheckUrl": "",
         "messageClass": "EMAIL",
         "messagePriority": priority,
         "properties": properties
     }
     gatewayOrgConfigs = NSAdminObject.gatewayOrgConfigs(gatewayOrgConfigs)
     domainProperties = self.nsObj.getDomainPropertiesByID(
         domainPropertiesId)
     domainPropertiesGatewayMap = {
         "orgId": self.orgId,
         "subDomain": shortName,
         "gatewayOrgConfigs": gatewayOrgConfigs,
         "domainProperties": domainProperties,
         "domainPropertiesId": domainPropertiesId,
     }
     domainPropertiesGatewayMap = NSAdminObject.domainPropertiesGatewayMap(
         domainPropertiesGatewayMap)
     self.nsObj.saveDomainPropertiesGatewayMap(domainPropertiesGatewayMap)
     self.nsadminHelper.domainGatewayValidate()
     msgDict = {
         "messageClass": "EMAIL",
         "priority": priority,
         "message": "test message with priority " + priority
     }
     msgId = self.nsadminHelper.createAndSendMessage(msgDict)
     resp = self.nsadminHelper.assertWithWaitUntil(
         msgId, ['RECEIVED_IN_QUEUE', 'SENT'], 'Messages status ACK', 10)
     Assertion.constructAssertion(resp.gateway == shortName,
                                  'gateway used for sending')
     Assertion.constructAssertion(resp.priority == priority, 'priority')
Exemple #10
0
 def getDefaultContactInfo(self, messageClass, value=''):
     contactInfoObj = []
     if messageClass == 'SMS' or messageClass == 'VOICECALL':
         if value == '':
             value = '919845012345'
         contactInfo = self.constructContactInfo(messageClass, 'gsm_sender_id', value)
         contactInfoObj.append(NSAdminObject.contactInfo(contactInfo))
         contactInfo = self.constructContactInfo(messageClass, 'cdma_sender_id', value)
         contactInfoObj.append(NSAdminObject.contactInfo(contactInfo))
     elif messageClass == 'EMAIL':
         if value == '':
             value = '*****@*****.**'
         contactInfo = self.constructContactInfo(messageClass, 'dmarc_id', value)
         contactInfoObj.append(NSAdminObject.contactInfo(contactInfo))
         contactInfo = self.constructContactInfo(messageClass, 'sender_id', value)
         contactInfoObj.append(NSAdminObject.contactInfo(contactInfo))
         contactInfo = self.constructContactInfo(messageClass, 'reply_to_id', value)
         contactInfoObj.append(NSAdminObject.contactInfo(contactInfo))
     return contactInfoObj
Exemple #11
0
 def test_sendMessage_EMAIL_without_Message(self):
     self.nsadminHelper.configureGateway('BULK', 'localmail_BULK')
     msgDict = {
         "messageClass": "EMAIL",
         "priority": "BULK",
         "receiver": "*****@*****.**",
         "body": "test message without message"
     }
     msgObj = NSAdminObject.message(msgDict)
     resp = self.nsObj.sendMessage(msgObj)
     Assertion.constructAssertion(resp == -1, 'sendMessage output')
Exemple #12
0
    def test_sendMultipleMessageEmailWithBulkGateway(self):
        self.nsadminHelper.configureGateway('BULK', 'localmail_BULK')
        params = [[
            0, "BULK", "test message 1",
            "autoemail" + randValues.getRandomMobileNumber() + "@gmail.com",
            ['RECEIVED_IN_QUEUE', 'SENT']
        ],
                  [
                      1, "BULK", "test message 2", "autoemail" +
                      randValues.getRandomMobileNumber() + "@gmail.com",
                      ['RECEIVED_IN_QUEUE', 'SENT']
                  ],
                  [
                      2, "HIGH", "test message 3", "autoemail" +
                      randValues.getRandomMobileNumber() + "@gmail.com",
                      ['RECEIVED_IN_QUEUE', 'FAILED']
                  ]]
        self.nsObj.whitelistEmailIds(
            [params[0][3], params[1][3], params[2][3]])
        msgObjList = []
        for p in params:
            msgObj = NSAdminObject.message({
                "messageClass": "EMAIL",
                "inboxId": p[0],
                "priority": p[1],
                "message": p[2],
                "receiver": p[3],
                "body": "test body"
            })
            msgObjList.append(msgObj)
        resp = self.nsObj.sendMultipleMessages(msgObjList)
        for i in range(0, 3):
            msgId = resp[i]
            msgResp = self.nsObj.getMessagesById([msgId])[0]
            #inboxId = msgResp.inboxId
            msgParams = params[i]
            Assertion.constructAssertion(msgResp.status in msgParams[4],
                                         'Messages status')
            Assertion.constructAssertion(msgResp.priority == msgParams[1],
                                         'Messages priority')
            Assertion.constructAssertion(msgResp.message == msgParams[2],
                                         'Message')
            Assertion.constructAssertion(msgResp.receiver == msgParams[3],
                                         'Messages receiver')
            currentMonthTable = NSAdminHelper.getDataTableName()
            query = 'select nsadmin_id from ' + currentMonthTable + ' where nsadmin_id=' + str(
                msgId)
            dbResp = dbHelper.queryDB(query, 'nsadmin')
            Assertion.constructAssertion(dbResp[0][0] == msgId, 'Messages id')

        for p in params:
            msg = self.nsObj.getMessagesByReceiver(self.orgId, p[3])
            Assertion.constructAssertion(msg[0].message == p[2],
                                         'Assert getMessagesByReceiver')
Exemple #13
0
 def test_sendMessage_EMAIL_without_Body(self):
     self.nsadminHelper.configureGateway('BULK', 'localmail_BULK')
     msgDict = {
         "messageClass": "EMAIL",
         "priority": "BULK",
         "receiver": "*****@*****.**",
         "message": "test message without body"
     }
     msgObj = NSAdminObject.message(msgDict)
     msgId = self.nsObj.sendMessage(msgObj)
     self.nsadminHelper.assertWithWaitUntil(msgId, ['EMAIL_BODY_EMPTY'],
                                            'Messages status ACK', 10)
Exemple #14
0
 def test_sendMessage_EMAIL_China_Prod_Sanity(self, priority, gateway):
     self.nsadminHelper.configureGateway(priority, gateway)
     msgDict = {
         "messageClass": "EMAIL",
         "priority": priority,
         "receiver": constant.config['prodEmail1'],
         "message": "test message for China cluster " + priority,
         "body": "test body"
     }
     msgObj = NSAdminObject.message(msgDict)
     msgId = self.nsObj.sendMessage(msgObj)
     self.nsadminHelper.assertWithWaitUntil(msgId,
                                            ['RECEIVED_IN_QUEUE', 'SENT'],
                                            'Messages status ACK', 10)
Exemple #15
0
 def test_sendMessage_EMAIL_ScheduledTime(self):
     self.nsadminHelper.configureGateway('BULK', 'localmail_BULK')
     msgDict = {
         "messageClass": "EMAIL",
         "priority": "BULK",
         "receiver": "*****@*****.**",
         "message": "test body",
         "body": "test message body",
         "scheduledTimestamp": int(time.time() + 600) * 1000
     }
     msgObj = NSAdminObject.message(msgDict)
     msgId = self.nsObj.sendMessage(msgObj)
     self.nsadminHelper.assertWithWaitUntil(msgId, ['DELAYED_SCHEDULED'],
                                            'Messages status ACK', 10)
Exemple #16
0
 def saveDomainPropertiesGatewayMap(self, domainPropertiesId, messagePriority, shortName, 
         connectionProperties, gatewayOrgConfigs, priority=1):
     serviceUrl = ''
     if self.messageClass == 'SMS' and self.cluster in constant.dummyGatewayIP:
         serviceUrl = "http://"+constant.dummyGatewayIP[self.cluster]+":5000"
     gatewayOrgConfigs.update({
         "orgId": self.orgId,
         "shortName": shortName,
         "fullName": shortName,
         "username": "",
         "password": "",
         "connectionProperties": connectionProperties,
         "serviceIp": "",
         "serviceUrl": serviceUrl,
         "statusCheckUrl": "",
         "messageClass": self.messageClass,
         "messagePriority": messagePriority,
         
     })
     if not 'hostName' in gatewayOrgConfigs:
         if self.messageClass == 'SMS':
             gatewayOrgConfigs['hostName'] = 'valuefirst'
         elif self.messageClass == 'EMAIL':
             gatewayOrgConfigs['hostName'] = 'localmail'
     gatewayOrgConfigs = NSAdminObject.gatewayOrgConfigs(gatewayOrgConfigs)
     domainProperties = self.nsObj.getDomainPropertiesByID(domainPropertiesId)
     domainPropertiesGatewayMap = {
         "orgId" : self.orgId,
         "subDomain" : shortName,
         "gatewayOrgConfigs" : gatewayOrgConfigs,
         "domainProperties" : domainProperties,
         "domainPropertiesId" : domainPropertiesId,
         "priority" : priority
     }
     domainPropertiesGatewayMap = NSAdminObject.domainPropertiesGatewayMap(domainPropertiesGatewayMap)
     self.nsObj.saveDomainPropertiesGatewayMap(domainPropertiesGatewayMap)
Exemple #17
0
 def test_sendMessage_EMAIL_withSoftBounce_lastFailedOnMoreThanMonth(
         self, priority, gateway):
     self.nsadminHelper.configureGateway(priority, gateway)
     msgDict = {
         "messageClass": "EMAIL",
         "priority": priority,
         "receiver": "*****@*****.**",
         "message": "test body",
         "body": "test message body",
         "tags": ["sb"]
     }
     msgObj = NSAdminObject.message(msgDict)
     msgId = self.nsObj.sendMessage(msgObj)
     self.nsadminHelper.assertWithWaitUntil(msgId,
                                            ['RECEIVED_IN_QUEUE', 'SENT'],
                                            'Messages status ACK', 10)
Exemple #18
0
 def createAndSendMessage(self, msgDict, unique = False):
     if unique == True:
         if msgDict['messageClass'] in ['SMS', 'VOICECALL'] :
             msgDict['receiver'] = randValues.getRandomMobileNumber()
         elif msgDict['messageClass'] == 'EMAIL':
             msgDict['body'] = "test body"
             msgDict['receiver'] = "*****@*****.**"
     else:
         if msgDict['messageClass'] in ['SMS', 'VOICECALL']:
             if not 'receiver' in msgDict:
                 msgDict['receiver'] = "918116645500"
         elif msgDict['messageClass'] == 'EMAIL':
             msgDict['body'] = "test body"
             if not 'receiver' in msgDict:
                 msgDict['receiver'] = "*****@*****.**"
     msgObj = NSAdminObject.message(msgDict)
     return self.nsObj.sendMessage(msgObj)
Exemple #19
0
 def test_getMessagesByUserOrReciever(self):
     mobile = randValues.getRandomMobileNumber()
     testMessage = "test message new"
     msgObj = NSAdminObject.message({
         "messageClass": "SMS",
         "inboxId": 1,
         "priority": "BULK",
         "message": testMessage,
         "receiver": mobile
     })
     nsadminId = self.nsObj.sendMessage(msgObj)
     resp = self.nsObj.getMessagesByReceiver(self.orgId, mobile)
     Assertion.constructAssertion(resp[0].message == testMessage,
                                  'getMessagesByReceiver response')
     resp = self.nsObj.getMessagesByUserOrReciever(self.orgId, '', mobile)
     Assertion.constructAssertion(resp[0].message == testMessage,
                                  'getMessagesByUserOrReciever response')
Exemple #20
0
 def updateCredit(credit=0,channel='EMAIL'):
     try:
         nsObj = NSAdminHelper.getMasterConnObj() if constant.config['cluster'] in ['nightly','staging','china'] else NSAdminHelper.getConnObj(newConnection=True)
         messageClass = 1 if channel == 'EMAIL' else 0
         creditDetails1 = {
             "orgId": int(constant.config['orgId']),
             "bulkCredits": int(credit),
             'messageClass': messageClass
         }
         creditDetails1 = NSAdminObject.OrgCreditDetails(creditDetails1)
         if credit == 0:
             currVal = nsObj.getCreditDetailsByOrgAndChannel(constant.config['orgId'], messageClass, 'test_{}'.format(int(time.time())))
             currVal = int(currVal.bulkCredits) * -1
             creditDetails1.bulkCredits = currVal
         nsObj.addCredits(creditDetails1)
     except Exception,exp:
         raise Exception('NotAbleToUpdateCreditTo:{}'.format(credit))
         Logger.log(exp)
Exemple #21
0
 def insertDomainProperties(self, contactInfoList, domainName = False):
     messageClass = contactInfoList[0].messageClass
     if not domainName:
         orgName = constant.orgDetails[self.cluster][self.orgId]['orgName']
         domainName = orgName+'_'+str(self.orgId)+'_'+messageClass
     if messageClass == 'EMAIL' and '.com' not in domainName:
         domainName += '.com'
     DomainProperties = {
         'orgId' : self.orgId,
         'domainName' : domainName,
         'description' : domainName,
         'contactInfo' : contactInfoList
     }
     DomainProperties = NSAdminObject.domainProperties(DomainProperties)
     self.nsObj.insertDomainProperties(DomainProperties)
     domainPropertiesList = self.nsObj.getDomainPropertiesByOrg(self.orgId)
     for k in domainPropertiesList:
         if domainName == k.domainName and len(k.contactInfo) != 0:
             return k       
Exemple #22
0
 def test_sendMessage_SMS_UseSystemDefaultsGateway_India_More_Prod_Sanity(
         self, priority, gateway):
     self.nsadminHelper.configureGateway(priority, gateway)
     msgDict = {
         "messageClass":
         "SMS",
         "receiver":
         constant.config['prodMobile1'],
         "priority":
         priority,
         "message":
         "test message priority " + priority + " cluster:" + self.cluster
     }
     msgObj = NSAdminObject.message(msgDict)
     msgId = self.nsObj.sendMessage(msgObj)
     resp = self.nsadminHelper.assertWithWaitUntil(
         msgId, ['RECEIVED_IN_QUEUE', 'SENT'], 'Messages status ACK', 10)
     Assertion.constructAssertion(resp.gateway == gateway,
                                  'gateway used for sending')
     Assertion.constructAssertion(resp.priority == priority, 'priority')
Exemple #23
0
 def test_sendMultipleMessage(self):
     self.nsadminHelper.configureGateway('HIGH', 'cardboardfishmock')
     self.nsadminHelper.configureGateway('BULK', 'valuefirstmock')
     mobile1 = randValues.getRandomMobileNumber()
     mobile2 = randValues.getRandomMobileNumber()
     mobile3 = randValues.getRandomMobileNumber()
     params = [[0, "BULK", "test message 1", mobile1],
               [1, "BULK", "test message 2", mobile2],
               [2, "HIGH", "test message 3", mobile3]]
     msgObjList = []
     for p in params:
         msgObj = NSAdminObject.message({
             "messageClass": "SMS",
             "inboxId": p[0],
             "priority": p[1],
             "message": p[2],
             "receiver": p[3]
         })
         msgObjList.append(msgObj)
     resp = self.nsObj.sendMultipleMessages(msgObjList)
     for i in range(0, 3):
         msgId = resp[i]
         msgResp = self.nsObj.getMessagesById([msgId])[0]
         #inboxId = msgResp.inboxId
         msgParams = params[i]
         Assertion.constructAssertion(
             msgResp.status in ['RECEIVED_IN_QUEUE', 'SENT'],
             'Messages status')
         Assertion.constructAssertion(msgResp.priority == msgParams[1],
                                      'Messages priority')
         Assertion.constructAssertion(msgResp.message == msgParams[2],
                                      'Message')
         Assertion.constructAssertion(msgResp.receiver == msgParams[3],
                                      'Messages receiver')
     msg1 = self.nsObj.getMessagesByReceiver(self.orgId, mobile1)[0]
     msg2 = self.nsObj.getMessagesByReceiver(self.orgId, mobile2)[0]
     Assertion.constructAssertion(msg1.message == 'test message 1',
                                  'getMessagesByReceiver Message')
     Assertion.constructAssertion(msg2.message == 'test message 2',
                                  'getMessagesByReceiver Message')
Exemple #24
0
 def test_sendMessage_EMAIL_withHTMLContentAndAttachment(self):
     filePath = constant.rootPath + '/src/modules/nsadmin/html'
     body = FileHelper.readFile(filePath)
     self.nsadminHelper.configureGateway('BULK', 'localmail_BULK')
     msgDict = {
         "messageClass": "EMAIL",
         "priority": "BULK",
         "receiver": "*****@*****.**",
         "message": "test message with html content",
         "body": body,
         "attachmentId": [23303]
     }
     msgObj = NSAdminObject.message(msgDict)
     msgId = self.nsObj.sendMessage(msgObj)
     resp = self.nsadminHelper.assertWithWaitUntil(
         msgId, ['RECEIVED_IN_QUEUE', 'SENT'], 'Messages status ACK', 10)
     currentMonthTable = NSAdminHelper.getDataTableName()
     query = 'select attachment_id from ' + currentMonthTable + ' where nsadmin_id=' + str(
         msgId)
     resp = dbHelper.queryDB(query, 'nsadmin')
     Assertion.constructAssertion(resp[0][0] == '23303',
                                  'Messages attachmentId')
Exemple #25
0
 def test_sendMultipleMessageEmail_India_More_Prod_Sanity(self):
     if self.cluster == 'india':
         self.nsadminHelper.configureGateway('BULK', 'sendgridmail_BULK')
     else:
         self.nsadminHelper.configureGateway('BULK', 'sendgridapac2_BULK')
     params = [[
         0, "BULK", "test message 1 for " + self.cluster,
         constant.config['prodEmail1'], ['RECEIVED_IN_QUEUE', 'SENT']
     ],
               [
                   1, "BULK", "test message 2 for " + self.cluster,
                   constant.config['prodEmail1'],
                   ['RECEIVED_IN_QUEUE', 'SENT']
               ]]
     msgObjList = []
     for p in params:
         msgObj = NSAdminObject.message({
             "messageClass": "EMAIL",
             "inboxId": p[0],
             "priority": p[1],
             "message": p[2],
             "receiver": p[3],
             "body": "test body"
         })
         msgObjList.append(msgObj)
     resp = self.nsObj.sendMultipleMessages(msgObjList)
     for i in range(0, 2):
         msgId = resp[i]
         msgResp = self.nsObj.getMessagesById([msgId])[0]
         msgParams = params[i]
         Assertion.constructAssertion(msgResp.status in msgParams[4],
                                      'Messages status')
         Assertion.constructAssertion(msgResp.priority == msgParams[1],
                                      'Messages priority')
         Assertion.constructAssertion(msgResp.message == msgParams[2],
                                      'Message')
         Assertion.constructAssertion(msgResp.receiver == msgParams[3],
                                      'Messages receiver')
Exemple #26
0
 def test_sendMessage_SMS_China_Prod_Sanity(self, priority, gateway,
                                            username, tags):
     domainPropertiesId = self.nsadminHelper.addDefaultDomain()
     orgName = constant.config['orgName']
     shortName = orgName + gateway
     connectionProperties = json.dumps({
         "account":
         username,
         "apiKey":
         "203dfd2c4eb6f8eed0889bef5d7aa646",
         "factory":
         gateway,
         "dlrUrl":
         constant.config['dlrUrl'] + gateway
     })
     properties = json.dumps({"scopes": tags, "countries": ["86"]})
     gatewayOrgConfigs = {
         "orgId": self.orgId,
         "hostName": gateway,
         "shortName": shortName,
         "fullName": shortName,
         "username": username,
         "password": "******",
         "connectionProperties": connectionProperties,
         "serviceIp": "",
         "serviceUrl": "http://202.91.244.252:30001/yqx/v1/sms/multi_send",
         "statusCheckUrl":
         "http://202.91.244.252:30001/yqx/v1/sms/multi_send",
         "messageClass": "SMS",
         "messagePriority": priority,
         "properties": properties
     }
     gatewayOrgConfigs = NSAdminObject.gatewayOrgConfigs(gatewayOrgConfigs)
     domainProperties = self.nsObj.getDomainPropertiesByID(
         domainPropertiesId)
     domainPropertiesGatewayMap = {
         "orgId": self.orgId,
         "subDomain": shortName,
         "gatewayOrgConfigs": gatewayOrgConfigs,
         "domainProperties": domainProperties,
         "domainPropertiesId": domainPropertiesId,
     }
     domainPropertiesGatewayMap = NSAdminObject.domainPropertiesGatewayMap(
         domainPropertiesGatewayMap)
     self.nsObj.saveDomainPropertiesGatewayMap(domainPropertiesGatewayMap)
     self.nsadminHelper.domainGatewayValidate()
     msgDict = {
         "messageClass":
         "SMS",
         "receiver":
         constant.config['prodMobile3'],
         "priority":
         priority,
         "message":
         "test message priority " + priority + " cluster:" + self.cluster
     }
     msgObj = NSAdminObject.message(msgDict)
     msgId = self.nsObj.sendMessage(msgObj)
     resp = self.nsadminHelper.assertWithWaitUntil(
         msgId, ['RECEIVED_IN_QUEUE', 'SENT', 'DELIVERED'],
         'Messages status ACK', 10)
     Assertion.constructAssertion(resp.gateway == shortName,
                                  'gateway used for sending')
     Assertion.constructAssertion(resp.priority == priority, 'priority')