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"))
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)
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)
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))
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')
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)
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"
def test_activity_message(messageclass, message): activity = hydrate_object(load_resource_blob(messageclass.TYPE)) activity_message = messageclass(activity) assert activity_message.get_message() == message
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"
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