##// END OF EJS Templates
tests: fix unit tests and make limited_date validation conditional
ergo -
Show More
@@ -1498,6 +1498,7 b' class TestAPISentryView(object):'
1498 1498 request = pyramid.threadlocal.get_current_request()
1499 1499 context = DummyContext()
1500 1500 context.resource = ApplicationService.by_id(1)
1501 context.resource.allow_permanent_storage = True
1501 1502 request.context = context
1502 1503 request.matched_route = route
1503 1504 request.body = b'eJy1UmFr2zAQ/S0T+7BCLOzYThp/C6xjG6SDLd/GCBf57Ki' \
@@ -1537,6 +1538,7 b' class TestAPISentryView(object):'
1537 1538 })
1538 1539 context = DummyContext()
1539 1540 context.resource = ApplicationService.by_id(1)
1541 context.resource.allow_permanent_storage = True
1540 1542 request.context = context
1541 1543 request.matched_route = route
1542 1544 request.body = SENTRY_RUBY_ENCODED
@@ -1556,6 +1558,7 b' class TestAPISentryView(object):'
1556 1558 request = pyramid.threadlocal.get_current_request()
1557 1559 context = DummyContext()
1558 1560 context.resource = ApplicationService.by_id(1)
1561 context.resource.allow_permanent_storage = True
1559 1562 request.context = context
1560 1563 request.matched_route = route
1561 1564 request.body = json.dumps(SENTRY_PYTHON_PAYLOAD_7).encode('utf8')
@@ -1583,6 +1586,7 b' class TestAPISentryView(object):'
1583 1586 })
1584 1587 context = DummyContext()
1585 1588 context.resource = ApplicationService.by_id(1)
1589 context.resource.allow_permanent_storage = True
1586 1590 request.context = context
1587 1591 request.matched_route = route
1588 1592 request.body = SENTRY_PYTHON_ENCODED
@@ -50,6 +50,12 b' def deferred_utcnow(node, kw):'
50 50 return kw['utcnow']
51 51
52 52
53 @colander.deferred
54 def optional_limited_date(node, kw):
55 if not kw.get('allow_permanent_storage'):
56 return limited_date
57
58
53 59 def lowercase_preparer(input_data):
54 60 """
55 61 Transforms a list of string entries to lowercase
@@ -292,9 +298,11 b' class ReportDetailBaseSchema(colander.MappingSchema):'
292 298 preparer=shortener_factory(1024), missing='')
293 299 ip = colander.SchemaNode(colander.String(), preparer=shortener_factory(39),
294 300 missing=None)
295 start_time = colander.SchemaNode(NonTZDate(), validator=limited_date,
301 start_time = colander.SchemaNode(NonTZDate(),
302 validator=optional_limited_date,
296 303 missing=deferred_utcnow)
297 end_time = colander.SchemaNode(NonTZDate(), validator=limited_date,
304 end_time = colander.SchemaNode(NonTZDate(),
305 validator=optional_limited_date,
298 306 missing=None)
299 307 user_agent = colander.SchemaNode(colander.String(),
300 308 preparer=[shortener_factory(512),
@@ -428,7 +428,9 b' def sentry_compat(request):'
428 428 len(non_pkey_logs)))
429 429 tasks.add_logs.delay(application.resource_id, {}, non_pkey_logs)
430 430 if event_type == ParsedSentryEventType.ERROR_REPORT:
431 schema = ReportSchema_0_5().bind(utcnow=datetime.datetime.utcnow())
431 schema = ReportSchema_0_5().bind(
432 utcnow=datetime.datetime.utcnow(),
433 allow_permanent_storage=application.allow_permanent_storage)
432 434 deserialized_reports = [schema.deserialize(event)]
433 435 rate_limiting(request, application,
434 436 'per_application_reports_rate_limit',
General Comments 0
You need to be logged in to leave comments. Login now