Permalink
Browse files

bug 866874 - redirect bp- prefix on crash_id

  • Loading branch information...
1 parent 9cbc154 commit 5053fb5b977f8b90f30faf8a953af38d786b87f7 @peterbe peterbe committed Apr 29, 2013
Showing with 110 additions and 0 deletions.
  1. +93 −0 crashstats/crashstats/tests/test_views.py
  2. +12 −0 crashstats/crashstats/views.py
  3. +5 −0 crashstats/settings/base.py
@@ -2192,6 +2192,99 @@ def mocked_get(url, **options):
@mock.patch('requests.post')
@mock.patch('requests.get')
+ def test_report_index_redirect_by_prefix(self, rget, rpost):
+
+ dump = "OS|Mac OS X|10.6.8 10K549\\nCPU|amd64|family 6 mod"
+ comment0 = "This is a comment"
+ email0 = "some@emailaddress.com"
+ url0 = "someaddress.com"
+ email1 = "some@otheremailaddress.com"
+
+ def mocked_get(url, **options):
+ if '/crash_data/' in url and '/datatype/meta/' in url:
+ return Response("""
+ {
+ "InstallTime": "1339289895",
+ "FramePoisonSize": "4096",
+ "Theme": "classic/1.0",
+ "Version": "5.0a1",
+ "Email": "%s",
+ "Vendor": "Mozilla",
+ "URL": "%s"
+ }
+ """ % (email0, url0))
+ if 'crashes/comments' in url:
+ return Response("""
+ {
+ "hits": [
+ {
+ "user_comments": "%s",
+ "date_processed": "2012-08-21T11:17:28-07:00",
+ "email": "%s",
+ "uuid": "469bde48-0e8f-3586-d486-b98810120830"
+ }
+ ],
+ "total": 1
+ }
+ """ % (comment0, email1))
+
+ if '/crash_data/' in url and '/datatype/processed' in url:
+ return Response("""
+ {
+ "client_crash_date": "2012-06-11T06:08:45",
+ "dump": "%s",
+ "signature": "FakeSignature1",
+ "user_comments": null,
+ "uptime": 14693,
+ "release_channel": "nightly",
+ "uuid": "11cb72f5-eb28-41e1-a8e4-849982120611",
+ "flash_version": "[blank]",
+ "hangid": null,
+ "distributor_version": null,
+ "truncated": true,
+ "process_type": null,
+ "id": 383569625,
+ "os_version": "10.6.8 10K549",
+ "version": "5.0a1",
+ "build": "20120609030536",
+ "ReleaseChannel": "nightly",
+ "addons_checked": null,
+ "product": "WaterWolf",
+ "os_name": "Mac OS X",
+ "last_crash": 371342,
+ "date_processed": "2012-06-11T06:08:44",
+ "cpu_name": "amd64",
+ "reason": "EXC_BAD_ACCESS / KERN_INVALID_ADDRESS",
+ "address": "0x8",
+ "completeddatetime": "2012-06-11T06:08:57",
+ "success": true
+ }
+ """ % dump)
+
+ raise NotImplementedError(url)
+
+ rget.side_effect = mocked_get
+
+ def mocked_post(url, **options):
+ if '/bugs/' in url:
+ return Response("""
+ {"hits": [{"id": "123456789",
+ "signature": "Something"}]}
+ """)
+ raise NotImplementedError(url)
+
+ rpost.side_effect = mocked_post
+
+ crash_id = (
+ settings.CRASH_ID_PREFIX + '11cb72f5-eb28-41e1-a8e4-849982120611'
+ )
+ assert len(crash_id) > 36
+ url = reverse('crashstats.report_index', args=[crash_id])
+ response = self.client.get(url)
+ eq_(response.status_code, 302)
+
+ @mock.patch('requests.post')
+ @mock.patch('requests.get')
def test_report_list_with_no_data(self, rget, rpost):
def mocked_post(url, **options):
@@ -780,6 +780,18 @@ def report_index(request, crash_id):
if not crash_id:
raise http.Http404("Crash id is missing")
+ # Sometimes, in Socorro we use a prefix on the crash ID. Usually it's
+ # 'bp-' but this is configurable.
+ # If you try to use this to reach the perma link for a crash, it should
+ # redirect to the report index with the correct crash ID.
+ if crash_id.startswith(settings.CRASH_ID_PREFIX):
+ crash_id = crash_id.replace(
+ settings.CRASH_ID_PREFIX,
+ '',
+ 1
+ )
+ return redirect(reverse('crashstats.report_index', args=(crash_id,)))
+
data = {
'crash_id': crash_id
}
@@ -247,3 +247,8 @@
'mail=%(mail)s,o=org,dc=mozilla',
'mail=%(mail)s,o=net,dc=mozillacom',
]
+
+
+# A prefix that is sometimes prefixed on the crash ID when used elsewhere in
+# the socorro eco-system.
+CRASH_ID_PREFIX = 'bp-'

0 comments on commit 5053fb5

Please sign in to comment.