示例#1
0
class AuthApp(OrgUserDataDocument, ClientTypeDocument):
    """
    开放应用程序,用于做身份认证的
    """

    __collection__ = "auth_app"
    __lazy__ = False

    appid = StringField(max_length=32, unique=True)  # 公钥
    secret = StringField(max_length=32, unique=True)  # 私钥
    callback = StringField()  # 可能是web回调的url或者是回调的app应用包名称,回调的域,用于安全性检查

    async def set_default_tag(self, **kwargs):
        """
        设置默认的标记
        :param kwargs:
        :return:
        """
        client_type = kwargs.get('client_type', None)
        http_req = kwargs.get('http_req', None)

        if list_have_none_mem(*[client_type, http_req]):
            return None

        await self.set_org_user_tag(http_req=http_req)
        self.set_client_type_tag(client_type=client_type)

        # super(AuthApp, self).set_default_rc_tag()
        return True
示例#2
0
class PerformReport(MyDocument):
    """
    性能测试报告,已经作废,在bench中有专门的处理的了:2016-09-10
    waste
    """
    __collection__ = "perform_report"

    server_soft_ware = StringField(max_length=2048)
    server_host_name = StringField(max_length=2048)
    server_port = StringField(max_length=64)
    doc_path = StringField(max_length=2048)
    doc_length = IntField()  # 文档长度,bytes
    con_level = IntField()  # 并发量
    test_time_taken = FloatField()  # 消耗时间 seconds
    complete_req = IntField()  # 完成请求数
    failed_req = IntField()  # 失败请求数
    non_2xx_res = IntField()  # 非2xx请求数
    total_trans = IntField()  # 总传输数据量bytes
    html_trans = IntField()  # 总html传输数据量bytes
    req_per_sec = FloatField()  # 每秒请求量
    time_per_req = FloatField()  # 平均http请求响应时间:ms
    time_per_req_across = FloatField()  # 所有并发请求量耗时(平均事务响应时间):ms
    trans_rate = FloatField()  # 每秒传输数据量,Kbytes/sec

    organization = ReferenceField(
        reference_document_type=Organization)  # 数据所属的组织
示例#3
0
class PenetrationTestData(ProjectDataDocument):
    """
    渗透测试详情
    """
    __collection__ = "penetration_test_data"
    start_time = StringField()
    use_time = FloatField()
    note = StringField()
示例#4
0
class FeedbackMsg(MyDocument):
    """
    feedback
    """

    __collection__ = 'feedback_msg'
    file_path = StringField()  # 文件路径
    msg = StringField()  # msg
示例#5
0
class UnitTestDataDetail(MyDocument):
    """
    api测试详细数据,只记录失败和错误--插入时没有使用
    """
    test_case = StringField(max_length=1024)  # 出错测试用例
    explain = StringField(max_length=1024)  # 目的
    status = StringField(max_length=1024)  # 测试状态,失败或者错误
    note = StringField()  # 详细记录
class User(Document):
    email = StringField(required=True)
    first_name = StringField(max_length=50)
    last_name = StringField(max_length=50)
    is_admin = BooleanField(default=True)

    def __repr__(self):
        return "%s %s <%s>" % (self.first_name, self.last_name, self.email)
示例#7
0
class ShareProjectReport(OrgUserDataDocument, ProjectBaseDocument):
    """
    分享测试项目报告,只有拥有此share的ID流水号的,就可以访问此报告信息,
    永久性的
    """
    __collection__ = 'share_project_report'
    pro_id = StringField()  # 测试项目id
    stoken = StringField()  # 访问此报告时所需要的token串号,share token
    cnt = IntField()  # 被访问的次数
    mark = StringField()  # 关于此分享的备注信息
示例#8
0
class ProjectFeedBack(ProjectDataDocument):
    """
    项目相关的问题反馈
    """

    msg = StringField()
    # images = ListField()  # 图片列表
    # todo 语音和视频
    label = StringField()  # 关于问题的标记
    status = IntField()  # 处理的状态码
示例#9
0
class User(Document):
    __collection__ = "AggregationUser"

    email = StringField(required=True)
    first_name = StringField(max_length=50, default=lambda: "Bernardo")
    last_name = StringField(max_length=50, default="Heynemann")
    is_admin = BooleanField(default=True)
    updated_at = DateTimeField(required=True, auto_now_on_insert=True, auto_now_on_update=True)
    number_of_documents = IntField()
    list_items = ListField(IntField())
示例#10
0
class ProxyipTestData(MyDocument):
    """
    爆破测试
    """
    __collection__ = "proxyip_test_data"
    remoteip = StringField(max_length=1024)
    originalip = StringField(max_length=1024)
    proxyip = StringField(max_length=1024)

    organization = ReferenceField(
        reference_document_type=Organization)  # 数据所属的组织
