コード例 #1
0
ファイル: test_models.py プロジェクト: awsaba/h1-python
 def setUpClass(cls):
     group_1_blob = load_resource_blob("group")
     cls.group_1a = hydrate_object(group_1_blob)
     cls.group_1b = hydrate_object(group_1_blob)
     group_2_blob = load_resource_blob("group")
     group_2_blob["id"] = "1338"
     cls.group_2 = hydrate_object(group_2_blob)
     cls.report = hydrate_object(load_resource_blob("report"))
コード例 #2
0
ファイル: test_models.py プロジェクト: awsaba/h1-python
 def test_serialize_round_trip_list(self):
     group_blob = load_resource_blob("group")
     group = hydrate_object(group_blob)
     group_list = [group, group]
     round_trip_group_list = json.loads(
         json.dumps(group_list, cls=HackerOneEncoder))
     self.assertEqual(len(round_trip_group_list), 2)
     self.assertDictEqual(round_trip_group_list[0], group_blob)
コード例 #3
0
ファイル: test_models.py プロジェクト: awsaba/h1-python
 def test_serialize_round_trip(self):
     # A model should deserialize to the same JSON as it was
     # originally serialized from
     group_blob = load_resource_blob("group")
     group = hydrate_object(group_blob)
     self.assertIsInstance(group, Group)
     round_trip_group_blob = json.loads(
         json.dumps(group, cls=HackerOneEncoder))
     self.assertDictEqual(round_trip_group_blob, group_blob)
コード例 #4
0
ファイル: test_models.py プロジェクト: awsaba/h1-python
 def test_hydrate_all_objects(self):
     # Try to hydrate every model we know about from the test resources
     for model_type in list_model_types():
         hydrate_object(load_resource_blob(model_type))
コード例 #5
0
def test_report_hydration():
    report = hydrate_object(load_resource_blob("report_322474"))
    assert report.id == '322474'
    assert report.title == "Backup SQL file lingering on https://ops.playtronics.com/"
    assert report.created_at == datetime.strptime(
        "2018-03-05T16:17:42.998 +0000", '%Y-%m-%dT%H:%M:%S.%f %z')
コード例 #6
0
def test_report_cve_activity():
    report = hydrate_object(load_resource_blob("report_322474"))
    assert any(activity.TYPE == "activity-cve-id-added"
               for activity in report.activities)
コード例 #7
0
def test_report_structured_scope():
    report = hydrate_object(load_resource_blob("report_322474"))
    h1_model.add_attributes_to_report(report)
    assert report.structured_scope.asset_type == "APPLE_STORE_APP_ID"
    assert report.structured_scope.asset_identifier == "com.playtronics.PlayTronicsStore"
コード例 #8
0
def test_activity_message(messageclass, message):
    activity = hydrate_object(load_resource_blob(messageclass.TYPE))
    activity_message = messageclass(activity)
    assert activity_message.get_message() == message
コード例 #9
0
def test_report_weakness():
    report = hydrate_object(load_resource_blob("report_322474"))
    h1_model.add_attributes_to_report(report)
    assert report.weakness.name == "Information Disclosure"
コード例 #10
0
def test_report_severity():
    report = hydrate_object(load_resource_blob("report_322474"))
    h1_model.add_attributes_to_report(report)
    assert report.severity.rating == 'critical'
    assert report.severity.score == 10