Example #1
0
    def test_16(self):
        "推送正式项目数据- 根据sourceId更新软件数据"
        pdata = securityCheck.JSONV2_Request(self.ProjectSysNo)
        sourceId = pdata['sourceId']
        pdata = json.dumps(pdata)
        pres = OpenAPI(method=self.method, data=pdata)
        self.assertEqual(0, pres.json()['code'], "Send OpenAPI Fail")

        data = json.loads(pdata)
        fake = Faker("zh_CN")
        # data = securityCheck.JSONV2_Request(self.ProjectSysNo)
        # 转换UTC时间为本地时间
        for k, v in data.items():
            if isinstance(k, datetime):
                data[k] = data[k].replace(
                    tzinfo=pytz.utc).astimezone(local_timezone)
        data['rectifyDate'] = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
        data['reviewUserName'] = fake.name()

        data = json.dumps(data)
        res = OpenAPI(method=self.method, data=data)
        self.assertEqual(0, res.json()['code'])

        elkLog = elkSearch.elkSoftware(sourceId, self.method)
        self.assertEqual(1, elkLog['uploadStatus'])
Example #2
0
    def test_02(self):
        "推送测试项目数据"
        data = securityCheck.JSONV2_Request(self.ProjectSysNo)
        sourceId = data['sourceId']
        data = json.dumps(data)
        res = OpenAPI(method=self.method, data=data)

        elkLog = elkSearch.elkSoftware(sourceId, self.method)
        self.assertEqual(self.ProjectSysNo, elkLog['projectSysNo'])
        self.assertEqual(0, res.json()['code'])
Example #3
0
    def test_21(self):
        "推送正式项目数据- 项目未添加应用"
        data = securityCheck.JSONV2_Request(10)
        sourceId = data['sourceId']
        data = json.dumps(data)
        res = OpenAPI(method=self.method, data=data)

        elkLog = elkSearch.elkSoftware(sourceId, self.method)
        self.assertEqual(0, res.json()['code'])
        self.assertEqual("不能使用该项目", elkLog['exceptionContent'])
Example #4
0
    def test_06(self):
        "推送正式项目数据- 无checkUserId"
        data = securityCheck.JSONV2_Request(self.ProjectSysNo)
        sourceId = data['sourceId']
        del data['checkUserId']
        data = json.dumps(data)
        res = OpenAPI(method=self.method, data=data)

        elkLog = elkSearch.elkSoftware(sourceId, self.method)
        self.assertEqual(0, res.json()['code'])
        self.assertEqual("checkUserId字段不能为空", elkLog['exceptionContent'])
Example #5
0
    def test_10(self):
        "推送正式项目数据- 字段类型不一致 datetime->string"
        data = securityCheck.JSONV2_Request(self.ProjectSysNo)
        sourceId = data['sourceId']
        data['checkDate'] = 'actualStartTime'
        data = json.dumps(data)
        res = OpenAPI(method=self.method, data=data)

        elkLog = elkSearch.elkSoftware(sourceId, self.method)
        self.assertEqual(0, res.json()['code'])
        self.assertEqual("checkDate字段类型不正确", elkLog['exceptionContent'])
Example #6
0
    def test_22(self):
        """推送正式设备数据-json 格式不正确"""
        data = securityCheck.JSONV2_Request(self.ProjectSysNo)
        sourceId = data['sourceId']
        data = json.dumps(data)
        data = data[:-1]
        res = OpenAPI(method=self.method, data=data)
        self.assertEqual(0, res.json()['code'])

        elkLog = elkSearch.elkSoftware(sourceId, self.method)
        self.assertEqual("json格式不正确", elkLog['exceptionContent'], elkLog)
        self.assertEqual(2, elkLog['uploadStatus'])
Example #7
0
    def test_11(self):
        "推送正式项目数据- 有未定义的节点"
        data = securityCheck.JSONV2_Request(self.ProjectSysNo)
        sourceId = data['sourceId']
        data['undefind_node'] = 'undefind_node'
        data = json.dumps(data)
        res = OpenAPI(method=self.method, data=data)

        elkLog = elkSearch.elkSoftware(sourceId, self.method)
        self.assertEqual(0, res.json()['code'])
        mongoLog = self.mongo.getbySourceId(sourceId, "security_check")
        if 'checkUserList' in mongoLog:
            del mongoLog['checkUserList']
        if 'partitioningList' in mongoLog:
            del mongoLog['partitioningList']
        self.assertEqual(0, res.json()['code'], "Send OpenAPI Fail")
        Mongo_ELK_Match, Mongo_ReqData_Match, ELK_ReqData_Match = Check.dataCheck(
            mongores=mongoLog, elkres=elkLog, reqdata=json.loads(data))
        self.assertTrue(Mongo_ELK_Match, "Mongo_ELK check Fail")
        self.assertTrue(Mongo_ReqData_Match, "Mongo_ReqData check Fail")
        self.assertTrue(ELK_ReqData_Match, "ELK_ReqData check Fail")