示例#11
0
class ServiceStatus(MyDocument):
    """
    服务器开放的服务状态
    """
    __collection__ = "service_status"

    info_asset = ReferenceField(reference_document_type=InfoAsset)  # 所属资产,信息资产
    port = IntField()  # 端口号
    protocol = StringField()  # 协议名称
    status = StringField()  # 状态
    version = StringField  # 版本
示例#12
0
class User(Document):
    email = StringField(required=True)
    first_name = StringField(max_length=50, default=lambda: "Bernardo")
    last_name = StringField(max_length=50, default="Heynemann")
    is_admin = BooleanField(default=True)
    website = URLField(default="http://google.com/")
    updated_at = DateTimeField(required=True,
                               auto_now_on_insert=True,
                               auto_now_on_update=True)

    def __repr__(self):
        return "%s %s <%s>" % (self.first_name, self.last_name, self.email)
示例#13
0
class SafetyTestReport(ProjectDataDocument):
    """
    安全测试报告
    """
    __collection__ = "safety_test_report"
    # project_name = StringField()  # 项目名,里面加上版本号,这个并不是具体的内部项目,和其它几种测试数据不同
    hack_tool = StringField()  # 用于hack的软件名称
    total_cnts = IntField()  # 总计次数
    success_cnts = IntField()  # 成功次数
    success_rate = FloatField()  # 成功率,冗余
    time_cycle = FloatField()  # 花费时间:s
    crack_rate = FloatField()  # 破解效率,冗余
    mark = StringField()  # 描述备注
示例#14
0
class LimitTestDataNote(MyDocument):
    """
    api测试详细数据,只记录失败和错误(作废-2016-11-23)
    """
    __collection__ = "limit_test_data_note"
    limittestdata_id = StringField(max_length=1024)
    test_case = StringField(max_length=1024)  # 出错测试用例
    explain = StringField(max_length=1024)  # 目的
    status = StringField(max_length=1024)  # 测试状态,失败或者错误
    note = StringField()  # 详细记录

    organization = ReferenceField(
        reference_document_type=Organization)  # 数据所属的组织
示例#15
0
class ApiTestDataNote(MyDocument):
    """
    api测试详细数据,只记录失败和错误---因为性能问题,取消使用 2016-09-30
    """
    __collection__ = "api_test_data_note"
    apitestdata_id = StringField(max_length=1024)
    test_case = StringField(max_length=1024)  # 出错测试用例
    explain = StringField(max_length=1024)  # 目的
    status = StringField(max_length=1024)  # 测试状态,失败或者错误
    note = StringField()  # 详细记录

    organization = ReferenceField(
        reference_document_type=Organization)  # 数据所属的组织
示例#16
0
class PenetrationTestDataNote(MyDocument):
    """
    渗透测试详情
    """
    __collection__ = "penetration_test_data_note"
    penetration_id = StringField(max_length=1024)
    ip = StringField(max_length=1024)
    details = ListField(ReferenceField(UnitPenetrationTest))
    # SSHRootEmptyPassword = StringField(max_length=1024)
    # RedisEmptyPassword = StringField(max_length=1024)
    # MongoEmptyPassword = StringField(max_length=1024)
    organization = ReferenceField(
        reference_document_type=Organization)  # 数据所属的组织
示例#17
0
class ApiReqDelay(MyDocument):
    """测试接口的延时
    """
    __collection__ = "api_req_delay"

    domain = StringField(max_length=2048)  # ms,基准域
    path = StringField(max_length=2048)  # ms,接口路径及参数
    delay = FloatField()  # ms,请求时间
    http_status = IntField()  # http状态值

    # 数据归属
    project = ReferenceField(reference_document_type=Project)
    project_name = StringField()  # 项目名称,冗余
    organization = ReferenceField(reference_document_type=Organization)
示例#18
0
class CurtainExData(MyDocument):
    """
    Curtain项目的测试数据
    """
    # answer = ListField()
    # track_data = ListField()
    action_user = StringField(max_length=256)
示例#19
0
class ResourceGroup(MyDocument):
    """
    资源套餐组,不同的套餐组有不同的限额
    """
    __collection__ = 'resource_group'
    __lazy__ = False

    name = StringField()  # 小组名称
示例#20
0
class OrgResourceGroupRelation(OrgUserDataDocument):
    """
    组织和资源组的关系,不同的资源组有不同的限额
    """

    __collection__ = 'org_resource_grp_rel'
    __lazy__ = False

    r_grp = ReferenceField(reference_document_type=ResourceGroup)
    rg_name = StringField()  # 冗余
示例#21
0
class OrgResourceCnt(OrgUserDataDocument):
    """
    当前组织使用资源的情况
    """
    __collection__ = 'org_resource_cnt'
    __lazy__ = False

    resource = ReferenceField(reference_document_type=ProductResource)
    r_name = StringField()  # 冗余
    cnt = IntField()
class User(Document):
    email = StringField(required=True)
    first_name = StringField(db_field="whatever",
                             max_length=50,
                             default=lambda: "Bernardo")
    last_name = StringField(max_length=50, default="Heynemann")
    is_admin = BooleanField(default=True)
    website = URLField(default="http://google.com/")
    updated_at = DateTimeField(required=True,
                               auto_now_on_insert=True,
                               auto_now_on_update=True)
    embedded = EmbeddedDocumentField(EmbeddedDocument,
                                     db_field="embedded_document")
    nullable = EmbeddedDocumentField(EmbeddedDocument,
                                     db_field="nullable_embedded_document")
    numbers = ListField(IntField())

    def __repr__(self):
        return "%s %s <%s>" % (self.first_name, self.last_name, self.email)
示例#23
0
class UnitTestData(MyDocument):
    """
    测试数据统计表--插入时没有使用,没有使用ORM
    """
    __collection__ = "unit_test_data"

    pro_version = StringField(max_length=1024)  # 项目版本号:1.2.3.4
    was_successful = BooleanField()  # 是否是成功的
    total = IntField()
    failures = IntField()
    errors = IntField()
    skipped = IntField()
    run_time = FloatField()
    details = ListField(ReferenceField(UnitTestDataDetail))

    # 数据归属
    project = ReferenceField(reference_document_type=Project)  # 测试数据所属的项目
    project_name = StringField()  # 项目名称,冗余
    organization = ReferenceField(
        reference_document_type=Organization)  # 数据所属的组织
示例#24
0
class ResourceGroupLimit(OrgUserDataDocument):
    """
    每个账号的相应的资源的限额
    """

    __collection__ = 'resource_group_limit'
    __lazy__ = False

    resource = ReferenceField(reference_document_type=ProductResource)
    r_name = StringField()  # 冗余 ,资源名称
    limit = IntField()  # 目录创建的数目
示例#25
0
class ApiTestData(ProjectDataDocument):
    """
    测试数据统计表---因为性能问题,取消使用 2016-09-30
    """
    __collection__ = "api_test_data"

    was_successful = BooleanField()  # 是否是成功的
    total = IntField()
    failures = IntField()
    errors = IntField()
    skipped = IntField()
    run_time = StringField(max_length=1024)
示例#26
0
class LimitTestData(MyDocument):
    """
    测试数据统计表
    """
    __collection__ = "limit_test_data"

    # id = ObjectId()
    was_successful = BooleanField()  # 是否是成功的
    total = IntField()
    failures = IntField()
    errors = IntField()
    skipped = IntField()
    run_time = StringField(max_length=1024)

    organization = ReferenceField(
        reference_document_type=Organization)  # 数据所属的组织
示例#27
0
class ProjectDataDocument(OrgDataBaseDocument, MyDocument):
    """
    项目数据
    """
    # 数据归属
    project = ReferenceField(reference_document_type=Project)  # 测试数据所属的项目
    project_name = StringField()  # 项目名称,冗余

    async def set_project_tag(self, project):
        """
        打上项目标记
        :type project:Project
        :return:
        """

        organization = project.organization
        self.project = project
        self.project_name = project.project_name
        self.organization = organization
        self.org_name = organization.name
class Post(Document):
    title = StringField(required=True)
    body = StringField(required=True)

    comments = ListField(EmbeddedDocumentField(Comment))
class CommentNotLazy(Document):
    __lazy__ = False

    text = StringField(required=True)
    user = ReferenceField(User, required=True)
class Comment(Document):
    text = StringField(required=True)
    user = ReferenceField(User, required=True)
示例#31
0
    def test_validate_enforces_strings(self):
        field = StringField(max_length=5)

        expect(field.validate(1)).to_be_false()
示例#32
0
    def test_validate_only_if_not_none(self):
        field = StringField(required=False)

        expect(field.validate(None)).to_be_true()
示例#33
0
    def test_validate_enforces_maxlength(self):
        field = StringField(max_length=5)

        expect(field.validate("-----")).to_be_true()
        expect(field.validate("-----" * 2)).to_be_false()
示例#34
0
 def test_is_empty(self):
     field = StringField()
     expect(field.is_empty(None)).to_be_true()
     expect(field.is_empty("")).to_be_true()
     expect(field.is_empty("123")).to_be_false()